From 869a5b83a57d8a4132507fe89e2bf59c8f5336db Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aur=C3=A9lien=20Warnon?= Date: Thu, 16 May 2019 14:51:12 +0000 Subject: [PATCH] [IMP] web: add capability to disable records drag/drop on kanban views This commit adds a recordsDraggable option on the kanban view that allows to completly disable the drag and drop feature. This is a preliminary work for the social 'Feeds' kanban where the user should not be able to drag and drop posts. --- addons/web/static/src/js/views/kanban/kanban_column.js | 3 ++- addons/web/static/src/js/views/kanban/kanban_view.js | 1 + doc/reference/views.rst | 2 ++ 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/addons/web/static/src/js/views/kanban/kanban_column.js b/addons/web/static/src/js/views/kanban/kanban_column.js index b4aecd7a236..0facd099370 100644 --- a/addons/web/static/src/js/views/kanban/kanban_column.js +++ b/addons/web/static/src/js/views/kanban/kanban_column.js @@ -59,6 +59,7 @@ var KanbanColumn = Widget.extend({ this.KanbanRecord = options.KanbanRecord || KanbanRecord; // the KanbanRecord class to use this.records_editable = options.records_editable; this.records_deletable = options.records_deletable; + this.recordsDraggable = options.recordsDraggable; this.relation = options.relation; this.offset = 0; this.remaining = data.count - this.data_records.length; @@ -100,7 +101,7 @@ var KanbanColumn = Widget.extend({ defs.push(this._addRecord(this.data_records[i])); } - if (!config.device.isMobile) { + if (this.recordsDraggable && !config.device.isMobile) { // 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. diff --git a/addons/web/static/src/js/views/kanban/kanban_view.js b/addons/web/static/src/js/views/kanban/kanban_view.js index 62205a2fc46..d265ca6ae6b 100644 --- a/addons/web/static/src/js/views/kanban/kanban_view.js +++ b/addons/web/static/src/js/views/kanban/kanban_view.js @@ -65,6 +65,7 @@ var KanbanView = BasicView.extend({ archivable: archAttrs.archivable ? !!JSON.parse(archAttrs.archivable) : true, group_creatable: activeActions.group_create && !config.device.isMobile, quickCreateView: archAttrs.quick_create_view || null, + recordsDraggable: archAttrs.records_draggable ? !!JSON.parse(archAttrs.records_draggable) : true, hasProgressBar: !!progressBar, }; this.rendererParams.record_options = { diff --git a/doc/reference/views.rst b/doc/reference/views.rst index 5e6fa266d93..9ab78b45073 100644 --- a/doc/reference/views.rst +++ b/doc/reference/views.rst @@ -1052,6 +1052,8 @@ attributes: whether it should be possible to create records without switching to the form view. By default, ``quick_create`` is enabled when the Kanban view is grouped by many2one, selection, char or boolean fields, and disabled when not. +``records_draggable`` + whether it should be possible to drag records when kanban is grouped. Default: true. Set to ``true`` to always enable it, and to ``false`` to always disable it.