Fix detail delete

This commit is contained in:
rijkvanzanten
2020-08-28 18:34:59 -04:00
parent b366b03d53
commit 1422ffcadd
3 changed files with 27 additions and 21 deletions

View File

@@ -331,7 +331,7 @@ export default class ItemsService implements AbstractService {
const schemaInspector = SchemaInspector(this.knex);
const primaryKeyField = await schemaInspector.primary(this.collection);
if (this.accountability && this.accountability.admin !== false) {
if (this.accountability && this.accountability.admin !== true) {
const authorizationService = new AuthorizationService({
accountability: this.accountability,
});

View File

@@ -177,24 +177,24 @@ export function useItem(collection: Ref<string>, primaryKey: Ref<string | number
}
async function remove(soft = false) {
if (soft) {
softDeleting.value = true;
} else {
deleting.value = true;
}
// if (soft) {
// softDeleting.value = true;
// } else {
deleting.value = true;
// }
try {
if (soft) {
if (!statusField.value || softDeleteStatus.value === null) {
throw new Error('[useItem] You cant soft-delete without a status field');
}
// if (soft) {
// if (!statusField.value || softDeleteStatus.value === null) {
// throw new Error('[useItem] You cant soft-delete without a status field');
// }
await api.patch(itemEndpoint.value, {
[statusField.value.field]: softDeleteStatus.value,
});
} else {
await api.delete(itemEndpoint.value);
}
// await api.patch(itemEndpoint.value, {
// [statusField.value.field]: softDeleteStatus.value,
// });
// } else {
await api.delete(itemEndpoint.value);
// }
item.value = null;
@@ -218,11 +218,11 @@ export function useItem(collection: Ref<string>, primaryKey: Ref<string | number
throw err;
} finally {
if (soft) {
softDeleting.value = false;
} else {
deleting.value = false;
}
// if (soft) {
// softDeleting.value = false;
// } else {
deleting.value = false;
// }
}
}

View File

@@ -330,11 +330,15 @@ export default defineComponent({
}
async function saveAndQuit() {
if (saveAllowed.value === false || hasEdits.value === false) return;
await save();
router.push(`/collections/${props.collection}`);
}
async function saveAndStay() {
if (saveAllowed.value === false || hasEdits.value === false) return;
const savedItem: Record<string, any> = await save();
revisionsDrawerDetail.value?.$data?.refresh?.();
@@ -347,6 +351,8 @@ export default defineComponent({
}
async function saveAndAddNew() {
if (saveAllowed.value === false || hasEdits.value === false) return;
await save();
router.push(`/collections/${props.collection}/+`);
}