forked from Gitlink/forgeplus-react
复制issue
This commit is contained in:
parent
4971dc0a3d
commit
f6c84e4fad
|
@ -47,14 +47,16 @@ class order_form extends Component {
|
||||||
}
|
}
|
||||||
componentDidMount = () => {
|
componentDidMount = () => {
|
||||||
this.getSelectList();
|
this.getSelectList();
|
||||||
//如果是复制issue则需要将原内容中的@谁录入 @列表中 (在tpm-md-editor.js中其实有处理,但是当用户点击【复制】按钮之后迅速创建issue会有延迟导致@失效)
|
};
|
||||||
if (this.state.form_type === "copy"){
|
|
||||||
let allUser = undefined;
|
copyIssueAtWhoInit = (description) =>{
|
||||||
|
if (description.indexOf("@") !== -1){
|
||||||
|
this.setState({isSpin: true});
|
||||||
|
const { projectsId, owner } = this.props.match.params;
|
||||||
axios.get(`/${owner}/${projectsId}/members.json`).then(response => {
|
axios.get(`/${owner}/${projectsId}/members.json`).then(response => {
|
||||||
|
this.setState({ isSpin: false});
|
||||||
if (response.data.total_count !== 0) {
|
if (response.data.total_count !== 0) {
|
||||||
allUser = response.data.users
|
const allUser = response.data.users;
|
||||||
}
|
|
||||||
})
|
|
||||||
if (allUser && allUser.length !== 0 && description && description.indexOf("@") !== -1) {
|
if (allUser && allUser.length !== 0 && description && description.indexOf("@") !== -1) {
|
||||||
const list = new Set();
|
const list = new Set();
|
||||||
allUser.map(item => {
|
allUser.map(item => {
|
||||||
|
@ -65,7 +67,9 @@ class order_form extends Component {
|
||||||
this.setState({ atWhoLoginList: Array.from(list) });
|
this.setState({ atWhoLoginList: Array.from(list) });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
get_detail = () => {
|
get_detail = () => {
|
||||||
this.setState({
|
this.setState({
|
||||||
|
@ -97,6 +101,9 @@ class order_form extends Component {
|
||||||
due_date: result.data.due_date,
|
due_date: result.data.due_date,
|
||||||
subject: result.data.subject,
|
subject: result.data.subject,
|
||||||
}
|
}
|
||||||
|
if (this.props.form_type === "copy" && result.data.description){
|
||||||
|
this.copyIssueAtWhoInit(result.data.description);
|
||||||
|
}
|
||||||
this.props.form.setFieldsValue({ ...data });
|
this.props.form.setFieldsValue({ ...data });
|
||||||
this.setState({ ...data });
|
this.setState({ ...data });
|
||||||
}
|
}
|
||||||
|
@ -261,8 +268,10 @@ class order_form extends Component {
|
||||||
|
|
||||||
//issue中at谁列表(存储:login)
|
//issue中at谁列表(存储:login)
|
||||||
changeAtWhoLoginList = (loginList) =>{
|
changeAtWhoLoginList = (loginList) =>{
|
||||||
|
let list = new Set(this.state.atWhoLoginList);
|
||||||
|
loginList.map(item => list.add(item));
|
||||||
this.setState({
|
this.setState({
|
||||||
atWhoLoginList:loginList,
|
atWhoLoginList: Array.from(list),
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -374,7 +383,7 @@ class order_form extends Component {
|
||||||
mdID={"order-new-description"}
|
mdID={"order-new-description"}
|
||||||
initValue={description}
|
initValue={description}
|
||||||
onChange={this.onContentChange}
|
onChange={this.onContentChange}
|
||||||
isCanAtme = {form_type}
|
isCanAtme = {true}
|
||||||
changeAtWhoLoginList = {this.changeAtWhoLoginList}
|
changeAtWhoLoginList = {this.changeAtWhoLoginList}
|
||||||
owner = {owner}
|
owner = {owner}
|
||||||
projectsId = {projectsId}
|
projectsId = {projectsId}
|
||||||
|
|
|
@ -106,20 +106,6 @@ export default ({ mdID, onChange, onCMBeforeChange, onCMBlur, error = false, cla
|
||||||
})
|
})
|
||||||
},[])
|
},[])
|
||||||
|
|
||||||
useEffect(()=>{
|
|
||||||
//如果是复制issue则需要将原内容中的@谁录入 @列表中
|
|
||||||
if (isCanAtme === "copy" && initValue && initValue.indexOf("@") !== -1) {
|
|
||||||
allUsers.map(item=>{
|
|
||||||
if (initValue.indexOf(`[@${item.username}](/${item.login})`) !== -1) {
|
|
||||||
const list = new Set(atWhoLoginList.current);
|
|
||||||
list.add(item.login);
|
|
||||||
atWhoLoginList.current = Array.from(list);
|
|
||||||
setAtWhoLoginListState(Array.from(list));
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}, [initValue])
|
|
||||||
|
|
||||||
function onLayout() {
|
function onLayout() {
|
||||||
let ro;
|
let ro;
|
||||||
if (editorEl.current) {
|
if (editorEl.current) {
|
||||||
|
@ -211,7 +197,7 @@ export default ({ mdID, onChange, onCMBeforeChange, onCMBlur, error = false, cla
|
||||||
}
|
}
|
||||||
|
|
||||||
useEffect(()=>{
|
useEffect(()=>{
|
||||||
changeAtWhoLoginList && changeAtWhoLoginList(atWhoLoginList.current);
|
changeAtWhoLoginList && changeAtWhoLoginList(atWhoLoginListState);
|
||||||
},[atWhoLoginListState])
|
},[atWhoLoginListState])
|
||||||
|
|
||||||
const atWhoList = (
|
const atWhoList = (
|
||||||
|
|
Loading…
Reference in New Issue