@cdmx/wappler_ag_grid 1.2.2 → 1.2.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.
Files changed (3) hide show
  1. package/README.md +19 -56
  2. package/dmx-ag-grid.js +35 -5
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -259,6 +259,9 @@ The Configure Actions Column feature allows you to configure actions for the but
259
259
  **Enable Actions**
260
260
  This will display the "Configure Actions" options for the buttons in the Actions Column.
261
261
 
262
+ Note: Button Tooltip Supports Calling a function, just define a function and add the function name in the Tooltip e.g. getEditTooltip().
263
+ In the function the variable for the row data will be available as the first attribute e.g. getEditTooltip(data), then data holds the values of the row.
264
+
262
265
  **Pin Actions Column**
263
266
  This will keep the Actions Column fixed when scrolling horizontally.
264
267
 
@@ -288,7 +291,7 @@ Specify the CSS class for styling the Edit Action button.
288
291
  Specify the CSS class for styling the icon of the Edit Action button.
289
292
 
290
293
  **Edit Action Button Condition**
291
- Specify the condition to Show the Edit Action button, eg: code==TEST, or status==COMPLETED
294
+ Specify the condition to Show the Edit Action button, eg: code==TEST, or status==COMPLETED||status==FINISHED or status==COMPLETED&&user_status==true
292
295
 
293
296
  **View Action Button**
294
297
  This will display the "View Action Button" options.
@@ -306,7 +309,7 @@ Specify the CSS class for styling the View Action button.
306
309
  Specify the CSS class for styling the icon of the View Action button.
307
310
 
308
311
  **View Action Button Condition**
309
- Specify the condition to Show the View Action button, eg: code==TEST, or status==COMPLETED
312
+ Specify the condition to Show the View Action button, eg: code==TEST, or status==COMPLETED||status==FINISHED or status==COMPLETED&&user_status==true
310
313
 
311
314
  **Delete Action Button**
312
315
  This will display the "Delete Action Button" options.
@@ -324,69 +327,29 @@ Specify the CSS class for styling the Delete Action button.
324
327
  Specify the CSS class for styling the icon of the Delete Action button.
325
328
 
326
329
  **Delete Action Button Condition**
327
- Specify the condition to Show the Delete Action button, eg: code==TEST, or status==COMPLETED
330
+ Specify the condition to Show the Delete Action button, eg: code==TEST, or status==COMPLETED||status==FINISHED or status==COMPLETED&&user_status==true
328
331
 
329
332
  # Custom Action Buttons
330
333
 
331
- **Button1 Class**
332
- Specify the CSS class for Button 1.
333
-
334
- **Button1 Tooltip**
335
- Specify the tooltip text for Button 1.
336
-
337
- **Button2 Class**
338
- Specify the CSS class for Button 2.
339
-
340
- **Button2 Tooltip**
341
- Specify the tooltip text for Button 2.
342
-
343
- **Button3 Class**
344
- Specify the CSS class for Button 3.
345
-
346
- **Button3 Tooltip**
347
- Specify the tooltip text for Button 3.
348
-
349
- **Button4 Class**
350
- Specify the CSS class for Button 4.
351
-
352
- **Button4 Tooltip**
353
- Specify the tooltip text for Button 4.
354
-
355
- **Button5 Class**
356
- Specify the CSS class for Button 5.
357
-
358
- **Button5 Tooltip**
359
- Specify the tooltip text for Button 5.
360
-
361
- **Button6 Class**
362
- Specify the CSS class for Button 6.
363
-
364
- **Button6 Tooltip**
365
- Specify the tooltip text for Button 6.
366
-
367
- **Button7 Class**
368
- Specify the CSS class for Button 7.
369
-
370
- **Button7 Tooltip**
371
- Specify the tooltip text for Button 7.
334
+ **Buttons 1-10**
372
335
 
373
- **Button8 Class**
374
- Specify the CSS class for Button 8.
336
+ **Button[i] Action Button**
337
+ This will display the "Button[i] Action Button" options.
375
338
 
376
- **Button8 Tooltip**
377
- Specify the tooltip text for Button 8.
339
+ **Button[i] Action Button Title**
340
+ Specify the title for the Button[i] Action button.
378
341
 
