feat: "save changes" button to discard changes dialog

This commit is contained in:
Jorge 2025-09-13 08:07:05 +02:00 committed by GitHub
parent 571ce6cb0d
commit 84e8632b98
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 26 additions and 3 deletions

View File

@ -11,17 +11,26 @@
@click="closeHovers"
:aria-label="$t('buttons.cancel')"
:title="$t('buttons.cancel')"
tabindex="2"
tabindex="3"
>
{{ $t("buttons.cancel") }}
</button>
<button
class="button button--flat button--blue"
@click="saveAndClose"
:aria-label="$t('buttons.saveChanges')"
:title="$t('buttons.saveChanges')"
tabindex="1"
>
{{ $t("buttons.saveChanges") }}
</button>
<button
id="focus-prompt"
@click="currentPrompt.confirm"
class="button button--flat button--red"
:aria-label="$t('buttons.discardChanges')"
:title="$t('buttons.discardChanges')"
tabindex="1"
tabindex="2"
>
{{ $t("buttons.discardChanges") }}
</button>
@ -40,6 +49,12 @@ export default {
},
methods: {
...mapActions(useLayoutStore, ["closeHovers"]),
saveAndClose() {
if (this.currentPrompt?.saveAction) {
this.currentPrompt.saveAction();
}
this.closeHovers();
},
},
};
</script>

View File

@ -42,7 +42,8 @@
"update": "Update",
"upload": "Upload",
"openFile": "Open file",
"discardChanges": "Discard"
"discardChanges": "Discard",
"saveChanges": "Save changes"
},
"download": {
"downloadFile": "Download File",

View File

@ -41,6 +41,7 @@ export const useLayoutStore = defineStore("layout", {
prompt: value,
confirm: null,
action: undefined,
saveAction: undefined,
props: null,
close: null,
});
@ -51,6 +52,7 @@ export const useLayoutStore = defineStore("layout", {
prompt: value.prompt,
confirm: value?.confirm,
action: value?.action,
saveAction: value?.saveAction,
props: value?.props,
close: value?.close,
});

View File

@ -2,6 +2,7 @@ interface PopupProps {
prompt: string;
confirm?: any;
action?: PopupAction;
saveAction?: () => void;
props?: any;
close?: (() => Promise<string>) | null;
}

View File

@ -157,6 +157,10 @@ onBeforeRouteUpdate((to, from, next) => {
event.preventDefault();
next();
},
saveAction: async () => {
await save();
next();
},
});
});