@cdmx/wappler_ag_grid 1.9.7 → 1.9.8

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 CHANGED
@@ -423,7 +423,14 @@ Specify the condition to Show the Button[i] Action button, eg: code==TEST, or st
423
423
 
424
424
  # Button Class Toggles
425
425
  The Button Class Toggles feature provides a way to define and manage classes for action buttons within a grid, based on certain data conditions. This can be useful for dynamically updating button styles based on the state of the row data.
426
- Specify the condition to apply the defined class on the Action button, eg: code==TEST, or status==COMPLETED||status==FINISHED or status==COMPLETED&&user_status==true
426
+ Specify the condition to apply the defined class on the Action button,
427
+ eg: code==TEST, or status==COMPLETED||status==FINISHED or status==COMPLETED&&user_status==true
428
+ You can also specify left-only conditions, where only the field name is provided. The field is then evaluated for its truthiness ie if value present/true(bool) eg: status
429
+
430
+ # Button Icon Class Toggles
431
+ The Icon Class Toggles feature works similarly to Button Class Toggles but is used to apply classes to icons in the action buttons based on conditions in the row data. This allows you to dynamically update the icons
432
+ eg: code==TEST, or status==COMPLETED||status==FINISHED or status==COMPLETED&&user_status==true
433
+ You can also specify left-only conditions, where only the field name is provided. The field is then evaluated for its truthiness ie if value present/true(bool) eg: status
427
434
 
428
435
  # Action Attributes
429
436
 
@@ -2930,7 +2930,7 @@
2930
2930
  "type": "boolean",
2931
2931
  "defaultValue": false,
2932
2932
  "display": "fieldset",
2933
- "show": ["actionBtnsClassToggles"],
2933
+ "show": ["actionBtnsClassToggles","actionBtnsIconClassToggles"],
2934
2934
  "noChangeOnHide": true,
2935
2935
  "groupEnabler": true,
2936
2936
  "children": [
@@ -2997,11 +2997,75 @@
2997
2997
  "class": "",
2998
2998
  "condition": ""
2999
2999
  }
3000
+ },
3001
+ {
3002
+ "name": "actionBtnsIconClassToggles",
3003
+ "attribute": "dmx-bind:action_button_icon_class_toggles",
3004
+ "title": "Buttons Icon Classes",
3005
+ "type": "grid",
3006
+ "jsonFormat": true,
3007
+ "dataBindings": true,
3008
+ "encloseBT": true,
3009
+ "jsonBT": true,
3010
+ "initDisplay": "none",
3011
+ "columns": [
3012
+ {
3013
+ "field": "btn_id",
3014
+ "caption": "Button",
3015
+ "editable": {
3016
+ "type": "list",
3017
+ "items": [
3018
+ {"id": "edit", "text": "Edit"},
3019
+ {"id": "view", "text": "View"},
3020
+ {"id": "delete", "text": "Delete"},
3021
+ {"id": "button1", "text": "Button 1"},
3022
+ {"id": "button2", "text": "Button 2"},
3023
+ {"id": "button3", "text": "Button 3"},
3024
+ {"id": "button4", "text": "Button 4"},
3025
+ {"id": "button5", "text": "Button 5"},
3026
+ {"id": "button6", "text": "Button 6"},
3027
+ {"id": "button7", "text": "Button 7"},
3028
+ {"id": "button8", "text": "Button 8"},
3029
+ {"id": "button9", "text": "Button 9"},
3030
+ {"id": "button10", "text": "Button 10"},
3031
+ {"id": "button11", "text": "Button 11"},
3032
+ {"id": "button12", "text": "Button 12"},
3033
+ {"id": "button13", "text": "Button 13"},
3034
+ {"id": "button14", "text": "Button 14"},
3035
+ {"id": "button15", "text": "Button 15"},
3036
+ {"id": "button16", "text": "Button 16"},
3037
+ {"id": "button17", "text": "Button 17"},
3038
+ {"id": "button18", "text": "Button 18"},
3039
+ {"id": "button19", "text": "Button 19"},
3040
+ {"id": "button20", "text": "Button 20"}
3041
+ ]
3042
+ }
3043
+ },
3044
+ {
3045
+ "field": "class",
3046
+ "caption": "Class",
3047
+ "editable": {
3048
+ "type": "text"
3049
+ }
3050
+ },
3051
+ {
3052
+ "field": "condition",
3053
+ "caption": "Condition",
3054
+ "editable": {
3055
+ "type": "text"
3056
+ }
3057
+ }
3058
+ ],
3059
+ "newRecord": {
3060
+ "btn_id": "",
3061
+ "class": "",
3062
+ "condition": ""
3063
+ }
3000
3064
  }
3001
3065
  ]
3002
3066
  }
3003
- ]
3004
- }
3067
+ ]
3068
+ }
3005
3069
 
3006
3070
  ],
