basic selection + download multiple files with selection

This commit is contained in:
2025-09-02 18:08:13 +02:00
parent be46f92ddf
commit e2085c1baa
22 changed files with 516 additions and 156 deletions

View File

@@ -9,7 +9,15 @@ export const useWarrenStore = defineStore('warrens', {
imageViewer: {
src: null as string | null,
},
current: null as { warrenId: string; path: string } | null,
current: null as {
warrenId: string;
path: string;
dir: {
parent: DirectoryEntry | null;
entries: DirectoryEntry[];
} | null;
} | null,
selection: new Set() as Set<DirectoryEntry>,
loading: false,
}),
actions: {
@@ -17,6 +25,21 @@ export const useWarrenStore = defineStore('warrens', {
this.current = {
warrenId,
path,
dir: null,
};
this.clearSelection();
},
setCurrentWarrenEntries(
entries: DirectoryEntry[],
parent: DirectoryEntry | null
) {
if (this.current == null) {
return;
}
this.current.dir = {
entries,
parent,
};
},
addToCurrentWarrenPath(path: string) {
@@ -28,14 +51,14 @@ export const useWarrenStore = defineStore('warrens', {
path = '/' + path;
}
this.current.path += path;
this.setCurrentWarrenPath(this.current.path + path);
},
backCurrentPath(): boolean {
if (this.current == null || this.current.path === '/') {
return false;
}
this.current.path = getParentPath(this.current.path);
this.setCurrentWarrenPath(getParentPath(this.current.path));
return true;
},
@@ -44,15 +67,50 @@ export const useWarrenStore = defineStore('warrens', {
return;
}
const previous = this.current.path;
if (!path.startsWith('/')) {
path = '/' + path;
}
this.current.path = path;
if (previous !== path) {
this.clearSelection();
this.current.dir = null;
}
},
clearCurrentWarren() {
this.current = null;
},
addToSelection(entry: DirectoryEntry) {
this.selection.add(entry);
},
addMultipleToSelection(entries: DirectoryEntry[]) {
for (const entry of entries) {
this.selection.add(entry);
}
},
removeFromSelection(entry: DirectoryEntry): boolean {
return this.selection.delete(entry);
},
toggleSelection(entry: DirectoryEntry) {
if (this.selection.has(entry)) {
this.removeFromSelection(entry);
} else {
this.addToSelection(entry);
}
},
isSelected(entry: DirectoryEntry): boolean {
if (this.current == null) {
return false;
}
return this.selection.has(entry);
},
clearSelection() {
this.selection.clear();
},
},
});