@cdmx/wappler_ag_grid 0.8.9 → 0.9.0
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 +23 -1
- package/dmx-ag-grid.js +42 -1
- package/package.json +3 -2
|
@@ -32,6 +32,11 @@
|
|
|
32
32
|
"name": "fields",
|
|
33
33
|
"title": "Fields",
|
|
34
34
|
"type": "object"
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
"name": "fileData",
|
|
38
|
+
"title": "fileData",
|
|
39
|
+
"type": "array"
|
|
35
40
|
}
|
|
36
41
|
],
|
|
37
42
|
"outputType": "object",
|
|
@@ -55,7 +60,6 @@
|
|
|
55
60
|
"type": "text",
|
|
56
61
|
"dataBindings": true,
|
|
57
62
|
"defaultValue": [],
|
|
58
|
-
"required": true,
|
|
59
63
|
"help": "Enter Data Source"
|
|
60
64
|
},
|
|
61
65
|
{
|
|
@@ -1844,6 +1848,15 @@
|
|
|
1844
1848
|
state: 'opened',
|
|
1845
1849
|
help: 'Save Column State to Browser Local Storage',
|
|
1846
1850
|
properties: []
|
|
1851
|
+
},
|
|
1852
|
+
{
|
|
1853
|
+
addTitle: 'importFileData',
|
|
1854
|
+
title: 'Import File Data',
|
|
1855
|
+
name: 'importFileData',
|
|
1856
|
+
icon: 'fa fa-lg fa-undo',
|
|
1857
|
+
state: 'opened',
|
|
1858
|
+
help: 'Import File Data to Grid',
|
|
1859
|
+
properties: []
|
|
1847
1860
|
}
|
|
1848
1861
|
],
|
|
1849
1862
|
"children": [],
|
|
@@ -1853,6 +1866,10 @@
|
|
|
1853
1866
|
"src": "../../../node_modules/ag-grid-community/dist/ag-grid-community.min.js",
|
|
1854
1867
|
"dst": "js/ag-grid-community.min.js"
|
|
1855
1868
|
},
|
|
1869
|
+
{
|
|
1870
|
+
"src": "../../../node_modules/papaparse/papaparse.js",
|
|
1871
|
+
"dst": "js/papaparse.js"
|
|
1872
|
+
},
|
|
1856
1873
|
{
|
|
1857
1874
|
"src": "../../../node_modules/ag-grid-community/styles/ag-theme-alpine.css",
|
|
1858
1875
|
"dst": "css/ag-theme-alpine.css"
|
|
@@ -1888,6 +1905,11 @@
|
|
|
1888
1905
|
"type": "js",
|
|
1889
1906
|
"defer": true
|
|
1890
1907
|
},
|
|
1908
|
+
{
|
|
1909
|
+
"src": "js/papaparse.js",
|
|
1910
|
+
"type": "js",
|
|
1911
|
+
"defer": true
|
|
1912
|
+
},
|
|
1891
1913
|
{
|
|
1892
1914
|
"src": "js/dmx-ag-grid.js",
|
|
1893
1915
|
"type": "js",
|
package/dmx-ag-grid.js
CHANGED
|
@@ -3,7 +3,8 @@ dmx.Component('ag-grid', {
|
|
|
3
3
|
id: null,
|
|
4
4
|
data: {},
|
|
5
5
|
count: Number,
|
|
6
|
-
fields: {}
|
|
6
|
+
fields: {},
|
|
7
|
+
fileData: []
|
|
7
8
|
},
|
|
8
9
|
|
|
9
10
|
attributes: {
|
|
@@ -186,6 +187,13 @@ dmx.Component('ag-grid', {
|
|
|
186
187
|
let gridInstance = this.refreshGrid();
|
|
187
188
|
this.set('gridInstance', gridInstance);
|
|
188
189
|
}, this);
|
|
190
|
+
},
|
|
191
|
+
importFileData: function () {
|
|
192
|
+
this.parseFileData();
|
|
193
|
+
dmx.nextTick(function() {
|
|
194
|
+
let gridInstance = this.refreshGrid();
|
|
195
|
+
this.set('gridInstance', gridInstance);
|
|
196
|
+
}, this);
|
|
189
197
|
}
|
|
190
198
|
},
|
|
191
199
|
|
|
@@ -219,7 +227,40 @@ dmx.Component('ag-grid', {
|
|
|
219
227
|
console.error('AG Grid instance or transaction not found.');
|
|
220
228
|
}
|
|
221
229
|
},
|
|
230
|
+
parseFileData: async function (options) {
|
|
231
|
+
const parseCSV = (csvData) => {
|
|
232
|
+
return new Promise((resolve, reject) => {
|
|
233
|
+
Papa.parse(csvData, {
|
|
234
|
+
header: true,
|
|
235
|
+
dynamicTyping: true,
|
|
236
|
+
complete: function (results) {
|
|
237
|
+
resolve(results.data);
|
|
238
|
+
},
|
|
239
|
+
error: function (error) {
|
|
240
|
+
reject(error.message);
|
|
241
|
+
}
|
|
242
|
+
});
|
|
243
|
+
});
|
|
244
|
+
};
|
|
245
|
+
const fileInput = document.getElementById('csv-file');
|
|
246
|
+
const file = fileInput.files[0];
|
|
247
|
+
if (!file) {
|
|
248
|
+
console.error('Please select a CSV file.');
|
|
249
|
+
return;
|
|
250
|
+
}
|
|
222
251
|
|
|
252
|
+
const reader = new FileReader();
|
|
253
|
+
reader.onload = async (e) => {
|
|
254
|
+
const csvData = e.target.result;
|
|
255
|
+
try {
|
|
256
|
+
const parsedData = await parseCSV(csvData);
|
|
257
|
+
this.set('fileData', parsedData);
|
|
258
|
+
} catch (error) {
|
|
259
|
+
console.error('Error parsing CSV:', error);
|
|
260
|
+
}
|
|
261
|
+
};
|
|
262
|
+
reader.readAsText(file);
|
|
263
|
+
},
|
|
223
264
|
refreshGrid: function () {
|
|
224
265
|
const options = this.props
|
|
225
266
|
const rowData = this.props.data;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cdmx/wappler_ag_grid",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.9.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "App Connect module for AG Grid Table Generation.",
|
|
6
6
|
"license": "MIT",
|
|
@@ -14,7 +14,8 @@
|
|
|
14
14
|
"ag-grid"
|
|
15
15
|
],
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"ag-grid-community": "30.1.x"
|
|
17
|
+
"ag-grid-community": "30.1.x",
|
|
18
|
+
"papaparse": "^5.4.1"
|
|
18
19
|
},
|
|
19
20
|
"scripts": {
|
|
20
21
|
"build": "rollup --config",
|