diff options
| author | Christophe Simonis <chs@odoo.com> | 2019-03-13 11:45:01 +0000 |
|---|---|---|
| committer | Christophe Simonis <chs@odoo.com> | 2019-03-13 14:24:51 +0000 |
| commit | 44515bc7beae3b4c46b5bc2959c320695b51439d (patch) | |
| tree | 5f56871242f7b5bc8a323c51f2749411e555159e /addons/web/static/src/js | |
| parent | bf69975b54164a21bfe00b2359d972329516a34e (diff) | |
| parent | c9f832d9f032b6af51807b387b325b5c2b8aad00 (diff) | |
[MERGE] forward port branch saas-12.2 up to c9f832d9f03
closes odoo/odoo#31790
Signed-off-by: Christophe Simonis <chs@odoo.com>
Diffstat (limited to 'addons/web/static/src/js')
11 files changed, 63 insertions, 41 deletions
diff --git a/addons/web/static/src/js/chrome/action_manager_act_window.js b/addons/web/static/src/js/chrome/action_manager_act_window.js index d00b3a49eb2..8d13f4d9679 100644 --- a/addons/web/static/src/js/chrome/action_manager_act_window.js +++ b/addons/web/static/src/js/chrome/action_manager_act_window.js @@ -535,6 +535,9 @@ ActionManager.include({ return newController(controller.jsID); } else { return Promise.resolve(controller.widget.willRestore()).then(function () { + viewOptions = _.extend({}, viewOptions, { + breadcrumbs: self._getBreadcrumbs(self.controllerStack.slice(0, index)), + }); return controller.widget.reload(viewOptions).then(function () { return controller; }); diff --git a/addons/web/static/src/js/fields/basic_fields.js b/addons/web/static/src/js/fields/basic_fields.js index a87ff3e4436..7439c36037f 100644 --- a/addons/web/static/src/js/fields/basic_fields.js +++ b/addons/web/static/src/js/fields/basic_fields.js @@ -1330,7 +1330,9 @@ var CopyClipboard = { */ destroy: function () { this._super.apply(this, arguments); - this.clipboard.destroy(); + if (this.clipboard) { + this.clipboard.destroy(); + } }, //-------------------------------------------------------------------------- @@ -1345,8 +1347,8 @@ var CopyClipboard = { var $clipboardBtn = this.$('.o_clipboard_button'); $clipboardBtn.tooltip({title: _t('Copied !'), trigger: 'manual', placement: 'right'}); this.clipboard = new ClipboardJS($clipboardBtn[0], { - text: function (_) { - return self.value.trim(); + text: function () { + return self.value.trim(); }, // Container added because of Bootstrap modal that give the focus to another element. // We need to give to correct focus to ClipboardJS (see in ClipboardJS doc) @@ -1362,40 +1364,31 @@ var CopyClipboard = { }); }); }, -}; - -var TextCopyClipboard = FieldText.extend(CopyClipboard, { - - //-------------------------------------------------------------------------- - // Private - //-------------------------------------------------------------------------- - /** * @override */ - _render: function() { + _render: function () { this._super.apply(this, arguments); this.$el.addClass('o_field_copy'); - this.$el.append($(qweb.render('CopyClipboardText'))); - this._initClipboard(); - } -}); - -var CharCopyClipboard = FieldChar.extend(CopyClipboard, { - - //-------------------------------------------------------------------------- - // Private - //-------------------------------------------------------------------------- - + }, /** * @override */ - _render: function() { + _renderReadonly: function () { this._super.apply(this, arguments); - this.$el.addClass('o_field_copy'); - this.$el.append($(qweb.render('CopyClipboardChar'))); - this._initClipboard(); + if (this.value) { + this.$el.append($(qweb.render(this.clipboardTemplate))); + this._initClipboard(); + } } +}; + +var TextCopyClipboard = FieldText.extend(CopyClipboard, { + clipboardTemplate: 'CopyClipboardText', +}); + +var CharCopyClipboard = FieldChar.extend(CopyClipboard, { + clipboardTemplate: 'CopyClipboardChar', }); var AbstractFieldBinary = AbstractField.extend({ diff --git a/addons/web/static/src/js/fields/field_registry.js b/addons/web/static/src/js/fields/field_registry.js index 0e0ba3dc117..cd4c92087eb 100644 --- a/addons/web/static/src/js/fields/field_registry.js +++ b/addons/web/static/src/js/fields/field_registry.js @@ -44,8 +44,9 @@ registry .add('priority', basic_fields.PriorityWidget) .add('attachment_image', basic_fields.AttachmentImage) .add('label_selection', basic_fields.LabelSelection) + .add('kanban_label_selection', basic_fields.LabelSelection) // deprecated, use label_selection .add('state_selection', basic_fields.StateSelectionWidget) - .add('kanban_state_selection', basic_fields.StateSelectionWidget) + .add('kanban_state_selection', basic_fields.StateSelectionWidget) // deprecated, use state_selection .add('boolean_favorite', basic_fields.FavoriteWidget) .add('boolean_button', basic_fields.FieldBooleanButton) .add('boolean_toggle', basic_fields.BooleanToggle) diff --git a/addons/web/static/src/js/fields/relational_fields.js b/addons/web/static/src/js/fields/relational_fields.js index 469cedb8ff1..15b7975aa42 100644 --- a/addons/web/static/src/js/fields/relational_fields.js +++ b/addons/web/static/src/js/fields/relational_fields.js @@ -242,7 +242,7 @@ var FieldMany2One = AbstractField.extend({ _bindAutoComplete: function () { var self = this; // avoid ignoring autocomplete="off" by obfuscating placeholder, see #30439 - if (this.$input.attr('placeholder')) { + if ($.browser.chrome && this.$input.attr('placeholder')) { this.$input.attr('placeholder', function (index, val) { return val.split('').join('\ufeff'); }); @@ -1901,6 +1901,7 @@ var FieldMany2ManyTags = AbstractField.extend({ } this.colorField = this.nodeOptions.color_field; + this.hasDropdown = false; }, //-------------------------------------------------------------------------- @@ -1969,6 +1970,7 @@ var FieldMany2ManyTags = AbstractField.extend({ return { colorField: this.colorField, elements: elements, + hasDropdown: this.hasDropdown, readonly: this.mode === "readonly", }; }, @@ -2080,6 +2082,14 @@ var FormFieldMany2ManyTags = FieldMany2ManyTags.extend({ 'mousedown .o_colorpicker a': '_onUpdateColor', 'mousedown .o_colorpicker .o_hide_in_kanban': '_onUpdateColor', }), + /** + * @override + */ + init: function () { + this._super.apply(this, arguments); + + this.hasDropdown = !!this.colorField; + }, //-------------------------------------------------------------------------- // Handlers diff --git a/addons/web/static/src/js/views/abstract_controller.js b/addons/web/static/src/js/views/abstract_controller.js index 0c251874480..965ce404a64 100644 --- a/addons/web/static/src/js/views/abstract_controller.js +++ b/addons/web/static/src/js/views/abstract_controller.js @@ -254,7 +254,7 @@ var AbstractController = mvc.Controller.extend(ActionMixin, { return; } self.renderer.setLocalState(localState); - return self._update(state); + return self._update(state, params); }); }); }, @@ -415,12 +415,15 @@ var AbstractController = mvc.Controller.extend(ActionMixin, { * * @private * @param {Object} state the state given by the model + * @param {Object} [params] + * @param {Object[]} [params.breadcrumbs] * @returns {Promise} */ - _update: function () { + _update: function (state, params) { // AAB: update the control panel -> this will be moved elsewhere at some point var cpContent = _.extend({}, this.controlPanelElements); this.updateControlPanel({ + breadcrumbs: params && params.breadcrumbs, cp_content: cpContent, title: this.getTitle(), }); diff --git a/addons/web/static/src/js/views/control_panel/control_panel_controller.js b/addons/web/static/src/js/views/control_panel/control_panel_controller.js index 913c226ba85..dc8fce9f5d1 100644 --- a/addons/web/static/src/js/views/control_panel/control_panel_controller.js +++ b/addons/web/static/src/js/views/control_panel/control_panel_controller.js @@ -17,6 +17,7 @@ var ControlPanelController = mvc.Controller.extend({ activate_time_range: '_onActivateTimeRange', autocompletion_filter: '_onAutoCompletionFilter', reload: '_onReload', + reset: '_onReset', }, /** @@ -244,6 +245,15 @@ var ControlPanelController = mvc.Controller.extend({ ev.stopPropagation(); this.trigger_up('search', this.model.getQuery()); }, + /** + * @private + * @param {OdooEvent} ev + */ + _onReset: function (ev) { + ev.stopPropagation(); + var state = this.model.get(); + this.renderer.updateState(state); + }, }); return ControlPanelController; diff --git a/addons/web/static/src/js/views/control_panel/search/search_bar.js b/addons/web/static/src/js/views/control_panel/search/search_bar.js index 4c2e71a378f..6248489922c 100644 --- a/addons/web/static/src/js/views/control_panel/search/search_bar.js +++ b/addons/web/static/src/js/views/control_panel/search/search_bar.js @@ -187,10 +187,16 @@ var SearchBar = Widget.extend({ */ _onAutoCompleteSelected: function (e, ui) { e.preventDefault(); - var filter = ui.item.facet.filter; + var facet = ui.item.facet; + if (!facet) { + // this happens when selecting "(no result)" item + this.trigger_up('reset'); + return; + } + var filter = facet.filter; if (filter.type === 'field') { var values = filter.autoCompleteValues; - values.push(ui.item.facet.values[0]); + values.push(facet.values[0]); this.trigger_up('autocompletion_filter', { filterId: filter.id, autoCompleteValues: values, diff --git a/addons/web/static/src/js/views/kanban/kanban_renderer.js b/addons/web/static/src/js/views/kanban/kanban_renderer.js index eda15f706d3..c69632129cd 100644 --- a/addons/web/static/src/js/views/kanban/kanban_renderer.js +++ b/addons/web/static/src/js/views/kanban/kanban_renderer.js @@ -249,7 +249,6 @@ var KanbanRenderer = BasicRenderer.extend({ */ updateState: function (state) { this._setState(state); - this._toggleNoContentHelper(); return this._super.apply(this, arguments); }, diff --git a/addons/web/static/src/js/views/list/list_editable_renderer.js b/addons/web/static/src/js/views/list/list_editable_renderer.js index 4619cb86e66..cb652cb968b 100644 --- a/addons/web/static/src/js/views/list/list_editable_renderer.js +++ b/addons/web/static/src/js/views/list/list_editable_renderer.js @@ -285,6 +285,8 @@ ListRenderer.include({ this.currentRow = null; } + // destroy widgets first + this._destroyFieldWidgets(recordID); // remove the row var $row = this.$('.o_data_row:nth(' + rowIndex + ')'); if (this.state.count >= 4) { @@ -292,8 +294,6 @@ ListRenderer.include({ } else { $row.replaceWith(this._renderEmptyRow()); } - - this._destroyFieldWidgets(recordID); }, /** * Updates the already rendered row associated to the given recordID so that diff --git a/addons/web/static/src/js/views/pivot/pivot_model.js b/addons/web/static/src/js/views/pivot/pivot_model.js index a4a2bae8fb0..989eaa448a9 100644 --- a/addons/web/static/src/js/views/pivot/pivot_model.js +++ b/addons/web/static/src/js/views/pivot/pivot_model.js @@ -992,7 +992,6 @@ var PivotModel = AbstractModel.extend({ var groupBys; var m; - for (var i = 0; i < rowGroupBys.length + 1; i++) { for (var j = 0; j < colGroupBys.length + 1; j++) { for (var k = 0; k < data[index].length; k++) { diff --git a/addons/web/static/src/js/widgets/auto_complete.js b/addons/web/static/src/js/widgets/auto_complete.js index 6dd78f8f730..4da54cf8b5c 100644 --- a/addons/web/static/src/js/widgets/auto_complete.js +++ b/addons/web/static/src/js/widgets/auto_complete.js @@ -201,10 +201,8 @@ return Widget.extend({ this.current_result = $li.data('result'); }, select_item: function (ev) { - if (this.current_result.facet) { - this.select(ev, {item: {facet: this.current_result.facet}}); - this.close(); - } + this.select(ev, {item: {facet: this.current_result.facet}}); + this.close(); }, show: function () { this.$el.show(); |
