blixify-ui-web 1.2.161 → 1.2.162
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/data/dataTemplate/index.tsx"],"names":[],"mappings":"AAqCA,OAAO,KASN,MAAM,OAAO,CAAC;AAgGf,OAAO,EACL,iBAAiB,EAKlB,MAAM,kBAAkB,CAAC;AA8G1B,eAAO,MAAM,YAAY,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/data/dataTemplate/index.tsx"],"names":[],"mappings":"AAqCA,OAAO,KASN,MAAM,OAAO,CAAC;AAgGf,OAAO,EACL,iBAAiB,EAKlB,MAAM,kBAAkB,CAAC;AA8G1B,eAAO,MAAM,YAAY,mFAu8bvB,CAAC"}
|
|
@@ -621,6 +621,10 @@ exports.DataTemplate = (0, react_1.forwardRef)(function (props, ref) {
|
|
|
621
621
|
var isCreatingRef = (0, react_1.useRef)(false);
|
|
622
622
|
var pendingDraftSaveRef = (0, react_1.useRef)(false);
|
|
623
623
|
var inflightIdRef = (0, react_1.useRef)("");
|
|
624
|
+
// INFO: ids this form created as a draft through the unique-idField create below —
|
|
625
|
+
// a later save of that same draft must update it, not be refused as a duplicate of
|
|
626
|
+
// itself. Cleared on the final save so the next new record is checked again.
|
|
627
|
+
var createdUniqueIdsRef = (0, react_1.useRef)(new Set());
|
|
624
628
|
// INFO: submit re-entry guard — prevents double-click, rapid Enter keypresses,
|
|
625
629
|
// or concurrent bareSaveOnTabChange calls from running handleSubmit twice.
|
|
626
630
|
// useRef is required (not useState) so the guard is readable synchronously
|
|
@@ -4801,17 +4805,17 @@ exports.DataTemplate = (0, react_1.forwardRef)(function (props, ref) {
|
|
|
4801
4805
|
});
|
|
4802
4806
|
}); };
|
|
4803
4807
|
var handleSubmitData = function (type, rowId, columnId, data, offlineId, isOfflineUpdate, isDraft) { return __awaiter(void 0, void 0, void 0, function () {
|
|
4804
|
-
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, currentRow, wentToServer, dataId, err_22, offlineDataResp, offlineData, clonedForOffline, tempData, selectedIndex_5, _a;
|
|
4808
|
+
var selectedId, id, createSelectedData_1, uniqueDataStructure, uniqueColumnId, res, offlineDataResp, offlineData, clonedForOffline, tempData, selectedIndex_3, err_20, isUniqueIdFieldCreate, isExistingDoc, newRecordData_1, changedAttributeIds, baseDraftValue, hasBaseDraftChange, offlineDataResp, clonedForOffline, tempData, selectedIndex_4, offlineData, err_21, dataToSubmit_2, changedAttributeIds, baseDraftValue, hasBaseDraftChange, operationType, currentRow, wentToServer, dataId, err_22, offlineDataResp, offlineData, clonedForOffline, tempData, selectedIndex_5, _a;
|
|
4805
4809
|
var _b, _c, _d, _e;
|
|
4806
|
-
var _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x;
|
|
4807
|
-
return __generator(this, function (
|
|
4808
|
-
switch (
|
|
4810
|
+
var _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y;
|
|
4811
|
+
return __generator(this, function (_z) {
|
|
4812
|
+
switch (_z.label) {
|
|
4809
4813
|
case 0:
|
|
4810
4814
|
selectedId = "";
|
|
4811
4815
|
id = "";
|
|
4812
|
-
|
|
4816
|
+
_z.label = 1;
|
|
4813
4817
|
case 1:
|
|
4814
|
-
|
|
4818
|
+
_z.trys.push([1, 39, , 45]);
|
|
4815
4819
|
if (type === "update")
|
|
4816
4820
|
selectedId = rowId !== null && rowId !== void 0 ? rowId : "";
|
|
4817
4821
|
else if (type === "create")
|
|
@@ -4841,8 +4845,8 @@ exports.DataTemplate = (0, react_1.forwardRef)(function (props, ref) {
|
|
|
4841
4845
|
return [3 /*break*/, 4];
|
|
4842
4846
|
case 2: return [4 /*yield*/, handleUploadImage(id, data)];
|
|
4843
4847
|
case 3:
|
|
4844
|
-
createSelectedData_1 =
|
|
4845
|
-
|
|
4848
|
+
createSelectedData_1 = _z.sent();
|
|
4849
|
+
_z.label = 4;
|
|
4846
4850
|
case 4:
|
|
4847
4851
|
uniqueDataStructure = structure.filter(function (eachStructure) {
|
|
4848
4852
|
return eachStructure.unique;
|
|
@@ -4864,12 +4868,12 @@ exports.DataTemplate = (0, react_1.forwardRef)(function (props, ref) {
|
|
|
4864
4868
|
if (isDraft)
|
|
4865
4869
|
createSelectedData_1["baseDraft"] = true;
|
|
4866
4870
|
if (!isOffline) return [3 /*break*/, 10];
|
|
4867
|
-
|
|
4871
|
+
_z.label = 5;
|
|
4868
4872
|
case 5:
|
|
4869
|
-
|
|
4873
|
+
_z.trys.push([5, 8, , 9]);
|
|
4870
4874
|
return [4 /*yield*/, indexedDb_1.indexedDb.getValue("local", props.collectionId)];
|
|
4871
4875
|
case 6:
|
|
4872
|
-
offlineDataResp =
|
|
4876
|
+
offlineDataResp = _z.sent();
|
|
4873
4877
|
offlineData = (_h = offlineDataResp === null || offlineDataResp === void 0 ? void 0 : offlineDataResp.data) !== null && _h !== void 0 ? _h : [];
|
|
4874
4878
|
clonedForOffline = (0, updateModule_1.handleClonedDataAttribute)(selectedData, structure, props.devSettings.server, true, showId);
|
|
4875
4879
|
tempData = (0, updateModule_1.handleParseOfflineWrite)(clonedForOffline, structure);
|
|
@@ -4913,22 +4917,28 @@ exports.DataTemplate = (0, react_1.forwardRef)(function (props, ref) {
|
|
|
4913
4917
|
type: props.collectionId,
|
|
4914
4918
|
})];
|
|
4915
4919
|
case 7:
|
|
4916
|
-
|
|
4920
|
+
_z.sent();
|
|
4917
4921
|
res = true;
|
|
4918
4922
|
return [3 /*break*/, 9];
|
|
4919
4923
|
case 8:
|
|
4920
|
-
err_20 =
|
|
4924
|
+
err_20 = _z.sent();
|
|
4921
4925
|
return [3 /*break*/, 9];
|
|
4922
4926
|
case 9: return [3 /*break*/, 16];
|
|
4923
4927
|
case 10:
|
|
4924
|
-
|
|
4925
|
-
|
|
4926
|
-
|
|
4928
|
+
isUniqueIdFieldCreate = !!idField &&
|
|
4929
|
+
!!selectedData[idField] &&
|
|
4930
|
+
uniqueColumnId === idField &&
|
|
4931
|
+
!((_j = props.bareSettings) === null || _j === void 0 ? void 0 : _j.bareUpsertPartialUpdate) &&
|
|
4932
|
+
!createdUniqueIdsRef.current.has(id);
|
|
4933
|
+
if (!(((idField && selectedData[idField]) ||
|
|
4934
|
+
((_k = props.bareSettings) === null || _k === void 0 ? void 0 : _k.bareUpsertPartialUpdate)) &&
|
|
4935
|
+
!isUniqueIdFieldCreate)) return [3 /*break*/, 12];
|
|
4936
|
+
isExistingDoc = ((_l = props.bareSettings) === null || _l === void 0 ? void 0 : _l.bareUpsertPartialUpdate) &&
|
|
4927
4937
|
loadedSelectedData.current != null;
|
|
4928
4938
|
if (isExistingDoc) {
|
|
4929
4939
|
changedAttributeIds = (0, updateModule_1.compareUpdatedFields)(loadedSelectedData.current, createSelectedData_1).changedAttributeIds;
|
|
4930
4940
|
baseDraftValue = isDraft ? true : false;
|
|
4931
|
-
hasBaseDraftChange = ((
|
|
4941
|
+
hasBaseDraftChange = ((_o = (_m = loadedSelectedData.current) === null || _m === void 0 ? void 0 : _m["baseDraft"]) !== null && _o !== void 0 ? _o : false) !==
|
|
4932
4942
|
baseDraftValue;
|
|
4933
4943
|
// INFO: if nothing changed (including baseDraft), skip the write
|
|
4934
4944
|
if (changedAttributeIds.length === 0 && !hasBaseDraftChange)
|
|
@@ -4977,9 +4987,12 @@ exports.DataTemplate = (0, react_1.forwardRef)(function (props, ref) {
|
|
|
4977
4987
|
id: id,
|
|
4978
4988
|
data: newRecordData_1,
|
|
4979
4989
|
upsert: true,
|
|
4990
|
+
unique: uniqueColumnId,
|
|
4980
4991
|
})];
|
|
4981
4992
|
case 11:
|
|
4982
|
-
res =
|
|
4993
|
+
res = _z.sent();
|
|
4994
|
+
if (!isDraft)
|
|
4995
|
+
createdUniqueIdsRef.current.delete(id);
|
|
4983
4996
|
return [3 /*break*/, 16];
|
|
4984
4997
|
case 12:
|
|
4985
4998
|
// INFO: stepper create guard — if a create is already in-flight, queue this
|
|
@@ -4999,7 +5012,9 @@ exports.DataTemplate = (0, react_1.forwardRef)(function (props, ref) {
|
|
|
4999
5012
|
})];
|
|
5000
5013
|
case 13:
|
|
5001
5014
|
//INFO: [CREATE] Create new data
|
|
5002
|
-
res =
|
|
5015
|
+
res = _z.sent();
|
|
5016
|
+
if (isUniqueIdFieldCreate && isDraft)
|
|
5017
|
+
createdUniqueIdsRef.current.add(id);
|
|
5003
5018
|
if (!(selectedId === "new")) return [3 /*break*/, 16];
|
|
5004
5019
|
isCreatingRef.current = false;
|
|
5005
5020
|
if (!pendingDraftSaveRef.current) return [3 /*break*/, 15];
|
|
@@ -5011,23 +5026,23 @@ exports.DataTemplate = (0, react_1.forwardRef)(function (props, ref) {
|
|
|
5011
5026
|
})];
|
|
5012
5027
|
case 14:
|
|
5013
5028
|
// INFO: replay as update — inflightIdRef.current holds the real _id
|
|
5014
|
-
|
|
5015
|
-
|
|
5029
|
+
_z.sent();
|
|
5030
|
+
_z.label = 15;
|
|
5016
5031
|
case 15:
|
|
5017
5032
|
inflightIdRef.current = "";
|
|
5018
|
-
|
|
5033
|
+
_z.label = 16;
|
|
5019
5034
|
case 16: return [3 /*break*/, 25];
|
|
5020
5035
|
case 17:
|
|
5021
5036
|
if (!selectedId) return [3 /*break*/, 25];
|
|
5022
5037
|
if (!(isOffline &&
|
|
5023
5038
|
!(isOfflineNetworkListener && !isNetworkOffline) &&
|
|
5024
5039
|
!offlineId)) return [3 /*break*/, 23];
|
|
5025
|
-
|
|
5040
|
+
_z.label = 18;
|
|
5026
5041
|
case 18:
|
|
5027
|
-
|
|
5042
|
+
_z.trys.push([18, 21, , 22]);
|
|
5028
5043
|
return [4 /*yield*/, indexedDb_1.indexedDb.getValue("local", props.collectionId)];
|
|
5029
5044
|
case 19:
|
|
5030
|
-
offlineDataResp =
|
|
5045
|
+
offlineDataResp = _z.sent();
|
|
5031
5046
|
clonedForOffline = (0, updateModule_1.handleClonedDataAttribute)(selectedData, structure, props.devSettings.server, true, showId);
|
|
5032
5047
|
tempData = (0, updateModule_1.handleParseOfflineWrite)(clonedForOffline, structure);
|
|
5033
5048
|
tempData[serverId] = selectedId;
|
|
@@ -5039,7 +5054,7 @@ exports.DataTemplate = (0, react_1.forwardRef)(function (props, ref) {
|
|
|
5039
5054
|
tempData.syncStatus = "pending";
|
|
5040
5055
|
tempData.baseOnline = true; // INFO: existing server doc, updated offline
|
|
5041
5056
|
selectedIndex_4 = -1;
|
|
5042
|
-
offlineData = (
|
|
5057
|
+
offlineData = (_p = offlineDataResp === null || offlineDataResp === void 0 ? void 0 : offlineDataResp.data) !== null && _p !== void 0 ? _p : [];
|
|
5043
5058
|
offlineData.map(function (eachOfflineData, index) {
|
|
5044
5059
|
var offlineDataId = eachOfflineData[serverId];
|
|
5045
5060
|
if (selectedId === offlineDataId)
|
|
@@ -5069,11 +5084,11 @@ exports.DataTemplate = (0, react_1.forwardRef)(function (props, ref) {
|
|
|
5069
5084
|
type: props.collectionId,
|
|
5070
5085
|
})];
|
|
5071
5086
|
case 20:
|
|
5072
|
-
|
|
5087
|
+
_z.sent();
|
|
5073
5088
|
res = true;
|
|
5074
5089
|
return [3 /*break*/, 22];
|
|
5075
5090
|
case 21:
|
|
5076
|
-
err_21 =
|
|
5091
|
+
err_21 = _z.sent();
|
|
5077
5092
|
return [3 /*break*/, 22];
|
|
5078
5093
|
case 22: return [3 /*break*/, 25];
|
|
5079
5094
|
case 23:
|
|
@@ -5082,10 +5097,10 @@ exports.DataTemplate = (0, react_1.forwardRef)(function (props, ref) {
|
|
|
5082
5097
|
_b[columnId] = createSelectedData_1[columnId],
|
|
5083
5098
|
_b);
|
|
5084
5099
|
}
|
|
5085
|
-
else if ((
|
|
5086
|
-
changedAttributeIds = (0, updateModule_1.compareUpdatedFields)((
|
|
5100
|
+
else if ((_q = props.bareSettings) === null || _q === void 0 ? void 0 : _q.bareUpsertPartialUpdate) {
|
|
5101
|
+
changedAttributeIds = (0, updateModule_1.compareUpdatedFields)((_r = loadedSelectedData.current) !== null && _r !== void 0 ? _r : {}, createSelectedData_1).changedAttributeIds;
|
|
5087
5102
|
baseDraftValue = isDraft ? true : false;
|
|
5088
|
-
hasBaseDraftChange = ((
|
|
5103
|
+
hasBaseDraftChange = ((_t = (_s = loadedSelectedData.current) === null || _s === void 0 ? void 0 : _s["baseDraft"]) !== null && _t !== void 0 ? _t : false) !==
|
|
5089
5104
|
baseDraftValue;
|
|
5090
5105
|
// INFO: if nothing changed (including baseDraft), skip the write entirely
|
|
5091
5106
|
if (changedAttributeIds.length === 0 && !hasBaseDraftChange)
|
|
@@ -5154,13 +5169,13 @@ exports.DataTemplate = (0, react_1.forwardRef)(function (props, ref) {
|
|
|
5154
5169
|
// doesn't exist yet (covers deterministicId passed directly as props.id).
|
|
5155
5170
|
// Also applies to offline upload path so the doc is created if it was
|
|
5156
5171
|
// deleted between the existence check and the write call.
|
|
5157
|
-
upsert: ((
|
|
5172
|
+
upsert: ((_u = props.bareSettings) === null || _u === void 0 ? void 0 : _u.bareUpsertPartialUpdate) && !isOfflineUpdate
|
|
5158
5173
|
? true
|
|
5159
5174
|
: undefined,
|
|
5160
5175
|
})];
|
|
5161
5176
|
case 24:
|
|
5162
|
-
res =
|
|
5163
|
-
|
|
5177
|
+
res = _z.sent();
|
|
5178
|
+
_z.label = 25;
|
|
5164
5179
|
case 25:
|
|
5165
5180
|
if (!(type === "update" || type === "create")) return [3 /*break*/, 33];
|
|
5166
5181
|
if (!res) return [3 /*break*/, 32];
|
|
@@ -5174,36 +5189,36 @@ exports.DataTemplate = (0, react_1.forwardRef)(function (props, ref) {
|
|
|
5174
5189
|
],
|
|
5175
5190
|
}, "update", rowId)];
|
|
5176
5191
|
case 26:
|
|
5177
|
-
|
|
5178
|
-
|
|
5192
|
+
_z.sent();
|
|
5193
|
+
_z.label = 27;
|
|
5179
5194
|
case 27: return [3 /*break*/, 30];
|
|
5180
5195
|
case 28: return [4 /*yield*/, handleGetListData({ data: [createSelectedData_1] }, "create")];
|
|
5181
5196
|
case 29:
|
|
5182
|
-
|
|
5183
|
-
|
|
5197
|
+
_z.sent();
|
|
5198
|
+
_z.label = 30;
|
|
5184
5199
|
case 30:
|
|
5185
|
-
if (!((
|
|
5200
|
+
if (!((_v = props.bareSettings) === null || _v === void 0 ? void 0 : _v.bareUpdateHandlePostComplete)) return [3 /*break*/, 32];
|
|
5186
5201
|
return [4 /*yield*/, props.bareSettings.bareUpdateHandlePostComplete(__assign((_d = {}, _d[serverId] = id, _d), createSelectedData_1))];
|
|
5187
5202
|
case 31:
|
|
5188
|
-
|
|
5189
|
-
|
|
5203
|
+
_z.sent();
|
|
5204
|
+
_z.label = 32;
|
|
5190
5205
|
case 32: return [3 /*break*/, 38];
|
|
5191
5206
|
case 33:
|
|
5192
5207
|
createSelectedData_1[serverId] = id;
|
|
5193
5208
|
if (!!isOffline) return [3 /*break*/, 35];
|
|
5194
5209
|
return [4 /*yield*/, handleGetListData({ data: [createSelectedData_1] }, selectedId === "new" ? "create" : "update", id)];
|
|
5195
5210
|
case 34:
|
|
5196
|
-
|
|
5197
|
-
|
|
5211
|
+
_z.sent();
|
|
5212
|
+
_z.label = 35;
|
|
5198
5213
|
case 35:
|
|
5199
5214
|
wentToServer = res &&
|
|
5200
5215
|
!offlineId &&
|
|
5201
5216
|
(!isOffline || (isOfflineNetworkListener && !isNetworkOffline));
|
|
5202
|
-
if (!(wentToServer && ((
|
|
5217
|
+
if (!(wentToServer && ((_w = props.bareSettings) === null || _w === void 0 ? void 0 : _w.bareUpdateHandlePostComplete))) return [3 /*break*/, 37];
|
|
5203
5218
|
return [4 /*yield*/, props.bareSettings.bareUpdateHandlePostComplete(__assign((_e = {}, _e[serverId] = id, _e), createSelectedData_1), handleResolveRawData())];
|
|
5204
5219
|
case 36:
|
|
5205
|
-
|
|
5206
|
-
|
|
5220
|
+
_z.sent();
|
|
5221
|
+
_z.label = 37;
|
|
5207
5222
|
case 37:
|
|
5208
5223
|
// INFO: a draft save announces itself (or stays silent on a step
|
|
5209
5224
|
// change) further up — this toast is for a real update only
|
|
@@ -5218,12 +5233,12 @@ exports.DataTemplate = (0, react_1.forwardRef)(function (props, ref) {
|
|
|
5218
5233
|
: "Data sucessfully updated",
|
|
5219
5234
|
});
|
|
5220
5235
|
}
|
|
5221
|
-
|
|
5236
|
+
_z.label = 38;
|
|
5222
5237
|
case 38:
|
|
5223
5238
|
dataId = res ? id : "";
|
|
5224
5239
|
return [2 /*return*/, dataId];
|
|
5225
5240
|
case 39:
|
|
5226
|
-
err_22 =
|
|
5241
|
+
err_22 = _z.sent();
|
|
5227
5242
|
console.log("error", err_22);
|
|
5228
5243
|
// INFO: clear in-flight guard on failure so the next save retries as a create
|
|
5229
5244
|
if (isCreatingRef.current) {
|
|
@@ -5231,18 +5246,18 @@ exports.DataTemplate = (0, react_1.forwardRef)(function (props, ref) {
|
|
|
5231
5246
|
pendingDraftSaveRef.current = false;
|
|
5232
5247
|
inflightIdRef.current = "";
|
|
5233
5248
|
}
|
|
5234
|
-
if (!(((
|
|
5249
|
+
if (!(((_x = props.bareSettings) === null || _x === void 0 ? void 0 : _x.bareOffline) &&
|
|
5235
5250
|
id &&
|
|
5236
5251
|
!offlineId &&
|
|
5237
5252
|
!isOfflineUpdate &&
|
|
5238
5253
|
!err_22.response)) return [3 /*break*/, 44];
|
|
5239
|
-
|
|
5254
|
+
_z.label = 40;
|
|
5240
5255
|
case 40:
|
|
5241
|
-
|
|
5256
|
+
_z.trys.push([40, 43, , 44]);
|
|
5242
5257
|
return [4 /*yield*/, indexedDb_1.indexedDb.getValue("local", props.collectionId)];
|
|
5243
5258
|
case 41:
|
|
5244
|
-
offlineDataResp =
|
|
5245
|
-
offlineData = (
|
|
5259
|
+
offlineDataResp = _z.sent();
|
|
5260
|
+
offlineData = (_y = offlineDataResp === null || offlineDataResp === void 0 ? void 0 : offlineDataResp.data) !== null && _y !== void 0 ? _y : [];
|
|
5246
5261
|
clonedForOffline = (0, updateModule_1.handleClonedDataAttribute)(selectedData, structure, props.devSettings.server, true, showId);
|
|
5247
5262
|
tempData = (0, updateModule_1.handleParseOfflineWrite)(clonedForOffline, structure);
|
|
5248
5263
|
if (!tempData[serverId])
|
|
@@ -5279,7 +5294,7 @@ exports.DataTemplate = (0, react_1.forwardRef)(function (props, ref) {
|
|
|
5279
5294
|
type: props.collectionId,
|
|
5280
5295
|
})];
|
|
5281
5296
|
case 42:
|
|
5282
|
-
|
|
5297
|
+
_z.sent();
|
|
5283
5298
|
setNotification({
|
|
5284
5299
|
type: false,
|
|
5285
5300
|
title: selectedId === "new"
|
|
@@ -5291,7 +5306,7 @@ exports.DataTemplate = (0, react_1.forwardRef)(function (props, ref) {
|
|
|
5291
5306
|
// INFO: return id so handleSubmit can navigate as if the save succeeded
|
|
5292
5307
|
return [2 /*return*/, id];
|
|
5293
5308
|
case 43:
|
|
5294
|
-
_a =
|
|
5309
|
+
_a = _z.sent();
|
|
5295
5310
|
return [3 /*break*/, 44];
|
|
5296
5311
|
case 44:
|
|
5297
5312
|
if (err_22.response) {
|