mirror of
https://github.com/filebrowser/filebrowser.git
synced 2025-09-14 10:20:32 +00:00
feat: "save changes" button to discard changes dialog
This commit is contained in:
parent
571ce6cb0d
commit
84e8632b98
@ -11,17 +11,26 @@
|
|||||||
@click="closeHovers"
|
@click="closeHovers"
|
||||||
:aria-label="$t('buttons.cancel')"
|
:aria-label="$t('buttons.cancel')"
|
||||||
:title="$t('buttons.cancel')"
|
:title="$t('buttons.cancel')"
|
||||||
tabindex="2"
|
tabindex="3"
|
||||||
>
|
>
|
||||||
{{ $t("buttons.cancel") }}
|
{{ $t("buttons.cancel") }}
|
||||||
</button>
|
</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
|
<button
|
||||||
id="focus-prompt"
|
id="focus-prompt"
|
||||||
@click="currentPrompt.confirm"
|
@click="currentPrompt.confirm"
|
||||||
class="button button--flat button--red"
|
class="button button--flat button--red"
|
||||||
:aria-label="$t('buttons.discardChanges')"
|
:aria-label="$t('buttons.discardChanges')"
|
||||||
:title="$t('buttons.discardChanges')"
|
:title="$t('buttons.discardChanges')"
|
||||||
tabindex="1"
|
tabindex="2"
|
||||||
>
|
>
|
||||||
{{ $t("buttons.discardChanges") }}
|
{{ $t("buttons.discardChanges") }}
|
||||||
</button>
|
</button>
|
||||||
@ -40,6 +49,12 @@ export default {
|
|||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
...mapActions(useLayoutStore, ["closeHovers"]),
|
...mapActions(useLayoutStore, ["closeHovers"]),
|
||||||
|
saveAndClose() {
|
||||||
|
if (this.currentPrompt?.saveAction) {
|
||||||
|
this.currentPrompt.saveAction();
|
||||||
|
}
|
||||||
|
this.closeHovers();
|
||||||
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
@ -42,7 +42,8 @@
|
|||||||
"update": "Update",
|
"update": "Update",
|
||||||
"upload": "Upload",
|
"upload": "Upload",
|
||||||
"openFile": "Open file",
|
"openFile": "Open file",
|
||||||
"discardChanges": "Discard"
|
"discardChanges": "Discard",
|
||||||
|
"saveChanges": "Save changes"
|
||||||
},
|
},
|
||||||
"download": {
|
"download": {
|
||||||
"downloadFile": "Download File",
|
"downloadFile": "Download File",
|
||||||
|
@ -41,6 +41,7 @@ export const useLayoutStore = defineStore("layout", {
|
|||||||
prompt: value,
|
prompt: value,
|
||||||
confirm: null,
|
confirm: null,
|
||||||
action: undefined,
|
action: undefined,
|
||||||
|
saveAction: undefined,
|
||||||
props: null,
|
props: null,
|
||||||
close: null,
|
close: null,
|
||||||
});
|
});
|
||||||
@ -51,6 +52,7 @@ export const useLayoutStore = defineStore("layout", {
|
|||||||
prompt: value.prompt,
|
prompt: value.prompt,
|
||||||
confirm: value?.confirm,
|
confirm: value?.confirm,
|
||||||
action: value?.action,
|
action: value?.action,
|
||||||
|
saveAction: value?.saveAction,
|
||||||
props: value?.props,
|
props: value?.props,
|
||||||
close: value?.close,
|
close: value?.close,
|
||||||
});
|
});
|
||||||
|
1
frontend/src/types/layout.d.ts
vendored
1
frontend/src/types/layout.d.ts
vendored
@ -2,6 +2,7 @@ interface PopupProps {
|
|||||||
prompt: string;
|
prompt: string;
|
||||||
confirm?: any;
|
confirm?: any;
|
||||||
action?: PopupAction;
|
action?: PopupAction;
|
||||||
|
saveAction?: () => void;
|
||||||
props?: any;
|
props?: any;
|
||||||
close?: (() => Promise<string>) | null;
|
close?: (() => Promise<string>) | null;
|
||||||
}
|
}
|
||||||
|
@ -157,6 +157,10 @@ onBeforeRouteUpdate((to, from, next) => {
|
|||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
next();
|
next();
|
||||||
},
|
},
|
||||||
|
saveAction: async () => {
|
||||||
|
await save();
|
||||||
|
next();
|
||||||
|
},
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user