From 9f574b4a3847b125c3af37e0179821e3492ef513 Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Mon, 27 Jan 2020 13:43:13 +0100 Subject: [PATCH] some egw object interface changes and using it in app.ts base object --- api/js/jsapi/egw_app.ts | 4 ++-- api/js/jsapi/egw_global.d.ts | 29 +++++++++++++++++++++++++---- 2 files changed, 27 insertions(+), 6 deletions(-) diff --git a/api/js/jsapi/egw_app.ts b/api/js/jsapi/egw_app.ts index 4674e2dc9b..7cb502e02e 100644 --- a/api/js/jsapi/egw_app.ts +++ b/api/js/jsapi/egw_app.ts @@ -108,7 +108,7 @@ export abstract class EgwApp * * @var {egw} */ - egw: any; + egw: IegwAppLocal; sidebox: JQuery; @@ -428,7 +428,7 @@ export abstract class EgwApp url = egw.link('/index.php', jQuery.extend({'favorite': safe_name}, egw.link_get_registry(this.appname, 'list'))); } // if no list try index value from application - else if (egw.app(this.appname).index) + else if (egw.app(this.appname)?.index) { url = egw.link('/index.php', 'menuaction='+egw.app(this.appname).index+'&favorite='+safe_name); } diff --git a/api/js/jsapi/egw_global.d.ts b/api/js/jsapi/egw_global.d.ts index 90bc71056e..ae24b8ac9d 100644 --- a/api/js/jsapi/egw_global.d.ts +++ b/api/js/jsapi/egw_global.d.ts @@ -21,7 +21,24 @@ declare var egw : Iegw; /** * Interface for global egw with window global or local methods or as function returning an object allowing also application local methods */ -declare interface Iegw extends IegwWndLocal { (_app : string, _wnd? : Window) : IegwAppLocal } +declare interface Iegw extends IegwWndLocal { (_app? : string, _wnd? : Window) : IegwAppLocal, webserverUrl : string } + +/** + * Return type for egw.app() call + */ +declare interface Iapplication +{ + title : string; // application title untranslated, better use egw.lang(app.name) + name : string; // app-name + enabled : number; + status : number; + id : number; + order : number; + version : string; + index? : string; + icon? : string; + icon_app? : string; +} /** * Interface for all window global methods (existing only in top window) @@ -164,8 +181,11 @@ declare interface IegwGlobal * java script console. The first parameter specifies the debug * level, all other parameters are passed to the corresponding * console function. + * + * @param {String} _level "navigation", "log", "info", "warn", "error" + * @param args arguments to egw.debug */ - debug(_level : number, ...args : any[]) : void; + debug(_level : "navigation"|"log"|"info"|"warn"|"error", ...args : any[]) : void; /** * Display log to user because he clicked on icon showed by raise_error * @@ -487,9 +507,10 @@ declare interface IegwGlobal * * @param {string} _app * @param {string} _name attribute to return, default return whole app-data-object - * @return object|string|undefined undefined if not found + * @return Iapplication|string|undefined undefined if not found */ - app(_app : string, _name? : string) : string|object|undefined; + app(_app : string, _name : string) : string|undefined; + app(_app : string) : Iapplication|undefined; /** * Get a list of accounts the user has access to * The list is filtered by type, one of 'accounts','groups','both', 'owngroups'