fix click on file

This commit is contained in:
Salem Yaslem 2023-06-03 06:59:17 +03:00
parent c9dde79651
commit 564825f3a8
3 changed files with 18 additions and 19 deletions

View File

@ -54,7 +54,7 @@ onUnmounted(() => {
watchEffect(() => { watchEffect(() => {
const file = filesManager.getFile(selectedPath.value); const file = filesManager.getFile(selectedPath.value);
filesGridList.value = file?.isFolder ? file.content : []; filesGridList.value = file?.content;
selectedList.value = []; selectedList.value = [];
for (const selectedElement of document.querySelectorAll(".selectable.selected")) { for (const selectedElement of document.querySelectorAll(".selectable.selected")) {

View File

@ -13,8 +13,8 @@ let selectedPath = useSelectedPath();
<template> <template>
<v-list :selected="[selectedPath]" density="compact" :nav="nav"> <v-list :selected="[selectedPath]" density="compact" :nav="nav">
<template v-for="file in filesList" :key="file.path"> <template v-for="file in filesList" :key="file.path">
<v-list-item active-color="light-blue-darken-4" :active=file.active :title="file.name" :subtitle="file.path" :value="file.path" <v-list-item active-color="light-blue-darken-4" :active=file.active :title="file.name" :subtitle="file.path"
@click="() =>{ :value="file.path" @click="() => {
selectedPath = file.path; selectedPath = file.path;
file.toggle = !file.toggle; file.toggle = !file.toggle;
}"> }">
@ -27,10 +27,9 @@ let selectedPath = useSelectedPath();
<v-icon>{{ `mdi-chevron-${file.toggle ? 'up' : 'down'}` }}</v-icon> <v-icon>{{ `mdi-chevron-${file.toggle ? 'up' : 'down'}` }}</v-icon>
</template> </template>
</v-list-item> </v-list-item>
<div :style="`background-color: rgba(0,0,0,0.05);${nav ? `border-radius: 4px;` : ''}` "> <div v-if="file.isFolder && file.toggle"
<template v-if="file.isFolder && file.toggle"> :style="`background-color: rgba(0,0,0,0.05);${nav ? `border-radius: 4px;` : ''}`">
<TreeView :files-list="file.content" :nav="false"></TreeView> <TreeView :files-list="file.content" :nav="false"></TreeView>
</template>
</div> </div>
</template> </template>
</v-list> </v-list>

View File

@ -144,7 +144,7 @@ export class FilesManager {
for (const file of (innerList || this.filesList.value)) { for (const file of (innerList || this.filesList.value)) {
if (file.path == path) { if (file.path == path) {
file.content = file.content.sort((a:any, b:any) => { file.content = file.content?.sort((a:any, b:any) => {
// sort by folder and from a to z // sort by folder and from a to z
if (a.isFolder && !b.isFolder) return -1; if (a.isFolder && !b.isFolder) return -1;
if (!a.isFolder && b.isFolder) return 1; if (!a.isFolder && b.isFolder) return 1;
@ -157,7 +157,7 @@ export class FilesManager {
} }
if (file.isFolder && path.includes(file.path)) { if (file.isFolder && path.includes(file.path)) {
let recursiveFile = this.getFile(path, file.content); const recursiveFile = this.getFile(path, file.content);
if (recursiveFile) { if (recursiveFile) {
return recursiveFile; return recursiveFile;
} }