ag-grid-url-sync 0.2.2 → 0.2.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +45 -22
- package/dist/core/grid-integration.d.ts +1 -1
- package/dist/core/grid-integration.js +141 -9
- package/dist/core/grid-integration.js.map +1 -1
- package/dist/core/types.d.ts +174 -36
- package/dist/core/types.js +179 -37
- package/dist/core/types.js.map +1 -1
- package/dist/core/url-generator.js +53 -15
- package/dist/core/url-generator.js.map +1 -1
- package/dist/core/url-parser.js +164 -35
- package/dist/core/url-parser.js.map +1 -1
- package/dist/core/validation.d.ts +38 -5
- package/dist/core/validation.js +115 -3
- package/dist/core/validation.js.map +1 -1
- package/dist/react/types.d.ts +5 -0
- package/dist/react/use-ag-grid-url-sync.js +42 -27
- package/dist/react/use-ag-grid-url-sync.js.map +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -8,6 +8,7 @@ A lightweight TypeScript library for synchronizing AG Grid text and number filte
|
|
|
8
8
|
|
|
9
9
|
- 🔍 **Complete text filter support** - All 8 AG Grid text operations (contains, equals, not contains, not equal, starts with, ends with, blank, not blank)
|
|
10
10
|
- 🔢 **Complete number filter support** - All 9 AG Grid number operations (equals, not equal, greater than, greater than or equal, less than, less than or equal, in range, blank, not blank)
|
|
11
|
+
- 🔢 **Complete date filter support** - All 9 AG Grid date operations (equals, not equal, before, before or equal, after, after or equal, in range, blank, not blank) with strict ISO date validation (YYYY-MM-DD)
|
|
11
12
|
- 🔗 Manual URL generation for sharing filter states
|
|
12
13
|
- ↔️ Bidirectional sync between grid and URL
|
|
13
14
|
- 🛠️ Framework agnostic - works with any AG Grid setup
|
|
@@ -22,7 +23,7 @@ A lightweight TypeScript library for synchronizing AG Grid text and number filte
|
|
|
22
23
|
|
|
23
24
|
## Supported Filter Types
|
|
24
25
|
|
|
25
|
-
Supports **all AG Grid text and
|
|
26
|
+
Supports **all AG Grid text, number, and date filter operations** (26 total) with clean, human-readable URL parameters:
|
|
26
27
|
|
|
27
28
|
### Text Filters (8 operations)
|
|
28
29
|
|
|
@@ -51,7 +52,21 @@ Supports **all AG Grid text and number filter operations** (17 total) with clean
|
|
|
51
52
|
| **Number** | Blank | `f_column_blank=true` | `f_bonus_blank=true` | Field is empty/null |
|
|
52
53
|
| **Number** | Not Blank | `f_column_notBlank=true` | `f_salary_notBlank=true` | Field has any numeric value |
|
|
53
54
|
|
|
54
|
-
|
|
55
|
+
### Date Filters (9 operations)
|
|
56
|
+
|
|
57
|
+
| Filter Type | Operation | URL Format | Example | Description |
|
|
58
|
+
| ----------- | --------------- | ------------------------------ | ------------------------------------------ | ----------------------------------------- |
|
|
59
|
+
| **Date** | Equals | `f_column_eq=YYYY-MM-DD` | `f_created_eq=2024-01-15` | Date equals value exactly |
|
|
60
|
+
| **Date** | Not Equal | `f_column_neq=YYYY-MM-DD` | `f_deadline_neq=2024-12-31` | Date does not equal value |
|
|
61
|
+
| **Date** | Before | `f_column_before=YYYY-MM-DD` | `f_deadline_before=2024-12-31` | Date is before value |
|
|
62
|
+
| **Date** | Before or Equal | `f_column_beforeEq=YYYY-MM-DD` | `f_archived_beforeEq=2024-12-31` | Date is before or equal to value |
|
|
63
|
+
| **Date** | After | `f_column_after=YYYY-MM-DD` | `f_created_after=2024-01-01` | Date is after value |
|
|
64
|
+
| **Date** | After or Equal | `f_column_afterEq=YYYY-MM-DD` | `f_updated_afterEq=2024-06-01` | Date is after or equal to value |
|
|
65
|
+
| **Date** | In Range | `f_column_daterange=start,end` | `f_period_daterange=2024-01-01,2024-12-31` | Date is between start and end (inclusive) |
|
|
66
|
+
| **Date** | Blank | `f_column_blank=true` | `f_deadline_blank=true` | Date field is empty/null |
|
|
67
|
+
| **Date** | Not Blank | `f_column_notBlank=true` | `f_created_notBlank=true` | Date field has any value |
|
|
68
|
+
|
|
69
|
+
> **🗓️ Date Format Note**: Date filters require strict ISO format (`YYYY-MM-DD`). All date values are validated for real calendar dates, including leap years and month boundaries. Invalid or non-ISO dates will be rejected.
|
|
55
70
|
|
|
56
71
|
### Filter Detection
|
|
57
72
|
|
|
@@ -61,9 +76,9 @@ The library automatically works with:
|
|
|
61
76
|
- **Number columns** configured with `filter: 'agNumberColumnFilter'`
|
|
62
77
|
- **Auto-detection** based on `cellDataType: 'number'` configuration
|
|
63
78
|
- Columns with `filter: true` (AG Grid's default text filter)
|
|
64
|
-
- Any column where users apply text or
|
|
65
|
-
- All AG Grid text and
|
|
66
|
-
- **Mixed filter types** - combine text and
|
|
79
|
+
- Any column where users apply text, number, or date-based filters
|
|
80
|
+
- All AG Grid text, number, and date filter operations through the filter menu
|
|
81
|
+
- **Mixed filter types** - combine text, number, and date filters in the same URL
|
|
67
82
|
|
|
68
83
|
### URL Examples
|
|
69
84
|
|
|
@@ -79,34 +94,40 @@ https://app.com/data?f_name_contains=john
|
|
|
79
94
|
https://app.com/data?f_salary_gt=75000
|
|
80
95
|
```
|
|
81
96
|
|
|
82
|
-
**
|
|
97
|
+
**Simple date filter:**
|
|
98
|
+
|
|
99
|
+
```
|
|
100
|
+
https://app.com/data?f_created_eq=2024-01-15
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
**Date range filter:**
|
|
83
104
|
|
|
84
105
|
```
|
|
85
|
-
https://app.com/data?
|
|
106
|
+
https://app.com/data?f_period_daterange=2024-01-01,2024-12-31
|
|
86
107
|
```
|
|
87
108
|
|
|
88
|
-
**
|
|
109
|
+
**Date before/after filter:**
|
|
89
110
|
|
|
90
111
|
```
|
|
91
|
-
https://app.com/data?
|
|
112
|
+
https://app.com/data?f_deadline_before=2024-12-31&f_created_after=2024-01-01
|
|
92
113
|
```
|
|
93
114
|
|
|
94
|
-
**
|
|
115
|
+
**Mixed text, number, and date filters:**
|
|
95
116
|
|
|
96
117
|
```
|
|
97
|
-
https://app.com/data?f_name_contains=john&
|
|
118
|
+
https://app.com/data?f_name_contains=john&f_department_eq=Engineering&f_salary_gte=80000&f_age_range=25,45&f_created_after=2024-01-01
|
|
98
119
|
```
|
|
99
120
|
|
|
100
|
-
**All
|
|
121
|
+
**All date operations:**
|
|
101
122
|
|
|
102
123
|
```
|
|
103
|
-
https://app.com/data?
|
|
124
|
+
https://app.com/data?f_created_eq=2024-01-15&f_deadline_neq=2024-12-31&f_start_after=2024-01-01&f_end_before=2024-12-31&f_updated_afterEq=2024-06-01&f_archived_beforeEq=2024-12-31&f_period_daterange=2024-01-01,2024-12-31&f_optional_blank=true&f_required_notBlank=true
|
|
104
125
|
```
|
|
105
126
|
|
|
106
|
-
**Blank operations (
|
|
127
|
+
**Blank operations (text, number, and date):**
|
|
107
128
|
|
|
108
129
|
```
|
|
109
|
-
https://app.com/data?f_comments_blank=true&f_bonus_blank=true&f_name_notBlank=true&f_salary_notBlank=true
|
|
130
|
+
https://app.com/data?f_comments_blank=true&f_bonus_blank=true&f_name_notBlank=true&f_salary_notBlank=true&f_deadline_blank=true&f_created_notBlank=true
|
|
110
131
|
```
|
|
111
132
|
|
|
112
133
|
## Installation
|
|
@@ -471,6 +492,7 @@ Parameter structure:
|
|
|
471
492
|
- Format: `f_{columnName}_{operation}={value}`
|
|
472
493
|
- **Text Operations**: `contains`, `eq`, `neq`, `startsWith`, `endsWith`, `notContains`, `blank`, `notBlank`
|
|
473
494
|
- **Number Operations**: `eq`, `neq`, `gt`, `gte`, `lt`, `lte`, `range`, `blank`, `notBlank`
|
|
495
|
+
- **Date Operations**: `eq`, `neq`, `before`, `beforeEq`, `after`, `afterEq`, `daterange`, `blank`, `notBlank`
|
|
474
496
|
- **Range Format**: `f_column_range=min,max` (comma-separated values)
|
|
475
497
|
- Standard URL encoding for special characters
|
|
476
498
|
- Supports column names with underscores (e.g., `user_id`, `salary_base`, `created_date`)
|
|
@@ -584,22 +606,23 @@ Comprehensive demonstration showcasing all features:
|
|
|
584
606
|
|
|
585
607
|
- **Complete text filter support** - All 8 AG Grid text operations (contains, equals, not contains, not equal, starts with, ends with, blank, not blank)
|
|
586
608
|
- **Complete number filter support** - All 9 AG Grid number operations (equals, not equal, greater than, greater than or equal, less than, less than or equal, in range, blank, not blank)
|
|
587
|
-
- **
|
|
609
|
+
- **Complete date filter support** - All 9 AG Grid date operations (equals, not equal, before, before or equal, after, after or equal, in range, blank, not blank)
|
|
610
|
+
- **Mixed filter scenarios** - Text, number, and date filters working together (Sales team + salary filters, Engineering + experience, Executive view with high salaries)
|
|
588
611
|
- **Number operation demos** - Dedicated buttons for salary ranges, age filtering, experience thresholds, and blank number fields
|
|
589
612
|
- **URL sharing workflow** - Copy to clipboard, email, and Slack integration
|
|
590
613
|
- **Performance monitoring** - Real-time benchmarks and stress testing with mixed filter types
|
|
591
|
-
- **Error handling** - Malformed URL and invalid filter testing for both text and
|
|
614
|
+
- **Error handling** - Malformed URL and invalid filter testing for both text, number, and date
|
|
592
615
|
- **Complete API showcase** - Generate URLs, apply filters, clear filters with comprehensive examples
|
|
593
616
|
|
|
594
617
|
### ⚛️ [React Integration](./examples/react-basic/basic-grid.tsx)
|
|
595
618
|
|
|
596
619
|
Clean React component showing the `useAGGridUrlSync` hook:
|
|
597
620
|
|
|
598
|
-
- React hook integration with AG Grid for text and
|
|
621
|
+
- React hook integration with AG Grid for text, number, and date filters
|
|
599
622
|
- Automatic filter state management for mixed filter types
|
|
600
623
|
- Share button with clipboard functionality
|
|
601
624
|
- Filter status indicators and controls
|
|
602
|
-
- Auto-apply filters on component mount with
|
|
625
|
+
- Auto-apply filters on component mount with all filter types
|
|
603
626
|
- Enhanced employee data with salary, age, and experience columns
|
|
604
627
|
- Full TypeScript support with comprehensive type coverage
|
|
605
628
|
|
|
@@ -609,9 +632,9 @@ Common data and column definitions used across examples:
|
|
|
609
632
|
|
|
610
633
|
- Enhanced employee data with salary, age, and experience number fields
|
|
611
634
|
- Project data with budget and numeric fields for comprehensive testing
|
|
612
|
-
- Column definitions with complete text and
|
|
613
|
-
- All 8 text filter operations and 9
|
|
614
|
-
- Realistic data ranges for demonstrating number filters (salaries $58K-$95K, ages 26-42, experience 3-15 years)
|
|
635
|
+
- Column definitions with complete text, number, and date filter support
|
|
636
|
+
- All 8 text filter operations, 9 number filter operations, and 9 date filter operations enabled
|
|
637
|
+
- Realistic data ranges for demonstrating number and date filters (salaries $58K-$95K, ages 26-42, experience 3-15 years)
|
|
615
638
|
- Includes null values for demonstrating blank/notBlank operations
|
|
616
639
|
|
|
617
640
|
All examples work out-of-the-box and demonstrate the complete functionality. The HTML demo can be opened directly in your browser, while the React example shows clean integration patterns.
|
|
@@ -3,7 +3,7 @@ import type { GridApi } from 'ag-grid-community';
|
|
|
3
3
|
/**
|
|
4
4
|
* Detects the expected filter type for a column based on AG Grid configuration
|
|
5
5
|
*/
|
|
6
|
-
export declare function detectColumnFilterType(gridApi: GridApi, columnId: string): 'text' | 'number' |
|
|
6
|
+
export declare function detectColumnFilterType(gridApi: GridApi, columnId: string): 'text' | 'number' | 'date';
|
|
7
7
|
/**
|
|
8
8
|
* Gets the current filter model from AG Grid
|
|
9
9
|
*/
|
|
@@ -1,4 +1,34 @@
|
|
|
1
|
-
import { AG_GRID_OPERATION_NAMES, REVERSE_AG_GRID_OPERATION_NAMES, TEXT_FILTER_OPERATIONS, NUMBER_FILTER_OPERATIONS } from './types.js';
|
|
1
|
+
import { AG_GRID_OPERATION_NAMES, REVERSE_AG_GRID_OPERATION_NAMES, TEXT_FILTER_OPERATIONS, NUMBER_FILTER_OPERATIONS, DATE_FILTER_OPERATIONS } from './types.js';
|
|
2
|
+
// Map AG Grid number operations to our internal number operations
|
|
3
|
+
// Since AG Grid uses generic names, we need to be explicit about number operations
|
|
4
|
+
const AG_GRID_TO_NUMBER_OPERATION_MAP = {
|
|
5
|
+
lessThan: 'lessThan',
|
|
6
|
+
lessThanOrEqual: 'lessThanOrEqual',
|
|
7
|
+
greaterThan: 'greaterThan',
|
|
8
|
+
greaterThanOrEqual: 'greaterThanOrEqual',
|
|
9
|
+
inRange: 'inRange',
|
|
10
|
+
equals: 'eq',
|
|
11
|
+
notEqual: 'notEqual',
|
|
12
|
+
blank: 'blank',
|
|
13
|
+
notBlank: 'notBlank'
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* Type guard to check if a value is a valid number operation key
|
|
17
|
+
*/
|
|
18
|
+
function isValidNumberOperation(operation) {
|
|
19
|
+
return Boolean(operation && operation in AG_GRID_TO_NUMBER_OPERATION_MAP);
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Converts a date string to ISO format (YYYY-MM-DD)
|
|
23
|
+
* Handles both date strings and undefined values
|
|
24
|
+
* Returns an empty string if the input is undefined or invalid
|
|
25
|
+
*/
|
|
26
|
+
function toIsoDateString(val) {
|
|
27
|
+
if (!val)
|
|
28
|
+
return '';
|
|
29
|
+
const match = val.match(/^(\d{4}-\d{2}-\d{2})/);
|
|
30
|
+
return match?.[1] ? match[1] : val || '';
|
|
31
|
+
}
|
|
2
32
|
/**
|
|
3
33
|
* Type predicate to check if an operation is a valid text filter operation
|
|
4
34
|
*/
|
|
@@ -11,6 +41,12 @@ function isTextFilterOperation(operation) {
|
|
|
11
41
|
function isNumberFilterOperation(operation) {
|
|
12
42
|
return NUMBER_FILTER_OPERATIONS.includes(operation);
|
|
13
43
|
}
|
|
44
|
+
/**
|
|
45
|
+
* Type predicate to check if an operation is a valid date filter operation
|
|
46
|
+
*/
|
|
47
|
+
function isDateFilterOperation(operation) {
|
|
48
|
+
return DATE_FILTER_OPERATIONS.includes(operation);
|
|
49
|
+
}
|
|
14
50
|
/**
|
|
15
51
|
* Detects the expected filter type for a column based on AG Grid configuration
|
|
16
52
|
*/
|
|
@@ -18,14 +54,18 @@ export function detectColumnFilterType(gridApi, columnId) {
|
|
|
18
54
|
try {
|
|
19
55
|
const column = gridApi.getColumn(columnId);
|
|
20
56
|
if (!column)
|
|
21
|
-
return
|
|
57
|
+
return 'text'; // Default to text for unknown columns
|
|
22
58
|
const colDef = column.getColDef();
|
|
23
59
|
// 1. Explicit filter configuration takes priority
|
|
60
|
+
if (colDef.filter === 'agDateColumnFilter')
|
|
61
|
+
return 'date';
|
|
24
62
|
if (colDef.filter === 'agNumberColumnFilter')
|
|
25
63
|
return 'number';
|
|
26
64
|
if (colDef.filter === 'agTextColumnFilter')
|
|
27
65
|
return 'text';
|
|
28
66
|
// 2. Cell data type configuration
|
|
67
|
+
if (colDef.cellDataType === 'date')
|
|
68
|
+
return 'date';
|
|
29
69
|
if (colDef.cellDataType === 'number')
|
|
30
70
|
return 'number';
|
|
31
71
|
if (colDef.cellDataType === 'text')
|
|
@@ -50,8 +90,8 @@ export function getFilterModel(config) {
|
|
|
50
90
|
for (const [column, filter] of Object.entries(model)) {
|
|
51
91
|
if (!filter || typeof filter !== 'object')
|
|
52
92
|
continue;
|
|
53
|
-
const { filterType, type, filter: value, filterTo } = filter;
|
|
54
|
-
// Handle
|
|
93
|
+
const { filterType, type, filter: value, filterTo, dateFrom, dateTo } = filter;
|
|
94
|
+
// Handle text filters
|
|
55
95
|
if (filterType === 'text') {
|
|
56
96
|
// Map AG Grid operations back to our internal operations using centralized mapping
|
|
57
97
|
const internalOperation = REVERSE_AG_GRID_OPERATION_NAMES[type];
|
|
@@ -60,19 +100,38 @@ export function getFilterModel(config) {
|
|
|
60
100
|
filterState[column] = {
|
|
61
101
|
filterType: 'text',
|
|
62
102
|
type: internalOperation, // Now properly typed as TextFilterOperation
|
|
63
|
-
filter: value || ''
|
|
103
|
+
filter: String(value || '')
|
|
64
104
|
};
|
|
65
105
|
}
|
|
66
106
|
}
|
|
107
|
+
// Handle number filters
|
|
67
108
|
else if (filterType === 'number') {
|
|
68
|
-
//
|
|
69
|
-
|
|
109
|
+
// For number filters, we need to handle the mapping carefully since
|
|
110
|
+
// AG Grid uses the same operation names for numbers and dates
|
|
111
|
+
// Use the explicit number mapping instead of the reverse AG Grid mapping
|
|
112
|
+
const internalOperation = isValidNumberOperation(type)
|
|
113
|
+
? AG_GRID_TO_NUMBER_OPERATION_MAP[type]
|
|
114
|
+
: null;
|
|
115
|
+
// If the operation type is not recognized, report the error
|
|
116
|
+
if (!internalOperation) {
|
|
117
|
+
if (config.onParseError) {
|
|
118
|
+
config.onParseError(new Error(`Unknown number filter operation '${type}' for column '${column}'. ` +
|
|
119
|
+
`Supported operations: ${Object.keys(AG_GRID_TO_NUMBER_OPERATION_MAP).join(', ')}`));
|
|
120
|
+
}
|
|
121
|
+
continue;
|
|
122
|
+
}
|
|
70
123
|
// Use type predicate to validate and narrow the type
|
|
71
124
|
if (internalOperation && isNumberFilterOperation(internalOperation)) {
|
|
125
|
+
// Validate that the filter value is actually a number
|
|
126
|
+
const numericValue = typeof value === 'number' ? value : Number(value);
|
|
127
|
+
// Skip invalid number filters
|
|
128
|
+
if (isNaN(numericValue)) {
|
|
129
|
+
continue;
|
|
130
|
+
}
|
|
72
131
|
const numberFilter = {
|
|
73
132
|
filterType: 'number',
|
|
74
133
|
type: internalOperation, // Now properly typed as NumberFilterOperation
|
|
75
|
-
filter:
|
|
134
|
+
filter: numericValue
|
|
76
135
|
};
|
|
77
136
|
// Handle range operations
|
|
78
137
|
if (internalOperation === 'inRange' && typeof filterTo === 'number') {
|
|
@@ -82,6 +141,39 @@ export function getFilterModel(config) {
|
|
|
82
141
|
filterState[column] = numberFilter;
|
|
83
142
|
}
|
|
84
143
|
}
|
|
144
|
+
// Handle date filters
|
|
145
|
+
else if (filterType === 'date') {
|
|
146
|
+
// Map AG Grid date operations back to our internal operations
|
|
147
|
+
const internalOperation = REVERSE_AG_GRID_OPERATION_NAMES[type];
|
|
148
|
+
// For date operations, we need to handle the special case where AG Grid uses
|
|
149
|
+
// generic operation names but we have date-specific internal names
|
|
150
|
+
let mappedOperation = internalOperation;
|
|
151
|
+
// Map AG Grid generic date operations to our date-specific operations
|
|
152
|
+
const AG_GRID_TO_DATE_OPERATION_MAP = {
|
|
153
|
+
lessThan: 'dateBefore',
|
|
154
|
+
lessThanOrEqual: 'dateBeforeOrEqual',
|
|
155
|
+
greaterThan: 'dateAfter',
|
|
156
|
+
greaterThanOrEqual: 'dateAfterOrEqual',
|
|
157
|
+
inRange: 'dateRange'
|
|
158
|
+
};
|
|
159
|
+
mappedOperation = type
|
|
160
|
+
? AG_GRID_TO_DATE_OPERATION_MAP[type] || internalOperation
|
|
161
|
+
: internalOperation;
|
|
162
|
+
// Use type predicate to validate and narrow the type
|
|
163
|
+
if (mappedOperation && isDateFilterOperation(mappedOperation)) {
|
|
164
|
+
const dateFilter = {
|
|
165
|
+
filterType: 'date',
|
|
166
|
+
type: mappedOperation,
|
|
167
|
+
filter: toIsoDateString(dateFrom || String(value || ''))
|
|
168
|
+
};
|
|
169
|
+
// Handle date range operations (AG Grid uses dateFrom/dateTo)
|
|
170
|
+
if (mappedOperation === 'dateRange' && dateTo) {
|
|
171
|
+
;
|
|
172
|
+
dateFilter.filterTo = toIsoDateString(dateTo);
|
|
173
|
+
}
|
|
174
|
+
filterState[column] = dateFilter;
|
|
175
|
+
}
|
|
176
|
+
}
|
|
85
177
|
}
|
|
86
178
|
return filterState;
|
|
87
179
|
}
|
|
@@ -96,6 +188,41 @@ export function getFilterModel(config) {
|
|
|
96
188
|
* Converts internal filter to AG Grid filter format
|
|
97
189
|
*/
|
|
98
190
|
function convertToAGGridFilter(filter) {
|
|
191
|
+
if (filter.filterType === 'date') {
|
|
192
|
+
// Handle date range operations
|
|
193
|
+
if (filter.type === 'dateRange') {
|
|
194
|
+
return {
|
|
195
|
+
filterType: 'date',
|
|
196
|
+
type: 'inRange', // AG Grid uses 'inRange' for date ranges
|
|
197
|
+
dateFrom: filter.filter,
|
|
198
|
+
dateTo: filter.filterTo || null
|
|
199
|
+
};
|
|
200
|
+
}
|
|
201
|
+
// Handle blank operations for dates
|
|
202
|
+
if (filter.type === 'blank' || filter.type === 'notBlank') {
|
|
203
|
+
return {
|
|
204
|
+
filterType: 'date',
|
|
205
|
+
type: filter.type,
|
|
206
|
+
dateFrom: null,
|
|
207
|
+
dateTo: null
|
|
208
|
+
};
|
|
209
|
+
}
|
|
210
|
+
// Map date-specific operations to AG Grid generic operations
|
|
211
|
+
const dateOperationMapping = {
|
|
212
|
+
dateBefore: 'lessThan',
|
|
213
|
+
dateBeforeOrEqual: 'lessThanOrEqual',
|
|
214
|
+
dateAfter: 'greaterThan',
|
|
215
|
+
dateAfterOrEqual: 'greaterThanOrEqual'
|
|
216
|
+
};
|
|
217
|
+
const agOperation = dateOperationMapping[filter.type] ||
|
|
218
|
+
AG_GRID_OPERATION_NAMES[filter.type];
|
|
219
|
+
return {
|
|
220
|
+
filterType: 'date',
|
|
221
|
+
type: agOperation,
|
|
222
|
+
dateFrom: filter.filter,
|
|
223
|
+
dateTo: null
|
|
224
|
+
};
|
|
225
|
+
}
|
|
99
226
|
if (filter.filterType === 'number') {
|
|
100
227
|
const agGridOperation = AG_GRID_OPERATION_NAMES[filter.type];
|
|
101
228
|
if (filter.type === 'inRange') {
|
|
@@ -135,8 +262,12 @@ export function applyFilterModel(filterState, config) {
|
|
|
135
262
|
// Detect expected filter type for this column
|
|
136
263
|
const expectedType = detectColumnFilterType(config.gridApi, column);
|
|
137
264
|
// Validate filter type compatibility
|
|
265
|
+
if (filter.filterType === 'date' && expectedType !== 'date') {
|
|
266
|
+
console.warn(`Column '${column}' expects a ${expectedType} filter but received a date filter. This may indicate a configuration mismatch in the column definition or filter application.`);
|
|
267
|
+
continue;
|
|
268
|
+
}
|
|
138
269
|
if (filter.filterType === 'number' && expectedType !== 'number') {
|
|
139
|
-
console.warn(`Column '${column}' expects a
|
|
270
|
+
console.warn(`Column '${column}' expects a ${expectedType} filter but received a number filter. This may indicate a configuration mismatch in the column definition or filter application.`);
|
|
140
271
|
continue;
|
|
141
272
|
}
|
|
142
273
|
// Convert to AG Grid filter model
|
|
@@ -145,6 +276,7 @@ export function applyFilterModel(filterState, config) {
|
|
|
145
276
|
model[column] = agGridFilter;
|
|
146
277
|
}
|
|
147
278
|
}
|
|
279
|
+
// Apply the filter model to AG Grid
|
|
148
280
|
config.gridApi.setFilterModel(model);
|
|
149
281
|
}
|
|
150
282
|
catch (error) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"grid-integration.js","sourceRoot":"","sources":["../../src/core/grid-integration.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"grid-integration.js","sourceRoot":"","sources":["../../src/core/grid-integration.ts"],"names":[],"mappings":"AAYA,OAAO,EACL,uBAAuB,EACvB,+BAA+B,EAC/B,sBAAsB,EACtB,wBAAwB,EACxB,sBAAsB,EACvB,MAAM,YAAY,CAAA;AAGnB,kEAAkE;AAClE,mFAAmF;AACnF,MAAM,+BAA+B,GAAG;IACtC,QAAQ,EAAE,UAAU;IACpB,eAAe,EAAE,iBAAiB;IAClC,WAAW,EAAE,aAAa;IAC1B,kBAAkB,EAAE,oBAAoB;IACxC,OAAO,EAAE,SAAS;IAClB,MAAM,EAAE,IAAI;IACZ,QAAQ,EAAE,UAAU;IACpB,KAAK,EAAE,OAAO;IACd,QAAQ,EAAE,UAAU;CAC8B,CAAA;AAEpD;;GAEG;AACH,SAAS,sBAAsB,CAC7B,SAA6B;IAE7B,OAAO,OAAO,CAAC,SAAS,IAAI,SAAS,IAAI,+BAA+B,CAAC,CAAA;AAC3E,CAAC;AAED;;;;GAIG;AACH,SAAS,eAAe,CAAC,GAAuB;IAC9C,IAAI,CAAC,GAAG;QAAE,OAAO,EAAE,CAAA;IACnB,MAAM,KAAK,GAAG,GAAG,CAAC,KAAK,CAAC,sBAAsB,CAAC,CAAA;IAC/C,OAAO,KAAK,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,IAAI,EAAE,CAAA;AAC1C,CAAC;AAED;;GAEG;AACH,SAAS,qBAAqB,CAC5B,SAA0B;IAE1B,OAAO,sBAAsB,CAAC,QAAQ,CAAC,SAAgC,CAAC,CAAA;AAC1E,CAAC;AAED;;GAEG;AACH,SAAS,uBAAuB,CAC9B,SAA0B;IAE1B,OAAO,wBAAwB,CAAC,QAA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