[#7135] merge scaffold collection indexes
This commit is contained in:
parent
5d964c1b1d
commit
ee8c0a66b6
|
|
@ -6,7 +6,13 @@
|
||||||
import { confirm } from "@/stores/confirmation";
|
import { confirm } from "@/stores/confirmation";
|
||||||
import { errors, removeError, setErrors } from "@/stores/errors";
|
import { errors, removeError, setErrors } from "@/stores/errors";
|
||||||
import { addSuccessToast, removeAllToasts } from "@/stores/toasts";
|
import { addSuccessToast, removeAllToasts } from "@/stores/toasts";
|
||||||
import { addCollection, removeCollection, scaffolds, activeCollection } from "@/stores/collections";
|
import {
|
||||||
|
addCollection,
|
||||||
|
removeCollection,
|
||||||
|
scaffolds,
|
||||||
|
activeCollection,
|
||||||
|
refreshScaffolds,
|
||||||
|
} from "@/stores/collections";
|
||||||
import tooltip from "@/actions/tooltip";
|
import tooltip from "@/actions/tooltip";
|
||||||
import Field from "@/components/base/Field.svelte";
|
import Field from "@/components/base/Field.svelte";
|
||||||
import OverlayPanel from "@/components/base/OverlayPanel.svelte";
|
import OverlayPanel from "@/components/base/OverlayPanel.svelte";
|
||||||
|
|
@ -161,7 +167,7 @@
|
||||||
isLoadingConfirmation = false;
|
isLoadingConfirmation = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
function save(hideAfterSave = true) {
|
async function save(hideAfterSave = true) {
|
||||||
if (isSaving) {
|
if (isSaving) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -171,45 +177,44 @@
|
||||||
const data = exportFormData();
|
const data = exportFormData();
|
||||||
const isNew = !collection.id;
|
const isNew = !collection.id;
|
||||||
|
|
||||||
let request;
|
try {
|
||||||
if (isNew) {
|
let result;
|
||||||
request = ApiClient.collections.create(data);
|
if (isNew) {
|
||||||
} else {
|
result = await ApiClient.collections.create(data);
|
||||||
request = ApiClient.collections.update(collection.id, data);
|
} else {
|
||||||
|
result = await ApiClient.collections.update(collection.id, data);
|
||||||
|
}
|
||||||
|
|
||||||
|
removeAllToasts();
|
||||||
|
|
||||||
|
addCollection(result);
|
||||||
|
|
||||||
|
if (hideAfterSave) {
|
||||||
|
confirmClose = false;
|
||||||
|
hide();
|
||||||
|
} else {
|
||||||
|
load(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
addSuccessToast(
|
||||||
|
!collection.id ? "Successfully created collection." : "Successfully updated collection.",
|
||||||
|
);
|
||||||
|
|
||||||
|
dispatch("save", {
|
||||||
|
isNew: isNew,
|
||||||
|
collection: result,
|
||||||
|
});
|
||||||
|
|
||||||
|
if (isNew) {
|
||||||
|
$activeCollection = result;
|
||||||
|
|
||||||
|
await refreshScaffolds();
|
||||||
|
}
|
||||||
|
} catch (err) {
|
||||||
|
ApiClient.error(err);
|
||||||
}
|
}
|
||||||
|
|
||||||
return request
|
isSaving = false;
|
||||||
.then((result) => {
|
|
||||||
removeAllToasts();
|
|
||||||
|
|
||||||
addCollection(result);
|
|
||||||
|
|
||||||
if (hideAfterSave) {
|
|
||||||
confirmClose = false;
|
|
||||||
hide();
|
|
||||||
} else {
|
|
||||||
load(result);
|
|
||||||
}
|
|
||||||
|
|
||||||
addSuccessToast(
|
|
||||||
!collection.id ? "Successfully created collection." : "Successfully updated collection.",
|
|
||||||
);
|
|
||||||
|
|
||||||
dispatch("save", {
|
|
||||||
isNew: isNew,
|
|
||||||
collection: result,
|
|
||||||
});
|
|
||||||
|
|
||||||
if (isNew) {
|
|
||||||
$activeCollection = result;
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.catch((err) => {
|
|
||||||
ApiClient.error(err);
|
|
||||||
})
|
|
||||||
.finally(() => {
|
|
||||||
isSaving = false;
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function exportFormData() {
|
function exportFormData() {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue