2018-02-01 12:17:04 +00:00
|
|
|
<template>
|
|
|
|
<div class="card floating">
|
|
|
|
<div class="card-content">
|
2023-12-28 09:11:53 +00:00
|
|
|
<p v-if="!this.isListing || selectedCount === 1">
|
2021-03-21 11:51:58 +00:00
|
|
|
{{ $t("prompts.deleteMessageSingle") }}
|
|
|
|
</p>
|
|
|
|
<p v-else>
|
|
|
|
{{ $t("prompts.deleteMessageMultiple", { count: selectedCount }) }}
|
|
|
|
</p>
|
2018-02-01 12:17:04 +00:00
|
|
|
</div>
|
|
|
|
<div class="card-action">
|
2021-03-21 11:51:58 +00:00
|
|
|
<button
|
2024-04-01 15:18:22 +00:00
|
|
|
@click="closeHovers"
|
2019-01-05 16:12:09 +00:00
|
|
|
class="button button--flat button--grey"
|
2018-02-01 12:17:04 +00:00
|
|
|
:aria-label="$t('buttons.cancel')"
|
2021-03-21 11:51:58 +00:00
|
|
|
:title="$t('buttons.cancel')"
|
2024-04-01 15:18:22 +00:00
|
|
|
tabindex="2"
|
2021-03-21 11:51:58 +00:00
|
|
|
>
|
|
|
|
{{ $t("buttons.cancel") }}
|
|
|
|
</button>
|
|
|
|
<button
|
2024-04-01 15:18:22 +00:00
|
|
|
id="focus-prompt"
|
2021-03-21 11:51:58 +00:00
|
|
|
@click="submit"
|
2019-01-05 16:12:09 +00:00
|
|
|
class="button button--flat button--red"
|
2018-02-01 12:17:04 +00:00
|
|
|
:aria-label="$t('buttons.delete')"
|
2021-03-21 11:51:58 +00:00
|
|
|
:title="$t('buttons.delete')"
|
2024-04-01 15:18:22 +00:00
|
|
|
tabindex="1"
|
2021-03-21 11:51:58 +00:00
|
|
|
>
|
|
|
|
{{ $t("buttons.delete") }}
|
|
|
|
</button>
|
2018-02-01 12:17:04 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
2024-04-01 15:18:22 +00:00
|
|
|
import { mapActions, mapState, mapWritableState } from "pinia";
|
2021-03-21 11:51:58 +00:00
|
|
|
import { files as api } from "@/api";
|
|
|
|
import buttons from "@/utils/buttons";
|
2024-04-01 15:18:22 +00:00
|
|
|
import { useFileStore } from "@/stores/file";
|
|
|
|
import { useLayoutStore } from "@/stores/layout";
|
2018-02-01 12:17:04 +00:00
|
|
|
|
|
|
|
export default {
|
2021-03-21 11:51:58 +00:00
|
|
|
name: "delete",
|
2024-04-01 15:18:22 +00:00
|
|
|
inject: ["$showError"],
|
2018-02-01 12:17:04 +00:00
|
|
|
computed: {
|
2024-04-01 15:18:22 +00:00
|
|
|
...mapState(useFileStore, [
|
|
|
|
"isListing",
|
|
|
|
"selectedCount",
|
|
|
|
"req",
|
|
|
|
"selected",
|
|
|
|
"currentPrompt",
|
|
|
|
]),
|
|
|
|
...mapWritableState(useFileStore, ["reload"]),
|
2018-02-01 12:17:04 +00:00
|
|
|
},
|
|
|
|
methods: {
|
2024-04-01 15:18:22 +00:00
|
|
|
...mapActions(useLayoutStore, ["closeHovers"]),
|
2019-01-05 16:12:09 +00:00
|
|
|
submit: async function () {
|
2021-03-21 11:51:58 +00:00
|
|
|
buttons.loading("delete");
|
2018-02-01 12:17:04 +00:00
|
|
|
|
2024-03-07 10:14:40 +00:00
|
|
|
window.sessionStorage.setItem("modified", "true");
|
2019-01-05 16:12:09 +00:00
|
|
|
try {
|
|
|
|
if (!this.isListing) {
|
2021-03-21 11:51:58 +00:00
|
|
|
await api.remove(this.$route.path);
|
|
|
|
buttons.success("delete");
|
2020-11-23 18:08:14 +00:00
|
|
|
|
2023-08-26 22:28:58 +00:00
|
|
|
this.currentPrompt?.confirm();
|
2021-03-21 11:51:58 +00:00
|
|
|
this.closeHovers();
|
|
|
|
return;
|
2019-01-05 16:12:09 +00:00
|
|
|
}
|
2018-02-01 12:17:04 +00:00
|
|
|
|
2021-03-21 11:51:58 +00:00
|
|
|
this.closeHovers();
|
2020-11-23 18:08:14 +00:00
|
|
|
|
2019-01-05 16:12:09 +00:00
|
|
|
if (this.selectedCount === 0) {
|
2021-03-21 11:51:58 +00:00
|
|
|
return;
|
2019-01-05 16:12:09 +00:00
|
|
|
}
|
2018-02-01 12:17:04 +00:00
|
|
|
|
2021-03-21 11:51:58 +00:00
|
|
|
let promises = [];
|
2019-01-05 16:12:09 +00:00
|
|
|
for (let index of this.selected) {
|
2021-03-21 11:51:58 +00:00
|
|
|
promises.push(api.remove(this.req.items[index].url));
|
2019-01-05 16:12:09 +00:00
|
|
|
}
|
2018-02-01 12:17:04 +00:00
|
|
|
|
2021-03-21 11:51:58 +00:00
|
|
|
await Promise.all(promises);
|
|
|
|
buttons.success("delete");
|
2024-04-01 15:18:22 +00:00
|
|
|
this.reload = true;
|
2019-01-05 16:12:09 +00:00
|
|
|
} catch (e) {
|
2021-03-21 11:51:58 +00:00
|
|
|
buttons.done("delete");
|
|
|
|
this.$showError(e);
|
2024-04-01 15:18:22 +00:00
|
|
|
if (this.isListing) this.reload = true;
|
2018-02-01 12:17:04 +00:00
|
|
|
}
|
2021-03-21 11:51:58 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
};
|
2018-02-01 12:17:04 +00:00
|
|
|
</script>
|