Browse Source

REPORT-110986 feat: 数据连接支持跳转至详情&联动

feature/x
Austin.Duan 12 months ago
parent
commit
792392ee47
  1. 61
      src/modules/pages/connection/connection.ts
  2. 11
      src/modules/pages/connection/list/list.model.ts
  3. 3
      src/modules/pages/connection/list/list_item/list_item.model.ts
  4. 5
      src/modules/pages/maintain/forms/form.model.ts
  5. 2
      src/modules/pages/maintain/forms/form.ts

61
src/modules/pages/connection/connection.ts

@ -24,24 +24,13 @@ export class Connection extends BI.Widget {
title: HTapeLayout;
watch = {
connectionSelected: (name: string) => {
if (name) {
const canEdit = connectionCanEdit(this.model.connectionSelectedOne);
const type = this.getSelectConnectionType();
this.connectionTitleWidget.setText(`${name}${getTextByDatabaseType(type)}`);
this.connectionEditWidget.setVisible(canEdit);
const hasRegistered = this.hasRegistered();
this.title.setVisible(hasRegistered);
if (!hasRegistered) {
this.listView.populate(BI.createItems(this.renderNoRegistered()));
} else {
this.listView.populate(BI.createItems(this.renderItems()));
}
} else {
this.listView.populate(BI.createItems(this.renderEmpty()));
this.connectionTitleWidget.setText('');
this.connectionEditWidget.setVisible(false);
}
connectionSelected: {
immediate: true,
handler: (name: string) => {
BI.nextTick(() => {
name ? this.renderConnectionListView(name) : this.renderEmptyListView();
});
},
},
};
@ -50,8 +39,6 @@ export class Connection extends BI.Widget {
}
render() {
this.store.setConnectionSelected('');
return {
type: BI.HTapeLayout.xtype,
hgap: 10,
@ -214,12 +201,6 @@ export class Connection extends BI.Widget {
}];
}
private renderEmpty() {
return [{
type: BI.Layout.xtype,
}];
}
private hasRegistered() {
const allDatabaseTypes = getAllDatabaseTypes();
switch (this.model.connectionSelectedOne.connectionType) {
@ -246,4 +227,32 @@ export class Connection extends BI.Widget {
this.store.setPageIndex(PAGE_INDEX.MAINTAIN);
this.store.setDatebaseTypeSelected('');
}
private renderConnectionListView(name: string) {
const canEdit = connectionCanEdit(this.model.connectionSelectedOne),
type = this.getSelectConnectionType(),
hasRegistered = this.hasRegistered();
this.connectionTitleWidget.setText(`${name}${getTextByDatabaseType(type)}`);
this.connectionEditWidget.setVisible(canEdit);
this.title.setVisible(hasRegistered);
hasRegistered
? this.listView.populate(BI.createItems(this.renderItems()))
: this.listView.populate(BI.createItems(this.renderNoRegistered()));
}
private renderEmptyListView() {
this.listView.populate(
BI.createItems([
{
type: BI.Layout.xtype,
}
])
);
this.connectionTitleWidget.setText('');
this.connectionEditWidget.setVisible(false);
}
}

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

@ -38,14 +38,19 @@ export class ConnectionListModel extends Model<{
}
});
this.model.connectionSelected = defaultDatabaseName ?? data.data[0].connectionName;
} else {
this.model.connectionSelected = '';
// 仅首次进入时从url中读取参数,其他情况保留选中状态
defaultDatabaseName ||= data.data[0].connectionName;
this.setSelectedConnection(this.model.connectionSelected || defaultDatabaseName);
}
return new Promise(resolve => {
resolve();
});
}),
setSelectedConnection(name: string) {
this.model.connectionSelected = name;
}
}
}

3
src/modules/pages/connection/list/list_item/list_item.model.ts

@ -139,8 +139,9 @@ export class ListItemModel extends Model<{
// 后端传过来的是字符串,转为对象
item.connectionData = JSON.parse(item.connectionData as string);
});
if (name === this.model.connectionSelected) {
this.model.connectionSelected = BI.size(this.model.connections) > 0 ? this.model.connections[0].connectionName : '';
this.setConnectionSelected(this.model.connections?.[0]?.connectionName || '');
}
api.shutdownConnectionStatus(name);
});

5
src/modules/pages/maintain/forms/form.model.ts

@ -17,6 +17,7 @@ export class MaintainFormModel extends Model<{
pageIndex: AppModel['TYPE']['pageIndex'];
connections: AppModel['TYPE']['connections'];
isCopy: AppModel['TYPE']['isCopy'];
connectionSelected: AppModel['TYPE']['connectionSelected'];
},
context: MaintainFormModel['context'];
}> {
@ -31,6 +32,7 @@ export class MaintainFormModel extends Model<{
'testEvent',
'connections',
'isCopy',
'connectionSelected',
];
actions = {
@ -51,5 +53,8 @@ export class MaintainFormModel extends Model<{
goFirstPage() {
this.model.pageIndex = PAGE_INDEX.CONNECTION;
},
setConnectionSelected(name: string) {
this.model.connectionSelected = name;
}
}
}

2
src/modules/pages/maintain/forms/form.ts

@ -295,6 +295,8 @@ export class MaintainForm extends BI.Widget {
return;
}
// 新增之后connections待更新,connectionSelected先置空
this.store.setConnectionSelected('');
this.store.goFirstPage();
this.store.setIsCopy(false);
});

Loading…
Cancel
Save