fix ESM module import (no currly brackets) as suggested by Guy Bedford

This commit is contained in:
Ralf Becker 2021-08-11 19:28:01 +02:00
parent 23c27659fc
commit 72699fad30
4 changed files with 61 additions and 71 deletions

View File

@ -67,6 +67,7 @@ import {et2_template} from "./et2_widget_template";
import {egw} from "../jsapi/egw_global"; import {egw} from "../jsapi/egw_global";
import {et2_compileLegacyJS} from "./et2_core_legacyJSFunctions"; import {et2_compileLegacyJS} from "./et2_core_legacyJSFunctions";
import {egwIsMobile} from "../egw_action/egw_action_common.js"; import {egwIsMobile} from "../egw_action/egw_action_common.js";
import Sortable from 'sortablejs/modular/sortable.complete.esm.js';
//import {et2_selectAccount} from "./et2_widget_SelectAccount"; //import {et2_selectAccount} from "./et2_widget_SelectAccount";
@ -2079,17 +2080,13 @@ export class et2_nextmatch extends et2_DOMWidget implements et2_IResizeable, et2
}; };
const $select = jQuery(select.getDOMNode()); const $select = jQuery(select.getDOMNode());
//todo (todo-jquery-ui): fix the sortable import statement
import('../../../node_modules/sortablejs/Sortable.min.js').then(function(){
let sortablejs = Sortable.create(select.getDOMNode().getElementsByClassName('ui-multiselect-checkboxes')[0], { let sortablejs = Sortable.create(select.getDOMNode().getElementsByClassName('ui-multiselect-checkboxes')[0], {
ghostClass: 'ui-fav-sortable-placeholder', ghostClass: 'ui-fav-sortable-placeholder',
draggable: 'li[class^="selcolumn_sortable_col"]', draggable: 'li[class^="selcolumn_sortable_col"]',
filter: 'li[class^="selcolumn_sortable_#"]', filter: 'li[class^="selcolumn_sortable_#"]',
direction: 'vertical', direction: 'vertical',
delay: 25, delay: 25,
}); });
}.bind(this));
$select.disableSelection(); $select.disableSelection();
$select.find('li[class^="selcolumn_sortable_"]').each(function(i,v){ $select.find('li[class^="selcolumn_sortable_"]').each(function(i,v){

View File

@ -19,6 +19,7 @@ import {et2_INextmatchHeader} from "./et2_extension_nextmatch";
import {et2_dropdown_button} from "./et2_widget_dropdown_button"; import {et2_dropdown_button} from "./et2_widget_dropdown_button";
import {ClassWithAttributes} from "./et2_core_inheritance"; import {ClassWithAttributes} from "./et2_core_inheritance";
import {egw, egw_getFramework} from "../jsapi/egw_global"; import {egw, egw_getFramework} from "../jsapi/egw_global";
import Sortable from 'sortablejs/modular/sortable.complete.esm.js';
/** /**
* Favorites widget, designed for use with a nextmatch widget * Favorites widget, designed for use with a nextmatch widget
@ -177,13 +178,11 @@ export class et2_favorites extends et2_dropdown_button implements et2_INextmatch
} }
}; };
//todo (@todo-jquery-ui): replace the import statement
/** /**
* todo (@todo-jquery-ui): the sorting does not work at the moment becuase of jquery-ui menu being used in order to create dropdown * todo (@todo-jquery-ui): the sorting does not work at the moment becuase of jquery-ui menu being used in order to create dropdown
* buttons menu. Once we replace the et2_widget_dropdown_button with web component this should be adapted * buttons menu. Once we replace the et2_widget_dropdown_button with web component this should be adapted
* and working again. * and working again.
**/ **/
import('../../../node_modules/sortablejs/Sortable.min.js').then(function(){
let sortablejs = Sortable.create(this.menu[0], { let sortablejs = Sortable.create(this.menu[0], {
ghostClass: 'ui-fav-sortable-placeholder', ghostClass: 'ui-fav-sortable-placeholder',
draggable: 'li:not([data-id$="add"])', draggable: 'li:not([data-id$="add"])',
@ -195,7 +194,6 @@ export class et2_favorites extends et2_dropdown_button implements et2_INextmatch
sideBoxDOMNodeSort(self.favSortedList); sideBoxDOMNodeSort(self.favSortedList);
} }
}); });
}.bind(this));
// Add a listener on the delete to remove // Add a listener on the delete to remove
this.menu.on("click","div.ui-icon-trash", app[self.options.app], function() { this.menu.on("click","div.ui-icon-trash", app[self.options.app], function() {

View File

@ -23,6 +23,7 @@ import {et2_action_object_impl, et2_DOMWidget} from "./et2_core_DOMWidget";
import {egw_getAppObjectManager, egwActionObject} from '../egw_action/egw_action.js'; import {egw_getAppObjectManager, egwActionObject} from '../egw_action/egw_action.js';
import {et2_directChildrenByTagName, et2_filteredNodeIterator, et2_readAttrWithDefault} from "./et2_core_xml"; import {et2_directChildrenByTagName, et2_filteredNodeIterator, et2_readAttrWithDefault} from "./et2_core_xml";
import {egw} from "../jsapi/egw_global"; import {egw} from "../jsapi/egw_global";
import Sortable from 'sortablejs/modular/sortable.complete.esm.js';
/** /**
@ -961,9 +962,6 @@ export class et2_grid extends et2_DOMWidget implements et2_IDetachedDOM, et2_IAl
} }
} }
//todo (todo-jquery-ui): fix the sortable import statement
import('../../../node_modules/sortablejs/Sortable.min.js').then(function(){
this.sortablejs = new Sortable(tbody,{ this.sortablejs = new Sortable(tbody,{
group: this.options.sortable_connectWith, group: this.options.sortable_connectWith,
draggable: "tr:not(.th)", draggable: "tr:not(.th)",
@ -991,7 +989,6 @@ export class et2_grid extends et2_DOMWidget implements et2_IDetachedDOM, et2_IAl
).sendRequest(); ).sendRequest();
}, },
}); });
}.bind(this));
} }
/** /**

View File

@ -17,6 +17,7 @@ import {et2_dialog} from "../etemplate/et2_widget_dialog";
import {et2_createWidget} from "../etemplate/et2_core_widget"; import {et2_createWidget} from "../etemplate/et2_core_widget";
import {et2_favorites} from "../etemplate/et2_widget_favorites"; import {et2_favorites} from "../etemplate/et2_widget_favorites";
import type {IegwAppLocal} from "./egw_global"; import type {IegwAppLocal} from "./egw_global";
import Sortable from 'sortablejs/modular/sortable.complete.esm.js';
/** /**
* Type for push-message * Type for push-message
@ -781,8 +782,6 @@ export abstract class EgwApp
}) })
.addClass("ui-helper-clearfix"); .addClass("ui-helper-clearfix");
//todo (@todo-jquery-ui): replace the import statement
import('../../../node_modules/sortablejs/Sortable.min.js').then(function(){
let el = document.getElementById('favorite_sidebox_'+this.appname).getElementsByTagName('ul')[0]; let el = document.getElementById('favorite_sidebox_'+this.appname).getElementsByTagName('ul')[0];
let sortablejs = Sortable.create(el, { let sortablejs = Sortable.create(el, {
ghostClass: 'ui-fav-sortable-placeholder', ghostClass: 'ui-fav-sortable-placeholder',
@ -795,7 +794,6 @@ export abstract class EgwApp
self._refresh_fav_nm(); self._refresh_fav_nm();
} }
}); });
}.bind(this));
// Bind favorite de-select // Bind favorite de-select
var egw_fw = egw_getFramework(); var egw_fw = egw_getFramework();