Browse Source

refactor: 去除自己绑定的按钮事件

qufenxi
alan 6 years ago
parent
commit
a9f8d64cb3
  1. 4
      private/constants.ts
  2. 6
      src/app/app.component.scss
  3. 19
      src/app/link_set/left/left_item/left.item.component.ts
  4. 27
      src/app/link_set/left/left_item/left.item.icon.component.ts
  5. 11
      src/app/link_set/more/more.link.component.ts
  6. 8
      src/app/link_set/more/more.link.item.component.ts
  7. 1
      src/app/link_set/right/nothing.component.ts
  8. 15
      src/app/link_status/left/left.item.component.ts
  9. 26
      src/app/title/title.component.ts
  10. 9
      src/app/title/title_item/title_item.component.ts

4
private/constants.ts

@ -1 +1,5 @@
export const OTHER_CONNECT = 'other'; export const OTHER_CONNECT = 'other';
export const DEFAULT_INFO = 'DESIGNER';
export const ACTION_DELETE = 'ACTION_DELETE';
export const ACTION_COPY = 'ACTION_COPY';
export const ACTION_TEST = 'ACTION_TEST';

6
src/app/app.component.scss

@ -5,7 +5,7 @@
.title{ .title{
background-color: #fff; background-color: #fff;
border-bottom: 1px solid #e8eaed; border-bottom: 1px solid #e8eaed;
.title-item{ .dec-title-item{
height: 39px; height: 39px;
line-height: 39px; line-height: 39px;
padding-left: 15px; padding-left: 15px;
@ -19,6 +19,10 @@
font-weight: 700; font-weight: 700;
cursor: pointer; cursor: pointer;
} }
.dec-title-item-selected{
color: '#3685f2';
border-bottom: solid 2px #3685f2;
}
.close-button { .close-button {
position: absolute !important; position: absolute !important;
right: 5px; right: 5px;

19
src/app/link_set/left/left_item/left.item.component.ts

@ -1,6 +1,7 @@
import {WidgetType, Left, Label, Icon} from '@ui'; import {WidgetType, Left, Label, Icon, TextButton} from '@ui';
import ItemIcon from './left.item.icon.component'; import ItemIcon from './left.item.icon.component';
import Model from '../../link-set.model'; import Model from '../../link-set.model';
import {ACTION_COPY, ACTION_TEST, ACTION_DELETE, DEFAULT_INFO} from '@private/constants';
const className = 'fr.component.linkSet.left.item'; const className = 'fr.component.linkSet.left.item';
const Widget: WidgetType = { const Widget: WidgetType = {
props: { props: {
@ -28,11 +29,14 @@ const Widget: WidgetType = {
title, title,
}, },
{ {
type: Label, type: TextButton,
cls:'link-title', cls:'link-title',
textAlign: 'left', textAlign: 'left',
text: title, text: title,
title, title,
handler: () => {
this.store.setLinkSelected(title);
},
}, },
{ {
type: Left, type: Left,
@ -42,24 +46,27 @@ const Widget: WidgetType = {
type: ItemIcon, type: ItemIcon,
cls: 'link-text-font', cls: 'link-text-font',
title: BI.i18nText('Dec-Dcm_Test_Connection'), title: BI.i18nText('Dec-Dcm_Test_Connection'),
value: ACTION_TEST,
id, id,
}, },
{ {
type: ItemIcon, type: ItemIcon,
cls: 'copy-font', cls: 'copy-font',
title: BI.i18nText('Dec-Dcm_Copy'), title: BI.i18nText('Dec-Dcm_Copy'),
value: ACTION_COPY,
id, id,
}, },
{ {
type: ItemIcon, type: ItemIcon,
cls: 'info-font', cls: 'info-font',
title: `${BI.i18nText('Dec-Dcm_Type')}${text === 'DESIGNER' ? BI.i18nText('Dec-Dcm_Other') : text} \r\n${BI.i18nText('Dec-Dcm_Creator')}${creator}`, title: `${BI.i18nText('Dec-Dcm_Type')}${text === DEFAULT_INFO ? BI.i18nText('Dec-Dcm_Other') : text} \r\n${BI.i18nText('Dec-Dcm_Creator')}${creator}`,
id, id,
}, },
{ {
type: ItemIcon, type: ItemIcon,
cls: 'delete-font', cls: 'delete-font',
title: BI.i18nText('Dec-Dcm_Delete'), title: BI.i18nText('Dec-Dcm_Delete'),
value: ACTION_DELETE,
id, id,
}, },
], ],
@ -68,12 +75,6 @@ const Widget: WidgetType = {
], ],
}; };
}, },
mounted() {
const {title} = this.options;
this.element.on('click', () => {
this.store.setLinkSelected(title);
});
},
}; };
BI.shortcut(className, BI.inherit(BI.Widget, Widget)); BI.shortcut(className, BI.inherit(BI.Widget, Widget));
export default className; export default className;

