Skip to content

Commit

Permalink
[KNOWAGE-8726]
Browse files Browse the repository at this point in the history
Added logic that filters out empty folders to reduce clutter.
  • Loading branch information
dbulatovicx32 committed Jan 15, 2025
1 parent f42f8b6 commit 842d6e9
Showing 1 changed file with 22 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ export default defineComponent({
.finally(() => {
this.loading = false
this.createNodeTree()
this.removeEmptyFolders()
})
},
createNodeTree() {
Expand Down Expand Up @@ -277,6 +278,27 @@ export default defineComponent({
},
toggleImportDialog() {
this.displayImportDialog = !this.displayImportDialog
},
filterDocuments(folder: iNode, parentFolder: any) {
if (folder.children && folder.children.length > 0) {
for (let i = folder.children.length - 1; i >= 0; i--) {
this.filterDocuments(folder.children[i], folder)
}
}
if (folder.children?.length == 0 && parentFolder && parentFolder.children) {
const array = parentFolder.children
const index = array.findIndex((node: iNode) => node.id === folder.id)
array.splice(index, 1)
}
},
removeEmptyFolders() {
for (let i = 0; i < this.nodes.length; i++) {
this.filterDocuments(this.nodes[i], null as any)
if (this.nodes[i].children?.length === 0) {
this.nodes[i].selectable = false
}
}
}
}
})
Expand Down

0 comments on commit 842d6e9

Please sign in to comment.