summaryrefslogtreecommitdiff
path: root/addons/web/static/src/js/views/basic/basic_renderer.js
diff options
context:
space:
mode:
authorLucas Perais (lpe) <lpe@odoo.com>2018-03-21 16:44:28 +0100
committerLucas Perais (lpe) <lpe@odoo.com>2018-03-22 22:51:57 -0800
commit8df055b584fd0e911238416ab9a1d473e3b27df7 (patch)
tree24bf7c269179995bea5db11b26a0722caa973681 /addons/web/static/src/js/views/basic/basic_renderer.js
parentef540eb006abac0d318f2a708384d125f6203662 (diff)
[FIX] web: don't loose focus when editing cell in list
Have a list with readonly modifiers on at least one column. Have the first record of the list be readonly as computed by the modifier Create and edit a second record Enter a value in the cell and hit TAB Before this commit: The focus on the targetted cell was lost and the rendering of the cell was in mode readonly This was because the baseMode of the modifier dict was applied to one and only one node (== one column) and hence to *all* the records After this commit: The rendering and keyboard TAB navigation works as expected in the list editable The baseMode concept has been sharpened and each cell now has one OPW-1816569 OPW-1824979 closes #23809 closes #22859 closes #23436
Diffstat (limited to 'addons/web/static/src/js/views/basic/basic_renderer.js')
-rw-r--r--addons/web/static/src/js/views/basic/basic_renderer.js16
1 files changed, 9 insertions, 7 deletions
diff --git a/addons/web/static/src/js/views/basic/basic_renderer.js b/addons/web/static/src/js/views/basic/basic_renderer.js
index 4b22a5dc66f..e2d486f7244 100644
--- a/addons/web/static/src/js/views/basic/basic_renderer.js
+++ b/addons/web/static/src/js/views/basic/basic_renderer.js
@@ -256,7 +256,7 @@ var BasicRenderer = AbstractRenderer.extend({
// If the view is in edit mode and that a widget have to switch
// its "readonly" state, we have to re-render it completely
if ('readonly' in modifiers && element.widget) {
- var mode = modifiers.readonly ? 'readonly' : modifiersData.baseMode;
+ var mode = modifiers.readonly ? 'readonly' : modifiersData.baseModeByRecord[record.id];
if (mode !== element.widget.mode) {
self._rerenderFieldWidget(element.widget, record, {
keepBaseMode: true,
@@ -416,16 +416,17 @@ var BasicRenderer = AbstractRenderer.extend({
* @param {Object} [options.callback] the callback to call on registration
* and on modifiers updates
* @param {boolean} [options.keepBaseMode=false] this function registers the
- * 'baseMode' of the node; this is a field widget specific settings which
+ * 'baseMode' of the node on a per record basis;
+ * this is a field widget specific settings which
* represents the generic mode of the widget, regardless of its modifiers
* (the interesting case is the list view: all widgets are supposed to be
* in the baseMode 'readonly', except the ones that are in the line that
* is currently being edited).
- * With option 'keepBaseMode' set to true, the current baseMode of the
+ * With option 'keepBaseMode' set to true, the baseMode of the record's
* node isn't overridden (this is particularily useful when a field widget
* is re-rendered because its readonly modifier changed, as in this case,
* we don't want to change its base mode).
- * @param {string} [options.mode] the 'baseMode' of the node is set to this
+ * @param {string} [options.mode] the 'baseMode' of the record's node is set to this
* value (if not given, it is set to this.mode, the mode of the renderer)
* @returns {Object} for code efficiency, returns the last evaluated
* modifiers for the given node and record.
@@ -443,15 +444,16 @@ var BasicRenderer = AbstractRenderer.extend({
modifiers: modifiers,
evaluatedModifiers: {},
elementsByRecord: {},
+ baseModeByRecord : {},
};
if (!_.isEmpty(modifiers)) { // Register only if modifiers might change (TODO condition might be improved here)
this.allModifiersData.push(modifiersData);
}
}
- // Compute node's base mode if necessary
- if (!options.keepBaseMode) {
- modifiersData.baseMode = options.mode || this.mode;
+ // Compute the record's base mode
+ if (!modifiersData.baseModeByRecord[record.id] || !options.keepBaseMode) {
+ modifiersData.baseModeByRecord[record.id] = options.mode || this.mode;
}
// Evaluate if necessary