feature/searchbar-enhance #17

Merged
ilia merged 48 commits from feature/searchbar-enhance into main 2026-01-18 14:04:53 +00:00
Showing only changes of commit f02b19eff5 - Show all commits

View File

@@ -37,41 +37,43 @@ export function createFilter<TValue extends string>(initialState: FilterModel<TV
})),
);
// Helper to find a property by ID
const findProp = (id: string) => properties.find(p => p.id === id);
return {
get properties() {
return properties;
},
get selectedProperties() {
return properties.filter(p => p.selected);
},
get selectedCount() {
return this.selectedProperties.length;
return properties.filter(p => p.selected)?.length;
},
// 3. Methods mutate the reactive state directly
toggleProperty(id: string) {
const prop = properties.find(p => p.id === id);
if (prop) prop.selected = !prop.selected;
const property = findProp(id);
if (property) {
property.selected = !property.selected;
}
},
selectProperty(id: string) {
const prop = properties.find(p => p.id === id);
if (prop) prop.selected = true;
const property = findProp(id);
if (property) {
property.selected = true;
}
},
deselectProperty(id: string) {
const prop = properties.find(p => p.id === id);
if (prop) prop.selected = false;
const property = findProp(id);
if (property) {
property.selected = false;
}
},
selectAll() {
properties.forEach(p => p.selected = true);
properties.forEach(property => property.selected = true);
},
deselectAll() {
properties.forEach(p => p.selected = false);
properties.forEach(property => property.selected = false);
},
};
}