Skip to content

A continuation of HomeBox the inventory and organization system built for the Home User

feat: compare filter values on a unique field instead of by reference for finding unselected (#195)

Tonya0ab95fb670b2
diff --git a/frontend/components/Search/Filter.vue b/frontend/components/Search/Filter.vue
index 328934a0..2cbbf6d3 100644
--- a/frontend/components/Search/Filter.vue
+++ b/frontend/components/Search/Filter.vue
@@ -45,6 +45,7 @@
options: any[];
display?: string;
modelValue: any[];
+ uniqueField: string;
};
const btn = ref<HTMLButtonElement>();
@@ -75,6 +76,7 @@
label: "",
display: "name",
modelValue: () => [],
+ uniqueField: "id",
});
const len = computed(() => {
@@ -95,9 +97,9 @@
const unselected = computed(() => {
return props.options.filter(o => {
if (searchFold.value.length > 0) {
- return o[props.display].toLowerCase().includes(searchFold.value) && !selected.value.includes(o);
+ return o[props.display].toLowerCase().includes(searchFold.value) && selected.value.every(s => s[props.uniqueField] !== o[props.uniqueField]);
}
- return !selected.value.includes(o);
+ return selected.value.every(s => s[props.uniqueField] !== o[props.uniqueField]);
});
});
</script>