From ac52723ce7e4ba139a4e5459d8e8f3af24bc13f9 Mon Sep 17 00:00:00 2001 From: nathan Date: Thu, 26 May 2022 16:10:58 -0600 Subject: [PATCH] Get Et2Taglist to show initial value when that value is not in select_options (only if allowFreeEntries is on) --- api/js/etemplate/Et2Taglist/Et2Taglist.ts | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/api/js/etemplate/Et2Taglist/Et2Taglist.ts b/api/js/etemplate/Et2Taglist/Et2Taglist.ts index 7a32036389..d581eefcd4 100644 --- a/api/js/etemplate/Et2Taglist/Et2Taglist.ts +++ b/api/js/etemplate/Et2Taglist/Et2Taglist.ts @@ -9,10 +9,10 @@ */ -import {css, html, PropertyValues, TemplateResult} from "@lion/core"; +import {css, html, TemplateResult} from "@lion/core"; import {Et2widgetWithSelectMixin} from "../Et2Select/Et2WidgetWithSelectMixin"; import {LionCombobox} from "@lion/combobox"; -import {find_select_options, SelectOption} from "../Et2Select/FindSelectOptions"; +import {SelectOption} from "../Et2Select/FindSelectOptions"; import {EgwOption} from "./EgwOption"; import {TaglistSelection} from "./TaglistSelection"; import {taglistStyles} from "./TaglistStyles"; @@ -81,6 +81,7 @@ export class Et2Taglist extends Et2widgetWithSelectMixin(LionCombobox) { super(); + this.value = []; } connectedCallback() @@ -170,7 +171,6 @@ export class Et2Taglist extends Et2widgetWithSelectMixin(LionCombobox) } } - getValue(): String[] { return this.modelValue; @@ -199,7 +199,23 @@ export class Et2Taglist extends Et2widgetWithSelectMixin(LionCombobox) { this.multiple = this.multiple ? values.length > 1 : false; } + if(this.allowFreeEntries) + { + values.forEach(val => + { + if(!this.select_options.find(opt => opt.value == val)) + { + this.__appendSelOption(val); + } + }); + } + this.value = values; + + if(!this.multiple) + { + values = values.shift(); + } this.modelValue = values; }