@cdmx/wappler_ag_grid 0.4.0 → 0.4.1
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/app_connect/components.hjson +85 -3
- package/dmx-ag-grid.js +61 -13
- package/package.json +1 -1
|
@@ -834,6 +834,7 @@
|
|
|
834
834
|
"show": [
|
|
835
835
|
"hideFields",
|
|
836
836
|
"hideFilters",
|
|
837
|
+
"hideSort",
|
|
837
838
|
],
|
|
838
839
|
"noChangeOnHide": true,
|
|
839
840
|
"groupEnabler": true,
|
|
@@ -852,6 +853,13 @@
|
|
|
852
853
|
"title": "Hide Filters",
|
|
853
854
|
"type": "text",
|
|
854
855
|
"initDisplay": "none"
|
|
856
|
+
},
|
|
857
|
+
{
|
|
858
|
+
"name": "hideSort",
|
|
859
|
+
"attribute": "hide_sort",
|
|
860
|
+
"title": "Hide Sort Filters",
|
|
861
|
+
"type": "text",
|
|
862
|
+
"initDisplay": "none"
|
|
855
863
|
}
|
|
856
864
|
]
|
|
857
865
|
}
|
|
@@ -878,7 +886,12 @@
|
|
|
878
886
|
"viewActionTitle",
|
|
879
887
|
"viewActionTooltip",
|
|
880
888
|
"viewActionBtnClass",
|
|
881
|
-
"viewActionIconClass"
|
|
889
|
+
"viewActionIconClass",
|
|
890
|
+
"deleteActionBtn",
|
|
891
|
+
"deleteActionTitle",
|
|
892
|
+
"deleteActionTooltip",
|
|
893
|
+
"deleteActionBtnClass",
|
|
894
|
+
"deleteActionIconClass"
|
|
882
895
|
],
|
|
883
896
|
"noChangeOnHide": true,
|
|
884
897
|
"groupEnabler": true,
|
|
@@ -923,7 +936,7 @@
|
|
|
923
936
|
{
|
|
924
937
|
"name": "editActionIconClass",
|
|
925
938
|
"attribute": "edit_action_icon_class",
|
|
926
|
-
"title": "Edit Action
|
|
939
|
+
"title": "Edit Action Icon Class",
|
|
927
940
|
"type": "text",
|
|
928
941
|
"defaultValue": 'fas fa-pencil-alt'
|
|
929
942
|
},
|
|
@@ -957,10 +970,45 @@
|
|
|
957
970
|
},
|
|
958
971
|
{
|
|
959
972
|
"name": "viewActionIconClass",
|
|
960
|
-
"attribute": "
|
|
973
|
+
"attribute": "view_action_icon_class",
|
|
961
974
|
"title": "View Action IconClass",
|
|
962
975
|
"type": "text",
|
|
963
976
|
"defaultValue": 'fas fa-eye'
|
|
977
|
+
},
|
|
978
|
+
{
|
|
979
|
+
"name": "deleteActionBtn",
|
|
980
|
+
"attribute": "dmx-bind:delete_action_btn",
|
|
981
|
+
"title": "Delete Action Button",
|
|
982
|
+
"type": "boolean",
|
|
983
|
+
"defaultValue": ''
|
|
984
|
+
},
|
|
985
|
+
{
|
|
986
|
+
"name": "deleteActionTitle",
|
|
987
|
+
"attribute": "delete_action_title",
|
|
988
|
+
"title": "Delete Action Button Title",
|
|
989
|
+
"type": "text",
|
|
990
|
+
"defaultValue": ''
|
|
991
|
+
},
|
|
992
|
+
{
|
|
993
|
+
"name": "deleteActionTooltip",
|
|
994
|
+
"attribute": "delete_action_tooltip",
|
|
995
|
+
"title": "Delete Action Button Tooltip",
|
|
996
|
+
"type": "text",
|
|
997
|
+
"defaultValue": ''
|
|
998
|
+
},
|
|
999
|
+
{
|
|
1000
|
+
"name": "deleteActionBtnClass",
|
|
1001
|
+
"attribute": "delete_action_btn_class",
|
|
1002
|
+
"title": "Delete Action Button Class",
|
|
1003
|
+
"type": "text",
|
|
1004
|
+
"defaultValue": 'btn-danger btn-xs'
|
|
1005
|
+
},
|
|
1006
|
+
{
|
|
1007
|
+
"name": "deleteActionIconClass",
|
|
1008
|
+
"attribute": "delete_action_icon_class",
|
|
1009
|
+
"title": "Delete Action Icon Class",
|
|
1010
|
+
"type": "text",
|
|
1011
|
+
"defaultValue": 'fas fa-trash'
|
|
964
1012
|
}
|
|
965
1013
|
]
|
|
966
1014
|
}
|
|
@@ -1434,6 +1482,40 @@
|
|
|
1434
1482
|
"allowedOn": {
|
|
1435
1483
|
"dmx-ag-grid": true
|
|
1436
1484
|
}
|
|
1485
|
+
},
|
|
1486
|
+
{
|
|
1487
|
+
"name": "dmx-ag-grid-delete-clicked",
|
|
1488
|
+
"attributeStartsWith": "dmx-on",
|
|
1489
|
+
"attribute": "row_action_delete",
|
|
1490
|
+
"display": "fieldset",
|
|
1491
|
+
"title": "Delete Clicked",
|
|
1492
|
+
"icon": "fa fa-lg fa-chevron-right",
|
|
1493
|
+
"groupTitle": "Grid Events",
|
|
1494
|
+
"groupIcon": "fa fa-lg fa-cubes",
|
|
1495
|
+
"defaultValue": false,
|
|
1496
|
+
"show": [
|
|
1497
|
+
"rowActionDelete"
|
|
1498
|
+
],
|
|
1499
|
+
"noChangeOnHide": true,
|
|
1500
|
+
"type": "boolean",
|
|
1501
|
+
"groupEnabler": true,
|
|
1502
|
+
"children": [
|
|
1503
|
+
{
|
|
1504
|
+
"name": "rowActionDelete",
|
|
1505
|
+
"attributeStartsWith": "dmx-on",
|
|
1506
|
+
"attribute": "row_action_delete",
|
|
1507
|
+
"isValue": true,
|
|
1508
|
+
"actionsPicker": true,
|
|
1509
|
+
"title": "Action:",
|
|
1510
|
+
"type": "text",
|
|
1511
|
+
"help": "Choose the action to execute.",
|
|
1512
|
+
"defaultValue": "",
|
|
1513
|
+
"initDisplay": "none"
|
|
1514
|
+
}
|
|
1515
|
+
],
|
|
1516
|
+
"allowedOn": {
|
|
1517
|
+
"dmx-ag-grid": true
|
|
1518
|
+
}
|
|
1437
1519
|
}
|
|
1438
1520
|
],
|
|
1439
1521
|
"static_events": []
|
package/dmx-ag-grid.js
CHANGED
|
@@ -38,6 +38,7 @@ dmx.Component('ag-grid', {
|
|
|
38
38
|
hide_id_field: { type: Boolean, default: false },
|
|
39
39
|
enable_rtl: { type: Boolean, default: false },
|
|
40
40
|
locale_text: { type: Text, default: null },
|
|
41
|
+
date_locale: { type: Text, default: 'en-IN' },
|
|
41
42
|
min_width: { type: Number, default: 150 },
|
|
42
43
|
sortable: { type: Boolean, default: true },
|
|
43
44
|
resizable: { type: Boolean, default: true },
|
|
@@ -60,16 +61,22 @@ dmx.Component('ag-grid', {
|
|
|
60
61
|
edit_action_btn: { type: Boolean, default: false },
|
|
61
62
|
edit_action_title: {type: String, default: '' },
|
|
62
63
|
edit_action_tooltip: {type: String, default: 'Edit' },
|
|
64
|
+
edit_action_icon_class: {type: String, default: 'fas fa-pencil-alt' },
|
|
65
|
+
edit_action_btn_class: {type: String, default: 'btn-primary btn-xs' },
|
|
63
66
|
view_action_btn: { type: Boolean, default: false },
|
|
64
67
|
view_action_title: {type: String, default: '' },
|
|
65
68
|
view_action_tooltip: {type: String, default: 'View' },
|
|
66
|
-
edit_action_icon_class: {type: String, default: 'fas fa-pencil-alt' },
|
|
67
|
-
edit_action_btn_class: {type: String, default: 'btn-primary btn-xs' },
|
|
68
69
|
view_action_icon_class: {type: String, default: 'fas fa-eye' },
|
|
69
70
|
view_action_btn_class: {type: String, default: 'btn-info btn-xs' },
|
|
71
|
+
delete_action_btn: { type: Boolean, default: false },
|
|
72
|
+
delete_action_title: {type: String, default: '' },
|
|
73
|
+
delete_action_tooltip: {type: String, default: 'Delete' },
|
|
74
|
+
delete_action_icon_class: {type: String, default: 'fas fa-trash' },
|
|
75
|
+
delete_action_btn_class: {type: String, default: 'btn-danger btn-xs' },
|
|
70
76
|
data_binded_changes: {type: Array, default: [] },
|
|
71
77
|
hide_fields: {type: Array, default: [] },
|
|
72
|
-
hide_filters: {type: Array, default: [] }
|
|
78
|
+
hide_filters: {type: Array, default: [] },
|
|
79
|
+
hide_sort: {type: Array, default: [] }
|
|
73
80
|
},
|
|
74
81
|
|
|
75
82
|
methods: {
|
|
@@ -97,8 +104,8 @@ dmx.Component('ag-grid', {
|
|
|
97
104
|
const cnames = this.props.cnames
|
|
98
105
|
const cwidths = this.props.cwidths
|
|
99
106
|
const ctypes = this.props.ctypes
|
|
100
|
-
const enableRowClickEvent = this.props.row_click_event;
|
|
101
|
-
const enableCellClickEvent = this.props.
|
|
107
|
+
const enableRowClickEvent = this.props.row_click_event && !this.props.row_action_edit && !this.props.row_action_view && !this.props.row_checkbox_event;
|
|
108
|
+
const enableCellClickEvent = this.props.row_click_event && (this.props.row_action_edit || this.props.row_action_view || this.props.row_checkbox_event);
|
|
102
109
|
let localeText;
|
|
103
110
|
let columnDefs = [];
|
|
104
111
|
let exportToCSV = this.props.export_to_csv;
|
|
@@ -133,6 +140,17 @@ dmx.Component('ag-grid', {
|
|
|
133
140
|
const value = params.value
|
|
134
141
|
return `<div onclick="cellClickEvent('${columnName}', '${value}', '${idValue}')" style="cursor: pointer;">${value}</div>`;
|
|
135
142
|
}
|
|
143
|
+
onCellClicked = (event) => {
|
|
144
|
+
const rowData = event.data;
|
|
145
|
+
const columnId = event.column.colId
|
|
146
|
+
const excludedColIds = ['checkboxColumn', 'actionsColumn', 'statusColumn'];
|
|
147
|
+
if (excludedColIds.includes(columnId)) {
|
|
148
|
+
return;
|
|
149
|
+
}
|
|
150
|
+
this.set('data', rowData);
|
|
151
|
+
this.set('id', rowData.id);
|
|
152
|
+
this.dispatchEvent('row_clicked')
|
|
153
|
+
}
|
|
136
154
|
|
|
137
155
|
function checkboxCellRenderer(params) {
|
|
138
156
|
const idValue = params.data.id;
|
|
@@ -163,8 +181,9 @@ dmx.Component('ag-grid', {
|
|
|
163
181
|
function actionsRenderer(params) {
|
|
164
182
|
// Default button configurations (Edit and View)
|
|
165
183
|
const defaultButtons = [
|
|
166
|
-
|
|
167
|
-
|
|
184
|
+
{ action: 'Edit', classNames: 'btn-primary btn-xs', tooltip: 'Edit', icon: 'fas fa-pencil-alt' },
|
|
185
|
+
{ action: 'View', classNames: 'btn-info btn-xs', tooltip: 'View', icon: 'fas fa-eye' },
|
|
186
|
+
{ action: 'Delete', classNames: 'btn-danger btn-xs', tooltip: 'Delete', icon: 'fas fa-trash' },
|
|
168
187
|
];
|
|
169
188
|
// User-defined button configurations (if any)
|
|
170
189
|
const buttons = params.buttons || defaultButtons;
|
|
@@ -209,8 +228,10 @@ dmx.Component('ag-grid', {
|
|
|
209
228
|
.replace(/_id$/, '')
|
|
210
229
|
.replace(/_/g, ' ')
|
|
211
230
|
.trim();
|
|
231
|
+
let words = str.split(' ');
|
|
232
|
+
words = words.map(word => word.charAt(0).toUpperCase() + word.substr(1));
|
|
212
233
|
|
|
213
|
-
return
|
|
234
|
+
return words.join(' ');
|
|
214
235
|
}
|
|
215
236
|
|
|
216
237
|
function blankOrNullValueFormatter(params) {
|
|
@@ -240,7 +261,7 @@ dmx.Component('ag-grid', {
|
|
|
240
261
|
hour12: true,
|
|
241
262
|
timeZone: timezone
|
|
242
263
|
};
|
|
243
|
-
return date.toLocaleString(
|
|
264
|
+
return date.toLocaleString(options.date_locale, options).toUpperCase();
|
|
244
265
|
} else {
|
|
245
266
|
const options = {
|
|
246
267
|
day: '2-digit',
|
|
@@ -250,7 +271,7 @@ dmx.Component('ag-grid', {
|
|
|
250
271
|
minute: 'numeric',
|
|
251
272
|
hour12: true
|
|
252
273
|
};
|
|
253
|
-
return date.toLocaleString(
|
|
274
|
+
return date.toLocaleString(options.date_locale, options).toUpperCase();
|
|
254
275
|
}
|
|
255
276
|
}
|
|
256
277
|
}
|
|
@@ -398,6 +419,7 @@ dmx.Component('ag-grid', {
|
|
|
398
419
|
let filterParams;
|
|
399
420
|
let minWidth;
|
|
400
421
|
let hide;
|
|
422
|
+
let colId;
|
|
401
423
|
|
|
402
424
|
if (dataType === 'number') {
|
|
403
425
|
filter = 'agNumberColumnFilter';
|
|
@@ -436,7 +458,6 @@ dmx.Component('ag-grid', {
|
|
|
436
458
|
}
|
|
437
459
|
}
|
|
438
460
|
else {
|
|
439
|
-
// valueGetter = getValueGetter(key, dataChanges);
|
|
440
461
|
valueGetter = createCombinedValueGetter(key, options.data_changes, options.data_binded_changes);
|
|
441
462
|
filterValueGetter = createCombinedFilterValueGetter(key, options.data_changes, options.data_binded_changes);
|
|
442
463
|
}
|
|
@@ -499,6 +520,7 @@ dmx.Component('ag-grid', {
|
|
|
499
520
|
}
|
|
500
521
|
if (key =='status' && options.row_status_event) {
|
|
501
522
|
cellRenderer = 'checkboxCellRenderer';
|
|
523
|
+
colId = 'statusColumn';
|
|
502
524
|
filter = null;
|
|
503
525
|
}
|
|
504
526
|
else if (options.hide_filters && options.hide_filters.includes(key)) {
|
|
@@ -506,6 +528,13 @@ dmx.Component('ag-grid', {
|
|
|
506
528
|
}
|
|
507
529
|
else {
|
|
508
530
|
cellRenderer = undefined;
|
|
531
|
+
colId = undefined;
|
|
532
|
+
}
|
|
533
|
+
if (options.hide_sort && options.hide_sort.includes(key)) {
|
|
534
|
+
sortable = false;
|
|
535
|
+
}
|
|
536
|
+
else {
|
|
537
|
+
sortable = true;
|
|
509
538
|
}
|
|
510
539
|
if (options.hide_id_field && key == 'id') {
|
|
511
540
|
hide = true;
|
|
@@ -525,6 +554,7 @@ dmx.Component('ag-grid', {
|
|
|
525
554
|
valueGetter: valueGetter,
|
|
526
555
|
minWidth: minWidth,
|
|
527
556
|
hide: hide,
|
|
557
|
+
sortable: sortable,
|
|
528
558
|
filterValueGetter: filterValueGetter,
|
|
529
559
|
filterParams: filterParams,
|
|
530
560
|
cellStyle: applyCellStyle,
|
|
@@ -537,6 +567,7 @@ dmx.Component('ag-grid', {
|
|
|
537
567
|
});
|
|
538
568
|
}
|
|
539
569
|
window.onRowClicked = (event) => {
|
|
570
|
+
console.log(event)
|
|
540
571
|
const rowData = event.data;
|
|
541
572
|
this.set('data', rowData);
|
|
542
573
|
this.set('id', rowData.id);
|
|
@@ -548,6 +579,7 @@ dmx.Component('ag-grid', {
|
|
|
548
579
|
headerCheckboxSelection: true,
|
|
549
580
|
headerCheckboxSelectionFilteredOnly: false,
|
|
550
581
|
headerName: '',
|
|
582
|
+
colId: 'checkboxColumn',
|
|
551
583
|
field: 'id',
|
|
552
584
|
filter: '',
|
|
553
585
|
checkboxSelection: true,
|
|
@@ -563,6 +595,7 @@ dmx.Component('ag-grid', {
|
|
|
563
595
|
actionsColumn = {
|
|
564
596
|
headerName: 'Actions',
|
|
565
597
|
field: 'action',
|
|
598
|
+
colId: 'actionsColumn',
|
|
566
599
|
filter: null,
|
|
567
600
|
cellRenderer: actionsRenderer,
|
|
568
601
|
pinned: options.pin_actions,
|
|
@@ -598,6 +631,19 @@ dmx.Component('ag-grid', {
|
|
|
598
631
|
},
|
|
599
632
|
});
|
|
600
633
|
}
|
|
634
|
+
if (options.delete_action_btn) {
|
|
635
|
+
actionsColumn.cellRendererParams.buttons.push({
|
|
636
|
+
action: options.delete_action_title,
|
|
637
|
+
classNames: options.delete_action_btn_class,
|
|
638
|
+
tooltip: options.delete_action_tooltip,
|
|
639
|
+
icon: options.delete_action_icon_class,
|
|
640
|
+
onClick: (rowData) => {
|
|
641
|
+
this.set('data', rowData);
|
|
642
|
+
this.set('id', rowData.id);
|
|
643
|
+
this.dispatchEvent('row_action_delete');
|
|
644
|
+
},
|
|
645
|
+
});
|
|
646
|
+
}
|
|
601
647
|
|
|
602
648
|
columnDefs.push(actionsColumn);
|
|
603
649
|
}
|
|
@@ -610,7 +656,8 @@ dmx.Component('ag-grid', {
|
|
|
610
656
|
enableRtl: options.enable_rtl,
|
|
611
657
|
noRowsOverlayComponent: '<div>No Records Found.</div>',
|
|
612
658
|
onRowClicked: enableRowClickEvent ? onRowClicked : undefined,
|
|
613
|
-
|
|
659
|
+
onCellClicked: enableCellClickEvent ? onCellClicked : undefined,
|
|
660
|
+
rowStyle: enableRowClickEvent || enableCellClickEvent ? { cursor: 'pointer' } : undefined,
|
|
614
661
|
defaultColDef: {
|
|
615
662
|
flex: 1,
|
|
616
663
|
minWidth: this.props.min_width,
|
|
@@ -772,7 +819,8 @@ dmx.Component('ag-grid', {
|
|
|
772
819
|
row_status_enabled: Event,
|
|
773
820
|
row_status_disabled: Event,
|
|
774
821
|
row_action_edit: Event,
|
|
775
|
-
row_action_view: Event
|
|
822
|
+
row_action_view: Event,
|
|
823
|
+
row_action_delete: Event
|
|
776
824
|
},
|
|
777
825
|
|
|
778
826
|
render: function(node) {
|