@cdmx/wappler_ag_grid 0.1.2 → 0.1.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.
@@ -357,23 +357,23 @@
357
357
  "title": "Row Click Events",
358
358
  "type": "boolean",
359
359
  "defaultValue": false,
360
- "help": "This enabled row click events which can then be used in Dynamic events => Grid Events => Row Clicked"
360
+ "help": "This enables row click events which can then be used in Dynamic events => Grid Events => Row Clicked"
361
361
  },
362
362
  {
363
363
  "name": "rowCheckboxEvent",
364
364
  "attribute": "dmx-bind:row_checkbox_event",
365
- "title": "Row Checkbox Events",
365
+ "title": "Enable Row Selection",
366
366
  "type": "boolean",
367
367
  "defaultValue": false,
368
- "help": "This enabled row checkbox events which can then be used in Dynamic events => Grid Events => Checkbox Checked || Checkbox Unchecked"
368
+ "help": "This enables row selection which can then be used in Dynamic events => Grid Events => Checkbox Checked || Checkbox Unchecked"
369
369
  },
370
370
  {
371
371
  "name": "rowStatusEvent",
372
372
  "attribute": "dmx-bind:row_status_event",
373
- "title": "Row Status Events",
373
+ "title": "Enable Row Status Toggle",
374
374
  "type": "boolean",
375
375
  "defaultValue": false,
376
- "help": "This enabled row status events which can then be used in Dynamic events => Grid Events => Checkbox Checked || Checkbox Unchecked"
376
+ "help": "This enables row status events which can then be used in Dynamic events => Grid Events => Checkbox Checked || Checkbox Unchecked"
377
377
  }
378
378
  ]
379
379
  },
@@ -486,7 +486,6 @@
486
486
  {
487
487
  "field": "field",
488
488
  "caption": "Field",
489
- "size": "10%",
490
489
  "editable": {
491
490
  "type": "text"
492
491
  }
@@ -494,7 +493,6 @@
494
493
  {
495
494
  "field": "value",
496
495
  "caption": "Value",
497
- "size": "10%",
498
496
  "editable": {
499
497
  "type": "text"
500
498
  }
@@ -502,7 +500,6 @@
502
500
  {
503
501
  field: "new_value",
504
502
  caption: "New Value",
505
- size: "10%",
506
503
  editable: {
507
504
  type: "text"
508
505
  }
package/dmx-ag-grid.js CHANGED
@@ -178,20 +178,26 @@ dmx.Component('ag-grid', {
178
178
  const value = formatValue(params.value, columnName, dataType, timezone);
179
179
  return `<div onclick="clickEvent('${columnName}', '${value}', '${idValue}')" style="cursor: pointer;">${value}</div>`;
180
180
  }
181
- function checkboxCellRenderer(params) {
181
+ function idCheckboxCellRenderer(params) {
182
182
  const idValue = params.data.id;
183
183
  const columnName = params.colDef.field;
184
184
  const dataType = detectDataType([params.value]);
185
185
  const value = formatValue(params.value, columnName, dataType, timezone);
186
-
187
- if (columnName === "id") {
188
- return `
186
+ return `
189
187
  <input
190
188
  type="checkbox"
191
189
  onclick="handleCheckboxClick(event, '${columnName}', '${value}', '${idValue}')"
192
190
  />
193
191
  `;
194
- } else if (columnName == "status" && enableStatusToggle) {
192
+ }
193
+
194
+ function checkboxCellRenderer(params) {
195
+ const idValue = params.data.id;
196
+ const columnName = params.colDef.field;
197
+ const dataType = detectDataType([params.value]);
198
+ const value = formatValue(params.value, columnName, dataType, timezone);
199
+
200
+ if (columnName == "status" && enableStatusToggle) {
195
201
  // Assuming `value` is a boolean representing the status
196
202
  const checked = value==true ? "checked" : "";
197
203
  return `
@@ -389,21 +395,20 @@ dmx.Component('ag-grid', {
389
395
  return false;
390
396
  }
391
397
  }
392
- const cstyles = this.props.cstyles
393
- // Check if custom color exists for the current field and condition
394
- function applyCellStyle(params) {
395
- const field = params.colDef.field.toString();
396
- if (cstyles.hasOwnProperty(field)) {
397
- const condition = cstyles[field].condition;
398
- const customColor = cstyles[field].customColor;
399
- const [left, operator, right] = extractConditionParts(condition);
400
- // Check if the field exists and its value is true
401
- if (params.data.hasOwnProperty(field) && evaluateCondition(params.data[left], operator, right)) {
402
- return { color: customColor };
403
- }
404
- }
405
- return null;
406
- }
398
+ const cstyles = this.props.cstyles
399
+ // Check if custom color exists for the current field and condition
400
+ function applyCellStyle(params) {
401
+ const field = params.colDef.field.toString();
402
+ if (cstyles.hasOwnProperty(field)) {
403
+ const condition = cstyles[field].condition;
404
+ const customColor = cstyles[field].customColor;
405
+ const [left, operator, right] = extractConditionParts(condition);
406
+ if (params.data.hasOwnProperty(field) && evaluateCondition(params.data[left], operator, right)) {
407
+ return { color: customColor };
408
+ }
409
+ }
410
+ return null;
411
+ }
407
412
  cnames = this.props.cnames
408
413
  cwidths = this.props.cwidths
409
414
  enableClickEvent = this.props.row_click_event;
@@ -427,10 +432,26 @@ const cstyles = this.props.cstyles
427
432
  minWidth: parseInt(cwidths[key].min_width),
428
433
  maxWidth: parseInt(cwidths[key].max_width),
429
434
  }),
430
- cellRenderer: enableClickEvent ? 'clickCellRenderer' : (enableCheckboxEvent ? 'checkboxCellRenderer' : undefined)
435
+ cellRenderer: enableClickEvent ? 'clickCellRenderer' : (enableStatusToggle ? 'checkboxCellRenderer' : undefined)
431
436
  };
432
437
  });
433
438
  }
439
+ let checkboxColumn;
440
+ if (enableCheckboxEvent) {
441
+ // Duplicate the column for 'id'
442
+ checkboxColumn = {
443
+ headerName: '',
444
+ field: 'id',
445
+ filter: '',
446
+ cellRenderer: 'idCheckboxCellRenderer',
447
+ resizable: false,
448
+ width: 50,
449
+ maxWidth: 50,
450
+ suppressMenu: true,
451
+ };
452
+ columnDefs.unshift(checkboxColumn);
453
+ }
454
+
434
455
  const gridOptions = {
435
456
  columnDefs: columnDefs,
436
457
  defaultColDef: {
@@ -462,7 +483,8 @@ const cstyles = this.props.cstyles
462
483
  localeText: this.props.localeText,
463
484
  components: {
464
485
  clickCellRenderer: clickCellRenderer,
465
- checkboxCellRenderer: checkboxCellRenderer
486
+ checkboxCellRenderer: checkboxCellRenderer,
487
+ idCheckboxCellRenderer: idCheckboxCellRenderer
466
488
  }
467
489
  };
468
490
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cdmx/wappler_ag_grid",
3
- "version": "0.1.2",
3
+ "version": "0.1.3",
4
4
  "type": "module",
5
5
  "description": "App Connect module for AG Grid Table Generation",
6
6
  "license": "MIT",