Browse Source

fix: 修复复制数据连接时的bug

master
alan 6 years ago
parent
commit
e4f19cff5e
  1. 70
      src/app/link_set/link-set.model.ts

70
src/app/link_set/link-set.model.ts

@ -14,20 +14,9 @@ const Model: ModelType = {
* @param name
*/
setLinkSelected(name: string) {
if (this.model.linkSelected && this.model.linkSelected.isSelected) {
dialog.confirm('当前设置尚未保存,是否保存?', (isConfirm: boolean) => {
if (isConfirm) {
saveConnection(this.model.linkUpdate).then(() => {
this.setEdit(false);
});
} else {
this.setCancel();
}
this._setLinkSelected(name);
});
} else {
this.noSaveConfirm(() => {
this._setLinkSelected(name);
}
});
},
_setLinkSelected(name: string) {
this.model.linkList.forEach((item: LinkType) => {
@ -55,7 +44,9 @@ const Model: ModelType = {
this._textLink(id);
break;
case '复制':
this.copyLink(id);
this.noSaveConfirm(() => {
this.copyLink(id);
});
break;
default:
break;
@ -83,22 +74,21 @@ const Model: ModelType = {
data = item;
}
});
const newCopy = {
...data,
isSelected: true,
connectionName:name,
connectionId: '',
};
this.model.linkList = [
{
...data,
isSelected: true,
connectionName:name,
},
newCopy,
...this.model.linkList,
];
this.model.linkSelected = {
...data,
isSelected: true,
connectionName:name,
...newCopy,
};
this.model.linkUpdate = {
...data,
connectionName:name,
...newCopy,
};
},
setLinkUpdate(value: any) {
@ -114,7 +104,6 @@ const Model: ModelType = {
setCancel() {
const linkSelected: LinkType = this.model.linkSelected;
const linkList: LinkType[] = this.model.linkList;
if (linkSelected.connectionId) {
this.setEdit(false);
} else {
@ -134,20 +123,9 @@ const Model: ModelType = {
}
},
setNewLink(value: string) {
if (this.model.linkSelected && this.model.linkSelected.isSelected) {
dialog.confirm('当前设置尚未保存,是否保存?', (isConfirm: boolean) => {
if (isConfirm) {
saveConnection(this.model.linkUpdate).then(() => {
this.setEdit(true);
});
} else {
this.setCancel();
}
this._setNewLink(value);
});
} else {
this.noSaveConfirm(() => {
this._setNewLink(value);
}
});
},
_setNewLink(value: string) {
const name = getCnnectionName(this.model.linkList);
@ -178,6 +156,22 @@ const Model: ModelType = {
setConnectionNameErr(err: string) {
this.model.connectionNameErr = err;
},
noSaveConfirm(cb: Function) {
if (this.model.linkSelected && this.model.linkSelected.isSelected) {
dialog.confirm('当前设置尚未保存,是否保存?', (isConfirm: boolean) => {
if (isConfirm) {
saveConnection(this.model.linkUpdate).then(() => {
this.setEdit(true);
});
} else {
this.setCancel();
}
cb();
});
} else {
cb();
}
},
},
};
BI.model(className, BI.inherit(Fix.Model, Model));

Loading…
Cancel
Save