Browse Source

refactor: 修正不规范的写法

qufenxi
alan 6 years ago
parent
commit
3ccfb07206
  1. 2
      i18n/zh_cn.properties
  2. 2
      private/i18n.ts
  3. 4
      src/app/connection/left/item/left_item.ts
  4. 43
      src/app/connection/left/item/left_item_delete.ts
  5. 60
      src/app/connection/left/item/left_item_icon.ts
  6. 7
      src/app/connection/left/left.ts
  7. 6
      src/app/connection/more/item/more_link_item.ts
  8. 14
      src/app/connection/more/more_link.service.ts
  9. 1
      src/app/connection/more/more_link.ts
  10. 7
      src/app/connection/right/right.ts
  11. 2
      src/app/connection/right/right_detail/right_detail.ts
  12. 11
      src/app/connection/right/right_edit/right_edit.ts
  13. 8
      src/app/connection/select/select.ts
  14. 7
      src/app/status/left/left.ts
  15. 14
      src/app/status/right/right.ts
  16. 35
      src/shared/service/dialog.service.ts

2
i18n/zh_cn.properties

@ -30,7 +30,7 @@ Dec-Dcm_Connection_Option_Cannot_Find= 找不到该连接的配置信息
Dec-Dcm_Connection_Config_No_Save= 当前设置尚未保存,是否保存? Dec-Dcm_Connection_Config_No_Save= 当前设置尚未保存,是否保存?
Dec-Dcm_Connection_New= 新建数据连接 Dec-Dcm_Connection_New= 新建数据连接
Dec-Dcm_Connection_More= 更多数据连接... Dec-Dcm_Connection_More= 更多数据连接...
Dec-Dcm_Connection_More-Title= 更多数据连接 Dec-Dcm_Connection_More_Title= 更多数据连接
Dec-Dcm_Connection_Other= 其他 Dec-Dcm_Connection_Other= 其他
Dec-Dcm_Connection_Plase_Add_One= 请选择左侧数据连接或点击新建数据连接 Dec-Dcm_Connection_Plase_Add_One= 请选择左侧数据连接或点击新建数据连接
Dec-Dcm_Connection_Is_Existence= 数据连接名已存在 Dec-Dcm_Connection_Is_Existence= 数据连接名已存在

2
private/i18n.ts

