prevent closing the datefield options on calendar select and updated collections upsert save handler

This commit is contained in:
Gani Georgiev
2023-03-28 09:06:16 +03:00
parent 3ea02c945d
commit ff1f99436a
31 changed files with 146 additions and 126 deletions
@@ -5,8 +5,25 @@
import SchemaField from "@/components/collections/schema/SchemaField.svelte";
export let field;
export let key = "";
let pickerMinValue = field?.options?.min;
let pickerMaxValue = field?.options?.max;
$: if (pickerMinValue != field?.options?.min) {
pickerMinValue = field?.options?.min;
}
$: if (pickerMaxValue != field?.options?.max) {
pickerMaxValue = field?.options?.max;
}
// ensure that value is set even on manual input edit
function onClose(e, key) {
if (e.detail && e.detail.length == 3) {
field.options[key] = e.detail[1];
}
}
</script>
<SchemaField
@@ -28,8 +45,9 @@
<Flatpickr
id={uniqueId}
options={CommonHelper.defaultFlatpickrOptions()}
value={field.options.min}
bind:value={pickerMinValue}
bind:formattedValue={field.options.min}
on:close={(e) => onClose(e, "min")}
/>
</Field>
</div>
@@ -40,8 +58,9 @@
<Flatpickr
id={uniqueId}
options={CommonHelper.defaultFlatpickrOptions()}
value={field.options.max}
bind:value={pickerMaxValue}
bind:formattedValue={field.options.max}
on:close={(e) => onClose(e, "max")}
/>
</Field>
</div>