blixify-ui-web 0.3.75 → 0.3.77

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.
Files changed (37) hide show
  1. package/lib/components/auth/bareSignIn/index.d.ts +2 -2
  2. package/lib/components/auth/bareSignIn/index.d.ts.map +1 -1
  3. package/lib/components/auth/bareSignIn/index.js +9 -1
  4. package/lib/components/auth/bareSignIn/index.js.map +1 -1
  5. package/lib/components/data/dataTemplate/dataStateModel.d.ts +0 -1
  6. package/lib/components/data/dataTemplate/dataStateModel.d.ts.map +1 -1
  7. package/lib/components/data/dataTemplate/dataStateModel.js.map +1 -1
  8. package/lib/components/data/dataTemplate/index.d.ts.map +1 -1
  9. package/lib/components/data/dataTemplate/index.js +25 -22
  10. package/lib/components/data/dataTemplate/index.js.map +1 -1
  11. package/lib/components/data/dataTemplate/model.d.ts +18 -2
  12. package/lib/components/data/dataTemplate/model.d.ts.map +1 -1
  13. package/lib/components/data/dataTemplate/settingsModal.d.ts +4 -1
  14. package/lib/components/data/dataTemplate/settingsModal.d.ts.map +1 -1
  15. package/lib/components/data/dataTemplate/settingsModal.js +42 -11
  16. package/lib/components/data/dataTemplate/settingsModal.js.map +1 -1
  17. package/lib/components/data/dataWrapper/index.d.ts +2 -1
  18. package/lib/components/data/dataWrapper/index.d.ts.map +1 -1
  19. package/lib/components/data/dataWrapper/index.js +10 -2
  20. package/lib/components/data/dataWrapper/index.js.map +1 -1
  21. package/lib/components/data/listModule.d.ts +7 -4
  22. package/lib/components/data/listModule.d.ts.map +1 -1
  23. package/lib/components/data/listModule.js +378 -208
  24. package/lib/components/data/listModule.js.map +1 -1
  25. package/lib/components/data/utils.d.ts +3 -0
  26. package/lib/components/data/utils.d.ts.map +1 -1
  27. package/lib/components/data/utils.js +36 -1
  28. package/lib/components/data/utils.js.map +1 -1
  29. package/lib/components/display/table/index.d.ts +0 -1
  30. package/lib/components/display/table/index.d.ts.map +1 -1
  31. package/lib/components/display/table/index.js +5 -15
  32. package/lib/components/display/table/index.js.map +1 -1
  33. package/lib/components/input/textInput/index.d.ts +1 -1
  34. package/lib/components/input/textInput/index.d.ts.map +1 -1
  35. package/lib/components/input/textInput/index.js +3 -2
  36. package/lib/components/input/textInput/index.js.map +1 -1
  37. package/package.json +2 -1
@@ -59,10 +59,14 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
59
59
  return (mod && mod.__esModule) ? mod : { "default": mod };
60
60
  };
61
61
  Object.defineProperty(exports, "__esModule", { value: true });
62
- exports.handleExportPDF = exports.renderSelectedRefreshTab = exports.renderSearchFilterComponents = exports.renderSearchFilterConditions = exports.handleDataEditButton = exports.handleListDataBasedOnModel = void 0;
62
+ exports.handleExportPDF = exports.renderSelectedRefreshTab = exports.renderSearchFilterComponents = exports.renderSearchFilterConditions = exports.renderSearchAdditionalQueries = exports.handleDataEditButton = exports.handleListDataBasedOnModel = void 0;
63
63
  var outline_1 = require("@heroicons/react/24/outline");
64
64
  var react_md_editor_1 = __importDefault(require("@uiw/react-md-editor"));
65
+ var axios_1 = __importDefault(require("axios"));
66
+ var jspdf_1 = require("jspdf");
67
+ var jspdf_autotable_1 = __importDefault(require("jspdf-autotable"));
65
68
  var moment_1 = __importDefault(require("moment"));
69
+ var papaparse_1 = __importDefault(require("papaparse"));
66
70
  var react_1 = __importDefault(require("react"));
67
71
  var tag_1 = require("../display/tag");
68
72
  var datePicker_1 = require("../input/datePicker");
@@ -70,16 +74,108 @@ var select_1 = require("../input/select");
70
74
  var textInput_1 = require("../input/textInput");
71
75
  var blobModule_1 = require("./blobModule");
72
76
  var moduleUtils_1 = require("./moduleUtils");
77
+ var readQuery_1 = require("./readQuery");
73
78
  var readQueryHoc_1 = require("./readQueryHoc");
74
79
  var utils_1 = require("./utils");
75
- var papaparse_1 = __importDefault(require("papaparse"));
76
- var jspdf_1 = require("jspdf");
77
- var jspdf_autotable_1 = __importDefault(require("jspdf-autotable"));
78
- var axios_1 = __importDefault(require("axios"));
80
+ var Parser = require("expr-eval").Parser;
81
+ var parser = new Parser();
79
82
  //=====================================================================================
80
83
  //SECTION: List Feature used across Data Components
81
84
  //=====================================================================================
