diff --git a/src/modules/pages/connection/connection.ts b/src/modules/pages/connection/connection.ts index 8094b8d..90f5ba1 100644 --- a/src/modules/pages/connection/connection.ts +++ b/src/modules/pages/connection/connection.ts @@ -81,6 +81,14 @@ export class Connection extends BI.Widget { type: 'dec.connection.driver.entry', invisible: !BI.Services.getService('dec.service.global').isAdmin(), from: '.dec-dcm', + listeners: [ + { + eventName: 'EVENT_CLOSE', + action: () => { + this.reset(); + }, + }, + ], }, ], }, diff --git a/src/modules/pages/maintain/components/driverselector/driverselector.model.ts b/src/modules/pages/maintain/components/driverselector/driverselector.model.ts index 77077ab..384e4f4 100644 --- a/src/modules/pages/maintain/components/driverselector/driverselector.model.ts +++ b/src/modules/pages/maintain/components/driverselector/driverselector.model.ts @@ -23,7 +23,7 @@ export class DriverSelectorModel extends Model { }, customDriver: { driver: driverSource !== '' ? selectedDriver : '', - text: driverSource !== '' ? `${this.options.driver} (${driverSource})` : '', + value: driverSource !== '' ? `${this.options.driver} (${driverSource})` : '', }, }; }; @@ -32,7 +32,8 @@ export class DriverSelectorModel extends Model { driverClassItems: () => this.model.customDrivers.map(driver => { return { text: `${driver.driverClass} (${driver.name})`, - value: driver.driverClass, + value: `${driver.driverClass} (${driver.name})`, + driverClass: driver.driverClass, }; }), @@ -45,7 +46,9 @@ export class DriverSelectorModel extends Model { initDriverClassList: cb => { api.getSimpleDriverList().then(res => { - this.model.customDrivers = res.data; + this.model.customDrivers = res.data.filter(driver => { + return BI.isKey(driver.driverClass); + }); cb(); }); }, @@ -55,14 +58,18 @@ export class DriverSelectorModel extends Model { this.model.driverSource = ''; }, - changeCustomDriver: driver => { - this.model.customDriver.driver = driver; + changeCustomDriver: value => { + const item = this.model.driverClassItems.find(item => { + return item.value === value; + }); + const driver = item.driverClass; + this.model.customDriver.driver = driver; this.model.customDrivers.some(customDriver => { if (customDriver.driverClass === driver) { this.model.driverSource = customDriver.name; - this.model.customDriver.text = `${driver} (${customDriver.name})`; + this.model.customDriver.value = `${driver} (${customDriver.name})`; return true; } diff --git a/src/modules/pages/maintain/components/driverselector/driverselector.ts b/src/modules/pages/maintain/components/driverselector/driverselector.ts index c155878..896c157 100644 --- a/src/modules/pages/maintain/components/driverselector/driverselector.ts +++ b/src/modules/pages/maintain/components/driverselector/driverselector.ts @@ -37,7 +37,7 @@ export class DriverSelector extends BI.Widget { watch = { driverClassItems: items => { this.customDrivers.populate(items); - this.customDrivers.setValue(this.model.customDriver.driver); + this.customDrivers.setValue(this.model.customDriver.value); }, driverManageEntryVisible: b => { @@ -76,12 +76,15 @@ export class DriverSelector extends BI.Widget { if (value === 'default') { this.defaultDrivers.setVisible(true); this.customDrivers.setVisible(false); - + this.fireEvent('EVENT_CHANGE'); return; } this.defaultDrivers.setVisible(false); this.customDrivers.setVisible(true); + if (BI.isKey(this.customDrivers.getValue()[0])) { + this.fireEvent('EVENT_CHANGE'); + } }, }, ], @@ -120,8 +123,8 @@ export class DriverSelector extends BI.Widget { width: 204, watermark: BI.i18nText('Dec-Please_Input'), items: this.model.driverClassItems, - value: this.model.customDriver.driver, - text: () => this.model.customDriver.text || '', + value: this.model.customDriver.value, + text: () => this.model.customDriver.value || '', defaultText: BI.i18nText('Dec-Please_Select'), warningTitle: BI.i18nText('Dec-Dcm-Driver_Driver_File_Lost'), listeners: [ @@ -136,71 +139,29 @@ export class DriverSelector extends BI.Widget { }, }, { el: { - type: BI.Button.xtype, + type: 'dec.connection.driver.entry', ref: (_ref: Button) => { this.driverManageEntry = _ref; }, - level: 'ignore', - text: BI.i18nText('Dec-Dcm_Create_New_Driver'), - invisible: !this.model.driverManageEntryVisible, - handler: () => { - this.createDriverManagerLayer(); + el: { + type: BI.Button.xtype, + level: 'ignore', + text: BI.i18nText('Dec-Dcm_Create_New_Driver'), }, - }, - }, - ], - }; - } - - private createDriverManagerLayer() { - const name = BI.UUID(); - - BI.Layers.create(name, '.dec-dcm', { - render: { - type: 'bi.vtape', - cls: 'bi-background', - items: [ - { - type: 'bi.vertical_adapt', - cls: 'bi-card', - items: [ + from: '.dec-dcm', + invisible: !this.model.driverManageEntryVisible, + listeners: [ { - el: { - type: 'bi.icon_text_item', - text: BI.i18nText('Dec-Connection_Driver_Management_Exit'), - cls: 'back-font bi-high-light', - height: 24, - logic: { - dynamic: true, - }, - handler: () => { - this.store.initDriverClassList(() => BI.Layers.remove(name)); - }, + eventName: 'EVENT_CLOSE', + action: () => { + this.store.initDriverClassList(BI.emptyFn); }, - hgap: 10, }, ], - height: 40, - }, { - el: { - type: 'dec.connection.driver', - listeners: [ - { - eventName: 'EVENT_CLOSE', - action() { - BI.Layers.remove(name); - }, - }, - ], - }, - hgap: 10, - vgap: 10, }, - ], - }, - }); - - BI.Layers.show(name); + }, + ], + }; } validation(): boolean {