mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-12-22 14:41:29 +01:00
possibility to replace et2-select-cat with et2-tree-cat
This commit is contained in:
parent
888f859097
commit
8de6bd0c25
@ -261,7 +261,7 @@ export function cleanSelectOptions(options : SelectOption[] | string[] | object)
|
|||||||
{
|
{
|
||||||
option.value = option.value.toString();
|
option.value = option.value.toString();
|
||||||
}
|
}
|
||||||
if(typeof option.label !== 'string')
|
if(option.label && typeof option.label !== 'string')
|
||||||
{
|
{
|
||||||
fixed_options.push(...cleanSelectOptions(option.label));
|
fixed_options.push(...cleanSelectOptions(option.label));
|
||||||
}
|
}
|
||||||
|
@ -8,11 +8,12 @@ import {property} from "lit/decorators/property.js";
|
|||||||
import {css, PropertyValues, unsafeCSS} from "lit";
|
import {css, PropertyValues, unsafeCSS} from "lit";
|
||||||
import {Et2TreeDropdown} from "./Et2TreeDropdown";
|
import {Et2TreeDropdown} from "./Et2TreeDropdown";
|
||||||
import {Et2CategoryTag} from "../Et2Select/Tag/Et2CategoryTag";
|
import {Et2CategoryTag} from "../Et2Select/Tag/Et2CategoryTag";
|
||||||
|
import {Et2StaticSelectMixin, StaticOptions as so} from "../Et2Select/StaticOptions";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @since 23.1.x
|
* @since 23.1.x
|
||||||
*/
|
*/
|
||||||
export class Et2TreeDropdownCategory extends Et2TreeDropdown
|
export class Et2TreeDropdownCategory extends Et2StaticSelectMixin(Et2TreeDropdown)
|
||||||
{
|
{
|
||||||
|
|
||||||
static get styles()
|
static get styles()
|
||||||
@ -58,12 +59,37 @@ export class Et2TreeDropdownCategory extends Et2TreeDropdown
|
|||||||
// Set the search options from our properties
|
// Set the search options from our properties
|
||||||
this.searchOptions.application = this.application;
|
this.searchOptions.application = this.application;
|
||||||
this.searchOptions.globalCategories = this.globalCategories;
|
this.searchOptions.globalCategories = this.globalCategories;
|
||||||
|
|
||||||
|
this.fetchComplete = so.cat(this).then(options => {
|
||||||
|
this.select_options = options;
|
||||||
|
this.requestUpdate("select_options");
|
||||||
|
|
||||||
|
if (this._tree)
|
||||||
|
{
|
||||||
|
this._tree._selectOptions = options
|
||||||
|
this._tree.requestUpdate();
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
willUpdate(changedProperties : PropertyValues)
|
willUpdate(changedProperties : PropertyValues)
|
||||||
{
|
{
|
||||||
super.willUpdate(changedProperties);
|
super.willUpdate(changedProperties);
|
||||||
|
|
||||||
|
if (changedProperties.has("globalCategories") ||
|
||||||
|
changedProperties.has("application") || changedProperties.has("parentCat"))
|
||||||
|
{
|
||||||
|
this.fetchComplete = so.cat(this).then(options => {
|
||||||
|
this.select_options = options;
|
||||||
|
this.requestUpdate("select_options");
|
||||||
|
|
||||||
|
// Shoelace select has rejected our value due to missing option by now, so re-set it
|
||||||
|
// this.updateComplete.then(() => {
|
||||||
|
// this.value = this.value;
|
||||||
|
// });
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
if(changedProperties.has('application'))
|
if(changedProperties.has('application'))
|
||||||
{
|
{
|
||||||
this.searchOptions.application = this.application;
|
this.searchOptions.application = this.application;
|
||||||
@ -91,7 +117,10 @@ export class Et2TreeDropdownCategory extends Et2TreeDropdown
|
|||||||
{
|
{
|
||||||
css += ".cat_" + option.value + " {--category-color: " + (option.data?.color || "transparent") + ";}\n";
|
css += ".cat_" + option.value + " {--category-color: " + (option.data?.color || "transparent") + ";}\n";
|
||||||
|
|
||||||
option.children?.forEach((option) => catColor(option))
|
if (typeof option.children === 'object')
|
||||||
|
{
|
||||||
|
option.children?.forEach((option) => catColor(option))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
this.select_options.forEach((option => catColor(option)));
|
this.select_options.forEach((option => catColor(option)));
|
||||||
// @formatter:off
|
// @formatter:off
|
||||||
|
Loading…
Reference in New Issue
Block a user