massage data

This commit is contained in:
Casey 2025-11-06 18:24:19 -06:00
parent 616fa1be79
commit 60d3f35988
7 changed files with 174 additions and 48 deletions

View file

@ -6,7 +6,7 @@ export const useFiltersStore = defineStore("filters", {
// Store filters by table/component name
tableFilters: {
clients: {
fullName: { value: null, matchMode: FilterMatchMode.CONTAINS },
addressName: { value: null, matchMode: FilterMatchMode.CONTAINS },
},
jobs: {
customer: { value: null, matchMode: FilterMatchMode.CONTAINS },
@ -25,24 +25,24 @@ export const useFiltersStore = defineStore("filters", {
routes: {
technician: { value: null, matchMode: FilterMatchMode.CONTAINS },
routeId: { value: null, matchMode: FilterMatchMode.CONTAINS },
}
}
},
},
}),
actions: {
// Generic method to get filters for a specific table
getTableFilters(tableName) {
return this.tableFilters[tableName] || {};
},
// Generic method to update a specific filter
updateTableFilter(tableName, fieldName, value, matchMode = null) {
if (!this.tableFilters[tableName]) {
this.tableFilters[tableName] = {};
}
if (!this.tableFilters[tableName][fieldName]) {
this.tableFilters[tableName][fieldName] = {
value: null,
matchMode: FilterMatchMode.CONTAINS
this.tableFilters[tableName][fieldName] = {
value: null,
matchMode: FilterMatchMode.CONTAINS,
};
}
this.tableFilters[tableName][fieldName].value = value;
@ -55,7 +55,7 @@ export const useFiltersStore = defineStore("filters", {
// Method to clear all filters for a table
clearTableFilters(tableName) {
if (this.tableFilters[tableName]) {
Object.keys(this.tableFilters[tableName]).forEach(key => {
Object.keys(this.tableFilters[tableName]).forEach((key) => {
this.tableFilters[tableName][key].value = null;
});
}
@ -66,12 +66,12 @@ export const useFiltersStore = defineStore("filters", {
if (!this.tableFilters[tableName]) {
this.tableFilters[tableName] = {};
}
columns.forEach(column => {
columns.forEach((column) => {
if (column.filterable && !this.tableFilters[tableName][column.fieldName]) {
this.tableFilters[tableName][column.fieldName] = {
value: null,
matchMode: FilterMatchMode.CONTAINS
matchMode: FilterMatchMode.CONTAINS,
};
}
});
@ -79,12 +79,12 @@ export const useFiltersStore = defineStore("filters", {
// Legacy method for backward compatibility
setClientNameFilter(filterValue) {
this.updateTableFilter('clients', 'fullName', filterValue);
this.updateTableFilter("clients", "addressName", filterValue);
},
// Getter for legacy compatibility
get clientNameFilter() {
return this.tableFilters?.clients?.fullName?.value || "";
}
return this.tableFilters?.clients?.addressName?.value || "";
},
},
});