@cdmx/wappler_ag_grid 1.2.2 → 1.2.3
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/dmx-ag-grid.js +26 -3
- package/package.json +1 -1
package/dmx-ag-grid.js
CHANGED
|
@@ -476,9 +476,8 @@ dmx.Component('ag-grid', {
|
|
|
476
476
|
container.appendChild(button);
|
|
477
477
|
// Check if the button should be hidden based on the condition string and row data
|
|
478
478
|
if (buttonConfig.condition) {
|
|
479
|
-
const
|
|
480
|
-
|
|
481
|
-
const isConditionMet = params.data.hasOwnProperty(left) && evaluateCondition(params.data[left], operator, right);
|
|
479
|
+
const conditions = buttonConfig.condition.split(/(\|\||&&)/);
|
|
480
|
+
const isConditionMet = evaluateConditions(conditions, params);
|
|
482
481
|
if (!isConditionMet) {
|
|
483
482
|
button.style.setProperty('display', 'none', 'important');
|
|
484
483
|
}
|
|
@@ -555,6 +554,30 @@ dmx.Component('ag-grid', {
|
|
|
555
554
|
|
|
556
555
|
return [left, operator, right];
|
|
557
556
|
}
|
|
557
|
+
function evaluateConditions(conditions, params) {
|
|
558
|
+
let results = [];
|
|
559
|
+
let operators = [];
|
|
560
|
+
for (let i = 0; i < conditions.length; i++) {
|
|
561
|
+
const part = conditions[i].trim();
|
|
562
|
+
if (part === '||' || part === '&&') {
|
|
563
|
+
operators.push(part);
|
|
564
|
+
} else {
|
|
565
|
+
const [left, operator, right] = extractConditionParts(part);
|
|
566
|
+
const result = evaluateCondition(params.data[left], operator, right);
|
|
567
|
+
results.push(result);
|
|
568
|
+
}
|
|
569
|
+
}
|
|
570
|
+
let finalResult = results[0];
|
|
571
|
+
|
|
572
|
+
for (let i = 0; i < operators.length; i++) {
|
|
573
|
+
if (operators[i] === '||') {
|
|
574
|
+
finalResult = finalResult || results[i + 1];
|
|
575
|
+
} else if (operators[i] === '&&') {
|
|
576
|
+
finalResult = finalResult && results[i + 1];
|
|
577
|
+
}
|
|
578
|
+
}
|
|
579
|
+
return finalResult;
|
|
580
|
+
}
|
|
558
581
|
|
|
559
582
|
function evaluateCondition(left, operator, right) {
|
|
560
583
|
switch (operator) {
|