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(() => {
const file = filesManager.getFile(selectedPath.value);
filesGridList.value = file?.isFolder ? file.content : [];
filesGridList.value = file?.content;
selectedList.value = [];
for (const selectedElement of document.querySelectorAll(".selectable.selected")) {

View File

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

View File

@ -144,7 +144,7 @@ export class FilesManager {
for (const file of (innerList || this.filesList.value)) {
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
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)) {
let recursiveFile = this.getFile(path, file.content);
const recursiveFile = this.getFile(path, file.content);
if (recursiveFile) {
return recursiveFile;
}