[IMP] web: Kanban grouped: don't allow to sort column

... if not grouped by m2o, as it won't save anything in database
anyway, so at the next refresh of the view the new order will
be lost.
This commit is contained in:
Aaron Bohy
2017-04-11 19:44:38 +02:00
parent cbf0e30af3
commit 04bc03ced2
3 changed files with 34 additions and 26 deletions
@@ -247,30 +247,33 @@ var KanbanRenderer = BasicRenderer.extend({
}
});
// Enable column sorting
this.$el.sortable({
axis: 'x',
items: '> .o_kanban_group',
handle: '.o_kanban_header',
cursor: 'move',
revert: 150,
delay: 100,
tolerance: 'pointer',
forcePlaceholderSize: true,
stop: function () {
var ids = [];
self.$('.o_kanban_group').each(function (index, u) {
ids.push($(u).data('id'));
});
self.trigger_up('resequence_columns', {ids: ids});
},
});
if (groupedByM2O) {
// Enable column sorting
this.$el.sortable({
axis: 'x',
items: '> .o_kanban_group',
handle: '.o_kanban_header',
cursor: 'move',
revert: 150,
delay: 100,
tolerance: 'pointer',
forcePlaceholderSize: true,
stop: function () {
var ids = [];
self.$('.o_kanban_group').each(function (index, u) {
ids.push($(u).data('id'));
});
self.trigger_up('resequence_columns', {ids: ids});
},
});
// Column quick create
if (this.columnOptions.group_creatable && groupedByM2O) {
var quickCreate = new ColumnQuickCreate(this);
quickCreate.appendTo(fragment);
// Enable column quickcreate
if (this.columnOptions.group_creatable) {
var quickCreate = new ColumnQuickCreate(this);
quickCreate.appendTo(fragment);
}
}
},
/**
* Renders an ungrouped kanban view in a fragment.
+3 -2
View File
@@ -389,7 +389,6 @@
margin: 0 @o-kanban-record-margin;
height: 50px;
line-height: 2.2;
cursor: move;
.o-flex-display();
.o_column_unfold {
display: none;
@@ -473,7 +472,9 @@
}
}
}
&.ui-sortable .o_kanban_header {
cursor: move;
}
.o_column_quick_create {
background-color: darken(@odoo-webclient-background-color, 10%);
cursor: pointer;
+6 -2
View File
@@ -265,7 +265,7 @@ QUnit.module('Views', {
});
QUnit.test('create in grouped on m2o', function (assert) {
assert.expect(4);
assert.expect(5);
var kanban = createView({
View: KanbanView,
@@ -281,6 +281,8 @@ QUnit.module('Views', {
});
kanban.renderButtons();
assert.ok(kanban.$('.o_kanban_view').hasClass('ui-sortable'),
"columns are sortable when grouped by a m2o field");
assert.ok(kanban.$buttons.find('.o-kanban-button-new').hasClass('btn-primary'),
"'create' button should be btn-primary for grouped kanban with at least one column");
assert.ok(kanban.$('.o_kanban_view > div:last').hasClass('o_column_quick_create'),
@@ -296,7 +298,7 @@ QUnit.module('Views', {
});
QUnit.test('create in grouped on char', function (assert) {
assert.expect(3);
assert.expect(4);
var kanban = createView({
View: KanbanView,
@@ -310,6 +312,8 @@ QUnit.module('Views', {
groupBy: ['foo'],
});
assert.ok(!kanban.$('.o_kanban_view').hasClass('ui-sortable'),
"columns aren't sortable when not grouped by a m2o field");
assert.strictEqual(kanban.$('.o_kanban_group').length, 3, "should have " + 3 + " columns");
assert.strictEqual(kanban.$('.o_kanban_group:first() .o_column_title').text(), "yop",
"'yop' column should be the first column");