From 96760511ea8b521998a38268dac991143ba848b4 Mon Sep 17 00:00:00 2001 From: Milan Date: Thu, 8 Feb 2024 21:16:07 +0100 Subject: [PATCH] EgwAction changes to suit Sl-Tree --- api/js/egw_action/EgwActionObject.ts | 9 +++------ api/js/egw_action/EgwActionObjectInterface.ts | 1 + api/js/egw_action/egw_action.ts | 2 +- 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/api/js/egw_action/EgwActionObject.ts b/api/js/egw_action/EgwActionObject.ts index 6a98652e3b..262fde6115 100644 --- a/api/js/egw_action/EgwActionObject.ts +++ b/api/js/egw_action/EgwActionObject.ts @@ -48,7 +48,7 @@ import {egwActionObjectInterface} from "./egw_action"; * defaults to 0 */ export class EgwActionObject { - readonly id: string + id: string readonly parent: EgwActionObject public readonly children: EgwActionObject[] = [] private actionLinks: EgwActionLink[] = [] @@ -111,13 +111,10 @@ export class EgwActionObject { // * @return {egwActionObject} description // * @todo Add search function to egw_action_commons.js // */ - getObjectById(_id, _search_depth) { + getObjectById(_id, _search_depth=Number.MAX_VALUE):EgwActionObject { if (this.id == _id) { return this; } - if (typeof _search_depth == "undefined") { - _search_depth = Number.MAX_VALUE; - } for (let i = 0; i < this.children.length && _search_depth > 0; i++) { const obj = this.children[i].getObjectById(_id, _search_depth - 1); @@ -163,7 +160,7 @@ export class EgwActionObject { * @returns object the generated object */ - insertObject(_index: number | boolean, _id: string | EgwActionObject, _iface: EgwActionObjectInterface, _flags: number) { + insertObject(_index: number | boolean, _id: string | EgwActionObject, _iface?: EgwActionObjectInterface, _flags?: number) { if (_index === false) _index = this.children.length; let obj = null; diff --git a/api/js/egw_action/EgwActionObjectInterface.ts b/api/js/egw_action/EgwActionObjectInterface.ts index 35b2a886c9..93f857a4c8 100644 --- a/api/js/egw_action/EgwActionObjectInterface.ts +++ b/api/js/egw_action/EgwActionObjectInterface.ts @@ -21,6 +21,7 @@ */ export interface EgwActionObjectInterface { //properties + id?:string _state: number; stateChangeCallback: Function; stateChangeContext: any; diff --git a/api/js/egw_action/egw_action.ts b/api/js/egw_action/egw_action.ts index 65b6fbb6a3..b6b2d5ead1 100755 --- a/api/js/egw_action/egw_action.ts +++ b/api/js/egw_action/egw_action.ts @@ -105,7 +105,7 @@ export function egw_getObjectManager(_id, _create = true, _search_depth = Number * @param {string} _appName //appName might not always be the current app, e.g. running app content under admin tab * @return {EgwActionObjectManager} */ -export function egw_getAppObjectManager(_create, _appName = "") { +export function egw_getAppObjectManager(_create = true, _appName = "") { return egw_getObjectManager(_appName ? _appName : window.egw(window).app_name(), _create, 1); }