27
src/app/link_set/left/left_item/left.item.icon.component.ts

@ -1,16 +1,18 @@
import {WidgetType, Icon, BubbleCombo, TextBubblePopupBarView} from '@ui/index'; import {WidgetType, Icon, BubbleCombo, TextBubblePopupBarView, IconButton} from '@ui/index';
import Model from '../../link-set.model'; import Model from '../../link-set.model';
import {ACTION_DELETE} from '@private/constants';
const className = 'fr.component.linkSet.left.item.icon'; const className = 'fr.component.linkSet.left.item.icon';
const Widget: WidgetType = { const Widget: WidgetType = {
_store() { _store() {
return BI.Models.getModel(Model); return BI.Models.getModel(Model);
}, },
render() { render() {
const {cls, title, id} = this.options; const {cls, title, id, value} = this.options;
const that = this; const that = this;
let iconContent: any = null; let iconContent: any = null;
let combo: any = null; let combo: any = null;
if (title === BI.i18nText('Dec-Dcm_Delete')) { if (value === ACTION_DELETE) {
return { return {
type: BubbleCombo, type: BubbleCombo,
direction: 'bottom', direction: 'bottom',
@ -60,27 +62,20 @@ const Widget: WidgetType = {
} }
return { return {
type: Icon, type: IconButton,
cls, cls,
extraCls: 'action-icon', extraCls: 'action-icon',
height: 24, height: 24,
width: 26, width: 26,
title, title,
}; handler: () => {
}, const {value, id, title} = this.options;
mounted() { if (value !== ACTION_DELETE) {
const {title, id} = this.options;
if (title !== BI.i18nText('Dec-Dcm_Delete')) {
this.element.on('click', (event: any) => {
event.stopPropagation();
this.store.onIconClick(title, id); this.store.onIconClick(title, id);
});
} else {
this.element.on('click', (event: any) => {
event.stopPropagation();
});
} }
}, },
}; };
},
};
BI.shortcut(className, BI.inherit(BI.Widget, Widget)); BI.shortcut(className, BI.inherit(BI.Widget, Widget));
export default className; export default className;

11
src/app/link_set/more/more.link.component.ts

@ -43,15 +43,10 @@ const Widget: WidgetType = {
text: item.text, text: item.text,
name: item.databaseType, name: item.databaseType,
selected: text === item.text, selected: text === item.text,
listeners: [ handler: () => {
{ that._renderItems(item.text);
eventName: 'EVENT_SELECT', that.fireEvent('EVENT_SELECT', item.text);
action (text: string) {
that._renderItems(text);
that.fireEvent('EVENT_SELECT', text);
},
}, },
],
}); });
}); });
morkLinkItem.populate(BI.createItems(items)); morkLinkItem.populate(BI.createItems(items));

8
src/app/link_set/more/more.link.item.component.ts

@ -29,12 +29,6 @@ const Widget: WidgetType = {
], ],
}; };
}, },
mounted() {
const {text} = this.options;
this.element.on('click', () => {
this.fireEvent('EVENT_SELECT', text);
});
},
}; };
BI.shortcut(className, BI.inherit(BI.Widget, Widget)); BI.shortcut(className, BI.inherit(BI.BasicButton, Widget));
export default className; export default className;

1
src/app/link_set/right/nothing.component.ts

