55 lines
1.2 KiB
TypeScript
55 lines
1.2 KiB
TypeScript
import { defineStore } from 'pinia';
|
|
import type { DirectoryEntry } from '~/types';
|
|
import type { Warren } from '~/types/warrens';
|
|
|
|
export const useWarrenStore = defineStore<
|
|
'warrens',
|
|
{
|
|
warrens: Record<string, Warren>;
|
|
}
|
|
>('warrens', {
|
|
state: () => ({
|
|
warrens: {},
|
|
upload: null,
|
|
}),
|
|
});
|
|
|
|
export const useWarrenRoute = () =>
|
|
computed(() => useRoute().path.split('/warrens/')[1]);
|
|
|
|
export const useCreateDirectoryDialog = defineStore('create_directory_dialog', {
|
|
state: () => ({
|
|
open: false,
|
|
value: '',
|
|
}),
|
|
actions: {
|
|
openDialog() {
|
|
this.open = true;
|
|
},
|
|
reset() {
|
|
this.open = false;
|
|
this.value = '';
|
|
},
|
|
},
|
|
});
|
|
|
|
export const useRenameDirectoryDialog = defineStore('rename_directory_dialog', {
|
|
state: () => ({
|
|
open: false,
|
|
entry: null as DirectoryEntry | null,
|
|
value: '',
|
|
}),
|
|
actions: {
|
|
openDialog(entry: DirectoryEntry) {
|
|
this.entry = entry;
|
|
this.value = entry.name;
|
|
this.open = true;
|
|
},
|
|
reset() {
|
|
this.open = false;
|
|
this.entry = null;
|
|
this.value = '';
|
|
},
|
|
},
|
|
});
|