2020-09-07 15:04:06 +02:00
|
|
|
/*
|
|
|
|
* OpenSTAManager: il software gestionale open source per l'assistenza tecnica e la fatturazione
|
2021-01-20 15:08:51 +01:00
|
|
|
* Copyright (C) DevCode s.r.l.
|
2020-09-07 15:04:06 +02:00
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
2019-07-26 17:40:52 +02:00
|
|
|
$(document).ready(function () {
|
2021-07-20 20:48:02 +02:00
|
|
|
const widgets = sortable("#widget-top, #widget-right", {
|
|
|
|
forcePlaceholderSize: true,
|
2019-07-26 17:40:52 +02:00
|
|
|
items: 'li',
|
|
|
|
cursor: 'move',
|
|
|
|
dropOnEmpty: true,
|
2021-07-20 20:48:02 +02:00
|
|
|
acceptFrom: '.widget',
|
2019-07-26 17:40:52 +02:00
|
|
|
scroll: true,
|
2021-07-20 20:48:02 +02:00
|
|
|
});
|
2019-07-26 17:40:52 +02:00
|
|
|
|
2021-07-20 20:48:02 +02:00
|
|
|
for (const sorting of widgets) {
|
|
|
|
sorting.addEventListener("sortupdate", function (e) {
|
2019-07-26 17:40:52 +02:00
|
|
|
// Rimuovo l'evidenziazione dell'area widget
|
|
|
|
$('.widget').removeClass('bordered');
|
|
|
|
|
|
|
|
// Salvo la lista su cui ho eseguito il drop
|
2021-07-20 20:48:02 +02:00
|
|
|
const location = $(e.detail.destination.container).attr('id').replace('widget-', '');
|
2019-07-26 17:40:52 +02:00
|
|
|
|
2021-07-20 20:48:02 +02:00
|
|
|
let order = $(".widget li[data-id]").toArray().map(a => $(a).data("id"))
|
|
|
|
$.post(globals.rootdir + "/actions.php", {
|
|
|
|
id_module: globals.order_manager_id,
|
2019-07-26 17:40:52 +02:00
|
|
|
id_module_widget: globals.id_module,
|
2021-07-20 20:48:02 +02:00
|
|
|
op: 'sort_widgets',
|
|
|
|
location: location,
|
|
|
|
order: order.join(','),
|
2019-07-26 17:40:52 +02:00
|
|
|
});
|
2021-07-20 20:48:02 +02:00
|
|
|
});
|
|
|
|
|
|
|
|
sorting.addEventListener("sortstart", function (e) {
|
|
|
|
// Evidenzio le aree dei widget
|
|
|
|
$('.widget').addClass('bordered');
|
|
|
|
});
|
|
|
|
}
|
2019-07-26 17:40:52 +02:00
|
|
|
});
|