prevent closing the datefield options on calendar select and updated collections upsert save handler
This commit is contained in:
@@ -7,7 +7,7 @@
|
||||
import { errors, setErrors, removeError } from "@/stores/errors";
|
||||
import { confirm } from "@/stores/confirmation";
|
||||
import { removeAllToasts, addSuccessToast } from "@/stores/toasts";
|
||||
import { loadCollections, removeCollection } from "@/stores/collections";
|
||||
import { addCollection, removeCollection } from "@/stores/collections";
|
||||
import tooltip from "@/actions/tooltip";
|
||||
import Field from "@/components/base/Field.svelte";
|
||||
import Toggler from "@/components/base/Toggler.svelte";
|
||||
@@ -35,7 +35,6 @@
|
||||
|
||||
let collectionPanel;
|
||||
let confirmChangesPanel;
|
||||
|
||||
let original = null;
|
||||
let collection = new Collection();
|
||||
let isSaving = false;
|
||||
@@ -143,7 +142,7 @@
|
||||
.then((result) => {
|
||||
removeAllToasts();
|
||||
|
||||
loadCollections(result.id);
|
||||
addCollection(result);
|
||||
|
||||
confirmClose = false;
|
||||
hide();
|
||||
@@ -262,6 +261,7 @@
|
||||
bind:this={collectionPanel}
|
||||
class="overlay-panel-lg colored-header collection-panel"
|
||||
escClose={false}
|
||||
overlayClose={!isSaving}
|
||||
beforeHide={() => {
|
||||
if (hasChanges && confirmClose) {
|
||||
confirm("You have unsaved changes. Do you really want to close the panel?", () => {
|
||||
|
||||
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user