[FIX] web: fix KanbanRenderer state management for date/datetime fields
In the KanbanRenderer, the _setState method extracts the groupBy field name and tries to get the field information from that string. When the field is a date/datetime grouped by day/week/month/..., the field name becomes "my_date:month". This prevents the gathering of state information since those information are stored in a dictionary with a 'my_date' key. This commit will detect if the field has additional grouping info (:month, :week, ...) and clean the name with a substring before accessing the state dictionary.
This commit is contained in:
@@ -441,8 +441,9 @@ var KanbanRenderer = BasicRenderer.extend({
|
||||
this.state = state;
|
||||
|
||||
var groupByField = state.groupedBy[0];
|
||||
var groupByFieldAttrs = state.fields[groupByField];
|
||||
var groupByFieldInfo = state.fieldsInfo.kanban[groupByField];
|
||||
var cleanGroupByField = this._cleanGroupByField(groupByField);
|
||||
var groupByFieldAttrs = state.fields[cleanGroupByField];
|
||||
var groupByFieldInfo = state.fieldsInfo.kanban[cleanGroupByField];
|
||||
// Deactivate the drag'n'drop if the groupedBy field:
|
||||
// - is a date or datetime since we group by month or
|
||||
// - is readonly (on the field attrs or in the view)
|
||||
@@ -472,6 +473,22 @@ var KanbanRenderer = BasicRenderer.extend({
|
||||
});
|
||||
this.createColumnEnabled = this.groupedByM2O && this.columnOptions.group_creatable;
|
||||
},
|
||||
/**
|
||||
* Remove date/datetime magic grouping info to get proper field attrs/info from state
|
||||
* ex: sent_date:month will become sent_date
|
||||
*
|
||||
* @private
|
||||
* @param {string} groupByField
|
||||
* @returns {string}
|
||||
*/
|
||||
_cleanGroupByField: function (groupByField) {
|
||||
var cleanGroupByField = groupByField;
|
||||
if (cleanGroupByField && cleanGroupByField.indexOf(':') > -1) {
|
||||
cleanGroupByField = cleanGroupByField.substring(0, cleanGroupByField.indexOf(':'));
|
||||
}
|
||||
|
||||
return cleanGroupByField;
|
||||
},
|
||||
/**
|
||||
* Moves the focus on the first card of the next column in a given direction
|
||||
* This ignores the folded columns and skips over the empty columns.
|
||||
|
||||
Reference in New Issue
Block a user