chore(createFilter): change format
This commit is contained in:
@@ -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);
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user