blixify-ui-web 1.2.20 → 1.2.22
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.map +1 -1
- package/lib/components/data/dataTemplate/index.js +944 -325
- package/lib/components/data/dataTemplate/index.js.map +1 -1
- package/lib/components/data/dataTemplate/indexedDb.d.ts +20 -0
- package/lib/components/data/dataTemplate/indexedDb.d.ts.map +1 -1
- package/lib/components/data/dataTemplate/indexedDb.js +86 -0
- package/lib/components/data/dataTemplate/indexedDb.js.map +1 -1
- package/lib/components/data/dataTemplate/model.d.ts +77 -0
- package/lib/components/data/dataTemplate/model.d.ts.map +1 -1
- package/lib/components/data/dataTemplate/socket.d.ts +34 -0
- package/lib/components/data/dataTemplate/socket.d.ts.map +1 -0
- package/lib/components/data/dataTemplate/socket.js +161 -0
- package/lib/components/data/dataTemplate/socket.js.map +1 -0
- package/lib/components/data/dataTemplate/workspaceModel.d.ts +6 -0
- package/lib/components/data/dataTemplate/workspaceModel.d.ts.map +1 -1
- package/lib/components/data/readQueryHoc/index.d.ts.map +1 -1
- package/lib/components/data/readQueryHoc/index.js +61 -15
- package/lib/components/data/readQueryHoc/index.js.map +1 -1
- package/lib/components/data/testSchema.d.ts.map +1 -1
- package/lib/components/data/testSchema.js +1 -0
- package/lib/components/data/testSchema.js.map +1 -1
- package/lib/components/data/updateModule.d.ts.map +1 -1
- package/lib/components/data/updateModule.js +51 -12
- package/lib/components/data/updateModule.js.map +1 -1
- package/lib/components/data/utils.d.ts.map +1 -1
- package/lib/components/data/utils.js +2 -0
- package/lib/components/data/utils.js.map +1 -1
- package/package.json +1 -1
|
@@ -142,13 +142,14 @@ var activityModal_1 = require("./activityModal");
|
|
|
142
142
|
var authModal_1 = require("./authModal");
|
|
143
143
|
var dataStateModel_1 = require("./dataStateModel");
|
|
144
144
|
var indexedDb_1 = require("./indexedDb");
|
|
145
|
+
var socket_1 = require("./socket");
|
|
145
146
|
var pagination_1 = require("./pagination");
|
|
146
147
|
var referenceModal_1 = require("./referenceModal");
|
|
147
148
|
var settingsModal_1 = require("./settingsModal");
|
|
148
149
|
var flexFilterModel_1 = require("./flexFilterModel");
|
|
149
150
|
var flexFilterModule_1 = require("./flexFilterModule");
|
|
150
151
|
exports.DataTemplate = (0, react_1.forwardRef)(function (props, ref) {
|
|
151
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, _21, _22, _23, _24, _25, _26, _27, _28, _29, _30, _31, _32, _33, _34, _35, _36, _37, _38, _39, _40, _41;
|
|
152
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, _21, _22, _23, _24, _25, _26, _27, _28, _29, _30, _31, _32, _33, _34, _35, _36, _37, _38, _39, _40, _41, _42, _43, _44;
|
|
152
153
|
var intialiseDefaultFilterValues = function () {
|
|
153
154
|
var _a;
|
|
154
155
|
var initialFilterSearch = {};
|
|
@@ -209,136 +210,143 @@ exports.DataTemplate = (0, react_1.forwardRef)(function (props, ref) {
|
|
|
209
210
|
initialFilterReferenceDate: initialFilterReferenceDate,
|
|
210
211
|
};
|
|
211
212
|
};
|
|
212
|
-
var
|
|
213
|
-
var
|
|
214
|
-
var
|
|
213
|
+
var _45 = intialiseDefaultFilterValues(), initialFilterSearch = _45.initialFilterSearch, initialFilterSearchParams = _45.initialFilterSearchParams, initialFilterSelection = _45.initialFilterSelection, initialFilterReference = _45.initialFilterReference, initialFilterReferenceDate = _45.initialFilterReferenceDate;
|
|
214
|
+
var _46 = (0, react_1.useState)(false), loading = _46[0], setLoading = _46[1];
|
|
215
|
+
var _47 = (0, react_1.useState)(), notification = _47[0], setNotification = _47[1];
|
|
215
216
|
//INFO : Used by List
|
|
216
|
-
var
|
|
217
|
-
var
|
|
218
|
-
var
|
|
219
|
-
var
|
|
220
|
-
var
|
|
221
|
-
var
|
|
222
|
-
var
|
|
223
|
-
var
|
|
224
|
-
var
|
|
225
|
-
var
|
|
226
|
-
var
|
|
227
|
-
var
|
|
228
|
-
var
|
|
229
|
-
var
|
|
230
|
-
var
|
|
231
|
-
var
|
|
232
|
-
var
|
|
233
|
-
var
|
|
234
|
-
var
|
|
217
|
+
var _48 = (0, react_1.useState)(initialFilterSearch), filterSearch = _48[0], setFilterSearch = _48[1];
|
|
218
|
+
var _49 = (0, react_1.useState)(initialFilterSearchParams), filterSearchParams = _49[0], setFilterSearchParams = _49[1];
|
|
219
|
+
var _50 = (0, react_1.useState)(initialFilterSelection), filterSelection = _50[0], setFilterSelection = _50[1];
|
|
220
|
+
var _51 = (0, react_1.useState)(initialFilterReference), filterReference = _51[0], setFilterReference = _51[1];
|
|
221
|
+
var _52 = (0, react_1.useState)({}), filterReferenceSearch = _52[0], setFilterReferenceSearch = _52[1];
|
|
222
|
+
var _53 = (0, react_1.useState)({}), filterReferenceList = _53[0], setFilterReferenceList = _53[1];
|
|
223
|
+
var _54 = (0, react_1.useState)(initialFilterReferenceDate), filterReferenceDate = _54[0], setFilterReferenceDate = _54[1];
|
|
224
|
+
var _55 = (0, react_1.useState)(true), tableLoading = _55[0], setTableLoading = _55[1];
|
|
225
|
+
var _56 = (0, react_1.useState)(""), cursor = _56[0], setCursor = _56[1];
|
|
226
|
+
var _57 = (0, react_1.useState)(""), lastCursor = _57[0], setLastCursor = _57[1];
|
|
227
|
+
var _58 = (0, react_1.useState)([]), tableData = _58[0], setTableData = _58[1];
|
|
228
|
+
var _59 = (0, react_1.useState)([]), spaceTableData = _59[0], setSpaceTableData = _59[1];
|
|
229
|
+
var _60 = (0, react_1.useState)(0), size = _60[0], setSize = _60[1];
|
|
230
|
+
var _61 = (0, react_1.useState)((_b = (_a = props.organise) === null || _a === void 0 ? void 0 : _a.pageIndex) !== null && _b !== void 0 ? _b : 0), pageIndex = _61[0], setPageIndex = _61[1];
|
|
231
|
+
var _62 = (0, react_1.useState)([]), selectedIds = _62[0], setSelectedIds = _62[1];
|
|
232
|
+
var _63 = (0, react_1.useState)(false), selectAll = _63[0], setSelectAll = _63[1];
|
|
233
|
+
var _64 = (0, react_1.useState)(""), deletePasscode = _64[0], setDeletePasscode = _64[1];
|
|
234
|
+
var _65 = (0, react_1.useState)(""), deletePasscodeInput = _65[0], setDeletePasscodeInput = _65[1];
|
|
235
|
+
var _66 = (0, react_1.useState)(""), deleteFeedId = _66[0], setDeleteFeedId = _66[1];
|
|
235
236
|
//INFO : Used by List Organise
|
|
236
|
-
var
|
|
237
|
-
var
|
|
238
|
-
var
|
|
239
|
-
var
|
|
240
|
-
var
|
|
241
|
-
var
|
|
237
|
+
var _67 = (0, react_1.useState)(false), sortModal = _67[0], setSortModal = _67[1];
|
|
238
|
+
var _68 = (0, react_1.useState)(false), filterModal = _68[0], setFilterModal = _68[1];
|
|
239
|
+
var _69 = (0, react_1.useState)(false), filterDraft = _69[0], setFilterDraft = _69[1];
|
|
240
|
+
var _70 = (0, react_1.useState)(false), addTabModal = _70[0], setAddTabModal = _70[1];
|
|
241
|
+
var _71 = (0, react_1.useState)(false), overviewModal = _71[0], setOverviewModal = _71[1];
|
|
242
|
+
var _72 = (0, react_1.useState)(props.defaultTab
|
|
242
243
|
? (0, listModule_1.renderSelectedRefreshTab)(props.localURLEndpoint, props.type, props.collectionId, props.id, (_c = props.organise) === null || _c === void 0 ? void 0 : _c.extendedTabs, (_d = props.organise) === null || _d === void 0 ? void 0 : _d.viewId)
|
|
243
|
-
: ""), selectedTab =
|
|
244
|
-
var
|
|
245
|
-
var
|
|
246
|
-
var
|
|
247
|
-
var
|
|
248
|
-
var
|
|
249
|
-
var
|
|
250
|
-
var
|
|
244
|
+
: ""), selectedTab = _72[0], setSelectedTab = _72[1];
|
|
245
|
+
var _73 = (0, react_1.useState)("dayGridMonth"), calendarView = _73[0], setCalendarView = _73[1];
|
|
246
|
+
var _74 = (0, react_1.useState)(new Date()), calendarTabMonth = _74[0], setCalendarTabMonth = _74[1];
|
|
247
|
+
var _75 = (0, react_1.useState)(true), kanbanDroppable = _75[0], setKanbanDroppable = _75[1];
|
|
248
|
+
var _76 = (0, react_1.useState)([]), kanbanOptions = _76[0], setKanbanOptions = _76[1];
|
|
249
|
+
var _77 = (0, react_1.useState)(false), queryForm = _77[0], setQueryForm = _77[1];
|
|
250
|
+
var _78 = (0, react_1.useState)(false), batchUpdateModal = _78[0], setBatchUpdateModal = _78[1];
|
|
251
|
+
var _79 = (0, react_1.useState)({
|
|
251
252
|
columnId: "",
|
|
252
253
|
columnData: {},
|
|
253
|
-
}), batchUpdateData =
|
|
254
|
-
var
|
|
255
|
-
var
|
|
254
|
+
}), batchUpdateData = _79[0], setBatchUpdateData = _79[1];
|
|
255
|
+
var _80 = (0, react_1.useState)((props === null || props === void 0 ? void 0 : props.model) || []), structure = _80[0], setStructure = _80[1];
|
|
256
|
+
var _81 = (0, react_1.useState)(((_e = props === null || props === void 0 ? void 0 : props.organise) === null || _e === void 0 ? void 0 : _e.additionalQuery) || []), additionalQuery = _81[0], setAdditionalQuery = _81[1];
|
|
256
257
|
// INFO: State for user-configurable flex filters (Monday.com-style)
|
|
257
258
|
// INFO: Initialize with one empty row so users see inputs immediately without clicking "Add Filter"
|
|
258
|
-
var
|
|
259
|
+
var _82 = (0, react_1.useState)([
|
|
259
260
|
{
|
|
260
261
|
id: "flex-filter-init-row",
|
|
261
262
|
columnId: "",
|
|
262
263
|
operator: "=",
|
|
263
264
|
value: undefined,
|
|
264
265
|
},
|
|
265
|
-
]), flexFilters =
|
|
266
|
-
var
|
|
267
|
-
var
|
|
268
|
-
var
|
|
266
|
+
]), flexFilters = _82[0], setFlexFilters = _82[1];
|
|
267
|
+
var _83 = (0, react_1.useState)({}), flexFilterReferenceOptions = _83[0], setFlexFilterReferenceOptions = _83[1];
|
|
268
|
+
var _84 = (0, react_1.useState)({}), flexFilterReferenceSearch = _84[0], setFlexFilterReferenceSearch = _84[1];
|
|
269
|
+
var _85 = (0, react_1.useState)(false), flexFilterModalOpen = _85[0], setFlexFilterModalOpen = _85[1];
|
|
269
270
|
//INFO : Used by Auth
|
|
270
|
-
var
|
|
271
|
+
var _86 = (0, react_1.useState)({
|
|
271
272
|
email: "",
|
|
272
273
|
google: "",
|
|
273
274
|
phone: "",
|
|
274
275
|
disabled: false,
|
|
275
276
|
create: false,
|
|
276
|
-
}), authMethods =
|
|
277
|
-
var
|
|
277
|
+
}), authMethods = _86[0], setAuthMethods = _86[1];
|
|
278
|
+
var _87 = (0, react_1.useState)(""), selectedAuthMethod = _87[0], setSelectedAuthMethod = _87[1];
|
|
278
279
|
// INFO: Used by Activity Log
|
|
279
|
-
var
|
|
280
|
-
var
|
|
280
|
+
var _88 = (0, react_1.useState)(false), activityModal = _88[0], setActivityModal = _88[1];
|
|
281
|
+
var _89 = (0, react_1.useState)(""), activityId = _89[0], setActivityId = _89[1];
|
|
281
282
|
//INFO : Used by Export
|
|
282
|
-
var
|
|
283
|
-
var
|
|
284
|
-
var
|
|
285
|
-
var
|
|
286
|
-
var
|
|
287
|
-
var
|
|
288
|
-
var
|
|
289
|
-
var
|
|
290
|
-
var
|
|
291
|
-
var
|
|
292
|
-
var
|
|
293
|
-
var
|
|
294
|
-
var
|
|
295
|
-
var
|
|
296
|
-
var
|
|
297
|
-
var
|
|
298
|
-
var
|
|
299
|
-
var
|
|
300
|
-
var
|
|
283
|
+
var _90 = (0, react_1.useState)(null), csvFile = _90[0], setCSVFile = _90[1];
|
|
284
|
+
var _91 = (0, react_1.useState)([]), csvFileData = _91[0], setCSVFileData = _91[1];
|
|
285
|
+
var _92 = (0, react_1.useState)(0), stepCSVIndex = _92[0], setStepCSVIndex = _92[1];
|
|
286
|
+
var _93 = (0, react_1.useState)({}), listCSVMapAttribute = _93[0], setListCSVMapAttribute = _93[1];
|
|
287
|
+
var _94 = (0, react_1.useState)({}), listCSVObjAttribute = _94[0], setListCSVObjAttribute = _94[1];
|
|
288
|
+
var _95 = (0, react_1.useState)([]), csvAPIAttribute = _95[0], setCSVAPIAttribute = _95[1];
|
|
289
|
+
var _96 = (0, react_1.useState)(((_f = props.devSettings.currentUser) === null || _f === void 0 ? void 0 : _f.userEmail) || ""), exportCSVEmail = _96[0], setExportCSVEmail = _96[1];
|
|
290
|
+
var _97 = (0, react_1.useState)(((_h = (_g = props.organise) === null || _g === void 0 ? void 0 : _g.exportSettings) === null || _h === void 0 ? void 0 : _h.defaultExportPDFName) || ""), exportPDFTitle = _97[0], setExportPDFTitle = _97[1];
|
|
291
|
+
var _98 = (0, react_1.useState)(false), exportPDFLoading = _98[0], setExportPDFLoading = _98[1];
|
|
292
|
+
var _99 = (0, react_1.useState)(false), exportReadPDFLoading = _99[0], setExportReadPDFLoading = _99[1];
|
|
293
|
+
var _100 = (0, react_1.useState)((_l = (_k = (_j = props.organise) === null || _j === void 0 ? void 0 : _j.exportSettings) === null || _k === void 0 ? void 0 : _k.sumColumnId) !== null && _l !== void 0 ? _l : []), exportSumAttributeIds = _100[0], setExportSumAttributeIds = _100[1];
|
|
294
|
+
var _101 = (0, react_1.useState)((_p = (_o = (_m = props.organise) === null || _m === void 0 ? void 0 : _m.exportSettings) === null || _o === void 0 ? void 0 : _o.hideSubItems) !== null && _p !== void 0 ? _p : false), hideSubItems = _101[0], setHideSubItems = _101[1];
|
|
295
|
+
var _102 = (0, react_1.useState)([]), importTableData = _102[0], setImportTableData = _102[1];
|
|
296
|
+
var _103 = (0, react_1.useState)([]), queryList = _103[0], setQueryList = _103[1];
|
|
297
|
+
var _104 = (0, react_1.useState)(undefined), allQueryList = _104[0], setAllQueryList = _104[1];
|
|
298
|
+
var _105 = (0, react_1.useState)(-1), queryIndex = _105[0], setQueryIndex = _105[1];
|
|
299
|
+
var _106 = (0, react_1.useState)((_q = props.organise) === null || _q === void 0 ? void 0 : _q.groupBy), groupId = _106[0], setGroupId = _106[1];
|
|
300
|
+
var _107 = (0, react_1.useState)(""), readTabSection = _107[0], setReadTabSection = _107[1];
|
|
301
|
+
var _108 = (0, react_1.useState)(false), readFloatingNav = _108[0], setReadFloatingNav = _108[1];
|
|
301
302
|
var readTabSectionRefs = (0, react_1.useRef)({});
|
|
302
303
|
//INFO : Used by Read
|
|
303
304
|
//INFO : Used by Update
|
|
304
|
-
var
|
|
305
|
-
var
|
|
306
|
-
var
|
|
307
|
-
var
|
|
308
|
-
var
|
|
309
|
-
var
|
|
310
|
-
var
|
|
305
|
+
var _109 = (0, react_1.useState)(false), modalVisible = _109[0], setModalVisible = _109[1];
|
|
306
|
+
var _110 = (0, react_1.useState)(false), deleteModal = _110[0], setDeleteModal = _110[1];
|
|
307
|
+
var _111 = (0, react_1.useState)(false), excelModal = _111[0], setExcelModal = _111[1];
|
|
308
|
+
var _112 = (0, react_1.useState)(false), exportExcel = _112[0], setExportExcel = _112[1];
|
|
309
|
+
var _113 = (0, react_1.useState)(""), exportType = _113[0], setExportType = _113[1];
|
|
310
|
+
var _114 = (0, react_1.useState)(false), exportQR = _114[0], setExportQR = _114[1];
|
|
311
|
+
var _115 = (0, react_1.useState)(function () {
|
|
311
312
|
var _a, _b;
|
|
312
313
|
var firstTabId = (_b = (_a = structure.find(function (item) { return item.tabId; })) === null || _a === void 0 ? void 0 : _a.tabId) !== null && _b !== void 0 ? _b : "";
|
|
313
314
|
return firstTabId;
|
|
314
|
-
}), activeTab =
|
|
315
|
-
var
|
|
316
|
-
var
|
|
317
|
-
var
|
|
318
|
-
var
|
|
319
|
-
var
|
|
320
|
-
var
|
|
321
|
-
var
|
|
315
|
+
}), activeTab = _115[0], setActiveTab = _115[1];
|
|
316
|
+
var _116 = (0, react_1.useState)(false), signatureSigning = _116[0], setSignatureSigning = _116[1];
|
|
317
|
+
var _117 = (0, react_1.useState)({}), selectedData = _117[0], setSelectedData = _117[1];
|
|
318
|
+
var _118 = (0, react_1.useState)(""), selectedObjectStructureId = _118[0], setSelectedObjectStructureId = _118[1];
|
|
319
|
+
var _119 = (0, react_1.useState)(""), selectedObjectId = _119[0], setSelectedObjectId = _119[1];
|
|
320
|
+
var _120 = (0, react_1.useState)(""), selectedListAddressId = _120[0], setSelectedListAddressId = _120[1];
|
|
321
|
+
var _121 = (0, react_1.useState)(-1), selectedListAddressIndex = _121[0], setSelectedListAddressIndex = _121[1];
|
|
322
|
+
var _122 = (0, react_1.useState)({
|
|
322
323
|
lat: 0,
|
|
323
324
|
lng: 0,
|
|
324
325
|
name: "",
|
|
325
|
-
}), selectedListAddress =
|
|
326
|
-
var
|
|
327
|
-
var
|
|
328
|
-
var
|
|
329
|
-
var
|
|
330
|
-
var
|
|
331
|
-
var
|
|
332
|
-
var
|
|
326
|
+
}), selectedListAddress = _122[0], setSelectedListAddress = _122[1];
|
|
327
|
+
var _123 = (0, react_1.useState)({}), selectedObjectData = _123[0], setSelectedObjectData = _123[1];
|
|
328
|
+
var _124 = (0, react_1.useState)(false), referenceLoading = _124[0], setReferenceLoading = _124[1];
|
|
329
|
+
var _125 = (0, react_1.useState)({}), referencesOptions = _125[0], setReferencesOptions = _125[1];
|
|
330
|
+
var _126 = (0, react_1.useState)({}), referencesDetails = _126[0], setReferencesDetails = _126[1];
|
|
331
|
+
var _127 = (0, react_1.useState)({}), referenceDeleteTableData = _127[0], setReferenceDeleteTableData = _127[1];
|
|
332
|
+
var _128 = (0, react_1.useState)(0), referenceDeleteIndex = _128[0], setReferenceDeleteIndex = _128[1];
|
|
333
|
+
var _129 = (0, react_1.useState)({
|
|
333
334
|
id: "",
|
|
334
335
|
name: "",
|
|
335
336
|
type: "string",
|
|
336
|
-
}), referenceCreationModal =
|
|
337
|
-
var
|
|
338
|
-
var
|
|
337
|
+
}), referenceCreationModal = _129[0], setReferenceCreationModal = _129[1];
|
|
338
|
+
var _130 = (0, react_1.useState)({}), referenceModelSchema = _130[0], setReferenceSchema = _130[1];
|
|
339
|
+
var _131 = (0, react_1.useState)([]), kanbanChecked = _131[0], setKanbanChecked = _131[1];
|
|
339
340
|
//INFO : Offline
|
|
340
|
-
var
|
|
341
|
-
var
|
|
341
|
+
var _132 = (0, react_1.useState)(0), offlineDataLength = _132[0], setOfflineDataLength = _132[1];
|
|
342
|
+
var _133 = (0, react_1.useState)(false), offlineModal = _133[0], setOfflineModal = _133[1];
|
|
343
|
+
// INFO: live-stream state — driven by socket connection and navigator.onLine
|
|
344
|
+
var _134 = (0, react_1.useState)(false), isLive = _134[0], setIsLive = _134[1];
|
|
345
|
+
var _135 = (0, react_1.useState)(false), isLiveOffline = _135[0], setIsLiveOffline = _135[1];
|
|
346
|
+
// INFO: true when navigator is offline — used to switch ReadQueryHoc between
|
|
347
|
+
// server reads (online, full pagination) and IndexedDB reads (offline, cached data).
|
|
348
|
+
// Independent of SSE status so it works even when bareSocketName is not set.
|
|
349
|
+
var _136 = (0, react_1.useState)(typeof navigator !== "undefined" ? !navigator.onLine : false), isNetworkOffline = _136[0], setIsNetworkOffline = _136[1];
|
|
342
350
|
var previousType = (0, react_1.useRef)(null);
|
|
343
351
|
var previousSelectedData = (0, react_1.useRef)(null);
|
|
344
352
|
var scrollSentinelRef = (0, react_1.useRef)(null);
|
|
@@ -348,6 +356,18 @@ exports.DataTemplate = (0, react_1.forwardRef)(function (props, ref) {
|
|
|
348
356
|
// Intentionally separate from previousSelectedData, which advances on every
|
|
349
357
|
// edit and therefore cannot serve as a stable submit baseline.
|
|
350
358
|
var loadedSelectedData = (0, react_1.useRef)(null);
|
|
359
|
+
// INFO: live-stream SSE client — created on mount when bareSocketName is set
|
|
360
|
+
var socketClientRef = (0, react_1.useRef)(null);
|
|
361
|
+
// INFO: always-current ref for handleApplyEnvelope — updated on every render
|
|
362
|
+
// so the LiveStreamClient's onEnvelope callback never holds a stale closure
|
|
363
|
+
// over props.type or other values that change without triggering the SSE useEffect.
|
|
364
|
+
var handleApplyEnvelopeRef = (0, react_1.useRef)(function () { return __awaiter(void 0, void 0, void 0, function () { return __generator(this, function (_a) {
|
|
365
|
+
return [2 /*return*/];
|
|
366
|
+
}); }); });
|
|
367
|
+
// INFO: always-current ref for handleRefresh — kept in sync below so the
|
|
368
|
+
// polling setInterval never captures a stale closure over filters/pagination
|
|
369
|
+
// state that changed after the interval was first registered.
|
|
370
|
+
var handleRefreshRef = (0, react_1.useRef)(function () { });
|
|
351
371
|
// INFO: Cumulative set of field IDs the user explicitly interacted with (dirty tracking).
|
|
352
372
|
// Populated via the bareUpdateHandleData useEffect which detects per-render field changes.
|
|
353
373
|
// Used as the PRIMARY condition for deciding what to submit:
|
|
@@ -632,12 +652,106 @@ exports.DataTemplate = (0, react_1.forwardRef)(function (props, ref) {
|
|
|
632
652
|
? JSON.parse(JSON.stringify(newBaseline))
|
|
633
653
|
: null;
|
|
634
654
|
},
|
|
655
|
+
// INFO: expose live-stream status so consumers can render indicators externally
|
|
656
|
+
isLive: isLive,
|
|
657
|
+
isLiveOffline: isLiveOffline,
|
|
635
658
|
}); });
|
|
636
659
|
(0, react_1.useEffect)(function () {
|
|
637
660
|
handleCheckOfflineDataLength();
|
|
638
661
|
/* eslint-disable */
|
|
639
662
|
}, [props.collectionId]);
|
|
640
663
|
/* eslint-enable */
|
|
664
|
+
// INFO: offline prefetch — fires on mount when bareOffline:true and navigator is online.
|
|
665
|
+
// Runs whenever collectionId or bareOffline changes (e.g. story switching in Storybook).
|
|
666
|
+
// handleOfflinePrefetch is a no-op when offline so safe to call unconditionally here.
|
|
667
|
+
(0, react_1.useEffect)(function () {
|
|
668
|
+
handleOfflinePrefetch();
|
|
669
|
+
/* eslint-disable */
|
|
670
|
+
}, [props.collectionId, (_34 = props.bareSettings) === null || _34 === void 0 ? void 0 : _34.bareOffline]);
|
|
671
|
+
/* eslint-enable */
|
|
672
|
+
// INFO: MRQ polling — calls handleRefresh every N ms (e.g. 1500) as a fallback.
|
|
673
|
+
// Calls through handleRefreshRef so the interval always dispatches the latest
|
|
674
|
+
// closure, even when filters or pagination state changes between ticks.
|
|
675
|
+
// Skips firing when SSE is connected (isLive) to avoid a jarring table
|
|
676
|
+
// re-fetch overwriting rows that SSE already delivered live.
|
|
677
|
+
// Also skips when the device is offline (isNetworkOffline) to avoid
|
|
678
|
+
// unnecessary failed network requests during offline periods.
|
|
679
|
+
(0, react_1.useEffect)(function () {
|
|
680
|
+
var _a;
|
|
681
|
+
var interval = (_a = props.bareSettings) === null || _a === void 0 ? void 0 : _a.barePollingInterval;
|
|
682
|
+
if (!interval)
|
|
683
|
+
return;
|
|
684
|
+
var timer = setInterval(function () {
|
|
685
|
+
if (!isLive && !isNetworkOffline)
|
|
686
|
+
handleRefreshRef.current();
|
|
687
|
+
}, interval);
|
|
688
|
+
return function () { return clearInterval(timer); };
|
|
689
|
+
/* eslint-disable */
|
|
690
|
+
}, [(_35 = props.bareSettings) === null || _35 === void 0 ? void 0 : _35.barePollingInterval, isLive, isNetworkOffline]);
|
|
691
|
+
/* eslint-enable */
|
|
692
|
+
// INFO: Pub/Sub → SSE live-stream — driven by bareSettings.bareSocketName
|
|
693
|
+
// EventSource URL: {sseEndpoint}/{room}?bm_apiToken={token}
|
|
694
|
+
// Mirrors Verdant's emitDeliveryEvent / pages/api/events.ts pattern on the client.
|
|
695
|
+
(0, react_1.useEffect)(function () {
|
|
696
|
+
var _a;
|
|
697
|
+
var room = (_a = props.bareSettings) === null || _a === void 0 ? void 0 : _a.bareSocketName;
|
|
698
|
+
var sseEndpoint = props.devSettings.sseEndpoint;
|
|
699
|
+
if (process.env.NODE_ENV !== "production") {
|
|
700
|
+
console.debug("[DTW SSE] room=", room, "sseEndpoint=", sseEndpoint, "→", room && sseEndpoint
|
|
701
|
+
? "connecting"
|
|
702
|
+
: "skipped (missing room or sseEndpoint)");
|
|
703
|
+
}
|
|
704
|
+
if (!room || !sseEndpoint)
|
|
705
|
+
return;
|
|
706
|
+
var client = new socket_1.LiveStreamClient({
|
|
707
|
+
url: (0, socket_1.buildSSEUrl)(sseEndpoint, room, props.devSettings.dbAPIToken, props.devSettings.dbUserToken),
|
|
708
|
+
onEnvelope: function (env) {
|
|
709
|
+
if (process.env.NODE_ENV !== "production") {
|
|
710
|
+
console.debug("[DTW SSE] envelope received", env);
|
|
711
|
+
}
|
|
712
|
+
handleApplyEnvelopeRef.current(env);
|
|
713
|
+
},
|
|
714
|
+
onStatusChange: function (status) {
|
|
715
|
+
if (process.env.NODE_ENV !== "production") {
|
|
716
|
+
console.debug("[DTW SSE] status →", status, "room=", room);
|
|
717
|
+
}
|
|
718
|
+
setIsLive(status === "connected");
|
|
719
|
+
setIsLiveOffline(status === "offline");
|
|
720
|
+
},
|
|
721
|
+
});
|
|
722
|
+
socketClientRef.current = client;
|
|
723
|
+
client.connect();
|
|
724
|
+
return function () {
|
|
725
|
+
client.disconnect();
|
|
726
|
+
socketClientRef.current = null;
|
|
727
|
+
setIsLive(false);
|
|
728
|
+
setIsLiveOffline(false);
|
|
729
|
+
};
|
|
730
|
+
/* eslint-disable */
|
|
731
|
+
}, [
|
|
732
|
+
(_36 = props.bareSettings) === null || _36 === void 0 ? void 0 : _36.bareSocketName,
|
|
733
|
+
props.collectionId,
|
|
734
|
+
props.devSettings.sseEndpoint,
|
|
735
|
+
props.devSettings.dbAPIToken,
|
|
736
|
+
]);
|
|
737
|
+
/* eslint-enable */
|
|
738
|
+
// INFO: track real network connectivity independently of SSE so
|
|
739
|
+
// ReadQueryHoc can switch between server (online) and IndexedDB (offline)
|
|
740
|
+
// even when bareSocketName is not set.
|
|
741
|
+
(0, react_1.useEffect)(function () {
|
|
742
|
+
var handleOnline = function () { return setIsNetworkOffline(false); };
|
|
743
|
+
var handleOffline = function () { return setIsNetworkOffline(true); };
|
|
744
|
+
if (typeof window !== "undefined") {
|
|
745
|
+
window.addEventListener("online", handleOnline);
|
|
746
|
+
window.addEventListener("offline", handleOffline);
|
|
747
|
+
}
|
|
748
|
+
return function () {
|
|
749
|
+
if (typeof window !== "undefined") {
|
|
750
|
+
window.removeEventListener("online", handleOnline);
|
|
751
|
+
window.removeEventListener("offline", handleOffline);
|
|
752
|
+
}
|
|
753
|
+
};
|
|
754
|
+
}, []);
|
|
641
755
|
// INFO: scroll-mode auto-pagination. Observes a sentinel below the list;
|
|
642
756
|
// when it enters the viewport we fire handlePagination("next"). End-of-list
|
|
643
757
|
// is per-backend — Firebase relies on cursor presence; non-Firebase uses
|
|
@@ -679,7 +793,7 @@ exports.DataTemplate = (0, react_1.forwardRef)(function (props, ref) {
|
|
|
679
793
|
}, [tableData.length]);
|
|
680
794
|
//INFO : Change Data Type & ID Refresh
|
|
681
795
|
(0, react_1.useEffect)(function () {
|
|
682
|
-
var _a, _b, _c;
|
|
796
|
+
var _a, _b, _c, _d;
|
|
683
797
|
switch (props.type) {
|
|
684
798
|
case "read":
|
|
685
799
|
case "update":
|
|
@@ -703,6 +817,11 @@ exports.DataTemplate = (0, react_1.forwardRef)(function (props, ref) {
|
|
|
703
817
|
}
|
|
704
818
|
if (props.id === "new") {
|
|
705
819
|
(0, updateModule_1.handleRetrieveReferenceOptions)(selectedData, props.model, dbModule, devSettings, setReferencesOptions, setReferencesDetails);
|
|
820
|
+
}
|
|
821
|
+
// INFO: skip online reference fetch when offline — referencesOptions
|
|
822
|
+
// is already populated from IndexedDB cache in handleRetrieveSelectedData.
|
|
823
|
+
// When online, runs for all read/update views (both new and existing docs).
|
|
824
|
+
if (!((_d = props.bareSettings) === null || _d === void 0 ? void 0 : _d.bareOffline)) {
|
|
706
825
|
handleObjectReferenceOptions();
|
|
707
826
|
}
|
|
708
827
|
//INFO : Auth Feature
|
|
@@ -839,10 +958,10 @@ exports.DataTemplate = (0, react_1.forwardRef)(function (props, ref) {
|
|
|
839
958
|
props.collectionId,
|
|
840
959
|
props.model,
|
|
841
960
|
props.localURLEndpoint,
|
|
842
|
-
(
|
|
843
|
-
(
|
|
844
|
-
(
|
|
845
|
-
(
|
|
961
|
+
(_37 = props.organise) === null || _37 === void 0 ? void 0 : _37.extendedTabs,
|
|
962
|
+
(_38 = props.organise) === null || _38 === void 0 ? void 0 : _38.viewId,
|
|
963
|
+
(_39 = props.organise) === null || _39 === void 0 ? void 0 : _39.additionalQuery,
|
|
964
|
+
(_40 = props.organise) === null || _40 === void 0 ? void 0 : _40.groupBy,
|
|
846
965
|
props.type,
|
|
847
966
|
]);
|
|
848
967
|
(0, react_1.useEffect)(function () {
|
|
@@ -932,7 +1051,7 @@ exports.DataTemplate = (0, react_1.forwardRef)(function (props, ref) {
|
|
|
932
1051
|
};
|
|
933
1052
|
}, 100);
|
|
934
1053
|
return function () { return clearTimeout(timeoutId); };
|
|
935
|
-
}, [(
|
|
1054
|
+
}, [(_41 = props.organise) === null || _41 === void 0 ? void 0 : _41.showReadFloatingNav, props.type, props.id, loading]);
|
|
936
1055
|
(0, react_1.useEffect)(function () {
|
|
937
1056
|
if (props.type !== "read")
|
|
938
1057
|
return;
|
|
@@ -1003,7 +1122,7 @@ exports.DataTemplate = (0, react_1.forwardRef)(function (props, ref) {
|
|
|
1003
1122
|
//SECTION: Handle List
|
|
1004
1123
|
//=====================================================================================
|
|
1005
1124
|
var handleCheckOfflineDataLength = function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
1006
|
-
var offlineDataResp, offlineData;
|
|
1125
|
+
var offlineDataResp, offlineData, pendingCount;
|
|
1007
1126
|
var _a;
|
|
1008
1127
|
return __generator(this, function (_b) {
|
|
1009
1128
|
switch (_b.label) {
|
|
@@ -1011,11 +1130,345 @@ exports.DataTemplate = (0, react_1.forwardRef)(function (props, ref) {
|
|
|
1011
1130
|
case 1:
|
|
1012
1131
|
offlineDataResp = _b.sent();
|
|
1013
1132
|
offlineData = (_a = offlineDataResp === null || offlineDataResp === void 0 ? void 0 : offlineDataResp.data) !== null && _a !== void 0 ? _a : [];
|
|
1014
|
-
|
|
1133
|
+
pendingCount = offlineData.filter(function (doc) { return !(doc.baseOnline === true && doc.syncStatus === "synced"); }).length;
|
|
1134
|
+
setOfflineDataLength(pendingCount);
|
|
1135
|
+
return [2 /*return*/];
|
|
1136
|
+
}
|
|
1137
|
+
});
|
|
1138
|
+
}); };
|
|
1139
|
+
// INFO: Offline prefetch — runs on mount when bareOffline:true and navigator is online.
|
|
1140
|
+
// Pulls the latest N docs from the main collection and all reference collections into
|
|
1141
|
+
// IndexedDB so the full offline experience works immediately after connectivity drops.
|
|
1142
|
+
//
|
|
1143
|
+
// Main collection → IndexedDB key "{collectionId}" stamped { baseOnline: true }
|
|
1144
|
+
// Reference tables → IndexedDB key "ref_{collectionId}" read-only, no limit by default
|
|
1145
|
+
var handleOfflinePrefetch = function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
1146
|
+
var prefetchLimit, mainRQ, mainResp, stamped, existingResp, existingData, pendingDocs, pendingIds_1, mergedData, _a, references;
|
|
1147
|
+
var _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
1148
|
+
return __generator(this, function (_l) {
|
|
1149
|
+
switch (_l.label) {
|
|
1150
|
+
case 0:
|
|
1151
|
+
if (!((_b = props.bareSettings) === null || _b === void 0 ? void 0 : _b.bareOffline))
|
|
1152
|
+
return [2 /*return*/];
|
|
1153
|
+
if (typeof navigator !== "undefined" && !navigator.onLine)
|
|
1154
|
+
return [2 /*return*/];
|
|
1155
|
+
if (!((_c = props.lib) === null || _c === void 0 ? void 0 : _c.axios))
|
|
1156
|
+
return [2 /*return*/];
|
|
1157
|
+
prefetchLimit = (_e = (_d = props.bareSettings) === null || _d === void 0 ? void 0 : _d.bareOfflinePrefetchLimit) !== null && _e !== void 0 ? _e : 10;
|
|
1158
|
+
_l.label = 1;
|
|
1159
|
+
case 1:
|
|
1160
|
+
_l.trys.push([1, 7, , 8]);
|
|
1161
|
+
mainRQ = new readQuery_1.ReadQuery({
|
|
1162
|
+
dbModule: props.lib.axios,
|
|
1163
|
+
dbType: devSettings.server,
|
|
1164
|
+
dbCollection: props.collectionId,
|
|
1165
|
+
dbEndpoint: devSettings.dbEndpoint,
|
|
1166
|
+
dbAPIToken: devSettings.dbAPIToken,
|
|
1167
|
+
dbUserToken: devSettings.dbUserToken,
|
|
1168
|
+
});
|
|
1169
|
+
return [4 /*yield*/, mainRQ.call({
|
|
1170
|
+
type: "list",
|
|
1171
|
+
// INFO: respect the consumer's configured sort so the prefetched page
|
|
1172
|
+
// matches what the user sees online. Fall back to createdAt desc when
|
|
1173
|
+
// no sort is configured (safe default for append-order collections).
|
|
1174
|
+
sort: (_g = (_f = props.organise) === null || _f === void 0 ? void 0 : _f.sort) !== null && _g !== void 0 ? _g : { sortId: "createdAt", type: "desc" },
|
|
1175
|
+
limit: prefetchLimit,
|
|
1176
|
+
})];
|
|
1177
|
+
case 2:
|
|
1178
|
+
mainResp = _l.sent();
|
|
1179
|
+
if (!((mainResp === null || mainResp === void 0 ? void 0 : mainResp.data) && Array.isArray(mainResp.data))) return [3 /*break*/, 6];
|
|
1180
|
+
stamped = mainResp.data.map(function (doc) { return (__assign(__assign({}, doc), { baseOnline: true, syncStatus: "synced", dirtySections: [] })); });
|
|
1181
|
+
return [4 /*yield*/, indexedDb_1.indexedDb.getValue("local", props.collectionId)];
|
|
1182
|
+
case 3:
|
|
1183
|
+
existingResp = _l.sent();
|
|
1184
|
+
existingData = (_h = existingResp === null || existingResp === void 0 ? void 0 : existingResp.data) !== null && _h !== void 0 ? _h : [];
|
|
1185
|
+
pendingDocs = existingData.filter(function (doc) { return !(doc.baseOnline === true && doc.syncStatus === "synced"); });
|
|
1186
|
+
pendingIds_1 = new Set(pendingDocs.map(function (doc) { var _a, _b; return (_b = (_a = doc[serverId]) !== null && _a !== void 0 ? _a : doc._id) !== null && _b !== void 0 ? _b : doc.id; }));
|
|
1187
|
+
mergedData = __spreadArray(__spreadArray([], pendingDocs, true), stamped.filter(function (doc) { var _a, _b; return !pendingIds_1.has((_b = (_a = doc[serverId]) !== null && _a !== void 0 ? _a : doc._id) !== null && _b !== void 0 ? _b : doc.id); }), true);
|
|
1188
|
+
return [4 /*yield*/, indexedDb_1.indexedDb.putValue("local", {
|
|
1189
|
+
type: props.collectionId,
|
|
1190
|
+
data: mergedData,
|
|
1191
|
+
})];
|
|
1192
|
+
case 4:
|
|
1193
|
+
_l.sent();
|
|
1194
|
+
return [4 /*yield*/, handleCheckOfflineDataLength()];
|
|
1195
|
+
case 5:
|
|
1196
|
+
_l.sent();
|
|
1197
|
+
_l.label = 6;
|
|
1198
|
+
case 6: return [3 /*break*/, 8];
|
|
1199
|
+
case 7:
|
|
1200
|
+
_a = _l.sent();
|
|
1201
|
+
return [3 /*break*/, 8];
|
|
1202
|
+
case 8:
|
|
1203
|
+
references = (_k = (_j = props.bareSettings) === null || _j === void 0 ? void 0 : _j.bareOfflineReferences) !== null && _k !== void 0 ? _k : [];
|
|
1204
|
+
return [4 /*yield*/, Promise.all(references.map(function (ref) { return __awaiter(void 0, void 0, void 0, function () {
|
|
1205
|
+
var refRQ, refResp, _a;
|
|
1206
|
+
return __generator(this, function (_b) {
|
|
1207
|
+
switch (_b.label) {
|
|
1208
|
+
case 0:
|
|
1209
|
+
_b.trys.push([0, 5, , 6]);
|
|
1210
|
+
refRQ = new readQuery_1.ReadQuery({
|
|
1211
|
+
dbModule: props.lib.axios,
|
|
1212
|
+
dbType: devSettings.server,
|
|
1213
|
+
dbCollection: ref.collectionId,
|
|
1214
|
+
dbEndpoint: devSettings.dbEndpoint,
|
|
1215
|
+
dbAPIToken: devSettings.dbAPIToken,
|
|
1216
|
+
dbUserToken: devSettings.dbUserToken,
|
|
1217
|
+
});
|
|
1218
|
+
return [4 /*yield*/, refRQ.call(__assign({ type: "list", query: ref.query, sort: ref.sort }, (ref.limit ? { limit: ref.limit } : { stopLimit: true })))];
|
|
1219
|
+
case 1:
|
|
1220
|
+
refResp = _b.sent();
|
|
1221
|
+
if (!((refResp === null || refResp === void 0 ? void 0 : refResp.data) && Array.isArray(refResp.data))) return [3 /*break*/, 3];
|
|
1222
|
+
return [4 /*yield*/, indexedDb_1.indexedDb.putValue("local", {
|
|
1223
|
+
// INFO: key format matches what handleRetrieveSelectedData reads:
|
|
1224
|
+
// eachModel.referenceSpaceId + "-ref" (e.g. "meraque-cycles-ref")
|
|
1225
|
+
type: "".concat(ref.collectionId, "-ref"),
|
|
1226
|
+
data: refResp.data,
|
|
1227
|
+
})];
|
|
1228
|
+
case 2:
|
|
1229
|
+
_b.sent();
|
|
1230
|
+
if (process.env.NODE_ENV !== "production") {
|
|
1231
|
+
console.debug("[DTW prefetch] reference cached", ref.collectionId + "-ref", "count=", refResp.data.length);
|
|
1232
|
+
}
|
|
1233
|
+
return [3 /*break*/, 4];
|
|
1234
|
+
case 3:
|
|
1235
|
+
if (process.env.NODE_ENV !== "production") {
|
|
1236
|
+
console.debug("[DTW prefetch] reference EMPTY or failed", ref.collectionId, refResp);
|
|
1237
|
+
}
|
|
1238
|
+
_b.label = 4;
|
|
1239
|
+
case 4: return [3 /*break*/, 6];
|
|
1240
|
+
case 5:
|
|
1241
|
+
_a = _b.sent();
|
|
1242
|
+
return [3 /*break*/, 6];
|
|
1243
|
+
case 6: return [2 /*return*/];
|
|
1244
|
+
}
|
|
1245
|
+
});
|
|
1246
|
+
}); }))];
|
|
1247
|
+
case 9:
|
|
1248
|
+
_l.sent();
|
|
1015
1249
|
return [2 /*return*/];
|
|
1016
1250
|
}
|
|
1017
1251
|
});
|
|
1018
1252
|
}); };
|
|
1253
|
+
// INFO: for each reference/listReference field in the schema, look up the
|
|
1254
|
+
// cached ref_{collectionId} in IndexedDB and substitute the label in-place.
|
|
1255
|
+
// This runs in the offline branch of handleGetListData so the list shows
|
|
1256
|
+
// human-readable labels instead of raw UUIDs.
|
|
1257
|
+
var handleResolveOfflineReferences = function (rows) { return __awaiter(void 0, void 0, void 0, function () {
|
|
1258
|
+
var refFields, refCacheMap;
|
|
1259
|
+
return __generator(this, function (_a) {
|
|
1260
|
+
switch (_a.label) {
|
|
1261
|
+
case 0:
|
|
1262
|
+
refFields = structure.filter(function (s) {
|
|
1263
|
+
return (s.type === "reference" || s.type === "listReference") &&
|
|
1264
|
+
s.referenceSpaceId &&
|
|
1265
|
+
s.referenceLabel;
|
|
1266
|
+
});
|
|
1267
|
+
if (refFields.length === 0)
|
|
1268
|
+
return [2 /*return*/, rows];
|
|
1269
|
+
refCacheMap = {};
|
|
1270
|
+
return [4 /*yield*/, Promise.all(refFields.map(function (field) { return __awaiter(void 0, void 0, void 0, function () {
|
|
1271
|
+
var colId, cached;
|
|
1272
|
+
return __generator(this, function (_a) {
|
|
1273
|
+
switch (_a.label) {
|
|
1274
|
+
case 0:
|
|
1275
|
+
colId = field.referenceSpaceId;
|
|
1276
|
+
if (refCacheMap[colId] !== undefined)
|
|
1277
|
+
return [2 /*return*/];
|
|
1278
|
+
return [4 /*yield*/, indexedDb_1.indexedDb.getValue("local", "".concat(colId, "-ref"))];
|
|
1279
|
+
case 1:
|
|
1280
|
+
cached = _a.sent();
|
|
1281
|
+
refCacheMap[colId] = Array.isArray(cached === null || cached === void 0 ? void 0 : cached.data) ? cached.data : [];
|
|
1282
|
+
return [2 /*return*/];
|
|
1283
|
+
}
|
|
1284
|
+
});
|
|
1285
|
+
}); }))];
|
|
1286
|
+
case 1:
|
|
1287
|
+
_a.sent();
|
|
1288
|
+
return [2 /*return*/, rows.map(function (row) {
|
|
1289
|
+
var resolved = __assign({}, row);
|
|
1290
|
+
refFields.forEach(function (field) {
|
|
1291
|
+
var _a, _b;
|
|
1292
|
+
var colId = field.referenceSpaceId;
|
|
1293
|
+
var labelKey = field.referenceLabel;
|
|
1294
|
+
var cache = (_a = refCacheMap[colId]) !== null && _a !== void 0 ? _a : [];
|
|
1295
|
+
var rawValue = row[field.id];
|
|
1296
|
+
if (!rawValue)
|
|
1297
|
+
return;
|
|
1298
|
+
if (field.type === "reference") {
|
|
1299
|
+
// INFO: single reference — replace UUID with the label string
|
|
1300
|
+
if (typeof rawValue !== "string" && typeof rawValue !== "number")
|
|
1301
|
+
return;
|
|
1302
|
+
var found = cache.find(function (r) { return r._id === rawValue || r.id === rawValue; });
|
|
1303
|
+
if (found)
|
|
1304
|
+
resolved[field.id] = (_b = found[labelKey]) !== null && _b !== void 0 ? _b : rawValue;
|
|
1305
|
+
}
|
|
1306
|
+
else if (field.type === "listReference") {
|
|
1307
|
+
// INFO: list reference — guard against non-array values (null, string, etc.)
|
|
1308
|
+
// Keep as array of resolved labels so downstream .map() calls still work.
|
|
1309
|
+
if (!Array.isArray(rawValue))
|
|
1310
|
+
return;
|
|
1311
|
+
resolved[field.id] = rawValue.map(function (id) {
|
|
1312
|
+
var _a;
|
|
1313
|
+
var found = cache.find(function (r) { return r._id === id || r.id === id; });
|
|
1314
|
+
return found ? ((_a = found[labelKey]) !== null && _a !== void 0 ? _a : id) : id;
|
|
1315
|
+
});
|
|
1316
|
+
}
|
|
1317
|
+
});
|
|
1318
|
+
return resolved;
|
|
1319
|
+
})];
|
|
1320
|
+
}
|
|
1321
|
+
});
|
|
1322
|
+
}); };
|
|
1323
|
+
// Behaviour is split by view type:
|
|
1324
|
+
// list → mutate tableData row(s) in-place; drive IndexedDB offline store
|
|
1325
|
+
// read / update → push update into selectedData; on delete navigate back to list
|
|
1326
|
+
var handleApplyEnvelope = function (envelope) { return __awaiter(void 0, void 0, void 0, function () {
|
|
1327
|
+
var isListView, _a, record_1, record_2, record, deletedId_1, snapData_1, record_3, safeFields_1, record, record;
|
|
1328
|
+
var _b;
|
|
1329
|
+
return __generator(this, function (_c) {
|
|
1330
|
+
switch (_c.label) {
|
|
1331
|
+
case 0:
|
|
1332
|
+
isListView = props.type === "list";
|
|
1333
|
+
if (!isListView) return [3 /*break*/, 10];
|
|
1334
|
+
_a = envelope.type;
|
|
1335
|
+
switch (_a) {
|
|
1336
|
+
case "insert": return [3 /*break*/, 1];
|
|
1337
|
+
case "update": return [3 /*break*/, 3];
|
|
1338
|
+
case "delete": return [3 /*break*/, 5];
|
|
1339
|
+
case "snapshot": return [3 /*break*/, 7];
|
|
1340
|
+
}
|
|
1341
|
+
return [3 /*break*/, 9];
|
|
1342
|
+
case 1:
|
|
1343
|
+
record_1 = envelope.payload;
|
|
1344
|
+
setTableData(function (prev) {
|
|
1345
|
+
if (prev.some(function (r) { return r._id === record_1._id; }))
|
|
1346
|
+
return prev;
|
|
1347
|
+
return __spreadArray([record_1], prev, true); // INFO: prepend — newest row at top
|
|
1348
|
+
});
|
|
1349
|
+
return [4 /*yield*/, indexedDb_1.indexedDb.handleUpsertLive(props.collectionId, record_1)];
|
|
1350
|
+
case 2:
|
|
1351
|
+
_c.sent();
|
|
1352
|
+
return [3 /*break*/, 9];
|
|
1353
|
+
case 3:
|
|
1354
|
+
record_2 = envelope.payload;
|
|
1355
|
+
setTableData(function (prev) {
|
|
1356
|
+
var idx = prev.findIndex(function (r) { return r._id === record_2._id; });
|
|
1357
|
+
if (idx < 0)
|
|
1358
|
+
return prev; // INFO: row not in current page — skip
|
|
1359
|
+
var next = __spreadArray([], prev, true);
|
|
1360
|
+
next[idx] = __assign(__assign({}, next[idx]), record_2);
|
|
1361
|
+
return next;
|
|
1362
|
+
});
|
|
1363
|
+
return [4 /*yield*/, indexedDb_1.indexedDb.handleUpsertLive(props.collectionId, record_2)];
|
|
1364
|
+
case 4:
|
|
1365
|
+
_c.sent();
|
|
1366
|
+
return [3 /*break*/, 9];
|
|
1367
|
+
case 5:
|
|
1368
|
+
record = envelope.payload;
|
|
1369
|
+
deletedId_1 = record._id;
|
|
1370
|
+
setTableData(function (prev) {
|
|
1371
|
+
return prev.filter(function (r) { return r._id !== deletedId_1; });
|
|
1372
|
+
});
|
|
1373
|
+
return [4 /*yield*/, indexedDb_1.indexedDb.handleDeleteLive(props.collectionId, deletedId_1)];
|
|
1374
|
+
case 6:
|
|
1375
|
+
_c.sent();
|
|
1376
|
+
return [3 /*break*/, 9];
|
|
1377
|
+
case 7:
|
|
1378
|
+
snapData_1 = Array.isArray(envelope.payload)
|
|
1379
|
+
? envelope.payload
|
|
1380
|
+
: [envelope.payload];
|
|
1381
|
+
setTableData(function (prev) {
|
|
1382
|
+
var map = new Map(prev.map(function (r) { return [r._id, r]; }));
|
|
1383
|
+
snapData_1.forEach(function (r) {
|
|
1384
|
+
return map.set(r._id, __assign(__assign({}, map.get(r._id)), r));
|
|
1385
|
+
});
|
|
1386
|
+
return Array.from(map.values());
|
|
1387
|
+
});
|
|
1388
|
+
// INFO: persist reconciled docs to IndexedDB so offline mode stays
|
|
1389
|
+
// consistent after a snapshot — mirrors what insert/update/delete do
|
|
1390
|
+
// via handleUpsertLive.
|
|
1391
|
+
return [4 /*yield*/, Promise.all(snapData_1.map(function (r) {
|
|
1392
|
+
return indexedDb_1.indexedDb.handleUpsertLive(props.collectionId, r);
|
|
1393
|
+
}))];
|
|
1394
|
+
case 8:
|
|
1395
|
+
// INFO: persist reconciled docs to IndexedDB so offline mode stays
|
|
1396
|
+
// consistent after a snapshot — mirrors what insert/update/delete do
|
|
1397
|
+
// via handleUpsertLive.
|
|
1398
|
+
_c.sent();
|
|
1399
|
+
return [3 /*break*/, 9];
|
|
1400
|
+
case 9: return [3 /*break*/, 11];
|
|
1401
|
+
case 10:
|
|
1402
|
+
// INFO: read / update view — push update into form; navigate away on delete
|
|
1403
|
+
switch (envelope.type) {
|
|
1404
|
+
case "update": {
|
|
1405
|
+
record_3 = envelope.payload;
|
|
1406
|
+
if (!Array.isArray(record_3)) {
|
|
1407
|
+
// INFO: verify the envelope targets the document currently open —
|
|
1408
|
+
// when using a collection-level room the server may broadcast updates
|
|
1409
|
+
// for sibling documents; applying them here would corrupt the form.
|
|
1410
|
+
if (record_3._id && record_3._id !== props.id)
|
|
1411
|
+
break;
|
|
1412
|
+
if (dirtyFieldsRef.current.size > 0) {
|
|
1413
|
+
safeFields_1 = Object.fromEntries(Object.entries(record_3).filter(function (_a) {
|
|
1414
|
+
var key = _a[0];
|
|
1415
|
+
return !dirtyFieldsRef.current.has(key);
|
|
1416
|
+
}));
|
|
1417
|
+
if (Object.keys(safeFields_1).length > 0) {
|
|
1418
|
+
setSelectedData(function (prev) { return (__assign(__assign({}, prev), safeFields_1)); });
|
|
1419
|
+
}
|
|
1420
|
+
}
|
|
1421
|
+
else {
|
|
1422
|
+
setSelectedData(function (prev) { return (__assign(__assign({}, prev), record_3)); });
|
|
1423
|
+
}
|
|
1424
|
+
}
|
|
1425
|
+
break;
|
|
1426
|
+
}
|
|
1427
|
+
case "snapshot": {
|
|
1428
|
+
record = envelope.payload;
|
|
1429
|
+
if (!Array.isArray(record)) {
|
|
1430
|
+
if (record._id && record._id !== props.id)
|
|
1431
|
+
break;
|
|
1432
|
+
setSelectedData(record);
|
|
1433
|
+
}
|
|
1434
|
+
break;
|
|
1435
|
+
}
|
|
1436
|
+
case "delete": {
|
|
1437
|
+
record = envelope.payload;
|
|
1438
|
+
if ((record === null || record === void 0 ? void 0 : record._id) && record._id !== props.id)
|
|
1439
|
+
break;
|
|
1440
|
+
// INFO: document deleted externally — navigate back to list if possible,
|
|
1441
|
+
// otherwise show an in-form notification so the user isn't left on a
|
|
1442
|
+
// stale deleted document with zero feedback (navigate may be null when
|
|
1443
|
+
// DataTemplateWrapper is used without a router integration)
|
|
1444
|
+
if ((_b = props.lib) === null || _b === void 0 ? void 0 : _b.navigate) {
|
|
1445
|
+
props.lib.navigate(-1);
|
|
1446
|
+
}
|
|
1447
|
+
else {
|
|
1448
|
+
setNotification({
|
|
1449
|
+
type: false,
|
|
1450
|
+
title: "Record Deleted",
|
|
1451
|
+
msg: "This record was deleted by another user.",
|
|
1452
|
+
});
|
|
1453
|
+
}
|
|
1454
|
+
break;
|
|
1455
|
+
}
|
|
1456
|
+
default:
|
|
1457
|
+
// INFO: insert envelopes are not expected on a read/update view
|
|
1458
|
+
// (document-level rooms never emit inserts). Silently ignore to
|
|
1459
|
+
// handle collection-level rooms that may broadcast all event types.
|
|
1460
|
+
break;
|
|
1461
|
+
}
|
|
1462
|
+
_c.label = 11;
|
|
1463
|
+
case 11: return [2 /*return*/];
|
|
1464
|
+
}
|
|
1465
|
+
});
|
|
1466
|
+
}); };
|
|
1467
|
+
// INFO: keep ref current after every render so the SSE client always
|
|
1468
|
+
// dispatches through the latest closure — captures current props.type,
|
|
1469
|
+
// props.collectionId, and any state values without requiring the SSE
|
|
1470
|
+
// useEffect to re-run (which would tear down and rebuild the EventSource).
|
|
1471
|
+
handleApplyEnvelopeRef.current = handleApplyEnvelope;
|
|
1019
1472
|
var handleReadQueryHocSort = function (query) {
|
|
1020
1473
|
var _a, _b;
|
|
1021
1474
|
var sort = (_b = (_a = props.organise) === null || _a === void 0 ? void 0 : _a.sort) !== null && _b !== void 0 ? _b : undefined;
|
|
@@ -1261,22 +1714,25 @@ exports.DataTemplate = (0, react_1.forwardRef)(function (props, ref) {
|
|
|
1261
1714
|
}
|
|
1262
1715
|
};
|
|
1263
1716
|
var handleGetListData = function (responseData, type, rowId) { return __awaiter(void 0, void 0, void 0, function () {
|
|
1264
|
-
var dataList, prettierDataList, clonedTableData, clonedSpaceTableData, dummyPrettierDataList_1, selectedIndex_1, isScrollMode, newTableData, newPrettierTableData, isExists, cursorResp, lastDataId, err_1;
|
|
1265
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m
|
|
1266
|
-
return __generator(this, function (
|
|
1267
|
-
switch (
|
|
1717
|
+
var dataList, prettierDataList, clonedTableData, clonedSpaceTableData, dummyPrettierDataList_1, resolvedData, selectedIndex_1, isScrollMode, newTableData, newPrettierTableData, isExists, cursorResp, lastDataId, err_1;
|
|
1718
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
|
|
1719
|
+
return __generator(this, function (_o) {
|
|
1720
|
+
switch (_o.label) {
|
|
1268
1721
|
case 0:
|
|
1269
1722
|
dataList = [];
|
|
1270
1723
|
prettierDataList = [];
|
|
1271
|
-
|
|
1724
|
+
_o.label = 1;
|
|
1272
1725
|
case 1:
|
|
1273
|
-
|
|
1726
|
+
_o.trys.push([1, 7, , 8]);
|
|
1274
1727
|
clonedTableData = JSON.parse(JSON.stringify(tableData));
|
|
1275
1728
|
clonedSpaceTableData = JSON.parse(JSON.stringify(spaceTableData));
|
|
1276
|
-
if (!(responseData === null || responseData === void 0 ? void 0 : responseData.data)) return [3 /*break*/,
|
|
1277
|
-
if (!((_a = props.bareSettings) === null || _a === void 0 ? void 0 : _a.bareOffline)) return [3 /*break*/,
|
|
1729
|
+
if (!(responseData === null || responseData === void 0 ? void 0 : responseData.data)) return [3 /*break*/, 6];
|
|
1730
|
+
if (!((_a = props.bareSettings) === null || _a === void 0 ? void 0 : _a.bareOffline)) return [3 /*break*/, 3];
|
|
1278
1731
|
dummyPrettierDataList_1 = [];
|
|
1279
|
-
|
|
1732
|
+
return [4 /*yield*/, handleResolveOfflineReferences(responseData.data)];
|
|
1733
|
+
case 2:
|
|
1734
|
+
resolvedData = _o.sent();
|
|
1735
|
+
resolvedData.map(function (eachData) {
|
|
1280
1736
|
var _a, _b;
|
|
1281
1737
|
var tempData = eachData;
|
|
1282
1738
|
(0, listModule_1.handleDataEditButton)(tempData, (_a = props.organise) === null || _a === void 0 ? void 0 : _a.handleNavigate, (_b = props.bareSettings) === null || _b === void 0 ? void 0 : _b.bareListActionBtns);
|
|
@@ -1284,10 +1740,10 @@ exports.DataTemplate = (0, react_1.forwardRef)(function (props, ref) {
|
|
|
1284
1740
|
return null;
|
|
1285
1741
|
});
|
|
1286
1742
|
prettierDataList = dummyPrettierDataList_1;
|
|
1287
|
-
return [3 /*break*/,
|
|
1288
|
-
case
|
|
1289
|
-
case
|
|
1290
|
-
prettierDataList =
|
|
1743
|
+
return [3 /*break*/, 5];
|
|
1744
|
+
case 3: return [4 /*yield*/, (0, listModule_1.handleListDataBasedOnModel)(responseData === null || responseData === void 0 ? void 0 : responseData.data, props.devSettings, (_b = props.lib) === null || _b === void 0 ? void 0 : _b.axios, structure, (_c = props.organise) === null || _c === void 0 ? void 0 : _c.handleNavigate, ((_d = props.organise) === null || _d === void 0 ? void 0 : _d.viewId) === "general", setActivityModal, setActivityId, isActivityLog ? (_e = props.edit) === null || _e === void 0 ? void 0 : _e.activityLog : undefined, (_f = props.bareSettings) === null || _f === void 0 ? void 0 : _f.bareListActionBtns, (_g = props.edit) === null || _g === void 0 ? void 0 : _g.disabledUpdate)];
|
|
1745
|
+
case 4:
|
|
1746
|
+
prettierDataList = _o.sent();
|
|
1291
1747
|
if (props.groupId) {
|
|
1292
1748
|
prettierDataList.forEach(function (item, idx) {
|
|
1293
1749
|
var _a, _b;
|
|
@@ -1296,9 +1752,9 @@ exports.DataTemplate = (0, react_1.forwardRef)(function (props, ref) {
|
|
|
1296
1752
|
}
|
|
1297
1753
|
});
|
|
1298
1754
|
}
|
|
1299
|
-
|
|
1300
|
-
case
|
|
1301
|
-
(
|
|
1755
|
+
_o.label = 5;
|
|
1756
|
+
case 5:
|
|
1757
|
+
(_h = responseData === null || responseData === void 0 ? void 0 : responseData.data) === null || _h === void 0 ? void 0 : _h.map(function (eachData) {
|
|
1302
1758
|
if (eachData["_id"]) {
|
|
1303
1759
|
eachData["id"] = eachData["_id"];
|
|
1304
1760
|
delete eachData["_id"];
|
|
@@ -1306,8 +1762,8 @@ exports.DataTemplate = (0, react_1.forwardRef)(function (props, ref) {
|
|
|
1306
1762
|
return null;
|
|
1307
1763
|
});
|
|
1308
1764
|
dataList = responseData.data;
|
|
1309
|
-
|
|
1310
|
-
case
|
|
1765
|
+
_o.label = 6;
|
|
1766
|
+
case 6:
|
|
1311
1767
|
if (type === "update" || type === "create") {
|
|
1312
1768
|
try {
|
|
1313
1769
|
if (type === "update") {
|
|
@@ -1318,12 +1774,12 @@ exports.DataTemplate = (0, react_1.forwardRef)(function (props, ref) {
|
|
|
1318
1774
|
return null;
|
|
1319
1775
|
});
|
|
1320
1776
|
if (selectedIndex_1 > -1) {
|
|
1321
|
-
clonedTableData[selectedIndex_1] = (
|
|
1777
|
+
clonedTableData[selectedIndex_1] = (_j = responseData === null || responseData === void 0 ? void 0 : responseData.data) === null || _j === void 0 ? void 0 : _j[0];
|
|
1322
1778
|
clonedSpaceTableData[selectedIndex_1] = prettierDataList === null || prettierDataList === void 0 ? void 0 : prettierDataList[0];
|
|
1323
1779
|
}
|
|
1324
1780
|
}
|
|
1325
1781
|
else {
|
|
1326
|
-
clonedTableData.push((
|
|
1782
|
+
clonedTableData.push((_k = responseData === null || responseData === void 0 ? void 0 : responseData.data) === null || _k === void 0 ? void 0 : _k[0]);
|
|
1327
1783
|
clonedSpaceTableData.push(prettierDataList === null || prettierDataList === void 0 ? void 0 : prettierDataList[0]);
|
|
1328
1784
|
}
|
|
1329
1785
|
handleSetListData(clonedTableData, clonedSpaceTableData);
|
|
@@ -1334,7 +1790,7 @@ exports.DataTemplate = (0, react_1.forwardRef)(function (props, ref) {
|
|
|
1334
1790
|
isScrollMode = renderCheckScrollMode();
|
|
1335
1791
|
if (!isScrollMode && !isFirebase) {
|
|
1336
1792
|
handleSetListData(dataList, prettierDataList);
|
|
1337
|
-
setSize((
|
|
1793
|
+
setSize((_l = responseData.count) !== null && _l !== void 0 ? _l : 0);
|
|
1338
1794
|
}
|
|
1339
1795
|
else {
|
|
1340
1796
|
newTableData = [];
|
|
@@ -1365,15 +1821,15 @@ exports.DataTemplate = (0, react_1.forwardRef)(function (props, ref) {
|
|
|
1365
1821
|
}
|
|
1366
1822
|
setCursor(cursorResp);
|
|
1367
1823
|
if (isScrollMode && !isFirebase) {
|
|
1368
|
-
setSize((
|
|
1824
|
+
setSize((_m = responseData.count) !== null && _m !== void 0 ? _m : 0);
|
|
1369
1825
|
}
|
|
1370
1826
|
}
|
|
1371
1827
|
}
|
|
1372
|
-
return [3 /*break*/,
|
|
1373
|
-
case 6:
|
|
1374
|
-
err_1 = _p.sent();
|
|
1375
|
-
return [3 /*break*/, 7];
|
|
1828
|
+
return [3 /*break*/, 8];
|
|
1376
1829
|
case 7:
|
|
1830
|
+
err_1 = _o.sent();
|
|
1831
|
+
return [3 /*break*/, 8];
|
|
1832
|
+
case 8:
|
|
1377
1833
|
setTableLoading(false);
|
|
1378
1834
|
return [2 /*return*/];
|
|
1379
1835
|
}
|
|
@@ -1400,6 +1856,9 @@ exports.DataTemplate = (0, react_1.forwardRef)(function (props, ref) {
|
|
|
1400
1856
|
handleCheckOfflineDataLength();
|
|
1401
1857
|
}, 500);
|
|
1402
1858
|
};
|
|
1859
|
+
// INFO: keep polling ref current so the setInterval always fires the latest
|
|
1860
|
+
// handleRefresh closure (captures current filters, pagination, etc.)
|
|
1861
|
+
handleRefreshRef.current = handleRefresh;
|
|
1403
1862
|
var handleObjectReferenceOptions = function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
1404
1863
|
var clonedOptions_1, clonedDetails_1, model, err_2;
|
|
1405
1864
|
var _a;
|
|
@@ -2019,7 +2478,7 @@ exports.DataTemplate = (0, react_1.forwardRef)(function (props, ref) {
|
|
|
2019
2478
|
case 0:
|
|
2020
2479
|
_a.trys.push([0, 4, , 5]);
|
|
2021
2480
|
uploadAsset_1 = function (eachImage, selectedField, listObjectId, multiple) { return __awaiter(void 0, void 0, void 0, function () {
|
|
2022
|
-
var uploadedData_1, imageValue, imageCollectionName, imageParentId, fileName, responseData, err_7;
|
|
2481
|
+
var uploadedData_1, hadValidEntries, imageValue, imageCollectionName, imageParentId, fileName, responseData, err_7;
|
|
2023
2482
|
var _a, _b;
|
|
2024
2483
|
return __generator(this, function (_c) {
|
|
2025
2484
|
switch (_c.label) {
|
|
@@ -2034,11 +2493,16 @@ exports.DataTemplate = (0, react_1.forwardRef)(function (props, ref) {
|
|
|
2034
2493
|
Array.isArray(selectedField["upload"]))) return [3 /*break*/, 3];
|
|
2035
2494
|
uploadedData_1 = [];
|
|
2036
2495
|
return [4 /*yield*/, Promise.all(selectedField["upload"].map(function (eachField) { return __awaiter(void 0, void 0, void 0, function () {
|
|
2037
|
-
var imageCollectionName, imageParentId, originalFileName, fileName, responseData, uploaded;
|
|
2496
|
+
var fileNameIsValid, imageCollectionName, imageParentId, originalFileName, fileName, responseData, uploaded;
|
|
2038
2497
|
var _a, _b, _c;
|
|
2039
2498
|
return __generator(this, function (_d) {
|
|
2040
2499
|
switch (_d.label) {
|
|
2041
2500
|
case 0:
|
|
2501
|
+
fileNameIsValid = eachField.fileName instanceof File ||
|
|
2502
|
+
(typeof eachField.fileName === "string" &&
|
|
2503
|
+
eachField.fileName.trim() !== "");
|
|
2504
|
+
if (!fileNameIsValid)
|
|
2505
|
+
return [2 /*return*/, null];
|
|
2042
2506
|
imageCollectionName = (_a = eachImage.imageCollectionName) !== null && _a !== void 0 ? _a : "";
|
|
2043
2507
|
if (objectId) {
|
|
2044
2508
|
imageCollectionName += "/".concat(dataId);
|
|
@@ -2084,6 +2548,10 @@ exports.DataTemplate = (0, react_1.forwardRef)(function (props, ref) {
|
|
|
2084
2548
|
}); }))];
|
|
2085
2549
|
case 2:
|
|
2086
2550
|
_c.sent();
|
|
2551
|
+
hadValidEntries = uploadedData_1.length > 0 ||
|
|
2552
|
+
selectedField["upload"].length === 0;
|
|
2553
|
+
if (!hadValidEntries)
|
|
2554
|
+
return [2 /*return*/, selectedField];
|
|
2087
2555
|
return [2 /*return*/, selectedField["data"].concat(uploadedData_1)];
|
|
2088
2556
|
case 3: return [2 /*return*/, selectedField];
|
|
2089
2557
|
case 4: return [3 /*break*/, 8];
|
|
@@ -2605,7 +3073,7 @@ exports.DataTemplate = (0, react_1.forwardRef)(function (props, ref) {
|
|
|
2605
3073
|
});
|
|
2606
3074
|
}); };
|
|
2607
3075
|
var handleRemoveSelectedData = function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
2608
|
-
var deletable, selectedId_1, deleteIds, res, offlineDataResp, offlineData, selectedIndex_2, err_13;
|
|
3076
|
+
var deletable, selectedId_1, deleteIds, res, offlineDataResp, offlineData, selectedIndex_2, doc, err_13;
|
|
2609
3077
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
2610
3078
|
return __generator(this, function (_k) {
|
|
2611
3079
|
switch (_k.label) {
|
|
@@ -2641,8 +3109,25 @@ exports.DataTemplate = (0, react_1.forwardRef)(function (props, ref) {
|
|
|
2641
3109
|
selectedIndex_2 = index;
|
|
2642
3110
|
return null;
|
|
2643
3111
|
});
|
|
2644
|
-
if (selectedIndex_2 >= 0)
|
|
3112
|
+
if (selectedIndex_2 >= 0) {
|
|
3113
|
+
doc = offlineData[selectedIndex_2];
|
|
3114
|
+
// INFO: block delete for server-originated docs when offline —
|
|
3115
|
+
// the source of truth is online and we can't safely remove it
|
|
3116
|
+
// locally without risking data loss on the server.
|
|
3117
|
+
// Only locally-created docs (baseOnline: false) can be deleted offline.
|
|
3118
|
+
if (doc.baseOnline === true) {
|
|
3119
|
+
setNotification({
|
|
3120
|
+
type: false,
|
|
3121
|
+
title: "Delete Not Allowed Offline",
|
|
3122
|
+
msg: "This record was created on the server and cannot be deleted while offline. Please reconnect and try again.",
|
|
3123
|
+
});
|
|
3124
|
+
setLoading(false);
|
|
3125
|
+
setModalVisible(false);
|
|
3126
|
+
setDeleteModal(false);
|
|
3127
|
+
return [2 /*return*/];
|
|
3128
|
+
}
|
|
2645
3129
|
offlineData.splice(selectedIndex_2, 1);
|
|
3130
|
+
}
|
|
2646
3131
|
return [4 /*yield*/, indexedDb_1.indexedDb.putValue("local", {
|
|
2647
3132
|
data: offlineData,
|
|
2648
3133
|
type: props.collectionId,
|
|
@@ -3082,23 +3567,26 @@ exports.DataTemplate = (0, react_1.forwardRef)(function (props, ref) {
|
|
|
3082
3567
|
});
|
|
3083
3568
|
}); };
|
|
3084
3569
|
var handleUploadOfflineData = function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
3085
|
-
var dataUploadedId, offlineDataResp, offlineData, offlineDataIds, updateDataRes, updateDataList, _loop_1, i, err_18, success,
|
|
3086
|
-
var _a, _b, _c, _d, _e;
|
|
3087
|
-
return __generator(this, function (
|
|
3088
|
-
switch (
|
|
3570
|
+
var dataUploadedId, offlineDataResp, offlineData, offlineDataIds, updateDataRes, updateDataList, _loop_1, i, err_18, success, fullDataResp, fullData, updatedData;
|
|
3571
|
+
var _a, _b, _c, _d, _e, _f;
|
|
3572
|
+
return __generator(this, function (_g) {
|
|
3573
|
+
switch (_g.label) {
|
|
3089
3574
|
case 0:
|
|
3090
3575
|
setLoading(true);
|
|
3091
3576
|
dataUploadedId = [];
|
|
3092
3577
|
return [4 /*yield*/, indexedDb_1.indexedDb.getValue("local", props.collectionId)];
|
|
3093
3578
|
case 1:
|
|
3094
|
-
offlineDataResp =
|
|
3579
|
+
offlineDataResp = _g.sent();
|
|
3095
3580
|
offlineData = (_a = offlineDataResp === null || offlineDataResp === void 0 ? void 0 : offlineDataResp.data) !== null && _a !== void 0 ? _a : [];
|
|
3581
|
+
// INFO: only upload docs that need syncing — skip prefetched server docs
|
|
3582
|
+
// (baseOnline: true, syncStatus: "synced") which are already on the server
|
|
3583
|
+
offlineData = offlineData.filter(function (doc) { return !(doc.baseOnline === true && doc.syncStatus === "synced"); });
|
|
3096
3584
|
offlineDataIds = offlineData.map(function (eachData) {
|
|
3097
3585
|
return eachData[serverId];
|
|
3098
3586
|
});
|
|
3099
|
-
|
|
3587
|
+
_g.label = 2;
|
|
3100
3588
|
case 2:
|
|
3101
|
-
|
|
3589
|
+
_g.trys.push([2, 8, , 9]);
|
|
3102
3590
|
if (!(offlineData.length > 0)) return [3 /*break*/, 7];
|
|
3103
3591
|
return [4 /*yield*/, readServerQuery.call({
|
|
3104
3592
|
type: "list",
|
|
@@ -3112,18 +3600,18 @@ exports.DataTemplate = (0, react_1.forwardRef)(function (props, ref) {
|
|
|
3112
3600
|
stopLimit: true,
|
|
3113
3601
|
})];
|
|
3114
3602
|
case 3:
|
|
3115
|
-
updateDataRes =
|
|
3603
|
+
updateDataRes = _g.sent();
|
|
3116
3604
|
updateDataList = (_b = updateDataRes === null || updateDataRes === void 0 ? void 0 : updateDataRes.data) !== null && _b !== void 0 ? _b : [];
|
|
3117
3605
|
_loop_1 = function (i) {
|
|
3118
3606
|
var eachOfflineData, offlineDataId, storedBaseline, serverDoc, preComplete, isUpdate, res, err_19;
|
|
3119
|
-
var
|
|
3120
|
-
return __generator(this, function (
|
|
3121
|
-
switch (
|
|
3607
|
+
var _h;
|
|
3608
|
+
return __generator(this, function (_j) {
|
|
3609
|
+
switch (_j.label) {
|
|
3122
3610
|
case 0:
|
|
3123
3611
|
eachOfflineData = offlineData[i];
|
|
3124
3612
|
return [4 /*yield*/, (0, utils_1.sleep)(300)];
|
|
3125
3613
|
case 1:
|
|
3126
|
-
|
|
3614
|
+
_j.sent();
|
|
3127
3615
|
offlineDataId = eachOfflineData[serverId];
|
|
3128
3616
|
storedBaseline = (_c = eachOfflineData.__offlineBaseline) !== null && _c !== void 0 ? _c : null;
|
|
3129
3617
|
delete eachOfflineData.__offlineBaseline;
|
|
@@ -3157,46 +3645,46 @@ exports.DataTemplate = (0, react_1.forwardRef)(function (props, ref) {
|
|
|
3157
3645
|
if (!((_d = props.bareSettings) === null || _d === void 0 ? void 0 : _d.bareUpdateHandlePreComplete)) return [3 /*break*/, 3];
|
|
3158
3646
|
return [4 /*yield*/, props.bareSettings.bareUpdateHandlePreComplete(eachOfflineData)];
|
|
3159
3647
|
case 2:
|
|
3160
|
-
preComplete =
|
|
3648
|
+
preComplete = _j.sent();
|
|
3161
3649
|
if (!preComplete)
|
|
3162
3650
|
return [2 /*return*/, "continue"]; // Skip this item
|
|
3163
|
-
|
|
3651
|
+
_j.label = 3;
|
|
3164
3652
|
case 3:
|
|
3165
3653
|
isUpdate = !!serverDoc;
|
|
3166
3654
|
return [4 /*yield*/, handleSubmitData(undefined, undefined, undefined, eachOfflineData, offlineDataId, isUpdate)];
|
|
3167
3655
|
case 4:
|
|
3168
|
-
res =
|
|
3656
|
+
res = _j.sent();
|
|
3169
3657
|
if (!res) return [3 /*break*/, 8];
|
|
3170
3658
|
dataUploadedId.push(offlineDataId);
|
|
3171
3659
|
if (!((_e = props.bareSettings) === null || _e === void 0 ? void 0 : _e.bareUpdateHandlePostComplete)) return [3 /*break*/, 8];
|
|
3172
|
-
|
|
3660
|
+
_j.label = 5;
|
|
3173
3661
|
case 5:
|
|
3174
|
-
|
|
3175
|
-
return [4 /*yield*/, props.bareSettings.bareUpdateHandlePostComplete(__assign((
|
|
3662
|
+
_j.trys.push([5, 7, , 8]);
|
|
3663
|
+
return [4 /*yield*/, props.bareSettings.bareUpdateHandlePostComplete(__assign((_h = {}, _h[serverId] = res, _h), eachOfflineData))];
|
|
3176
3664
|
case 6:
|
|
3177
|
-
|
|
3665
|
+
_j.sent();
|
|
3178
3666
|
return [3 /*break*/, 8];
|
|
3179
3667
|
case 7:
|
|
3180
|
-
err_19 =
|
|
3668
|
+
err_19 = _j.sent();
|
|
3181
3669
|
return [3 /*break*/, 8];
|
|
3182
3670
|
case 8: return [2 /*return*/];
|
|
3183
3671
|
}
|
|
3184
3672
|
});
|
|
3185
3673
|
};
|
|
3186
3674
|
i = 0;
|
|
3187
|
-
|
|
3675
|
+
_g.label = 4;
|
|
3188
3676
|
case 4:
|
|
3189
3677
|
if (!(i < offlineData.length)) return [3 /*break*/, 7];
|
|
3190
3678
|
return [5 /*yield**/, _loop_1(i)];
|
|
3191
3679
|
case 5:
|
|
3192
|
-
|
|
3193
|
-
|
|
3680
|
+
_g.sent();
|
|
3681
|
+
_g.label = 6;
|
|
3194
3682
|
case 6:
|
|
3195
3683
|
i++;
|
|
3196
3684
|
return [3 /*break*/, 4];
|
|
3197
3685
|
case 7: return [3 /*break*/, 9];
|
|
3198
3686
|
case 8:
|
|
3199
|
-
err_18 =
|
|
3687
|
+
err_18 = _g.sent();
|
|
3200
3688
|
return [3 /*break*/, 9];
|
|
3201
3689
|
case 9:
|
|
3202
3690
|
success = dataUploadedId.length === offlineData.length;
|
|
@@ -3207,13 +3695,22 @@ exports.DataTemplate = (0, react_1.forwardRef)(function (props, ref) {
|
|
|
3207
3695
|
? dataUploadedId.length
|
|
3208
3696
|
: offlineData.length - dataUploadedId.length, " offline data have been ").concat(success ? "success" : "failed", " uploaded to cloud"),
|
|
3209
3697
|
});
|
|
3210
|
-
|
|
3698
|
+
return [4 /*yield*/, indexedDb_1.indexedDb.getValue("local", props.collectionId)];
|
|
3699
|
+
case 10:
|
|
3700
|
+
fullDataResp = _g.sent();
|
|
3701
|
+
fullData = (_f = fullDataResp === null || fullDataResp === void 0 ? void 0 : fullDataResp.data) !== null && _f !== void 0 ? _f : [];
|
|
3702
|
+
updatedData = fullData.map(function (doc) {
|
|
3703
|
+
if (dataUploadedId.includes(doc[serverId])) {
|
|
3704
|
+
return __assign(__assign({}, doc), { syncStatus: "synced", baseOnline: true });
|
|
3705
|
+
}
|
|
3706
|
+
return doc;
|
|
3707
|
+
});
|
|
3211
3708
|
return [4 /*yield*/, indexedDb_1.indexedDb.putValue("local", {
|
|
3212
|
-
data:
|
|
3709
|
+
data: updatedData,
|
|
3213
3710
|
type: props.collectionId,
|
|
3214
3711
|
})];
|
|
3215
|
-
case
|
|
3216
|
-
|
|
3712
|
+
case 11:
|
|
3713
|
+
_g.sent();
|
|
3217
3714
|
handleRefresh();
|
|
3218
3715
|
setLoading(false);
|
|
3219
3716
|
handlePopUpModal(false);
|
|
@@ -3222,50 +3719,52 @@ exports.DataTemplate = (0, react_1.forwardRef)(function (props, ref) {
|
|
|
3222
3719
|
});
|
|
3223
3720
|
}); };
|
|
3224
3721
|
var handleSubmitData = function (type, rowId, columnId, data, offlineId, isOfflineUpdate, isDraft) { return __awaiter(void 0, void 0, void 0, function () {
|
|
3225
|
-
var
|
|
3226
|
-
var
|
|
3227
|
-
var
|
|
3228
|
-
return __generator(this, function (
|
|
3229
|
-
switch (
|
|
3722
|
+
var selectedId, id, createSelectedData_1, uniqueDataStructure, uniqueColumnId, res, offlineDataResp, offlineData, clonedForOffline, tempData, selectedIndex_3, err_20, isExistingDoc, newRecordData_1, changedAttributeIds, baseDraftValue, hasBaseDraftChange, offlineDataResp, clonedForOffline, tempData, selectedIndex_4, offlineData, err_21, dataToSubmit_2, changedAttributeIds, baseDraftValue, hasBaseDraftChange, operationType, selectedIndex_5, dataId, err_22, offlineDataResp, offlineData, clonedForOffline, tempData, selectedIndex_6, _a;
|
|
3723
|
+
var _b, _c;
|
|
3724
|
+
var _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v;
|
|
3725
|
+
return __generator(this, function (_w) {
|
|
3726
|
+
switch (_w.label) {
|
|
3230
3727
|
case 0:
|
|
3231
|
-
|
|
3232
|
-
|
|
3728
|
+
selectedId = "";
|
|
3729
|
+
id = "";
|
|
3730
|
+
_w.label = 1;
|
|
3731
|
+
case 1:
|
|
3732
|
+
_w.trys.push([1, 37, , 43]);
|
|
3233
3733
|
if (type === "update")
|
|
3234
|
-
|
|
3734
|
+
selectedId = rowId !== null && rowId !== void 0 ? rowId : "";
|
|
3235
3735
|
else if (type === "create")
|
|
3236
|
-
|
|
3736
|
+
selectedId = "new";
|
|
3237
3737
|
else if (props.id)
|
|
3238
|
-
|
|
3738
|
+
selectedId = props.id;
|
|
3239
3739
|
else
|
|
3240
|
-
|
|
3241
|
-
id_1 = "";
|
|
3740
|
+
selectedId = "new";
|
|
3242
3741
|
if (type === "update")
|
|
3243
|
-
|
|
3244
|
-
else if (
|
|
3742
|
+
id = rowId !== null && rowId !== void 0 ? rowId : "";
|
|
3743
|
+
else if (selectedId === "new" && !showId) {
|
|
3245
3744
|
if (idField && selectedData[idField])
|
|
3246
|
-
|
|
3745
|
+
id = selectedData[idField];
|
|
3247
3746
|
else
|
|
3248
|
-
|
|
3747
|
+
id = (0, uuid_1.v4)();
|
|
3249
3748
|
}
|
|
3250
3749
|
else
|
|
3251
|
-
|
|
3750
|
+
id = (_d = props.id) !== null && _d !== void 0 ? _d : "";
|
|
3252
3751
|
if (offlineId) {
|
|
3253
|
-
|
|
3254
|
-
|
|
3752
|
+
selectedId = offlineId;
|
|
3753
|
+
id = offlineId;
|
|
3255
3754
|
}
|
|
3256
|
-
if (!(isOffline && !offlineId)) return [3 /*break*/,
|
|
3755
|
+
if (!(isOffline && !offlineId)) return [3 /*break*/, 2];
|
|
3257
3756
|
createSelectedData_1 = selectedData;
|
|
3258
|
-
return [3 /*break*/,
|
|
3259
|
-
case
|
|
3260
|
-
case 2:
|
|
3261
|
-
createSelectedData_1 = _t.sent();
|
|
3262
|
-
_t.label = 3;
|
|
3757
|
+
return [3 /*break*/, 4];
|
|
3758
|
+
case 2: return [4 /*yield*/, handleUploadImage(id, data)];
|
|
3263
3759
|
case 3:
|
|
3760
|
+
createSelectedData_1 = _w.sent();
|
|
3761
|
+
_w.label = 4;
|
|
3762
|
+
case 4:
|
|
3264
3763
|
uniqueDataStructure = structure.filter(function (eachStructure) {
|
|
3265
3764
|
return eachStructure.unique;
|
|
3266
3765
|
});
|
|
3267
3766
|
uniqueColumnId = uniqueDataStructure.length > 0 ? uniqueDataStructure[0].id : undefined;
|
|
3268
|
-
if ((
|
|
3767
|
+
if ((_e = props.bareSettings) === null || _e === void 0 ? void 0 : _e.bareUpdatePrefill) {
|
|
3269
3768
|
props.bareSettings.bareUpdatePrefill(selectedData).map(function (eachField) {
|
|
3270
3769
|
var key = eachField.key, value = eachField.value;
|
|
3271
3770
|
createSelectedData_1[key] = value;
|
|
@@ -3273,26 +3772,30 @@ exports.DataTemplate = (0, react_1.forwardRef)(function (props, ref) {
|
|
|
3273
3772
|
});
|
|
3274
3773
|
}
|
|
3275
3774
|
res = "";
|
|
3276
|
-
if (!(
|
|
3775
|
+
if (!(selectedId === "new")) return [3 /*break*/, 17];
|
|
3277
3776
|
if (!showId)
|
|
3278
|
-
createSelectedData_1[serverId] =
|
|
3777
|
+
createSelectedData_1[serverId] = id;
|
|
3279
3778
|
if (isDraft)
|
|
3280
3779
|
createSelectedData_1["baseDraft"] = true;
|
|
3281
|
-
if (!isOffline) return [3 /*break*/,
|
|
3282
|
-
|
|
3283
|
-
case 4:
|
|
3284
|
-
_t.trys.push([4, 7, , 8]);
|
|
3285
|
-
return [4 /*yield*/, indexedDb_1.indexedDb.getValue("local", props.collectionId)];
|
|
3780
|
+
if (!isOffline) return [3 /*break*/, 10];
|
|
3781
|
+
_w.label = 5;
|
|
3286
3782
|
case 5:
|
|
3287
|
-
|
|
3288
|
-
|
|
3783
|
+
_w.trys.push([5, 8, , 9]);
|
|
3784
|
+
return [4 /*yield*/, indexedDb_1.indexedDb.getValue("local", props.collectionId)];
|
|
3785
|
+
case 6:
|
|
3786
|
+
offlineDataResp = _w.sent();
|
|
3787
|
+
offlineData = (_f = offlineDataResp === null || offlineDataResp === void 0 ? void 0 : offlineDataResp.data) !== null && _f !== void 0 ? _f : [];
|
|
3289
3788
|
clonedForOffline = (0, updateModule_1.handleClonedDataAttribute)(selectedData, structure, props.devSettings.server, true, showId);
|
|
3290
3789
|
tempData = (0, updateModule_1.handleParseOfflineWrite)(clonedForOffline, structure);
|
|
3291
3790
|
// INFO: Stamp the _id on the offline entry so subsequent saves can find and update it
|
|
3292
3791
|
if (!tempData[serverId])
|
|
3293
|
-
tempData[serverId] =
|
|
3792
|
+
tempData[serverId] = id;
|
|
3294
3793
|
// INFO: Remove non-serializable keys that IDB's structured clone can't handle
|
|
3295
3794
|
delete tempData["update"];
|
|
3795
|
+
// INFO: mark as pending sync so handleCheckOfflineDataLength counts it
|
|
3796
|
+
// and the upload button appears in the list view
|
|
3797
|
+
tempData.syncStatus = "pending";
|
|
3798
|
+
tempData.baseOnline = false; // INFO: locally created, never synced
|
|
3296
3799
|
// INFO: Store original baseline on first offline save so the upload
|
|
3297
3800
|
// diff can identify which fields the user actually changed.
|
|
3298
3801
|
if (!tempData.__offlineBaseline) {
|
|
@@ -3303,7 +3806,7 @@ exports.DataTemplate = (0, react_1.forwardRef)(function (props, ref) {
|
|
|
3303
3806
|
selectedIndex_3 = -1;
|
|
3304
3807
|
offlineData.map(function (eachOfflineData, index) {
|
|
3305
3808
|
var offlineDataId = eachOfflineData[serverId];
|
|
3306
|
-
if (
|
|
3809
|
+
if (id === offlineDataId)
|
|
3307
3810
|
selectedIndex_3 = index;
|
|
3308
3811
|
return null;
|
|
3309
3812
|
});
|
|
@@ -3323,27 +3826,27 @@ exports.DataTemplate = (0, react_1.forwardRef)(function (props, ref) {
|
|
|
3323
3826
|
data: offlineData,
|
|
3324
3827
|
type: props.collectionId,
|
|
3325
3828
|
})];
|
|
3326
|
-
case 6:
|
|
3327
|
-
_t.sent();
|
|
3328
|
-
res = true;
|
|
3329
|
-
return [3 /*break*/, 8];
|
|
3330
3829
|
case 7:
|
|
3331
|
-
|
|
3332
|
-
|
|
3333
|
-
|
|
3334
|
-
case
|
|
3830
|
+
_w.sent();
|
|
3831
|
+
res = true;
|
|
3832
|
+
return [3 /*break*/, 9];
|
|
3833
|
+
case 8:
|
|
3834
|
+
err_20 = _w.sent();
|
|
3835
|
+
return [3 /*break*/, 9];
|
|
3836
|
+
case 9: return [3 /*break*/, 16];
|
|
3837
|
+
case 10:
|
|
3335
3838
|
if (!((idField && selectedData[idField]) ||
|
|
3336
|
-
((
|
|
3337
|
-
isExistingDoc = ((
|
|
3839
|
+
((_g = props.bareSettings) === null || _g === void 0 ? void 0 : _g.bareUpsertPartialUpdate))) return [3 /*break*/, 12];
|
|
3840
|
+
isExistingDoc = ((_h = props.bareSettings) === null || _h === void 0 ? void 0 : _h.bareUpsertPartialUpdate) &&
|
|
3338
3841
|
loadedSelectedData.current != null;
|
|
3339
3842
|
if (isExistingDoc) {
|
|
3340
3843
|
changedAttributeIds = (0, updateModule_1.compareUpdatedFields)(loadedSelectedData.current, createSelectedData_1).changedAttributeIds;
|
|
3341
3844
|
baseDraftValue = isDraft ? true : false;
|
|
3342
|
-
hasBaseDraftChange = ((
|
|
3845
|
+
hasBaseDraftChange = ((_k = (_j = loadedSelectedData.current) === null || _j === void 0 ? void 0 : _j["baseDraft"]) !== null && _k !== void 0 ? _k : false) !==
|
|
3343
3846
|
baseDraftValue;
|
|
3344
3847
|
// INFO: if nothing changed (including baseDraft), skip the write
|
|
3345
3848
|
if (changedAttributeIds.length === 0 && !hasBaseDraftChange)
|
|
3346
|
-
return [2 /*return*/,
|
|
3849
|
+
return [2 /*return*/, id];
|
|
3347
3850
|
newRecordData_1 = {};
|
|
3348
3851
|
changedAttributeIds.forEach(function (key) {
|
|
3349
3852
|
var _a;
|
|
@@ -3385,69 +3888,73 @@ exports.DataTemplate = (0, react_1.forwardRef)(function (props, ref) {
|
|
|
3385
3888
|
newRecordData_1 = createSelectedData_1;
|
|
3386
3889
|
}
|
|
3387
3890
|
return [4 /*yield*/, writeServerQuery.call("update", {
|
|
3388
|
-
id:
|
|
3891
|
+
id: id,
|
|
3389
3892
|
data: newRecordData_1,
|
|
3390
3893
|
upsert: true,
|
|
3391
3894
|
})];
|
|
3392
|
-
case 10:
|
|
3393
|
-
res = _t.sent();
|
|
3394
|
-
return [3 /*break*/, 15];
|
|
3395
3895
|
case 11:
|
|
3896
|
+
res = _w.sent();
|
|
3897
|
+
return [3 /*break*/, 16];
|
|
3898
|
+
case 12:
|
|
3396
3899
|
// INFO: stepper create guard — if a create is already in-flight, queue this
|
|
3397
3900
|
// draft save and return early. It will be replayed as an update once the
|
|
3398
3901
|
// in-flight create resolves.
|
|
3399
|
-
if (
|
|
3902
|
+
if (selectedId === "new" && isCreatingRef.current) {
|
|
3400
3903
|
pendingDraftSaveRef.current = true;
|
|
3401
3904
|
return [2 /*return*/, ""];
|
|
3402
3905
|
}
|
|
3403
|
-
if (
|
|
3906
|
+
if (selectedId === "new") {
|
|
3404
3907
|
isCreatingRef.current = true;
|
|
3405
|
-
inflightIdRef.current =
|
|
3908
|
+
inflightIdRef.current = id; // INFO: id is the UUID already generated above
|
|
3406
3909
|
}
|
|
3407
3910
|
return [4 /*yield*/, writeServerQuery.call("create", {
|
|
3408
3911
|
data: createSelectedData_1,
|
|
3409
3912
|
unique: uniqueColumnId,
|
|
3410
3913
|
})];
|
|
3411
|
-
case
|
|
3914
|
+
case 13:
|
|
3412
3915
|
//INFO: [CREATE] Create new data
|
|
3413
|
-
res =
|
|
3414
|
-
if (!(
|
|
3916
|
+
res = _w.sent();
|
|
3917
|
+
if (!(selectedId === "new")) return [3 /*break*/, 16];
|
|
3415
3918
|
isCreatingRef.current = false;
|
|
3416
|
-
if (!pendingDraftSaveRef.current) return [3 /*break*/,
|
|
3919
|
+
if (!pendingDraftSaveRef.current) return [3 /*break*/, 15];
|
|
3417
3920
|
pendingDraftSaveRef.current = false;
|
|
3418
3921
|
// INFO: replay as update — inflightIdRef.current holds the real _id
|
|
3419
3922
|
return [4 /*yield*/, writeServerQuery.call("update", {
|
|
3420
3923
|
id: inflightIdRef.current,
|
|
3421
3924
|
data: __assign(__assign({}, createSelectedData_1), { baseDraft: true }),
|
|
3422
3925
|
})];
|
|
3423
|
-
case 13:
|
|
3424
|
-
// INFO: replay as update — inflightIdRef.current holds the real _id
|
|
3425
|
-
_t.sent();
|
|
3426
|
-
_t.label = 14;
|
|
3427
3926
|
case 14:
|
|
3927
|
+
// INFO: replay as update — inflightIdRef.current holds the real _id
|
|
3928
|
+
_w.sent();
|
|
3929
|
+
_w.label = 15;
|
|
3930
|
+
case 15:
|
|
3428
3931
|
inflightIdRef.current = "";
|
|
3429
|
-
|
|
3430
|
-
case
|
|
3431
|
-
case 16:
|
|
3432
|
-
if (!selectedId_2) return [3 /*break*/, 24];
|
|
3433
|
-
if (!(isOffline && !offlineId)) return [3 /*break*/, 22];
|
|
3434
|
-
_t.label = 17;
|
|
3932
|
+
_w.label = 16;
|
|
3933
|
+
case 16: return [3 /*break*/, 25];
|
|
3435
3934
|
case 17:
|
|
3436
|
-
|
|
3437
|
-
return [
|
|
3935
|
+
if (!selectedId) return [3 /*break*/, 25];
|
|
3936
|
+
if (!(isOffline && !offlineId)) return [3 /*break*/, 23];
|
|
3937
|
+
_w.label = 18;
|
|
3438
3938
|
case 18:
|
|
3439
|
-
|
|
3939
|
+
_w.trys.push([18, 21, , 22]);
|
|
3940
|
+
return [4 /*yield*/, indexedDb_1.indexedDb.getValue("local", props.collectionId)];
|
|
3941
|
+
case 19:
|
|
3942
|
+
offlineDataResp = _w.sent();
|
|
3440
3943
|
clonedForOffline = (0, updateModule_1.handleClonedDataAttribute)(selectedData, structure, props.devSettings.server, true, showId);
|
|
3441
3944
|
tempData = (0, updateModule_1.handleParseOfflineWrite)(clonedForOffline, structure);
|
|
3442
|
-
tempData[serverId] =
|
|
3945
|
+
tempData[serverId] = selectedId;
|
|
3443
3946
|
// INFO: Remove non-serializable keys that IDB's structured clone can't handle
|
|
3444
3947
|
// (e.g. 'update' which is a React element injected by bareUpdateActionComponent)
|
|
3445
3948
|
delete tempData["update"];
|
|
3949
|
+
// INFO: mark as pending so handleCheckOfflineDataLength counts it
|
|
3950
|
+
// and the upload button appears — overrides syncStatus:"synced" from prefetch
|
|
3951
|
+
tempData.syncStatus = "pending";
|
|
3952
|
+
tempData.baseOnline = true; // INFO: existing server doc, updated offline
|
|
3446
3953
|
selectedIndex_4 = -1;
|
|
3447
|
-
offlineData = (
|
|
3954
|
+
offlineData = (_l = offlineDataResp === null || offlineDataResp === void 0 ? void 0 : offlineDataResp.data) !== null && _l !== void 0 ? _l : [];
|
|
3448
3955
|
offlineData.map(function (eachOfflineData, index) {
|
|
3449
3956
|
var offlineDataId = eachOfflineData[serverId];
|
|
3450
|
-
if (
|
|
3957
|
+
if (selectedId === offlineDataId)
|
|
3451
3958
|
selectedIndex_4 = index;
|
|
3452
3959
|
return null;
|
|
3453
3960
|
});
|
|
@@ -3473,28 +3980,28 @@ exports.DataTemplate = (0, react_1.forwardRef)(function (props, ref) {
|
|
|
3473
3980
|
data: offlineData,
|
|
3474
3981
|
type: props.collectionId,
|
|
3475
3982
|
})];
|
|
3476
|
-
case 19:
|
|
3477
|
-
_t.sent();
|
|
3478
|
-
res = true;
|
|
3479
|
-
return [3 /*break*/, 21];
|
|
3480
3983
|
case 20:
|
|
3481
|
-
|
|
3482
|
-
|
|
3483
|
-
|
|
3484
|
-
case
|
|
3984
|
+
_w.sent();
|
|
3985
|
+
res = true;
|
|
3986
|
+
return [3 /*break*/, 22];
|
|
3987
|
+
case 21:
|
|
3988
|
+
err_21 = _w.sent();
|
|
3989
|
+
return [3 /*break*/, 22];
|
|
3990
|
+
case 22: return [3 /*break*/, 25];
|
|
3991
|
+
case 23:
|
|
3485
3992
|
if (type === "update" && columnId) {
|
|
3486
|
-
dataToSubmit_2 = (
|
|
3487
|
-
|
|
3488
|
-
|
|
3993
|
+
dataToSubmit_2 = (_b = {},
|
|
3994
|
+
_b[columnId] = createSelectedData_1[columnId],
|
|
3995
|
+
_b);
|
|
3489
3996
|
}
|
|
3490
|
-
else if ((
|
|
3491
|
-
changedAttributeIds = (0, updateModule_1.compareUpdatedFields)((
|
|
3997
|
+
else if ((_m = props.bareSettings) === null || _m === void 0 ? void 0 : _m.bareUpsertPartialUpdate) {
|
|
3998
|
+
changedAttributeIds = (0, updateModule_1.compareUpdatedFields)((_o = loadedSelectedData.current) !== null && _o !== void 0 ? _o : {}, createSelectedData_1).changedAttributeIds;
|
|
3492
3999
|
baseDraftValue = isDraft ? true : false;
|
|
3493
|
-
hasBaseDraftChange = ((
|
|
4000
|
+
hasBaseDraftChange = ((_q = (_p = loadedSelectedData.current) === null || _p === void 0 ? void 0 : _p["baseDraft"]) !== null && _q !== void 0 ? _q : false) !==
|
|
3494
4001
|
baseDraftValue;
|
|
3495
4002
|
// INFO: if nothing changed (including baseDraft), skip the write entirely
|
|
3496
4003
|
if (changedAttributeIds.length === 0 && !hasBaseDraftChange)
|
|
3497
|
-
return [2 /*return*/,
|
|
4004
|
+
return [2 /*return*/, id];
|
|
3498
4005
|
dataToSubmit_2 = {};
|
|
3499
4006
|
changedAttributeIds.forEach(function (key) {
|
|
3500
4007
|
var _a;
|
|
@@ -3552,25 +4059,25 @@ exports.DataTemplate = (0, react_1.forwardRef)(function (props, ref) {
|
|
|
3552
4059
|
? "create"
|
|
3553
4060
|
: "update";
|
|
3554
4061
|
return [4 /*yield*/, writeServerQuery.call(operationType, {
|
|
3555
|
-
id:
|
|
4062
|
+
id: selectedId,
|
|
3556
4063
|
data: dataToSubmit_2,
|
|
3557
4064
|
unique: uniqueColumnId,
|
|
3558
4065
|
// INFO: bareUpsertPartialUpdate — upsert so the doc is created if it
|
|
3559
4066
|
// doesn't exist yet (covers deterministicId passed directly as props.id).
|
|
3560
4067
|
// Also applies to offline upload path so the doc is created if it was
|
|
3561
4068
|
// deleted between the existence check and the write call.
|
|
3562
|
-
upsert: ((
|
|
4069
|
+
upsert: ((_r = props.bareSettings) === null || _r === void 0 ? void 0 : _r.bareUpsertPartialUpdate) && !isOfflineUpdate
|
|
3563
4070
|
? true
|
|
3564
4071
|
: undefined,
|
|
3565
4072
|
})];
|
|
3566
|
-
case 23:
|
|
3567
|
-
res = _t.sent();
|
|
3568
|
-
_t.label = 24;
|
|
3569
4073
|
case 24:
|
|
3570
|
-
|
|
3571
|
-
|
|
3572
|
-
|
|
3573
|
-
if (!
|
|
4074
|
+
res = _w.sent();
|
|
4075
|
+
_w.label = 25;
|
|
4076
|
+
case 25:
|
|
4077
|
+
if (!(type === "update" || type === "create")) return [3 /*break*/, 33];
|
|
4078
|
+
if (!res) return [3 /*break*/, 32];
|
|
4079
|
+
if (!(type === "update")) return [3 /*break*/, 28];
|
|
4080
|
+
if (!columnId) return [3 /*break*/, 27];
|
|
3574
4081
|
selectedIndex_5 = -1;
|
|
3575
4082
|
tableData.map(function (eachData, index) {
|
|
3576
4083
|
if (eachData.id === rowId || eachData._id === rowId) {
|
|
@@ -3580,26 +4087,29 @@ exports.DataTemplate = (0, react_1.forwardRef)(function (props, ref) {
|
|
|
3580
4087
|
return null;
|
|
3581
4088
|
});
|
|
3582
4089
|
return [4 /*yield*/, handleGetListData({ data: tableData[selectedIndex_5] }, "update", rowId)];
|
|
3583
|
-
case
|
|
3584
|
-
|
|
3585
|
-
|
|
3586
|
-
case
|
|
3587
|
-
case
|
|
3588
|
-
case 28:
|
|
3589
|
-
_t.sent();
|
|
3590
|
-
_t.label = 29;
|
|
4090
|
+
case 26:
|
|
4091
|
+
_w.sent();
|
|
4092
|
+
_w.label = 27;
|
|
4093
|
+
case 27: return [3 /*break*/, 30];
|
|
4094
|
+
case 28: return [4 /*yield*/, handleGetListData({ data: [createSelectedData_1] }, "create")];
|
|
3591
4095
|
case 29:
|
|
3592
|
-
|
|
3593
|
-
|
|
4096
|
+
_w.sent();
|
|
4097
|
+
_w.label = 30;
|
|
3594
4098
|
case 30:
|
|
3595
|
-
|
|
3596
|
-
|
|
3597
|
-
case 31:
|
|
3598
|
-
|
|
3599
|
-
|
|
3600
|
-
|
|
4099
|
+
if (!((_s = props.bareSettings) === null || _s === void 0 ? void 0 : _s.bareUpdateHandlePostComplete)) return [3 /*break*/, 32];
|
|
4100
|
+
return [4 /*yield*/, props.bareSettings.bareUpdateHandlePostComplete(__assign((_c = {}, _c[serverId] = id, _c), createSelectedData_1))];
|
|
4101
|
+
case 31:
|
|
4102
|
+
_w.sent();
|
|
4103
|
+
_w.label = 32;
|
|
4104
|
+
case 32: return [3 /*break*/, 36];
|
|
3601
4105
|
case 33:
|
|
3602
|
-
|
|
4106
|
+
createSelectedData_1[serverId] = id;
|
|
4107
|
+
if (!!isOffline) return [3 /*break*/, 35];
|
|
4108
|
+
return [4 /*yield*/, handleGetListData({ data: [createSelectedData_1] }, selectedId === "new" ? "create" : "update", id)];
|
|
4109
|
+
case 34:
|
|
4110
|
+
_w.sent();
|
|
4111
|
+
_w.label = 35;
|
|
4112
|
+
case 35:
|
|
3603
4113
|
setNotification({
|
|
3604
4114
|
type: true,
|
|
3605
4115
|
title: props.id === "new"
|
|
@@ -3609,12 +4119,12 @@ exports.DataTemplate = (0, react_1.forwardRef)(function (props, ref) {
|
|
|
3609
4119
|
? "Data sucessfully created"
|
|
3610
4120
|
: "Data sucessfully updated",
|
|
3611
4121
|
});
|
|
3612
|
-
|
|
3613
|
-
case
|
|
3614
|
-
dataId = res ?
|
|
4122
|
+
_w.label = 36;
|
|
4123
|
+
case 36:
|
|
4124
|
+
dataId = res ? id : "";
|
|
3615
4125
|
return [2 /*return*/, dataId];
|
|
3616
|
-
case
|
|
3617
|
-
err_22 =
|
|
4126
|
+
case 37:
|
|
4127
|
+
err_22 = _w.sent();
|
|
3618
4128
|
console.log("error", err_22);
|
|
3619
4129
|
// INFO: clear in-flight guard on failure so the next save retries as a create
|
|
3620
4130
|
if (isCreatingRef.current) {
|
|
@@ -3622,8 +4132,71 @@ exports.DataTemplate = (0, react_1.forwardRef)(function (props, ref) {
|
|
|
3622
4132
|
pendingDraftSaveRef.current = false;
|
|
3623
4133
|
inflightIdRef.current = "";
|
|
3624
4134
|
}
|
|
4135
|
+
if (!(((_t = props.bareSettings) === null || _t === void 0 ? void 0 : _t.bareOffline) &&
|
|
4136
|
+
id &&
|
|
4137
|
+
!offlineId &&
|
|
4138
|
+
!isOfflineUpdate &&
|
|
4139
|
+
!err_22.response)) return [3 /*break*/, 42];
|
|
4140
|
+
_w.label = 38;
|
|
4141
|
+
case 38:
|
|
4142
|
+
_w.trys.push([38, 41, , 42]);
|
|
4143
|
+
return [4 /*yield*/, indexedDb_1.indexedDb.getValue("local", props.collectionId)];
|
|
4144
|
+
case 39:
|
|
4145
|
+
offlineDataResp = _w.sent();
|
|
4146
|
+
offlineData = (_u = offlineDataResp === null || offlineDataResp === void 0 ? void 0 : offlineDataResp.data) !== null && _u !== void 0 ? _u : [];
|
|
4147
|
+
clonedForOffline = (0, updateModule_1.handleClonedDataAttribute)(selectedData, structure, props.devSettings.server, true, showId);
|
|
4148
|
+
tempData = (0, updateModule_1.handleParseOfflineWrite)(clonedForOffline, structure);
|
|
4149
|
+
if (!tempData[serverId])
|
|
4150
|
+
tempData[serverId] = id;
|
|
4151
|
+
delete tempData["update"];
|
|
4152
|
+
// INFO: existing server doc edited while "online" but write failed
|
|
4153
|
+
// → baseOnline:true so it can be patched on next successful sync.
|
|
4154
|
+
// New doc that never reached the server → baseOnline:false.
|
|
4155
|
+
tempData.syncStatus = "pending";
|
|
4156
|
+
tempData.baseOnline = selectedId !== "new";
|
|
4157
|
+
if (!tempData.__offlineBaseline) {
|
|
4158
|
+
tempData.__offlineBaseline = loadedSelectedData.current
|
|
4159
|
+
? JSON.parse(JSON.stringify(loadedSelectedData.current))
|
|
4160
|
+
: null;
|
|
4161
|
+
}
|
|
4162
|
+
selectedIndex_6 = -1;
|
|
4163
|
+
offlineData.forEach(function (d, i) {
|
|
4164
|
+
if (d[serverId] === id)
|
|
4165
|
+
selectedIndex_6 = i;
|
|
4166
|
+
});
|
|
4167
|
+
if (selectedIndex_6 >= 0) {
|
|
4168
|
+
if (!tempData.__offlineBaseline &&
|
|
4169
|
+
offlineData[selectedIndex_6].__offlineBaseline) {
|
|
4170
|
+
tempData.__offlineBaseline =
|
|
4171
|
+
offlineData[selectedIndex_6].__offlineBaseline;
|
|
4172
|
+
}
|
|
4173
|
+
offlineData[selectedIndex_6] = tempData;
|
|
4174
|
+
}
|
|
4175
|
+
else {
|
|
4176
|
+
offlineData.push(tempData);
|
|
4177
|
+
}
|
|
4178
|
+
return [4 /*yield*/, indexedDb_1.indexedDb.putValue("local", {
|
|
4179
|
+
data: offlineData,
|
|
4180
|
+
type: props.collectionId,
|
|
4181
|
+
})];
|
|
4182
|
+
case 40:
|
|
4183
|
+
_w.sent();
|
|
4184
|
+
setNotification({
|
|
4185
|
+
type: false,
|
|
4186
|
+
title: selectedId === "new"
|
|
4187
|
+
? "Create Failed — Saved Offline"
|
|
4188
|
+
: "Update Failed — Saved Offline",
|
|
4189
|
+
msg: "Network unavailable. Changes saved locally and will sync when reconnected.",
|
|
4190
|
+
});
|
|
4191
|
+
handleCheckOfflineDataLength();
|
|
4192
|
+
// INFO: return id so handleSubmit can navigate as if the save succeeded
|
|
4193
|
+
return [2 /*return*/, id];
|
|
4194
|
+
case 41:
|
|
4195
|
+
_a = _w.sent();
|
|
4196
|
+
return [3 /*break*/, 42];
|
|
4197
|
+
case 42:
|
|
3625
4198
|
if (err_22.response && err_22.response.status === 400) {
|
|
3626
|
-
if (typeof ((
|
|
4199
|
+
if (typeof ((_v = err_22.response.data) === null || _v === void 0 ? void 0 : _v.err) === "string")
|
|
3627
4200
|
setNotification({
|
|
3628
4201
|
type: false,
|
|
3629
4202
|
title: "Error",
|
|
@@ -3636,8 +4209,8 @@ exports.DataTemplate = (0, react_1.forwardRef)(function (props, ref) {
|
|
|
3636
4209
|
msg: "Please contact our administrator for assistance or try your request again later. We apologize for any inconvenience",
|
|
3637
4210
|
});
|
|
3638
4211
|
}
|
|
3639
|
-
return [3 /*break*/,
|
|
3640
|
-
case
|
|
4212
|
+
return [3 /*break*/, 43];
|
|
4213
|
+
case 43: return [2 /*return*/];
|
|
3641
4214
|
}
|
|
3642
4215
|
});
|
|
3643
4216
|
}); };
|
|
@@ -3833,22 +4406,34 @@ exports.DataTemplate = (0, react_1.forwardRef)(function (props, ref) {
|
|
|
3833
4406
|
});
|
|
3834
4407
|
}); };
|
|
3835
4408
|
var handleRetrieveSelectedData = function (responseData) { return __awaiter(void 0, void 0, void 0, function () {
|
|
3836
|
-
var clonedReferencesOptions_1, dummyRespData, dummyReferenceModelSchema, newRespData, _a;
|
|
3837
|
-
var _b, _c, _d, _e, _f, _g;
|
|
3838
|
-
return __generator(this, function (
|
|
3839
|
-
switch (
|
|
4409
|
+
var resolved, clonedReferencesOptions_1, dummyRespData, dummyReferenceModelSchema, newRespData, _a;
|
|
4410
|
+
var _b, _c, _d, _e, _f, _g, _h, _j;
|
|
4411
|
+
return __generator(this, function (_k) {
|
|
4412
|
+
switch (_k.label) {
|
|
3840
4413
|
case 0:
|
|
3841
|
-
if (
|
|
3842
|
-
|
|
4414
|
+
if (process.env.NODE_ENV !== "production") {
|
|
4415
|
+
console.debug("[DTW read] handleRetrieveSelectedData called", "offline=", (_b = props.bareSettings) === null || _b === void 0 ? void 0 : _b.bareOffline, "hasData=", !!(responseData === null || responseData === void 0 ? void 0 : responseData.data), "type=", props.type);
|
|
4416
|
+
}
|
|
4417
|
+
if (!responseData.data) return [3 /*break*/, 9];
|
|
4418
|
+
if (!((_c = props.bareSettings) === null || _c === void 0 ? void 0 : _c.bareOffline)) return [3 /*break*/, 5];
|
|
3843
4419
|
// INFO: Mark as programmatic so initial data load doesn't populate dirtyFields
|
|
3844
4420
|
programmaticUpdateRef.current = true;
|
|
4421
|
+
if (!(props.type === "read")) return [3 /*break*/, 2];
|
|
4422
|
+
return [4 /*yield*/, handleResolveOfflineReferences([
|
|
4423
|
+
responseData.data,
|
|
4424
|
+
])];
|
|
4425
|
+
case 1:
|
|
4426
|
+
resolved = _k.sent();
|
|
4427
|
+
setSelectedData(resolved[0]);
|
|
4428
|
+
return [3 /*break*/, 3];
|
|
4429
|
+
case 2:
|
|
3845
4430
|
setSelectedData(responseData.data);
|
|
3846
|
-
|
|
3847
|
-
|
|
3848
|
-
//
|
|
3849
|
-
//
|
|
4431
|
+
_k.label = 3;
|
|
4432
|
+
case 3:
|
|
4433
|
+
// INFO: always baseline the raw doc (IDs intact) so diff/submit paths
|
|
4434
|
+
// compare against actual field values, not display labels.
|
|
3850
4435
|
loadedSelectedData.current = JSON.parse(JSON.stringify(responseData.data));
|
|
3851
|
-
if ((
|
|
4436
|
+
if ((_d = props.bareSettings) === null || _d === void 0 ? void 0 : _d.bareReadHandleData)
|
|
3852
4437
|
props.bareSettings.bareReadHandleData(responseData.data);
|
|
3853
4438
|
clonedReferencesOptions_1 = JSON.parse(JSON.stringify(referencesOptions));
|
|
3854
4439
|
return [4 /*yield*/, Promise.all(structure.map(function (eachModel) { return __awaiter(void 0, void 0, void 0, function () {
|
|
@@ -3862,7 +4447,29 @@ exports.DataTemplate = (0, react_1.forwardRef)(function (props, ref) {
|
|
|
3862
4447
|
case 1:
|
|
3863
4448
|
offlineDataResp = _c.sent();
|
|
3864
4449
|
offlineData = (_a = offlineDataResp === null || offlineDataResp === void 0 ? void 0 : offlineDataResp.data) !== null && _a !== void 0 ? _a : [];
|
|
3865
|
-
|
|
4450
|
+
if (process.env.NODE_ENV !== "production") {
|
|
4451
|
+
console.debug("[DTW offline ref]", eachModel.id, "key=", eachModel.referenceSpaceId + "-ref", "count=", offlineData.length, "sample=", offlineData[0]);
|
|
4452
|
+
}
|
|
4453
|
+
// INFO: convert raw docs to Option[] format so reference Select
|
|
4454
|
+
// components receive { key, label, secondaryLabel } as expected
|
|
4455
|
+
// (mirrors the shape handleRetrieveObjectReferenceOptions builds online)
|
|
4456
|
+
if ((eachModel.type === "reference" ||
|
|
4457
|
+
eachModel.type === "listReference") &&
|
|
4458
|
+
eachModel.referenceLabel) {
|
|
4459
|
+
clonedReferencesOptions_1[eachModel.id] = offlineData.map(function (r) {
|
|
4460
|
+
var _a, _b, _c, _d;
|
|
4461
|
+
return ({
|
|
4462
|
+
key: (_b = (_a = r._id) !== null && _a !== void 0 ? _a : r.id) !== null && _b !== void 0 ? _b : "",
|
|
4463
|
+
label: (_d = (_c = r[eachModel.referenceLabel]) !== null && _c !== void 0 ? _c : r._id) !== null && _d !== void 0 ? _d : "",
|
|
4464
|
+
secondaryLabel: eachModel.referenceSecondaryLabel
|
|
4465
|
+
? r[eachModel.referenceSecondaryLabel]
|
|
4466
|
+
: undefined,
|
|
4467
|
+
});
|
|
4468
|
+
});
|
|
4469
|
+
}
|
|
4470
|
+
else {
|
|
4471
|
+
clonedReferencesOptions_1[eachModel.id] = offlineData;
|
|
4472
|
+
}
|
|
3866
4473
|
if (!(isObject && eachModel.objectData)) return [3 /*break*/, 3];
|
|
3867
4474
|
prefix_1 = eachModel.id;
|
|
3868
4475
|
return [4 /*yield*/, Promise.all((_b = eachModel.objectData) === null || _b === void 0 ? void 0 : _b.map(function (eachObjectData) { return __awaiter(void 0, void 0, void 0, function () {
|
|
@@ -3895,25 +4502,28 @@ exports.DataTemplate = (0, react_1.forwardRef)(function (props, ref) {
|
|
|
3895
4502
|
}
|
|
3896
4503
|
});
|
|
3897
4504
|
}); }))];
|
|
3898
|
-
case
|
|
3899
|
-
|
|
4505
|
+
case 4:
|
|
4506
|
+
_k.sent();
|
|
3900
4507
|
setReferencesOptions(clonedReferencesOptions_1);
|
|
3901
|
-
|
|
3902
|
-
|
|
4508
|
+
if (process.env.NODE_ENV !== "production") {
|
|
4509
|
+
console.debug("[DTW offline ref] setReferencesOptions done, keys=", Object.keys(clonedReferencesOptions_1), "pilotId count=", (_e = clonedReferencesOptions_1["pilotId"]) === null || _e === void 0 ? void 0 : _e.length);
|
|
4510
|
+
}
|
|
4511
|
+
return [3 /*break*/, 9];
|
|
4512
|
+
case 5:
|
|
3903
4513
|
dummyRespData = JSON.parse(JSON.stringify(responseData.data), utils_1.jsonReviver);
|
|
3904
4514
|
dummyReferenceModelSchema = JSON.parse(JSON.stringify(referenceModelSchema));
|
|
3905
|
-
if (!(props.type === "read")) return [3 /*break*/,
|
|
4515
|
+
if (!(props.type === "read")) return [3 /*break*/, 7];
|
|
3906
4516
|
return [4 /*yield*/, (0, readModule_1.handleRetrieveDeepModel)(dummyRespData, structure !== null && structure !== void 0 ? structure : [], dbModule, devSettings, {
|
|
3907
|
-
assetParentId: (
|
|
3908
|
-
bucketName: (
|
|
3909
|
-
}, dummyReferenceModelSchema, setReferenceSchema, (
|
|
3910
|
-
case
|
|
3911
|
-
_a =
|
|
3912
|
-
return [3 /*break*/,
|
|
3913
|
-
case
|
|
4517
|
+
assetParentId: (_f = props.id) !== null && _f !== void 0 ? _f : "",
|
|
4518
|
+
bucketName: (_g = devSettings.bucketName) !== null && _g !== void 0 ? _g : "",
|
|
4519
|
+
}, dummyReferenceModelSchema, setReferenceSchema, (_h = props.organise) === null || _h === void 0 ? void 0 : _h.handleCustomDownloadFile)];
|
|
4520
|
+
case 6:
|
|
4521
|
+
_a = _k.sent();
|
|
4522
|
+
return [3 /*break*/, 8];
|
|
4523
|
+
case 7:
|
|
3914
4524
|
_a = dummyRespData;
|
|
3915
|
-
|
|
3916
|
-
case
|
|
4525
|
+
_k.label = 8;
|
|
4526
|
+
case 8:
|
|
3917
4527
|
newRespData = _a;
|
|
3918
4528
|
// INFO: Mark as programmatic so initial data load doesn't populate dirtyFields
|
|
3919
4529
|
programmaticUpdateRef.current = true;
|
|
@@ -3923,14 +4533,14 @@ exports.DataTemplate = (0, react_1.forwardRef)(function (props, ref) {
|
|
|
3923
4533
|
// Deep clone to prevent shared-reference mutations from making the
|
|
3924
4534
|
// diff see no changes (e.g. listObject array pushes).
|
|
3925
4535
|
loadedSelectedData.current = JSON.parse(JSON.stringify(newRespData));
|
|
3926
|
-
if ((
|
|
4536
|
+
if ((_j = props.bareSettings) === null || _j === void 0 ? void 0 : _j.bareReadHandleData)
|
|
3927
4537
|
props.bareSettings.bareReadHandleData(newRespData);
|
|
3928
4538
|
if ((props.type === "update" || props.type === "read") &&
|
|
3929
4539
|
props.id !== "new") {
|
|
3930
4540
|
(0, updateModule_1.handleRetrieveReferenceOptions)(newRespData, structure, dbModule, devSettings, setReferencesOptions, setReferencesDetails);
|
|
3931
4541
|
}
|
|
3932
|
-
|
|
3933
|
-
case
|
|
4542
|
+
_k.label = 9;
|
|
4543
|
+
case 9:
|
|
3934
4544
|
setModalVisible(false);
|
|
3935
4545
|
setLoading(false);
|
|
3936
4546
|
return [2 /*return*/];
|
|
@@ -5684,7 +6294,7 @@ exports.DataTemplate = (0, react_1.forwardRef)(function (props, ref) {
|
|
|
5684
6294
|
authList));
|
|
5685
6295
|
};
|
|
5686
6296
|
var renderContent = function () {
|
|
5687
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, _21, _22, _23, _24, _25, _26;
|
|
6297
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, _21, _22, _23, _24, _25, _26, _27, _28;
|
|
5688
6298
|
var isBottom = ((_a = props.bareSettings) === null || _a === void 0 ? void 0 : _a.bareUpdateActionBottom) ? true : false;
|
|
5689
6299
|
var tabs = renderTabs();
|
|
5690
6300
|
var pages = [
|
|
@@ -5714,7 +6324,7 @@ exports.DataTemplate = (0, react_1.forwardRef)(function (props, ref) {
|
|
|
5714
6324
|
type: "get",
|
|
5715
6325
|
id: props.id,
|
|
5716
6326
|
pipeline: pipeline,
|
|
5717
|
-
}, offline: (_g = props.bareSettings) === null || _g === void 0 ? void 0 : _g.bareOffline, onChangeData: handleRetrieveSelectedData, onError: handleGetItemError }),
|
|
6327
|
+
}, offline: ((_g = props.bareSettings) === null || _g === void 0 ? void 0 : _g.bareOffline) && isNetworkOffline, onChangeData: handleRetrieveSelectedData, onError: handleGetItemError }),
|
|
5718
6328
|
!loading && (react_1.default.createElement(react_1.default.Fragment, null,
|
|
5719
6329
|
renderBreadcrumb(pages),
|
|
5720
6330
|
react_1.default.createElement("div", null,
|
|
@@ -5906,7 +6516,7 @@ exports.DataTemplate = (0, react_1.forwardRef)(function (props, ref) {
|
|
|
5906
6516
|
type: "get",
|
|
5907
6517
|
id: props.id,
|
|
5908
6518
|
pipeline: pipeline,
|
|
5909
|
-
}, offline: (_6 = props.bareSettings) === null || _6 === void 0 ? void 0 : _6.bareOffline, onChangeData: handleRetrieveSelectedData, onError: handleGetItemError })),
|
|
6519
|
+
}, offline: ((_6 = props.bareSettings) === null || _6 === void 0 ? void 0 : _6.bareOffline) && isNetworkOffline, onChangeData: handleRetrieveSelectedData, onError: handleGetItemError })),
|
|
5910
6520
|
renderBreadcrumb(pages),
|
|
5911
6521
|
react_1.default.createElement("div", { className: "flex flex-col py-2 sm:items-center sm:flex-row" },
|
|
5912
6522
|
(props.title || props.description) && (react_1.default.createElement("div", { className: "flex flex-col w-full" },
|
|
@@ -5978,7 +6588,7 @@ exports.DataTemplate = (0, react_1.forwardRef)(function (props, ref) {
|
|
|
5978
6588
|
dbEndpoint: devSettings.dbEndpoint,
|
|
5979
6589
|
dbAPIToken: devSettings.dbAPIToken,
|
|
5980
6590
|
dbUserToken: devSettings.dbUserToken,
|
|
5981
|
-
}, cond: handleReadQueryHocCond(), offline: (_21 = props.bareSettings) === null || _21 === void 0 ? void 0 : _21.bareOffline, onChangeData: function (data) {
|
|
6591
|
+
}, cond: handleReadQueryHocCond(), offline: ((_21 = props.bareSettings) === null || _21 === void 0 ? void 0 : _21.bareOffline) && isNetworkOffline, onChangeData: function (data) {
|
|
5982
6592
|
handleGetListData(data, "", "");
|
|
5983
6593
|
}, onError: handleGetItemError }));
|
|
5984
6594
|
if ((_22 = props.renderSettings) === null || _22 === void 0 ? void 0 : _22.renderListUI) {
|
|
@@ -6160,15 +6770,24 @@ exports.DataTemplate = (0, react_1.forwardRef)(function (props, ref) {
|
|
|
6160
6770
|
? "w-full flex-row flex-wrap sm:flex-nowrap items-end"
|
|
6161
6771
|
: "flex-col md:items-end md:flex-row") },
|
|
6162
6772
|
(props.title || props.description) && (react_1.default.createElement("div", { className: "flex flex-col" },
|
|
6163
|
-
props.title && (react_1.default.createElement("
|
|
6773
|
+
props.title && (react_1.default.createElement("div", { className: "flex items-center gap-2" },
|
|
6774
|
+
react_1.default.createElement("p", { className: "text-xl font-medium" }, props.title),
|
|
6775
|
+
((_24 = props.bareSettings) === null || _24 === void 0 ? void 0 : _24.bareSocketName) &&
|
|
6776
|
+
isLive &&
|
|
6777
|
+
!isLiveOffline && (react_1.default.createElement("span", { className: "inline-flex items-center gap-1 rounded-full bg-green-100 px-2 py-0.5 text-xs font-medium text-green-700" },
|
|
6778
|
+
react_1.default.createElement("span", { className: "h-1.5 w-1.5 rounded-full bg-green-500" }),
|
|
6779
|
+
"LIVE")),
|
|
6780
|
+
((_25 = props.bareSettings) === null || _25 === void 0 ? void 0 : _25.bareSocketName) && isLiveOffline && (react_1.default.createElement("span", { className: "inline-flex items-center gap-1 rounded-full bg-orange-100 px-2 py-0.5 text-xs font-medium text-orange-700" },
|
|
6781
|
+
react_1.default.createElement("span", { className: "h-1.5 w-1.5 rounded-full bg-orange-400" }),
|
|
6782
|
+
"OFFLINE")))),
|
|
6164
6783
|
props.description && (react_1.default.createElement("span", { className: "text-sm text-gray-500" }, props.description)))),
|
|
6165
|
-
react_1.default.createElement("div", { className: ((
|
|
6784
|
+
react_1.default.createElement("div", { className: ((_26 = props.bareSettings) === null || _26 === void 0 ? void 0 : _26.bareCompactMode)
|
|
6166
6785
|
? "hidden sm:block grow"
|
|
6167
6786
|
: "grow" }),
|
|
6168
6787
|
renderListFilterElements(),
|
|
6169
6788
|
renderListActionElements()),
|
|
6170
6789
|
renderListNewRowFilterElements(),
|
|
6171
|
-
(schemaPresent || ((
|
|
6790
|
+
(schemaPresent || ((_27 = props.bareSettings) === null || _27 === void 0 ? void 0 : _27.bareReadListTabs)) && (react_1.default.createElement(tabs_1.Tabs, { tabs: tabs, selectedId: viewType, linkType: props.linkType, custom: props.custom, onClick: function (id) { return handleSelectTab(id); }, darkMode: (_28 = props.organise) === null || _28 === void 0 ? void 0 : _28.darkMode })),
|
|
6172
6791
|
renderTabContent(tabs, props.type, viewType),
|
|
6173
6792
|
isBottom && renderActionButtons(props.type, true)));
|
|
6174
6793
|
default:
|
|
@@ -7735,7 +8354,7 @@ exports.DataTemplate = (0, react_1.forwardRef)(function (props, ref) {
|
|
|
7735
8354
|
};
|
|
7736
8355
|
return (react_1.default.createElement(react_1.default.Fragment, null,
|
|
7737
8356
|
renderNotification("root"),
|
|
7738
|
-
((
|
|
8357
|
+
((_43 = (_42 = props.renderSettings) === null || _42 === void 0 ? void 0 : _42.renderLoadingUI) === null || _43 === void 0 ? void 0 : _43.call(_42)) && loading ? ((_44 = props.renderSettings) === null || _44 === void 0 ? void 0 : _44.renderLoadingUI()) : (react_1.default.createElement(modal_1.Modal, { maxWidth: selectedObjectStructureId || excelModal ? "2xl" : undefined, open: modalVisible, title: renderModalTitle(), renderContent: renderModalContent, onClose: function () {
|
|
7739
8358
|
var _a, _b;
|
|
7740
8359
|
if (loading)
|
|
7741
8360
|
return;
|