Browse Source

fix: DEC-10011 删除最后一个数据连接时,右侧显示空白,左侧显示无可用数据连接

qufenxi
alan 6 years ago
parent
commit
2a288e0bdb
  1. 10
      src/modules/pages/connection/connection.ts
  2. 4
      src/modules/pages/connection/list/list.model.ts
  3. 76
      src/modules/pages/connection/list/list.ts

10
src/modules/pages/connection/connection.ts

@ -36,6 +36,10 @@ export class Connection extends BI.Widget {
} else { } else {
this.listView.populate(BI.createItems(this.renderItems())); 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() { private hasRegistered() {
const allDatabaseTypes = getAllDatabaseTypes(); const allDatabaseTypes = getAllDatabaseTypes();
switch (this.model.connectionSelectedOne.connectionType) { switch (this.model.connectionSelectedOne.connectionType) {

4
src/modules/pages/connection/list/list.model.ts

@ -12,6 +12,10 @@ export class ConnectionListModel extends Model<{
}> { }> {
context = ['connections', 'connectionSelected']; context = ['connections', 'connectionSelected'];
computed = {
shwoType: () => BI.size(this.model.connections) > 0 ? 'list' : 'none',
}
actions = { actions = {
setConnections: ():Promise<void> => api.getConnectionlist().then(data => { setConnections: ():Promise<void> => api.getConnectionlist().then(data => {
if (BI.size(data.data) > 0) { if (BI.size(data.data) > 0) {

76
src/modules/pages/connection/list/list.ts

@ -1,5 +1,5 @@
import { shortcut, store } from '@core/core'; 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 { ListItemXtype } from './list_item/list_item';
import { ConnectionListModel, ConnectionListModelXtype } from './list.model'; import { ConnectionListModel, ConnectionListModelXtype } from './list.model';
import { getCreator, getDatabaseType } from './list.service'; import { getCreator, getDatabaseType } from './list.service';
@ -11,6 +11,7 @@ export class ConnectionList extends BI.LoadingPane {
model: ConnectionListModel['model']; model: ConnectionListModel['model'];
groupWidget: any; groupWidget: any;
tab: any;
beforeInit(cb: Function) { beforeInit(cb: Function) {
this.store.setConnections().then(() => { 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.populate(this.renderList(0, this.groupWidget.times * 50));
this.groupWidget.times = times; this.groupWidget.times = times;
}, },
shwoType: (type: 'list' | 'none') => {
this.tab.setSelect(type);
},
} }
render() { render() {
if (BI.size(this.model.connections) === 0) { return {
return { type: Tab,
type: CenterAdapt, single: true,
items: [ showIndex: this.model.shwoType,
{ ref: (_ref: any) => {
type: Vtape, this.tab = _ref;
width: 260, },
height: 150, cardCreator: (index: 'list' | 'none') => {
if (index === 'none') {
return {
type: CenterAdapt,
items: [ items: [
{ {
el: { type: Vtape,
type: Layout, width: 260,
cls: 'data-connection-background', height: 150,
}, items: [
height: 130, {
}, el: {
{ type: Layout,
type: Label, cls: 'data-connection-background',
cls: 'bi-tips', },
text: BI.i18nText('Dec-Dcm_Connection_None'), 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));
}, },
], hasNext: options => options.times * 50 < BI.size(this.model.connections),
}; ref: (_ref: any) => {
} this.groupWidget = _ref;
},
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;
}, },
}; };
} }

Loading…
Cancel
Save