From 0601458aeb4b557cfe286338c9364e434282a67d Mon Sep 17 00:00:00 2001
From: pythongosssss <125205205+pythongosssss@users.noreply.github.com>
Date: Mon, 26 Aug 2024 14:06:40 +0100
Subject: [PATCH 1/4] Add search filters to node library
---
src/components/common/SearchBox.vue | 81 ++++++++++++++++---
src/components/common/SearchFilterChip.vue | 41 ++++++++++
src/components/searchbox/NodeSearchBox.vue | 60 ++++++++------
src/components/searchbox/NodeSearchFilter.vue | 73 ++++++-----------
.../sidebar/tabs/NodeLibrarySidebarTab.vue | 39 ++++++++-
src/services/nodeSearchService.ts | 14 +++-
6 files changed, 216 insertions(+), 92 deletions(-)
create mode 100644 src/components/common/SearchFilterChip.vue
diff --git a/src/components/common/SearchBox.vue b/src/components/common/SearchBox.vue
index bc3bb93cf..05c677e93 100644
--- a/src/components/common/SearchBox.vue
+++ b/src/components/common/SearchBox.vue
@@ -1,20 +1,45 @@
-
-
-
-
+
-
diff --git a/src/components/common/SearchFilterChip.vue b/src/components/common/SearchFilterChip.vue
new file mode 100644
index 000000000..11530550c
--- /dev/null
+++ b/src/components/common/SearchFilterChip.vue
@@ -0,0 +1,41 @@
+
+
+
+ {{ badge }}
+
+ {{ text }}
+
+
+
+
+
+
diff --git a/src/components/searchbox/NodeSearchBox.vue b/src/components/searchbox/NodeSearchBox.vue
index e19963745..07fcc2bfd 100644
--- a/src/components/searchbox/NodeSearchBox.vue
+++ b/src/components/searchbox/NodeSearchBox.vue
@@ -7,7 +7,22 @@
v-if="hoveredSuggestion"
/>
-
+
+
+
+
-
-
- {{ value[0].invokeSequence.toUpperCase() }}
-
- {{ value[1] }}
-
+
@@ -70,9 +85,9 @@
diff --git a/src/components/sidebar/tabs/NodeLibrarySidebarTab.vue b/src/components/sidebar/tabs/NodeLibrarySidebarTab.vue
index ab05d6e21..300148bbc 100644
--- a/src/components/sidebar/tabs/NodeLibrarySidebarTab.vue
+++ b/src/components/sidebar/tabs/NodeLibrarySidebarTab.vue
@@ -23,8 +23,17 @@
class="node-lib-search-box"
v-model:modelValue="searchQuery"
@search="handleSearch"
+ @show-filter="($event) => searchFilter.toggle($event)"
+ @filter-removed="handleSearch(searchQuery)"
:placeholder="$t('searchNodes') + '...'"
+ filter-icon="pi pi-filter"
+ :filters
/>
+
+
+
+
+
(null)
const hoveredComfyNode = computed(() => {
@@ -228,15 +241,20 @@ const insertNode = (nodeDef: ComfyNodeDefImpl) => {
}
const filteredRoot = ref(null)
+const filters = ref }>>(
+ []
+)
const handleSearch = (query: string) => {
- if (query.length < 3) {
+ if (query.length < 3 && !filters.value.length) {
filteredRoot.value = null
expandedKeys.value = {}
return
}
- const matchedNodes = nodeDefStore.nodeSearchService.searchNode(query, [], {
- limit: 64
+ const f = filters.value.map((f) => f.filter as FilterAndValue)
+ const matchedNodes = nodeDefStore.nodeSearchService.searchNode(query, f, {
+ limit: 64,
+ supportWildcard: false
})
filteredRoot.value = buildNodeDefTree(matchedNodes)
@@ -320,6 +338,19 @@ const addNewBookmarkFolder = (parent?: ComfyNodeDefImpl) => {
renameEditingNode.value = findNodeByKey(renderedRoot.value, newFolderKey)
})
}
+
+const onAddFilter = (filterAndValue: FilterAndValue) => {
+ searchFilter.value.hide()
+ filters.value.push({
+ filter: filterAndValue,
+ badge: filterAndValue[0].invokeSequence.toUpperCase(),
+ badgeClass: filterAndValue[0].invokeSequence + '-badge',
+ text: filterAndValue[1],
+ id: +new Date()
+ })
+
+ handleSearch(searchQuery.value)
+}