@cdmx/wappler_ag_grid 0.3.9 → 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 +102 -12
- package/dmx-ag-grid.js +65 -17
- package/package.json +1 -1
|
@@ -58,6 +58,14 @@
|
|
|
58
58
|
"required": true,
|
|
59
59
|
"help": "Enter Data Source"
|
|
60
60
|
},
|
|
61
|
+
{
|
|
62
|
+
"name": "gridNoLoad",
|
|
63
|
+
"hasAttribute": "noload",
|
|
64
|
+
"title": "No Auto Load",
|
|
65
|
+
"type": "boolean",
|
|
66
|
+
"defaultValue": "",
|
|
67
|
+
"initValue": true
|
|
68
|
+
},
|
|
61
69
|
{
|
|
62
70
|
"name": "grid_theme",
|
|
63
71
|
"attribute": "grid_theme",
|
|
@@ -826,6 +834,7 @@
|
|
|
826
834
|
"show": [
|
|
827
835
|
"hideFields",
|
|
828
836
|
"hideFilters",
|
|
837
|
+
"hideSort",
|
|
829
838
|
],
|
|
830
839
|
"noChangeOnHide": true,
|
|
831
840
|
"groupEnabler": true,
|
|
@@ -844,6 +853,13 @@
|
|
|
844
853
|
"title": "Hide Filters",
|
|
845
854
|
"type": "text",
|
|
846
855
|
"initDisplay": "none"
|
|
856
|
+
},
|
|
857
|
+
{
|
|
858
|
+
"name": "hideSort",
|
|
859
|
+
"attribute": "hide_sort",
|
|
860
|
+
"title": "Hide Sort Filters",
|
|
861
|
+
"type": "text",
|
|
862
|
+
"initDisplay": "none"
|
|
847
863
|
}
|
|
848
864
|
]
|
|
849
865
|
}
|
|
@@ -870,7 +886,12 @@
|
|
|
870
886
|
"viewActionTitle",
|
|
871
887
|
"viewActionTooltip",
|
|
872
888
|
"viewActionBtnClass",
|
|
873
|
-
"viewActionIconClass"
|
|
889
|
+
"viewActionIconClass",
|
|
890
|
+
"deleteActionBtn",
|
|
891
|
+
"deleteActionTitle",
|
|
892
|
+
"deleteActionTooltip",
|
|
893
|
+
"deleteActionBtnClass",
|
|
894
|
+
"deleteActionIconClass"
|
|
874
895
|
],
|
|
875
896
|
"noChangeOnHide": true,
|
|
876
897
|
"groupEnabler": true,
|
|
@@ -915,7 +936,7 @@
|
|
|
915
936
|
{
|
|
916
937
|
"name": "editActionIconClass",
|
|
917
938
|
"attribute": "edit_action_icon_class",
|
|
918
|
-
"title": "Edit Action
|
|
939
|
+
"title": "Edit Action Icon Class",
|
|
919
940
|
"type": "text",
|
|
920
941
|
"defaultValue": 'fas fa-pencil-alt'
|
|
921
942
|
},
|
|
@@ -949,10 +970,45 @@
|
|
|
949
970
|
},
|
|
950
971
|
{
|
|
951
972
|
"name": "viewActionIconClass",
|
|
952
|
-
"attribute": "
|
|
973
|
+
"attribute": "view_action_icon_class",
|
|
953
974
|
"title": "View Action IconClass",
|
|
954
975
|
"type": "text",
|
|
955
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'
|
|
956
1012
|
}
|
|
957
1013
|
]
|
|
958
1014
|
}
|
|
@@ -962,21 +1018,21 @@
|
|
|
962
1018
|
],
|
|
963
1019
|
actionsScheme: [
|
|
964
1020
|
{
|
|
965
|
-
addTitle: '
|
|
966
|
-
title : '
|
|
967
|
-
name : '
|
|
1021
|
+
addTitle: 'Load',
|
|
1022
|
+
title : 'Load',
|
|
1023
|
+
name : 'loadGrid',
|
|
968
1024
|
icon : 'fa fa-lg fa-play',
|
|
969
1025
|
state : 'opened',
|
|
970
|
-
help: '
|
|
1026
|
+
help: 'Load the AG Grid',
|
|
971
1027
|
properties : []
|
|
972
1028
|
},
|
|
973
1029
|
{
|
|
974
|
-
addTitle: '
|
|
975
|
-
title : '
|
|
976
|
-
name : '
|
|
977
|
-
icon : 'fa fa-lg fa-
|
|
1030
|
+
addTitle: 'Reload',
|
|
1031
|
+
title : 'Reload',
|
|
1032
|
+
name : 'reloadGrid',
|
|
1033
|
+
icon : 'fa fa-lg fa-sync',
|
|
978
1034
|
state : 'opened',
|
|
979
|
-
help: '
|
|
1035
|
+
help: 'Reload the AG Grid',
|
|
980
1036
|
properties : []
|
|
981
1037
|
}
|
|
982
1038
|
],
|
|
@@ -1426,6 +1482,40 @@
|
|
|
1426
1482
|
"allowedOn": {
|
|
1427
1483
|
"dmx-ag-grid": true
|
|
1428
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
|
+
}
|
|
1429
1519
|
}
|
|
1430
1520
|
],
|
|
1431
1521
|
"static_events": []
|
package/dmx-ag-grid.js
CHANGED
|
@@ -8,6 +8,7 @@ dmx.Component('ag-grid', {
|
|
|
8
8
|
|
|
9
9
|
attributes: {
|
|
10
10
|
id: { default: null },
|
|
11
|
+
noload: { type: Boolean, default: false },
|
|
11
12
|
grid_theme: { type: String, default: 'ag-theme-alpine' },
|
|
12
13
|
column_defs: { type: Array, default: [] },
|
|
13
14
|
cstyles: { type: Array, default: [] },
|
|
@@ -37,6 +38,7 @@ dmx.Component('ag-grid', {
|
|
|
37
38
|
hide_id_field: { type: Boolean, default: false },
|
|
38
39
|
enable_rtl: { type: Boolean, default: false },
|
|
39
40
|
locale_text: { type: Text, default: null },
|
|
41
|
+
date_locale: { type: Text, default: 'en-IN' },
|
|
40
42
|
min_width: { type: Number, default: 150 },
|
|
41
43
|
sortable: { type: Boolean, default: true },
|
|
42
44
|
resizable: { type: Boolean, default: true },
|
|
@@ -59,16 +61,22 @@ dmx.Component('ag-grid', {
|
|
|
59
61
|
edit_action_btn: { type: Boolean, default: false },
|
|
60
62
|
edit_action_title: {type: String, default: '' },
|
|
61
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' },
|
|
62
66
|
view_action_btn: { type: Boolean, default: false },
|
|
63
67
|
view_action_title: {type: String, default: '' },
|
|
64
68
|
view_action_tooltip: {type: String, default: 'View' },
|
|
65
|
-
edit_action_icon_class: {type: String, default: 'fas fa-pencil-alt' },
|
|
66
|
-
edit_action_btn_class: {type: String, default: 'btn-primary btn-xs' },
|
|
67
69
|
view_action_icon_class: {type: String, default: 'fas fa-eye' },
|
|
68
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' },
|
|
69
76
|
data_binded_changes: {type: Array, default: [] },
|
|
70
77
|
hide_fields: {type: Array, default: [] },
|
|
71
|
-
hide_filters: {type: Array, default: [] }
|
|
78
|
+
hide_filters: {type: Array, default: [] },
|
|
79
|
+
hide_sort: {type: Array, default: [] }
|
|
72
80
|
},
|
|
73
81
|
|
|
74
82
|
methods: {
|
|
@@ -82,10 +90,9 @@ dmx.Component('ag-grid', {
|
|
|
82
90
|
this.refreshGrid();
|
|
83
91
|
}, this);
|
|
84
92
|
},
|
|
85
|
-
|
|
93
|
+
loadGrid: function () {
|
|
86
94
|
dmx.nextTick(function() {
|
|
87
|
-
|
|
88
|
-
// this.updateGrid();
|
|
95
|
+
this.refreshGrid();
|
|
89
96
|
}, this);
|
|
90
97
|
}
|
|
91
98
|
},
|
|
@@ -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) {
|
|
@@ -783,7 +831,7 @@ dmx.Component('ag-grid', {
|
|
|
783
831
|
|
|
784
832
|
update: function (props) {
|
|
785
833
|
this.set('count', this.props.data.length);
|
|
786
|
-
if (!dmx.equal(this.props.data, props.data)) {
|
|
834
|
+
if (!dmx.equal(this.props.data, props.data) && !this.props.noload) {
|
|
787
835
|
let gridInstance = this.refreshGrid();
|
|
788
836
|
this.set('gridInstance', gridInstance);
|
|
789
837
|
}
|