From 17efecf65be179ec682e2190839c34f6f1e04717 Mon Sep 17 00:00:00 2001 From: alan Date: Sun, 28 Apr 2019 16:25:25 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20=E8=B0=83=E6=95=B4=E6=96=87?= =?UTF-8?q?=E4=BB=B6=E5=8F=8A=E7=9B=AE=E5=BD=95=E7=9A=84=E5=90=8D=E7=A7=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app/app.component.ts | 4 ++-- src/app/app.model.ts | 3 ++- .../link-set.component.ts} | 6 ++--- .../link-set.model.ts} | 0 .../select/select.component.ts | 22 +++++++++++++++++++ src/app/link_set/select/select.model.ts | 11 ++++++++++ .../link_status.component.ts} | 2 +- .../link_status.model.ts} | 0 src/app/title/title.component.ts | 2 +- .../title_item.component.ts} | 4 ++-- .../title_item.model.ts} | 0 .../title_item.service.ts} | 0 12 files changed, 44 insertions(+), 10 deletions(-) rename src/app/{linkSet/linkSet.component.ts => link_set/link-set.component.ts} (90%) rename src/app/{linkSet/linkSet.model.ts => link_set/link-set.model.ts} (100%) rename src/app/{linkSet => link_set}/select/select.component.ts (72%) create mode 100644 src/app/link_set/select/select.model.ts rename src/app/{linkStatus/linkStatus.component.ts => link_status/link_status.component.ts} (93%) rename src/app/{linkStatus/linkStatus.model.ts => link_status/link_status.model.ts} (100%) rename src/app/title/{titleItem/title-item.component.ts => title_item/title_item.component.ts} (87%) rename src/app/title/{titleItem/title-item.model.ts => title_item/title_item.model.ts} (100%) rename src/app/title/{titleItem/title-item.service.ts => title_item/title_item.service.ts} (100%) diff --git a/src/app/app.component.ts b/src/app/app.component.ts index 3e0fff9..c656dcd 100644 --- a/src/app/app.component.ts +++ b/src/app/app.component.ts @@ -1,8 +1,8 @@ import {Vtape} from '../ui/index'; import appModel from './app.model'; import title from './title/title.component'; -import linkSet from './linkSet/linkSet.component'; -import linkStatus from './linkStatus/linkStatus.component'; +import linkSet from './link_set/link-set.component'; +import linkStatus from './link_status/link_status.component'; import './app.component.scss'; const className = 'fr.main'; diff --git a/src/app/app.model.ts b/src/app/app.model.ts index 2db3b97..cda6e69 100644 --- a/src/app/app.model.ts +++ b/src/app/app.model.ts @@ -2,10 +2,11 @@ const className = 'fr.model.main'; import {ModelType} from '@ui'; const Model: ModelType = { - childContext: ['tab'], + childContext: ['tab', 'newLink'], state () { return { tab: '数据连接管理', + newLink: '', }; }, computed: { diff --git a/src/app/linkSet/linkSet.component.ts b/src/app/link_set/link-set.component.ts similarity index 90% rename from src/app/linkSet/linkSet.component.ts rename to src/app/link_set/link-set.component.ts index 1afb924..4ad5da3 100644 --- a/src/app/linkSet/linkSet.component.ts +++ b/src/app/link_set/link-set.component.ts @@ -1,5 +1,5 @@ -import {Htape, WidgetType, Vtape} from '@ui'; -import linkSetModel from './linkSet.model'; +import {Htape, WidgetType, Vtape, Left} from '@ui'; +import linkSetModel from './link-set.model'; import Select from './select/select.component'; const className = 'fr.linkset'; const Widget: WidgetType = { @@ -22,7 +22,7 @@ const Widget: WidgetType = { items: [ { el: { - type: 'bi.left', + type: Left, cls:'select-group', items:[ { diff --git a/src/app/linkSet/linkSet.model.ts b/src/app/link_set/link-set.model.ts similarity index 100% rename from src/app/linkSet/linkSet.model.ts rename to src/app/link_set/link-set.model.ts diff --git a/src/app/linkSet/select/select.component.ts b/src/app/link_set/select/select.component.ts similarity index 72% rename from src/app/linkSet/select/select.component.ts rename to src/app/link_set/select/select.component.ts index 387b49f..d0b039c 100644 --- a/src/app/linkSet/select/select.component.ts +++ b/src/app/link_set/select/select.component.ts @@ -1,10 +1,16 @@ import {WidgetType, Combo, ButtonGroup, TextItem, Vertical} from '@ui'; +import selectModel from './select.model'; const linkList = [ 'APACHE KYLIN', 'DERBY', 'HP Vertica', 'IBM DB2', 'INFORMIX', 'Microsoft SQL Server', 'MySQL', 'Oracle', 'Privotal Greenplum Database', 'Postgresql', 'GaussDB 200', ]; const className = 'fr.linkset.select'; const Widget: WidgetType = { + _store() { + return BI.Models.getModel(selectModel); + }, render() { + let combo: any = null; + return { type: Combo, cls:'select', @@ -25,6 +31,8 @@ const Widget: WidgetType = { height: 24, width: 152, text: item, + title: item, + value: item, }; }), { type: TextItem, @@ -32,12 +40,16 @@ const Widget: WidgetType = { height: 24, width: 152, text: '更多数据连接...', + title:'更多数据连接...', + value: 'more', }, { type: TextItem, cls: 'link-item', height: 24, width: 152, text: '其他', + title:'其他', + value: 'other', }], layouts: [{ type: Vertical, @@ -45,6 +57,16 @@ const Widget: WidgetType = { }, maxHeight: 400, }, + listeners:[{ + eventName: 'EVENT_CHANGE', + action: (v: string) => { + this.store.setNewLink(v); + combo.hideView(); + }, + }], + ref () { + combo = this; + }, }; }, }; diff --git a/src/app/link_set/select/select.model.ts b/src/app/link_set/select/select.model.ts new file mode 100644 index 0000000..e0d792e --- /dev/null +++ b/src/app/link_set/select/select.model.ts @@ -0,0 +1,11 @@ +const className = 'fr.model.linkset.select'; +const Model = BI.inherit(Fix.Model, { + context: ['newLink'], + actions: { + setNewLink(value: string) { + this.model.newLink = value; + }, + }, +}); +BI.model(className, Model); +export default className; diff --git a/src/app/linkStatus/linkStatus.component.ts b/src/app/link_status/link_status.component.ts similarity index 93% rename from src/app/linkStatus/linkStatus.component.ts rename to src/app/link_status/link_status.component.ts index d9ab7d6..b1d725a 100644 --- a/src/app/linkStatus/linkStatus.component.ts +++ b/src/app/link_status/link_status.component.ts @@ -1,5 +1,5 @@ import {WidgetType, Htape} from '@ui'; -import linkStatusModel from './linkStatus.model'; +import linkStatusModel from './link_status.model'; const className = 'fr.linkstatus'; const Widget: WidgetType = { diff --git a/src/app/linkStatus/linkStatus.model.ts b/src/app/link_status/link_status.model.ts similarity index 100% rename from src/app/linkStatus/linkStatus.model.ts rename to src/app/link_status/link_status.model.ts diff --git a/src/app/title/title.component.ts b/src/app/title/title.component.ts index 0fe19c9..3e0a792 100644 --- a/src/app/title/title.component.ts +++ b/src/app/title/title.component.ts @@ -1,5 +1,5 @@ import {Left, WidgetType} from '@ui/index'; -import TitleItem from './titleItem/title-item.component'; +import TitleItem from './title_item/title_item.component'; const tabs = ['数据连接管理', '连接池状态']; const className = 'fr.title'; const Widget: WidgetType = { diff --git a/src/app/title/titleItem/title-item.component.ts b/src/app/title/title_item/title_item.component.ts similarity index 87% rename from src/app/title/titleItem/title-item.component.ts rename to src/app/title/title_item/title_item.component.ts index 397a773..7a3adef 100644 --- a/src/app/title/titleItem/title-item.component.ts +++ b/src/app/title/title_item/title_item.component.ts @@ -1,6 +1,6 @@ import {Label} from '@ui'; -import tableItemModel from './title-item.model'; -import {getSelectStyle} from './title-item.service'; +import tableItemModel from './title_item.model'; +import {getSelectStyle} from './title_item.service'; const className = 'fr.title.item'; const Widget = BI.inherit(BI.Widget, { props: { diff --git a/src/app/title/titleItem/title-item.model.ts b/src/app/title/title_item/title_item.model.ts similarity index 100% rename from src/app/title/titleItem/title-item.model.ts rename to src/app/title/title_item/title_item.model.ts diff --git a/src/app/title/titleItem/title-item.service.ts b/src/app/title/title_item/title_item.service.ts similarity index 100% rename from src/app/title/titleItem/title-item.service.ts rename to src/app/title/title_item/title_item.service.ts