diff --git a/kdots/head.tpl b/kdots/head.tpl index 7dd3b5c071..ab6a686420 100644 --- a/kdots/head.tpl +++ b/kdots/head.tpl @@ -42,7 +42,7 @@ {topmenu_info_items} - +
diff --git a/kdots/js/EgwFramework.ts b/kdots/js/EgwFramework.ts index f09568a076..eb5764c7d6 100644 --- a/kdots/js/EgwFramework.ts +++ b/kdots/js/EgwFramework.ts @@ -8,6 +8,7 @@ import styles from "./EgwFramework.styles"; import {egw} from "../../api/js/jsapi/egw_global"; import {SlDropdown, SlTab, SlTabGroup} from "@shoelace-style/shoelace"; import {EgwFrameworkApp} from "./EgwFrameworkApp"; +import {until} from "lit/directives/until.js"; /** * @summary Accessable, webComponent-based EGroupware framework @@ -160,6 +161,21 @@ export class EgwFramework extends LitElement }; } + /** + * A promise for if egw is loaded + * + * @returns {Promise} + */ + getEgwComplete() + { + let egwLoading = Promise.resolve(); + if(typeof this.egw.window['egw_ready'] !== "undefined") + { + egwLoading = this.egw.window['egw_ready']; + } + return egwLoading; + } + /** * * @param _function Framework function to be called on the server. @@ -617,7 +633,7 @@ export class EgwFramework extends LitElement } classes[`egw_fw__layout-${this.layout}`] = true; - return html` + return html`${until(this.getEgwComplete().then(() => html`
- `; + `), html`Waiting for egw... + `)}`; } } diff --git a/kdots/js/EgwFrameworkApp.ts b/kdots/js/EgwFrameworkApp.ts index 906cb978ef..d724bced96 100644 --- a/kdots/js/EgwFrameworkApp.ts +++ b/kdots/js/EgwFrameworkApp.ts @@ -12,6 +12,7 @@ import type {EgwFramework} from "./EgwFramework"; import {etemplate2} from "../../api/js/etemplate/etemplate2"; import {et2_IPrint} from "../../api/js/etemplate/et2_core_interfaces"; import {repeat} from "lit/directives/repeat.js"; +import {until} from "lit/directives/until.js"; /** * @summary Application component inside EgwFramework @@ -137,6 +138,7 @@ export class EgwFrameworkApp extends LitElement /** The application's content must be in an iframe instead of handled normally */ protected useIframe = false; + protected _sideboxData : any; connectedCallback() { @@ -161,7 +163,6 @@ export class EgwFrameworkApp extends LitElement firstUpdated() { - this.load(this.url); } @@ -259,7 +260,8 @@ export class EgwFrameworkApp extends LitElement public setSidebox(sideboxData, hash?) { - console.log("Not implemented"); + this._sideboxData = sideboxData; + this.requestUpdate(); } public showLeft() @@ -519,36 +521,99 @@ export class EgwFrameworkApp extends LitElement protected _rightHeaderTemplate() { return html` - - - { - this.egw.refresh("", this.name); - /* Could also be this.load(false); this.load(this.url) */ - }} - > - this.framework.print()} - > - ${this.egw.user('apps')['waffles'] !== "undefined" ? html` - - { - // @ts-ignore - egw_link_handler(`/egroupware/index.php?menuaction=admin.admin_ui.index&load=admin.uiconfig.index&appname=${this.name}&ajax=true`, 'admin'); - }} - >` : nothing - } - + + + + + + { + this.egw.refresh("", this.name); + /* Could also be this.load(false); this.load(this.url) */ + }} + > + + ${this.egw.lang("Reload %1", this.egw.lang(this.name))} + + this.framework.print()} + > + + ${this.egw.lang("Print")} + + ${this.egw.user('apps')['admin'] !== undefined ? html` + + { + // @ts-ignore + egw_link_handler(`/egroupware/index.php?menuaction=admin.admin_ui.index&load=admin.uiconfig.index&appname=${this.name}&ajax=true`, 'admin'); + }} + > + + ${this.egw.lang("App configuration")} + + + ` : nothing} + ${this._sideboxMenuTemplate()} + + + `; } + protected _sideboxMenuTemplate() + { + if(!this._sideboxData) + { + return nothing; + } + + return html`${repeat(this._sideboxData, (menu) => menu['menu_name'], (menu) => + { + // No favorites here + if(menu["title"] == "Favorites" || menu["title"] == this.egw.lang("favorites")) + { + return nothing; + } + // Just one thing, don't bother with submenu + if(menu["entries"].length == 1) + { + return html` + this.egw.open_link(menu["entries"][0]["item_link"])} + > + ${menu["title"]} + `; + } + return html` + + ${menu["title"]} + + ${repeat(menu["entries"], (entry) => + { + return this._sideboxMenuItemTemplate(entry); + })} + + `; + })}`; + } + + _sideboxMenuItemTemplate(item) + { + if(item["lang_item"] == "
") + { + return html` + `; + } + return html` + this.egw.open_link(item["item_link"])} + > + ${item["lang_item"]} + `; + + } + render() { const hasLeftSlots = this.hasSideContent("left"); @@ -579,7 +644,8 @@ export class EgwFrameworkApp extends LitElement
${this.name} main-header
- ${this._rightHeaderTemplate()} + ${until(this.framework.getEgwComplete().then(() => this._rightHeaderTemplate()), html` + `)}