From e575c40ff366cc9481cf22644387018ac23d9a87 Mon Sep 17 00:00:00 2001 From: nathan Date: Mon, 30 Jan 2023 15:26:09 -0700 Subject: [PATCH] Some missed cases where client-side lavatar was not used --- api/js/etemplate/Et2Select/Et2Select.ts | 2 +- .../etemplate/Et2Select/Et2SelectAccount.ts | 33 +------------------ api/js/etemplate/Et2Select/SearchMixin.ts | 2 +- .../Et2Select/test/Et2SelectOptions.test.ts | 3 ++ ...ss.calendar_owner_etemplate_widget.inc.php | 2 +- calendar/js/CalendarOwner.ts | 27 ++++++++++++++- 6 files changed, 33 insertions(+), 36 deletions(-) diff --git a/api/js/etemplate/Et2Select/Et2Select.ts b/api/js/etemplate/Et2Select/Et2Select.ts index 0653b73f8a..c0d63ec0db 100644 --- a/api/js/etemplate/Et2Select/Et2Select.ts +++ b/api/js/etemplate/Et2Select/Et2Select.ts @@ -520,7 +520,7 @@ export class Et2Select extends Et2WithSearchMixin(Et2WidgetWithSelect) protected _createImage(item) { - let image = item.querySelector("et2-image"); + let image = item.querySelector("et2-image") || item.querySelector("[slot='prefix']"); if(image) { image = image.clone(); diff --git a/api/js/etemplate/Et2Select/Et2SelectAccount.ts b/api/js/etemplate/Et2Select/Et2SelectAccount.ts index 2a23fafbf8..0ab1361a9d 100644 --- a/api/js/etemplate/Et2Select/Et2SelectAccount.ts +++ b/api/js/etemplate/Et2Select/Et2SelectAccount.ts @@ -9,7 +9,6 @@ import {Et2Select} from "./Et2Select"; import {cleanSelectOptions, SelectOption} from "./FindSelectOptions"; -import {Et2Image} from "../Et2Image/Et2Image"; import {SelectAccountMixin} from "./SelectAccountMixin"; import {Et2StaticSelectMixin} from "./StaticOptions"; import {html, nothing} from "@lion/core"; @@ -103,7 +102,7 @@ export class Et2SelectAccount extends SelectAccountMixin(Et2StaticSelectMixin(Et { return []; } - let select_options : Array = [...super.select_options] || []; + let select_options : Array = [...(this.static_options || []), ...super.select_options]; return select_options.filter((value, index, self) => { @@ -135,36 +134,6 @@ export class Et2SelectAccount extends SelectAccountMixin(Et2StaticSelectMixin(Et > `; } - - /** - * Override the prefix image for tags (multiple=true) - * The default is probably fine, but we're being explicit here. - * @param item - * @returns {TemplateResult<1>} - * @protected - * - */ - protected _createImage(item) : Et2Image - { - const image = document.createElement("et2-lavatar"); - image.contactId = item.value; - if(item.lname) - { - image.lname = item.lname; - } - if(item.fname) - { - image.fname = item.fname; - } - - // If there's an actual image associated with the account, use that image instead of initials - if(item.src) - { - image.src = item.src; - } - - return image; - } } customElements.define("et2-select-account", Et2SelectAccount); \ No newline at end of file diff --git a/api/js/etemplate/Et2Select/SearchMixin.ts b/api/js/etemplate/Et2Select/SearchMixin.ts index d47509d91a..02c555c036 100644 --- a/api/js/etemplate/Et2Select/SearchMixin.ts +++ b/api/js/etemplate/Et2Select/SearchMixin.ts @@ -366,7 +366,7 @@ export const Et2WithSearchMixin = >(superclass // Update any tags if edit mode changes if(changedProperties.has("editModeEnabled")) { - this.shadowRoot.querySelectorAll(this.tagTag).forEach(tag => tag.editable = this.editModeEnabled); + this.shadowRoot.querySelectorAll(".select__tags > *").forEach(tag => tag.editable = this.editModeEnabled); } } diff --git a/api/js/etemplate/Et2Select/test/Et2SelectOptions.test.ts b/api/js/etemplate/Et2Select/test/Et2SelectOptions.test.ts index 2ba25b5930..357216a683 100644 --- a/api/js/etemplate/Et2Select/test/Et2SelectOptions.test.ts +++ b/api/js/etemplate/Et2Select/test/Et2SelectOptions.test.ts @@ -63,6 +63,7 @@ describe("Select widget", () => // @ts-ignore TypeScript is not recognizing that this widget is a LitElement await elementUpdated(container); element = container.getWidgetById('select'); + await element.updateComplete; /** TESTING **/ assert.isNotNull(element.querySelector("[value='option']"), "Missing static option"); @@ -82,6 +83,7 @@ describe("Select widget", () => // @ts-ignore TypeScript is not recognizing that this widget is a LitElement await elementUpdated(container); element = container.getWidgetById('select'); + await element.updateComplete; /** TESTING **/ assert.equal(element.querySelectorAll("sl-menu-item").length, 2); @@ -102,6 +104,7 @@ describe("Select widget", () => // @ts-ignore TypeScript is not recognizing that this widget is a LitElement await elementUpdated(container); element = container.getWidgetById('select'); + await element.updateComplete; /** TESTING **/ diff --git a/calendar/inc/class.calendar_owner_etemplate_widget.inc.php b/calendar/inc/class.calendar_owner_etemplate_widget.inc.php index f77f69d3bb..9874223235 100644 --- a/calendar/inc/class.calendar_owner_etemplate_widget.inc.php +++ b/calendar/inc/class.calendar_owner_etemplate_widget.inc.php @@ -303,7 +303,7 @@ class calendar_owner_etemplate_widget extends Etemplate\Widget\Taglist $value = array( 'value' => substr($id, 0, 1) == $type ? $id : $type . $id, 'label' => $title, - 'app' => lang($data['app']) + 'app' => $data['app'] ); if(is_array($value['label'])) { diff --git a/calendar/js/CalendarOwner.ts b/calendar/js/CalendarOwner.ts index 62a5e0207a..53f3e8e54c 100644 --- a/calendar/js/CalendarOwner.ts +++ b/calendar/js/CalendarOwner.ts @@ -9,7 +9,7 @@ */ import {Et2Select} from "../../api/js/etemplate/Et2Select/Et2Select"; -import {css} from "@lion/core"; +import {css, html, nothing} from "@lion/core"; import {IsEmail} from "../../api/js/etemplate/Validators/IsEmail"; /** @@ -96,6 +96,31 @@ export class CalendarOwner extends Et2Select }); } + /** + * Override icon for the select option to use lavatar + * + * @param option + * @protected + */ + protected _iconTemplate(option) + { + // Not a user / contact, no icon - use app image + if(!option.fname && !option.lname && !option.icon && option.app) + { + return html` + `; + } + // lavatar uses a size property, not a CSS variable + let style = getComputedStyle(this); + return html` + + `; + } + /** * Check if a free entry value is acceptable. * We only check the free entry, since value can be mixed.