From 2a288e0bdb1c099768fcf422395e58d475adeef9 Mon Sep 17 00:00:00 2001 From: alan Date: Fri, 27 Sep 2019 10:18:46 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20DEC-10011=20=E5=88=A0=E9=99=A4=E6=9C=80?= =?UTF-8?q?=E5=90=8E=E4=B8=80=E4=B8=AA=E6=95=B0=E6=8D=AE=E8=BF=9E=E6=8E=A5?= =?UTF-8?q?=E6=97=B6=EF=BC=8C=E5=8F=B3=E4=BE=A7=E6=98=BE=E7=A4=BA=E7=A9=BA?= =?UTF-8?q?=E7=99=BD=EF=BC=8C=E5=B7=A6=E4=BE=A7=E6=98=BE=E7=A4=BA=E6=97=A0?= =?UTF-8?q?=E5=8F=AF=E7=94=A8=E6=95=B0=E6=8D=AE=E8=BF=9E=E6=8E=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/modules/pages/connection/connection.ts | 10 +++ .../pages/connection/list/list.model.ts | 4 + src/modules/pages/connection/list/list.ts | 76 +++++++++++-------- 3 files changed, 59 insertions(+), 31 deletions(-) diff --git a/src/modules/pages/connection/connection.ts b/src/modules/pages/connection/connection.ts index a804c35..b604354 100644 --- a/src/modules/pages/connection/connection.ts +++ b/src/modules/pages/connection/connection.ts @@ -36,6 +36,10 @@ export class Connection extends BI.Widget { } else { this.listView.populate(BI.createItems(this.renderItems())); } + } else { + this.listView.populate(BI.createItems(this.renderEmpty())); + this.connectionTitleWidget.setText(''); + this.connectionEditWidget.setVisible(false); } }, } @@ -175,6 +179,12 @@ export class Connection extends BI.Widget { }]; } + private renderEmpty() { + return [{ + type: Layout, + }]; + } + private hasRegistered() { const allDatabaseTypes = getAllDatabaseTypes(); switch (this.model.connectionSelectedOne.connectionType) { diff --git a/src/modules/pages/connection/list/list.model.ts b/src/modules/pages/connection/list/list.model.ts index c3d08aa..4e76792 100644 --- a/src/modules/pages/connection/list/list.model.ts +++ b/src/modules/pages/connection/list/list.model.ts @@ -12,6 +12,10 @@ export class ConnectionListModel extends Model<{ }> { context = ['connections', 'connectionSelected']; + computed = { + shwoType: () => BI.size(this.model.connections) > 0 ? 'list' : 'none', + } + actions = { setConnections: ():Promise => api.getConnectionlist().then(data => { if (BI.size(data.data) > 0) { diff --git a/src/modules/pages/connection/list/list.ts b/src/modules/pages/connection/list/list.ts index a208382..ef2d6ce 100644 --- a/src/modules/pages/connection/list/list.ts +++ b/src/modules/pages/connection/list/list.ts @@ -1,5 +1,5 @@ import { shortcut, store } from '@core/core'; -import { CenterAdapt, Label, Layout, Vtape, Loader } from 'ui'; +import { CenterAdapt, Label, Layout, Vtape, Loader, Tab } from 'ui'; import { ListItemXtype } from './list_item/list_item'; import { ConnectionListModel, ConnectionListModelXtype } from './list.model'; import { getCreator, getDatabaseType } from './list.service'; @@ -11,6 +11,7 @@ export class ConnectionList extends BI.LoadingPane { model: ConnectionListModel['model']; groupWidget: any; + tab: any; beforeInit(cb: Function) { this.store.setConnections().then(() => { @@ -24,44 +25,57 @@ export class ConnectionList extends BI.LoadingPane { this.groupWidget.populate(this.renderList(0, this.groupWidget.times * 50)); this.groupWidget.times = times; }, + shwoType: (type: 'list' | 'none') => { + this.tab.setSelect(type); + }, } render() { - if (BI.size(this.model.connections) === 0) { - return { - type: CenterAdapt, - items: [ - { - type: Vtape, - width: 260, - height: 150, + return { + type: Tab, + single: true, + showIndex: this.model.shwoType, + ref: (_ref: any) => { + this.tab = _ref; + }, + cardCreator: (index: 'list' | 'none') => { + if (index === 'none') { + return { + type: CenterAdapt, items: [ { - el: { - type: Layout, - cls: 'data-connection-background', - }, - height: 130, - }, - { - type: Label, - cls: 'bi-tips', - text: BI.i18nText('Dec-Dcm_Connection_None'), + type: Vtape, + width: 260, + height: 150, + items: [ + { + el: { + type: Layout, + cls: 'data-connection-background', + }, + height: 130, + }, + { + type: Label, + cls: 'bi-tips', + text: BI.i18nText('Dec-Dcm_Connection_None'), + }, + ], }, ], + }; + } + + return { + type: Loader, + itemsCreator: (options: {times: number}, populate) => { + populate(this.renderList((options.times - 1) * 50, options.times * 50)); }, - ], - }; - } - - return { - type: Loader, - itemsCreator: (options: {times: number}, populate) => { - populate(this.renderList((options.times - 1) * 50, options.times * 50)); - }, - hasNext: options => options.times * 50 < BI.size(this.model.connections), - ref: (_ref: any) => { - this.groupWidget = _ref; + hasNext: options => options.times * 50 < BI.size(this.model.connections), + ref: (_ref: any) => { + this.groupWidget = _ref; + }, + }; }, }; }