mirror of
https://github.com/directus/directus.git
synced 2026-01-25 20:28:23 -05:00
Fix detail delete
This commit is contained in:
@@ -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,
|
||||
});
|
||||
|
||||
@@ -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;
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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}/+`);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user