|
|
|
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;
|
|
|
|
|
|
|
|
watch = {
|
|
|
|
driverClassItems: items => {
|
|
|
|
// this.customDrivers.populate(items);
|
|
|
|
// this.customDrivers.setValue(this.model.customDriver.value);
|
|
|
|
},
|
|
|
|
|
|
|
|
driverManageEntryVisible: b => {
|
|
|
|
this.driverManageEntry.setVisible(false);
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
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,
|
|
|
|
invisible: true,
|
|
|
|
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);
|
|
|
|
this.fireEvent('EVENT_CHANGE');
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
this.defaultDrivers.setVisible(false);
|
|
|
|
this.customDrivers.setVisible(true);
|
|
|
|
if (BI.isKey(this.customDrivers.getValue()[0])) {
|
|
|
|
this.fireEvent('EVENT_CHANGE');
|
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
}, {
|
|
|
|
el: {
|
|
|
|
type: BI.EditorIconCheckCombo.xtype,
|
|
|
|
$testId: 'dec-editor-icon-check-combo',
|
|
|
|
$value: 'driver',
|
|
|
|
ref: _ref => {
|
|
|
|
this.defaultDrivers = _ref;
|
|
|
|
},
|
|
|
|
invisible: this.model.driverSource !== '',
|
|
|
|
width: 300,
|
|
|
|
items: this.model.defaultDrivers,
|
|
|
|
value: this.model.defaultDriver.driver,
|
|
|
|
listeners: [
|
|
|
|
{
|
|
|
|
eventName: BI.EditorIconCheckCombo.EVENT_CHANGE,
|
|
|
|
action: () => {
|
|
|
|
this.store.changeDefaultDriver(this.defaultDrivers.getValue());
|
|
|
|
this.fireEvent('EVENT_CHANGE');
|
|
|
|
},
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
}, {
|
|
|
|
el: {
|
|
|
|
type: BI.SearchTextValueCombo.xtype,
|
|
|
|
$testId: 'dec-editor-icon-check-combo',
|
|
|
|
$value: 'driver',
|
|
|
|
ref: _ref => {
|
|
|
|
this.customDrivers = _ref;
|
|
|
|
},
|
|
|
|
invisible: true,
|
|
|
|
width: 204,
|
|
|
|
watermark: BI.i18nText('Dec-Please_Input'),
|
|
|
|
items: this.model.driverClassItems,
|
|
|
|
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: [
|
|
|
|
{
|
|
|
|
eventName: BI.SearchTextValueCombo.EVENT_CHANGE,
|
|
|
|
action: () => {
|
|
|
|
this.store.changeCustomDriver(this.customDrivers.getValue()[0]);
|
|
|
|
this.fireEvent('EVENT_CHANGE');
|
|
|
|
},
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
}, {
|
|
|
|
el: {
|
|
|
|
type: 'dec.connection.driver.entry',
|
|
|
|
ref: (_ref: Button) => {
|
|
|
|
this.driverManageEntry = _ref;
|
|
|
|
},
|
|
|
|
el: {
|
|
|
|
type: BI.Button.xtype,
|
|
|
|
level: 'ignore',
|
|
|
|
text: BI.i18nText('Dec-Dcm_Create_New_Driver'),
|
|
|
|
},
|
|
|
|
from: '.dec-dcm',
|
|
|
|
invisible: true,
|
|
|
|
listeners: [
|
|
|
|
{
|
|
|
|
eventName: 'EVENT_CLOSE',
|
|
|
|
action: () => {
|
|
|
|
this.store.initDriverClassList(BI.emptyFn);
|
|
|
|
},
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
],
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
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,
|
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|