@cdmx/wappler_ag_grid 0.1.5 → 0.1.7
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 +12 -0
- package/dmx-ag-grid.js +55 -28
- package/package.json +1 -1
|
@@ -152,6 +152,18 @@
|
|
|
152
152
|
"defaultValue": 20,
|
|
153
153
|
"help": "Number of rows to show per page"
|
|
154
154
|
},
|
|
155
|
+
{
|
|
156
|
+
"name": "rowSelection",
|
|
157
|
+
"attribute": "rowSelection",
|
|
158
|
+
"title": "Row Selection",
|
|
159
|
+
"type": "droplist",
|
|
160
|
+
"defaultValue": 'single',
|
|
161
|
+
"values": [
|
|
162
|
+
{title: 'Single', value: 'single'},
|
|
163
|
+
{title: 'Muliple', value: 'multiple'}
|
|
164
|
+
],
|
|
165
|
+
"help": "Row Selection (single or multiple)"
|
|
166
|
+
},
|
|
155
167
|
{
|
|
156
168
|
"name": "timezone",
|
|
157
169
|
"attribute": "timezone",
|
package/dmx-ag-grid.js
CHANGED
|
@@ -55,7 +55,7 @@ dmx.Component('ag-grid', {
|
|
|
55
55
|
data: { type: Array, default: [] },
|
|
56
56
|
domLayout: { default: 'autoHeight' },
|
|
57
57
|
enableCellTextSelection: { type: Boolean, default: true },
|
|
58
|
-
rowSelection: { type:
|
|
58
|
+
rowSelection: { type: String, default: 'single' },
|
|
59
59
|
suppressRowDeselection: { type: Boolean, default: false },
|
|
60
60
|
pagination: { type: Boolean, default: true },
|
|
61
61
|
paginationPageSize: { default: 20 },
|
|
@@ -121,24 +121,24 @@ dmx.Component('ag-grid', {
|
|
|
121
121
|
console.error('No row data provided.');
|
|
122
122
|
return;
|
|
123
123
|
}
|
|
124
|
-
function formatValue(value, key, dataType, timezone) {
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
}
|
|
124
|
+
// function formatValue(value, key, dataType, timezone) {
|
|
125
|
+
// params = {"value":value}
|
|
126
|
+
// if (dataType === 'number') {
|
|
127
|
+
// if (/(amount|amt)$/.test(key)) {
|
|
128
|
+
// return Number(value).toLocaleString("en-US", {
|
|
129
|
+
// minimumFractionDigits: 2,
|
|
130
|
+
// maximumFractionDigits: 2,
|
|
131
|
+
// });
|
|
132
|
+
// } else {
|
|
133
|
+
// return blankOrNullValueFormatter(params);
|
|
134
|
+
// }
|
|
135
|
+
// } else if (dataType === 'date') {
|
|
136
|
+
// return formatTime(params, timezone);
|
|
137
|
+
// }
|
|
138
|
+
// else {
|
|
139
|
+
// return blankOrNullValueFormatter(params);
|
|
140
|
+
// }
|
|
141
|
+
// }
|
|
142
142
|
window.cellClickEvent = (columnName, value, idValue) => {
|
|
143
143
|
this.set('fields', {"field": columnName, "data": value});
|
|
144
144
|
this.set('id', idValue);
|
|
@@ -169,10 +169,7 @@ dmx.Component('ag-grid', {
|
|
|
169
169
|
function checkboxCellRenderer(params) {
|
|
170
170
|
const idValue = params.data.id;
|
|
171
171
|
const columnName = params.colDef.field;
|
|
172
|
-
const
|
|
173
|
-
const value = formatValue(params.value, columnName, dataType, timezone);
|
|
174
|
-
|
|
175
|
-
if (columnName == "status" && enableStatusToggle) {
|
|
172
|
+
const value = params.value;
|
|
176
173
|
// Assuming `value` is a boolean representing the status
|
|
177
174
|
const checked = value==true ? "checked" : "";
|
|
178
175
|
return `
|
|
@@ -192,9 +189,6 @@ dmx.Component('ag-grid', {
|
|
|
192
189
|
</span>
|
|
193
190
|
</label>
|
|
194
191
|
`;
|
|
195
|
-
} else {
|
|
196
|
-
return value;
|
|
197
|
-
}
|
|
198
192
|
}
|
|
199
193
|
|
|
200
194
|
|
|
@@ -254,6 +248,25 @@ dmx.Component('ag-grid', {
|
|
|
254
248
|
}
|
|
255
249
|
}
|
|
256
250
|
}
|
|
251
|
+
dateFilterParams = {
|
|
252
|
+
comparator: function (filterLocalDateAtMidnight, cellValue) {
|
|
253
|
+
var cellDate = new Date(cellValue);
|
|
254
|
+
var filterDate = new Date(filterLocalDateAtMidnight);
|
|
255
|
+
|
|
256
|
+
// Compare the date portion of the cell value with the filter value
|
|
257
|
+
var cellDateOnly = new Date(cellDate.getFullYear(), cellDate.getMonth(), cellDate.getDate());
|
|
258
|
+
var filterDateOnly = new Date(filterDate.getFullYear(), filterDate.getMonth(), filterDate.getDate());
|
|
259
|
+
|
|
260
|
+
if (cellDateOnly < filterDateOnly) {
|
|
261
|
+
return -1;
|
|
262
|
+
} else if (cellDateOnly > filterDateOnly) {
|
|
263
|
+
return 1;
|
|
264
|
+
} else {
|
|
265
|
+
return 0;
|
|
266
|
+
}
|
|
267
|
+
},
|
|
268
|
+
browserDatePicker: true,
|
|
269
|
+
}
|
|
257
270
|
// Function to detect the data type based on the values
|
|
258
271
|
function detectDataType(values) {
|
|
259
272
|
let hasDate = false;
|
|
@@ -304,6 +317,8 @@ dmx.Component('ag-grid', {
|
|
|
304
317
|
let valueGetter;
|
|
305
318
|
let filterValueGetter;
|
|
306
319
|
let valueFormatter;
|
|
320
|
+
let filterParams;
|
|
321
|
+
let minWidth;
|
|
307
322
|
|
|
308
323
|
|
|
309
324
|
if (dataType === 'number') {
|
|
@@ -324,9 +339,13 @@ dmx.Component('ag-grid', {
|
|
|
324
339
|
} else if (dataType === 'date') {
|
|
325
340
|
filter = 'agDateColumnFilter';
|
|
326
341
|
valueFormatter = (params) => formatTime(params, timezone);
|
|
342
|
+
filterParams = dateFilterParams;
|
|
343
|
+
minWidth = 200;
|
|
327
344
|
} else {
|
|
328
345
|
filter = 'agTextColumnFilter';
|
|
329
346
|
valueFormatter = blankOrNullValueFormatter;
|
|
347
|
+
filterParams = undefined;
|
|
348
|
+
minWidth = undefined;
|
|
330
349
|
}
|
|
331
350
|
// Check if custom definition exists for the current field
|
|
332
351
|
if (this.props.definitions && this.props.definitions[key]) {
|
|
@@ -389,26 +408,34 @@ dmx.Component('ag-grid', {
|
|
|
389
408
|
enableRowClickEvent = this.props.row_click_event;
|
|
390
409
|
enableCellClickEvent = this.props.cell_click_event;
|
|
391
410
|
if (cnames.hasOwnProperty(key)) {
|
|
392
|
-
console.log(key)
|
|
393
411
|
const cname = cnames[key]
|
|
394
412
|
headerName = cname ? cname.custom_name : humanize(key);
|
|
395
413
|
}
|
|
396
414
|
else {
|
|
397
415
|
headerName = humanize(key);
|
|
398
416
|
}
|
|
417
|
+
if (key =='status' && enableStatusToggle) {
|
|
418
|
+
cellRenderer = 'checkboxCellRenderer';
|
|
419
|
+
}
|
|
420
|
+
else {
|
|
421
|
+
cellRenderer = undefined;
|
|
422
|
+
}
|
|
423
|
+
|
|
399
424
|
return {
|
|
400
425
|
headerName: headerName,
|
|
401
426
|
field: key,
|
|
402
427
|
filter: filter,
|
|
403
428
|
valueFormatter: valueFormatter,
|
|
404
429
|
valueGetter: valueGetter,
|
|
430
|
+
minWidth: minWidth,
|
|
405
431
|
filterValueGetter: filterValueGetter,
|
|
432
|
+
filterParams: filterParams,
|
|
406
433
|
cellStyle: applyCellStyle,
|
|
407
434
|
...(cwidths.hasOwnProperty(key) && {
|
|
408
435
|
minWidth: parseInt(cwidths[key].min_width),
|
|
409
436
|
maxWidth: parseInt(cwidths[key].max_width),
|
|
410
437
|
}),
|
|
411
|
-
cellRenderer:
|
|
438
|
+
cellRenderer: cellRenderer
|
|
412
439
|
};
|
|
413
440
|
});
|
|
414
441
|
}
|