From 2c196d341937e9ad4e0ae27c3934d1b89e09d3d1 Mon Sep 17 00:00:00 2001 From: nathan Date: Mon, 30 Sep 2024 13:58:31 -0600 Subject: [PATCH] Fix drag & drop onto tree items loaded via ajax did not hightlight on drag enter --- api/js/egw_action/EgwDragDropShoelaceTree.ts | 93 +++++++++++--------- api/js/etemplate/Et2Tree/Et2Tree.ts | 6 ++ mail/js/app.js | 2 +- 3 files changed, 60 insertions(+), 41 deletions(-) diff --git a/api/js/egw_action/EgwDragDropShoelaceTree.ts b/api/js/egw_action/EgwDragDropShoelaceTree.ts index 19d8bf3e11..41681a3d61 100644 --- a/api/js/egw_action/EgwDragDropShoelaceTree.ts +++ b/api/js/egw_action/EgwDragDropShoelaceTree.ts @@ -24,50 +24,63 @@ export class EgwDragDropShoelaceTree extends egwActionObjectInterface{ // Reference to the widget that's handling actions for us public findActionTargetHandler : EgwActionObject; - constructor(_tree:Et2Tree, _itemId: string) { - super(); - this.node = _tree.getDomNode(_itemId); - this.id = _itemId - this.tree = _tree + private timeout : ReturnType; + + constructor(_tree : Et2Tree) + { + + super(); + this.tree = _tree this.findActionTargetHandler = _tree.widget_object; - this.doGetDOMNode = function () { - return this.node; - } - let timeout: NodeJS.Timeout; + } - this.doTriggerEvent = function (_event) { - if (_event == EGW_AI_DRAG_ENTER) - { + public doTriggerEvent(egw_event : number, dom_event : Event) + { + const target = this.tree.findActionTarget(dom_event); + if(egw_event == EGW_AI_DRAG_ENTER) + { + target.target.classList.add("draggedOver", "drop-hover"); + this.timeout = setTimeout(() => + { + if(target.target.classList.contains("draggedOver")) + { + (target.target).expanded = true + } + }, EXPAND_FOLDER_ON_DRAG_DROP_TIMEOUT) + } + else if(egw_event == EGW_AI_DRAG_OUT) + { + target.target.classList.remove("draggedOver", "drop-hover"); + clearTimeout(this.timeout) + } + else + { + debugger; + } + return true + } - this.node.classList.add("draggedOver", "drop-hover"); - timeout = setTimeout(() => { - if (this.node.classList.contains("draggedOver")) - { - this.node.expanded = true - } - }, EXPAND_FOLDER_ON_DRAG_DROP_TIMEOUT) - } - if (_event == EGW_AI_DRAG_OUT) - { - (this.node).classList.remove("draggedOver", "drop-hover"); - clearTimeout(timeout) - } - return true - } + public doSetState(_state) + { + if(!this.tree || !this.tree.focusItem) + { + return; + } - this.doSetState = function (_state) { - if (!_tree || !_tree.focusItem) return; + // Update the "focused" flag + if(egwBitIsSet(_state, EGW_AO_STATE_FOCUSED)) + { + this.tree.focusItem(this.id); + } + if(egwBitIsSet(_state, EGW_AO_STATE_SELECTED)) + { + // _tree.selectItem(this.id, false); // false = do not trigger onSelect + } + } - // Update the "focused" flag - if (egwBitIsSet(_state, EGW_AO_STATE_FOCUSED)) - { - _tree.focusItem(this.id); - } - if (egwBitIsSet(_state, EGW_AO_STATE_SELECTED)) - { - // _tree.selectItem(this.id, false); // false = do not trigger onSelect - } - } - } + doGetDOMNode() + { + return this.tree; + } } \ No newline at end of file diff --git a/api/js/etemplate/Et2Tree/Et2Tree.ts b/api/js/etemplate/Et2Tree/Et2Tree.ts index 3f09f9d8bb..95e72b7eda 100644 --- a/api/js/etemplate/Et2Tree/Et2Tree.ts +++ b/api/js/etemplate/Et2Tree/Et2Tree.ts @@ -1291,6 +1291,12 @@ export class Et2Tree extends Et2WidgetWithSelectMixin(LitElement) implements Fin return element.tagName == "SL-TREE-ITEM" }); let action : EgwActionObject = this.widget_object.getObjectById(target.id); + + // Create on the fly if not there? + if(!action) + { + debugger; + } return {target: target, action: action}; } } diff --git a/mail/js/app.js b/mail/js/app.js index c2cba36f7a..a7bd51f436 100755 --- a/mail/js/app.js +++ b/mail/js/app.js @@ -3693,7 +3693,7 @@ app.classes.mail = AppJS.extend( * @param _allMessagesChecked */ mail_callMove: function(_action,_senders,_target,_allMessagesChecked) { - var target = _action.id == 'drop_move_mail' ? _target.iface.id : _action.id.substr(5); + var target = _action.id == 'drop_move_mail' ? _target.id : _action.id.substr(5); var messages = this.mail_getFormData(_senders); if (typeof _allMessagesChecked=='undefined') _allMessagesChecked=false;