Skip to content

Commit 00a8ee2

Browse files
committed
refactor: unificazione funzione di ordinamento righe
1 parent 741a0a8 commit 00a8ee2

7 files changed

Lines changed: 17 additions & 114 deletions

File tree

assets/src/js/functions/init.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,23 @@ function init() {
106106
});
107107

108108
restart_inputs();
109+
110+
sortable(".sortable", {
111+
axis: "y",
112+
handle: ".handle",
113+
cursor: "move",
114+
dropOnEmpty: true,
115+
scroll: true,
116+
})[0].addEventListener("sortupdate", function(e) {
117+
let order = $(".table tr[data-id]").toArray().map(a => $(a).data("id"))
118+
119+
$.post(globals.rootdir + "/actions.php", {
120+
id_module: globals.id_module,
121+
id_record: globals.id_record,
122+
op: "update_position",
123+
order: order.join(","),
124+
});
125+
});
109126
}
110127

111128
/**

modules/contratti/row-list.php

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -645,25 +645,6 @@ function duplicaRiga(id) {
645645
}).catch(swal.noop);
646646
}
647647
648-
$(document).ready(function() {
649-
sortable(".sortable", {
650-
axis: "y",
651-
handle: ".handle",
652-
cursor: "move",
653-
dropOnEmpty: true,
654-
scroll: true,
655-
})[0].addEventListener("sortupdate", function(e) {
656-
let order = $(".table tr[data-id]").toArray().map(a => $(a).data("id"))
657-
658-
$.post(globals.rootdir + "/actions.php", {
659-
id_module: globals.id_module,
660-
id_record: globals.id_record,
661-
op: "update_position",
662-
order: order.join(","),
663-
});
664-
});
665-
});
666-
667648
$(".check").on("change", function() {
668649
let checked = 0;
669650
$(".check").each(function() {

modules/ddt/row-list.php

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -742,25 +742,6 @@ function incollaRighe() {
742742
}).catch(function(err) { swal({ title: "'.tr('Errore').'", text: "'.tr('Impossibile leggere dagli appunti').': " + err, type: "error" }); });
743743
}
744744
745-
$(document).ready(function() {
746-
sortable(".sortable", {
747-
axis: "y",
748-
handle: ".handle",
749-
cursor: "move",
750-
dropOnEmpty: true,
751-
scroll: true,
752-
})[0].addEventListener("sortupdate", function(e) {
753-
let order = $(".table tr[data-id]").toArray().map(a => $(a).data("id"))
754-
755-
$.post(globals.rootdir + "/actions.php", {
756-
id_module: globals.id_module,
757-
id_record: globals.id_record,
758-
op: "update_position",
759-
order: order.join(","),
760-
});
761-
});
762-
});
763-
764745
$(".check").on("change", function() {
765746
let checked = 0;
766747
$(".check").each(function() {

modules/fatture/row-list.php

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -875,25 +875,6 @@ function incollaRighe() {
875875
});
876876
}
877877
878-
$(document).ready(function() {
879-
sortable(".sortable", {
880-
axis: "y",
881-
handle: ".handle",
882-
cursor: "move",
883-
dropOnEmpty: true,
884-
scroll: true,
885-
})[0].addEventListener("sortupdate", function(e) {
886-
let order = $(".table tr[data-id]").toArray().map(a => $(a).data("id"))
887-
888-
$.post(globals.rootdir + "/actions.php", {
889-
id_module: globals.id_module,
890-
id_record: globals.id_record,
891-
op: "update_position",
892-
order: order.join(","),
893-
});
894-
});
895-
});
896-
897878
$(".check").on("change", function() {
898879
let checked = 0;
899880
$(".check").each(function() {

modules/interventi/row-list.php

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -520,25 +520,6 @@ function modificaSeriali(button) {
520520
openModal("'.tr('Aggiorna SN').'", globals.rootdir + "/modules/fatture/add_serial.php?id_module=" + globals.id_module + "&id_record=" + globals.id_record + "&riga_id=" + id + "&riga_type=" + type);
521521
}
522522
523-
$(document).ready(function() {
524-
sortable(".sortable", {
525-
axis: "y",
526-
handle: ".handle",
527-
cursor: "move",
528-
dropOnEmpty: true,
529-
scroll: true,
530-
})[0].addEventListener("sortupdate", function(e) {
531-
let order = $(".table tr[data-id]").toArray().map(a => $(a).data("id"))
532-
533-
$.post(globals.rootdir + "/actions.php", {
534-
id_module: globals.id_module,
535-
id_record: globals.id_record,
536-
op: "update_position",
537-
order: order.join(","),
538-
});
539-
});
540-
});
541-
542523
$(".check").on("change", function() {
543524
let checked = 0;
544525
$(".check").each(function() {

modules/ordini/row-list.php

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -868,25 +868,6 @@ function incollaRighe() {
868868
});
869869
}
870870
871-
$(document).ready(function() {
872-
sortable(".sortable", {
873-
axis: "y",
874-
handle: ".handle",
875-
cursor: "move",
876-
dropOnEmpty: true,
877-
scroll: true,
878-
})[0].addEventListener("sortupdate", function(e) {
879-
let order = $(".table tr[data-id]").toArray().map(a => $(a).data("id"))
880-
881-
$.post(globals.rootdir + "/actions.php", {
882-
id_module: globals.id_module,
883-
id_record: globals.id_record,
884-
op: "update_position",
885-
order: order.join(","),
886-
});
887-
});
888-
});
889-
890871
$(".check").on("change", function() {
891872
let checked = 0;
892873
$(".check").each(function() {

modules/preventivi/row-list.php

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -714,25 +714,6 @@ function duplicaRiga(id) {
714714
}).catch(swal.noop);
715715
}
716716
717-
$(document).ready(function() {
718-
sortable(".sortable", {
719-
axis: "y",
720-
handle: ".handle",
721-
cursor: "move",
722-
dropOnEmpty: true,
723-
scroll: true,
724-
})[0].addEventListener("sortupdate", function(e) {
725-
let order = $(".table tr[data-id]").toArray().map(a => $(a).data("id"))
726-
727-
$.post(globals.rootdir + "/actions.php", {
728-
id_module: globals.id_module,
729-
id_record: globals.id_record,
730-
op: "update_position",
731-
order: order.join(","),
732-
});
733-
});
734-
});
735-
736717
$(".check").on("change", function() {
737718
let checked = 0;
738719
$(".check").each(function() {

0 commit comments

Comments
 (0)