[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)
This commit is contained in:
@@ -82,24 +82,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
|
||||
@@ -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);
|
||||
}
|
||||
},
|
||||
|
||||
@@ -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;
|
||||
},
|
||||
|
||||
@@ -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');
|
||||
|
||||
|
||||
@@ -2464,8 +2464,8 @@ QUnit.module('Views', {
|
||||
"there should be no columns");
|
||||
assert.strictEqual(kanban.$('.o_kanban_record').length, 0,
|
||||
"there should be no records");
|
||||
assert.strictEqual(kanban.$('.o_view_nocontent').length, 1,
|
||||
"there should be a nocontent helper");
|
||||
assert.strictEqual(kanban.$('.o_view_nocontent').length, 0,
|
||||
"there should not be a nocontent helper");
|
||||
assert.strictEqual(kanban.$('.o_column_quick_create').length, 0,
|
||||
"there should not be a column quick create");
|
||||
kanban.destroy();
|
||||
|
||||
Reference in New Issue
Block a user