You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
218 lines
7.9 KiB
218 lines
7.9 KiB
import { shortcut, store } from '@core/core'; |
|
|
|
import { |
|
Button, |
|
EditorIconCheckCombo, |
|
SearchTextValueCombo, |
|
TextValueCombo, |
|
} from '@fui/core'; |
|
import { ConnectionJDBC } from '../../../../crud/crud.typings'; |
|
import { getJdbcDatabaseType } from '../../../../app.service'; |
|
import { DriverSelectorModel } from './driverselector.model'; |
|
|
|
|
|
@shortcut() |
|
@store(DriverSelectorModel, { |
|
props(this: DriverSelector) { |
|
return this.options; |
|
}, |
|
}) |
|
export class DriverSelector extends BI.Widget { |
|
static xtype = 'dec.dcm.maintain.form.jdbc.driver_selector'; |
|
|
|
props = { |
|
driver: '', |
|
driverSource: '', |
|
connectionData: {} as ConnectionJDBC, |
|
}; |
|
|
|
defaultDrivers: EditorIconCheckCombo = null; |
|
|
|
customDrivers: SearchTextValueCombo = null; |
|
|
|
beforeRender(cb: Function) { |
|
this.store.initDriverClassList(cb); |
|
} |
|
|
|
watch = { |
|
driverClassItems: items => { |
|
this.customDrivers.populate(items); |
|
this.customDrivers.setValue(this.model.customDriver.driver); |
|
}, |
|
|
|
driverManageEntryVisible: b => { |
|
this.driverManageEntry.setVisible(b); |
|
}, |
|
}; |
|
|
|
private driverManageEntry = null; |
|
|
|
render() { |
|
const { driver } = this.options.connectionData; |
|
|
|
return { |
|
type: BI.VerticalAdaptLayout.xtype, |
|
rgap: 10, |
|
items: [ |
|
{ |
|
el: { |
|
type: BI.TextValueCombo.xtype, |
|
width: 86, |
|
value: this.model.selectedDriverType, |
|
items: [ |
|
{ |
|
text: BI.i18nText('Dec-Basic_Default'), |
|
value: 'default', |
|
}, { |
|
text: BI.i18nText('Dec-Basic_Custom'), |
|
value: 'custom', |
|
}, |
|
], |
|
listeners: [ |
|
{ |
|
eventName: BI.TextValueCombo.EVENT_CHANGE, |
|
action: value => { |
|
this.store.changeSelectedDriverType(value); |
|
if (value === 'default') { |
|
this.defaultDrivers.setVisible(true); |
|
this.customDrivers.setVisible(false); |
|
|
|
return; |
|
} |
|
|
|
this.defaultDrivers.setVisible(false); |
|
this.customDrivers.setVisible(true); |
|
}, |
|
}, |
|
], |
|
}, |
|
}, { |
|
el: { |
|
type: BI.EditorIconCheckCombo.xtype, |
|
$testId: 'dec-editor-icon-check-combo', |
|
$value: 'driver', |
|
ref: _ref => { |
|
this.defaultDrivers = _ref; |
|
}, |
|
invisible: this.model.driverSource !== '', |
|
width: 204, |
|
items: this.model.defaultDrivers, |
|
value: this.model.defaultDriver.driver, |
|
listeners: [ |
|
{ |
|
eventName: BI.EditorIconCheckCombo.EVENT_CHANGE, |
|
action: () => this.store.changeDefaultDriver(this.defaultDrivers.getValue()), |
|
}, |
|
], |
|
}, |
|
}, { |
|
el: { |
|
type: BI.SearchTextValueCombo.xtype, |
|
$testId: 'dec-editor-icon-check-combo', |
|
$value: 'driver', |
|
ref: _ref => { |
|
this.customDrivers = _ref; |
|
}, |
|
invisible: this.model.driverSource === '', |
|
width: 204, |
|
watermark: BI.i18nText('Dec-Please_Input'), |
|
items: this.model.driverClassItems, |
|
value: this.model.customDriver.driver, |
|
text: () => this.model.customDriver.text || '', |
|
defaultText: BI.i18nText('Dec-Please_Select'), |
|
warningTitle: BI.i18nText('Dec-Dcm-Driver_Driver_File_Lost'), |
|
listeners: [ |
|
{ |
|
eventName: BI.SearchTextValueCombo.EVENT_CHANGE, |
|
action: () => this.store.changeCustomDriver(this.customDrivers.getValue()[0]), |
|
}, |
|
], |
|
}, |
|
}, { |
|
el: { |
|
type: BI.Button.xtype, |
|
ref: (_ref: Button) => { |
|
this.driverManageEntry = _ref; |
|
}, |
|
level: 'ignore', |
|
text: BI.i18nText('Dec-Dcm_Create_New_Driver'), |
|
invisible: !this.model.driverManageEntryVisible, |
|
handler: () => { |
|
this.createDriverManagerLayer(); |
|
}, |
|
}, |
|
}, |
|
], |
|
}; |
|
} |
|
|
|
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: [ |
|
{ |
|
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)); |
|
}, |
|
}, |
|
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 { |
|
if (this.model.selectedDriverType === 'default' && BI.isKey(this.model.defaultDriver.driver)) { |
|
return true; |
|
} |
|
if (this.model.selectedDriverType === 'custom' && BI.isKey(this.model.customDriver.driver)) { |
|
return true; |
|
} |
|
BI.Msg.toast(BI.i18nText('Dec-Dcm_Driver_Class_Not_Allow_Empty'), { level: 'error' }); |
|
|
|
return false; |
|
} |
|
|
|
getValue() { |
|
return { |
|
driverSource: this.model.driverSource, |
|
driver: this.model.driverSource === '' ? this.model.defaultDriver.driver : this.model.customDriver.driver, |
|
}; |
|
} |
|
}
|
|
|