diff --git a/assets/src/css/style.css b/assets/src/css/style.css index 0ba672be8..0f3c87898 100755 --- a/assets/src/css/style.css +++ b/assets/src/css/style.css @@ -1085,6 +1085,14 @@ div.tip { background-color: rgba(255, 99, 71, 0.6) !important; } -.login-box .img-responsive{ +.login-box .img-responsive { padding: 18px 0px 4px; } + +.no-selection { + -webkit-touch-callout: none; + -webkit-user-select: none; + -moz-user-select: none; + -ms-user-select: none; + user-select: none; +} diff --git a/assets/src/js/base/sidebar.js b/assets/src/js/base/sidebar.js index 906b847aa..c0c292e88 100644 --- a/assets/src/js/base/sidebar.js +++ b/assets/src/js/base/sidebar.js @@ -40,21 +40,21 @@ $(document).ready(function () { } // Menu ordinabile - $(".sidebar-menu").sortable({ - cursor: 'move', + if (!globals.is_mobile) { + sortable(".sidebar-menu", { + axis: "y", + cursor: "move", + dropOnEmpty: true, + scroll: true, + })[0].addEventListener("sortupdate", function(e) { + let order = $(".sidebar-menu > .treeview[data-id]").toArray().map(a => $(a).data("id")) - stop: function (event, ui) { - let order = $(this).sortable('toArray').toString(); - - $.post(globals.rootdir + "/actions.php?id_module=" + globals.order_manager_id, { - op: 'sort_modules', - ids: order + $.post(globals.rootdir + "/actions.php", { + id_module: globals.order_manager_id, + op: "sort_modules", + order: order.join(","), }); - } - }); - - if (globals.is_mobile) { - $(".sidebar-menu").sortable("disable"); + }); } $(".sidebar-toggle").click(function () { diff --git a/assets/src/js/base/widgets.js b/assets/src/js/base/widgets.js index 4736df14a..3aae07b43 100644 --- a/assets/src/js/base/widgets.js +++ b/assets/src/js/base/widgets.js @@ -17,35 +17,36 @@ */ $(document).ready(function () { - $("#widget-top, #widget-right").sortable({ + const widgets = sortable("#widget-top, #widget-right", { + forcePlaceholderSize: true, items: 'li', cursor: 'move', dropOnEmpty: true, - connectWith: '.widget', + acceptFrom: '.widget', scroll: true, - helper: 'clone', - start: function (event, ui) { - // Salvo la lista da cui proviene il drag - src_list = ($(this).attr('id')).replace('widget-', ''); + }); - // Evidenzio le aree dei widget - $('.widget').addClass('bordered').sortable('refreshPositions'); - }, - stop: function (event, ui) { + for (const sorting of widgets) { + sorting.addEventListener("sortupdate", function (e) { // Rimuovo l'evidenziazione dell'area widget $('.widget').removeClass('bordered'); // Salvo la lista su cui ho eseguito il drop - dst_list = (ui.item.parent().attr('id')).replace('widget-', ''); + const location = $(e.detail.destination.container).attr('id').replace('widget-', ''); - var order = $(this).sortable('toArray').toString(); - $.post(globals.rootdir + "/actions.php?id_module=" + globals.order_manager_id, { - op: 'sort_widgets', - location: dst_list, - ids: order, + let order = $(".widget li[data-id]").toArray().map(a => $(a).data("id")) + $.post(globals.rootdir + "/actions.php", { + id_module: globals.order_manager_id, id_module_widget: globals.id_module, - id_record: globals.id_record, + op: 'sort_widgets', + location: location, + order: order.join(','), }); - } - }); + }); + + sorting.addEventListener("sortstart", function (e) { + // Evidenzio le aree dei widget + $('.widget').addClass('bordered'); + }); + } }); diff --git a/gulpfile.js b/gulpfile.js index f34e24a0d..e13758c78 100755 --- a/gulpfile.js +++ b/gulpfile.js @@ -86,7 +86,7 @@ const JS = gulp.parallel(() => { 'html5sortable/dist/html5sortable.js', 'bootstrap-colorpicker/dist/js/bootstrap-colorpicker.js', 'moment/moment.js', - //'components-jqueryui/jquery-ui.js', + 'components-jqueryui/jquery-ui.js', 'datatables.net/js/jquery.dataTables.js', 'datatables.net-buttons/js/dataTables.buttons.js', 'datatables.net-buttons/js/buttons.colVis.js', diff --git a/include/colonne.php b/include/colonne.php index 1ce8a8c94..6746474fb 100644 --- a/include/colonne.php +++ b/include/colonne.php @@ -30,7 +30,7 @@ $fields = $dbo->fetchArray('SELECT *, (SELECT GROUP_CONCAT(zz_groups.nome) FROM foreach ($fields as $field) { echo '
-
+
'.$field['name'].'
( '.$field['gruppi_con_accesso'].')
@@ -76,22 +76,19 @@ echo ' // Ordinamento dinamico delle colonne $(document).ready(function() { - $(".sortable").disableSelection(); - $(".sortable").each(function() { - $(this).sortable({ - cursor: "move", - dropOnEmpty: true, - scroll: true, - update: function(event, ui) { - let order = $(".panel[data-id]").toArray().map(a => $(a).data("id")) + sortable(".sortable", { + axis: "y", + cursor: "move", + dropOnEmpty: true, + scroll: true, + })[0].addEventListener("sortupdate", function(e) { + let order = $(".panel[data-id]").toArray().map(a => $(a).data("id")) + console.log(order); - $.post(globals.rootdir + "/actions.php", { - id: ui.item.data("id"), - id_module: "'.$id_module.'", - op: "ordina_colonne", - order: order.join(","), - }); - } + $.post(globals.rootdir + "/actions.php", { + id_module: globals.id_module, + op: "ordina_colonne", + order: order.join(","), }); }); }); diff --git a/modules/contratti/row-list.php b/modules/contratti/row-list.php index 5f553543b..6b9cac5d9 100755 --- a/modules/contratti/row-list.php +++ b/modules/contratti/row-list.php @@ -299,25 +299,21 @@ function rimuoviRiga(button) { } $(document).ready(function() { - $(".sortable").each(function() { - $(this).sortable({ - axis: "y", - handle: ".handle", - cursor: "move", - dropOnEmpty: true, - scroll: true, - update: function(event, ui) { - let order = $(".table tr[data-id]").toArray().map(a => $(a).data("id")) + sortable(".sortable", { + axis: "y", + handle: ".handle", + cursor: "move", + dropOnEmpty: true, + scroll: true, + })[0].addEventListener("sortupdate", function(e) { + let order = $(".table tr[data-id]").toArray().map(a => $(a).data("id")) - $.post(globals.rootdir + "/actions.php", { - id: ui.item.data("id"), - id_module: '.$id_module.', - id_record: '.$id_record.', - op: "update_position", - order: order.join(","), - }); - } - }); - }); + $.post(globals.rootdir + "/actions.php", { + id_module: globals.id_module, + id_record: globals.id_record, + op: "update_position", + order: order.join(","), + }); + }); }); '; diff --git a/modules/ddt/row-list.php b/modules/ddt/row-list.php index c82249e7c..4d09ca89f 100755 --- a/modules/ddt/row-list.php +++ b/modules/ddt/row-list.php @@ -373,25 +373,21 @@ function apriRiferimenti(button) { } $(document).ready(function() { - $(".sortable").each(function() { - $(this).sortable({ - axis: "y", - handle: ".handle", - cursor: "move", - dropOnEmpty: true, - scroll: true, - update: function(event, ui) { - let order = $(".table tr[data-id]").toArray().map(a => $(a).data("id")) + sortable(".sortable", { + axis: "y", + handle: ".handle", + cursor: "move", + dropOnEmpty: true, + scroll: true, + })[0].addEventListener("sortupdate", function(e) { + let order = $(".table tr[data-id]").toArray().map(a => $(a).data("id")) - $.post(globals.rootdir + "/actions.php", { - id: ui.item.data("id"), - id_module: '.$id_module.', - id_record: '.$id_record.', - op: "update_position", - order: order.join(","), - }); - } - }); - }); + $.post(globals.rootdir + "/actions.php", { + id_module: globals.id_module, + id_record: globals.id_record, + op: "update_position", + order: order.join(","), + }); + }); }); '; diff --git a/modules/fatture/row-list.php b/modules/fatture/row-list.php index 4ef74526b..8cc19a4dc 100755 --- a/modules/fatture/row-list.php +++ b/modules/fatture/row-list.php @@ -474,25 +474,21 @@ function apriInformazioniFE(button) { } $(document).ready(function() { - $(".sortable").each(function() { - $(this).sortable({ - axis: "y", - handle: ".handle", - cursor: "move", - dropOnEmpty: true, - scroll: true, - update: function(event, ui) { - let order = $(".table tr[data-id]").toArray().map(a => $(a).data("id")) + sortable(".sortable", { + axis: "y", + handle: ".handle", + cursor: "move", + dropOnEmpty: true, + scroll: true, + })[0].addEventListener("sortupdate", function(e) { + let order = $(".table tr[data-id]").toArray().map(a => $(a).data("id")) - $.post(globals.rootdir + "/actions.php", { - id: ui.item.data("id"), - id_module: '.$id_module.', - id_record: '.$id_record.', - op: "update_position", - order: order.join(","), - }); - } - }); - }); + $.post(globals.rootdir + "/actions.php", { + id_module: globals.id_module, + id_record: globals.id_record, + op: "update_position", + order: order.join(","), + }); + }); }); '; diff --git a/modules/ordini/row-list.php b/modules/ordini/row-list.php index 14ec21b05..ad4a8434d 100755 --- a/modules/ordini/row-list.php +++ b/modules/ordini/row-list.php @@ -402,25 +402,21 @@ function apriRiferimenti(button) { } $(document).ready(function() { - $(".sortable").each(function() { - $(this).sortable({ - axis: "y", - handle: ".handle", - cursor: "move", - dropOnEmpty: true, - scroll: true, - update: function(event, ui) { - let order = $(".table tr[data-id]").toArray().map(a => $(a).data("id")) + sortable(".sortable", { + axis: "y", + handle: ".handle", + cursor: "move", + dropOnEmpty: true, + scroll: true, + })[0].addEventListener("sortupdate", function(e) { + let order = $(".table tr[data-id]").toArray().map(a => $(a).data("id")) - $.post(globals.rootdir + "/actions.php", { - id: ui.item.data("id"), - id_module: '.$id_module.', - id_record: '.$id_record.', - op: "update_position", - order: order.join(","), - }); - } - }); - }); + $.post(globals.rootdir + "/actions.php", { + id_module: globals.id_module, + id_record: globals.id_record, + op: "update_position", + order: order.join(","), + }); + }); }); '; diff --git a/modules/preventivi/row-list.php b/modules/preventivi/row-list.php index 6a847bd71..6eea49daf 100755 --- a/modules/preventivi/row-list.php +++ b/modules/preventivi/row-list.php @@ -366,25 +366,21 @@ function rimuoviRiga(button) { } $(document).ready(function() { - $(".sortable").each(function() { - $(this).sortable({ - axis: "y", - handle: ".handle", - cursor: "move", - dropOnEmpty: true, - scroll: true, - update: function(event, ui) { - let order = $(".table .sortable tr[data-id]").toArray().map(a => $(a).data("id")) + sortable(".sortable", { + axis: "y", + handle: ".handle", + cursor: "move", + dropOnEmpty: true, + scroll: true, + })[0].addEventListener("sortupdate", function(e) { + let order = $(".table tr[data-id]").toArray().map(a => $(a).data("id")) - $.post(globals.rootdir + "/actions.php", { - id: ui.item.data("id"), - id_module: '.$id_module.', - id_record: '.$id_record.', - op: "update_position", - order: order.join(","), - }); - } - }); - }); + $.post(globals.rootdir + "/actions.php", { + id_module: globals.id_module, + id_record: globals.id_record, + op: "update_position", + order: order.join(","), + }); + }); }); '; diff --git a/modules/stato_servizi/actions.php b/modules/stato_servizi/actions.php index 8f207da76..b23573a4d 100755 --- a/modules/stato_servizi/actions.php +++ b/modules/stato_servizi/actions.php @@ -121,38 +121,21 @@ switch (filter('op')) { // Ordinamento moduli di primo livello case 'sort_modules': - $rs = $dbo->fetchArray('SELECT id FROM zz_modules WHERE enabled = 1 AND parent IS NULL ORDER BY `order` ASC'); + $order = explode(',', post('order', true)); - if ($_POST['ids'] != implode(',', array_column($rs, 'id'))) { - $ids = explode(',', $_POST['ids']); - - for ($i = 0; $i < count($ids); ++$i) { - $dbo->query('UPDATE zz_modules SET `order`='.prepare($i).' WHERE id='.prepare($ids[$i])); - } - - flash()->info(tr('Posizione delle voci di menĂ¹ aggiornata!')); + foreach ($order as $i => $id) { + $dbo->query('UPDATE zz_modules SET `order`='.prepare($i).' WHERE id='.prepare($id)); } break; case 'sort_widgets': - $location = post('location'); - $id_module_widget = post('id_module_widget'); + $order = explode(',', post('order', true)); - $location = empty($id_record) ? 'controller_'.$location : 'editor_'.$location; - - $rs = $dbo->fetchArray("SELECT CONCAT('widget_', id) AS id FROM zz_widgets WHERE enabled = 1 AND location = ".prepare($location).' AND id_module = '.prepare($id_module_widget).' ORDER BY `order` ASC'); - - if ($_POST['ids'] != implode(',', array_column($rs, 'id'))) { - $ids = explode(',', $_POST['ids']); - - for ($i = 0; $i < count($ids); ++$i) { - $id = explode('_', $ids[$i]); - $dbo->query('UPDATE zz_widgets SET `order`='.prepare($i).' WHERE id='.prepare($id[1])); - } - - flash()->info(tr('Posizioni widgets aggiornate!')); + foreach ($order as $i => $id) { + $dbo->query('UPDATE zz_widgets SET `order`='.prepare($i).' WHERE id='.prepare($id)); } + break; case 'sizes': diff --git a/modules/viste/fields.php b/modules/viste/fields.php index dc674c236..cb03faaca 100755 --- a/modules/viste/fields.php +++ b/modules/viste/fields.php @@ -144,7 +144,7 @@ echo ' foreach ($fields as $field) { echo ' -

+

'; @@ -243,30 +243,19 @@ echo ' $(document).ready(function() { $("#save-buttons").hide(); - $(".sortable").disableSelection(); - $(".sortable").each(function() { - $(this).sortable({ - axis: "y", - cursor: "move", - dropOnEmpty: true, - scroll: true, - update: function(event, ui) { + sortable(".sortable", { + axis: "y", + cursor: "move", + dropOnEmpty: true, + scroll: true, + })[0].addEventListener("sortupdate", function(e) { + let order = $(".sortable p[data-id]").toArray().map(a => $(a).data("id")) - var order = ""; - $("div.panel-body.sortable p[data-id]").each( function() { - order += ","+$(this).data("id"); - }); - - order = order.replace(/^,/, ""); - - $.post(globals.rootdir + "/actions.php", { - id: ui.item.data("id"), - id_module: '.$id_module.', - id_record: '.$id_record.', - op: "update_position", - order: order, - }); - } + $.post(globals.rootdir + "/actions.php", { + id_module: globals.id_module, + id_record: globals.id_record, + op: "update_position", + order: order.join(","), }); }); }); diff --git a/plugins/checks.php b/plugins/checks.php index 2fe1bee40..9f6635891 100755 --- a/plugins/checks.php +++ b/plugins/checks.php @@ -84,29 +84,25 @@ $(document).ready(function() { id_record: "'.$id_record.'", }, "'.$checks_id.'"); - $(".checklist").sortable({ + sortable(".checklist", { placeholder: "sort-highlight", handle: ".handle", forcePlaceholderSize: true, zIndex: 999999, - update: function(event, ui) { - var order = []; - $(".checklist > li").each( function(){ - order.push($(this).data("id")); - }); + })[0].addEventListener("sortupdate", function(e) { + let order = $(".checklist > li[data-id]").toArray().map(a => $(a).data("id")) - $.post(globals.rootdir + "/actions.php", { - id_module: "'.$id_module.'", - id_plugin: "'.$id_plugin.'", - id_record: "'.$id_record.'", + $.post(globals.rootdir + "/actions.php", { + id_module: globals.id_module, + id_plugin: "'.$id_plugin.'", + id_record: globals.id_record, op: "ordina-checks", - order: order.join(","), - }); - } + order: order.join(","), + }); }); $(".checklist").todoList({ - onCheck : function () { + onCheck: function () { var id = $(this).parent().data("id"); checklists["'.$checks_id.'"].toggleCheck(id); diff --git a/src/HTMLBuilder/Manager/WidgetManager.php b/src/HTMLBuilder/Manager/WidgetManager.php index 34f9532a2..ad9597861 100755 --- a/src/HTMLBuilder/Manager/WidgetManager.php +++ b/src/HTMLBuilder/Manager/WidgetManager.php @@ -258,7 +258,7 @@ class WidgetManager implements ManagerInterface // Aggiungo ad uno ad uno tutti i widget foreach ($widgets as $widget) { $result .= ' -

  • '; +
  • '; $info = array_merge($options, [ 'id' => $widget['id'], diff --git a/src/Modules.php b/src/Modules.php index 0452aca20..f411b85c9 100755 --- a/src/Modules.php +++ b/src/Modules.php @@ -357,7 +357,7 @@ class Modules if ($active) { $result .= ' active actual'; } - $result .= '" id="'.$element['id'].'"> + $result .= '" id="'.$element['id'].'" data-id="'.$element['id'].'"> '.$title.'';