blixify-ui-web 0.1.71 → 0.1.73
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/lib/components/data/dataTemplate/index.d.ts +1 -0
- package/lib/components/data/dataTemplate/index.d.ts.map +1 -1
- package/lib/components/data/dataTemplate/index.js +486 -77
- package/lib/components/data/dataTemplate/index.js.map +1 -1
- package/lib/components/data/dataTemplate/model.d.ts +3 -3
- package/lib/components/data/dataTemplate/model.d.ts.map +1 -1
- package/lib/components/display/emptyState/index.d.ts +1 -0
- package/lib/components/display/emptyState/index.d.ts.map +1 -1
- package/lib/components/display/emptyState/index.js +2 -1
- package/lib/components/display/emptyState/index.js.map +1 -1
- package/lib/components/input/textArea/index.d.ts +1 -0
- package/lib/components/input/textArea/index.d.ts.map +1 -1
- package/lib/components/input/textArea/index.js +1 -0
- package/lib/components/input/textArea/index.js.map +1 -1
- package/lib/components/input/uploadInput/index.js +1 -1
- package/lib/components/input/uploadInput/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -72,6 +72,7 @@ var button_1 = require("../../action/button");
|
|
|
72
72
|
var iconButton_1 = require("../../action/iconButton");
|
|
73
73
|
var popUp_1 = require("../../advanced/popUp");
|
|
74
74
|
var detailList_1 = require("../../display/detailList");
|
|
75
|
+
var emptyState_1 = require("../../display/emptyState");
|
|
75
76
|
var list_1 = require("../../display/list");
|
|
76
77
|
var loading_1 = require("../../display/loading");
|
|
77
78
|
var modal_1 = require("../../display/modal");
|
|
@@ -92,45 +93,97 @@ var readQuery_1 = require("../readQuery");
|
|
|
92
93
|
var readQueryHoc_1 = require("../readQueryHoc");
|
|
93
94
|
var utils_2 = require("../utils");
|
|
94
95
|
var writeQuery_1 = require("../writeQuery");
|
|
96
|
+
var queryTableHeader = [
|
|
97
|
+
{
|
|
98
|
+
key: "name",
|
|
99
|
+
title: "Query",
|
|
100
|
+
},
|
|
101
|
+
{
|
|
102
|
+
key: "value",
|
|
103
|
+
title: "Value",
|
|
104
|
+
},
|
|
105
|
+
{
|
|
106
|
+
key: "sort",
|
|
107
|
+
title: "Sort",
|
|
108
|
+
},
|
|
109
|
+
{
|
|
110
|
+
key: "view",
|
|
111
|
+
title: "View",
|
|
112
|
+
},
|
|
113
|
+
{
|
|
114
|
+
key: "del",
|
|
115
|
+
title: "Delete",
|
|
116
|
+
},
|
|
117
|
+
];
|
|
118
|
+
var queryType = [
|
|
119
|
+
{
|
|
120
|
+
key: "=",
|
|
121
|
+
label: "=",
|
|
122
|
+
},
|
|
123
|
+
{
|
|
124
|
+
key: ">",
|
|
125
|
+
label: ">",
|
|
126
|
+
},
|
|
127
|
+
{
|
|
128
|
+
key: "<",
|
|
129
|
+
label: "<",
|
|
130
|
+
},
|
|
131
|
+
{
|
|
132
|
+
key: "><",
|
|
133
|
+
label: "><",
|
|
134
|
+
},
|
|
135
|
+
];
|
|
95
136
|
function DataTemplate(props) {
|
|
96
137
|
var _this = this;
|
|
97
|
-
var _a, _b, _c, _d, _e;
|
|
138
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
98
139
|
var formRef = (0, react_1.createRef)();
|
|
99
140
|
var objectFormRef = (0, react_1.createRef)();
|
|
100
141
|
var typingTimeout = (0, react_1.useRef)();
|
|
101
142
|
var modalFormInputRefs = props.model.map(function () { return (0, react_1.createRef)(); });
|
|
102
143
|
var limit = props.limit ? props.limit : 10;
|
|
103
|
-
var
|
|
144
|
+
var _h = (0, react_1.useState)(false), loading = _h[0], setLoading = _h[1];
|
|
104
145
|
//INFO : Used by List
|
|
105
|
-
var
|
|
106
|
-
var
|
|
107
|
-
var
|
|
108
|
-
var
|
|
109
|
-
var
|
|
110
|
-
var
|
|
111
|
-
var
|
|
112
|
-
var
|
|
113
|
-
var
|
|
114
|
-
var
|
|
115
|
-
var
|
|
116
|
-
var
|
|
117
|
-
var
|
|
118
|
-
var
|
|
119
|
-
var
|
|
120
|
-
var
|
|
121
|
-
var
|
|
122
|
-
var
|
|
146
|
+
var _j = (0, react_1.useState)(""), filterSearch = _j[0], setFilterSearch = _j[1];
|
|
147
|
+
var _k = (0, react_1.useState)(""), filterSearchParams = _k[0], setFilterSearchParams = _k[1];
|
|
148
|
+
var _l = (0, react_1.useState)(""), filterSelection = _l[0], setFilterSelection = _l[1];
|
|
149
|
+
var _m = (0, react_1.useState)(""), filterReference = _m[0], setFilterReference = _m[1];
|
|
150
|
+
var _o = (0, react_1.useState)(""), filterReferenceSearch = _o[0], setFilterReferenceSearch = _o[1];
|
|
151
|
+
var _p = (0, react_1.useState)([]), filterReferenceList = _p[0], setFilterReferenceList = _p[1];
|
|
152
|
+
var _q = (0, react_1.useState)(true), tableLoading = _q[0], setTableLoading = _q[1];
|
|
153
|
+
var _r = (0, react_1.useState)(""), cursor = _r[0], setCursor = _r[1];
|
|
154
|
+
var _s = (0, react_1.useState)(""), lastCursor = _s[0], setLastCursor = _s[1];
|
|
155
|
+
var _t = (0, react_1.useState)([]), data = _t[0], setData = _t[1];
|
|
156
|
+
var _u = (0, react_1.useState)(0), size = _u[0], setSize = _u[1];
|
|
157
|
+
var _v = (0, react_1.useState)(0), pageIndex = _v[0], setPageIndex = _v[1];
|
|
158
|
+
var _w = (0, react_1.useState)(null), csvFile = _w[0], setCSVFile = _w[1];
|
|
159
|
+
var _x = (0, react_1.useState)([]), csvFileData = _x[0], setCSVFileData = _x[1];
|
|
160
|
+
var _y = (0, react_1.useState)(0), stepCSVIndex = _y[0], setStepCSVIndex = _y[1];
|
|
161
|
+
var _z = (0, react_1.useState)({}), listCSVMapAttribute = _z[0], setListCSVMapAttribute = _z[1];
|
|
162
|
+
var _0 = (0, react_1.useState)({}), listCSVObjAttribute = _0[0], setListCSVObjAttribute = _0[1];
|
|
163
|
+
var _1 = (0, react_1.useState)([]), csvAPIAttribute = _1[0], setCSVAPIAttribute = _1[1];
|
|
164
|
+
var _2 = (0, react_1.useState)(""), exportLink = _2[0], setExportLink = _2[1];
|
|
165
|
+
var _3 = (0, react_1.useState)([]), exportReferenceList = _3[0], setExportReferenceList = _3[1];
|
|
166
|
+
var _4 = (0, react_1.useState)(""), exportReferenceSearch = _4[0], setExportReferenceSearch = _4[1];
|
|
167
|
+
var _5 = (0, react_1.useState)(), notification = _5[0], setNotification = _5[1];
|
|
123
168
|
//INFO : Used by Read
|
|
124
169
|
//INFO : Used by Update
|
|
125
|
-
var
|
|
126
|
-
var
|
|
127
|
-
var
|
|
128
|
-
var
|
|
129
|
-
var
|
|
130
|
-
var
|
|
131
|
-
var
|
|
132
|
-
var
|
|
133
|
-
var
|
|
170
|
+
var _6 = (0, react_1.useState)(false), modalVisible = _6[0], setModalVisible = _6[1];
|
|
171
|
+
var _7 = (0, react_1.useState)(false), excelModal = _7[0], setExcelModal = _7[1];
|
|
172
|
+
var _8 = (0, react_1.useState)(false), exportExcel = _8[0], setExportExcel = _8[1];
|
|
173
|
+
var _9 = (0, react_1.useState)({}), selectedData = _9[0], setSelectedData = _9[1];
|
|
174
|
+
var _10 = (0, react_1.useState)(""), selectedObjectStructureId = _10[0], setSelectedObjectStructureId = _10[1];
|
|
175
|
+
var _11 = (0, react_1.useState)(""), selectedObjectId = _11[0], setSelectedObjectId = _11[1];
|
|
176
|
+
var _12 = (0, react_1.useState)({}), selectedObjectData = _12[0], setSelectedObjectData = _12[1];
|
|
177
|
+
var _13 = (0, react_1.useState)({}), referenceModelSchema = _13[0], setReferenceSchema = _13[1];
|
|
178
|
+
var _14 = (0, react_1.useState)({}), referenceOptions = _14[0], setReferenceOptions = _14[1];
|
|
179
|
+
var _15 = (0, react_1.useState)({}), referenceSearchText = _15[0], setReferenceSearchText = _15[1];
|
|
180
|
+
var _16 = (0, react_1.useState)([]), queryList = _16[0], setQueryList = _16[1];
|
|
181
|
+
var _17 = (0, react_1.useState)(false), queryModal = _17[0], setQueryModal = _17[1];
|
|
182
|
+
var _18 = (0, react_1.useState)({
|
|
183
|
+
queryId: "",
|
|
184
|
+
type: "=",
|
|
185
|
+
value: "",
|
|
186
|
+
}), queryInput = _18[0], setQueryInput = _18[1];
|
|
134
187
|
var dbModule = props.server === "firebase" ? (_a = props.lib) === null || _a === void 0 ? void 0 : _a.firebase : (_b = props.lib) === null || _b === void 0 ? void 0 : _b.axios;
|
|
135
188
|
var writeServerQuery = new writeQuery_1.WriteQuery((_c = props.lib) === null || _c === void 0 ? void 0 : _c.axios, props.server, props.collectionId, props.dbEndpoint);
|
|
136
189
|
var moreButtonPopUp = [
|
|
@@ -141,6 +194,13 @@ function DataTemplate(props) {
|
|
|
141
194
|
setModalVisible(true);
|
|
142
195
|
},
|
|
143
196
|
},
|
|
197
|
+
{
|
|
198
|
+
text: "Export Excel",
|
|
199
|
+
onClick: function () {
|
|
200
|
+
setExportExcel(true);
|
|
201
|
+
setModalVisible(true);
|
|
202
|
+
},
|
|
203
|
+
},
|
|
144
204
|
];
|
|
145
205
|
(0, react_1.useEffect)(function () {
|
|
146
206
|
switch (props.type) {
|
|
@@ -157,6 +217,86 @@ function DataTemplate(props) {
|
|
|
157
217
|
break;
|
|
158
218
|
}
|
|
159
219
|
}, [props.type, props.id]);
|
|
220
|
+
(0, react_1.useEffect)(function () {
|
|
221
|
+
var handleGetExportReferenceList = function () { return __awaiter(_this, void 0, void 0, function () {
|
|
222
|
+
var referenceOptionsList;
|
|
223
|
+
var _this = this;
|
|
224
|
+
return __generator(this, function (_a) {
|
|
225
|
+
switch (_a.label) {
|
|
226
|
+
case 0:
|
|
227
|
+
referenceOptionsList = [];
|
|
228
|
+
return [4 /*yield*/, Promise.all(props.model.map(function (eachModel) { return __awaiter(_this, void 0, void 0, function () {
|
|
229
|
+
var referenceRQ, query, referenceData, clonedQueryInput;
|
|
230
|
+
var _a, _b;
|
|
231
|
+
return __generator(this, function (_c) {
|
|
232
|
+
switch (_c.label) {
|
|
233
|
+
case 0:
|
|
234
|
+
if (!(queryInput.queryId === eachModel.id)) return [3 /*break*/, 3];
|
|
235
|
+
if (!(eachModel.type === "reference" ||
|
|
236
|
+
eachModel.type === "listReference")) return [3 /*break*/, 2];
|
|
237
|
+
referenceRQ = new readQuery_1.ReadQuery(dbModule, props.server, (_a = eachModel.referenceSpaceId) !== null && _a !== void 0 ? _a : "", props.dbEndpoint);
|
|
238
|
+
query = [];
|
|
239
|
+
if (exportReferenceSearch) {
|
|
240
|
+
query.push({
|
|
241
|
+
type: "search",
|
|
242
|
+
value: exportReferenceSearch,
|
|
243
|
+
searchIds: [(_b = eachModel.referenceLabel) !== null && _b !== void 0 ? _b : "_id"],
|
|
244
|
+
});
|
|
245
|
+
}
|
|
246
|
+
return [4 /*yield*/, referenceRQ.call({
|
|
247
|
+
type: "list",
|
|
248
|
+
limit: 10,
|
|
249
|
+
query: query,
|
|
250
|
+
})];
|
|
251
|
+
case 1:
|
|
252
|
+
referenceData = _c.sent();
|
|
253
|
+
referenceData.data.map(function (eachData) {
|
|
254
|
+
var _a, _b;
|
|
255
|
+
var data = JSON.parse(JSON.stringify(eachData));
|
|
256
|
+
var id = props.server === "mongoServer" ? data["_id"] : data["id"];
|
|
257
|
+
referenceOptionsList.push({
|
|
258
|
+
key: id,
|
|
259
|
+
label: (_b = data[(_a = eachModel.referenceLabel) !== null && _a !== void 0 ? _a : ""]) !== null && _b !== void 0 ? _b : id,
|
|
260
|
+
});
|
|
261
|
+
return "";
|
|
262
|
+
});
|
|
263
|
+
return [3 /*break*/, 3];
|
|
264
|
+
case 2:
|
|
265
|
+
if (eachModel.type === "date" && !queryInput.value) {
|
|
266
|
+
clonedQueryInput = JSON.parse(JSON.stringify(queryInput));
|
|
267
|
+
clonedQueryInput["value"] = (0, moment_1.default)().toISOString();
|
|
268
|
+
setQueryInput(clonedQueryInput);
|
|
269
|
+
}
|
|
270
|
+
_c.label = 3;
|
|
271
|
+
case 3: return [2 /*return*/];
|
|
272
|
+
}
|
|
273
|
+
});
|
|
274
|
+
}); }))];
|
|
275
|
+
case 1:
|
|
276
|
+
_a.sent();
|
|
277
|
+
setExportReferenceList(referenceOptionsList);
|
|
278
|
+
return [2 /*return*/];
|
|
279
|
+
}
|
|
280
|
+
});
|
|
281
|
+
}); };
|
|
282
|
+
if (queryInput.type === "><" && !Array.isArray(queryInput.value)) {
|
|
283
|
+
var clonedQueryInput = JSON.parse(JSON.stringify(queryInput));
|
|
284
|
+
var dates = [];
|
|
285
|
+
dates.push((0, moment_1.default)().toISOString());
|
|
286
|
+
dates.push((0, moment_1.default)().toISOString());
|
|
287
|
+
clonedQueryInput["value"] = dates;
|
|
288
|
+
setQueryInput(clonedQueryInput);
|
|
289
|
+
}
|
|
290
|
+
handleGetExportReferenceList();
|
|
291
|
+
}, [
|
|
292
|
+
queryInput,
|
|
293
|
+
exportReferenceSearch,
|
|
294
|
+
dbModule,
|
|
295
|
+
props.dbEndpoint,
|
|
296
|
+
props.model,
|
|
297
|
+
props.server,
|
|
298
|
+
]);
|
|
299
|
+
var queryIdOptions = [];
|
|
160
300
|
//SECTION - List
|
|
161
301
|
var handlePagination = function (value) {
|
|
162
302
|
if (props.server === "mongoServer") {
|
|
@@ -207,7 +347,7 @@ function DataTemplate(props) {
|
|
|
207
347
|
dataList = _b.sent();
|
|
208
348
|
_b.label = 6;
|
|
209
349
|
case 6:
|
|
210
|
-
setData(
|
|
350
|
+
setData(filterSearchParams ? dataList : dataList.concat(data));
|
|
211
351
|
setCursor(responseData.count);
|
|
212
352
|
_b.label = 7;
|
|
213
353
|
case 7:
|
|
@@ -216,10 +356,45 @@ function DataTemplate(props) {
|
|
|
216
356
|
}
|
|
217
357
|
});
|
|
218
358
|
}); };
|
|
359
|
+
var handleExportCSVData = function () { return __awaiter(_this, void 0, void 0, function () {
|
|
360
|
+
var res, err_1;
|
|
361
|
+
var _a, _b, _c;
|
|
362
|
+
return __generator(this, function (_d) {
|
|
363
|
+
switch (_d.label) {
|
|
364
|
+
case 0:
|
|
365
|
+
_d.trys.push([0, 2, , 3]);
|
|
366
|
+
setLoading(true);
|
|
367
|
+
return [4 /*yield*/, ((_b = (_a = props.lib) === null || _a === void 0 ? void 0 : _a.axios) === null || _b === void 0 ? void 0 : _b.post("".concat(props.schemaEndpoint, "/csv/export"), {
|
|
368
|
+
data: { spaceId: props.collectionId, query: queryList },
|
|
369
|
+
}, {
|
|
370
|
+
headers: {
|
|
371
|
+
"Content-Type": "multipart/form-data",
|
|
372
|
+
},
|
|
373
|
+
}))];
|
|
374
|
+
case 1:
|
|
375
|
+
res = _d.sent();
|
|
376
|
+
setExportLink((_c = res === null || res === void 0 ? void 0 : res.data.link) !== null && _c !== void 0 ? _c : "");
|
|
377
|
+
setNotification({
|
|
378
|
+
type: true,
|
|
379
|
+
title: "Export Successfully",
|
|
380
|
+
msg: "A download link had been generated.",
|
|
381
|
+
});
|
|
382
|
+
setLoading(false);
|
|
383
|
+
return [3 /*break*/, 3];
|
|
384
|
+
case 2:
|
|
385
|
+
err_1 = _d.sent();
|
|
386
|
+
return [3 /*break*/, 3];
|
|
387
|
+
case 3: return [2 /*return*/];
|
|
388
|
+
}
|
|
389
|
+
});
|
|
390
|
+
}); };
|
|
219
391
|
var handleGetItemError = function () {
|
|
220
392
|
setTableLoading(false);
|
|
221
393
|
setModalVisible(false);
|
|
222
394
|
setLoading(false);
|
|
395
|
+
if (props.type === "update" || props.type === "read") {
|
|
396
|
+
handleNavigate();
|
|
397
|
+
}
|
|
223
398
|
};
|
|
224
399
|
//SECTION - CSV
|
|
225
400
|
var handleOnChangeCSV = function (e) {
|
|
@@ -252,7 +427,7 @@ function DataTemplate(props) {
|
|
|
252
427
|
}
|
|
253
428
|
};
|
|
254
429
|
var handleStepCSV = function () { return __awaiter(_this, void 0, void 0, function () {
|
|
255
|
-
var csvList_1, _loop_1, _i, _a, _b, eachKey, eachValue, valid_1, errorValue_1, response,
|
|
430
|
+
var csvList_1, _loop_1, _i, _a, _b, eachKey, eachValue, valid_1, errorValue_1, response, err_2;
|
|
256
431
|
var _c, _d, _e, _f, _g;
|
|
257
432
|
return __generator(this, function (_h) {
|
|
258
433
|
switch (_h.label) {
|
|
@@ -374,17 +549,86 @@ function DataTemplate(props) {
|
|
|
374
549
|
_h.label = 5;
|
|
375
550
|
case 5: return [3 /*break*/, 7];
|
|
376
551
|
case 6:
|
|
377
|
-
|
|
552
|
+
err_2 = _h.sent();
|
|
378
553
|
setNotification({
|
|
379
554
|
type: false,
|
|
380
555
|
title: "Import Error",
|
|
381
|
-
msg:
|
|
556
|
+
msg: err_2.message,
|
|
382
557
|
});
|
|
383
558
|
return [3 /*break*/, 7];
|
|
384
559
|
case 7: return [2 /*return*/];
|
|
385
560
|
}
|
|
386
561
|
});
|
|
387
562
|
}); };
|
|
563
|
+
var handleQueryModal = function () {
|
|
564
|
+
setQueryModal(!queryModal);
|
|
565
|
+
setQueryInput({
|
|
566
|
+
queryId: "",
|
|
567
|
+
type: "=",
|
|
568
|
+
value: "",
|
|
569
|
+
});
|
|
570
|
+
setExportReferenceList([]);
|
|
571
|
+
setExportReferenceSearch("");
|
|
572
|
+
};
|
|
573
|
+
var handleCloneQueryList = function () {
|
|
574
|
+
var _a;
|
|
575
|
+
var clonedQueryInput = (_a = JSON.parse(JSON.stringify(queryList))) !== null && _a !== void 0 ? _a : [];
|
|
576
|
+
clonedQueryInput.map(function (eachQuery) {
|
|
577
|
+
var tempValue = eachQuery.value;
|
|
578
|
+
if (tempValue === "false" || tempValue === "true") {
|
|
579
|
+
tempValue = tempValue === "false" ? false : true;
|
|
580
|
+
}
|
|
581
|
+
else if (!isNaN(tempValue)) {
|
|
582
|
+
tempValue = Number(tempValue);
|
|
583
|
+
}
|
|
584
|
+
eachQuery.value = tempValue;
|
|
585
|
+
return null;
|
|
586
|
+
});
|
|
587
|
+
return clonedQueryInput;
|
|
588
|
+
};
|
|
589
|
+
var handlePushQueryList = function () {
|
|
590
|
+
var tempQueryList = handleCloneQueryList();
|
|
591
|
+
if (!tempQueryList.some(function (eachQuery) { return eachQuery.queryId === queryInput.queryId; })) {
|
|
592
|
+
var tempValue = queryInput.value;
|
|
593
|
+
if (tempValue === "false" || tempValue === "true") {
|
|
594
|
+
tempValue = tempValue === "false" ? false : true;
|
|
595
|
+
}
|
|
596
|
+
else if (!isNaN(tempValue)) {
|
|
597
|
+
tempValue = Number(tempValue);
|
|
598
|
+
}
|
|
599
|
+
queryInput.value = tempValue;
|
|
600
|
+
tempQueryList.push(queryInput);
|
|
601
|
+
setQueryModal(!queryModal);
|
|
602
|
+
setQueryList(tempQueryList);
|
|
603
|
+
setQueryInput({
|
|
604
|
+
queryId: "",
|
|
605
|
+
type: "=",
|
|
606
|
+
value: "",
|
|
607
|
+
});
|
|
608
|
+
}
|
|
609
|
+
else {
|
|
610
|
+
// NOTIFICATION - CONISTS
|
|
611
|
+
setNotification({
|
|
612
|
+
type: false,
|
|
613
|
+
title: "Export Failed",
|
|
614
|
+
msg: "Please check again your query attribute.",
|
|
615
|
+
});
|
|
616
|
+
}
|
|
617
|
+
};
|
|
618
|
+
var handleViewQuery = function (index) {
|
|
619
|
+
handleQueryModal();
|
|
620
|
+
setQueryInput(queryList[index]);
|
|
621
|
+
};
|
|
622
|
+
var handleSortQuery = function (index, sortType) {
|
|
623
|
+
var _a;
|
|
624
|
+
var sortList = JSON.parse(JSON.stringify(queryList));
|
|
625
|
+
var ascIndex = sortType === "up" ? index - 1 : index + 1;
|
|
626
|
+
_a = [
|
|
627
|
+
sortList[ascIndex],
|
|
628
|
+
sortList[index],
|
|
629
|
+
], sortList[index] = _a[0], sortList[ascIndex] = _a[1];
|
|
630
|
+
setQueryList(sortList);
|
|
631
|
+
};
|
|
388
632
|
//Section - Update
|
|
389
633
|
var handleRetrieveSelectedData = function (responseData) { return __awaiter(_this, void 0, void 0, function () {
|
|
390
634
|
var dummyRespData, dummyReferenceModelSchema, newRespData, _a;
|
|
@@ -452,6 +696,7 @@ function DataTemplate(props) {
|
|
|
452
696
|
defaultValue[eachAttribute.id];
|
|
453
697
|
break;
|
|
454
698
|
case "image":
|
|
699
|
+
case "file":
|
|
455
700
|
clonedSelectedData[eachAttribute.id] = defaultValue[eachAttribute.id];
|
|
456
701
|
break;
|
|
457
702
|
case "number":
|
|
@@ -532,7 +777,7 @@ function DataTemplate(props) {
|
|
|
532
777
|
setReferenceSearchText(clonedSearchText);
|
|
533
778
|
};
|
|
534
779
|
var handleGetReferenceOptions = function (dataList, dataStructure, label, currentData) { return __awaiter(_this, void 0, void 0, function () {
|
|
535
|
-
var optionList_1, clonedReferrenceOptions, referenceRQ, res,
|
|
780
|
+
var optionList_1, clonedReferrenceOptions, referenceRQ, res, err_3;
|
|
536
781
|
var _a;
|
|
537
782
|
return __generator(this, function (_b) {
|
|
538
783
|
switch (_b.label) {
|
|
@@ -541,10 +786,11 @@ function DataTemplate(props) {
|
|
|
541
786
|
optionList_1 = [];
|
|
542
787
|
clonedReferrenceOptions = JSON.parse(JSON.stringify(referenceOptions));
|
|
543
788
|
dataList.data.map(function (eachData) {
|
|
789
|
+
var _a;
|
|
544
790
|
var eachDataJSON = JSON.parse(JSON.stringify(eachData));
|
|
545
791
|
optionList_1.push({
|
|
546
792
|
key: eachData._id,
|
|
547
|
-
label: eachDataJSON[label],
|
|
793
|
+
label: (_a = eachDataJSON[label]) !== null && _a !== void 0 ? _a : eachData._id,
|
|
548
794
|
});
|
|
549
795
|
return null;
|
|
550
796
|
});
|
|
@@ -564,12 +810,13 @@ function DataTemplate(props) {
|
|
|
564
810
|
res = _b.sent();
|
|
565
811
|
if (res === null || res === void 0 ? void 0 : res.data) {
|
|
566
812
|
res.data.map(function (eachData) {
|
|
813
|
+
var _a;
|
|
567
814
|
var id = props.server === "mongoServer" ? eachData._id : eachData.id;
|
|
568
815
|
var eachDataJSON = JSON.parse(JSON.stringify(eachData));
|
|
569
816
|
if (!optionList_1.some(function (eachData) { return eachData.key === id; })) {
|
|
570
817
|
optionList_1.push({
|
|
571
818
|
key: eachData._id,
|
|
572
|
-
label: eachDataJSON[label],
|
|
819
|
+
label: (_a = eachDataJSON[label]) !== null && _a !== void 0 ? _a : eachData._id,
|
|
573
820
|
});
|
|
574
821
|
}
|
|
575
822
|
return null;
|
|
@@ -581,7 +828,7 @@ function DataTemplate(props) {
|
|
|
581
828
|
setReferenceOptions(clonedReferrenceOptions);
|
|
582
829
|
return [3 /*break*/, 4];
|
|
583
830
|
case 3:
|
|
584
|
-
|
|
831
|
+
err_3 = _b.sent();
|
|
585
832
|
return [3 /*break*/, 4];
|
|
586
833
|
case 4: return [2 /*return*/];
|
|
587
834
|
}
|
|
@@ -589,7 +836,7 @@ function DataTemplate(props) {
|
|
|
589
836
|
}); };
|
|
590
837
|
//SECTION - Assets
|
|
591
838
|
var handleUploadAxios = function (eachImageEndpoint, assetParentId, assetCollectionName, assetFileName, file) { return __awaiter(_this, void 0, void 0, function () {
|
|
592
|
-
var responseData,
|
|
839
|
+
var responseData, err_4;
|
|
593
840
|
var _a, _b;
|
|
594
841
|
return __generator(this, function (_c) {
|
|
595
842
|
switch (_c.label) {
|
|
@@ -611,7 +858,7 @@ function DataTemplate(props) {
|
|
|
611
858
|
responseData = _c.sent();
|
|
612
859
|
return [2 /*return*/, responseData];
|
|
613
860
|
case 2:
|
|
614
|
-
|
|
861
|
+
err_4 = _c.sent();
|
|
615
862
|
return [3 /*break*/, 3];
|
|
616
863
|
case 3: return [2 /*return*/];
|
|
617
864
|
}
|
|
@@ -633,7 +880,7 @@ function DataTemplate(props) {
|
|
|
633
880
|
objectAttribute.map(function (eachObject) {
|
|
634
881
|
var _a;
|
|
635
882
|
var filterImageObjectData = (_a = eachObject.objectData) === null || _a === void 0 ? void 0 : _a.filter(function (eachAttribute) {
|
|
636
|
-
return eachAttribute.type === "image";
|
|
883
|
+
return (eachAttribute.type === "image" || eachAttribute.type === "file");
|
|
637
884
|
});
|
|
638
885
|
uploadObjectAttribute[eachObject.id] = filterImageObjectData;
|
|
639
886
|
return null;
|
|
@@ -703,7 +950,7 @@ function DataTemplate(props) {
|
|
|
703
950
|
objectAttribute.map(function (eachObject) {
|
|
704
951
|
var _a;
|
|
705
952
|
var filterImageObjectData = (_a = eachObject.objectData) === null || _a === void 0 ? void 0 : _a.filter(function (eachAttribute) {
|
|
706
|
-
return eachAttribute.type === "image";
|
|
953
|
+
return (eachAttribute.type === "image" || eachAttribute.type === "file");
|
|
707
954
|
});
|
|
708
955
|
uploadObjectAttribute[eachObject.id] = filterImageObjectData;
|
|
709
956
|
return null;
|
|
@@ -787,7 +1034,7 @@ function DataTemplate(props) {
|
|
|
787
1034
|
case 1:
|
|
788
1035
|
clonedSelectedData = _a.sent();
|
|
789
1036
|
imageAttribute = props.model.filter(function (eachAttribute) {
|
|
790
|
-
return eachAttribute.type === "image";
|
|
1037
|
+
return eachAttribute.type === "image" || eachAttribute.type === "file";
|
|
791
1038
|
});
|
|
792
1039
|
return [4 /*yield*/, Promise.all(imageAttribute.map(function (eachImage) { return __awaiter(_this, void 0, void 0, function () {
|
|
793
1040
|
var responseData;
|
|
@@ -817,7 +1064,7 @@ function DataTemplate(props) {
|
|
|
817
1064
|
});
|
|
818
1065
|
}); };
|
|
819
1066
|
var handleRemoveImageAxios = function (imageEndpoint, assetParentId, assetCollectionName, assetFileName) { return __awaiter(_this, void 0, void 0, function () {
|
|
820
|
-
var
|
|
1067
|
+
var err_5;
|
|
821
1068
|
var _a, _b;
|
|
822
1069
|
return __generator(this, function (_c) {
|
|
823
1070
|
switch (_c.label) {
|
|
@@ -838,7 +1085,7 @@ function DataTemplate(props) {
|
|
|
838
1085
|
_c.sent();
|
|
839
1086
|
return [3 /*break*/, 3];
|
|
840
1087
|
case 2:
|
|
841
|
-
|
|
1088
|
+
err_5 = _c.sent();
|
|
842
1089
|
return [3 /*break*/, 3];
|
|
843
1090
|
case 3: return [2 /*return*/];
|
|
844
1091
|
}
|
|
@@ -851,7 +1098,7 @@ function DataTemplate(props) {
|
|
|
851
1098
|
switch (_a.label) {
|
|
852
1099
|
case 0:
|
|
853
1100
|
imageAttribute = props.model.filter(function (eachAttribute) {
|
|
854
|
-
return eachAttribute.type === "image";
|
|
1101
|
+
return eachAttribute.type === "image" || eachAttribute.type === "file";
|
|
855
1102
|
});
|
|
856
1103
|
return [4 /*yield*/, Promise.all(imageAttribute.map(function (eachImage) { return __awaiter(_this, void 0, void 0, function () {
|
|
857
1104
|
var _a, _b, _c, _d;
|
|
@@ -884,7 +1131,7 @@ function DataTemplate(props) {
|
|
|
884
1131
|
objectAttribute.map(function (eachObject) {
|
|
885
1132
|
var _a;
|
|
886
1133
|
var filterImageObjectData = (_a = eachObject.objectData) === null || _a === void 0 ? void 0 : _a.filter(function (eachAttribute) {
|
|
887
|
-
return eachAttribute.type === "image";
|
|
1134
|
+
return (eachAttribute.type === "image" || eachAttribute.type === "file");
|
|
888
1135
|
});
|
|
889
1136
|
uploadObjectAttribute[eachObject.id] = filterImageObjectData;
|
|
890
1137
|
return null;
|
|
@@ -1001,7 +1248,7 @@ function DataTemplate(props) {
|
|
|
1001
1248
|
};
|
|
1002
1249
|
//SECTION - CRUD
|
|
1003
1250
|
var handleRemoveSelectedData = function () { return __awaiter(_this, void 0, void 0, function () {
|
|
1004
|
-
var selectedId, res,
|
|
1251
|
+
var selectedId, res, err_6;
|
|
1005
1252
|
return __generator(this, function (_a) {
|
|
1006
1253
|
switch (_a.label) {
|
|
1007
1254
|
case 0:
|
|
@@ -1027,7 +1274,7 @@ function DataTemplate(props) {
|
|
|
1027
1274
|
_a.label = 4;
|
|
1028
1275
|
case 4: return [3 /*break*/, 6];
|
|
1029
1276
|
case 5:
|
|
1030
|
-
|
|
1277
|
+
err_6 = _a.sent();
|
|
1031
1278
|
setModalVisible(false);
|
|
1032
1279
|
setLoading(false);
|
|
1033
1280
|
return [3 /*break*/, 6];
|
|
@@ -1036,7 +1283,7 @@ function DataTemplate(props) {
|
|
|
1036
1283
|
});
|
|
1037
1284
|
}); };
|
|
1038
1285
|
var handleSubmit = function () { return __awaiter(_this, void 0, void 0, function () {
|
|
1039
|
-
var selectedId, id, createSelectedData, res,
|
|
1286
|
+
var selectedId, id, createSelectedData, res, err_7;
|
|
1040
1287
|
var _a;
|
|
1041
1288
|
return __generator(this, function (_b) {
|
|
1042
1289
|
switch (_b.label) {
|
|
@@ -1085,7 +1332,7 @@ function DataTemplate(props) {
|
|
|
1085
1332
|
}
|
|
1086
1333
|
return [3 /*break*/, 7];
|
|
1087
1334
|
case 6:
|
|
1088
|
-
|
|
1335
|
+
err_7 = _b.sent();
|
|
1089
1336
|
setModalVisible(false);
|
|
1090
1337
|
setLoading(false);
|
|
1091
1338
|
return [3 /*break*/, 7];
|
|
@@ -1095,18 +1342,23 @@ function DataTemplate(props) {
|
|
|
1095
1342
|
}); };
|
|
1096
1343
|
//SECTION - Utils
|
|
1097
1344
|
var handlePopUpModal = function (modalVisible) {
|
|
1345
|
+
setModalVisible(modalVisible);
|
|
1098
1346
|
if (!modalVisible) {
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1347
|
+
setTimeout(function () {
|
|
1348
|
+
setExcelModal(false);
|
|
1349
|
+
setExportExcel(false);
|
|
1350
|
+
setSelectedObjectStructureId("");
|
|
1351
|
+
setSelectedObjectData({});
|
|
1352
|
+
setStepCSVIndex(0);
|
|
1353
|
+
setCSVFile(null);
|
|
1354
|
+
setCSVFileData([]);
|
|
1355
|
+
setListCSVMapAttribute({});
|
|
1356
|
+
setListCSVObjAttribute({});
|
|
1357
|
+
setCSVAPIAttribute([]);
|
|
1358
|
+
setExportLink("");
|
|
1359
|
+
setQueryList([]);
|
|
1360
|
+
}, 500);
|
|
1108
1361
|
}
|
|
1109
|
-
setModalVisible(modalVisible);
|
|
1110
1362
|
};
|
|
1111
1363
|
var handleNavigate = function (link) {
|
|
1112
1364
|
var _a, _b, _c;
|
|
@@ -1127,13 +1379,14 @@ function DataTemplate(props) {
|
|
|
1127
1379
|
setTableLoading(true);
|
|
1128
1380
|
};
|
|
1129
1381
|
var handleNameSearch = function (e) {
|
|
1382
|
+
setFilterSearch(e.target.value);
|
|
1130
1383
|
handleClearDataByFilter();
|
|
1131
1384
|
if (typingTimeout.current) {
|
|
1132
1385
|
clearTimeout(typingTimeout.current);
|
|
1133
1386
|
typingTimeout.current = null;
|
|
1134
1387
|
}
|
|
1135
1388
|
typingTimeout.current = setTimeout(function () {
|
|
1136
|
-
|
|
1389
|
+
setFilterSearchParams(e.target.value);
|
|
1137
1390
|
}, 500);
|
|
1138
1391
|
};
|
|
1139
1392
|
var renderTableHeader = function () {
|
|
@@ -1179,7 +1432,7 @@ function DataTemplate(props) {
|
|
|
1179
1432
|
});
|
|
1180
1433
|
filteredModel.map(function (eachAttribute, index) {
|
|
1181
1434
|
//INFO - Default Model Contain Id While Object Type Don't have
|
|
1182
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m
|
|
1435
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
|
|
1183
1436
|
var clonedSelectedData = handleClonedDataAttribute(data, model);
|
|
1184
1437
|
var clonedReferenceOptions = JSON.parse(JSON.stringify(referenceOptions));
|
|
1185
1438
|
var clonedReferenceSearchText = JSON.parse(JSON.stringify(referenceSearchText));
|
|
@@ -1212,17 +1465,31 @@ function DataTemplate(props) {
|
|
|
1212
1465
|
break;
|
|
1213
1466
|
case "list":
|
|
1214
1467
|
case "multipleList":
|
|
1215
|
-
|
|
1468
|
+
var optionList_2 = eachAttribute.listSelection
|
|
1469
|
+
? (_c = eachAttribute.listSelection) === null || _c === void 0 ? void 0 : _c.map(function (eachAttribute) {
|
|
1216
1470
|
return {
|
|
1217
1471
|
key: eachAttribute,
|
|
1218
1472
|
label: eachAttribute,
|
|
1219
1473
|
};
|
|
1220
|
-
})
|
|
1474
|
+
})
|
|
1475
|
+
: [];
|
|
1476
|
+
if (clonedSelectedData[eachAttribute.id]) {
|
|
1477
|
+
var selectedList = clonedSelectedData[eachAttribute.id];
|
|
1478
|
+
var selectedKeys = Array.isArray(selectedList)
|
|
1479
|
+
? selectedList
|
|
1480
|
+
: [selectedList];
|
|
1481
|
+
selectedKeys.forEach(function (key) {
|
|
1482
|
+
if (!optionList_2.some(function (item) { return item.key === key; })) {
|
|
1483
|
+
optionList_2.push({ key: key, label: key });
|
|
1484
|
+
}
|
|
1485
|
+
});
|
|
1486
|
+
}
|
|
1487
|
+
inputList.push(react_1.default.createElement(select_1.Select, { ref: eachAttribute.optional ? null : formInputRef[index], id: eachAttribute.id, value: (_d = clonedSelectedData[eachAttribute.id]) !== null && _d !== void 0 ? _d : (eachAttribute.type === "list" ? "" : []), label: label, options: optionList_2, onChange: function (value) {
|
|
1221
1488
|
handleOnChangeSelect(eachAttribute.id, value);
|
|
1222
1489
|
}, disabled: disabled }));
|
|
1223
1490
|
break;
|
|
1224
1491
|
case "boolean":
|
|
1225
|
-
var value = (
|
|
1492
|
+
var value = (_e = clonedSelectedData[eachAttribute.id]) === null || _e === void 0 ? void 0 : _e.toString();
|
|
1226
1493
|
inputList.push(react_1.default.createElement(select_1.Select, { ref: eachAttribute.optional ? null : formInputRef[index], id: eachAttribute.id, value: value, label: label, options: [
|
|
1227
1494
|
{
|
|
1228
1495
|
key: "true",
|
|
@@ -1237,6 +1504,7 @@ function DataTemplate(props) {
|
|
|
1237
1504
|
}, disabled: disabled }));
|
|
1238
1505
|
break;
|
|
1239
1506
|
case "image":
|
|
1507
|
+
case "file":
|
|
1240
1508
|
var hasImageToken = typeof clonedSelectedData[eachAttribute.id] === "string";
|
|
1241
1509
|
var url = void 0;
|
|
1242
1510
|
if (hasImageToken) {
|
|
@@ -1250,19 +1518,19 @@ function DataTemplate(props) {
|
|
|
1250
1518
|
: (0, utils_2.renderImageUrlFromPath)(props.imageEndpoint, eachAttribute.imageCollectionName + "%2F" + props.id, selectedObjectStructureId, eachAttribute.imageFileName, clonedSelectedData[eachAttribute.id])
|
|
1251
1519
|
: (0, utils_2.renderImageUrlFromPath)(props.imageEndpoint, eachAttribute.imageCollectionName, props.id, eachAttribute.imageFileName, clonedSelectedData[eachAttribute.id]);
|
|
1252
1520
|
}
|
|
1253
|
-
inputList.push(react_1.default.createElement(uploadInput_1.UploadInput, { ref: eachAttribute.optional ? null : formInputRef[index], id: eachAttribute.id, label: label, file: (
|
|
1521
|
+
inputList.push(react_1.default.createElement(uploadInput_1.UploadInput, { ref: eachAttribute.optional ? null : formInputRef[index], id: eachAttribute.id, label: label, hidePreview: eachAttribute.type === "image" ? false : true, file: (_f = url !== null && url !== void 0 ? url : clonedSelectedData[eachAttribute.id]) !== null && _f !== void 0 ? _f : "", accept: eachAttribute.type === "image" ? ".png,.jpg,.jpe,.tiff" : ".pdf", fileDescription: eachAttribute.type === "image" ? undefined : "PDF up to 30MB", maxFileSize: props.maxFileSize, onChange: handleOnChangeFile, disabled: disabled }));
|
|
1254
1522
|
break;
|
|
1255
1523
|
case "number":
|
|
1256
|
-
inputList.push(react_1.default.createElement(textInput_1.TextInput, { id: eachAttribute.id, ref: eachAttribute.optional ? null : formInputRef[index], type: "number", value: (
|
|
1524
|
+
inputList.push(react_1.default.createElement(textInput_1.TextInput, { id: eachAttribute.id, ref: eachAttribute.optional ? null : formInputRef[index], type: "number", value: (_g = clonedSelectedData[eachAttribute.id]) !== null && _g !== void 0 ? _g : "", placeholder: label, label: label, onChange: handleOnChangeText, disabled: disabled }));
|
|
1257
1525
|
break;
|
|
1258
1526
|
case "reference":
|
|
1259
1527
|
case "listReference":
|
|
1260
|
-
var referenceLabel_1 = (
|
|
1528
|
+
var referenceLabel_1 = (_h = eachAttribute.referenceLabel) !== null && _h !== void 0 ? _h : "";
|
|
1261
1529
|
inputList.push(react_1.default.createElement(react_1.default.Fragment, null,
|
|
1262
1530
|
react_1.default.createElement(readQueryHoc_1.ReadQueryHoc, { database: {
|
|
1263
1531
|
dbModule: dbModule,
|
|
1264
1532
|
dbType: props.server,
|
|
1265
|
-
dbCollection: (
|
|
1533
|
+
dbCollection: (_j = eachAttribute.referenceSpaceId) !== null && _j !== void 0 ? _j : "",
|
|
1266
1534
|
dbEndpoint: props.dbEndpoint,
|
|
1267
1535
|
}, cond: {
|
|
1268
1536
|
type: "list",
|
|
@@ -1279,14 +1547,14 @@ function DataTemplate(props) {
|
|
|
1279
1547
|
}, onChangeData: function (data) {
|
|
1280
1548
|
handleGetReferenceOptions(data, eachAttribute, referenceLabel_1, clonedSelectedData[eachAttribute.id]);
|
|
1281
1549
|
} }),
|
|
1282
|
-
react_1.default.createElement(select_1.Select, { ref: eachAttribute.optional ? null : formInputRef[index], id: eachAttribute.id, value: (
|
|
1550
|
+
react_1.default.createElement(select_1.Select, { ref: eachAttribute.optional ? null : formInputRef[index], id: eachAttribute.id, value: (_k = clonedSelectedData[eachAttribute.id]) !== null && _k !== void 0 ? _k : (eachAttribute.type === "reference" ? "" : []), label: label, options: (_l = clonedReferenceOptions[eachAttribute.id]) !== null && _l !== void 0 ? _l : [], onChange: function (value) {
|
|
1283
1551
|
handleOnChangeSelect(eachAttribute.id, value);
|
|
1284
1552
|
}, onSearch: function (value) {
|
|
1285
1553
|
handleSearchReferenceOptions(eachAttribute.id, value);
|
|
1286
1554
|
}, disabled: disabled })));
|
|
1287
1555
|
break;
|
|
1288
1556
|
case "string":
|
|
1289
|
-
inputList.push(react_1.default.createElement(textInput_1.TextInput, { id: eachAttribute.id, ref: eachAttribute.optional ? null : formInputRef[index], type: "text", value: (
|
|
1557
|
+
inputList.push(react_1.default.createElement(textInput_1.TextInput, { id: eachAttribute.id, ref: eachAttribute.optional ? null : formInputRef[index], type: "text", value: (_m = clonedSelectedData[eachAttribute.id]) !== null && _m !== void 0 ? _m : "", placeholder: label, label: label, onChange: handleOnChangeText, disabled: disabled }));
|
|
1290
1558
|
break;
|
|
1291
1559
|
case "date":
|
|
1292
1560
|
inputList.push(react_1.default.createElement(datePicker_1.InputDatePicker, { title: label, id: eachAttribute.id, ref: eachAttribute.optional ? null : formInputRef[index], onChange: handleOnChangeDate, value: clonedSelectedData[eachAttribute.id], disabled: disabled }));
|
|
@@ -1517,6 +1785,124 @@ function DataTemplate(props) {
|
|
|
1517
1785
|
return null;
|
|
1518
1786
|
}
|
|
1519
1787
|
};
|
|
1788
|
+
var renderQueryIdOptions = function () {
|
|
1789
|
+
props.model.map(function (data) {
|
|
1790
|
+
if (data.id !== "_id" && data.id !== "id") {
|
|
1791
|
+
queryIdOptions.push({
|
|
1792
|
+
key: data.id,
|
|
1793
|
+
label: data.name,
|
|
1794
|
+
});
|
|
1795
|
+
}
|
|
1796
|
+
return "";
|
|
1797
|
+
});
|
|
1798
|
+
return queryIdOptions;
|
|
1799
|
+
};
|
|
1800
|
+
var renderQueryModalContent = function () {
|
|
1801
|
+
var _a, _b;
|
|
1802
|
+
var queryValueInput = [];
|
|
1803
|
+
var formInputRef = Object.values(queryInput).map(function () { return (0, react_1.createRef)(); });
|
|
1804
|
+
var modelType = (_b = (_a = props.model.find(function (eachModel) { return eachModel.id === queryInput.queryId; })) === null || _a === void 0 ? void 0 : _a.type) !== null && _b !== void 0 ? _b : "string";
|
|
1805
|
+
switch (modelType) {
|
|
1806
|
+
case "listReference":
|
|
1807
|
+
case "reference":
|
|
1808
|
+
queryValueInput.push(react_1.default.createElement(select_1.Select, { id: "value", ref: formInputRef[2], value: queryInput.value, label: "Value", options: exportReferenceList !== null && exportReferenceList !== void 0 ? exportReferenceList : [], onSearch: function (value) {
|
|
1809
|
+
setExportReferenceSearch(value);
|
|
1810
|
+
}, onChange: function (value) {
|
|
1811
|
+
var clonedQueryInput = JSON.parse(JSON.stringify(queryInput));
|
|
1812
|
+
clonedQueryInput["value"] = value;
|
|
1813
|
+
setQueryInput(clonedQueryInput);
|
|
1814
|
+
} }));
|
|
1815
|
+
break;
|
|
1816
|
+
case "date":
|
|
1817
|
+
queryValueInput.push(react_1.default.createElement(datePicker_1.InputDatePicker, { id: "value", ref: formInputRef[2], value: queryInput.value
|
|
1818
|
+
? (0, moment_1.default)(queryInput.value).toDate()
|
|
1819
|
+
: (0, moment_1.default)().toDate(), onChange: function (id, date) {
|
|
1820
|
+
var clonedQueryInput = JSON.parse(JSON.stringify(queryInput));
|
|
1821
|
+
clonedQueryInput[id] = (0, moment_1.default)(date).toISOString();
|
|
1822
|
+
setQueryInput(clonedQueryInput);
|
|
1823
|
+
} }));
|
|
1824
|
+
break;
|
|
1825
|
+
default:
|
|
1826
|
+
queryValueInput.push(react_1.default.createElement(textInput_1.TextInput, { id: "value", ref: formInputRef[2], value: queryInput.value, label: "Value", type: "text", placeholder: "eg. Type", onChange: function (e) {
|
|
1827
|
+
var clonedQueryInput = JSON.parse(JSON.stringify(queryInput));
|
|
1828
|
+
clonedQueryInput[e.target.id] = e.target.value;
|
|
1829
|
+
setQueryInput(clonedQueryInput);
|
|
1830
|
+
} }));
|
|
1831
|
+
break;
|
|
1832
|
+
}
|
|
1833
|
+
if (queryInput.type === "><") {
|
|
1834
|
+
queryValueInput.pop();
|
|
1835
|
+
queryValueInput.push(react_1.default.createElement(datePicker_1.InputDatePicker, { id: "value", ref: formInputRef[2], range: true, startDate: (0, moment_1.default)(queryInput.value[0]).toDate(), endDate: (0, moment_1.default)(queryInput.value[1]).toDate(), onChange: function (id, date, type) {
|
|
1836
|
+
var clonedQueryInput = JSON.parse(JSON.stringify(queryInput));
|
|
1837
|
+
if (type === "start")
|
|
1838
|
+
clonedQueryInput[id][0] = (0, moment_1.default)(date).toISOString();
|
|
1839
|
+
else
|
|
1840
|
+
clonedQueryInput[id][1] = (0, moment_1.default)(date).toISOString();
|
|
1841
|
+
setQueryInput(clonedQueryInput);
|
|
1842
|
+
} }));
|
|
1843
|
+
}
|
|
1844
|
+
return (react_1.default.createElement(react_1.default.Fragment, null,
|
|
1845
|
+
react_1.default.createElement(form_1.Form, { ref: formRef, refList: formInputRef, handleComplete: handlePushQueryList, className: "mt-6 grid grid-cols-1 gap-5" },
|
|
1846
|
+
react_1.default.createElement(select_1.Select, { id: "queryId", ref: formInputRef[0], value: queryInput.queryId, label: "Column ID", options: renderQueryIdOptions(), onChange: function (value) { return __awaiter(_this, void 0, void 0, function () {
|
|
1847
|
+
var clonedQueryInput;
|
|
1848
|
+
return __generator(this, function (_a) {
|
|
1849
|
+
clonedQueryInput = JSON.parse(JSON.stringify(queryInput));
|
|
1850
|
+
clonedQueryInput["queryId"] = value;
|
|
1851
|
+
clonedQueryInput["value"] = "";
|
|
1852
|
+
setQueryInput(clonedQueryInput);
|
|
1853
|
+
return [2 /*return*/];
|
|
1854
|
+
});
|
|
1855
|
+
}); } }),
|
|
1856
|
+
react_1.default.createElement(select_1.Select, { id: "type", ref: formInputRef[1], value: queryInput.type, label: "Condition", options: queryType, onChange: function (value) {
|
|
1857
|
+
var clonedQueryInput = JSON.parse(JSON.stringify(queryInput));
|
|
1858
|
+
clonedQueryInput["type"] = value;
|
|
1859
|
+
clonedQueryInput["value"] = "";
|
|
1860
|
+
setQueryInput(clonedQueryInput);
|
|
1861
|
+
} }),
|
|
1862
|
+
queryValueInput),
|
|
1863
|
+
react_1.default.createElement("div", { className: "flex flex-row justify-end pt-4" },
|
|
1864
|
+
react_1.default.createElement(button_1.Button, { className: "mt-4", text: "Add", size: "small", type: "normal", onClick: function () { return __awaiter(_this, void 0, void 0, function () {
|
|
1865
|
+
var _a;
|
|
1866
|
+
return __generator(this, function (_b) {
|
|
1867
|
+
switch (_b.label) {
|
|
1868
|
+
case 0: return [4 /*yield*/, ((_a = formRef.current) === null || _a === void 0 ? void 0 : _a.handleSubmit())];
|
|
1869
|
+
case 1:
|
|
1870
|
+
_b.sent();
|
|
1871
|
+
return [2 /*return*/];
|
|
1872
|
+
}
|
|
1873
|
+
});
|
|
1874
|
+
}); } }))));
|
|
1875
|
+
};
|
|
1876
|
+
var renderQueryData = function () {
|
|
1877
|
+
var queryStructureView = [];
|
|
1878
|
+
var sortComponent = undefined;
|
|
1879
|
+
queryList.map(function (data, index) {
|
|
1880
|
+
if (queryList.length > 1) {
|
|
1881
|
+
var upData_1 = index === queryList.length - 1;
|
|
1882
|
+
sortComponent = (react_1.default.createElement("div", { className: "cursor-pointer ml-2", onClick: function () {
|
|
1883
|
+
handleSortQuery(index, upData_1 ? "up" : "down");
|
|
1884
|
+
} }, upData_1 ? (react_1.default.createElement(outline_1.ArrowUpIcon, { className: "h-5 w-5 block text-primary-600" })) : (react_1.default.createElement(outline_1.ArrowDownIcon, { className: "h-5 w-5 block text-primary-600" }))));
|
|
1885
|
+
}
|
|
1886
|
+
queryStructureView.push({
|
|
1887
|
+
key: index,
|
|
1888
|
+
name: data.queryId,
|
|
1889
|
+
value: data.value,
|
|
1890
|
+
sort: sortComponent,
|
|
1891
|
+
view: (react_1.default.createElement("div", { className: "cursor-pointer ml-2", onClick: function () {
|
|
1892
|
+
handleViewQuery(index);
|
|
1893
|
+
} },
|
|
1894
|
+
react_1.default.createElement(outline_1.EyeIcon, { className: "h-5 w-5 block text-primary-600" }))),
|
|
1895
|
+
del: (react_1.default.createElement("div", { className: "cursor-pointer ml-2", onClick: function () {
|
|
1896
|
+
var temp = JSON.parse(JSON.stringify(queryList));
|
|
1897
|
+
temp.splice(index, 1);
|
|
1898
|
+
setQueryList(temp);
|
|
1899
|
+
} },
|
|
1900
|
+
react_1.default.createElement(outline_1.TrashIcon, { className: "h-5 w-5 block text-primary-600" }))),
|
|
1901
|
+
});
|
|
1902
|
+
return "";
|
|
1903
|
+
});
|
|
1904
|
+
return queryStructureView;
|
|
1905
|
+
};
|
|
1520
1906
|
var renderNotification = function (location) {
|
|
1521
1907
|
var _a;
|
|
1522
1908
|
if (notification) {
|
|
@@ -1654,7 +2040,7 @@ function DataTemplate(props) {
|
|
|
1654
2040
|
react_1.default.createElement("div", { className: "flex flex-row items-center justify-content mt-2 sm:mr-5 md:mt-0" },
|
|
1655
2041
|
react_1.default.createElement(link_1.Link, { className: "mr-2", href: "".concat(props.localURLEndpoint, "?data=new&type=update&collection=").concat(props.collectionId), linkType: props.linkType, custom: props.custom },
|
|
1656
2042
|
react_1.default.createElement(button_1.Button, { text: "Add", type: "normal" })),
|
|
1657
|
-
react_1.default.createElement(popUp_1.PopUp, { ctaComp: react_1.default.createElement(iconButton_1.IconButton, { className: "bg-
|
|
2043
|
+
react_1.default.createElement(popUp_1.PopUp, { ctaComp: react_1.default.createElement(iconButton_1.IconButton, { className: "bg-primary-100", icon: react_1.default.createElement(solid_1.EllipsisVerticalIcon, { className: "h-7 w-7 text-primary-500" }) }), renderComp: react_1.default.createElement("div", { className: "shadow-lg" }, moreButtonPopUp.map(function (eachPopup) { return (react_1.default.createElement(react_1.default.Fragment, null,
|
|
1658
2044
|
react_1.default.createElement("span", { className: "w-40 text-gray-700 block py-3 text-sm text-center cursor-pointer hover:bg-gray-100", onClick: eachPopup.onClick }, eachPopup.text))); })), lib: {
|
|
1659
2045
|
Menu: (_e = props === null || props === void 0 ? void 0 : props.lib) === null || _e === void 0 ? void 0 : _e.Menu,
|
|
1660
2046
|
Transition: (_f = props === null || props === void 0 ? void 0 : props.lib) === null || _f === void 0 ? void 0 : _f.Transition,
|
|
@@ -1683,17 +2069,19 @@ function DataTemplate(props) {
|
|
|
1683
2069
|
});
|
|
1684
2070
|
else if (eachSettings.type === "search") {
|
|
1685
2071
|
searchQueryExist = true;
|
|
1686
|
-
if (
|
|
2072
|
+
if (filterSearchParams) {
|
|
1687
2073
|
query.push({
|
|
1688
2074
|
type: "search",
|
|
1689
2075
|
searchIds: [eachSettings.value],
|
|
1690
|
-
value:
|
|
2076
|
+
value: filterSearchParams,
|
|
1691
2077
|
});
|
|
1692
2078
|
}
|
|
1693
2079
|
}
|
|
1694
2080
|
return null;
|
|
1695
2081
|
});
|
|
1696
|
-
if (!searchQueryExist &&
|
|
2082
|
+
if (!searchQueryExist &&
|
|
2083
|
+
props.server === "mongoServer" &&
|
|
2084
|
+
filterSearchParams) {
|
|
1697
2085
|
var searchKeys = props.model.map(function (eachAttribute) {
|
|
1698
2086
|
if (eachAttribute.type === "address")
|
|
1699
2087
|
return eachAttribute.id + ".name";
|
|
@@ -1703,7 +2091,7 @@ function DataTemplate(props) {
|
|
|
1703
2091
|
query.push({
|
|
1704
2092
|
type: "search",
|
|
1705
2093
|
searchIds: searchKeys,
|
|
1706
|
-
value:
|
|
2094
|
+
value: filterSearchParams,
|
|
1707
2095
|
});
|
|
1708
2096
|
}
|
|
1709
2097
|
return query.length > 0 ? query : undefined;
|
|
@@ -1814,6 +2202,18 @@ function DataTemplate(props) {
|
|
|
1814
2202
|
} })),
|
|
1815
2203
|
react_1.default.createElement(button_1.Button, { text: "".concat(stepCSVIndex < 2 ? "Next" : "Submit"), type: "normal", onClick: handleStepCSV }))));
|
|
1816
2204
|
}
|
|
2205
|
+
else if (exportExcel) {
|
|
2206
|
+
return (react_1.default.createElement(react_1.default.Fragment, null, exportLink ? (react_1.default.createElement(react_1.default.Fragment, null,
|
|
2207
|
+
react_1.default.createElement(emptyState_1.EmptyState, { icon: react_1.default.createElement(outline_1.CheckCircleIcon, { className: "w-20 h-20 text-primary-600" }), text: "Data have been successfully exported on ".concat(exportLink), callToAction: react_1.default.createElement("div", null,
|
|
2208
|
+
react_1.default.createElement(link_1.Link, { href: exportLink },
|
|
2209
|
+
react_1.default.createElement(button_1.Button, { text: "Download", type: "normal", size: "small" }))) }))) : (react_1.default.createElement(react_1.default.Fragment, null,
|
|
2210
|
+
react_1.default.createElement("p", { className: "text-gray-600 text-sm pt-2 mb-4" }, "Export your data to .csv format to be viewable on Excel. Filter your data exported based on conditions by creating queries at the table below"),
|
|
2211
|
+
react_1.default.createElement("div", { className: "flex justify-end items-center" },
|
|
2212
|
+
react_1.default.createElement(iconButton_1.IconButton, { className: "sm", icon: react_1.default.createElement(outline_1.PlusCircleIcon, { className: "w-6 h-6 text-white" }), background: "bg-primary-500 hover:bg-primary-600", onClick: handleQueryModal })),
|
|
2213
|
+
react_1.default.createElement(table_1.Table, { className: "mt-5", header: queryTableHeader, data: renderQueryData(), loading: false }),
|
|
2214
|
+
react_1.default.createElement("div", { className: "flex mt-5 justify-end " },
|
|
2215
|
+
react_1.default.createElement(button_1.Button, { className: "mt-4", text: "Submit", size: "small", type: "normal", onClick: handleExportCSVData }))))));
|
|
2216
|
+
}
|
|
1817
2217
|
else {
|
|
1818
2218
|
var filterObjectModel = props.model.find(function (eachModel) {
|
|
1819
2219
|
return eachModel.id === selectedObjectStructureId;
|
|
@@ -1856,13 +2256,22 @@ function DataTemplate(props) {
|
|
|
1856
2256
|
}
|
|
1857
2257
|
}
|
|
1858
2258
|
};
|
|
2259
|
+
var renderModalTitle = function () {
|
|
2260
|
+
if (excelModal)
|
|
2261
|
+
return "Import CSV";
|
|
2262
|
+
else if (exportExcel)
|
|
2263
|
+
return "Export CSV";
|
|
2264
|
+
else
|
|
2265
|
+
return "";
|
|
2266
|
+
};
|
|
1859
2267
|
return (react_1.default.createElement(react_1.default.Fragment, null,
|
|
1860
2268
|
renderNotification("root"),
|
|
1861
|
-
react_1.default.createElement(modal_1.Modal, { open: modalVisible, lib: { Dialog: (_d = props.lib) === null || _d === void 0 ? void 0 : _d.Dialog, Transition: (_e = props.lib) === null || _e === void 0 ? void 0 : _e.Transition }, renderContent: renderModalContent, onClose: loading
|
|
2269
|
+
react_1.default.createElement(modal_1.Modal, { open: modalVisible, title: renderModalTitle(), lib: { Dialog: (_d = props.lib) === null || _d === void 0 ? void 0 : _d.Dialog, Transition: (_e = props.lib) === null || _e === void 0 ? void 0 : _e.Transition }, renderContent: renderModalContent, onClose: loading
|
|
1862
2270
|
? function () { }
|
|
1863
2271
|
: function () {
|
|
1864
2272
|
handlePopUpModal(false);
|
|
1865
2273
|
}, notification: react_1.default.createElement(react_1.default.Fragment, null, renderNotification("modal")) }),
|
|
2274
|
+
react_1.default.createElement(modal_1.Modal, { title: "Create a new Query", open: queryModal, lib: { Dialog: (_f = props.lib) === null || _f === void 0 ? void 0 : _f.Dialog, Transition: (_g = props.lib) === null || _g === void 0 ? void 0 : _g.Transition }, renderContent: renderQueryModalContent, onClose: handleQueryModal, notification: react_1.default.createElement(react_1.default.Fragment, null, renderNotification("modal")) }),
|
|
1866
2275
|
renderContent()));
|
|
1867
2276
|
}
|
|
1868
2277
|
exports.DataTemplate = DataTemplate;
|