From 9770d034790b92e8a6d7a2933365dfdd48ce21be Mon Sep 17 00:00:00 2001 From: yflory Date: Fri, 3 Sep 2021 13:22:15 +0200 Subject: [PATCH] Disable 'sortable' when editing poll time options --- www/form/app-form.less | 6 ++++++ www/form/inner.js | 14 +++++++++++++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/www/form/app-form.less b/www/form/app-form.less index 031411800..d16aa9ce2 100644 --- a/www/form/app-form.less +++ b/www/form/app-form.less @@ -600,6 +600,12 @@ } } .cp-form-edit-block { + &.cp-no-sortable { + .cp-form-handle { + visibility: hidden; + cursor: default; + } + } button.btn-secondary { margin-left: 30px; margin-bottom: 5px; diff --git a/www/form/inner.js b/www/form/inner.js index ecadea17c..e3a2021b5 100644 --- a/www/form/inner.js +++ b/www/form/inner.js @@ -374,11 +374,16 @@ define([ var container = h('div.cp-form-edit-block', inputs); var $container = $(container); - Sortable.create(container, { + var sortableOption = Sortable.create(container, { direction: "vertical", handle: ".cp-form-handle", draggable: ".cp-form-edit-block-input", forceFallback: true, + store: { + set: function () { + evOnSave.fire(); + } + } }); var containerItems; @@ -393,6 +398,11 @@ define([ handle: ".cp-form-handle", draggable: ".cp-form-edit-block-input", forceFallback: true, + store: { + set: function () { + evOnSave.fire(); + } + } }); } @@ -456,6 +466,8 @@ define([ var refreshView = function () { if (!v.type) { return; } var $calendar = $(calendarView); + sortableOption.option("disabled", v.type !== "text"); + $container.toggleClass('cp-no-sortable', v.type !== "text"); if (v.type !== "day") { $calendar.hide(); $container.show();