|
|
|
import {WidgetType, Left, Label, Button} from '@ui/index';
|
|
|
|
import RightTitleModel from './right.title.model';
|
|
|
|
import {LinkType} from '@ui/type';
|
|
|
|
import {addConnection, updateConnection} from '@shared/crud/crud.request';
|
|
|
|
const className = 'fr.component.right.title';
|
|
|
|
const Widget: WidgetType = {
|
|
|
|
_store() {
|
|
|
|
return BI.Models.getModel(RightTitleModel);
|
|
|
|
},
|
|
|
|
render() {
|
|
|
|
const linkSelected: LinkType = this.model.linkSelected;
|
|
|
|
const that = this;
|
|
|
|
const {isEdit} = this.options;
|
|
|
|
|
|
|
|
return {
|
|
|
|
type: Left,
|
|
|
|
height: 40,
|
|
|
|
cls: 'right-title',
|
|
|
|
items: [
|
|
|
|
{
|
|
|
|
type: Label,
|
|
|
|
cls: 'right-title-text',
|
|
|
|
text: `数据连接(${linkSelected.databaseType.toLocaleUpperCase().replace('-', ' ')})`,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
type: Button,
|
|
|
|
cls:'right-title-button',
|
|
|
|
invisible: isEdit,
|
|
|
|
text: '编辑',
|
|
|
|
handler() {
|
|
|
|
that.store.setEdit(true);
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
type: Button,
|
|
|
|
cls:'right-title-button',
|
|
|
|
invisible: !isEdit,
|
|
|
|
text: '保存',
|
|
|
|
handler() {
|
|
|
|
if (that.model.linkUpdate.connectionId) {
|
|
|
|
addConnection(that.model.linkUpdate, (res: string) => {
|
|
|
|
if (res === 'success') {
|
|
|
|
that.store.setEdit(false);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
updateConnection(that.model.linkUpdate, (res: string) => {
|
|
|
|
if (res === 'success') {
|
|
|
|
that.store.setEdit(false);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
type: Button,
|
|
|
|
cls:'right-title-button',
|
|
|
|
invisible: !isEdit,
|
|
|
|
level: 'ignore',
|
|
|
|
text: '取消',
|
|
|
|
handler() {
|
|
|
|
that.store.setEdit(false);
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
],
|
|
|
|
};
|
|
|
|
},
|
|
|
|
};
|
|
|
|
BI.shortcut(className, BI.inherit(BI.Widget, Widget));
|
|
|
|
export default className;
|