diff --git a/src/lang/en-US/index.json b/src/lang/en-US/index.json
index 4077a5f081..f0f7c1ad06 100644
--- a/src/lang/en-US/index.json
+++ b/src/lang/en-US/index.json
@@ -581,6 +581,11 @@
"layout_preview": "Layout Preview",
"layout_setup": "Layout Setup",
+ "unsaved_changes": "Unsaved Changes",
+ "unsaved_changes_copy": "Are you sure you want to leave this page?",
+ "discard_changes": "Discard Changes",
+ "keep_editing": "Keep Editing",
+
"page_help_collections_overview": "Provides a listing of all collections you have access to.",
"page_help_collections_browse": "**Item Browse Page** — Customize the layout, filters, and sorting to tailor your view of items within this {collection} collection.
You can also save bookmarks of these different configurations to quickly switch between them.
Learn More",
"page_help_collections_detail": "For more information this page please refer to the
Learn More",
@@ -746,7 +751,6 @@
"desc": "desc",
"description": "Description",
"dialog_beginning": "Beginning of dialog window.",
- "discard_changes": "Discard Changes",
"display_name": "Display Name",
"directus_version": "Directus Version",
"done": "Done",
@@ -855,7 +859,6 @@
"item_deleted": "Item Deleted",
"item_saved": "Item Saved | {count} Items Saved",
"junction_collection": "Junction Collection",
- "keep_editing": "Keep Editing",
"latency": "Latency",
"learn_more": "Learn More",
"length_disabled_placeholder": "Length is determined by the datatype",
@@ -980,8 +983,6 @@
"to": "To",
"turn_all_on": "Turn all on",
"turn_all_off": "Turn all off",
- "unsaved_changes": "Unsaved Changes",
- "unsaved_changes_copy": "Are you sure you want to leave this page?",
"update_confirm": "Are you sure you want to update {count} items?",
"update_field": "Update Field",
"upload_exceeds_max_size": "{filename} can't be uploaded. Your server is not configured to handle uploads of this size.",
diff --git a/src/modules/collections/routes/detail/detail.vue b/src/modules/collections/routes/detail/detail.vue
index 0f7b863a7a..acd2e08526 100644
--- a/src/modules/collections/routes/detail/detail.vue
+++ b/src/modules/collections/routes/detail/detail.vue
@@ -142,6 +142,19 @@
v-model="edits"
/>
+
+
+ {{ $t('unsaved_changes') }}
+ {{ $t('unsaved_changes_copy') }}
+
+
+ {{ $t('discard_changes') }}
+
+ {{ $t('keep_editing') }}
+
+
+
+
@@ -188,6 +201,18 @@ type Values = {
export default defineComponent({
name: 'collections-detail',
+ beforeRouteLeave(to, from, next) {
+ const self = this as any;
+ const hasEdits = Object.keys(self.edits).length > 0;
+
+ if (hasEdits) {
+ self.confirmLeave = true;
+ self.leaveTo = to.fullPath;
+ return next(false);
+ }
+
+ return next();
+ },
components: {
CollectionsNavigation,
CollectionsNotFound,
@@ -238,6 +263,9 @@ export default defineComponent({
const confirmDelete = ref(false);
const confirmSoftDelete = ref(false);
+ const confirmLeave = ref(false);
+ const leaveTo = ref(null);
+
const backLink = computed(
() => `/${currentProjectKey.value}/collections/${collection.value}/`
);
@@ -287,6 +315,9 @@ export default defineComponent({
revisionsDrawerDetail,
marked,
refresh,
+ confirmLeave,
+ leaveTo,
+ discardAndLeave,
};
function useBreadcrumb() {
@@ -335,6 +366,12 @@ export default defineComponent({
await remove(soft);
router.push(`/${currentProjectKey.value}/collections/${props.collection}`);
}
+
+ function discardAndLeave() {
+ if (!leaveTo.value) return;
+ edits.value = {};
+ router.push(leaveTo.value);
+ }
},
});
diff --git a/src/modules/files/routes/detail/detail.vue b/src/modules/files/routes/detail/detail.vue
index 228af42a24..e30a38b773 100644
--- a/src/modules/files/routes/detail/detail.vue
+++ b/src/modules/files/routes/detail/detail.vue
@@ -102,6 +102,19 @@
/>
+
+
+ {{ $t('unsaved_changes') }}
+ {{ $t('unsaved_changes_copy') }}
+
+
+ {{ $t('discard_changes') }}
+
+ {{ $t('keep_editing') }}
+
+
+
+
0;
+
+ if (hasEdits) {
+ self.confirmLeave = true;
+ self.leaveTo = to.fullPath;
+ return next(false);
+ }
+
+ return next();
+ },
components: {
FilesNavigation,
RevisionsDrawerDetail,
@@ -204,6 +229,9 @@ export default defineComponent({
.filter((field: Field) => fieldsBlacklist.includes(field.field) === false);
});
+ const confirmLeave = ref(false);
+ const leaveTo = ref(null);
+
return {
item,
loading,
@@ -228,6 +256,9 @@ export default defineComponent({
revisionsDrawerDetail,
formFields,
marked,
+ confirmLeave,
+ leaveTo,
+ discardAndLeave,
};
function changeCacheBuster() {
@@ -276,6 +307,12 @@ export default defineComponent({
await remove();
router.push(`/${currentProjectKey.value}/files`);
}
+
+ function discardAndLeave() {
+ if (!leaveTo.value) return;
+ edits.value = {};
+ router.push(leaveTo.value);
+ }
},
});
diff --git a/src/modules/users/routes/detail/detail.vue b/src/modules/users/routes/detail/detail.vue
index 8165d0fabe..c5823f17f8 100644
--- a/src/modules/users/routes/detail/detail.vue
+++ b/src/modules/users/routes/detail/detail.vue
@@ -97,6 +97,19 @@
/>
+
+
+ {{ $t('unsaved_changes') }}
+ {{ $t('unsaved_changes_copy') }}
+
+
+ {{ $t('discard_changes') }}
+
+ {{ $t('keep_editing') }}
+
+
+
+
[TK]
@@ -141,6 +154,18 @@ type Values = {
export default defineComponent({
name: 'users-detail',
+ beforeRouteLeave(to, from, next) {
+ const self = this as any;
+ const hasEdits = Object.keys(self.edits).length > 0;
+
+ if (hasEdits) {
+ self.confirmLeave = true;
+ self.leaveTo = to.fullPath;
+ return next(false);
+ }
+
+ return next();
+ },
components: { UsersNavigation, RevisionsDrawerDetail, SaveOptions, CommentsDrawerDetail },
props: {
primaryKey: {
@@ -187,6 +212,9 @@ export default defineComponent({
const { loading: previewLoading, avatarSrc, roleName } = useUserPreview();
+ const confirmLeave = ref(false);
+ const leaveTo = ref(null);
+
return {
title,
item,
@@ -210,6 +238,9 @@ export default defineComponent({
previewLoading,
avatarSrc,
roleName,
+ confirmLeave,
+ leaveTo,
+ discardAndLeave,
};
function useBreadcrumb() {
@@ -291,6 +322,12 @@ export default defineComponent({
}
}
}
+
+ function discardAndLeave() {
+ if (!leaveTo.value) return;
+ edits.value = {};
+ router.push(leaveTo.value);
+ }
},
});
diff --git a/src/views/private/components/comments-drawer-detail/comments-drawer-detail.vue b/src/views/private/components/comments-drawer-detail/comments-drawer-detail.vue
index 26b44cc093..841573bc3d 100644
--- a/src/views/private/components/comments-drawer-detail/comments-drawer-detail.vue
+++ b/src/views/private/components/comments-drawer-detail/comments-drawer-detail.vue
@@ -2,7 +2,7 @@