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', { ...@@ -238,19 +238,27 @@ Ext.define('Event.form.field.UserDataMultiDefault', {
var me = this, var me = this,
combo = me.combo || null, combo = me.combo || null,
previousEvent = me.lastEvent, form = me.up('xform, form').getForm(),
undef = me.trUndefined, cfg, formRecord, rawValue, record;
cfg, form, formRecord, rawValue, record;
// link me to the ComboBox // is the form ready
// The comboBox field is identidied by its name, e.g HistororyId_events if (!form) {
return;
}
// linked the ComboBox
// It is identified by its name, e.g HistororyId_events
if (!combo) { if (!combo) {
form = me.up('xform, form').getForm(); me.combo = form.findField(me.formFieldIdEvent);
if (!form) { if (!combo) {
return; 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); me.combo.on('select', me.onComboBoxSelect, me);
return;
} }
// protection // protection
...@@ -260,31 +268,22 @@ Ext.define('Event.form.field.UserDataMultiDefault', { ...@@ -260,31 +268,22 @@ Ext.define('Event.form.field.UserDataMultiDefault', {
return; return;
} }
formRecord = me.up('xform, form').getForm().getRecord(); // NOTE ExtJS 6.2
// rather complicated logic to find the correct grid configuration
// //
// NOTE ExtJS 6 // In order to retrieve the configuration for the event, it should be
// The ComboBox behave strangely in that configuration // enough to extract the event selected in the ComboBox. However, the
// The method ComboBox.getValue() always return 1 // ComboBox behave strangely, since the method ComboBox.getValue()
// The property value and rawValue refer to was have been select previously // always return 1.
// Therefore a complexe logic is required to solve all case //
// 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) { // get the data load in the form
me.lastKey = formRecord.get(me.formFieldIdEvent); 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); me.lastKey = formRecord.get(me.formFieldIdEvent);
} else { } else {
...@@ -295,7 +294,7 @@ Ext.define('Event.form.field.UserDataMultiDefault', { ...@@ -295,7 +294,7 @@ Ext.define('Event.form.field.UserDataMultiDefault', {
record = me.store.findRecord(me.dictFieldIdEvent, me.lastKey); record = me.store.findRecord(me.dictFieldIdEvent, me.lastKey);
me.lastEvent = record.get(me.dictFieldEvent); 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); cfg = me.buildSourceConfig(record);
// fill the property grid // 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