From eb14eef3dfe3d915492f697889831dd6cd3b596c Mon Sep 17 00:00:00 2001 From: ralf Date: Tue, 17 Sep 2024 10:49:03 +0200 Subject: [PATCH] fix icon in et2-vfs-path and also get it to display "/" for the root --- api/js/etemplate/Et2Vfs/Et2VfsPath.ts | 17 +++++++++++++---- api/js/jsapi/egw_global.d.ts | 8 ++++++++ api/js/jsapi/egw_user.js | 18 ++++++++++++++++++ 3 files changed, 39 insertions(+), 4 deletions(-) diff --git a/api/js/etemplate/Et2Vfs/Et2VfsPath.ts b/api/js/etemplate/Et2Vfs/Et2VfsPath.ts index 4dbf689e1f..8365d51107 100644 --- a/api/js/etemplate/Et2Vfs/Et2VfsPath.ts +++ b/api/js/etemplate/Et2Vfs/Et2VfsPath.ts @@ -261,10 +261,14 @@ export class Et2VfsPath extends Et2InputWidget(LitElement) protected _getIcon(pathParts) { - let image = this.egw().image("filemanager", "api"); + let image = this.egw().image("navbar", "filemanager"); if(pathParts.length > 2 && pathParts[1] == "apps") { - image = this.egw().image('navbar', pathParts[2].toLowerCase()); + const app = this.egw().app(pathParts[2], 'name') || this.egw().appByTitle(pathParts[2], 'name'); + if (app && !(image = this.egw().image('navbar', app))) + { + image = this.egw().image('navbar', 'api'); + } } return image; @@ -290,6 +294,11 @@ export class Et2VfsPath extends Et2InputWidget(LitElement) } } } + // we want / aka pathParts [''] to be displayed as /, therefore we need to add another '' to it + else if (pathParts.length === 1) + { + pathParts.unshift(''); + } return html` ${pathName} @@ -347,7 +356,7 @@ export class Et2VfsPath extends Et2InputWidget(LitElement) > ${icon ? html` - { this.setValue("/"); @@ -422,4 +431,4 @@ export class Et2VfsPath extends Et2InputWidget(LitElement) } } -customElements.define("et2-vfs-path", Et2VfsPath); +customElements.define("et2-vfs-path", Et2VfsPath); \ No newline at end of file diff --git a/api/js/jsapi/egw_global.d.ts b/api/js/jsapi/egw_global.d.ts index c545d06a60..9e99eef8fc 100644 --- a/api/js/jsapi/egw_global.d.ts +++ b/api/js/jsapi/egw_global.d.ts @@ -571,6 +571,14 @@ declare interface IegwGlobal */ app(_app : string, _name : string) : string|undefined; app(_app : string) : Iapplication|undefined; + /** + * Same as app(), but use the translated app-name / title + * + * @param {string} _title + * @param {string} _name attribute to return, default return whole app-data-object + */ + appByTitle(_title : string, _name : string) : string|undefined; + appByTitle(_title : 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' diff --git a/api/js/jsapi/egw_user.js b/api/js/jsapi/egw_user.js index cf49b6b924..76b4150490 100644 --- a/api/js/jsapi/egw_user.js +++ b/api/js/jsapi/egw_user.js @@ -87,6 +87,24 @@ egw.extend('user', egw.MODULE_GLOBAL, function() userData.apps[_app] : userData.apps[_app][_name]; }, + /** + * Same as app(), but use the translated app-name / title + * + * @param {string} _title + * @param {string} _name attribute to return, default return whole app-data-object + */ + appByTitle: function(_title, _name) + { + for(const app in userData.apps) + { + if (userData.apps[app].title === _title) + { + return typeof _name == 'undefined' || typeof userData.apps[app] == 'undefined' ? + userData.apps[app] : userData.apps[app][_name]; + } + } + }, + /** * Get a list of accounts the user has access to * The list is filtered by type, one of 'accounts','groups','both', 'owngroups'