From 3ccfb07206cf9a1376b1f755e35b8c79ae43aebe Mon Sep 17 00:00:00 2001 From: alan Date: Thu, 30 May 2019 16:28:01 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20=E4=BF=AE=E6=AD=A3=E4=B8=8D?= =?UTF-8?q?=E8=A7=84=E8=8C=83=E7=9A=84=E5=86=99=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- i18n/zh_cn.properties | 2 +- private/i18n.ts | 2 +- src/app/connection/left/item/left_item.ts | 4 +- .../connection/left/item/left_item_delete.ts | 43 +++++++++++++ .../connection/left/item/left_item_icon.ts | 62 ++----------------- src/app/connection/left/left.ts | 7 +-- .../connection/more/item/more_link_item.ts | 6 +- src/app/connection/more/more_link.service.ts | 14 ++--- src/app/connection/more/more_link.ts | 1 - src/app/connection/right/right.ts | 7 +-- .../right/right_detail/right_detail.ts | 2 +- .../connection/right/right_edit/right_edit.ts | 11 ++-- src/app/connection/select/select.ts | 8 +-- src/app/status/left/left.ts | 7 +-- src/app/status/right/right.ts | 14 ++--- src/shared/service/dialog.service.ts | 37 +++-------- 16 files changed, 94 insertions(+), 133 deletions(-) create mode 100644 src/app/connection/left/item/left_item_delete.ts diff --git a/i18n/zh_cn.properties b/i18n/zh_cn.properties index 32d7ec2..13c2e30 100644 --- a/i18n/zh_cn.properties +++ b/i18n/zh_cn.properties @@ -30,7 +30,7 @@ Dec-Dcm_Connection_Option_Cannot_Find= 找不到该连接的配置信息 Dec-Dcm_Connection_Config_No_Save= 当前设置尚未保存,是否保存? Dec-Dcm_Connection_New= 新建数据连接 Dec-Dcm_Connection_More= 更多数据连接... -Dec-Dcm_Connection_More-Title= 更多数据连接 +Dec-Dcm_Connection_More_Title= 更多数据连接 Dec-Dcm_Connection_Other= 其他 Dec-Dcm_Connection_Plase_Add_One= 请选择左侧数据连接或点击新建数据连接 Dec-Dcm_Connection_Is_Existence= 数据连接名已存在 diff --git a/private/i18n.ts b/private/i18n.ts index a5bc85b..03caabc 100644 --- a/private/i18n.ts +++ b/private/i18n.ts @@ -31,7 +31,7 @@ export default { 'Dec-Dcm_Connection_Config_No_Save': '当前设置尚未保存,是否保存?', 'Dec-Dcm_Connection_New': '新建数据连接', 'Dec-Dcm_Connection_More': '更多数据连接...', - 'Dec-Dcm_Connection_More-Title': '更多数据连接', + 'Dec-Dcm_Connection_More_Title': '更多数据连接', 'Dec-Dcm_Connection_Other': '其他', 'Dec-Dcm_Connection_Plase_Add_One': '请选择左侧数据连接或点击新建数据连接', 'Dec-Dcm_Connection_Is_Existence': '数据连接名已存在', diff --git a/src/app/connection/left/item/left_item.ts b/src/app/connection/left/item/left_item.ts index ba31418..ef29d2e 100644 --- a/src/app/connection/left/item/left_item.ts +++ b/src/app/connection/left/item/left_item.ts @@ -1,6 +1,7 @@ import './left_item.less'; import {WidgetType, Icon, TextButton, LeftRightVerticalAdapt} from '@ui'; import ItemIcon from './left_item_icon'; +import ItemDelete from './left_item_delete'; import Model from '../../link_set.model'; import {ACTION_COPY, ACTION_TEST, ACTION_DELETE, DEFAULT_INFO} from '@private/constants'; const className = 'dec.dcm.component.linkSet.left.item'; @@ -33,7 +34,6 @@ const Widget: WidgetType = { }, { type: TextButton, - cls: 'link-title', textHeight: 24, textAlign: 'left', text: title, @@ -62,7 +62,7 @@ const Widget: WidgetType = { id, }, { - type: ItemIcon, + type: ItemDelete, cls: 'link-item-icon dcm-delete-font', title: BI.i18nText('Dec-Dcm_Delete'), value: ACTION_DELETE, diff --git a/src/app/connection/left/item/left_item_delete.ts b/src/app/connection/left/item/left_item_delete.ts new file mode 100644 index 0000000..c21f9f8 --- /dev/null +++ b/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; diff --git a/src/app/connection/left/item/left_item_icon.ts b/src/app/connection/left/item/left_item_icon.ts index d8fd1d5..a597f02 100644 --- a/src/app/connection/left/item/left_item_icon.ts +++ b/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 {ACTION_DELETE} from '@private/constants'; const className = 'dec.dcm.component.linkSet.left.item.icon'; const Widget: WidgetType = { @@ -8,58 +7,7 @@ const Widget: WidgetType = { return BI.Models.getModel(Model); }, render() { - const {title, id, value} = 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', - }); - }, - }], - }; - } + const {title} = this.options; return { type: IconButton, @@ -68,10 +16,8 @@ const Widget: WidgetType = { stopPropagation: true, title, handler: () => { - const {value, id, title} = this.options; - if (value !== ACTION_DELETE) { - this.store.onIconClick(title, id); - } + const {id, title} = this.options; + this.store.onIconClick(title, id); }, }; }, diff --git a/src/app/connection/left/left.ts b/src/app/connection/left/left.ts index d9c2b85..dd4b5a1 100644 --- a/src/app/connection/left/left.ts +++ b/src/app/connection/left/left.ts @@ -4,21 +4,20 @@ import {LinkType} from '@ui/type'; import LeftItem from './item/left_item'; const className = 'dec.dcm.component.linkset.left'; -let leftContent: any = null; const Widget: WidgetType = { _store() { return BI.Models.getModel(Model); }, watch: { linkList(linkList: LinkType[]) { - leftContent.populate(BI.createItems(this._renderItems(linkList))); + this.leftContent.populate(BI.createItems(this._renderItems(linkList))); }, }, render() { return { type: ListView, - ref(_ref: any) { - leftContent = _ref; + ref: _ref => { + this.leftContent = _ref; }, items: this._renderItems(this.model.linkList), }; diff --git a/src/app/connection/more/item/more_link_item.ts b/src/app/connection/more/item/more_link_item.ts index 61e2e17..01a41c3 100644 --- a/src/app/connection/more/item/more_link_item.ts +++ b/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 Widget: WidgetType = { props: { - baseCls: 'dec-webui-dcm-connection-more-link-item', + baseCls: 'dec-webui-dcm-connection-more-link-item bi-border', }, _store() { return BI.Models.getModel(ModelName); @@ -21,9 +21,6 @@ const Widget: WidgetType = { return { type: Vertical, - cls: 'bi-border', - width: 120, - height: 117, items: [ { type: Img, @@ -52,6 +49,7 @@ const Widget: WidgetType = { type: Label, cls: 'bi-header-background', height: 27, + width: 120, text, }, ], diff --git a/src/app/connection/more/more_link.service.ts b/src/app/connection/more/more_link.service.ts index acfac03..c10489c 100644 --- a/src/app/connection/more/more_link.service.ts +++ b/src/app/connection/more/more_link.service.ts @@ -1,12 +1,12 @@ import MoreLink from './more_link'; -let SubbitButton: any = null; +let subbitButton = null; let selectKey = ''; export const moreLink = (onConfirm?: Function): void => { const id = BI.UUID(); BI.Popovers.create(id, { type: 'bi.bar_popover', size: 'normal', - header: BI.i18nText('Dec-Dcm_Connection_More-Title'), + header: BI.i18nText('Dec-Dcm_Connection_More_Title'), width: 560, height: 500, body: { @@ -16,7 +16,7 @@ export const moreLink = (onConfirm?: Function): void => { eventName: 'EVENT_SELECT', action (text: string) { selectKey = text; - SubbitButton.setEnable(true); + subbitButton.setEnable(true); }, }, ], @@ -29,7 +29,7 @@ export const moreLink = (onConfirm?: Function): void => { text: BI.i18nText('BI-Basic_Cancel'), value: 1, level: 'ignore', - handler (v: any) { + handler () { BI.Popovers.close(id); }, }, { @@ -37,10 +37,10 @@ export const moreLink = (onConfirm?: Function): void => { text: BI.i18nText('BI-Basic_Sure'), disabled: true, value: 0, - ref(ref: any) { - SubbitButton = ref; + ref: _ref => { + subbitButton = _ref; }, - handler (v: any) { + handler () { BI.Popovers.close(id); onConfirm ? onConfirm(selectKey) : null; }, diff --git a/src/app/connection/more/more_link.ts b/src/app/connection/more/more_link.ts index bde8e09..b2ce288 100644 --- a/src/app/connection/more/more_link.ts +++ b/src/app/connection/more/more_link.ts @@ -26,7 +26,6 @@ const Widget: WidgetType = { type: Left, scrolly: true, width: 528, - height: 380, tgap: 2, rgap: 2, bgap: 2, diff --git a/src/app/connection/right/right.ts b/src/app/connection/right/right.ts index 16ef861..905be56 100644 --- a/src/app/connection/right/right.ts +++ b/src/app/connection/right/right.ts @@ -3,7 +3,6 @@ import {LinkType} from '@ui/type'; import Nothing from './nothing'; import RightDetail from './right_detail/right_detail'; import Model from '../link_set.model'; -let rightContent: any = null; const className = 'dec.dcm.component.right'; const Widget: WidgetType = { _store() { @@ -11,7 +10,7 @@ const Widget: WidgetType = { }, watch: { linkSelected(linkSelected: LinkType) { - rightContent.populate(BI.createItems([ + this.rightContent.populate(BI.createItems([ { type: (linkSelected && linkSelected.connectionName) ? RightDetail : Nothing, }, @@ -21,8 +20,8 @@ const Widget: WidgetType = { render() { return { type: ListView, - ref(_ref: any) { - rightContent = _ref; + ref: _ref => { + this.rightContent = _ref; }, items: [{ type: Nothing, diff --git a/src/app/connection/right/right_detail/right_detail.ts b/src/app/connection/right/right_detail/right_detail.ts index 3a8b596..d41547c 100644 --- a/src/app/connection/right/right_detail/right_detail.ts +++ b/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 {LinkType} from '@ui/type'; import Title from '../right_title/right_title'; diff --git a/src/app/connection/right/right_edit/right_edit.ts b/src/app/connection/right/right_edit/right_edit.ts index 8393f0b..b2c80fd 100644 --- a/src/app/connection/right/right_edit/right_edit.ts +++ b/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 {CONNECT_CHARSET} from '@private/constants'; import Model from '../../link_set.model'; import FormItem from '@shared/components/form_item'; import Title from '@shared/components/title'; import {getDrivers, connectNameChecker} from './right_edit.service'; -let ConnectionName: any = null; +let connectionName: any = null; const className = 'dec.dcm.component.right.edit'; const Widget: WidgetType = { _store() { @@ -14,7 +14,7 @@ const Widget: WidgetType = { watch: { connectionNameErr(msg: string) { if (msg) { - BI.Bubbles.show('singleBubble', msg, ConnectionName, { + BI.Bubbles.show('singleBubble', msg, connectionName, { level: 'error', }); } else { @@ -35,12 +35,11 @@ const Widget: WidgetType = { text: BI.i18nText('Dec-Dcm_Connection_Form_ConnectionName'), hint: BI.i18nText('Dec-Dcm_Connection_Form_ConnectionName-Change-Confirm'), form: { - type: Editor, - cls: 'bi-border', + type: TextEditor, width: 300, value: linkSelected.connectionName, ref(ref: any) { - ConnectionName = ref; + connectionName = ref; }, listeners: [{ eventName: BI.Editor.EVENT_CHANGE, diff --git a/src/app/connection/select/select.ts b/src/app/connection/select/select.ts index 56a82ed..22854c7 100644 --- a/src/app/connection/select/select.ts +++ b/src/app/connection/select/select.ts @@ -9,8 +9,6 @@ const Widget: WidgetType = { return BI.Models.getModel(selectModel); }, render() { - let combo: any = null; - return { type: Combo, trigger: 'click', @@ -67,11 +65,11 @@ const Widget: WidgetType = { } else { this.store.setNewLink(v); } - combo.hideView(); + this.combo.hideView(); }, }], - ref () { - combo = this; + ref: _ref => { + this.combo = _ref; }, }; }, diff --git a/src/app/status/left/left.ts b/src/app/status/left/left.ts index fa07593..d16451d 100644 --- a/src/app/status/left/left.ts +++ b/src/app/status/left/left.ts @@ -4,7 +4,6 @@ import {LinkType} from '@ui/type'; import LeftItem from './left_item'; const className = 'dec.dcm.component.linkStatus.left'; -let leftContent: any = null; const Widget: WidgetType = { _store() { return BI.Models.getModel(Model); @@ -16,14 +15,14 @@ const Widget: WidgetType = { }, statusSelected(title: string) { const linkList = this.model.linkList; - leftContent.populate(BI.createItems(this._renderItems(linkList, title))); + this.leftContent.populate(BI.createItems(this._renderItems(linkList, title))); }, }, render() { return { type: ListView, - ref(_ref: any) { - leftContent = _ref; + ref: _ref => { + this.leftContent = _ref; }, items: this._renderItems(this.model.linkList, this.model.statusSelected), }; diff --git a/src/app/status/right/right.ts b/src/app/status/right/right.ts index 5e9fa42..ceb454e 100644 --- a/src/app/status/right/right.ts +++ b/src/app/status/right/right.ts @@ -7,8 +7,6 @@ import {LinkType} from '@ui/type'; import pluginListConstant from '../../app.constant'; const className = 'dec.dcm.component.linkStatus.right'; -let Title: any = null; -let Group: any = null; const Widget: WidgetType = { _store() { @@ -21,12 +19,12 @@ const Widget: WidgetType = { 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; info(name, (res: InfoType) => { - Group.populate(BI.createItems([{ + this.statusGroup.populate(BI.createItems([{ type: Pool, ...res, }])); }); - Title.setText(`${BI.i18nText('Dec-Dcm_Data_Connections')}(${title})`); + this.statusTitle.setText(`${BI.i18nText('Dec-Dcm_Data_Connections')}(${title})`); }, }, render() { @@ -47,16 +45,16 @@ const Widget: WidgetType = { text: BI.i18nText('Dec-Dcm_Data_Connections'), }, ], - ref(ref: any) { - Title = ref; + ref: _ref => { + this.statusTitle = _ref; }, }, { type: ListView, cls: 'right-status-body', vgap: 10, hgap: 10, - ref(ref: any) { - Group = ref; + ref: _ref => { + this.statusGroup = _ref; }, }, ], diff --git a/src/shared/service/dialog.service.ts b/src/shared/service/dialog.service.ts index d9eb404..c7ddb77 100644 --- a/src/shared/service/dialog.service.ts +++ b/src/shared/service/dialog.service.ts @@ -131,8 +131,8 @@ class Dialog { } public linkFail(text: string, more: string, cb?: Function): string { - let Popover: any = null; - let More: any = null; + let dialogPopover = null; + let dialogMore = null; const id = BI.UUID(); const that = this; const body = { @@ -168,11 +168,11 @@ class Dialog { text: BI.i18nText('Dec-Dcm_Connection_Detailed_Information'), level: 'ignore', handler() { - const isHide = !More.isVisible(); - Popover.element.css({ + const isHide = !dialogMore.isVisible(); + dialogPopover.element.css({ 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')); }, }, @@ -206,8 +206,8 @@ class Dialog { height: 73, width: 400, value: false, - ref(ref: any) { - More = ref; + ref: _ref => { + dialogMore = _ref; }, }, ], @@ -224,8 +224,8 @@ class Dialog { width: 450, height: 220, items: [body], - ref(ref: any) { - Popover = ref; + ref: _ref => { + dialogPopover = _ref; }, }, }], @@ -242,24 +242,7 @@ class Dialog { public remove(id: string): void{ 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 { const name = BI.UUID();