diff options
| author | Alexandre Kühn <aku@odoo.com> | 2018-02-20 15:26:31 +0100 |
|---|---|---|
| committer | Alexandre Kühn <aku@odoo.com> | 2018-02-22 14:23:03 +0100 |
| commit | 9445d2f04d0decc29366aedea819b091f287f5e5 (patch) | |
| tree | 75abf633937d5b19d1110a3fce759fac4a4d5854 /addons/web/static/src | |
| parent | d4a67bbcf458cda8b98c5281c7ed88c6363de512 (diff) | |
[FIX] web: hide nocontent helper in grouped kanban with no column
Before this commit, the no content helper was displayed in grouped
kanban without any column.
It should be hidden, because the user expects to have a button to
create a task, which is intentionally hidden in this case.
(To sum up, the user is expected to create new columns before being
prompted to create new tasks)
Diffstat (limited to 'addons/web/static/src')
3 files changed, 21 insertions, 26 deletions
diff --git a/addons/web/static/src/js/views/kanban/kanban_controller.js b/addons/web/static/src/js/views/kanban/kanban_controller.js index 8e2222be3a9..8a779becdea 100644 --- a/addons/web/static/src/js/views/kanban/kanban_controller.js +++ b/addons/web/static/src/js/views/kanban/kanban_controller.js @@ -83,24 +83,6 @@ var KanbanController = BasicController.extend({ return this.renderer.updateRecord(this.model.get(id)); }, /** - * The column quick create should be displayed in kanban iff grouped by an - * m2o field and group_create action enabled. - * - * @private - * @param {Object} state the current state - * @returns {boolean} - */ - _isCreateColumnEnabled: function (state) { - var groupCreate = this.is_action_enabled('group_create'); - if (!groupCreate) { - // pre-return to avoid a lot of the following processing - return false; - } - var groupByField = state.fields[state.groupedBy[0]]; - var groupedByM2o = groupByField && (groupByField.type === 'many2one'); - return !!groupedByM2o; - }, - /** * This method calls the server to ask for a resequence. Note that this * does not rerender the user interface, because in most case, the * resequencing operation has already been displayed by the renderer. @@ -136,7 +118,7 @@ var KanbanController = BasicController.extend({ _updateButtons: function () { if (this.$buttons) { var state = this.model.get(this.handle, {raw: true}); - var createHidden = state.data.length === 0 && this._isCreateColumnEnabled(state); + var createHidden = this.is_action_enabled('group_create') && state.isGroupedByM2ONoColumn; this.$buttons.find('.o-kanban-button-new').toggleClass('o_hidden', createHidden); } }, diff --git a/addons/web/static/src/js/views/kanban/kanban_model.js b/addons/web/static/src/js/views/kanban/kanban_model.js index 676dfdfac86..15d6284cfad 100644 --- a/addons/web/static/src/js/views/kanban/kanban_model.js +++ b/addons/web/static/src/js/views/kanban/kanban_model.js @@ -131,7 +131,11 @@ var KanbanModel = BasicModel.extend({ }); }, /** - * Add the key `tooltipData` (kanban specific) when performing a `geŧ`. + * Add the following (kanban specific) keys when performing a `get`: + * + * - tooltipData + * - progressBarValues + * - isGroupedByM2ONoColumn * * @override * @see _readTooltipFields @@ -140,11 +144,19 @@ var KanbanModel = BasicModel.extend({ get: function () { var result = this._super.apply(this, arguments); var dp = result && this.localData[result.id]; - if (dp && dp.tooltipData) { - result.tooltipData = $.extend(true, {}, dp.tooltipData); - } - if (dp && dp.progressBarValues) { - result.progressBarValues = $.extend(true, {}, dp.progressBarValues); + if (dp) { + if (dp.tooltipData) { + result.tooltipData = $.extend(true, {}, dp.tooltipData); + } + if (dp.progressBarValues) { + result.progressBarValues = $.extend(true, {}, dp.progressBarValues); + } + if (dp.fields[dp.groupedBy[0]]) { + var groupedByM2O = dp.fields[dp.groupedBy[0]].type === 'many2one'; + result.isGroupedByM2ONoColumn = !dp.data.length && groupedByM2O; + } else { + result.isGroupedByM2ONoColumn = false; + } } return result; }, 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 4236ce74da4..913a4257257 100644 --- a/addons/web/static/src/js/views/kanban/kanban_renderer.js +++ b/addons/web/static/src/js/views/kanban/kanban_renderer.js @@ -350,7 +350,8 @@ var KanbanRenderer = BasicRenderer.extend({ !remove && !this._hasContent() && !!this.noContentHelp && - !(this.quickCreate && !this.quickCreate.folded); + !(this.quickCreate && !this.quickCreate.folded) && + !this.state.isGroupedByM2ONoColumn; var $noContentHelper = this.$('.o_view_nocontent'); |