379
- **Button9 Class**
380
- Specify the CSS class for Button 9.
342
+ **Button[i] Action Button Tooltip**
343
+ Specify the tooltip text for the Button[i] Action button.
381
344
 
382
- **Button9 Tooltip**
383
- Specify the tooltip text for Button 9.
345
+ **Button[i] Action Button Class**
346
+ Specify the CSS class for styling the Button[i] Action button.
384
347
 
385
- **Button10 Class**
386
- Specify the CSS class for Button 10.
348
+ **Button[i] Action Button Icon Class**
349
+ Specify the CSS class for styling the icon of the Button[i] Action button.
387
350
 
388
- **Button10 Tooltip**
389
- Specify the tooltip text for Button 10.
351
+ **Button[i] Action Button Condition**
352
+ Specify the condition to Show the Button[i] Action button, eg: code==TEST, or status==COMPLETED||status==FINISHED or status==COMPLETED&&user_status==true
390
353
 
391
354
  # Action Attributes
392
355
 
package/dmx-ag-grid.js CHANGED
@@ -464,21 +464,27 @@ dmx.Component('ag-grid', {
464
464
  const buttons = params.buttons || defaultButtons;
465
465
  // Create a new container element to hold the buttons
466
466
  const container = document.createElement('div');
467
-
467
+
468
468
  buttons.forEach((buttonConfig) => {
469
469
  const button = document.createElement('button');
470
470
  button.classList.add('btn');
471
471
  const classNames = buttonConfig.classNames.split(' ');
472
472
  classNames.forEach((className) => button.classList.add(className));
473
473
  button.setAttribute('data-toggle', 'tooltip');
474
- button.setAttribute('title', buttonConfig.tooltip);
474
+ // Call a function to get the dynamic tooltip content
475
+ if (buttonConfig.tooltip.endsWith('()')) {
476
+ const tooltipFunction = buttonConfig.tooltip.slice(0, -2); // Remove the trailing '()'
477
+ const tooltipText = window[tooltipFunction](params.data)
478
+ button.setAttribute('title', tooltipText);
479
+ } else {
480
+ button.setAttribute('title', buttonConfig.tooltip);
481
+ }
475
482
  button.innerHTML = `<i class="${buttonConfig.icon}"></i> ${buttonConfig.action}`;
476
483
  container.appendChild(button);
477
484
  // Check if the button should be hidden based on the condition string and row data
478
485
  if (buttonConfig.condition) {
479
- const [left, operator, right] = extractConditionParts(buttonConfig.condition);
480
-
481
- const isConditionMet = params.data.hasOwnProperty(left) && evaluateCondition(params.data[left], operator, right);
486
+ const conditions = buttonConfig.condition.split(/(\|\||&&)/);
487
+ const isConditionMet = evaluateConditions(conditions, params);
482
488
  if (!isConditionMet) {
483
489
  button.style.setProperty('display', 'none', 'important');
484
490
  }
@@ -555,6 +561,30 @@ dmx.Component('ag-grid', {
555
561
 
556
562
  return [left, operator, right];
557
563
  }
564
+ function evaluateConditions(conditions, params) {
565
+ let results = [];
566
+ let operators = [];
567
+ for (let i = 0; i < conditions.length; i++) {
568
+ const part = conditions[i].trim();
569
+ if (part === '||' || part === '&&') {
570
+ operators.push(part);
571
+ } else {
572
+ const [left, operator, right] = extractConditionParts(part);
573
+ const result = evaluateCondition(params.data[left], operator, right);
574
+ results.push(result);
575
+ }
576
+ }
577
+ let finalResult = results[0];
578
+
579
+ for (let i = 0; i < operators.length; i++) {
580
+ if (operators[i] === '||') {
581
+ finalResult = finalResult || results[i + 1];
582
+ } else if (operators[i] === '&&') {
583
+ finalResult = finalResult && results[i + 1];
584
+ }
585
+ }
586
+ return finalResult;
587
+ }
558
588
 
559
589
  function evaluateCondition(left, operator, right) {
560
590
  switch (operator) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cdmx/wappler_ag_grid",
3
- "version": "1.2.2",
3
+ "version": "1.2.4",
4
4
  "type": "module",
5
5
  "description": "App Connect module for AG Grid Table Generation.",
6
6
  "license": "MIT",