mirror of
https://github.com/directus/directus.git
synced 2026-04-25 03:00:53 -04:00
Allow for discarding of changes without leaving (#9644)
* Allow for discarding of changes without leaving * Update to use v-if for consistency * Fix boolean logic * Allow disabling of options * Remove unused disabled prop
This commit is contained in:
@@ -136,6 +136,7 @@
|
||||
@save-and-stay="saveAndStay"
|
||||
@save-and-add-new="saveAndAddNew"
|
||||
@save-as-copy="saveAsCopyAndNavigate"
|
||||
@discard-and-stay="discardAndStay"
|
||||
/>
|
||||
</template>
|
||||
</v-button>
|
||||
@@ -385,6 +386,7 @@ export default defineComponent({
|
||||
saveAndStay,
|
||||
saveAndAddNew,
|
||||
saveAsCopyAndNavigate,
|
||||
discardAndStay,
|
||||
templateData,
|
||||
templateDataLoading,
|
||||
archiveTooltip,
|
||||
@@ -506,6 +508,11 @@ export default defineComponent({
|
||||
router.push(leaveTo.value);
|
||||
}
|
||||
|
||||
function discardAndStay() {
|
||||
edits.value = {};
|
||||
confirmLeave.value = false;
|
||||
}
|
||||
|
||||
function revert(values: Record<string, any>) {
|
||||
edits.value = {
|
||||
...edits.value,
|
||||
|
||||
@@ -99,9 +99,11 @@
|
||||
|
||||
<template #append-outer>
|
||||
<save-options
|
||||
v-if="hasEdits === true || saveAllowed === true"
|
||||
v-if="hasEdits === true && saveAllowed === true"
|
||||
:disabled-options="['save-and-add-new']"
|
||||
@save-and-stay="saveAndStay"
|
||||
@save-as-copy="saveAsCopyAndNavigate"
|
||||
@discard-and-stay="discardAndStay"
|
||||
/>
|
||||
</template>
|
||||
</v-button>
|
||||
@@ -328,6 +330,7 @@ export default defineComponent({
|
||||
deleting,
|
||||
saveAndStay,
|
||||
saveAsCopyAndNavigate,
|
||||
discardAndStay,
|
||||
isBatch,
|
||||
editActive,
|
||||
revisionsDrawerDetail,
|
||||
@@ -411,9 +414,15 @@ export default defineComponent({
|
||||
function discardAndLeave() {
|
||||
if (!leaveTo.value) return;
|
||||
edits.value = {};
|
||||
confirmLeave.value = false;
|
||||
router.push(leaveTo.value);
|
||||
}
|
||||
|
||||
function discardAndStay() {
|
||||
edits.value = {};
|
||||
confirmLeave.value = false;
|
||||
}
|
||||
|
||||
function downloadFile() {
|
||||
const filePath = addTokenToURL(getRootPath() + `assets/${props.primaryKey}?download`);
|
||||
window.open(filePath, '_blank');
|
||||
|
||||
@@ -37,10 +37,11 @@
|
||||
|
||||
<template #append-outer>
|
||||
<save-options
|
||||
:disabled="hasEdits === false"
|
||||
v-if="hasEdits === true"
|
||||
@save-and-stay="saveAndStay"
|
||||
@save-and-add-new="saveAndAddNew"
|
||||
@save-as-copy="saveAsCopyAndNavigate"
|
||||
@discard-and-stay="discardAndStay"
|
||||
/>
|
||||
</template>
|
||||
</v-button>
|
||||
@@ -178,6 +179,7 @@ export default defineComponent({
|
||||
saveAndStay,
|
||||
saveAndAddNew,
|
||||
saveAsCopyAndNavigate,
|
||||
discardAndStay,
|
||||
isBatch,
|
||||
title,
|
||||
validationErrors,
|
||||
@@ -217,6 +219,11 @@ export default defineComponent({
|
||||
confirmLeave.value = false;
|
||||
router.push(leaveTo.value);
|
||||
}
|
||||
|
||||
function discardAndStay() {
|
||||
edits.value = {};
|
||||
confirmLeave.value = false;
|
||||
}
|
||||
},
|
||||
});
|
||||
</script>
|
||||
|
||||
@@ -89,6 +89,7 @@
|
||||
@save-and-stay="saveAndStay"
|
||||
@save-and-add-new="saveAndAddNew"
|
||||
@save-as-copy="saveAsCopyAndNavigate"
|
||||
@discard-and-stay="discardAndStay"
|
||||
/>
|
||||
</template>
|
||||
</v-button>
|
||||
@@ -343,6 +344,7 @@ export default defineComponent({
|
||||
saveAndStay,
|
||||
saveAndAddNew,
|
||||
saveAsCopyAndNavigate,
|
||||
discardAndStay,
|
||||
isBatch,
|
||||
revisionsDrawerDetail,
|
||||
previewLoading,
|
||||
@@ -492,9 +494,15 @@ export default defineComponent({
|
||||
function discardAndLeave() {
|
||||
if (!leaveTo.value) return;
|
||||
edits.value = {};
|
||||
confirmLeave.value = false;
|
||||
router.push(leaveTo.value);
|
||||
}
|
||||
|
||||
function discardAndStay() {
|
||||
edits.value = {};
|
||||
confirmLeave.value = false;
|
||||
}
|
||||
|
||||
async function toggleArchive() {
|
||||
await archive();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user