Fix up recur days

This commit is contained in:
nathan 2023-03-28 13:48:26 -06:00
parent 8ac1c9c457
commit 21e9d67916
3 changed files with 42 additions and 8 deletions

View File

@ -182,10 +182,6 @@ export class Et2Select extends Et2WithSearchMixin(Et2WidgetWithSelect)
::part(display-label) {
margin: 0;
}
:host::part(display-label) {
max-height: 8em;
overflow-y: auto;
}
`
];
}
@ -942,6 +938,45 @@ export class Et2SelectDayOfWeek extends Et2StaticSelectMixin(Et2Select)
super.value = expanded_value;
}
get value()
{
return super.value;
super.connectedCallback();
// 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))
{
expanded_value.push("" + right);
}
}
super.value = expanded_value;
})
});
return;
}
super.value = expanded_value;
}
get value()
{
return super.value;

View File

@ -44,9 +44,7 @@ class Select extends Etemplate\Widget
'select-bool',
'select-cat',
'select-country',
// DOW needs some server-side pre-processing to unpack the options,
// so can't be skipped.
//'select-dow',
'select-dow',
'select-number',
'select-priority',
'select-percent',

View File

@ -120,7 +120,8 @@
</row>
<row valign="top">
<et2-description for="recur_data" value="Repeat days"></et2-description>
<et2-select-dow statustext="Days of the week for a weekly repeated event" id="recur_data" rows="6" multiple="1" placeholder="1"></et2-select-dow>
<et2-select-dow statustext="Days of the week for a weekly repeated event" id="recur_data" rows="6"
multiple="true" placeholder=""></et2-select-dow>
<et2-vbox>
<et2-description value="Exceptions"></et2-description>
<et2-button statustext="Create an exception for the given date" label="@exception_label" id="button[exception]" noLang="1"></et2-button>