|
1 | 1 | <template> |
2 | | - <Modal :show="visible" v-on:close="visible = false"> |
| 2 | + <Modal :show="isVisible" v-on:close="isVisible = false"> |
3 | 3 | <MessageBox |
4 | 4 | class="alert error mb-8" |
5 | 5 | title="Error" |
|
12 | 12 | Deletion is a permanent operation: <strong>{{ object.name }}</strong><span v-if="object.directory">, as well as its contents,</span> will be removed immediately. |
13 | 13 | </p> |
14 | 14 | <div class="mt-8 text-right"> |
15 | | - <button class="btn btn-secondary btn-sm" v-on:click.prevent="visible = false">Cancel</button> |
| 15 | + <button class="btn btn-secondary btn-sm" v-on:click.prevent="isVisible = false">Cancel</button> |
16 | 16 | <button class="btn btn-red btn-sm ml-2" v-on:click="deleteItem" :disabled="isLoading"> |
17 | 17 | <span v-if="isLoading" class="spinner white"> </span> |
18 | 18 | <span v-else>Yes, Delete</span> |
|
30 | 30 | import {mapState} from "vuex"; |
31 | 31 | import {AxiosError} from "axios"; |
32 | 32 | import { join } from 'path'; |
| 33 | + import {ApplicationState} from '@/store/types'; |
33 | 34 |
|
34 | 35 | type DataStructure = { |
35 | 36 | isLoading: boolean, |
|
45 | 46 | object: { type: Object as () => DirectoryContentObject, required: true } |
46 | 47 | }, |
47 | 48 |
|
48 | | - watch: { |
49 | | - visible: function (value: boolean) { |
50 | | - this.$emit('update:visible', value); |
51 | | - }, |
52 | | - }, |
53 | | -
|
54 | 49 | data: function (): DataStructure { |
55 | 50 | return { |
56 | 51 | isLoading: false, |
|
59 | 54 | }, |
60 | 55 |
|
61 | 56 | computed: { |
62 | | - ...mapState('server', ['fm', 'server', 'credentials']), |
| 57 | + ...mapState({ |
| 58 | + server: (state: ApplicationState) => state.server.server, |
| 59 | + credentials: (state: ApplicationState) => state.server.credentials, |
| 60 | + fm: (state: ApplicationState) => state.server.fm, |
| 61 | + }), |
| 62 | +
|
| 63 | + isVisible: { |
| 64 | + get: function (): boolean { |
| 65 | + return this.visible; |
| 66 | + }, |
| 67 | + set: function (value: boolean) { |
| 68 | + this.$emit('update:visible', value); |
| 69 | + }, |
| 70 | + }, |
63 | 71 | }, |
64 | 72 |
|
65 | 73 | methods: { |
66 | 74 | deleteItem: function () { |
67 | 75 | this.isLoading = true; |
68 | 76 |
|
| 77 | + // @ts-ignore |
69 | 78 | deleteElement(this.server.uuid, this.credentials, [ |
| 79 | + // @ts-ignore |
70 | 80 | join(this.fm.currentDirectory, this.object.name) |
71 | 81 | ]) |
72 | 82 | .then(() => this.$emit('deleted')) |
|
0 commit comments