Et2SelectDayOfWeek: Fix missing all days, weekday, weekend options

This commit is contained in:
nathan 2023-03-30 08:32:26 -06:00
parent e185831c4a
commit 824ebe514c
2 changed files with 45 additions and 7 deletions

View File

@ -11,7 +11,7 @@
import {css, html, PropertyValues, TemplateResult} from "@lion/core";
import {Et2StaticSelectMixin, StaticOptions as so} from "./StaticOptions";
import {Et2widgetWithSelectMixin} from "./Et2WidgetWithSelectMixin";
import {SelectOption} from "./FindSelectOptions";
import {cleanSelectOptions, SelectOption} from "./FindSelectOptions";
import {SlMenuItem, SlSelect} from "@shoelace-style/shoelace";
import shoelace from "../Styles/shoelace";
import {Et2WithSearchMixin} from "./SearchMixin";
@ -902,11 +902,49 @@ customElements.define("et2-select-day", Et2SelectDay);
export class Et2SelectDayOfWeek extends Et2StaticSelectMixin(Et2Select)
{
constructor()
connectedCallback()
{
super();
super.connectedCallback();
this.static_options = so.dow(this, {other: this.other || []});
// Wait for connected instead of constructor because attributes make a difference in
// which options are offered
this.fetchComplete = so.dow(this, {other: this.other || []}).then(options =>
{
this.set_static_options(cleanSelectOptions(options));
});
}
set value(new_value)
{
let expanded_value = typeof new_value == "object" ? new_value : [];
if(new_value && (typeof new_value == "string" || typeof new_value == "number"))
{
let int_value = parseInt(new_value);
this.updateComplete.then(() =>
{
this.fetchComplete.then(() =>
{
let options = this.select_options;
for(let index in options)
{
let right = parseInt(options[index].value);
if((int_value & right) == right)
{
expanded_value.push("" + right);
}
}
super.value = expanded_value;
})
});
return;
}
super.value = expanded_value;
}
get value()
{
return super.value;
}
}

View File

@ -343,10 +343,10 @@ export const StaticOptions = new class StaticOptionsType
return this.cached_server_side(widget, 'select-state', options);
}
dow(widget : Et2SelectWidgets, attrs) : SelectOption[] | Promise<SelectOption[]>
dow(widget : Et2SelectWidgets, attrs) : Promise<SelectOption[]>
{
var options = ',' + (attrs.other || []).join(',');
return this.cached_server_side(widget, 'select-dow', options);
var options = (widget.rows || "") + ',' + (attrs.other || []).join(',');
return <Promise<SelectOption[]>>this.cached_server_side(widget, 'select-dow', options, true);
}
lang(widget : Et2SelectWidgets, attrs) : SelectOption[] | Promise<SelectOption[]>