@cdmx/wappler_ag_grid 2.1.3 → 2.1.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/.claude/settings.json +7 -0
- package/CHANGELOG.md +23 -1
- package/app_connect/components.hjson +6 -5
- package/dmx-ag-grid.js +37 -12
- package/package.json +2 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,4 +1,26 @@
|
|
|
1
|
-
# Change Log
|
|
1
|
+
# Change Log
|
|
2
|
+
|
|
3
|
+
## Version 2.1.4 (Row Color Formatting Fix)
|
|
4
|
+
|
|
5
|
+
### Summary
|
|
6
|
+
Fixed row color styling (`rstyles`) so it works dynamically, supports multiple colors for the
|
|
7
|
+
same field, and can color rows directly by field value.
|
|
8
|
+
|
|
9
|
+
### Changes Made
|
|
10
|
+
1. **`app_connect/components.hjson`** - removed `"key": "field"` from the "Configure Row Colors"
|
|
11
|
+
grid so it serializes as an array (unlimited rows per field). Renamed the `condition` column to
|
|
12
|
+
"Condition" and documented the supported syntax.
|
|
13
|
+
2. **`dmx-ag-grid.js`** - changed the `rstyles` prop default from `{}` to `[]`, and rewrote
|
|
14
|
+
`createRowStyleFunction` to mirror the cell-style path: it normalizes both array and legacy
|
|
15
|
+
object input (backward compatible), and evaluates value/operator expressions
|
|
16
|
+
(`status == active`, `amount > 1000`, compound `&&`/`||`), function conditions (`myFn()`), and a
|
|
17
|
+
Field + plain-value exact-match shorthand. First matching condition wins.
|
|
18
|
+
3. **`dmx-ag-grid.js`** - fixed operator parsing in `extractConditionParts` so `>=` and `<=`
|
|
19
|
+
are no longer mis-parsed as `>`/`<` (this also fixes `>=`/`<=` conditions in cell styles).
|
|
20
|
+
Function conditions require trailing `()` so plain shorthand values (e.g. status `open`)
|
|
21
|
+
cannot collide with `window` built-ins like `window.open`.
|
|
22
|
+
|
|
23
|
+
---
|
|
2
24
|
|
|
3
25
|
## Version 2.0.15 (HTML Export Removal Added)
|
|
4
26
|
|
|
@@ -808,14 +808,13 @@
|
|
|
808
808
|
],
|
|
809
809
|
"noChangeOnHide": true,
|
|
810
810
|
"groupEnabler": true,
|
|
811
|
-
"help": "Add
|
|
811
|
+
"help": "Color whole rows by condition. Add one row per color - the same field can have many. Condition supports value/operator expressions (e.g. status == active, amount > 1000, status == open && amount > 100), a function name returning a boolean (e.g. myFn()), or - as a shorthand - a Field plus a plain value for an exact match. Values are unquoted."
|
|
812
812
|
"children": [
|
|
813
813
|
{
|
|
814
814
|
"name": "listRowColors",
|
|
815
815
|
"attribute": "dmx-bind:rstyles",
|
|
816
816
|
"title": "Row Colors",
|
|
817
817
|
"type": "grid",
|
|
818
|
-
"key": "field",
|
|
819
818
|
"dataBindings": true,
|
|
820
819
|
"jsonFormat": true,
|
|
821
820
|
"encloseBT": true,
|
|
@@ -827,14 +826,16 @@
|
|
|
827
826
|
"caption": "Field",
|
|
828
827
|
"editable": {
|
|
829
828
|
"type": "text"
|
|
830
|
-
}
|
|
829
|
+
},
|
|
830
|
+
help: "Optional. Used with the shorthand (Field + plain value in Condition) for an exact match."
|
|
831
831
|
},
|
|
832
832
|
{
|
|
833
833
|
"field": "condition",
|
|
834
|
-
"caption": "
|
|
834
|
+
"caption": "Condition",
|
|
835
835
|
"editable": {
|
|
836
836
|
"type": "text"
|
|
837
|
-
}
|
|
837
|
+
},
|
|
838
|
+
help: "Expression (status == active, amount > 1000, a && b), function name with trailing parentheses (myFn() - the () are required), or a plain value matched against Field. Values are unquoted."
|
|
838
839
|
},
|
|
839
840
|
{
|
|
840
841
|
"field": "customColor",
|
package/dmx-ag-grid.js
CHANGED
|
@@ -24,7 +24,7 @@ dmx.Component('ag-grid', {
|
|
|
24
24
|
tooltip_config: { type: Array, default: [] },
|
|
25
25
|
custom_tooltip: { type: String, default: null },
|
|
26
26
|
cstyles: { type: Array, default: [] },
|
|
27
|
-
rstyles: { type: Array, default:
|
|
27
|
+
rstyles: { type: Array, default: [] },
|
|
28
28
|
cnames: { type: Object, default: {} },
|
|
29
29
|
cwidths: { type: Object, default: {} },
|
|
30
30
|
ctypes: { type: Array, default: [] },
|
|
@@ -850,7 +850,8 @@ dmx.Component('ag-grid', {
|
|
|
850
850
|
|
|
851
851
|
function extractConditionParts(condition) {
|
|
852
852
|
|
|
853
|
-
|
|
853
|
+
// Multi-char operators must be checked before '>' / '<' so '>=' and '<=' parse correctly
|
|
854
|
+
const operators = ['===', '==', '!=', '>=', '<=', '>', '<'];
|
|
854
855
|
let operator;
|
|
855
856
|
let left;
|
|
856
857
|
let right;
|
|
@@ -1065,27 +1066,51 @@ dmx.Component('ag-grid', {
|
|
|
1065
1066
|
//Custom Row Styles
|
|
1066
1067
|
function createRowStyleFunction(rstyles) {
|
|
1067
1068
|
return function(params) {
|
|
1068
|
-
|
|
1069
|
+
// Accept both the array form (current) and the legacy object-keyed-by-field form
|
|
1070
|
+
const styles = Array.isArray(rstyles)
|
|
1071
|
+
? rstyles
|
|
1072
|
+
: (rstyles && typeof rstyles === 'object' ? Object.values(rstyles) : []);
|
|
1073
|
+
if (styles.length === 0) {
|
|
1069
1074
|
return; // No styles to apply
|
|
1070
1075
|
}
|
|
1071
|
-
const
|
|
1072
|
-
|
|
1073
|
-
const condition = style.condition
|
|
1076
|
+
for (const style of styles) {
|
|
1077
|
+
if (!style || !style.customColor) continue;
|
|
1078
|
+
const condition = (style.condition || '').toString().trim();
|
|
1079
|
+
const field = style.field;
|
|
1074
1080
|
const customColor = style.customColor;
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1081
|
+
if (condition === '') continue;
|
|
1082
|
+
let conditionResult = false;
|
|
1083
|
+
|
|
1084
|
+
if (condition.endsWith('()') && typeof window[condition.replace(/\(\)$/, '')] === 'function') {
|
|
1085
|
+
// Function-based condition: receives row data, must return a boolean
|
|
1086
|
+
const result = window[condition.replace(/\(\)$/, '')](params.data);
|
|
1078
1087
|
if (typeof result !== 'boolean') {
|
|
1079
1088
|
console.error('Row condition function must return a boolean value.');
|
|
1080
|
-
|
|
1089
|
+
continue;
|
|
1081
1090
|
}
|
|
1082
1091
|
conditionResult = result;
|
|
1092
|
+
} else if (/(===|==|!=|>=|<=|>|<)/.test(condition)) {
|
|
1093
|
+
// Value/operator expression, with support for compound && / ||
|
|
1094
|
+
if (/&&|\|\|/.test(condition)) {
|
|
1095
|
+
const tokens = condition.split(/\s*(&&|\|\|)\s*/).filter(t => t !== '');
|
|
1096
|
+
conditionResult = evaluateConditions(tokens, params);
|
|
1097
|
+
} else {
|
|
1098
|
+
const [left, operator, right] = extractConditionParts(condition);
|
|
1099
|
+
conditionResult = params.data.hasOwnProperty(left) &&
|
|
1100
|
+
(params.data[left] !== null ? evaluateCondition(params.data[left], operator, right) : false);
|
|
1101
|
+
}
|
|
1102
|
+
} else if (field) {
|
|
1103
|
+
// Shorthand: Field + plain value => exact match on that field's value
|
|
1104
|
+
conditionResult = params.data.hasOwnProperty(field) &&
|
|
1105
|
+
params.data[field] !== null &&
|
|
1106
|
+
String(params.data[field]) === condition;
|
|
1083
1107
|
}
|
|
1108
|
+
|
|
1084
1109
|
if (conditionResult) {
|
|
1085
|
-
|
|
1110
|
+
return { background: customColor }; // first match wins
|
|
1086
1111
|
}
|
|
1087
1112
|
}
|
|
1088
|
-
return
|
|
1113
|
+
return; // no condition matched
|
|
1089
1114
|
};
|
|
1090
1115
|
}
|
|
1091
1116
|
dateFilterParams = {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cdmx/wappler_ag_grid",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.4",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "App Connect module for AG Grid v35 - Advanced data grid with enhanced editing, filtering, and tree data capabilities.",
|
|
6
6
|
"license": "MIT",
|
|
@@ -26,3 +26,4 @@
|
|
|
26
26
|
"publish-dry-run": "npm publish ./dist --access public --dry-run"
|
|
27
27
|
}
|
|
28
28
|
}
|
|
29
|
+
|