From 7623f3ecf7bc9ab54d293430969c31ffdbfd313b Mon Sep 17 00:00:00 2001 From: Samuel Degueldre Date: Wed, 16 Oct 2019 12:24:22 +0000 Subject: [PATCH] [IMP] website: add quick move buttons for sections and columns This commit adds buttons to move sections up or down and to move columns left or right, which is more user-friendly than drag-and-drop in some cases. Part of https://github.com/odoo/odoo/pull/38959 maintask-2066614 task-2088265 --- .../static/src/js/editor/snippets.options.js | 33 +++++++++++++++++++ addons/website/views/snippets.xml | 12 +++++++ 2 files changed, 45 insertions(+) diff --git a/addons/website/static/src/js/editor/snippets.options.js b/addons/website/static/src/js/editor/snippets.options.js index ea8e048b9fe..8d26b20038d 100644 --- a/addons/website/static/src/js/editor/snippets.options.js +++ b/addons/website/static/src/js/editor/snippets.options.js @@ -1848,4 +1848,37 @@ options.registry.SectionStretch = options.Class.extend({ this.$el.find('[data-toggle-container-fluid]').toggleClass('active', isFluid); }, }); + +/** + * Allows snippets to be moved before the preceding element or after the following. + */ +options.registry.SnippetMove = options.Class.extend({ + + /** + * @override + */ + isTopOption: function () { + return true; + }, + + //-------------------------------------------------------------------------- + // Options + //-------------------------------------------------------------------------- + + /** + * Moves the snippet around. + * + * @see this.selectClass for parameters + */ + moveSnippet: function (previewMode, value, $opt) { + switch (value) { + case 'prev': + this.$target.prev().before(this.$target); + break; + case 'next': + this.$target.next().after(this.$target); + break; + } + }, +}); }); diff --git a/addons/website/views/snippets.xml b/addons/website/views/snippets.xml index 7e9fffa0ad9..ef7d054fe88 100644 --- a/addons/website/views/snippets.xml +++ b/addons/website/views/snippets.xml @@ -1220,6 +1220,18 @@ + +
+ + +
+
+ + +
+