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_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= 数据连接名已存在

2
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': '数据连接名已存在',

4
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,

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 {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) {
const {id, title} = this.options;
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';
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),
};

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 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,
},
],

14
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;
},

1
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,

7
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,

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 {LinkType} from '@ui/type';
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 {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,

8
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;
},
};
},

7
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),
};

14
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;
},
},
],

35
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();

Loading…
Cancel
Save