3007
3071
  actionsScheme: [
package/dmx-ag-grid.js CHANGED
@@ -62,7 +62,6 @@ dmx.Component('ag-grid', {
62
62
  suppress_agg_at_root_level: { type: Boolean, default: false },
63
63
  suppress_clipboard_paste: { type: Boolean, default: false },
64
64
  suppress_scroll_on_new_data: { type: Boolean, default: false },
65
- suppress_property_names_check: { type: Boolean, default: false },
66
65
  hide_id_field: { type: Boolean, default: false },
67
66
  numeric_column_align: { type: Boolean, default: false },
68
67
  enable_rtl: { type: Boolean, default: false },
@@ -128,6 +127,7 @@ dmx.Component('ag-grid', {
128
127
  delete_action_btn_condition: {type: String, default: null },
129
128
  enable_custom_action_btns: { type: Boolean, default: false },
130
129
  action_button_class_toggles: { type: Array, default: [] },
130
+ action_button_icon_class_toggles: { type: Array, default: [] },
131
131
  button1_action_btn: { type: "Boolean", default: false },
132
132
  button1_action_title: { type: "String", default: "" },
133
133
  button1_action_tooltip: { type: "String", default: "" },
@@ -474,6 +474,7 @@ dmx.Component('ag-grid', {
474
474
  const enableCellClickEvent = this.props.row_click_event && (this.props.enable_actions || this.props.row_checkbox_event);
475
475
  const enableCellDoubleClickEvent = this.props.row_double_click_event && (this.props.enable_actions || this.props.row_checkbox_event);
476
476
  const actionButtonClassToggles = options.action_button_class_toggles
477
+ const actionButtonIconClassToggles = options.action_button_icon_class_toggles
477
478
  let localeText;
478
479
  let columnDefs = [];
479
480
  let groupedColumnDefs = [];
@@ -621,10 +622,19 @@ dmx.Component('ag-grid', {
621
622
  button.innerHTML = `<i class="${buttonConfig.icon}"></i> ${buttonConfig.action}`;
622
623
  container.appendChild(button);
623
624
  // Handle dynamic classes based on conditions and buttonConfig.id
625
+
624
626
  actionButtonClassToggles.forEach((toggle) => {
625
- if (toggle.btn_id === buttonConfig.id && evaluateConditions([toggle.condition], params)) {
627
+ if (toggle.btn_id.toLowerCase() === buttonConfig.id && evaluateConditions([toggle.condition], params)) {
626
628
  button.classList.add(...toggle.class.split(' '));
627
629
  }
630
+ });
631
+ actionButtonIconClassToggles.forEach((iconToggle) => {
632
+ if (iconToggle.btn_id.toLowerCase() === buttonConfig.id && evaluateConditions([iconToggle.condition], params)) {
633
+ const iconElement = button.querySelector('i');
634
+ if (iconElement) {
635
+ iconElement.classList.add(...iconToggle.class.split(' '));
636
+ }
637
+ }
628
638
  });
629
639
  // Check if the button should be hidden based on the condition string and row data
630
640
  if (buttonConfig.condition) {
@@ -714,22 +724,29 @@ dmx.Component('ag-grid', {
714
724
  if (part === '||' || part === '&&') {
715
725
  operators.push(part);
716
726
  } else {
717
- const [left, operator, right] = extractConditionParts(part);
718
- const result = params.data[left] !== null ? evaluateCondition(params.data[left], operator, right) : false;
719
- results.push(result);
727
+ const hasOperator = /(==|!=|<=|>=|<|>)/.test(part);
728
+ if (!hasOperator) {
729
+ const left = part;
730
+ const result = params.data[left] !== null && params.data[left] !== undefined && params.data[left] !== "";
731
+ results.push(result);
732
+ } else {
733
+ const [left, operator, right] = extractConditionParts(part);
734
+ const result = params.data[left] !== null ? evaluateCondition(params.data[left], operator, right) : false;
735
+ results.push(result);
736
+ }
720
737
  }
721
738
  }
722
739
  let finalResult = results[0];
723
-
740
+
724
741
  for (let i = 0; i < operators.length; i++) {
725
- if (operators[i] === '||') {
726
- finalResult = finalResult || results[i + 1];
727
- } else if (operators[i] === '&&') {
728
- finalResult = finalResult && results[i + 1];
729
- }
730
- }
742
+ if (operators[i] === '||') {
743
+ finalResult = finalResult || results[i + 1];
744
+ } else if (operators[i] === '&&') {
745
+ finalResult = finalResult && results[i + 1];
746
+ }
747
+ }
731
748
  return finalResult;
732
- }
749
+ }
733
750
 
734
751
  function evaluateCondition(left, operator, right) {
735
752
  switch (operator) {
@@ -1585,7 +1602,6 @@ dmx.Component('ag-grid', {
1585
1602
  suppressAggFuncInHeader: this.props.suppress_agg_func_in_header,
1586
1603
  suppressClipboardPaste: this.props.suppress_clipboard_paste,
1587
1604
  suppressScrollOnNewData: this.props.suppress_scroll_on_new_data,
1588
- suppressPropertyNamesCheck: this.props.suppress_property_names_check,
1589
1605
  columnHoverHighlight: this.props.column_hover_highlight,
1590
1606
  onFilterModified: function (params) {
1591
1607
  const columnApi = params.api;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cdmx/wappler_ag_grid",
3
- "version": "1.9.7",
3
+ "version": "1.9.8",
4
4
  "type": "module",
5
5
  "description": "App Connect module for AG Grid Table Generation.",
6
6
  "license": "MIT",