[FIX] web_kanban: prevent drag'n'drop
Prevent drag'n'drop in the following cases: - Group by field is read-only - Group by field is a date or datetime This is necessary to avoid, for example, changing the state of a sales order or an invoice without going through all the business logic. Related to #7047 opw-671697
This commit is contained in:
@@ -52,6 +52,7 @@ var KanbanColumn = Widget.extend({
|
||||
this.grouped_by_m2o = options.grouped_by_m2o;
|
||||
this.editable = options.editable;
|
||||
this.deletable = options.deletable;
|
||||
this.draggable = record_options.draggable;
|
||||
this.has_active_field = options.has_active_field;
|
||||
this.records_editable = options.records_editable;
|
||||
this.records_deletable = options.records_deletable;
|
||||
@@ -82,7 +83,7 @@ var KanbanColumn = Widget.extend({
|
||||
}
|
||||
this.$header.tooltip();
|
||||
|
||||
if (config.device.size_class > config.device.SIZES.XS) {
|
||||
if (config.device.size_class > config.device.SIZES.XS && this.draggable !== false) {
|
||||
// deactivate sortable in mobile mode. It does not work anyway,
|
||||
// and it breaks horizontal scrolling in kanban views. Someday, we
|
||||
// should find a way to use the touch events to make sortable work.
|
||||
|
||||
@@ -423,8 +423,34 @@ var KanbanView = View.extend({
|
||||
|
||||
render_grouped: function (fragment) {
|
||||
var self = this;
|
||||
|
||||
// FORWARDPORT UP TO SAAS-10, NOT IN MASTER!
|
||||
// Drag'n'drop activation/deactivation
|
||||
var group_by_field_attrs = this.fields_view.fields[this.group_by_field];
|
||||
|
||||
// Group_by field might not be in the Kanban view, so we need to get it somewhere else...
|
||||
// This somewhere else is on the search view.
|
||||
if (group_by_field_attrs === undefined) {
|
||||
if (this.ViewManager.searchview.groupby_menu && this.ViewManager.searchview.groupby_menu.groupable_fields) {
|
||||
group_by_field_attrs = _.find(this.ViewManager.searchview.groupby_menu.groupable_fields, function(field) {
|
||||
return field.name === self.group_by_field;
|
||||
})
|
||||
}
|
||||
}
|
||||
// Deactivate the drag'n'drop if:
|
||||
// - field is a date or datetime since we group by month
|
||||
// - field is readonly
|
||||
var draggable = true;
|
||||
if (group_by_field_attrs) {
|
||||
if (group_by_field_attrs.type === "date" || group_by_field_attrs.type === "datetime") {
|
||||
var draggable = false;
|
||||
}
|
||||
else if (group_by_field_attrs.readonly !== undefined) {
|
||||
var draggable = !(group_by_field_attrs.readonly);
|
||||
}
|
||||
}
|
||||
var record_options = _.extend(this.record_options, {
|
||||
draggable: true,
|
||||
draggable: draggable,
|
||||
});
|
||||
|
||||
var column_options = this.get_column_options();
|
||||
|
||||
Reference in New Issue
Block a user