复制issue

This commit is contained in:
谢思 2021-11-30 16:52:12 +08:00
parent 4971dc0a3d
commit f6c84e4fad
2 changed files with 27 additions and 32 deletions

View File

@ -47,25 +47,29 @@ class order_form extends Component {
}
componentDidMount = () => {
this.getSelectList();
//如果是复制issue则需要将原内容中的@谁录入 @列表中 (在tpm-md-editor.js中其实有处理但是当用户点击【复制】按钮之后迅速创建issue会有延迟导致@失效)
if (this.state.form_type === "copy"){
let allUser = undefined;
axios.get(`/${owner}/${projectsId}/members.json`).then(response=>{
};
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 => {
this.setState({ isSpin: false});
if (response.data.total_count !== 0) {
allUser = response.data.users
const allUser = response.data.users;
if (allUser && allUser.length !== 0 && description && description.indexOf("@") !== -1) {
const list = new Set();
allUser.map(item => {
if (description.indexOf(`[@${item.username}](/${item.login})`) !== -1) {
list.add(item.login);
}
})
this.setState({ atWhoLoginList: Array.from(list) });
}
}
})
if (allUser && allUser.length !== 0 && description && description.indexOf("@") !== -1) {
const list = new Set();
allUser.map(item => {
if (description.indexOf(`[@${item.username}](/${item.login})`) !== -1) {
list.add(item.login);
}
})
this.setState({ atWhoLoginList: Array.from(list)});
}
}
};
}
get_detail = () => {
this.setState({
@ -97,6 +101,9 @@ class order_form extends Component {
due_date: result.data.due_date,
subject: result.data.subject,
}
if (this.props.form_type === "copy" && result.data.description){
this.copyIssueAtWhoInit(result.data.description);
}
this.props.form.setFieldsValue({ ...data });
this.setState({ ...data });
}
@ -261,8 +268,10 @@ class order_form extends Component {
//issue中at谁列表存储login
changeAtWhoLoginList = (loginList) =>{
let list = new Set(this.state.atWhoLoginList);
loginList.map(item => list.add(item));
this.setState({
atWhoLoginList:loginList,
atWhoLoginList: Array.from(list),
});
};
@ -374,7 +383,7 @@ class order_form extends Component {
mdID={"order-new-description"}
initValue={description}
onChange={this.onContentChange}
isCanAtme = {form_type}
isCanAtme = {true}
changeAtWhoLoginList = {this.changeAtWhoLoginList}
owner = {owner}
projectsId = {projectsId}

View File

@ -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() {
let ro;
if (editorEl.current) {
@ -211,7 +197,7 @@ export default ({ mdID, onChange, onCMBeforeChange, onCMBlur, error = false, cla
}
useEffect(()=>{
changeAtWhoLoginList && changeAtWhoLoginList(atWhoLoginList.current);
changeAtWhoLoginList && changeAtWhoLoginList(atWhoLoginListState);
},[atWhoLoginListState])
const atWhoList = (