Replace all jquery-ui sortable used in fw

This commit is contained in:
Hadi Nategh
2022-05-23 17:45:56 +02:00
parent 0ac617eb15
commit 1afcc3ebce
3 changed files with 26 additions and 30 deletions

View File

@ -13,6 +13,7 @@
*/
import '../jsapi/egw_inheritance.js';
import {et2_IPrint} from "../etemplate/et2_core_interfaces";
import "sortablejs/Sortable.min.js";
window.fw_base = (function(){ "use strict"; return Class.extend(
{
@ -387,21 +388,24 @@ window.fw_base = (function(){ "use strict"; return Class.extend(
// reliable init sidebox, as app.js might initialise earlier
if (typeof app[_app.appName] == 'object')
{
var sidebox = jQuery('#favorite_sidebox_'+_app.appName, this.sidemenuDiv);
var sidebox = jQuery('#favorite_sidebox_'+_app.appName, this.sidemenuDiv).getElementsByTagName('ul')[0];
var self = this;
var currentAppName = _app.appName;
// make sidebox
sidebox.children().sortable({
items:'li:not([data-id$="add"])',
placeholder:'ui-fav-sortable-placeholder',
update: function (event, ui)
let sortablejs = Sortable.create(sidebox, {
ghostClass: 'ui-fav-sortable-placeholder',
draggable: 'li:not([data-id$="add"])',
delay: 25,
dataIdAttr: 'data-id',
onSort: function(event)
{
var favSortedList = jQuery(this).sortable('toArray', {attribute:'data-id'});
egw().set_preference(currentAppName,'fav_sort_pref',favSortedList);
let favSortedList = sortablejs.toArray();
self.egw.set_preference(currentAppName, 'fav_sort_pref', favSortedList);
self._refresh_fav_nm();
}
});
if (sidebox.length) app[_app.appName]._init_sidebox.call(app[_app.appName], sidebox);
}
}