@ -31,7 +31,7 @@ export default {
'Dec-Dcm_Connection_Config_No_Save': '当前设置尚未保存,是否保存?', 'Dec-Dcm_Connection_Config_No_Save': '当前设置尚未保存,是否保存?',
'Dec-Dcm_Connection_New': '新建数据连接', 'Dec-Dcm_Connection_New': '新建数据连接',
'Dec-Dcm_Connection_More': '更多数据连接...', 'Dec-Dcm_Connection_More': '更多数据连接...',
'Dec-Dcm_Connection_More-Title': '更多数据连接', 'Dec-Dcm_Connection_More_Title': '更多数据连接',
'Dec-Dcm_Connection_Other': '其他', 'Dec-Dcm_Connection_Other': '其他',
'Dec-Dcm_Connection_Plase_Add_One': '请选择左侧数据连接或点击新建数据连接', 'Dec-Dcm_Connection_Plase_Add_One': '请选择左侧数据连接或点击新建数据连接',
'Dec-Dcm_Connection_Is_Existence': '数据连接名已存在', 'Dec-Dcm_Connection_Is_Existence': '数据连接名已存在',

4
src/app/connection/left/item/left_item.ts

@ -1,6 +1,7 @@
import './left_item.less'; import './left_item.less';
import {WidgetType, Icon, TextButton, LeftRightVerticalAdapt} from '@ui'; import {WidgetType, Icon, TextButton, LeftRightVerticalAdapt} from '@ui';
import ItemIcon from './left_item_icon'; import ItemIcon from './left_item_icon';
import ItemDelete from './left_item_delete';
import Model from '../../link_set.model'; import Model from '../../link_set.model';
import {ACTION_COPY, ACTION_TEST, ACTION_DELETE, DEFAULT_INFO} from '@private/constants'; import {ACTION_COPY, ACTION_TEST, ACTION_DELETE, DEFAULT_INFO} from '@private/constants';
const className = 'dec.dcm.component.linkSet.left.item'; const className = 'dec.dcm.component.linkSet.left.item';
@ -33,7 +34,6 @@ const Widget: WidgetType = {
}, },
{ {
type: TextButton, type: TextButton,
cls: 'link-title',
textHeight: 24, textHeight: 24,
textAlign: 'left', textAlign: 'left',
text: title, text: title,
@ -62,7 +62,7 @@ const Widget: WidgetType = {
id, id,
}, },
{ {
type: ItemIcon, type: ItemDelete,
cls: 'link-item-icon dcm-delete-font', cls: 'link-item-icon dcm-delete-font',
title: BI.i18nText('Dec-Dcm_Delete'), title: BI.i18nText('Dec-Dcm_Delete'),
value: ACTION_DELETE, value: ACTION_DELETE,

43
src/app/connection/left/item/left_item_delete.ts

@ -0,0 +1,43 @@
import {WidgetType, Icon, BubbleCombo, TextBubblePopupBarView} from '@ui';
import Model from '../../link_set.model';
const className = 'dec.dcm.component.linkSet.left.item.icon.delete';
const Widget: WidgetType = {
_store() {
return BI.Models.getModel(Model);
},
render() {
const {title, id} = this.options;
const that = this;
return {
type: BubbleCombo,
stopPropagation: true,
direction: 'bottom',
ref: _ref => {
this.combo = _ref;
},
el: {
type: Icon,
height: 24,
width: 26,
title,
},
popup: {
type: TextBubblePopupBarView,
text: BI.i18nText('Dec-Dcm_Connection_Make_Sure_Delete'),
listeners: [{
eventName: BI.BubblePopupBarView.EVENT_CLICK_TOOLBAR_BUTTON,
action (type: boolean) {
that.combo.hideView();
if (type) {
that.store.onIconClick(title, id);
}
},
}],
},
};
},
};
BI.shortcut(className, BI.inherit(BI.Widget, Widget));
export default className;

60
src/app/connection/left/item/left_item_icon.ts

@ -1,6 +1,5 @@
import {WidgetType, Icon, BubbleCombo, TextBubblePopupBarView, IconButton} from '@ui'; import {WidgetType, IconButton} from '@ui';
import Model from '../../link_set.model'; import Model from '../../link_set.model';
import {ACTION_DELETE} from '@private/constants';
const className = 'dec.dcm.component.linkSet.left.item.icon'; const className = 'dec.dcm.component.linkSet.left.item.icon';
const Widget: WidgetType = { const Widget: WidgetType = {
@ -8,58 +7,7 @@ const Widget: WidgetType = {
return BI.Models.getModel(Model); return BI.Models.getModel(Model);
}, },
render() { render() {
const {title, id, value} = this.options; const {title} = this.options;
const that = this;
let iconContent: any = null;
let combo: any = null;
if (value === ACTION_DELETE) {
return {
type: BubbleCombo,
stopPropagation: true,
direction: 'bottom',
ref () {
combo = this;
},
el: {
type: Icon,
baseCls: 'action-icon',
height: 24,
width: 26,
title,
ref (ref: any) {
iconContent = ref;
},
},
popup: {
type: TextBubblePopupBarView,
text: BI.i18nText('Dec-Dcm_Connection_Make_Sure_Delete'),
listeners: [{
eventName: BI.BubblePopupBarView.EVENT_CLICK_TOOLBAR_BUTTON,
action (type: boolean) {
combo.hideView();
if (type) {
that.store.onIconClick(title, id);
}
},
}],
},
listeners: [{
eventName: BI.BubbleCombo.EVENT_EXPAND,
action () {
iconContent.element.css({
visibility: 'visible',
});
},
}, {
eventName: BI.BubbleCombo.EVENT_AFTER_HIDEVIEW,
action () {
iconContent.element.css({
visibility: 'hidden',
});
},
}],
};
}
return { return {
type: IconButton, type: IconButton,
@ -68,10 +16,8 @@ const Widget: WidgetType = {
stopPropagation: true, stopPropagation: true,
title, title,
handler: () => { handler: () => {
const {value, id, title} = this.options; const {id, title} = this.options;
if (value !== ACTION_DELETE) {
this.store.onIconClick(title, id); this.store.onIconClick(title, id);
}
}, },
}; };
}, },

7
src/app/connection/left/left.ts

@ -4,21 +4,20 @@ import {LinkType} from '@ui/type';
import LeftItem from './item/left_item'; import LeftItem from './item/left_item';
const className = 'dec.dcm.component.linkset.left'; const className = 'dec.dcm.component.linkset.left';
let leftContent: any = null;
const Widget: WidgetType = { const Widget: WidgetType = {
_store() { _store() {
return BI.Models.getModel(Model); return BI.Models.getModel(Model);
}, },
watch: { watch: {
linkList(linkList: LinkType[]) { linkList(linkList: LinkType[]) {
leftContent.populate(BI.createItems(this._renderItems(linkList))); this.leftContent.populate(BI.createItems(this._renderItems(linkList)));
}, },
}, },
render() { render() {
return { return {
type: ListView, type: ListView,
ref(_ref: any) { ref: _ref => {
leftContent = _ref; this.leftContent = _ref;
}, },
items: this._renderItems(this.model.linkList), items: this._renderItems(this.model.linkList),
}; };

6
src/app/connection/more/item/more_link_item.ts

@ -5,7 +5,7 @@ import ModelName from './more_link_litem.model';
const className = 'dec.dcm.component.linkSet.morelink.item'; const className = 'dec.dcm.component.linkSet.morelink.item';
const Widget: WidgetType = { const Widget: WidgetType = {
props: { props: {
baseCls: 'dec-webui-dcm-connection-more-link-item', baseCls: 'dec-webui-dcm-connection-more-link-item bi-border',
}, },
_store() { _store() {
return BI.Models.getModel(ModelName); return BI.Models.getModel(ModelName);
@ -21,9 +21,6 @@ const Widget: WidgetType = {
return { return {
type: Vertical, type: Vertical,
cls: 'bi-border',
width: 120,
height: 117,
items: [ items: [
{ {
type: Img, type: Img,
@ -52,6 +49,7 @@ const Widget: WidgetType = {
type: Label, type: Label,
cls: 'bi-header-background', cls: 'bi-header-background',
height: 27, height: 27,
width: 120,
text, text,
}, },
], ],

14
src/app/connection/more/more_link.service.ts

@ -1,12 +1,12 @@
import MoreLink from './more_link'; import MoreLink from './more_link';
let SubbitButton: any = null; let subbitButton = null;
let selectKey = ''; let selectKey = '';
export const moreLink = (onConfirm?: Function): void => { export const moreLink = (onConfirm?: Function): void => {
const id = BI.UUID(); const id = BI.UUID();
BI.Popovers.create(id, { BI.Popovers.create(id, {
type: 'bi.bar_popover', type: 'bi.bar_popover',
size: 'normal', size: 'normal',
header: BI.i18nText('Dec-Dcm_Connection_More-Title'), header: BI.i18nText('Dec-Dcm_Connection_More_Title'),
width: 560, width: 560,
height: 500, height: 500,
body: { body: {
@ -16,7 +16,7 @@ export const moreLink = (onConfirm?: Function): void => {
eventName: 'EVENT_SELECT', eventName: 'EVENT_SELECT',
action (text: string) { action (text: string) {
selectKey = text; selectKey = text;
SubbitButton.setEnable(true); subbitButton.setEnable(true);
}, },
}, },
], ],
@ -29,7 +29,7 @@ export const moreLink = (onConfirm?: Function): void => {
text: BI.i18nText('BI-Basic_Cancel'), text: BI.i18nText('BI-Basic_Cancel'),
value: 1, value: 1,
level: 'ignore', level: 'ignore',
handler (v: any) { handler () {
BI.Popovers.close(id); BI.Popovers.close(id);
}, },
}, { }, {
@ -37,10 +37,10 @@ export const moreLink = (onConfirm?: Function): void => {
text: BI.i18nText('BI-Basic_Sure'), text: BI.i18nText('BI-Basic_Sure'),
disabled: true, disabled: true,
value: 0, value: 0,
ref(ref: any) { ref: _ref => {
SubbitButton = ref; subbitButton = _ref;
}, },
handler (v: any) { handler () {
BI.Popovers.close(id); BI.Popovers.close(id);
onConfirm ? onConfirm(selectKey) : null; onConfirm ? onConfirm(selectKey) : null;
}, },

1
src/app/connection/more/more_link.ts

@ -26,7 +26,6 @@ const Widget: WidgetType = {
type: Left, type: Left,
scrolly: true, scrolly: true,
width: 528, width: 528,
height: 380,
tgap: 2, tgap: 2,
rgap: 2, rgap: 2,
bgap: 2, bgap: 2,

7
src/app/connection/right/right.ts

@ -3,7 +3,6 @@ import {LinkType} from '@ui/type';
import Nothing from './nothing'; import Nothing from './nothing';
import RightDetail from './right_detail/right_detail'; import RightDetail from './right_detail/right_detail';
import Model from '../link_set.model'; import Model from '../link_set.model';
let rightContent: any = null;
const className = 'dec.dcm.component.right'; const className = 'dec.dcm.component.right';
const Widget: WidgetType = { const Widget: WidgetType = {
_store() { _store() {
@ -11,7 +10,7 @@ const Widget: WidgetType = {
}, },
watch: { watch: {
linkSelected(linkSelected: LinkType) { linkSelected(linkSelected: LinkType) {
rightContent.populate(BI.createItems([ this.rightContent.populate(BI.createItems([
{ {
type: (linkSelected && linkSelected.connectionName) ? RightDetail : Nothing, type: (linkSelected && linkSelected.connectionName) ? RightDetail : Nothing,
}, },
@ -21,8 +20,8 @@ const Widget: WidgetType = {
render() { render() {
return { return {
type: ListView, type: ListView,
ref(_ref: any) { ref: _ref => {
rightContent = _ref; this.rightContent = _ref;
}, },
items: [{ items: [{
type: Nothing, type: Nothing,

2
src/app/connection/right/right_detail/right_detail.ts

@ -1,4 +1,4 @@
import {WidgetType, ListView, Left} from '@ui/index'; import {WidgetType, ListView} from '@ui/index';
import Model from './right_detail.model'; import Model from './right_detail.model';
import {LinkType} from '@ui/type'; import {LinkType} from '@ui/type';
import Title from '../right_title/right_title'; import Title from '../right_title/right_title';

11
src/app/connection/right/right_edit/right_edit.ts

@ -1,11 +1,11 @@
import {WidgetType, Vertical, MultiSelectItem, TextAreaEditor, Editor, Button, TextValueCombo} from '@ui/index'; import {WidgetType, Vertical, MultiSelectItem, TextAreaEditor, Editor, Button, TextValueCombo, TextEditor} from '@ui/index';
import {LinkType} from '@ui/type'; import {LinkType} from '@ui/type';
import {CONNECT_CHARSET} from '@private/constants'; import {CONNECT_CHARSET} from '@private/constants';
import Model from '../../link_set.model'; import Model from '../../link_set.model';
import FormItem from '@shared/components/form_item'; import FormItem from '@shared/components/form_item';
import Title from '@shared/components/title'; import Title from '@shared/components/title';
import {getDrivers, connectNameChecker} from './right_edit.service'; import {getDrivers, connectNameChecker} from './right_edit.service';
let ConnectionName: any = null; let connectionName: any = null;
const className = 'dec.dcm.component.right.edit'; const className = 'dec.dcm.component.right.edit';
const Widget: WidgetType = { const Widget: WidgetType = {
_store() { _store() {
@ -14,7 +14,7 @@ const Widget: WidgetType = {
watch: { watch: {
connectionNameErr(msg: string) { connectionNameErr(msg: string) {
if (msg) { if (msg) {
BI.Bubbles.show('singleBubble', msg, ConnectionName, { BI.Bubbles.show('singleBubble', msg, connectionName, {
level: 'error', level: 'error',
}); });
} else { } else {
@ -35,12 +35,11 @@ const Widget: WidgetType = {
text: BI.i18nText('Dec-Dcm_Connection_Form_ConnectionName'), text: BI.i18nText('Dec-Dcm_Connection_Form_ConnectionName'),
hint: BI.i18nText('Dec-Dcm_Connection_Form_ConnectionName-Change-Confirm'), hint: BI.i18nText('Dec-Dcm_Connection_Form_ConnectionName-Change-Confirm'),
form: { form: {
type: Editor, type: TextEditor,
cls: 'bi-border',
width: 300, width: 300,
value: linkSelected.connectionName, value: linkSelected.connectionName,
ref(ref: any) { ref(ref: any) {
ConnectionName = ref; connectionName = ref;
}, },
listeners: [{ listeners: [{
eventName: BI.Editor.EVENT_CHANGE, eventName: BI.Editor.EVENT_CHANGE,

8
src/app/connection/select/select.ts

@ -9,8 +9,6 @@ const Widget: WidgetType = {
return BI.Models.getModel(selectModel); return BI.Models.getModel(selectModel);
}, },
render() { render() {
let combo: any = null;
return { return {
type: Combo, type: Combo,
trigger: 'click', trigger: 'click',
@ -67,11 +65,11 @@ const Widget: WidgetType = {
} else { } else {
this.store.setNewLink(v); this.store.setNewLink(v);
} }
combo.hideView(); this.combo.hideView();
}, },
}], }],
ref () { ref: _ref => {
combo = this; this.combo = _ref;
}, },
}; };
}, },

7
src/app/status/left/left.ts

@ -4,7 +4,6 @@ import {LinkType} from '@ui/type';
import LeftItem from './left_item'; import LeftItem from './left_item';
const className = 'dec.dcm.component.linkStatus.left'; const className = 'dec.dcm.component.linkStatus.left';
let leftContent: any = null;
const Widget: WidgetType = { const Widget: WidgetType = {
_store() { _store() {
return BI.Models.getModel(Model); return BI.Models.getModel(Model);
@ -16,14 +15,14 @@ const Widget: WidgetType = {
}, },
statusSelected(title: string) { statusSelected(title: string) {
const linkList = this.model.linkList; const linkList = this.model.linkList;
leftContent.populate(BI.createItems(this._renderItems(linkList, title))); this.leftContent.populate(BI.createItems(this._renderItems(linkList, title)));
}, },
}, },
render() { render() {
return { return {
type: ListView, type: ListView,
ref(_ref: any) { ref: _ref => {
leftContent = _ref; this.leftContent = _ref;
}, },
items: this._renderItems(this.model.linkList, this.model.statusSelected), items: this._renderItems(this.model.linkList, this.model.statusSelected),
}; };

14
src/app/status/right/right.ts

@ -7,8 +7,6 @@ import {LinkType} from '@ui/type';
import pluginListConstant from '../../app.constant'; import pluginListConstant from '../../app.constant';
const className = 'dec.dcm.component.linkStatus.right'; const className = 'dec.dcm.component.linkStatus.right';
let Title: any = null;
let Group: any = null;
const Widget: WidgetType = { const Widget: WidgetType = {
_store() { _store() {
@ -21,12 +19,12 @@ const Widget: WidgetType = {
const isPlugin = link.text && BI.some(plugins, (index: number, item: string) => item === link.text); const isPlugin = link.text && BI.some(plugins, (index: number, item: string) => item === link.text);
const Pool = isPlugin ? BI.Constants.getConstant(`dec.constant.database.conf.connect.form.${link.text.toLowerCase()}.pool`) : RightCard; const Pool = isPlugin ? BI.Constants.getConstant(`dec.constant.database.conf.connect.form.${link.text.toLowerCase()}.pool`) : RightCard;
info(name, (res: InfoType) => { info(name, (res: InfoType) => {
Group.populate(BI.createItems([{ this.statusGroup.populate(BI.createItems([{
type: Pool, type: Pool,
...res, ...res,
}])); }]));
}); });
Title.setText(`${BI.i18nText('Dec-Dcm_Data_Connections')}(${title})`); this.statusTitle.setText(`${BI.i18nText('Dec-Dcm_Data_Connections')}(${title})`);
}, },
}, },
render() { render() {
@ -47,16 +45,16 @@ const Widget: WidgetType = {
text: BI.i18nText('Dec-Dcm_Data_Connections'), text: BI.i18nText('Dec-Dcm_Data_Connections'),
}, },
], ],
ref(ref: any) { ref: _ref => {
Title = ref; this.statusTitle = _ref;
}, },
}, { }, {
type: ListView, type: ListView,
cls: 'right-status-body', cls: 'right-status-body',
vgap: 10, vgap: 10,
hgap: 10, hgap: 10,
ref(ref: any) { ref: _ref => {
Group = ref; this.statusGroup = _ref;
}, },
}, },
], ],

35
src/shared/service/dialog.service.ts

@ -131,8 +131,8 @@ class Dialog {
} }
public linkFail(text: string, more: string, cb?: Function): string { public linkFail(text: string, more: string, cb?: Function): string {
let Popover: any = null; let dialogPopover = null;
let More: any = null; let dialogMore = null;
const id = BI.UUID(); const id = BI.UUID();
const that = this; const that = this;
const body = { const body = {
@ -168,11 +168,11 @@ class Dialog {
text: BI.i18nText('Dec-Dcm_Connection_Detailed_Information'), text: BI.i18nText('Dec-Dcm_Connection_Detailed_Information'),
level: 'ignore', level: 'ignore',
handler() { handler() {
const isHide = !More.isVisible(); const isHide = !dialogMore.isVisible();
Popover.element.css({ dialogPopover.element.css({
height: isHide ? '290' : '220', height: isHide ? '290' : '220',
}); });
More.setVisible(isHide); dialogMore.setVisible(isHide);
this.setText(isHide ? BI.i18nText('Dec-Dcm_Connection_Handup_Information') : BI.i18nText('Dec-Dcm_Connection_Detailed_Information')); this.setText(isHide ? BI.i18nText('Dec-Dcm_Connection_Handup_Information') : BI.i18nText('Dec-Dcm_Connection_Detailed_Information'));
}, },
}, },
@ -206,8 +206,8 @@ class Dialog {
height: 73, height: 73,
width: 400, width: 400,
value: false, value: false,
ref(ref: any) { ref: _ref => {
More = ref; dialogMore = _ref;
}, },
}, },
], ],
@ -224,8 +224,8 @@ class Dialog {
width: 450, width: 450,
height: 220, height: 220,
items: [body], items: [body],
ref(ref: any) { ref: _ref => {
Popover = ref; dialogPopover = _ref;
}, },
}, },
}], }],
@ -242,24 +242,7 @@ class Dialog {
public remove(id: string): void{ public remove(id: string): void{
BI.Maskers.remove(id); BI.Maskers.remove(id);
} }
public show1(body: any, autoClose = 0): string {
const id = BI.UUID();
BI.Popovers.create(id, {
type: 'bi.popover',
cls: 'popover-notitle bi-custom-show',
size: 'small',
width: 450,
height: 220,
body,
}).open(id);
if (autoClose > 0) {
setTimeout(() => {
this.close(id);
}, autoClose);
}
return id;
}
public show(body: any, autoClose = 0): string { public show(body: any, autoClose = 0): string {
const name = BI.UUID(); const name = BI.UUID();

Loading…
Cancel
Save