Et2Select: Fix select options were only visible as search results

This commit is contained in:
nathan 2023-10-02 08:04:19 -06:00
parent 4f575894a2
commit 6c06a5311f
2 changed files with 21 additions and 5 deletions

View File

@ -716,11 +716,12 @@ export class Et2Select extends Et2WithSearchMixin(Et2WidgetWithSelect)
return html`
<sl-option
part="option"
exportparts="prefix:tag__prefix, suffix:tag__suffix"
value="${value}"
title="${!option.title || this.noLang ? option.title : this.egw().lang(option.title)}"
class=${classMap({
"match": option.isMatch,
"no-match": !option.isMatch,
"match": this.searchEnabled && option.isMatch,
"no-match": this.searchEnabled && !option.isMatch,
...Object.fromEntries((option.class || "").split(" ").map(k => [k, true]))
})}
.option=${option}

View File

@ -13,6 +13,7 @@ import {css, html, nothing, TemplateResult} from "@lion/core";
import {IsEmail} from "../../api/js/etemplate/Validators/IsEmail";
import {SelectOption} from "../../api/js/etemplate/Et2Select/FindSelectOptions";
import {Et2StaticSelectMixin} from "../../api/js/etemplate/Et2Select/StaticOptions";
import {classMap} from "lit/directives/class-map.js";
/**
* Select widget customised for calendar owner, which can be a user
@ -56,16 +57,30 @@ export class CalendarOwner extends Et2StaticSelectMixin(Et2Select)
*/
_optionTemplate(option : SelectOption) : TemplateResult
{
// Exclude non-matches when searching
// unless they're already selected, in which case removing them removes them from value
if(typeof option.isMatch == "boolean" && !option.isMatch && !this.getValueAsArray().includes(option.value))
{
return html``;
}
// Tag used must match this.optionTag, but you can't use the variable directly.
// Pass option along so SearchMixin can grab it if needed
const value = (<string>option.value).replaceAll(" ", "___");
return html`
<sl-option
part="option"
exportparts="prefix:tag__prefix, suffix:tag__suffix"
value="${option.value}"
value="${value}"
title="${!option.title || this.noLang ? option.title : this.egw().lang(option.title)}"
class="${option.class}" .option=${option}
?disabled=${option.disabled}
class=${classMap({
"match": option.isMatch,
"no-match": !option.isMatch,
...Object.fromEntries((option.class || "").split(" ").map(k => [k, true]))
})}
.option=${option}
.selected=${this.getValueAsArray().some(v => v == value)}
?disabled=${option.disabled}
>
${this._iconTemplate(option)}
${this.noLang ? option.label : this.egw().lang(option.label)}