|
188 | 188 |
|
189 | 189 | <script> |
190 | 190 | import '@nextcloud/dialogs/style.css' |
191 | | -import Vue from 'vue' |
| 191 | +import Vue, { defineComponent } from 'vue' |
192 | 192 |
|
193 | 193 | import axios from '@nextcloud/axios' |
194 | 194 | import { showError } from '@nextcloud/dialogs' |
@@ -225,7 +225,7 @@ const NcModal = () => import( |
225 | 225 | const NcActionLink = () => import(/* webpackChunkName: 'components' */'@nextcloud/vue/dist/Components/NcActionLink.js') |
226 | 226 | const NcActionButton = () => import(/* webpackChunkName: 'components' */'@nextcloud/vue/dist/Components/NcActionButton.js') |
227 | 227 |
|
228 | | -export default { |
| 228 | +export default defineComponent({ |
229 | 229 | name: 'Viewer', |
230 | 230 |
|
231 | 231 | components: { |
@@ -963,7 +963,7 @@ export default { |
963 | 963 | event.preventDefault() |
964 | 964 | if (this.canDownload) { |
965 | 965 | const a = document.createElement('a') |
966 | | - a.href = this.currentFile.davPath |
| 966 | + a.href = this.currentFile.source ?? this.currentFile.davPath |
967 | 967 | a.download = this.currentFile.basename |
968 | 968 | document.body.appendChild(a) |
969 | 969 | a.click() |
@@ -1116,16 +1116,25 @@ export default { |
1116 | 1116 | async onDelete() { |
1117 | 1117 | try { |
1118 | 1118 | const fileid = this.currentFile.fileid |
1119 | | - const url = this.source ?? this.currentFile.davPath |
| 1119 | + const url = this.currentFile.source ?? this.currentFile.davPath |
| 1120 | +
|
| 1121 | + // Fake node to emit the event until Viewer is migrated to the new Node API. |
| 1122 | + const node = new NcFile({ |
| 1123 | + source: url, |
| 1124 | + fileid, |
| 1125 | + mime: this.currentFile.mime, |
| 1126 | + owner: this.currentFile.ownerId, |
| 1127 | + root: url.includes('remote.php/dav') ? davGetRootPath() : undefined, |
| 1128 | + }) |
1120 | 1129 |
|
1121 | 1130 | await axios.delete(url) |
1122 | | - emit('files:node:deleted', { fileid }) |
| 1131 | + emit('files:node:deleted', node) |
1123 | 1132 |
|
1124 | | - // fileid is not unique, basename is not unqiue, filename is |
| 1133 | + // fileid is not unique, basename is not unique, filename is |
1125 | 1134 | const currentIndex = this.fileList.findIndex(file => file.filename === this.currentFile.filename) |
1126 | 1135 | if (this.hasPrevious || this.hasNext) { |
1127 | 1136 | // Checking the previous or next file |
1128 | | - this.hasPrevious ? this.previous() : this.next() |
| 1137 | + this.hasNext ? this.next() : this.previous() |
1129 | 1138 |
|
1130 | 1139 | this.fileList.splice(currentIndex, 1) |
1131 | 1140 | } else { |
@@ -1194,7 +1203,7 @@ export default { |
1194 | 1203 | }, |
1195 | 1204 |
|
1196 | 1205 | }, |
1197 | | -} |
| 1206 | +}) |
1198 | 1207 | </script> |
1199 | 1208 |
|
1200 | 1209 | <style lang="scss" scoped> |
|
0 commit comments