Commit bb7199bc authored by LE GAC Renaud's avatar LE GAC Renaud
Browse files

Update UserDataMultiDefault in order to simplify the method setValue and to fix a bug.

parent e1f3e845
......@@ -238,19 +238,27 @@ Ext.define('Event.form.field.UserDataMultiDefault', {
var me = this,
combo = me.combo || null,
previousEvent = me.lastEvent,
undef = me.trUndefined,
cfg, form, formRecord, rawValue, record;
form = me.up('xform, form').getForm(),
cfg, formRecord, rawValue, record;
// link me to the ComboBox
// The comboBox field is identidied by its name, e.g HistororyId_events
// is the form ready
if (!form) {
return;
}
// linked the ComboBox
// It is identified by its name, e.g HistororyId_events
if (!combo) {
form = me.up('xform, form').getForm();
if (!form) {
me.combo = form.findField(me.formFieldIdEvent);
if (!combo) {
return;
}
me.combo = form.findField(me.formFieldIdEvent);
}
// check if the the select handler activated for the ComboBox
if (!combo.hasListener("select")) {
me.combo.on('select', me.onComboBoxSelect, me);
return;
}
// protection
......@@ -260,31 +268,22 @@ Ext.define('Event.form.field.UserDataMultiDefault', {
return;
}
formRecord = me.up('xform, form').getForm().getRecord();
// rather complicated logic to find the correct grid configuration
// NOTE ExtJS 6.2
//
// NOTE ExtJS 6
// The ComboBox behave strangely in that configuration
// The method ComboBox.getValue() always return 1
// The property value and rawValue refer to was have been select previously
// Therefore a complexe logic is required to solve all case
// In order to retrieve the configuration for the event, it should be
// enough to extract the event selected in the ComboBox. However, the
// ComboBox behave strangely, since the method ComboBox.getValue()
// always return 1.
//
// In order to fix this issue, we get the full record loaded in the
// form, instead, and extract the selected event.
//
if ((previousEvent === undef && rawValue === undef) || formRecord === undefined) {
me.lastKey = 1;
value = {};
} else if (previousEvent !== undefined && rawValue === undef) {
me.lastKey = 1;
value = {};
} else if (previousEvent === rawValue) {
me.lastKey = formRecord.get(me.formFieldIdEvent);
} else if (previousEvent === undefined && formRecord !== null) {
me.lastKey = formRecord.get(me.formFieldIdEvent);
// get the data load in the form
formRecord = form.getRecord();
} else if (previousEvent !== undefined && rawValue !== undefined) {
// get the selected event and retrieve its configuration
if (formRecord) {
me.lastKey = formRecord.get(me.formFieldIdEvent);
} else {
......@@ -295,7 +294,7 @@ Ext.define('Event.form.field.UserDataMultiDefault', {
record = me.store.findRecord(me.dictFieldIdEvent, me.lastKey);
me.lastEvent = record.get(me.dictFieldEvent);
// build the configuration of the Ext.grid.property.Grid
// get the configuration for the Ext.grid.property.Grid
cfg = me.buildSourceConfig(record);
// fill the property grid
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment