From 3ebf911427aea3985f4af996ece0ee768246f777 Mon Sep 17 00:00:00 2001 From: nathan Date: Mon, 7 Oct 2024 13:31:28 -0600 Subject: [PATCH] More changes related to getting tree to handle actions on its leaves - Fix action system selection vs tree --- api/js/egw_action/EgwDragDropShoelaceTree.ts | 4 ++-- api/js/etemplate/Et2Tree/Et2Tree.ts | 15 ++++++++++++++- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/api/js/egw_action/EgwDragDropShoelaceTree.ts b/api/js/egw_action/EgwDragDropShoelaceTree.ts index dbd390e623..bd2455c06e 100644 --- a/api/js/egw_action/EgwDragDropShoelaceTree.ts +++ b/api/js/egw_action/EgwDragDropShoelaceTree.ts @@ -18,8 +18,8 @@ import {FindActionTarget} from "../etemplate/FindActionTarget"; export const EXPAND_FOLDER_ON_DRAG_DROP_TIMEOUT = 1000 export class EgwDragDropShoelaceTree extends egwActionObjectInterface{ - node: SlTreeItem; - id: string; + + id: string; tree: Et2Tree; // Reference to the widget that's handling actions for us diff --git a/api/js/etemplate/Et2Tree/Et2Tree.ts b/api/js/etemplate/Et2Tree/Et2Tree.ts index 5a57f29e9c..5ee10ff2fb 100644 --- a/api/js/etemplate/Et2Tree/Et2Tree.ts +++ b/api/js/etemplate/Et2Tree/Et2Tree.ts @@ -1304,12 +1304,25 @@ export class Et2Tree extends Et2WidgetWithSelectMixin(LitElement) implements Fin if(!action) { // NOTE: FLAT object structure under the tree ActionObject to avoid nested selection - action = this.widget_object.addObject(target.id, this.widget_object.iface); + action = this.widget_object.addObject(target.id, this.widget_object.iface) + action.setSelected = (set) => + { + target.selected = set; + this.widget_object.updateSelectedChildren(action, set); + } + action.getSelected = () => target.selected; // Required to get dropped accepted, but also re-binds action.updateActionLinks(this._get_action_links(this.actions)); } // This is just the action system, which we override this.widget_object.setAllSelected(false); + // This will affect action system & DOM, but not our internal value + this.widget_object.children.forEach(c => + { + c.setSelected(false) + }) + + this.widget_object.iface.stateChangeContext = action; action.setSelected(true); return {target: target, action: action};