blixify-ui-web 0.1.37 → 0.1.39
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 +2 -33
- package/lib/components/data/dataTemplate/index.d.ts.map +1 -1
- package/lib/components/data/dataTemplate/index.js +342 -518
- package/lib/components/data/dataTemplate/index.js.map +1 -1
- package/lib/components/data/dataTemplate/model.d.ts +37 -0
- package/lib/components/data/dataTemplate/model.d.ts.map +1 -0
- package/lib/components/data/dataTemplate/model.js +3 -0
- package/lib/components/data/dataTemplate/model.js.map +1 -0
- package/lib/components/data/readQueryHoc/index.d.ts +1 -0
- package/lib/components/data/readQueryHoc/index.d.ts.map +1 -1
- package/lib/components/data/readQueryHoc/index.js +3 -0
- package/lib/components/data/readQueryHoc/index.js.map +1 -1
- package/lib/components/data/utils.d.ts +10 -2
- package/lib/components/data/utils.d.ts.map +1 -1
- package/lib/components/data/utils.js +234 -14
- package/lib/components/data/utils.js.map +1 -1
- package/lib/components/display/detailList/index.d.ts +1 -1
- package/lib/components/display/detailList/index.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -1,15 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __assign = (this && this.__assign) || function () {
|
|
3
|
-
__assign = Object.assign || function(t) {
|
|
4
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
-
s = arguments[i];
|
|
6
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
-
t[p] = s[p];
|
|
8
|
-
}
|
|
9
|
-
return t;
|
|
10
|
-
};
|
|
11
|
-
return __assign.apply(this, arguments);
|
|
12
|
-
};
|
|
13
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
14
3
|
if (k2 === undefined) k2 = k;
|
|
15
4
|
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
@@ -69,15 +58,6 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
69
58
|
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
70
59
|
}
|
|
71
60
|
};
|
|
72
|
-
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
73
|
-
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
74
|
-
if (ar || !(i in from)) {
|
|
75
|
-
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
76
|
-
ar[i] = from[i];
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
80
|
-
};
|
|
81
61
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
82
62
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
83
63
|
};
|
|
@@ -104,7 +84,6 @@ var uploadInput_1 = require("../../input/uploadInput");
|
|
|
104
84
|
var breadcrumb_1 = require("../../navigation/breadcrumb");
|
|
105
85
|
var tabs_1 = require("../../navigation/tabs");
|
|
106
86
|
var link_1 = require("../../structure/link");
|
|
107
|
-
var readQuery_1 = require("../readQuery");
|
|
108
87
|
var readQueryHoc_1 = require("../readQueryHoc");
|
|
109
88
|
var utils_2 = require("../utils");
|
|
110
89
|
var writeQuery_1 = require("../writeQuery");
|
|
@@ -115,30 +94,39 @@ function DataTemplate(props) {
|
|
|
115
94
|
var objectFormRef = (0, react_1.createRef)();
|
|
116
95
|
var modalFormInputRefs = props.model.map(function () { return (0, react_1.createRef)(); });
|
|
117
96
|
var limit = props.limit ? props.limit : 10;
|
|
118
|
-
var _f = (0, react_1.useState)(false),
|
|
119
|
-
|
|
120
|
-
var
|
|
121
|
-
var
|
|
122
|
-
var
|
|
123
|
-
var
|
|
124
|
-
var
|
|
125
|
-
var
|
|
126
|
-
var
|
|
97
|
+
var _f = (0, react_1.useState)(false), loading = _f[0], setLoading = _f[1];
|
|
98
|
+
//INFO : Used by List
|
|
99
|
+
var _g = (0, react_1.useState)(""), searchText = _g[0], setSearchText = _g[1];
|
|
100
|
+
var _h = (0, react_1.useState)(true), tableLoading = _h[0], setTableLoading = _h[1];
|
|
101
|
+
var _j = (0, react_1.useState)(""), cursor = _j[0], setCursor = _j[1];
|
|
102
|
+
var _k = (0, react_1.useState)(""), lastCursor = _k[0], setLastCursor = _k[1];
|
|
103
|
+
var _l = (0, react_1.useState)([]), data = _l[0], setData = _l[1];
|
|
104
|
+
var _m = (0, react_1.useState)(0), size = _m[0], setSize = _m[1];
|
|
105
|
+
var _o = (0, react_1.useState)(0), pageIndex = _o[0], setPageIndex = _o[1];
|
|
106
|
+
//INFO : Used by Read
|
|
107
|
+
//INFO : Used by Update
|
|
108
|
+
var _p = (0, react_1.useState)(false), modalVisible = _p[0], setModalVisible = _p[1];
|
|
127
109
|
var _q = (0, react_1.useState)({}), selectedData = _q[0], setSelectedData = _q[1];
|
|
128
|
-
var _r = (0, react_1.useState)(
|
|
129
|
-
var _s = (0, react_1.useState)(
|
|
130
|
-
var _t = (0, react_1.useState)(
|
|
131
|
-
var _u = (0, react_1.useState)(
|
|
132
|
-
var _v = (0, react_1.useState)(
|
|
110
|
+
var _r = (0, react_1.useState)(""), selectedObjectStructureId = _r[0], setSelectedObjectStructureId = _r[1];
|
|
111
|
+
var _s = (0, react_1.useState)(""), selectedObjectId = _s[0], setSelectedObjectId = _s[1];
|
|
112
|
+
var _t = (0, react_1.useState)({}), selectedObjectData = _t[0], setSelectedObjectData = _t[1];
|
|
113
|
+
var _u = (0, react_1.useState)({}), referenceModelSchema = _u[0], setReferenceSchema = _u[1];
|
|
114
|
+
var _v = (0, react_1.useState)({}), referenceOptions = _v[0], setReferenceOptions = _v[1];
|
|
115
|
+
var _w = (0, react_1.useState)({}), referenceSearchText = _w[0], setReferenceSearchText = _w[1];
|
|
133
116
|
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;
|
|
134
117
|
var writeServerQuery = new writeQuery_1.WriteQuery((_c = props.lib) === null || _c === void 0 ? void 0 : _c.axios, props.server, props.collectionId, props.dbEndpoint);
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
118
|
+
(0, react_1.useEffect)(function () {
|
|
119
|
+
switch (props.type) {
|
|
120
|
+
case "read":
|
|
121
|
+
case "update":
|
|
122
|
+
setModalVisible(true);
|
|
123
|
+
setLoading(true);
|
|
124
|
+
break;
|
|
125
|
+
case "list":
|
|
126
|
+
break;
|
|
139
127
|
}
|
|
140
|
-
|
|
141
|
-
|
|
128
|
+
}, [props.type]);
|
|
129
|
+
//SECTION - List
|
|
142
130
|
var handlePagination = function (value) {
|
|
143
131
|
if (typeof value === "number") {
|
|
144
132
|
setPageIndex(value);
|
|
@@ -158,196 +146,17 @@ function DataTemplate(props) {
|
|
|
158
146
|
}
|
|
159
147
|
}
|
|
160
148
|
};
|
|
161
|
-
var handleListReferenceDetails = function (data) { return __awaiter(_this, void 0, void 0, function () {
|
|
162
|
-
var referenceDetails_1, referenceCollection_1, referenceKey_1, responseData_1, err_1;
|
|
163
|
-
var _this = this;
|
|
164
|
-
return __generator(this, function (_a) {
|
|
165
|
-
switch (_a.label) {
|
|
166
|
-
case 0:
|
|
167
|
-
_a.trys.push([0, 3, , 4]);
|
|
168
|
-
referenceDetails_1 = {};
|
|
169
|
-
referenceCollection_1 = [];
|
|
170
|
-
referenceKey_1 = [];
|
|
171
|
-
return [4 /*yield*/, Promise.all(data.map(function (eachData) {
|
|
172
|
-
var _a, _b;
|
|
173
|
-
var _loop_1 = function (eachKey, eachValue) {
|
|
174
|
-
var model = props.model.find(function (eachAttribute) {
|
|
175
|
-
return eachAttribute.id === eachKey;
|
|
176
|
-
});
|
|
177
|
-
switch (model === null || model === void 0 ? void 0 : model.type) {
|
|
178
|
-
case "reference":
|
|
179
|
-
if (referenceDetails_1[eachKey]) {
|
|
180
|
-
if (!referenceDetails_1[eachKey].includes(eachValue)) {
|
|
181
|
-
referenceDetails_1[eachKey].push(eachValue);
|
|
182
|
-
}
|
|
183
|
-
}
|
|
184
|
-
else {
|
|
185
|
-
referenceDetails_1[eachKey] = [eachValue];
|
|
186
|
-
referenceKey_1.push(eachKey);
|
|
187
|
-
referenceCollection_1.push((_a = model.referenceSpaceId) !== null && _a !== void 0 ? _a : "");
|
|
188
|
-
}
|
|
189
|
-
break;
|
|
190
|
-
case "listReference":
|
|
191
|
-
if (Array.isArray(eachValue)) {
|
|
192
|
-
if (referenceDetails_1[eachKey]) {
|
|
193
|
-
var mergedSet = new Set(__spreadArray(__spreadArray([], eachValue, true), referenceDetails_1[eachKey], true));
|
|
194
|
-
referenceDetails_1[eachKey] = Array.from(mergedSet);
|
|
195
|
-
}
|
|
196
|
-
else {
|
|
197
|
-
referenceDetails_1[eachKey] = __spreadArray([], eachValue, true);
|
|
198
|
-
referenceKey_1.push(eachKey);
|
|
199
|
-
referenceCollection_1.push((_b = model.referenceSpaceId) !== null && _b !== void 0 ? _b : "");
|
|
200
|
-
}
|
|
201
|
-
}
|
|
202
|
-
break;
|
|
203
|
-
}
|
|
204
|
-
};
|
|
205
|
-
for (var _i = 0, _c = Object.entries(eachData); _i < _c.length; _i++) {
|
|
206
|
-
var _d = _c[_i], eachKey = _d[0], eachValue = _d[1];
|
|
207
|
-
_loop_1(eachKey, eachValue);
|
|
208
|
-
}
|
|
209
|
-
return null;
|
|
210
|
-
}))];
|
|
211
|
-
case 1:
|
|
212
|
-
_a.sent();
|
|
213
|
-
responseData_1 = {};
|
|
214
|
-
return [4 /*yield*/, Promise.all(referenceCollection_1.map(function (eachCollection, index) { return __awaiter(_this, void 0, void 0, function () {
|
|
215
|
-
var query, res;
|
|
216
|
-
var _a;
|
|
217
|
-
return __generator(this, function (_b) {
|
|
218
|
-
switch (_b.label) {
|
|
219
|
-
case 0:
|
|
220
|
-
query = new readQuery_1.ReadQuery(dbModule, props.server, eachCollection, props.dbEndpoint);
|
|
221
|
-
return [4 /*yield*/, query.call({
|
|
222
|
-
type: "list",
|
|
223
|
-
query: [
|
|
224
|
-
{
|
|
225
|
-
type: "in",
|
|
226
|
-
value: (_a = referenceDetails_1[referenceKey_1[index]]) !== null && _a !== void 0 ? _a : [],
|
|
227
|
-
queryId: props.server === "mongoServer" ? "_id" : "id",
|
|
228
|
-
},
|
|
229
|
-
],
|
|
230
|
-
})];
|
|
231
|
-
case 1:
|
|
232
|
-
res = _b.sent();
|
|
233
|
-
responseData_1[referenceKey_1[index]] = res === null || res === void 0 ? void 0 : res.data;
|
|
234
|
-
return [2 /*return*/];
|
|
235
|
-
}
|
|
236
|
-
});
|
|
237
|
-
}); }))];
|
|
238
|
-
case 2:
|
|
239
|
-
_a.sent();
|
|
240
|
-
return [2 /*return*/, responseData_1];
|
|
241
|
-
case 3:
|
|
242
|
-
err_1 = _a.sent();
|
|
243
|
-
return [2 /*return*/, []];
|
|
244
|
-
case 4: return [2 /*return*/];
|
|
245
|
-
}
|
|
246
|
-
});
|
|
247
|
-
}); };
|
|
248
|
-
var handleListDataBasedOnModel = function (data, server) { return __awaiter(_this, void 0, void 0, function () {
|
|
249
|
-
var dataList, referenceDetails;
|
|
250
|
-
return __generator(this, function (_a) {
|
|
251
|
-
switch (_a.label) {
|
|
252
|
-
case 0:
|
|
253
|
-
dataList = [];
|
|
254
|
-
return [4 /*yield*/, handleListReferenceDetails(data)];
|
|
255
|
-
case 1:
|
|
256
|
-
referenceDetails = _a.sent();
|
|
257
|
-
data.map(function (eachDataAttribute) {
|
|
258
|
-
var _a, _b;
|
|
259
|
-
var eachData = {};
|
|
260
|
-
var eachNewData = JSON.parse(JSON.stringify(eachDataAttribute), utils_2.jsonReviver);
|
|
261
|
-
var eachDataId = (_a = eachNewData["id"]) !== null && _a !== void 0 ? _a : eachNewData["_id"];
|
|
262
|
-
var _loop_2 = function (eachKey, eachValue) {
|
|
263
|
-
var model = props.model.find(function (eachAttribute) {
|
|
264
|
-
return eachAttribute.id === eachKey;
|
|
265
|
-
});
|
|
266
|
-
switch (model === null || model === void 0 ? void 0 : model.type) {
|
|
267
|
-
case "string":
|
|
268
|
-
if (eachKey === "id" || eachKey === "_id") {
|
|
269
|
-
eachData[eachKey] = eachValue;
|
|
270
|
-
}
|
|
271
|
-
else {
|
|
272
|
-
eachData[eachKey] =
|
|
273
|
-
typeof eachValue === "string"
|
|
274
|
-
? eachValue.length > 15
|
|
275
|
-
? eachValue.substring(0, 15) + "..."
|
|
276
|
-
: eachValue
|
|
277
|
-
: eachValue;
|
|
278
|
-
}
|
|
279
|
-
break;
|
|
280
|
-
case "date":
|
|
281
|
-
case "number":
|
|
282
|
-
case "boolean":
|
|
283
|
-
case "address":
|
|
284
|
-
case "object":
|
|
285
|
-
case "list":
|
|
286
|
-
case "multipleList":
|
|
287
|
-
eachData[eachKey] = eachValue;
|
|
288
|
-
break;
|
|
289
|
-
case "image":
|
|
290
|
-
var url = (0, utils_2.renderImageUrlFromPath)(props.imageEndpoint, model.imageCollectionName, eachDataId, model.imageFileName, eachValue);
|
|
291
|
-
eachData[eachKey] = (react_1.default.createElement("img", { src: url, alt: "".concat(eachValue), className: "w-10 h-10" }));
|
|
292
|
-
break;
|
|
293
|
-
case "reference":
|
|
294
|
-
var currentReferenceData = referenceDetails[eachKey].find(function (eachDetail) {
|
|
295
|
-
return props.server === "mongoServer"
|
|
296
|
-
? eachDetail._id === eachValue
|
|
297
|
-
: eachDetail.id === eachValue;
|
|
298
|
-
});
|
|
299
|
-
eachData[eachKey] =
|
|
300
|
-
(_b = currentReferenceData[model.referenceLabel]) !== null && _b !== void 0 ? _b : (0, utils_2.renderReferenceStringAttribute)(currentReferenceData);
|
|
301
|
-
break;
|
|
302
|
-
case "listReference":
|
|
303
|
-
var referenceListLabel_1 = [];
|
|
304
|
-
if (Array.isArray(eachValue)) {
|
|
305
|
-
eachValue.map(function (value) {
|
|
306
|
-
var _a;
|
|
307
|
-
var currentReferenceDetails = referenceDetails[eachKey].find(function (eachDetail) {
|
|
308
|
-
return props.server === "mongoServer"
|
|
309
|
-
? eachDetail._id === value
|
|
310
|
-
: eachDetail.id === value;
|
|
311
|
-
});
|
|
312
|
-
referenceListLabel_1.push((_a = currentReferenceDetails[model.referenceLabel]) !== null && _a !== void 0 ? _a : (0, utils_2.renderReferenceStringAttribute)(currentReferenceDetails));
|
|
313
|
-
return null;
|
|
314
|
-
});
|
|
315
|
-
}
|
|
316
|
-
eachData[eachKey] = referenceListLabel_1;
|
|
317
|
-
break;
|
|
318
|
-
default:
|
|
319
|
-
break;
|
|
320
|
-
}
|
|
321
|
-
};
|
|
322
|
-
for (var _i = 0, _c = Object.entries(eachNewData); _i < _c.length; _i++) {
|
|
323
|
-
var _d = _c[_i], eachKey = _d[0], eachValue = _d[1];
|
|
324
|
-
_loop_2(eachKey, eachValue);
|
|
325
|
-
}
|
|
326
|
-
eachData["update"] = (react_1.default.createElement(outline_1.PencilSquareIcon, { className: "w-5 text-primary-600", onClick: function (event) {
|
|
327
|
-
var _a;
|
|
328
|
-
event.preventDefault();
|
|
329
|
-
event.stopPropagation();
|
|
330
|
-
var id = (_a = eachData["id"]) !== null && _a !== void 0 ? _a : eachData["_id"];
|
|
331
|
-
handleNavigate("".concat(props.localURLEndpoint, "?data=").concat(id, "&type=update&collection=").concat(props.collectionId, "&view=general"));
|
|
332
|
-
} }));
|
|
333
|
-
dataList.push(server === "mongoServer"
|
|
334
|
-
? __assign(__assign({}, eachData), { id: eachData["_id"] }) : __assign({}, eachData));
|
|
335
|
-
return null;
|
|
336
|
-
});
|
|
337
|
-
return [2 /*return*/, dataList];
|
|
338
|
-
}
|
|
339
|
-
});
|
|
340
|
-
}); };
|
|
341
149
|
var handleGetListData = function (responseData) { return __awaiter(_this, void 0, void 0, function () {
|
|
342
|
-
var dataList;
|
|
150
|
+
var dataList, handleListResponse;
|
|
343
151
|
var _a, _b;
|
|
344
152
|
return __generator(this, function (_c) {
|
|
345
153
|
switch (_c.label) {
|
|
346
154
|
case 0:
|
|
347
155
|
dataList = [];
|
|
156
|
+
handleListResponse = (0, utils_2.handleListDataBasedOnModel)(responseData.data, props.server, dbModule, props.model, (_a = props.imageEndpoint) !== null && _a !== void 0 ? _a : "", props.localURLEndpoint, props.collectionId, props.dbEndpoint, handleNavigate);
|
|
348
157
|
if (!(props.server === "mongoServer")) return [3 /*break*/, 3];
|
|
349
158
|
if (!(responseData.data.length > 0)) return [3 /*break*/, 2];
|
|
350
|
-
return [4 /*yield*/,
|
|
159
|
+
return [4 /*yield*/, handleListResponse];
|
|
351
160
|
case 1:
|
|
352
161
|
dataList = _c.sent();
|
|
353
162
|
setData(dataList);
|
|
@@ -355,20 +164,28 @@ function DataTemplate(props) {
|
|
|
355
164
|
_c.label = 2;
|
|
356
165
|
case 2: return [3 /*break*/, 6];
|
|
357
166
|
case 3:
|
|
358
|
-
if (!(((_b =
|
|
359
|
-
return [4 /*yield*/,
|
|
167
|
+
if (!(((_b = responseData.data) === null || _b === void 0 ? void 0 : _b.length) > 0)) return [3 /*break*/, 5];
|
|
168
|
+
return [4 /*yield*/, handleListResponse];
|
|
360
169
|
case 4:
|
|
361
170
|
dataList = _c.sent();
|
|
362
171
|
_c.label = 5;
|
|
363
172
|
case 5:
|
|
364
173
|
setData(searchText ? dataList : dataList.concat(data));
|
|
365
|
-
setCursor(responseData.
|
|
174
|
+
setCursor(responseData.count);
|
|
366
175
|
_c.label = 6;
|
|
367
|
-
case 6:
|
|
176
|
+
case 6:
|
|
177
|
+
setTableLoading(false);
|
|
178
|
+
return [2 /*return*/];
|
|
368
179
|
}
|
|
369
180
|
});
|
|
370
181
|
}); };
|
|
371
|
-
var
|
|
182
|
+
var handleGetItemError = function () {
|
|
183
|
+
setTableLoading(false);
|
|
184
|
+
setModalVisible(false);
|
|
185
|
+
setLoading(false);
|
|
186
|
+
};
|
|
187
|
+
//Section - Update
|
|
188
|
+
var handleRetrieveSelectedData = function (responseData) { return __awaiter(_this, void 0, void 0, function () {
|
|
372
189
|
var dummyRespData, dummyReferenceModelSchema, newRespData, _a;
|
|
373
190
|
var _b, _c, _d;
|
|
374
191
|
return __generator(this, function (_e) {
|
|
@@ -378,7 +195,7 @@ function DataTemplate(props) {
|
|
|
378
195
|
dummyRespData = JSON.parse(JSON.stringify(responseData.data), utils_2.jsonReviver);
|
|
379
196
|
dummyReferenceModelSchema = JSON.parse(JSON.stringify(referenceModelSchema));
|
|
380
197
|
if (!(props.type === "read")) return [3 /*break*/, 2];
|
|
381
|
-
return [4 /*yield*/, (0, utils_2.
|
|
198
|
+
return [4 /*yield*/, (0, utils_2.handleRetrieveDeepModel)(dummyRespData, (_b = props.model) !== null && _b !== void 0 ? _b : [], dbModule, props.server, props.dbEndpoint, props.schemaEndpoint, (_c = props.imageEndpoint) !== null && _c !== void 0 ? _c : "", (_d = props.id) !== null && _d !== void 0 ? _d : "", dummyReferenceModelSchema, setReferenceSchema)];
|
|
382
199
|
case 1:
|
|
383
200
|
_a = _e.sent();
|
|
384
201
|
return [3 /*break*/, 3];
|
|
@@ -389,23 +206,13 @@ function DataTemplate(props) {
|
|
|
389
206
|
newRespData = _a;
|
|
390
207
|
setSelectedData(newRespData);
|
|
391
208
|
_e.label = 4;
|
|
392
|
-
case 4:
|
|
209
|
+
case 4:
|
|
210
|
+
setModalVisible(false);
|
|
211
|
+
setLoading(false);
|
|
212
|
+
return [2 /*return*/];
|
|
393
213
|
}
|
|
394
214
|
});
|
|
395
215
|
}); };
|
|
396
|
-
var handleNavigate = function (link) {
|
|
397
|
-
var _a, _b, _c;
|
|
398
|
-
var href = link !== null && link !== void 0 ? link : "".concat(props.localURLEndpoint, "?type=list&collection=").concat(props.collectionId);
|
|
399
|
-
if ((_a = props.lib) === null || _a === void 0 ? void 0 : _a.navigateNext) {
|
|
400
|
-
props.lib.navigateNext.push(href);
|
|
401
|
-
}
|
|
402
|
-
else if ((_b = props.lib) === null || _b === void 0 ? void 0 : _b.navigate) {
|
|
403
|
-
(_c = props.lib) === null || _c === void 0 ? void 0 : _c.navigate(href);
|
|
404
|
-
}
|
|
405
|
-
else if (window) {
|
|
406
|
-
window.location.replace(href);
|
|
407
|
-
}
|
|
408
|
-
};
|
|
409
216
|
var handleClonedDataAttribute = function (selectedData, model, force, IsRemainId) {
|
|
410
217
|
var defaultValue = selectedData;
|
|
411
218
|
var clonedSelectedData = JSON.parse(JSON.stringify(selectedData));
|
|
@@ -449,88 +256,64 @@ function DataTemplate(props) {
|
|
|
449
256
|
}
|
|
450
257
|
return clonedSelectedData;
|
|
451
258
|
};
|
|
452
|
-
var
|
|
259
|
+
var handleOnChangeData = function () {
|
|
453
260
|
var _a;
|
|
454
261
|
if (modalVisible && selectedObjectStructureId) {
|
|
455
262
|
var filterObjectModel = props.model.find(function (eachModel) {
|
|
456
263
|
return eachModel.id === selectedObjectStructureId;
|
|
457
264
|
});
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
265
|
+
return {
|
|
266
|
+
data: selectedObjectData,
|
|
267
|
+
model: (_a = filterObjectModel === null || filterObjectModel === void 0 ? void 0 : filterObjectModel.objectData) !== null && _a !== void 0 ? _a : [],
|
|
268
|
+
};
|
|
462
269
|
}
|
|
463
270
|
else {
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
271
|
+
return {
|
|
272
|
+
data: selectedData,
|
|
273
|
+
model: props.model,
|
|
274
|
+
};
|
|
468
275
|
}
|
|
469
276
|
};
|
|
470
|
-
var
|
|
471
|
-
var _a;
|
|
277
|
+
var handleUpdateChangeData = function (data) {
|
|
472
278
|
if (modalVisible && selectedObjectStructureId) {
|
|
473
|
-
|
|
474
|
-
return eachModel.id === selectedObjectStructureId;
|
|
475
|
-
});
|
|
476
|
-
var clonedSelectedObjectData = handleClonedDataAttribute(selectedObjectData, (_a = filterObjectModel === null || filterObjectModel === void 0 ? void 0 : filterObjectModel.objectData) !== null && _a !== void 0 ? _a : []);
|
|
477
|
-
clonedSelectedObjectData[id] = address;
|
|
478
|
-
setSelectedObjectData(clonedSelectedObjectData);
|
|
279
|
+
setSelectedObjectData(data);
|
|
479
280
|
}
|
|
480
281
|
else {
|
|
481
|
-
|
|
482
|
-
clonedSelectedData[id] = address;
|
|
483
|
-
setSelectedData(clonedSelectedData);
|
|
282
|
+
setSelectedData(data);
|
|
484
283
|
}
|
|
485
284
|
};
|
|
285
|
+
var handleOnChangeFile = function (e) {
|
|
286
|
+
var _a = handleOnChangeData(), data = _a.data, model = _a.model;
|
|
287
|
+
var clonedData = handleClonedDataAttribute(data, model);
|
|
288
|
+
clonedData[e.target.id] =
|
|
289
|
+
e.target.files.length > 0 ? e.target.files[0] : undefined;
|
|
290
|
+
handleUpdateChangeData(clonedData);
|
|
291
|
+
};
|
|
292
|
+
var handleOnChangeAddress = function (id, address) {
|
|
293
|
+
var _a = handleOnChangeData(), data = _a.data, model = _a.model;
|
|
294
|
+
var clonedData = handleClonedDataAttribute(data, model);
|
|
295
|
+
clonedData[id] = address;
|
|
296
|
+
handleUpdateChangeData(clonedData);
|
|
297
|
+
};
|
|
486
298
|
var handleOnChangeText = function (e) {
|
|
487
|
-
var _a;
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
});
|
|
492
|
-
var clonedSelectedObjectData = handleClonedDataAttribute(selectedObjectData, (_a = filterObjectModel === null || filterObjectModel === void 0 ? void 0 : filterObjectModel.objectData) !== null && _a !== void 0 ? _a : []);
|
|
493
|
-
clonedSelectedObjectData[e.target.id] = e.target.value;
|
|
494
|
-
setSelectedObjectData(clonedSelectedObjectData);
|
|
495
|
-
}
|
|
496
|
-
else {
|
|
497
|
-
var clonedSelectedData = handleClonedDataAttribute(selectedData, props.model);
|
|
498
|
-
clonedSelectedData[e.target.id] = e.target.value;
|
|
499
|
-
setSelectedData(clonedSelectedData);
|
|
500
|
-
}
|
|
299
|
+
var _a = handleOnChangeData(), data = _a.data, model = _a.model;
|
|
300
|
+
var clonedData = handleClonedDataAttribute(data, model);
|
|
301
|
+
clonedData[e.target.id] = e.target.value;
|
|
302
|
+
handleUpdateChangeData(clonedData);
|
|
501
303
|
};
|
|
502
304
|
var handleOnChangeSelect = function (id, value) {
|
|
503
|
-
var _a;
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
});
|
|
508
|
-
var clonedSelectedObjectData = handleClonedDataAttribute(selectedObjectData, (_a = filterObjectModel === null || filterObjectModel === void 0 ? void 0 : filterObjectModel.objectData) !== null && _a !== void 0 ? _a : []);
|
|
509
|
-
clonedSelectedObjectData[id] = value;
|
|
510
|
-
setSelectedObjectData(clonedSelectedObjectData);
|
|
511
|
-
}
|
|
512
|
-
else {
|
|
513
|
-
var clonedSelectedData = handleClonedDataAttribute(selectedData, props.model);
|
|
514
|
-
clonedSelectedData[id] = value;
|
|
515
|
-
setSelectedData(clonedSelectedData);
|
|
516
|
-
}
|
|
305
|
+
var _a = handleOnChangeData(), data = _a.data, model = _a.model;
|
|
306
|
+
var clonedData = handleClonedDataAttribute(data, model);
|
|
307
|
+
clonedData[id] = value;
|
|
308
|
+
handleUpdateChangeData(clonedData);
|
|
517
309
|
};
|
|
518
310
|
var handleOnChangeDate = function (id, value) {
|
|
519
|
-
var _a;
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
});
|
|
524
|
-
var clonedSelectedObjectData = handleClonedDataAttribute(selectedObjectData, (_a = filterObjectModel === null || filterObjectModel === void 0 ? void 0 : filterObjectModel.objectData) !== null && _a !== void 0 ? _a : []);
|
|
525
|
-
clonedSelectedObjectData[id] = value;
|
|
526
|
-
setSelectedObjectData(clonedSelectedObjectData);
|
|
527
|
-
}
|
|
528
|
-
else {
|
|
529
|
-
var clonedSelectedData = handleClonedDataAttribute(selectedData, props.model);
|
|
530
|
-
clonedSelectedData[id] = value;
|
|
531
|
-
setSelectedData(clonedSelectedData);
|
|
532
|
-
}
|
|
311
|
+
var _a = handleOnChangeData(), data = _a.data, model = _a.model;
|
|
312
|
+
var clonedData = handleClonedDataAttribute(data, model);
|
|
313
|
+
clonedData[id] = value;
|
|
314
|
+
handleUpdateChangeData(clonedData);
|
|
533
315
|
};
|
|
316
|
+
//SECTION - Reference
|
|
534
317
|
var handleSearchReferenceOptions = function (id, searchText) {
|
|
535
318
|
var clonedSearchText = JSON.parse(JSON.stringify(referenceSearchText));
|
|
536
319
|
clonedSearchText[id] = searchText;
|
|
@@ -550,140 +333,36 @@ function DataTemplate(props) {
|
|
|
550
333
|
clonedReferrenceOptions[id] = optionList;
|
|
551
334
|
setReferenceOptions(clonedReferrenceOptions);
|
|
552
335
|
};
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
case 0:
|
|
558
|
-
_a.trys.push([0, 5, , 6]);
|
|
559
|
-
selectedId = props.id;
|
|
560
|
-
if (!selectedId) return [3 /*break*/, 4];
|
|
561
|
-
setLoading(true);
|
|
562
|
-
setModalVisible(true);
|
|
563
|
-
return [4 /*yield*/, handleRemoveImage()];
|
|
564
|
-
case 1:
|
|
565
|
-
_a.sent();
|
|
566
|
-
return [4 /*yield*/, handleRemoveObjectImage()];
|
|
567
|
-
case 2:
|
|
568
|
-
_a.sent();
|
|
569
|
-
return [4 /*yield*/, writeServerQuery.call("delete", { id: selectedId })];
|
|
570
|
-
case 3:
|
|
571
|
-
res = _a.sent();
|
|
572
|
-
setModalVisible(false);
|
|
573
|
-
setLoading(false);
|
|
574
|
-
if (res) {
|
|
575
|
-
handleNavigate();
|
|
576
|
-
}
|
|
577
|
-
_a.label = 4;
|
|
578
|
-
case 4: return [3 /*break*/, 6];
|
|
579
|
-
case 5:
|
|
580
|
-
err_2 = _a.sent();
|
|
581
|
-
setModalVisible(false);
|
|
582
|
-
setLoading(false);
|
|
583
|
-
return [3 /*break*/, 6];
|
|
584
|
-
case 6: return [2 /*return*/];
|
|
585
|
-
}
|
|
586
|
-
});
|
|
587
|
-
}); };
|
|
588
|
-
var handleRemoveImage = function () { return __awaiter(_this, void 0, void 0, function () {
|
|
589
|
-
var imageAttribute;
|
|
590
|
-
var _this = this;
|
|
591
|
-
return __generator(this, function (_a) {
|
|
592
|
-
switch (_a.label) {
|
|
593
|
-
case 0:
|
|
594
|
-
imageAttribute = props.model.filter(function (eachAttribute) {
|
|
595
|
-
return eachAttribute.type === "image";
|
|
596
|
-
});
|
|
597
|
-
return [4 /*yield*/, Promise.all(imageAttribute.map(function (eachImage) { return __awaiter(_this, void 0, void 0, function () {
|
|
598
|
-
var _a, _b;
|
|
599
|
-
return __generator(this, function (_c) {
|
|
600
|
-
switch (_c.label) {
|
|
601
|
-
case 0: return [4 /*yield*/, ((_a = props.lib) === null || _a === void 0 ? void 0 : _a.axios.post((_b = eachImage.imageEndpoint + "/delete") !== null && _b !== void 0 ? _b : "", {
|
|
602
|
-
data: {
|
|
603
|
-
assetParentId: props.id,
|
|
604
|
-
assetCollectionName: eachImage.imageCollectionName,
|
|
605
|
-
assetFileName: eachImage.imageFileName,
|
|
606
|
-
},
|
|
607
|
-
}))];
|
|
608
|
-
case 1:
|
|
609
|
-
_c.sent();
|
|
610
|
-
return [2 /*return*/];
|
|
611
|
-
}
|
|
612
|
-
});
|
|
613
|
-
}); }))];
|
|
614
|
-
case 1:
|
|
615
|
-
_a.sent();
|
|
616
|
-
return [2 /*return*/];
|
|
617
|
-
}
|
|
618
|
-
});
|
|
619
|
-
}); };
|
|
620
|
-
var handleRemoveObjectImage = function () { return __awaiter(_this, void 0, void 0, function () {
|
|
621
|
-
var uploadObjectAttribute, objectAttribute, _loop_3, _i, _a, _b, eachKey, eachValue;
|
|
622
|
-
var _this = this;
|
|
336
|
+
//SECTION - Assets
|
|
337
|
+
var handleUploadAxios = function (eachImageEndpoint, assetParentId, assetCollectionName, assetFileName, file, id, isObject) { return __awaiter(_this, void 0, void 0, function () {
|
|
338
|
+
var collectionName, responseData;
|
|
339
|
+
var _a, _b;
|
|
623
340
|
return __generator(this, function (_c) {
|
|
624
341
|
switch (_c.label) {
|
|
625
342
|
case 0:
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
switch (_d.label) {
|
|
642
|
-
case 0:
|
|
643
|
-
if (!Array.isArray(eachValue)) return [3 /*break*/, 2];
|
|
644
|
-
return [4 /*yield*/, Promise.all(eachValue.map(function (eachImage) { return __awaiter(_this, void 0, void 0, function () {
|
|
645
|
-
var _a, _b;
|
|
646
|
-
return __generator(this, function (_c) {
|
|
647
|
-
switch (_c.label) {
|
|
648
|
-
case 0: return [4 /*yield*/, ((_a = props.lib) === null || _a === void 0 ? void 0 : _a.axios.post((_b = eachImage.imageEndpoint + "/delete") !== null && _b !== void 0 ? _b : "", {
|
|
649
|
-
data: {
|
|
650
|
-
assetParentId: eachKey,
|
|
651
|
-
assetCollectionName: eachImage.imageCollectionName + "/" + props.id,
|
|
652
|
-
assetFileName: eachImage.imageFileName,
|
|
653
|
-
},
|
|
654
|
-
}))];
|
|
655
|
-
case 1:
|
|
656
|
-
_c.sent();
|
|
657
|
-
return [2 /*return*/, null];
|
|
658
|
-
}
|
|
659
|
-
});
|
|
660
|
-
}); }))];
|
|
661
|
-
case 1:
|
|
662
|
-
_d.sent();
|
|
663
|
-
_d.label = 2;
|
|
664
|
-
case 2: return [2 /*return*/];
|
|
665
|
-
}
|
|
666
|
-
});
|
|
667
|
-
};
|
|
668
|
-
_i = 0, _a = Object.entries(uploadObjectAttribute);
|
|
669
|
-
_c.label = 1;
|
|
343
|
+
collectionName = isObject
|
|
344
|
+
? assetCollectionName + "/" + id
|
|
345
|
+
: assetCollectionName;
|
|
346
|
+
return [4 /*yield*/, ((_a = props.lib) === null || _a === void 0 ? void 0 : _a.axios.post((_b = eachImageEndpoint + "/upload") !== null && _b !== void 0 ? _b : "", {
|
|
347
|
+
file: file,
|
|
348
|
+
data: {
|
|
349
|
+
assetParentId: assetParentId,
|
|
350
|
+
assetCollectionName: collectionName,
|
|
351
|
+
assetFileName: assetFileName,
|
|
352
|
+
},
|
|
353
|
+
}, {
|
|
354
|
+
headers: {
|
|
355
|
+
"Content-Type": "multipart/form-data",
|
|
356
|
+
},
|
|
357
|
+
}))];
|
|
670
358
|
case 1:
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
return [5 /*yield**/, _loop_3(eachKey, eachValue)];
|
|
674
|
-
case 2:
|
|
675
|
-
_c.sent();
|
|
676
|
-
_c.label = 3;
|
|
677
|
-
case 3:
|
|
678
|
-
_i++;
|
|
679
|
-
return [3 /*break*/, 1];
|
|
680
|
-
case 4: return [2 /*return*/];
|
|
359
|
+
responseData = _c.sent();
|
|
360
|
+
return [2 /*return*/, responseData];
|
|
681
361
|
}
|
|
682
362
|
});
|
|
683
363
|
}); };
|
|
684
|
-
// TODO - Object Support Image With Path - spaceId / dataId / structureId / file.jpg;
|
|
685
364
|
var handleUploadObjectImage = function (id) { return __awaiter(_this, void 0, void 0, function () {
|
|
686
|
-
var clonedSelectedData, uploadObjectAttribute, objectAttribute,
|
|
365
|
+
var clonedSelectedData, uploadObjectAttribute, objectAttribute, _loop_1, _i, _a, _b, eachKey, eachValue;
|
|
687
366
|
var _this = this;
|
|
688
367
|
return __generator(this, function (_c) {
|
|
689
368
|
switch (_c.label) {
|
|
@@ -702,7 +381,7 @@ function DataTemplate(props) {
|
|
|
702
381
|
uploadObjectAttribute[eachObject.id] = filterImageObjectData;
|
|
703
382
|
return null;
|
|
704
383
|
});
|
|
705
|
-
|
|
384
|
+
_loop_1 = function (eachKey, eachValue) {
|
|
706
385
|
return __generator(this, function (_d) {
|
|
707
386
|
switch (_d.label) {
|
|
708
387
|
case 0:
|
|
@@ -715,18 +394,7 @@ function DataTemplate(props) {
|
|
|
715
394
|
case 0:
|
|
716
395
|
if (!(typeof selectedData[eachKey][eachImage.id] === "string")) return [3 /*break*/, 1];
|
|
717
396
|
return [2 /*return*/];
|
|
718
|
-
case 1: return [4 /*yield*/, ((_a =
|
|
719
|
-
file: selectedData[eachKey][eachImage.id],
|
|
720
|
-
data: {
|
|
721
|
-
assetParentId: eachKey,
|
|
722
|
-
assetCollectionName: eachImage.imageCollectionName + "/" + id,
|
|
723
|
-
assetFileName: eachImage.imageFileName,
|
|
724
|
-
},
|
|
725
|
-
}, {
|
|
726
|
-
headers: {
|
|
727
|
-
"Content-Type": "multipart/form-data",
|
|
728
|
-
},
|
|
729
|
-
}))];
|
|
397
|
+
case 1: return [4 /*yield*/, handleUploadAxios((_a = eachImage.imageEndpoint) !== null && _a !== void 0 ? _a : "", eachKey, eachImage.imageCollectionName + "/" + id, (_b = eachImage.imageFileName) !== null && _b !== void 0 ? _b : "", selectedData[eachKey][eachImage.id], id, false)];
|
|
730
398
|
case 2:
|
|
731
399
|
responseData = _c.sent();
|
|
732
400
|
if (responseData.data) {
|
|
@@ -749,7 +417,7 @@ function DataTemplate(props) {
|
|
|
749
417
|
case 1:
|
|
750
418
|
if (!(_i < _a.length)) return [3 /*break*/, 4];
|
|
751
419
|
_b = _a[_i], eachKey = _b[0], eachValue = _b[1];
|
|
752
|
-
return [5 /*yield**/,
|
|
420
|
+
return [5 /*yield**/, _loop_1(eachKey, eachValue)];
|
|
753
421
|
case 2:
|
|
754
422
|
_c.sent();
|
|
755
423
|
_c.label = 3;
|
|
@@ -761,7 +429,7 @@ function DataTemplate(props) {
|
|
|
761
429
|
});
|
|
762
430
|
}); };
|
|
763
431
|
var handleUploadListObjectImage = function (id) { return __awaiter(_this, void 0, void 0, function () {
|
|
764
|
-
var clonedSelectedData, uploadObjectAttribute, objectAttribute,
|
|
432
|
+
var clonedSelectedData, uploadObjectAttribute, objectAttribute, _loop_2, _i, _a, _b, eachKey, eachValue;
|
|
765
433
|
var _this = this;
|
|
766
434
|
return __generator(this, function (_c) {
|
|
767
435
|
switch (_c.label) {
|
|
@@ -780,7 +448,7 @@ function DataTemplate(props) {
|
|
|
780
448
|
uploadObjectAttribute[eachObject.id] = filterImageObjectData;
|
|
781
449
|
return null;
|
|
782
450
|
});
|
|
783
|
-
|
|
451
|
+
_loop_2 = function (eachKey, eachValue) {
|
|
784
452
|
return __generator(this, function (_d) {
|
|
785
453
|
switch (_d.label) {
|
|
786
454
|
case 0:
|
|
@@ -792,7 +460,7 @@ function DataTemplate(props) {
|
|
|
792
460
|
return __generator(this, function (_a) {
|
|
793
461
|
switch (_a.label) {
|
|
794
462
|
case 0:
|
|
795
|
-
//
|
|
463
|
+
//INFO : Only upload if this is a File Blob
|
|
796
464
|
return [4 /*yield*/, Promise.all(clonedSelectedData[eachKey].map(function (eachData, index) { return __awaiter(_this, void 0, void 0, function () {
|
|
797
465
|
var objectId, responseData;
|
|
798
466
|
var _a, _b, _c;
|
|
@@ -803,22 +471,11 @@ function DataTemplate(props) {
|
|
|
803
471
|
return [2 /*return*/];
|
|
804
472
|
case 1:
|
|
805
473
|
objectId = (_a = eachData["id"]) !== null && _a !== void 0 ? _a : (0, uuid_1.v4)();
|
|
806
|
-
return [4 /*yield*/, ((_b =
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
"/" +
|
|
812
|
-
id +
|
|
813
|
-
"/" +
|
|
814
|
-
objectId,
|
|
815
|
-
assetFileName: eachImage.imageFileName,
|
|
816
|
-
},
|
|
817
|
-
}, {
|
|
818
|
-
headers: {
|
|
819
|
-
"Content-Type": "multipart/form-data",
|
|
820
|
-
},
|
|
821
|
-
}))];
|
|
474
|
+
return [4 /*yield*/, handleUploadAxios((_b = eachImage.imageEndpoint) !== null && _b !== void 0 ? _b : "", eachKey, eachImage.imageCollectionName +
|
|
475
|
+
"/" +
|
|
476
|
+
id +
|
|
477
|
+
"/" +
|
|
478
|
+
objectId, (_c = eachImage.imageFileName) !== null && _c !== void 0 ? _c : "", eachData[eachImage.id], id, true)];
|
|
822
479
|
case 2:
|
|
823
480
|
responseData = _d.sent();
|
|
824
481
|
if (responseData.data) {
|
|
@@ -831,7 +488,7 @@ function DataTemplate(props) {
|
|
|
831
488
|
});
|
|
832
489
|
}); }))];
|
|
833
490
|
case 1:
|
|
834
|
-
//
|
|
491
|
+
//INFO : Only upload if this is a File Blob
|
|
835
492
|
_a.sent();
|
|
836
493
|
return [2 /*return*/, null];
|
|
837
494
|
}
|
|
@@ -849,7 +506,7 @@ function DataTemplate(props) {
|
|
|
849
506
|
case 1:
|
|
850
507
|
if (!(_i < _a.length)) return [3 /*break*/, 4];
|
|
851
508
|
_b = _a[_i], eachKey = _b[0], eachValue = _b[1];
|
|
852
|
-
return [5 /*yield**/,
|
|
509
|
+
return [5 /*yield**/, _loop_2(eachKey, eachValue)];
|
|
853
510
|
case 2:
|
|
854
511
|
_c.sent();
|
|
855
512
|
_c.label = 3;
|
|
@@ -873,26 +530,15 @@ function DataTemplate(props) {
|
|
|
873
530
|
});
|
|
874
531
|
return [4 /*yield*/, Promise.all(imageAttribute.map(function (eachImage) { return __awaiter(_this, void 0, void 0, function () {
|
|
875
532
|
var responseData;
|
|
876
|
-
var _a, _b;
|
|
877
|
-
return __generator(this, function (
|
|
878
|
-
switch (
|
|
533
|
+
var _a, _b, _c;
|
|
534
|
+
return __generator(this, function (_d) {
|
|
535
|
+
switch (_d.label) {
|
|
879
536
|
case 0:
|
|
880
537
|
if (!(typeof selectedData[eachImage.id] === "string")) return [3 /*break*/, 1];
|
|
881
538
|
return [2 /*return*/];
|
|
882
|
-
case 1: return [4 /*yield*/, ((_a =
|
|
883
|
-
file: selectedData[eachImage.id],
|
|
884
|
-
data: {
|
|
885
|
-
assetParentId: id,
|
|
886
|
-
assetCollectionName: eachImage.imageCollectionName,
|
|
887
|
-
assetFileName: eachImage.imageFileName,
|
|
888
|
-
},
|
|
889
|
-
}, {
|
|
890
|
-
headers: {
|
|
891
|
-
"Content-Type": "multipart/form-data",
|
|
892
|
-
},
|
|
893
|
-
}))];
|
|
539
|
+
case 1: return [4 /*yield*/, handleUploadAxios((_a = eachImage.imageEndpoint) !== null && _a !== void 0 ? _a : "", id, (_b = eachImage.imageCollectionName) !== null && _b !== void 0 ? _b : "", (_c = eachImage.imageFileName) !== null && _c !== void 0 ? _c : "", selectedData[eachImage.id], id, true)];
|
|
894
540
|
case 2:
|
|
895
|
-
responseData =
|
|
541
|
+
responseData = _d.sent();
|
|
896
542
|
if (responseData.data) {
|
|
897
543
|
clonedSelectedData[eachImage.id] = responseData.data.data;
|
|
898
544
|
}
|
|
@@ -906,6 +552,113 @@ function DataTemplate(props) {
|
|
|
906
552
|
}
|
|
907
553
|
});
|
|
908
554
|
}); };
|
|
555
|
+
var handleRemoveImageAxios = function (eachImage) { return __awaiter(_this, void 0, void 0, function () {
|
|
556
|
+
var _a, _b;
|
|
557
|
+
return __generator(this, function (_c) {
|
|
558
|
+
switch (_c.label) {
|
|
559
|
+
case 0: return [4 /*yield*/, ((_a = props.lib) === null || _a === void 0 ? void 0 : _a.axios.post((_b = eachImage.imageEndpoint + "/delete") !== null && _b !== void 0 ? _b : "", {
|
|
560
|
+
data: {
|
|
561
|
+
assetParentId: props.id,
|
|
562
|
+
assetCollectionName: eachImage.imageCollectionName,
|
|
563
|
+
assetFileName: eachImage.imageFileName,
|
|
564
|
+
},
|
|
565
|
+
}))];
|
|
566
|
+
case 1:
|
|
567
|
+
_c.sent();
|
|
568
|
+
return [2 /*return*/];
|
|
569
|
+
}
|
|
570
|
+
});
|
|
571
|
+
}); };
|
|
572
|
+
var handleRemoveImage = function () { return __awaiter(_this, void 0, void 0, function () {
|
|
573
|
+
var imageAttribute;
|
|
574
|
+
var _this = this;
|
|
575
|
+
return __generator(this, function (_a) {
|
|
576
|
+
switch (_a.label) {
|
|
577
|
+
case 0:
|
|
578
|
+
imageAttribute = props.model.filter(function (eachAttribute) {
|
|
579
|
+
return eachAttribute.type === "image";
|
|
580
|
+
});
|
|
581
|
+
return [4 /*yield*/, Promise.all(imageAttribute.map(function (eachImage) { return __awaiter(_this, void 0, void 0, function () {
|
|
582
|
+
return __generator(this, function (_a) {
|
|
583
|
+
switch (_a.label) {
|
|
584
|
+
case 0: return [4 /*yield*/, handleRemoveImageAxios(eachImage)];
|
|
585
|
+
case 1:
|
|
586
|
+
_a.sent();
|
|
587
|
+
return [2 /*return*/];
|
|
588
|
+
}
|
|
589
|
+
});
|
|
590
|
+
}); }))];
|
|
591
|
+
case 1:
|
|
592
|
+
_a.sent();
|
|
593
|
+
return [2 /*return*/];
|
|
594
|
+
}
|
|
595
|
+
});
|
|
596
|
+
}); };
|
|
597
|
+
var handleRemoveObjectImage = function () { return __awaiter(_this, void 0, void 0, function () {
|
|
598
|
+
var uploadObjectAttribute, objectAttribute, _loop_3, _i, _a, _b, eachKey, eachValue;
|
|
599
|
+
var _this = this;
|
|
600
|
+
return __generator(this, function (_c) {
|
|
601
|
+
switch (_c.label) {
|
|
602
|
+
case 0:
|
|
603
|
+
uploadObjectAttribute = {};
|
|
604
|
+
objectAttribute = props.model.filter(function (eachAttribute) {
|
|
605
|
+
return eachAttribute.type === "object";
|
|
606
|
+
});
|
|
607
|
+
if (!(objectAttribute.length > 0)) return [3 /*break*/, 4];
|
|
608
|
+
objectAttribute.map(function (eachObject) {
|
|
609
|
+
var _a;
|
|
610
|
+
var filterImageObjectData = (_a = eachObject.objectData) === null || _a === void 0 ? void 0 : _a.filter(function (eachAttribute) {
|
|
611
|
+
return eachAttribute.type === "image";
|
|
612
|
+
});
|
|
613
|
+
uploadObjectAttribute[eachObject.id] = filterImageObjectData;
|
|
614
|
+
return null;
|
|
615
|
+
});
|
|
616
|
+
_loop_3 = function (eachKey, eachValue) {
|
|
617
|
+
return __generator(this, function (_d) {
|
|
618
|
+
switch (_d.label) {
|
|
619
|
+
case 0:
|
|
620
|
+
if (!Array.isArray(eachValue)) return [3 /*break*/, 2];
|
|
621
|
+
return [4 /*yield*/, Promise.all(eachValue.map(function (eachImage) { return __awaiter(_this, void 0, void 0, function () {
|
|
622
|
+
var _a, _b;
|
|
623
|
+
return __generator(this, function (_c) {
|
|
624
|
+
switch (_c.label) {
|
|
625
|
+
case 0: return [4 /*yield*/, ((_a = props.lib) === null || _a === void 0 ? void 0 : _a.axios.post((_b = eachImage.imageEndpoint + "/delete") !== null && _b !== void 0 ? _b : "", {
|
|
626
|
+
data: {
|
|
627
|
+
assetParentId: eachKey,
|
|
628
|
+
assetCollectionName: eachImage.imageCollectionName + "/" + props.id,
|
|
629
|
+
assetFileName: eachImage.imageFileName,
|
|
630
|
+
},
|
|
631
|
+
}))];
|
|
632
|
+
case 1:
|
|
633
|
+
_c.sent();
|
|
634
|
+
return [2 /*return*/, null];
|
|
635
|
+
}
|
|
636
|
+
});
|
|
637
|
+
}); }))];
|
|
638
|
+
case 1:
|
|
639
|
+
_d.sent();
|
|
640
|
+
_d.label = 2;
|
|
641
|
+
case 2: return [2 /*return*/];
|
|
642
|
+
}
|
|
643
|
+
});
|
|
644
|
+
};
|
|
645
|
+
_i = 0, _a = Object.entries(uploadObjectAttribute);
|
|
646
|
+
_c.label = 1;
|
|
647
|
+
case 1:
|
|
648
|
+
if (!(_i < _a.length)) return [3 /*break*/, 4];
|
|
649
|
+
_b = _a[_i], eachKey = _b[0], eachValue = _b[1];
|
|
650
|
+
return [5 /*yield**/, _loop_3(eachKey, eachValue)];
|
|
651
|
+
case 2:
|
|
652
|
+
_c.sent();
|
|
653
|
+
_c.label = 3;
|
|
654
|
+
case 3:
|
|
655
|
+
_i++;
|
|
656
|
+
return [3 /*break*/, 1];
|
|
657
|
+
case 4: return [2 /*return*/];
|
|
658
|
+
}
|
|
659
|
+
});
|
|
660
|
+
}); };
|
|
661
|
+
//SECTION - Object
|
|
909
662
|
// TODO - Remove Root Folder of the Object List Image
|
|
910
663
|
var handleRemoveObjectListData = function () {
|
|
911
664
|
var clonedSelectedData = handleClonedDataAttribute(selectedData, props.model);
|
|
@@ -976,8 +729,44 @@ function DataTemplate(props) {
|
|
|
976
729
|
setModalVisible(true);
|
|
977
730
|
}
|
|
978
731
|
};
|
|
732
|
+
//SECTION - CRUD
|
|
733
|
+
var handleRemoveSelectedData = function () { return __awaiter(_this, void 0, void 0, function () {
|
|
734
|
+
var selectedId, res, err_1;
|
|
735
|
+
return __generator(this, function (_a) {
|
|
736
|
+
switch (_a.label) {
|
|
737
|
+
case 0:
|
|
738
|
+
_a.trys.push([0, 5, , 6]);
|
|
739
|
+
selectedId = props.id;
|
|
740
|
+
if (!selectedId) return [3 /*break*/, 4];
|
|
741
|
+
setLoading(true);
|
|
742
|
+
setModalVisible(true);
|
|
743
|
+
return [4 /*yield*/, handleRemoveImage()];
|
|
744
|
+
case 1:
|
|
745
|
+
_a.sent();
|
|
746
|
+
return [4 /*yield*/, handleRemoveObjectImage()];
|
|
747
|
+
case 2:
|
|
748
|
+
_a.sent();
|
|
749
|
+
return [4 /*yield*/, writeServerQuery.call("delete", { id: selectedId })];
|
|
750
|
+
case 3:
|
|
751
|
+
res = _a.sent();
|
|
752
|
+
setModalVisible(false);
|
|
753
|
+
setLoading(false);
|
|
754
|
+
if (res) {
|
|
755
|
+
handleNavigate();
|
|
756
|
+
}
|
|
757
|
+
_a.label = 4;
|
|
758
|
+
case 4: return [3 /*break*/, 6];
|
|
759
|
+
case 5:
|
|
760
|
+
err_1 = _a.sent();
|
|
761
|
+
setModalVisible(false);
|
|
762
|
+
setLoading(false);
|
|
763
|
+
return [3 /*break*/, 6];
|
|
764
|
+
case 6: return [2 /*return*/];
|
|
765
|
+
}
|
|
766
|
+
});
|
|
767
|
+
}); };
|
|
979
768
|
var handleSubmit = function () { return __awaiter(_this, void 0, void 0, function () {
|
|
980
|
-
var selectedId, id, createSelectedData, res,
|
|
769
|
+
var selectedId, id, createSelectedData, res, err_2;
|
|
981
770
|
var _a;
|
|
982
771
|
return __generator(this, function (_b) {
|
|
983
772
|
switch (_b.label) {
|
|
@@ -1017,11 +806,16 @@ function DataTemplate(props) {
|
|
|
1017
806
|
setModalVisible(false);
|
|
1018
807
|
setLoading(false);
|
|
1019
808
|
if (res) {
|
|
1020
|
-
|
|
809
|
+
if (props.onComplete) {
|
|
810
|
+
props.onComplete();
|
|
811
|
+
}
|
|
812
|
+
else {
|
|
813
|
+
handleNavigate();
|
|
814
|
+
}
|
|
1021
815
|
}
|
|
1022
816
|
return [3 /*break*/, 7];
|
|
1023
817
|
case 6:
|
|
1024
|
-
|
|
818
|
+
err_2 = _b.sent();
|
|
1025
819
|
setModalVisible(false);
|
|
1026
820
|
setLoading(false);
|
|
1027
821
|
return [3 /*break*/, 7];
|
|
@@ -1029,11 +823,33 @@ function DataTemplate(props) {
|
|
|
1029
823
|
}
|
|
1030
824
|
});
|
|
1031
825
|
}); };
|
|
826
|
+
//SECTION - Utils
|
|
827
|
+
var handlePopUpModal = function (modalVisible) {
|
|
828
|
+
if (!modalVisible) {
|
|
829
|
+
setSelectedObjectStructureId("");
|
|
830
|
+
setSelectedObjectData({});
|
|
831
|
+
}
|
|
832
|
+
setModalVisible(modalVisible);
|
|
833
|
+
};
|
|
834
|
+
var handleNavigate = function (link) {
|
|
835
|
+
var _a, _b, _c;
|
|
836
|
+
var href = link !== null && link !== void 0 ? link : "".concat(props.localURLEndpoint, "?type=list&collection=").concat(props.collectionId);
|
|
837
|
+
if ((_a = props.lib) === null || _a === void 0 ? void 0 : _a.navigateNext) {
|
|
838
|
+
props.lib.navigateNext.push(href);
|
|
839
|
+
}
|
|
840
|
+
else if ((_b = props.lib) === null || _b === void 0 ? void 0 : _b.navigate) {
|
|
841
|
+
(_c = props.lib) === null || _c === void 0 ? void 0 : _c.navigate(href);
|
|
842
|
+
}
|
|
843
|
+
else if (window) {
|
|
844
|
+
window.location.replace(href);
|
|
845
|
+
}
|
|
846
|
+
};
|
|
1032
847
|
var renderTableHeader = function () {
|
|
1033
848
|
var tableHeader = [];
|
|
1034
849
|
props.model.map(function (eachAttribute) {
|
|
1035
850
|
if (eachAttribute.id === "baseUpdatedAt" ||
|
|
1036
|
-
eachAttribute.type === "listObject"
|
|
851
|
+
eachAttribute.type === "listObject" ||
|
|
852
|
+
eachAttribute.hide) {
|
|
1037
853
|
return null;
|
|
1038
854
|
}
|
|
1039
855
|
tableHeader.push({
|
|
@@ -1075,18 +891,23 @@ function DataTemplate(props) {
|
|
|
1075
891
|
};
|
|
1076
892
|
var renderDataTemplateForm = function (data, model, formInputRef, isObject, isObjectList) {
|
|
1077
893
|
var inputList = [];
|
|
1078
|
-
//
|
|
894
|
+
//INFO : filteredModel is to secure the formInputRef[index] will not have any issue
|
|
1079
895
|
var filteredModel = model.filter(function (eachAttribute) {
|
|
1080
|
-
//
|
|
896
|
+
//INFO - Default Model Contain Id While Object Type Don't have
|
|
1081
897
|
return eachAttribute.id !== "_id" && eachAttribute.id !== "id";
|
|
1082
898
|
});
|
|
1083
899
|
filteredModel.map(function (eachAttribute, index) {
|
|
1084
|
-
//
|
|
900
|
+
//INFO - Default Model Contain Id While Object Type Don't have
|
|
1085
901
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
|
1086
902
|
var clonedSelectedData = handleClonedDataAttribute(data, model);
|
|
1087
903
|
var clonedReferenceOptions = JSON.parse(JSON.stringify(referenceOptions));
|
|
1088
904
|
var clonedReferenceSearchText = JSON.parse(JSON.stringify(referenceSearchText));
|
|
1089
905
|
var label = eachAttribute.name;
|
|
906
|
+
var disabled = props.type === "read"
|
|
907
|
+
? true
|
|
908
|
+
: props.type === "update" && props.id === "new"
|
|
909
|
+
? false
|
|
910
|
+
: eachAttribute.disabled;
|
|
1090
911
|
switch (eachAttribute.type) {
|
|
1091
912
|
case "address":
|
|
1092
913
|
inputList.push(react_1.default.createElement(address_1.Address, { id: eachAttribute.id, label: label, value: (_a = clonedSelectedData[eachAttribute.id]) !== null && _a !== void 0 ? _a : {
|
|
@@ -1095,7 +916,7 @@ function DataTemplate(props) {
|
|
|
1095
916
|
name: "",
|
|
1096
917
|
}, onChange: function (address) {
|
|
1097
918
|
handleOnChangeAddress(eachAttribute.id, address);
|
|
1098
|
-
}, ref: formInputRef[index], disabled:
|
|
919
|
+
}, ref: eachAttribute.optional ? null : formInputRef[index], disabled: disabled }));
|
|
1099
920
|
break;
|
|
1100
921
|
case "object":
|
|
1101
922
|
inputList.push(react_1.default.createElement(react_1.default.Fragment, null,
|
|
@@ -1110,17 +931,17 @@ function DataTemplate(props) {
|
|
|
1110
931
|
break;
|
|
1111
932
|
case "list":
|
|
1112
933
|
case "multipleList":
|
|
1113
|
-
inputList.push(react_1.default.createElement(select_1.Select, { ref: formInputRef[index], id: eachAttribute.id, value: (_b = clonedSelectedData[eachAttribute.id]) !== null && _b !== void 0 ? _b : (eachAttribute.type === "list" ? "" : []), label: label, options: (_d = (_c = eachAttribute.listSelection) === null || _c === void 0 ? void 0 : _c.map(function (eachAttribute) {
|
|
934
|
+
inputList.push(react_1.default.createElement(select_1.Select, { ref: eachAttribute.optional ? null : formInputRef[index], id: eachAttribute.id, value: (_b = clonedSelectedData[eachAttribute.id]) !== null && _b !== void 0 ? _b : (eachAttribute.type === "list" ? "" : []), label: label, options: (_d = (_c = eachAttribute.listSelection) === null || _c === void 0 ? void 0 : _c.map(function (eachAttribute) {
|
|
1114
935
|
return {
|
|
1115
936
|
key: eachAttribute,
|
|
1116
937
|
label: eachAttribute,
|
|
1117
938
|
};
|
|
1118
939
|
})) !== null && _d !== void 0 ? _d : [], onChange: function (value) {
|
|
1119
940
|
handleOnChangeSelect(eachAttribute.id, value);
|
|
1120
|
-
}, disabled:
|
|
941
|
+
}, disabled: disabled }));
|
|
1121
942
|
break;
|
|
1122
943
|
case "boolean":
|
|
1123
|
-
inputList.push(react_1.default.createElement(select_1.Select, { ref: formInputRef[index], id: eachAttribute.id, value: (_e = clonedSelectedData[eachAttribute.id]) !== null && _e !== void 0 ? _e : "", label: label, options: [
|
|
944
|
+
inputList.push(react_1.default.createElement(select_1.Select, { ref: eachAttribute.optional ? null : formInputRef[index], id: eachAttribute.id, value: (_e = clonedSelectedData[eachAttribute.id]) !== null && _e !== void 0 ? _e : "", label: label, options: [
|
|
1124
945
|
{
|
|
1125
946
|
key: "true",
|
|
1126
947
|
label: "True",
|
|
@@ -1131,7 +952,7 @@ function DataTemplate(props) {
|
|
|
1131
952
|
},
|
|
1132
953
|
], onChange: function (value) {
|
|
1133
954
|
handleOnChangeSelect(eachAttribute.id, value);
|
|
1134
|
-
}, disabled:
|
|
955
|
+
}, disabled: disabled }));
|
|
1135
956
|
break;
|
|
1136
957
|
case "image":
|
|
1137
958
|
var hasImageToken = typeof clonedSelectedData[eachAttribute.id] === "string";
|
|
@@ -1147,10 +968,10 @@ function DataTemplate(props) {
|
|
|
1147
968
|
: (0, utils_2.renderImageUrlFromPath)(props.imageEndpoint, eachAttribute.imageCollectionName + "%2F" + props.id, selectedObjectStructureId, eachAttribute.imageFileName, clonedSelectedData[eachAttribute.id])
|
|
1148
969
|
: (0, utils_2.renderImageUrlFromPath)(props.imageEndpoint, eachAttribute.imageCollectionName, props.id, eachAttribute.imageFileName, clonedSelectedData[eachAttribute.id]);
|
|
1149
970
|
}
|
|
1150
|
-
inputList.push(react_1.default.createElement(uploadInput_1.UploadInput, { ref: formInputRef[index], id: eachAttribute.id, label: "Upload Image", file: (_f = url !== null && url !== void 0 ? url : clonedSelectedData[eachAttribute.id]) !== null && _f !== void 0 ? _f : "", accept: ".png,.jpg,.jpeg", onChange: handleOnChangeFile, disabled:
|
|
971
|
+
inputList.push(react_1.default.createElement(uploadInput_1.UploadInput, { ref: eachAttribute.optional ? null : formInputRef[index], id: eachAttribute.id, label: "Upload Image", file: (_f = url !== null && url !== void 0 ? url : clonedSelectedData[eachAttribute.id]) !== null && _f !== void 0 ? _f : "", accept: ".png,.jpg,.jpeg", onChange: handleOnChangeFile, disabled: disabled }));
|
|
1151
972
|
break;
|
|
1152
973
|
case "number":
|
|
1153
|
-
inputList.push(react_1.default.createElement(textInput_1.TextInput, { id: eachAttribute.id, ref: formInputRef[index], type: "number", value: (_g = clonedSelectedData[eachAttribute.id]) !== null && _g !== void 0 ? _g : "", placeholder: label, label: label, onChange: handleOnChangeText, disabled:
|
|
974
|
+
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 }));
|
|
1154
975
|
break;
|
|
1155
976
|
case "reference":
|
|
1156
977
|
case "listReference":
|
|
@@ -1174,18 +995,20 @@ function DataTemplate(props) {
|
|
|
1174
995
|
}, onChangeData: function (data) {
|
|
1175
996
|
var _a;
|
|
1176
997
|
handleGetReferenceOptions(data, eachAttribute.id, (_a = eachAttribute.referenceLabel) !== null && _a !== void 0 ? _a : "");
|
|
998
|
+
}, onError: function (error) {
|
|
999
|
+
console.debug(error);
|
|
1177
1000
|
} }),
|
|
1178
|
-
react_1.default.createElement(select_1.Select, { ref: formInputRef[index], id: eachAttribute.id, value: (_j = clonedSelectedData[eachAttribute.id]) !== null && _j !== void 0 ? _j : (eachAttribute.type === "reference" ? "" : []), label: label, options: (_k = clonedReferenceOptions[eachAttribute.id]) !== null && _k !== void 0 ? _k : [], onChange: function (value) {
|
|
1001
|
+
react_1.default.createElement(select_1.Select, { ref: eachAttribute.optional ? null : formInputRef[index], id: eachAttribute.id, value: (_j = clonedSelectedData[eachAttribute.id]) !== null && _j !== void 0 ? _j : (eachAttribute.type === "reference" ? "" : []), label: label, options: (_k = clonedReferenceOptions[eachAttribute.id]) !== null && _k !== void 0 ? _k : [], onChange: function (value) {
|
|
1179
1002
|
handleOnChangeSelect(eachAttribute.id, value);
|
|
1180
1003
|
}, onSearch: function (value) {
|
|
1181
1004
|
handleSearchReferenceOptions(eachAttribute.id, value);
|
|
1182
|
-
}, disabled:
|
|
1005
|
+
}, disabled: disabled })));
|
|
1183
1006
|
break;
|
|
1184
1007
|
case "string":
|
|
1185
|
-
inputList.push(react_1.default.createElement(textInput_1.TextInput, { id: eachAttribute.id, ref: formInputRef[index], type: "text", value: (_l = clonedSelectedData[eachAttribute.id]) !== null && _l !== void 0 ? _l : "", placeholder: label, label: label, onChange: handleOnChangeText, disabled:
|
|
1008
|
+
inputList.push(react_1.default.createElement(textInput_1.TextInput, { id: eachAttribute.id, ref: eachAttribute.optional ? null : formInputRef[index], type: "text", value: (_l = clonedSelectedData[eachAttribute.id]) !== null && _l !== void 0 ? _l : "", placeholder: label, label: label, onChange: handleOnChangeText, disabled: disabled }));
|
|
1186
1009
|
break;
|
|
1187
1010
|
case "date":
|
|
1188
|
-
inputList.push(react_1.default.createElement(datePicker_1.InputDatePicker, { title: label, id: eachAttribute.id, ref: formInputRef[index], onChange: handleOnChangeDate, value: clonedSelectedData[eachAttribute.id], disabled:
|
|
1011
|
+
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 }));
|
|
1189
1012
|
break;
|
|
1190
1013
|
}
|
|
1191
1014
|
return null;
|
|
@@ -1206,7 +1029,7 @@ function DataTemplate(props) {
|
|
|
1206
1029
|
});
|
|
1207
1030
|
if (viewType === "general") {
|
|
1208
1031
|
if (dataType === "list") {
|
|
1209
|
-
return (react_1.default.createElement(table_1.Table, { paginationType: props.server === "mongoServer" ? "page" : "cursor", data: data, size: size, limit: limit, cursor: cursor, loading:
|
|
1032
|
+
return (react_1.default.createElement(table_1.Table, { paginationType: props.server === "mongoServer" ? "page" : "cursor", data: data, size: size, limit: limit, cursor: cursor, loading: tableLoading, header: renderTableHeader(), pageIndex: pageIndex, onClickRow: function (id) {
|
|
1210
1033
|
handleNavigate("".concat(props.localURLEndpoint, "?data=").concat(id, "&type=read&collection=").concat(props.collectionId, "&view=general"));
|
|
1211
1034
|
}, linkType: props.linkType, custom: props.custom, newTabUrl: "".concat(props.localURLEndpoint, "?data="), addNewTabUrl: "&type=read&collection=".concat(props.collectionId, "&view=general"), handleUpdatePageIndex: handlePagination, className: "mt-5" }));
|
|
1212
1035
|
}
|
|
@@ -1232,7 +1055,7 @@ function DataTemplate(props) {
|
|
|
1232
1055
|
var renderDetailListData = function () {
|
|
1233
1056
|
var _a;
|
|
1234
1057
|
var detailList = [];
|
|
1235
|
-
var
|
|
1058
|
+
var _loop_4 = function (eachKey, eachValue) {
|
|
1236
1059
|
if (eachKey !== "id" &&
|
|
1237
1060
|
eachKey !== "_id" &&
|
|
1238
1061
|
eachKey !== "baseUpdatedAt") {
|
|
@@ -1247,7 +1070,7 @@ function DataTemplate(props) {
|
|
|
1247
1070
|
};
|
|
1248
1071
|
for (var _i = 0, _b = Object.entries(selectedData); _i < _b.length; _i++) {
|
|
1249
1072
|
var _c = _b[_i], eachKey = _c[0], eachValue = _c[1];
|
|
1250
|
-
|
|
1073
|
+
_loop_4(eachKey, eachValue);
|
|
1251
1074
|
}
|
|
1252
1075
|
return detailList;
|
|
1253
1076
|
};
|
|
@@ -1266,7 +1089,7 @@ function DataTemplate(props) {
|
|
|
1266
1089
|
tag: "",
|
|
1267
1090
|
};
|
|
1268
1091
|
var isTitle = true;
|
|
1269
|
-
var
|
|
1092
|
+
var _loop_5 = function (eachKey, eachValue) {
|
|
1270
1093
|
if (eachListObject.objectData) {
|
|
1271
1094
|
var model = eachListObject.objectData.find(function (eachAttribute) {
|
|
1272
1095
|
return eachAttribute.id === eachKey;
|
|
@@ -1291,7 +1114,7 @@ function DataTemplate(props) {
|
|
|
1291
1114
|
else if (eachValue instanceof File) {
|
|
1292
1115
|
url = URL.createObjectURL(eachValue);
|
|
1293
1116
|
}
|
|
1294
|
-
eachNewList[eachKey] = (react_1.default.createElement("img", { src: url, alt: "", className: "w-10 h-10" }));
|
|
1117
|
+
eachNewList[eachKey] = (react_1.default.createElement("img", { src: url, alt: "", className: "w-10 h-10 object-contain" }));
|
|
1295
1118
|
break;
|
|
1296
1119
|
case "date":
|
|
1297
1120
|
eachNewList[eachKey] =
|
|
@@ -1316,7 +1139,7 @@ function DataTemplate(props) {
|
|
|
1316
1139
|
};
|
|
1317
1140
|
for (var _i = 0, _a = Object.entries(eachObject); _i < _a.length; _i++) {
|
|
1318
1141
|
var _b = _a[_i], eachKey = _b[0], eachValue = _b[1];
|
|
1319
|
-
|
|
1142
|
+
_loop_5(eachKey, eachValue);
|
|
1320
1143
|
}
|
|
1321
1144
|
eachNewList["tag"] = "";
|
|
1322
1145
|
if (list_2[eachListObject.id]) {
|
|
@@ -1394,16 +1217,17 @@ function DataTemplate(props) {
|
|
|
1394
1217
|
}, cond: {
|
|
1395
1218
|
type: "get",
|
|
1396
1219
|
id: props.id,
|
|
1397
|
-
}, onChangeData:
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
react_1.default.createElement("div",
|
|
1401
|
-
react_1.default.createElement("div", { className: "flex flex-col" },
|
|
1402
|
-
react_1.default.createElement("
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1220
|
+
}, onChangeData: handleRetrieveSelectedData, onError: handleGetItemError }),
|
|
1221
|
+
!loading && (react_1.default.createElement(react_1.default.Fragment, null,
|
|
1222
|
+
props.breadcrumb && (react_1.default.createElement(breadcrumb_1.Breadcrumb, { pages: pages, linkType: props.linkType, custom: props.custom, className: "mb-5" })),
|
|
1223
|
+
react_1.default.createElement("div", null,
|
|
1224
|
+
react_1.default.createElement("div", { className: "flex flex-col py-2 justify-between sm:items-center sm:flex-row" },
|
|
1225
|
+
react_1.default.createElement("div", { className: "flex flex-col" },
|
|
1226
|
+
react_1.default.createElement("p", { className: "text-xl font-medium" }, props.title),
|
|
1227
|
+
react_1.default.createElement("span", { className: "text-sm text-gray-500" }, props.description)),
|
|
1228
|
+
props.deleteBtn && (react_1.default.createElement(button_1.Button, { text: "Delete", className: "ml-0 mt-5 sm:mt-0 sm:ml-5", type: "danger", onClick: handleRemoveSelectedData })))),
|
|
1229
|
+
react_1.default.createElement(tabs_1.Tabs, { tabs: tabs, selectedId: viewType, linkType: props.linkType, custom: props.custom }),
|
|
1230
|
+
renderTabContent(tabs, props.type, viewType)))));
|
|
1407
1231
|
case "update":
|
|
1408
1232
|
pages.push({
|
|
1409
1233
|
name: props.id ? props.id : "new",
|
|
@@ -1419,7 +1243,7 @@ function DataTemplate(props) {
|
|
|
1419
1243
|
}, cond: {
|
|
1420
1244
|
type: "get",
|
|
1421
1245
|
id: props.id,
|
|
1422
|
-
}, onChangeData:
|
|
1246
|
+
}, onChangeData: handleRetrieveSelectedData, onError: handleGetItemError })),
|
|
1423
1247
|
props.breadcrumb && (react_1.default.createElement(breadcrumb_1.Breadcrumb, { pages: pages, linkType: props.linkType, custom: props.custom, className: "mb-5" })),
|
|
1424
1248
|
react_1.default.createElement("div", { className: "flex flex-col py-2 justify-between sm:items-center sm:flex-row" },
|
|
1425
1249
|
react_1.default.createElement("div", { className: "flex flex-col" },
|
|
@@ -1461,7 +1285,7 @@ function DataTemplate(props) {
|
|
|
1461
1285
|
cursor: renderCursor(),
|
|
1462
1286
|
sort: (_d = props.sort) !== null && _d !== void 0 ? _d : undefined,
|
|
1463
1287
|
limit: limit,
|
|
1464
|
-
}, onChangeData: handleGetListData }),
|
|
1288
|
+
}, onChangeData: handleGetListData, onError: handleGetItemError }),
|
|
1465
1289
|
react_1.default.createElement("div", { className: "flex flex-col py-2 sm:items-center sm:flex-row" },
|
|
1466
1290
|
react_1.default.createElement("div", { className: "flex flex-col" },
|
|
1467
1291
|
react_1.default.createElement("p", { className: "text-xl font-medium" }, props.title),
|