alan
6 years ago
5 changed files with 74 additions and 55 deletions
@ -0,0 +1,50 @@
|
||||
import {LinkType} from '@ui/type'; |
||||
import {saveConnection} from './link_set.service'; |
||||
|
||||
const mixinName = 'dec.dcm.minxin.linkset'; |
||||
const Mixin = { |
||||
setConnectionNameErr(err: string) { |
||||
this.model.connectionNameErr = err; |
||||
}, |
||||
setEdit(type: boolean) { |
||||
this.model.linkSelected = { |
||||
...this.model.linkSelected, |
||||
isSelected: type, |
||||
}; |
||||
this.model.linkUpdate = this.model.linkSelected; |
||||
}, |
||||
setCancel() { |
||||
const linkSelected: LinkType = this.model.linkSelected; |
||||
const linkList: LinkType[] = this.model.linkList; |
||||
if (linkSelected.connectionId) { |
||||
this.setEdit(false); |
||||
} else { |
||||
this.model.linkList = [ |
||||
...linkList.filter(item => !!item.connectionId), |
||||
]; |
||||
if (this.model.linkList.length > 0) { |
||||
this.model.linkList[0].isSelected = true; |
||||
this.model.linkSelected = { |
||||
...this.model.linkList[0], |
||||
isSelected: false, |
||||
}; |
||||
} else { |
||||
this.model.linkSelected = {}; |
||||
} |
||||
this.model.linkUpdate = this.model.linkSelected; |
||||
} |
||||
}, |
||||
saveLink() { |
||||
const pluginData = this.model.linkUpdate.text ? BI.Constants.getConstant(`dec.constant.database.conf.connect.form.${this.model.linkUpdate.text.toLowerCase()}.value`) : {}; |
||||
const update = { |
||||
...this.model.linkUpdate, |
||||
...pluginData, |
||||
}; |
||||
saveConnection(update).then(() => { |
||||
this.setEdit(false); |
||||
}); |
||||
}, |
||||
}; |
||||
|
||||
Fix.mixin(mixinName, Mixin); |
||||
export default mixinName; |
@ -1,10 +1,6 @@
|
||||
const className = 'dec.dcm.model.link.set.right.detail'; |
||||
export const Model = BI.inherit(Fix.Model, { |
||||
|
||||
context: ['linkSelected'], |
||||
actions: { |
||||
|
||||
}, |
||||
}); |
||||
BI.model(className, Model); |
||||
export default className; |
||||
|
@ -0,0 +1,20 @@
|
||||
import LinksetMixin from '../../link_set.mixin'; |
||||
import {LinkType} from '@ui/type'; |
||||
const modelName = 'dec.dcm.model.component.right.title'; |
||||
export const Model = BI.inherit(Fix.Model, { |
||||
context: ['linkSelected', 'linkList', 'linkUpdate'], |
||||
mixins: [LinksetMixin], |
||||
actions: { |
||||
onSave() { |
||||
const linkList: LinkType[] = this.model.linkList; |
||||
const result = BI.find(linkList, (idx: number, value: LinkType) => this.model.linkUpdate.connectionName === value.connectionName && value.connectionId !== this.model.linkUpdate.connectionId); |
||||
if (result) { |
||||
this.setConnectionNameErr(BI.i18nText('Dec-Dcm_Connection_Is_Existence')); |
||||
} else { |
||||
this.saveLink(); |
||||
} |
||||
}, |
||||
}, |
||||
}); |
||||
BI.model(modelName, Model); |
||||
export default modelName; |
Loading…
Reference in new issue