@cdmx/wappler_ag_grid 0.4.2 → 0.4.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.
@@ -258,7 +258,7 @@
258
258
  "attribute": "date_format",
259
259
  "title": "Date Format",
260
260
  "type": "text",
261
- "defaultValue": "dd/MM/yyyy HH:mm A",
261
+ "defaultValue": "dd/MM/yyyy hh:mm A",
262
262
  "help": "Date Format"
263
263
  },
264
264
  {
@@ -503,7 +503,7 @@
503
503
  "variables": [
504
504
  {
505
505
  "name": "cstyles",
506
- "title": "Configure Colors",
506
+ "title": "Configure Colors and Fonts",
507
507
  "attributeStartsWith": "dmx-bind",
508
508
  "attribute": "cstyles",
509
509
  "type": "boolean",
@@ -551,14 +551,39 @@
551
551
  "type": "text"
552
552
  },
553
553
  help: "Example: '#FF0000' or 'red'"
554
+ },
555
+ {
556
+ "field": "area",
557
+ "caption": "Area",
558
+ "size": "20%",
559
+ "editable": {
560
+ "type": "list",
561
+ "items": [
562
+ {id: 'text', text: 'text'},
563
+ {id: 'cell', text: 'cell'}
564
+ ]
565
+ }
566
+ },
567
+ {
568
+ "field": "font",
569
+ "caption": "Font",
570
+ "size": "20%",
571
+ "editable": {
572
+ "type": "list",
573
+ "items": [
574
+ {id: 'normal', text: 'normal'},
575
+ {id: 'italic', text: 'italic'},
576
+ {id: 'bold', text: 'bold'}
577
+ ]
578
+ }
554
579
  }
555
580
  ],
556
581
  "newRecord": {
557
- "name": "",
558
- "value": "",
559
582
  "field": "",
560
583
  "condition": "",
561
- "customColor": ""
584
+ "customColor": "",
585
+ "area": "text",
586
+ "font": "normal"
562
587
  }
563
588
  }
564
589
  ]
package/dmx-ag-grid.js CHANGED
@@ -39,7 +39,7 @@ dmx.Component('ag-grid', {
39
39
  enable_rtl: { type: Boolean, default: false },
40
40
  locale_text: { type: String, default: null },
41
41
  date_locale: { type: String, default: 'en-IN' },
42
- date_format: { type: String, default: 'dd/MM/yyyy HH:mm A' },
42
+ date_format: { type: String, default: 'dd/MM/yyyy hh:mm A' },
43
43
  min_width: { type: Number, default: 150 },
44
44
  sortable: { type: Boolean, default: true },
45
45
  resizable: { type: Boolean, default: true },
@@ -216,8 +216,6 @@ dmx.Component('ag-grid', {
216
216
 
217
217
  return container;
218
218
  }
219
-
220
-
221
219
  function humanize(str) {
222
220
  if (str == null) return str;
223
221
 
@@ -520,12 +518,26 @@ dmx.Component('ag-grid', {
520
518
  filterValueGetter = createCombinedFilterValueGetter(key, options.data_changes, options.data_binded_changes);
521
519
  }
522
520
  function extractConditionParts(condition) {
523
- const parts = condition.match(/(.+?)(===|==|!=|>|<|>=|<=)(.+)/);
524
- if (parts) {
525
- const [, left, operator, right] = parts;
526
- return [left.trim(), operator.trim(), right.trim()];
521
+ const operators = ['===', '==', '!=', '>', '<', '>=', '<='];
522
+ let operator;
523
+ let left;
524
+ let right;
525
+
526
+ for (const op of operators) {
527
+ if (condition.includes(op)) {
528
+ operator = op;
529
+ const parts = condition.split(op).map(part => part.trim());
530
+ left = parts[0];
531
+ right = parts.slice(1).join(op).trim();
532
+ break;
533
+ }
534
+ }
535
+
536
+ if (!operator) {
537
+ throw new Error('Invalid operator in the condition.');
527
538
  }
528
- return [];
539
+
540
+ return [left, operator, right];
529
541
  }
530
542
 
531
543
  function evaluateCondition(left, operator, right) {
@@ -557,17 +569,24 @@ dmx.Component('ag-grid', {
557
569
  for (const style of styles) {
558
570
  const condition = style.condition;
559
571
  const customColor = style.customColor;
572
+ const font = style.font || 'normal';
573
+ const area = style.area || 'text';
560
574
  const [left, operator, right] = extractConditionParts(condition);
575
+
561
576
  if (
562
- params.data.hasOwnProperty(left) &&
563
- evaluateCondition(params.data[left], operator, right)
577
+ params.data.hasOwnProperty(left) &&
578
+ evaluateCondition(params.data[left], operator, right)
564
579
  ) {
565
- return { color: customColor };
580
+ if (area === 'text') {
581
+ return { color: customColor, fontStyle: font };
582
+ } else if (area === 'cell') {
583
+ return { backgroundColor: customColor, fontStyle: font };
584
+ }
566
585
  }
567
586
  }
568
587
 
569
588
  return null;
570
- }
589
+ }
571
590
 
572
591
  if (cnames.hasOwnProperty(key)) {
573
592
  const cname = cnames[key]
@@ -654,6 +673,7 @@ dmx.Component('ag-grid', {
654
673
  field: 'action',
655
674
  colId: 'actionsColumn',
656
675
  filter: null,
676
+ sortable: false,
657
677
  cellRenderer: actionsRenderer,
658
678
  pinned: options.pin_actions,
659
679
  cellRendererParams: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cdmx/wappler_ag_grid",
3
- "version": "0.4.2",
3
+ "version": "0.4.4",
4
4
  "type": "module",
5
5
  "description": "App Connect module for AG Grid Table Generation",
6
6
  "license": "MIT",