Skip to content

Commit 8784506

Browse files
authored
Merge pull request #182 from trustbit/feature/search-parent-domains
feat(filter): enable parent domain search support
2 parents f763528 + dd60497 commit 8784506

File tree

3 files changed

+14
-9
lines changed

3 files changed

+14
-9
lines changed

frontend-vue/src/components/primitives/input/ContextureSearch.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
@input="onInput"
1717
/>
1818
<div v-if="modelValue" class="absolute inset-y-0 right-0 flex cursor-pointer items-center pr-3" @click="clear">
19-
<Icon:materialSymbols:close class="h-5 w-5 text-blue-500 hover:text-blue-400" />
19+
<Icon:materialSymbols:close class="h-5 w-5 text-blue-500 hover:text-blue-400 bg-white" />
2020
</div>
2121
</div>
2222
</template>

frontend-vue/src/core/filter.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@ export function filter(obj: any, query: string, key?: string | undefined): boole
2222
return true;
2323
}
2424
} else if (typeof propValue === "object") {
25-
return filter(propValue, query);
25+
if (filter(propValue, query)) {
26+
return true;
27+
}
2628
} else if (typeof propValue === "string") {
2729
if (propValue.toLowerCase().includes(query?.toLowerCase())) {
2830
return true;

frontend-vue/src/pages/search/Search.vue

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424

2525
<div class="mt-8 flex flex-col gap-y-4">
2626
<template v-for="parentDomain of sortedParentDomains" :key="parentDomain.id">
27-
<div class="grid-cols-3 gap-4 bg-gray-100 p-2 sm:grid sm:p-6" v-if="showParentDomain(parentDomain.id)">
27+
<div class="grid-cols-3 gap-4 bg-gray-100 p-2 sm:grid sm:p-6" v-if="showParentDomain(parentDomain)">
2828
<!-- parent domains -->
2929
<!-- first column -->
3030
<RouterLink
@@ -325,8 +325,7 @@ import { useBoundedContextsStore } from "~/stores/boundedContexts";
325325
import { useDomainsStore } from "~/stores/domains";
326326
import { refDebounced, useLocalStorage } from "@vueuse/core";
327327
import { BoundedContext } from "~/types/boundedContext";
328-
import { Domain } from "~/types/domain";
329-
import { DomainId } from "~/types/domain";
328+
import { Domain, DomainId } from "~/types/domain";
330329
331330
interface DomainListViewSettings {
332331
showDescription: boolean;
@@ -419,9 +418,13 @@ const searchInBoundedContext = (
419418
}, {});
420419
};
421420
422-
const showParentDomain = (parentDomainId: DomainId) => {
423-
return searchQuery.value
424-
? filteredSubdomains.value[parentDomainId]?.length > 0 || filteredBoundedContexts.value[parentDomainId]?.length > 0
425-
: filteredSubdomains;
421+
const showParentDomain = (parentDomain: Domain) => {
422+
if (!searchQuery.value) return filteredSubdomains;
423+
const parentDomainId: DomainId = parentDomain.id;
424+
return (
425+
filteredSubdomains.value[parentDomainId]?.length > 0 ||
426+
filteredBoundedContexts.value[parentDomainId]?.length > 0 ||
427+
filter({ ...parentDomain, boundedContexts: [], subdomains: [] }, searchQuery.value)
428+
);
426429
};
427430
</script>

0 commit comments

Comments
 (0)