From 20baf40d5e505eacdb54357c9742399e7e574e50 Mon Sep 17 00:00:00 2001 From: Salem Yaslem Date: Thu, 18 May 2023 23:54:37 +0300 Subject: [PATCH] get list of selected files --- app.vue | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/app.vue b/app.vue index 278e246..50ee2c6 100644 --- a/app.vue +++ b/app.vue @@ -41,6 +41,7 @@ watchEffect(async () => { }) function onDrop(e: any) { + if(!e.dataTransfer.files.length) return; files.value = e.dataTransfer.files; selectedItem.value = '/'; } @@ -87,28 +88,43 @@ function getFile(path: string, innerList = undefined): any { } let filesGridList = ref([]) +let selectedList = ref([]) watchEffect(() => { filesGridList.value = getFile(selectedItem.value)?.content || []; + selectedList.value = []; + + for (const selectedElement of document.querySelectorAll(".selectable.selected")) { + selectedElement.classList.remove("selected"); + } }) +watchEffect(() => { + console.log(selectedList.value) +}) + + let dragContainer = document.querySelector(".select-area"); function onSelectStart(e: any) { e.added.forEach((el: any) => { el.classList.add("selected"); + selectedList.value = [...selectedList.value, el?.__vnode?.ctx?.props?.value]; }); e.removed.forEach((el: any) => { el.classList.remove("selected"); + selectedList.value = selectedList.value.filter((value: string) => value != el?.__vnode?.ctx?.props?.value) }); } function onSelectEnd(e: any) { e.afterAdded.forEach((el: any) => { el.classList.add("selected"); + selectedList.value = [...selectedList.value, el?.__vnode?.ctx?.props?.value]; }); e.afterRemoved.forEach((el: any) => { el.classList.remove("selected"); + selectedList.value = selectedList.value.filter((value: string) => value != el?.__vnode?.ctx?.props?.value) }); } @@ -136,9 +152,9 @@ function onSelectEnd(e: any) { - + { selectedItem = file.path; }"> @@ -151,10 +167,11 @@ function onSelectEnd(e: any) { - + +