82
- var handleListDataBasedOnModel = function (data, devSettings, dbModule, modelSchema, handleNavigate, isTableView, setActivityModal, setActivityId, activityLog, addActionBtns) { return __awaiter(void 0, void 0, void 0, function () {
85
+ var handleProcessShowReferences = function (eachData, eachNewData, modelSchema, devSettings, dbModule, schemaReference) { return __awaiter(void 0, void 0, void 0, function () {
86
+ var server, filterShowReferenceStructure, _loop_1, _i, filterShowReferenceStructure_1, eachStructure;
87
+ var _a, _b, _c, _d, _e;
88
+ return __generator(this, function (_f) {
89
+ switch (_f.label) {
90
+ case 0:
91
+ server = devSettings.server;
92
+ filterShowReferenceStructure = modelSchema.filter(function (eachStructure) { return eachStructure.type === "showReference"; });
93
+ _loop_1 = function (eachStructure) {
94
+ var showReferenceRQ, getValue_1, query, res, showReferenceDataList_1, showReferenceStructure, err_1;
95
+ return __generator(this, function (_g) {
96
+ switch (_g.label) {
97
+ case 0:
98
+ _g.trys.push([0, 4, , 5]);
99
+ showReferenceRQ = new readQuery_1.ReadQuery({
100
+ dbModule: dbModule,
101
+ dbType: server,
102
+ dbCollection: (_a = eachStructure.referenceSpaceId) !== null && _a !== void 0 ? _a : "",
103
+ dbEndpoint: devSettings.dbEndpoint,
104
+ dbAPIToken: devSettings.dbAPIToken,
105
+ dbUserToken: devSettings.dbUserToken,
106
+ });
107
+ getValue_1 = function (eachCond) {
108
+ var _a, _b, _c, _d;
109
+ return (_c = (_a = eachCond === null || eachCond === void 0 ? void 0 : eachCond.value) !== null && _a !== void 0 ? _a : eachNewData === null || eachNewData === void 0 ? void 0 : eachNewData[(_b = eachCond.fromColumnId) !== null && _b !== void 0 ? _b : "_id"]) !== null && _c !== void 0 ? _c : eachData[(_d = eachCond.fromColumnId) !== null && _d !== void 0 ? _d : "_id"];
110
+ };
111
+ query = (_c = (_b = eachStructure.condition) === null || _b === void 0 ? void 0 : _b.map(function (eachCond) {
112
+ var _a, _b;
113
+ var baseQuery = {
114
+ type: eachCond.condition,
115
+ queryId: (_a = eachCond.toColumnId) !== null && _a !== void 0 ? _a : "_id",
116
+ };
117
+ var value = getValue_1(eachCond);
118
+ if (eachCond.condition === "><") {
119
+ if (Array.isArray(value)) {
120
+ return __assign(__assign({}, baseQuery), { value: value });
121
+ }
122
+ var startOfDay = (0, moment_1.default)(value).startOf("day").toISOString();
123
+ var endOfDay = (0, moment_1.default)(value).endOf("day").toISOString();
124
+ return __assign(__assign({}, baseQuery), { value: (_b = eachCond.value) !== null && _b !== void 0 ? _b : [startOfDay, endOfDay] });
125
+ }
126
+ if (eachCond.condition === "in") {
127
+ return __assign(__assign({}, baseQuery), { value: Array.isArray(value) ? value : [value] });
128
+ }
129
+ return __assign(__assign({}, baseQuery), { value: value });
130
+ })) !== null && _c !== void 0 ? _c : [];
131
+ return [4 /*yield*/, showReferenceRQ.call({
132
+ type: "list",
133
+ query: query,
134
+ })];
135
+ case 1:
136
+ res = _g.sent();
137
+ return [4 /*yield*/, (0, exports.handleListDataBasedOnModel)(res === null || res === void 0 ? void 0 : res.data, devSettings, dbModule, (_d = schemaReference === null || schemaReference === void 0 ? void 0 : schemaReference[eachStructure.id]) !== null && _d !== void 0 ? _d : [], function () { })];
138
+ case 2:
139
+ showReferenceDataList_1 = _g.sent();
140
+ showReferenceStructure = (_e = schemaReference === null || schemaReference === void 0 ? void 0 : schemaReference[eachStructure.id]) !== null && _e !== void 0 ? _e : [];
141
+ return [4 /*yield*/, Promise.all(showReferenceStructure.map(function (eachReferenceStructure) { return __awaiter(void 0, void 0, void 0, function () {
142
+ var value;
143
+ return __generator(this, function (_a) {
144
+ value = showReferenceDataList_1.map(function (eachData) {
145
+ return eachData === null || eachData === void 0 ? void 0 : eachData[eachReferenceStructure.id];
146
+ });
147
+ eachData["".concat(eachStructure.id, "_").concat(eachReferenceStructure.id)] =
148
+ value;
149
+ return [2 /*return*/];
150
+ });
151
+ }); }))];
152
+ case 3:
153
+ _g.sent();
154
+ return [3 /*break*/, 5];
155
+ case 4:
156
+ err_1 = _g.sent();
157
+ return [3 /*break*/, 5];
158
+ case 5: return [2 /*return*/];
159
+ }
160
+ });
161
+ };
162
+ _i = 0, filterShowReferenceStructure_1 = filterShowReferenceStructure;
163
+ _f.label = 1;
164
+ case 1:
165
+ if (!(_i < filterShowReferenceStructure_1.length)) return [3 /*break*/, 4];
166
+ eachStructure = filterShowReferenceStructure_1[_i];
167
+ return [5 /*yield**/, _loop_1(eachStructure)];
168
+ case 2:
169
+ _f.sent();
170
+ _f.label = 3;
171
+ case 3:
172
+ _i++;
173
+ return [3 /*break*/, 1];
174
+ case 4: return [2 /*return*/, eachData];
175
+ }
176
+ });
177
+ }); };
178
+ var handleListDataBasedOnModel = function (data, devSettings, dbModule, modelSchema, handleNavigate, isTableView, setActivityModal, setActivityId, activityLog, addActionBtns, schemaReference) { return __awaiter(void 0, void 0, void 0, function () {
83
179
  var server, imageEndpoint, bucketName, organisationMembers, serverId, dataList, referenceDetails;
84
180
  return __generator(this, function (_a) {
85
181
  switch (_a.label) {
@@ -90,189 +186,221 @@ var handleListDataBasedOnModel = function (data, devSettings, dbModule, modelSch
90
186
  return [4 /*yield*/, (0, moduleUtils_1.handleListReferenceDetails)(data, modelSchema, dbModule, devSettings)];
91
187
  case 1:
92
188
  referenceDetails = _a.sent();
93
- data.map(function (eachDataAttribute) {
94
- var _a, _b, _c, _d, _e, _f;
95
- var eachData = {};
96
- var eachNewData = JSON.parse(JSON.stringify(eachDataAttribute), utils_1.jsonReviver);
97
- var eachDataId = (_a = eachNewData["id"]) !== null && _a !== void 0 ? _a : eachNewData["_id"];
98
- var isTag = false;
99
- var _loop_1 = function (eachKey, eachValue) {
100
- var model = modelSchema.find(function (eachAttribute) {
101
- return eachAttribute.id === eachKey;
102
- });
103
- var isDraft = isTableView ? eachNewData["baseDraft"] : false;
104
- switch (model === null || model === void 0 ? void 0 : model.type) {
105
- case "string":
106
- case "textArea":
107
- case "contact":
108
- case "email":
109
- if (eachKey === "id" || eachKey === "_id") {
110
- eachData[eachKey] = eachValue;
111
- }
112
- else {
113
- eachData[eachKey] =
114
- typeof eachValue === "string"
115
- ? eachValue.length > 60
116
- ? eachValue.substring(0, 60) + "..."
117
- : eachValue
118
- : eachValue;
119
- }
120
- break;
121
- case "date":
122
- if (typeof eachValue === "object" && eachValue instanceof Date) {
123
- eachData[eachKey] = (0, moment_1.default)(eachValue).format("YYYY-MM-DD hh:mm A");
124
- }
125
- else {
126
- eachData[eachKey] =
127
- typeof eachValue === "object"
128
- ? (0, moment_1.default)((eachValue === null || eachValue === void 0 ? void 0 : eachValue["_seconds"]) * 1000).format("YYYY-MM-DD hh:mm A")
129
- : eachValue;
130
- }
131
- break;
132
- case "number":
133
- case "boolean":
134
- case "address":
135
- case "object":
136
- case "multipleList":
137
- case "referenceSelection":
138
- eachData[eachKey] = eachValue;
139
- break;
140
- case "list":
141
- var colourPresent = "";
142
- if (((_b = model.listSelectionColour) === null || _b === void 0 ? void 0 : _b.length) > 0) {
143
- var colourIndex = (_c = model.listSelection) === null || _c === void 0 ? void 0 : _c.indexOf(eachValue);
144
- var selectedColour = model.listSelectionColour[colourIndex];
145
- if (selectedColour)
146
- colourPresent = selectedColour;
147
- }
148
- if (colourPresent)
149
- eachData[eachKey] = (react_1.default.createElement(tag_1.Tag, { size: "small", tagText: eachValue, color: colourPresent }));
150
- else
151
- eachData[eachKey] = eachValue;
152
- break;
153
- case "image":
154
- var url = (0, blobModule_1.renderImageUrlFromPath)(imageEndpoint, model.imageCollectionName, eachDataId, model.imageFileName, eachValue, bucketName);
155
- if (eachValue) {
156
- eachData[eachKey] = (react_1.default.createElement("img", { src: url, alt: "".concat(eachValue), className: "w-10 h-10 object-contain" }));
157
- }
158
- else {
159
- eachData[eachKey] = " - ";
160
- }
161
- break;
162
- case "multipleImage":
163
- if (eachValue && Array.isArray(eachValue) && eachValue.length > 0) {
164
- var imgList_1 = [];
165
- eachValue.map(function (eachImg) {
166
- var _a;
167
- var url = (0, blobModule_1.renderImageUrlFromPath)(imageEndpoint, model.imageCollectionName, eachDataId, eachImg.fileName, (_a = eachImg.token) !== null && _a !== void 0 ? _a : "", bucketName);
168
- imgList_1.push(react_1.default.createElement("img", { src: url, alt: "".concat(eachImg), className: "w-10 h-10 object-contain" }));
169
- return null;
170
- });
171
- eachData[eachKey] = (react_1.default.createElement("div", { className: "flex gap-x-2 w-max flex-wrap" }, imgList_1.map(function (eachImgElemnt) { return eachImgElemnt; })));
172
- }
173
- else
174
- eachData[eachKey] = " - ";
175
- break;
176
- case "reference":
177
- var currentReferenceData = (_d = referenceDetails === null || referenceDetails === void 0 ? void 0 : referenceDetails[eachKey]) === null || _d === void 0 ? void 0 : _d.find(function (eachDetail) {
178
- return eachDetail[serverId] === eachValue;
179
- });
180
- if (currentReferenceData) {
181
- eachData[eachKey] =
182
- (_e = currentReferenceData[model.referenceLabel]) !== null && _e !== void 0 ? _e : (0, moduleUtils_1.renderReferenceStringAttribute)(currentReferenceData);
183
- }
184
- else {
185
- eachData[eachKey] = " - ";
186
- }
187
- break;
188
- case "listReference":
189
- var referenceListLabel_1 = [];
190
- if (Array.isArray(eachValue)) {
191
- eachValue.map(function (value) {
192
- var _a;
193
- if (referenceDetails === null || referenceDetails === void 0 ? void 0 : referenceDetails[eachKey]) {
194
- var currentReferenceDetails = referenceDetails[eachKey].find(function (eachDetail) {
195
- return eachDetail[serverId] === value;
196
- });
197
- if (currentReferenceDetails) {
198
- referenceListLabel_1.push((_a = currentReferenceDetails[model.referenceLabel]) !== null && _a !== void 0 ? _a : (0, moduleUtils_1.renderReferenceStringAttribute)(currentReferenceDetails));
199
- }
189
+ return [4 /*yield*/, Promise.all(data.map(function (eachDataAttribute) { return __awaiter(void 0, void 0, void 0, function () {
190
+ var eachData, eachNewData, eachDataId, isTag, _loop_2, _i, _a, _b, eachKey, eachValue;
191
+ var _c, _d, _e, _f, _g, _h;
192
+ return __generator(this, function (_j) {
193
+ switch (_j.label) {
194
+ case 0:
195
+ eachData = {};
196
+ eachNewData = JSON.parse(JSON.stringify(eachDataAttribute), utils_1.jsonReviver);
197
+ eachDataId = (_c = eachNewData["id"]) !== null && _c !== void 0 ? _c : eachNewData["_id"];
198
+ isTag = false;
199
+ _loop_2 = function (eachKey, eachValue) {
200
+ var model = modelSchema.find(function (eachAttribute) { return eachAttribute.id === eachKey; });
201
+ var isDraft = isTableView ? eachNewData["baseDraft"] : false;
202
+ switch (model === null || model === void 0 ? void 0 : model.type) {
203
+ case "string":
204
+ case "textArea":
205
+ case "contact":
206
+ case "email":
207
+ if (eachKey === "id" || eachKey === "_id") {
208
+ eachData[eachKey] = eachValue;
209
+ }
210
+ else {
211
+ eachData[eachKey] =
212
+ typeof eachValue === "string"
213
+ ? eachValue.length > 60
214
+ ? eachValue.substring(0, 60) + "..."
215
+ : eachValue
216
+ : eachValue;
217
+ }
218
+ break;
219
+ case "date":
220
+ if (typeof eachValue === "object" && eachValue instanceof Date) {
221
+ eachData[eachKey] =
222
+ (0, moment_1.default)(eachValue).format("YYYY-MM-DD hh:mm A");
223
+ }
224
+ else {
225
+ eachData[eachKey] =
226
+ typeof eachValue === "object"
227
+ ? (0, moment_1.default)((eachValue === null || eachValue === void 0 ? void 0 : eachValue["_seconds"]) * 1000).format("YYYY-MM-DD hh:mm A")
228
+ : eachValue;
229
+ }
230
+ break;
231
+ case "number":
232
+ case "boolean":
233
+ case "address":
234
+ case "object":
235
+ case "multipleList":
236
+ case "referenceSelection":
237
+ eachData[eachKey] = eachValue;
238
+ break;
239
+ case "list":
240
+ var colourPresent = "";
241
+ if (model.listSelectionColour &&
242
+ ((_d = model === null || model === void 0 ? void 0 : model.listSelectionColour) === null || _d === void 0 ? void 0 : _d.length) > 0) {
243
+ var colourIndex = (_e = model.listSelection) === null || _e === void 0 ? void 0 : _e.indexOf(eachValue);
244
+ var selectedColour = model.listSelectionColour[colourIndex];
245
+ if (selectedColour)
246
+ colourPresent = selectedColour;
247
+ }
248
+ if (colourPresent)
249
+ eachData[eachKey] = (react_1.default.createElement(tag_1.Tag, { size: "small", tagText: eachValue, color: colourPresent }));
250
+ else
251
+ eachData[eachKey] = eachValue;
252
+ break;
253
+ case "image":
254
+ var url = (0, blobModule_1.renderImageUrlFromPath)(imageEndpoint, model.imageCollectionName, eachDataId, model.imageFileName, eachValue, bucketName);
255
+ if (eachValue) {
256
+ eachData[eachKey] = (react_1.default.createElement("img", { src: url, alt: "".concat(eachValue), className: "w-10 h-10 object-contain" }));
257
+ }
258
+ else {
259
+ eachData[eachKey] = " - ";
260
+ }
261
+ break;
262
+ case "multipleImage":
263
+ if (eachValue && Array.isArray(eachValue) && eachValue.length > 0) {
264
+ var imgList_1 = [];
265
+ eachValue.map(function (eachImg) {
266
+ var _a;
267
+ var url = (0, blobModule_1.renderImageUrlFromPath)(imageEndpoint, model.imageCollectionName, eachDataId, eachImg.fileName, (_a = eachImg.token) !== null && _a !== void 0 ? _a : "", bucketName);
268
+ imgList_1.push(react_1.default.createElement("img", { src: url, alt: "".concat(eachImg), className: "w-10 h-10 object-contain" }));
269
+ return null;
270
+ });
271
+ eachData[eachKey] = (react_1.default.createElement("div", { className: "flex gap-x-2 w-max flex-wrap" }, imgList_1.map(function (eachImgElemnt) { return eachImgElemnt; })));
272
+ }
273
+ else
274
+ eachData[eachKey] = " - ";
275
+ break;
276
+ case "reference":
277
+ var currentReferenceData = (_f = referenceDetails === null || referenceDetails === void 0 ? void 0 : referenceDetails[eachKey]) === null || _f === void 0 ? void 0 : _f.find(function (eachDetail) {
278
+ return eachDetail[serverId] === eachValue;
279
+ });
280
+ if (currentReferenceData) {
281
+ eachData[eachKey] =
282
+ (_g = currentReferenceData[model.referenceLabel]) !== null && _g !== void 0 ? _g : (0, moduleUtils_1.renderReferenceStringAttribute)(currentReferenceData);
283
+ }
284
+ else {
285
+ eachData[eachKey] = " - ";
286
+ }
287
+ break;
288
+ case "listReference":
289
+ var referenceListLabel_1 = [];
290
+ if (Array.isArray(eachValue)) {
291
+ eachValue.map(function (value) {
292
+ var _a;
293
+ if (referenceDetails === null || referenceDetails === void 0 ? void 0 : referenceDetails[eachKey]) {
294
+ var currentReferenceDetails = referenceDetails[eachKey].find(function (eachDetail) {
295
+ return eachDetail[serverId] === value;
296
+ });
297
+ if (currentReferenceDetails) {
298
+ referenceListLabel_1.push((_a = currentReferenceDetails[model.referenceLabel]) !== null && _a !== void 0 ? _a : (0, moduleUtils_1.renderReferenceStringAttribute)(currentReferenceDetails));
299
+ }
300
+ }
301
+ return null;
302
+ });
303
+ }
304
+ if (referenceListLabel_1.length === 0) {
305
+ referenceListLabel_1.push(" - ");
306
+ }
307
+ eachData[eachKey] = referenceListLabel_1;
308
+ break;
309
+ case "person":
310
+ case "listPerson":
311
+ var personData_1 = [];
312
+ if (organisationMembers) {
313
+ if (Array.isArray(eachValue)) {
314
+ personData_1 = organisationMembers.filter(function (orgMember) {
315
+ return eachValue.includes(orgMember.key);
316
+ });
317
+ }
318
+ else if (eachValue) {
319
+ personData_1 = organisationMembers.filter(function (orgMember) { return eachValue === orgMember.key; });
320
+ }
321
+ }
322
+ var personValue = " - ";
323
+ if (personData_1.length > 0) {
324
+ var name_1 = "";
325
+ personData_1.map(function (eachPerson, index) {
326
+ name_1 +=
327
+ eachPerson.label + (index + 1 < personData_1.length ? "," : "");
328
+ return null;
329
+ });
330
+ personValue = (react_1.default.createElement("div", { className: "flex flex-row" },
331
+ personData_1.map(function (eachPerson, index) { return (react_1.default.createElement("img", { key: eachPerson.key + index, src: eachPerson.image, className: "rounded-full w-6 h-6 ".concat(index > 0 ? "-ml-3" : ""), alt: "" })); }),
332
+ react_1.default.createElement("p", { className: "ml-2" }, name_1)));
333
+ }
334
+ eachData[eachKey] = personValue;
335
+ break;
336
+ case "markdown":
337
+ var markdownValue = (react_1.default.createElement("div", null,
338
+ react_1.default.createElement(react_md_editor_1.default.Markdown, { source: (_h = eachValue) !== null && _h !== void 0 ? _h : "", wrapperElement: { "data-color-mode": "light" }, className: "no-tailwind", style: {
339
+ fontSize: 14,
340
+ lineHeight: 1.25,
341
+ wordBreak: "break-word",
342
+ backgroundColor: "transparent",
343
+ },
344
+ // INFO : Disble header link
345
+ rehypeRewrite: function (node, _index, parent) {
346
+ if (node.tagName === "a" &&
347
+ parent &&
348
+ /^h(1|2|3|4|5|6)/.test(parent.tagName)) {
349
+ parent.children = parent.children.slice(1);
350
+ }
351
+ } })));
352
+ eachData[eachKey] = markdownValue;
353
+ break;
354
+ default:
355
+ if (eachKey === "id" || eachKey === "_id") {
356
+ eachData[eachKey] = eachValue;
357
+ }
358
+ break;
200
359
  }
201
- return null;
202
- });
203
- }
204
- if (referenceListLabel_1.length === 0) {
205
- referenceListLabel_1.push(" - ");
206
- }
207
- eachData[eachKey] = referenceListLabel_1;
208
- break;
209
- case "person":
210
- case "listPerson":
211
- var personData_1 = [];
212
- if (organisationMembers) {
213
- if (Array.isArray(eachValue)) {
214
- personData_1 = organisationMembers.filter(function (orgMember) {
215
- return eachValue.includes(orgMember.key);
216
- });
217
- }
218
- else if (eachValue) {
219
- personData_1 = organisationMembers.filter(function (orgMember) { return eachValue === orgMember.key; });
360
+ //TODO : Change draft position
361
+ if (isDraft && !isTag && eachKey !== "_id" && eachKey !== "id") {
362
+ eachData[eachKey] = (react_1.default.createElement("div", { className: "flex flex-row justify-start items-center" },
363
+ react_1.default.createElement(tag_1.Tag, { size: "small", tagText: "Draft" }),
364
+ eachData[eachKey]));
365
+ isTag = true;
366
+ }
367
+ };
368
+ for (_i = 0, _a = Object.entries(eachNewData); _i < _a.length; _i++) {
369
+ _b = _a[_i], eachKey = _b[0], eachValue = _b[1];
370
+ _loop_2(eachKey, eachValue);
220
371
  }
221
- }
222
- var personValue = " - ";
223
- if (personData_1.length > 0) {
224
- var name_1 = "";
225
- personData_1.map(function (eachPerson, index) {
226
- name_1 +=
227
- eachPerson.label + (index + 1 < personData_1.length ? "," : "");
372
+ return [4 /*yield*/, handleProcessShowReferences(eachData, eachNewData, modelSchema, devSettings, dbModule, schemaReference)];
373
+ case 1:
374
+ eachData = _j.sent();
375
+ modelSchema.map(function (eachModel) {
376
+ switch (eachModel.type) {
377
+ case "math":
378
+ try {
379
+ var expr = parser.parse(eachModel.mathExpression);
380
+ var variableKeys_1 = {};
381
+ var exprVariables = expr.variables();
382
+ exprVariables === null || exprVariables === void 0 ? void 0 : exprVariables.map(function (eachVariable) {
383
+ variableKeys_1[eachVariable] = eachDataAttribute[eachVariable];
384
+ return null;
385
+ });
386
+ eachData[eachModel.id] = expr.evaluate(variableKeys_1);
387
+ }
388
+ catch (err) {
389
+ eachData[eachModel.id] = "Error";
390
+ }
391
+ break;
392
+ }
228
393
  return null;
229
394
  });
230
- personValue = (react_1.default.createElement("div", { className: "flex flex-row" },
231
- personData_1.map(function (eachPerson, index) { return (react_1.default.createElement("img", { key: eachPerson.key + index, src: eachPerson.image, className: "rounded-full w-6 h-6 ".concat(index > 0 ? "-ml-3" : ""), alt: "" })); }),
232
- react_1.default.createElement("p", { className: "ml-2" }, name_1)));
233
- }
234
- eachData[eachKey] = personValue;
235
- break;
236
- case "markdown":
237
- var markdownValue = (react_1.default.createElement("div", null,
238
- react_1.default.createElement(react_md_editor_1.default.Markdown, { source: (_f = eachValue) !== null && _f !== void 0 ? _f : "", wrapperElement: { "data-color-mode": "light" }, className: "no-tailwind", style: {
239
- fontSize: 14,
240
- lineHeight: 1.25,
241
- wordBreak: "break-word",
242
- backgroundColor: "transparent",
243
- },
244
- // INFO : Disble header link
245
- rehypeRewrite: function (node, _index, parent) {
246
- if (node.tagName === "a" &&
247
- parent &&
248
- /^h(1|2|3|4|5|6)/.test(parent.tagName)) {
249
- parent.children = parent.children.slice(1);
250
- }
251
- } })));
252
- eachData[eachKey] = markdownValue;
253
- break;
254
- default:
255
- if (eachKey === "id" || eachKey === "_id") {
256
- eachData[eachKey] = eachValue;
257
- }
258
- break;
259
- }
260
- if (isDraft && !isTag && eachKey !== "_id" && eachKey !== "id") {
261
- eachData[eachKey] = (react_1.default.createElement("div", { className: "flex flex-row justify-start items-center" },
262
- react_1.default.createElement(tag_1.Tag, { size: "small", tagText: "Draft" }),
263
- eachData[eachKey]));
264
- isTag = true;
265
- }
266
- };
267
- for (var _i = 0, _g = Object.entries(eachNewData); _i < _g.length; _i++) {
268
- var _h = _g[_i], eachKey = _h[0], eachValue = _h[1];
269
- _loop_1(eachKey, eachValue);
270
- }
271
- (0, exports.handleDataEditButton)(eachData, handleNavigate, addActionBtns, setActivityModal, setActivityId, activityLog);
272
- dataList.push(server === "mongoServer"
273
- ? __assign(__assign({}, eachData), { id: eachData["_id"] }) : __assign({}, eachData));
274
- return null;
275
- });
395
+ (0, exports.handleDataEditButton)(eachData, handleNavigate, addActionBtns, setActivityModal, setActivityId, activityLog);
396
+ dataList.push(server === "mongoServer"
397
+ ? __assign(__assign({}, eachData), { id: eachData["_id"] }) : __assign({}, eachData));
398
+ return [2 /*return*/, null];
399
+ }
400
+ });
401
+ }); }))];
402
+ case 2:
403
+ _a.sent();
276
404
  return [2 /*return*/, dataList];
277
405
  }
278
406
  });
@@ -299,36 +427,77 @@ var handleDataEditButton = function (eachData, handleNavigate, addActionBtns, se
299
427
  } }))));
300
428
  };
301
429
  exports.handleDataEditButton = handleDataEditButton;
430
+ var renderSearchAdditionalQueries = function (dataStructure, additionalQueries) {
431
+ var clonedQueries = JSON.parse(JSON.stringify(additionalQueries !== null && additionalQueries !== void 0 ? additionalQueries : []));
432
+ dataStructure.map(function (eachStructure) {
433
+ if (!clonedQueries.some(function (eachQuery) { return eachQuery.value === eachStructure.id; })) {
434
+ switch (eachStructure.type) {
435
+ case "date":
436
+ clonedQueries.push({
437
+ type: "range",
438
+ value: eachStructure.id,
439
+ });
440
+ break;
441
+ case "list":
442
+ case "multipleList":
443
+ clonedQueries.push({
444
+ type: "list",
445
+ value: eachStructure.id,
446
+ options: eachStructure.listSelection,
447
+ });
448
+ break;
449
+ case "reference":
450
+ case "listReference":
451
+ clonedQueries.push({
452
+ type: "reference",
453
+ value: eachStructure.id,
454
+ spaceId: eachStructure.referenceSpaceId,
455
+ label: eachStructure.referenceLabel,
456
+ referenceQuery: eachStructure.referenceQuery,
457
+ });
458
+ break;
459
+ }
460
+ }
461
+ return null;
462
+ });
463
+ return clonedQueries;
464
+ };
465
+ exports.renderSearchAdditionalQueries = renderSearchAdditionalQueries;
302
466
  var renderSearchFilterConditions = function (model, devSettings, state, organise, bareListFilterQuery, selectedTab) {
303
- var _a;
304
467
  var filterSearchParams = state.filterSearchParams, filterSelection = state.filterSelection, filterReferenceDate = state.filterReferenceDate, filterReference = state.filterReference;
305
468
  var query = [];
306
469
  var searchQueryExist = false;
307
470
  var isFirebase = devSettings.server === "fbServer" || devSettings.server === "firebase";
308
- (_a = organise === null || organise === void 0 ? void 0 : organise.additionalQuery) === null || _a === void 0 ? void 0 : _a.map(function (eachSettings) {
309
- var _a;
471
+ var additionalQueries = (0, exports.renderSearchAdditionalQueries)(model, organise === null || organise === void 0 ? void 0 : organise.additionalQuery);
472
+ additionalQueries.map(function (eachSettings) {
473
+ var _a, _b;
310
474
  if ((eachSettings.type === "list" || eachSettings.type === "person") &&
311
- (filterSelection === null || filterSelection === void 0 ? void 0 : filterSelection[eachSettings.value])) {
312
- var selectedStructure = model.find(function (eachDataStructure) {
475
+ ((_a = filterSelection === null || filterSelection === void 0 ? void 0 : filterSelection[eachSettings.value]) === null || _a === void 0 ? void 0 : _a.length) > 0) {
476
+ var selectedStructure_1 = model.find(function (eachDataStructure) {
313
477
  return eachDataStructure.id === eachSettings.value;
314
478
  });
315
- var currentSelection = filterSelection === null || filterSelection === void 0 ? void 0 : filterSelection[eachSettings.value];
316
- if (currentSelection === "false" || currentSelection === "true") {
317
- currentSelection = currentSelection === "false" ? false : true;
318
- }
319
- else if ((selectedStructure === null || selectedStructure === void 0 ? void 0 : selectedStructure.type) === "number" &&
320
- !isNaN(currentSelection)) {
321
- currentSelection = Number(currentSelection);
322
- }
479
+ var currentSelection = JSON.parse(JSON.stringify(filterSelection === null || filterSelection === void 0 ? void 0 : filterSelection[eachSettings.value]));
480
+ var newSelection_1 = [];
481
+ currentSelection === null || currentSelection === void 0 ? void 0 : currentSelection.map(function (eachSelection) {
482
+ if (eachSelection === "false" || eachSelection === "true") {
483
+ eachSelection = eachSelection === "false" ? false : true;
484
+ }
485
+ else if ((selectedStructure_1 === null || selectedStructure_1 === void 0 ? void 0 : selectedStructure_1.type) === "number" &&
486
+ !isNaN(eachSelection)) {
487
+ eachSelection = Number(eachSelection);
488
+ }
489
+ newSelection_1.push(eachSelection);
490
+ return null;
491
+ });
323
492
  query.push({
324
- type: "=",
493
+ type: "in",
325
494
  queryId: eachSettings.value,
326
- value: currentSelection,
495
+ value: newSelection_1,
327
496
  });
328
497
  }
329
498
  else if ((eachSettings.type === "reference" ||
330
499
  eachSettings.type === "listReference") &&
331
- ((_a = filterReference === null || filterReference === void 0 ? void 0 : filterReference[eachSettings.value]) === null || _a === void 0 ? void 0 : _a.length) > 0) {
500
+ ((_b = filterReference === null || filterReference === void 0 ? void 0 : filterReference[eachSettings.value]) === null || _b === void 0 ? void 0 : _b.length) > 0) {
332
501
  if ((filterReference === null || filterReference === void 0 ? void 0 : filterReference[eachSettings.value]) === "emptyValueDev") {
333
502
  query.push({
334
503
  type: "in",
@@ -338,7 +507,8 @@ var renderSearchFilterConditions = function (model, devSettings, state, organise
338
507
  }
339
508
  else {
340
509
  query.push({
341
- type: eachSettings.type === "reference" ? "=" : "in",
510
+ // type: eachSettings.type === "reference" ? "=" : "in",
511
+ type: "in",
342
512
  queryId: eachSettings.value,
343
513
  value: JSON.parse(JSON.stringify(filterReference === null || filterReference === void 0 ? void 0 : filterReference[eachSettings.value])),
344
514
  });
@@ -442,7 +612,7 @@ var renderSearchFilterComponents = function (model, devSettings, limit, dbModule
442
612
  return null;
443
613
  });
444
614
  }
445
- searchFilterList.push(react_1.default.createElement(select_1.Select, { label: "Filter by ".concat((0, utils_1.camelCaseToText)((_c = eachSettings.filterLabel) !== null && _c !== void 0 ? _c : eachSettings.value)), placeholder: (0, utils_1.camelCaseToText)((_d = eachSettings.filterLabel) !== null && _d !== void 0 ? _d : eachSettings.value), options: filterOptions_1, value: (_e = filterSelection === null || filterSelection === void 0 ? void 0 : filterSelection[eachSettings.value]) !== null && _e !== void 0 ? _e : "", onChange: function (value) {
615
+ searchFilterList.push(react_1.default.createElement(select_1.Select, { label: "Filter by ".concat((0, utils_1.camelCaseToText)((_c = eachSettings.filterLabel) !== null && _c !== void 0 ? _c : eachSettings.value)), placeholder: (0, utils_1.camelCaseToText)((_d = eachSettings.filterLabel) !== null && _d !== void 0 ? _d : eachSettings.value), options: filterOptions_1, value: (_e = filterSelection === null || filterSelection === void 0 ? void 0 : filterSelection[eachSettings.value]) !== null && _e !== void 0 ? _e : [], onChange: function (value) {
446
616
  handleClearDataByFilter("list");
447
617
  var clonedFilterSelection = JSON.parse(JSON.stringify(filterSelection));
448
618
  clonedFilterSelection[eachSettings.value] = value;
@@ -453,8 +623,8 @@ var renderSearchFilterComponents = function (model, devSettings, limit, dbModule
453
623
  case "reference":
454
624
  case "listReference":
455
625
  var selectedModel_1 = model.find(function (eachDataStructure) { return eachDataStructure.id === eachSettings.value; });
456
- var defaultValue = eachSettings.type === "listReference" ? [] : "";
457
- var selectedValue = (_f = filterReference === null || filterReference === void 0 ? void 0 : filterReference[eachSettings.value]) !== null && _f !== void 0 ? _f : defaultValue;
626
+ // const defaultValue = eachSettings.type === "listReference" ? [] : "";
627
+ var selectedValue = (_f = filterReference === null || filterReference === void 0 ? void 0 : filterReference[eachSettings.value]) !== null && _f !== void 0 ? _f : [];
458
628
  var referenceQuery = [];
459
629
  if (filterReferenceSearch === null || filterReferenceSearch === void 0 ? void 0 : filterReferenceSearch[eachSettings.value])
460
630
  referenceQuery = referenceQuery.concat([
@@ -547,7 +717,7 @@ var renderSelectedRefreshTab = function (localURLEndpoint, type, collectionId, d
547
717
  };
548
718
  exports.renderSelectedRefreshTab = renderSelectedRefreshTab;
549
719
  var handleExportPDF = function (csvDownloadLink, printOnly) { return __awaiter(void 0, void 0, void 0, function () {
550
- var response, csvData, fileName_1, err_1;
720
+ var response, csvData, fileName_1, err_2;
551
721
  var _a;
552
722
  return __generator(this, function (_b) {
553
723
  switch (_b.label) {
@@ -600,8 +770,8 @@ var handleExportPDF = function (csvDownloadLink, printOnly) { return __awaiter(v
600
770
  });
601
771
  return [3 /*break*/, 4];
602
772
  case 3:
603
- err_1 = _b.sent();
604
- throw err_1;
773
+ err_2 = _b.sent();
774
+ throw err_2;
605
775
  case 4: return [2 /*return*/];
606
776
  }
607
777
  });