diff --git a/src/store/files.js b/src/store/files.js
index b900382f68..b6fa3abc29 100644
--- a/src/store/files.js
+++ b/src/store/files.js
@@ -223,13 +223,24 @@ export const useFilesStore = function(...args) {
await axios.delete(generateOcsUrl(url, {
fileId: file.nodeId,
}))
+ .then(() => {
+ del(this.files, file.nodeId)
+ const index = this.ordered.indexOf(file.nodeId)
+ if (index > -1) {
+ this.ordered.splice(index, 1)
+ }
+ })
}
- del(this.files, file.nodeId)
- const index = this.ordered.indexOf(file.nodeId)
- if (index > -1) {
- this.ordered.splice(index, 1)
- }
+ },
+ async deleteMultiple(nodeIds, deleteFile) {
+ this.loading = true
+ nodeIds.forEach(async nodeId => {
+ await this.delete(this.files[nodeId], deleteFile)
+ })
+ const toRemove = nodeIds.filter(nodeId => (!this.files[nodeId]?.uuid))
+ del(this.files, ...toRemove)
+ this.loading = false
},
async getAllFiles(filter) {
if (this.loading || this.loadedAll) {
diff --git a/src/store/keyboard.js b/src/store/keyboard.js
new file mode 100644
index 0000000000..20693a71d5
--- /dev/null
+++ b/src/store/keyboard.js
@@ -0,0 +1,47 @@
+/**
+ * SPDX-FileCopyrightText: 2024 LibreCode coop and contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
+ */
+import { defineStore } from 'pinia'
+import { set } from 'vue'
+
+/**
+ * Observe various events and save the current
+ * special keys states. Useful for checking the
+ * current status of a key when executing a method.
+ * @param {...any} args properties
+ */
+export const useKeyboardStore = function(...args) {
+ const store = defineStore('keyboard', {
+ state: () => ({
+ altKey: false,
+ ctrlKey: false,
+ metaKey: false,
+ shiftKey: false,
+ }),
+
+ actions: {
+ onEvent(event) {
+ if (!event) {
+ event = window.event
+ }
+ set(this, 'altKey', !!event.altKey)
+ set(this, 'ctrlKey', !!event.ctrlKey)
+ set(this, 'metaKey', !!event.metaKey)
+ set(this, 'shiftKey', !!event.shiftKey)
+ },
+ },
+ })
+
+ const keyboardStore = store(...args)
+ // Make sure we only register the listeners once
+ if (!keyboardStore._initialized) {
+ window.addEventListener('keydown', keyboardStore.onEvent)
+ window.addEventListener('keyup', keyboardStore.onEvent)
+ window.addEventListener('mousemove', keyboardStore.onEvent)
+
+ keyboardStore._initialized = true
+ }
+
+ return keyboardStore
+}
diff --git a/src/store/selection.js b/src/store/selection.js
new file mode 100644
index 0000000000..a6e6ed3b1f
--- /dev/null
+++ b/src/store/selection.js
@@ -0,0 +1,57 @@
+/**
+ * SPDX-FileCopyrightText: 2024 LibreCode coop and contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
+ */
+import { defineStore } from 'pinia'
+import { set } from 'vue'
+
+import { subscribe } from '@nextcloud/event-bus'
+
+export const useSelectionStore = function(...args) {
+ const store = defineStore('selection', {
+ state: () => ({
+ selected: [],
+ lastSelection: [],
+ lastSelectedIndex: null,
+ }),
+
+ actions: {
+ /**
+ * Set the selection of fileIds
+ * @param {Array} selection Selected files
+ */
+ set(selection = []) {
+ set(this, 'selected', [...new Set(selection)])
+ },
+
+ /**
+ * Set the last selected index
+ * @param {number | null} lastSelectedIndex Position of last selected file
+ */
+ setLastIndex(lastSelectedIndex = null) {
+ // Update the last selection if we provided a new selection starting point
+ set(this, 'lastSelection', lastSelectedIndex ? this.selected : [])
+ set(this, 'lastSelectedIndex', lastSelectedIndex)
+ },
+
+ /**
+ * Reset the selection
+ */
+ reset() {
+ set(this, 'selected', [])
+ set(this, 'lastSelection', [])
+ set(this, 'lastSelectedIndex', null)
+ },
+ },
+ })
+
+ const selectionStore = store(...args)
+
+ // Make sure we only register the listeners once
+ if (!selectionStore._initialized) {
+ subscribe('libresign:filters:update', selectionStore.reset)
+ selectionStore._initialized = true
+ }
+
+ return selectionStore
+}
diff --git a/src/views/FilesList/FileEntry/FileEntry.vue b/src/views/FilesList/FileEntry/FileEntry.vue
index dc7512ba02..69e4c57e2f 100644
--- a/src/views/FilesList/FileEntry/FileEntry.vue
+++ b/src/views/FilesList/FileEntry/FileEntry.vue
@@ -5,6 +5,10 @@
+
+
@@ -40,6 +44,7 @@
import NcDateTime from '@nextcloud/vue/dist/Components/NcDateTime.js'
import FileEntryActions from './FileEntryActions.vue'
+import FileEntryCheckbox from './FileEntryCheckbox.vue'
import FileEntryName from './FileEntryName.vue'
import FileEntryPreview from './FileEntryPreview.vue'
import FileEntryStatus from './FileEntryStatus.vue'
@@ -53,6 +58,7 @@ export default {
components: {
NcDateTime,
FileEntryActions,
+ FileEntryCheckbox,
FileEntryName,
FileEntryPreview,
FileEntryStatus,
diff --git a/src/views/FilesList/FileEntry/FileEntryCheckbox.vue b/src/views/FilesList/FileEntry/FileEntryCheckbox.vue
new file mode 100644
index 0000000000..c577e79156
--- /dev/null
+++ b/src/views/FilesList/FileEntry/FileEntryCheckbox.vue
@@ -0,0 +1,113 @@
+
+
+
+
+
@@ -26,13 +37,6 @@
@click="openDetailsIfAvailable">
-
-
-
+
+
+
+
diff --git a/src/views/FilesList/FileEntry/FileEntryGrid.vue b/src/views/FilesList/FileEntry/FileEntryGrid.vue
index e810debe8f..cb0006c97e 100644
--- a/src/views/FilesList/FileEntry/FileEntryGrid.vue
+++ b/src/views/FilesList/FileEntry/FileEntryGrid.vue
@@ -13,6 +13,10 @@
:extension="'.pdf'" />
+
+