@ -17,7 +17,6 @@ const Widget: WidgetType = {
}, },
{ {
type:Label, type:Label,
cls: 'Dec-Dcm_Tips',
height: 20, height: 20,
text: BI.i18nText('Dec-Dcm_Connection_Plase_Add_One'), text: BI.i18nText('Dec-Dcm_Connection_Plase_Add_One'),
}, },

15
src/app/link_status/left/left.item.component.ts

@ -1,4 +1,4 @@
import {WidgetType, Left, Label} from '@ui'; import {WidgetType, Left, Label, TextButton} from '@ui';
import Model from './left.model'; import Model from './left.model';
const className = 'fr.component.linkStatus.left.item'; const className = 'fr.component.linkStatus.left.item';
const Widget: WidgetType = { const Widget: WidgetType = {
@ -19,21 +19,18 @@ const Widget: WidgetType = {
extraCls, extraCls,
items: [ items: [
{ {
type: Label, type: TextButton,
cls:'link-title', cls:'link-title',
textAlign: 'left', textAlign: 'left',
text: title, text: title,
title, title,
handler: () => {
this.store.setStatusSelected(title);
},
}, },
], ],
}; };
}, },
mounted() {
const {title} = this.options;
this.element.on('click', () => {
this.store.setStatusSelected(title);
});
},
}; };
BI.shortcut(className, BI.inherit(BI.Widget, Widget)); BI.shortcut(className, BI.inherit(BI.BasicButton, Widget));
export default className; export default className;

26
src/app/title/title.component.ts

@ -1,7 +1,6 @@
import {Left, WidgetType, IconButton} from '@ui/index'; import {Left, WidgetType, IconButton} from '@ui/index';
import TitleItem from './title_item/title_item.component'; import TitleItem from './title_item/title_item.component';
import {isDesigner, closeWindow} from '@shared/crud/crud.request'; import {isDesigner, closeWindow} from '@shared/crud/crud.request';
const tabs = ['Dec-Dcm_Connection_Management', 'Dec-Dcm_Pool_Connection_Management'];
const className = 'fr.title'; const className = 'fr.title';
const Widget: WidgetType = { const Widget: WidgetType = {
render() { render() {
@ -9,12 +8,27 @@ const Widget: WidgetType = {
type: Left, type: Left,
cls: 'title', cls: 'title',
items: [ items: [
...BI.map(tabs, (index: number, text: string) => { {
return {
type: TitleItem, type: TitleItem,
text: BI.i18nText(text), cls: 'dec-title-item-selected',
}; text: BI.i18nText('Dec-Dcm_Connection_Management'),
}), ref: _ref => {
this.ConnectSet = _ref;
},
handler: () => {
this.ConnectSet.select();
},
},
{
type: TitleItem,
text: BI.i18nText('Dec-Dcm_Pool_Connection_Management'),
ref: _ref => {
this.ConnectPool = _ref;
},
handler: () => {
this.ConnectPool.select();
},
},
{ {
type:IconButton, type:IconButton,
cls:'close-button', cls:'close-button',

9
src/app/title/title_item/title_item.component.ts

@ -2,7 +2,7 @@ import {Label} from '@ui';
import tableItemModel from './title_item.model'; import tableItemModel from './title_item.model';
import {getSelectStyle} from './title_item.service'; import {getSelectStyle} from './title_item.service';
const className = 'fr.title.item'; const className = 'fr.title.item';
const Widget = BI.inherit(BI.Widget, { const Widget = BI.inherit(BI.BasicButton, {
props: { props: {
text:'', text:'',
}, },
@ -20,16 +20,13 @@ const Widget = BI.inherit(BI.Widget, {
return { return {
type: Label, type: Label,
cls: 'title-item', cls: 'dec-title-item',
text, text,
}; };
}, },
mounted() { select() {
const {text} = this.options; const {text} = this.options;
this.element.css(getSelectStyle(BI.i18nText('Dec-Dcm_Connection_Management'), text));
this.element.on('click', () => {
this.store.setTab(text); this.store.setTab(text);
});
}, },
}); });
BI.shortcut(className, Widget); BI.shortcut(className, Widget);

Loading…
Cancel
Save