blixify-ui-web 1.2.6 → 1.2.7
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 +308 -97
- package/lib/components/data/dataTemplate/index.js.map +1 -1
- package/lib/components/data/dataWrapper/index.d.ts +2 -0
- package/lib/components/data/dataWrapper/index.d.ts.map +1 -1
- package/lib/components/data/dataWrapper/index.js +15 -0
- package/lib/components/data/dataWrapper/index.js.map +1 -1
- package/lib/components/data/testData.d.ts +1 -0
- package/lib/components/data/testData.d.ts.map +1 -1
- package/lib/components/data/testData.js +2 -1
- package/lib/components/data/testData.js.map +1 -1
- package/lib/components/data/testSchema.d.ts +1 -0
- package/lib/components/data/testSchema.d.ts.map +1 -1
- package/lib/components/data/testSchema.js +229 -1
- 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 +20 -4
- package/lib/components/data/updateModule.js.map +1 -1
- package/lib/components/display/flexTable/index.d.ts +2 -0
- package/lib/components/display/flexTable/index.d.ts.map +1 -1
- package/lib/components/display/flexTable/index.js +18 -5
- package/lib/components/display/flexTable/index.js.map +1 -1
- package/lib/components/display/flexTable/uploadCell.d.ts +10 -1
- package/lib/components/display/flexTable/uploadCell.d.ts.map +1 -1
- package/lib/components/display/flexTable/uploadCell.js +72 -8
- package/lib/components/display/flexTable/uploadCell.js.map +1 -1
- package/lib/tail.css +1 -1
- package/package.json +1 -1
|
@@ -333,6 +333,18 @@ exports.DataTemplate = (0, react_1.forwardRef)(function (props, ref) {
|
|
|
333
333
|
// Intentionally separate from previousSelectedData, which advances on every
|
|
334
334
|
// edit and therefore cannot serve as a stable submit baseline.
|
|
335
335
|
var loadedSelectedData = (0, react_1.useRef)(null);
|
|
336
|
+
// INFO: Cumulative set of field IDs the user explicitly interacted with (dirty tracking).
|
|
337
|
+
// Populated via the bareUpdateHandleData useEffect which detects per-render field changes.
|
|
338
|
+
// Used as the PRIMARY condition for deciding what to submit:
|
|
339
|
+
// - If a field is in dirtyFields → it was user-edited → always include it in the payload
|
|
340
|
+
// - If a field is NOT in dirtyFields but appears in compareUpdatedFields diff → it was
|
|
341
|
+
// changed externally (e.g. socket merge, prefill) → apply non-empty-wins as SECONDARY guard
|
|
342
|
+
// Reset after each successful save (baseline rebase).
|
|
343
|
+
var dirtyFieldsRef = (0, react_1.useRef)(new Set());
|
|
344
|
+
// INFO: Flag to distinguish user interactions from programmatic updates (handleUpdateSelectedData,
|
|
345
|
+
// socket merges, prefills). When true, the next changedAttributeIds from the useEffect should NOT
|
|
346
|
+
// be added to dirtyFields because the change was programmatic, not user-driven.
|
|
347
|
+
var programmaticUpdateRef = (0, react_1.useRef)(false);
|
|
336
348
|
var formRef = (0, react_1.createRef)();
|
|
337
349
|
var objectFormRef = (0, react_1.createRef)();
|
|
338
350
|
var listAddressFromRef = (0, react_1.createRef)();
|
|
@@ -518,6 +530,16 @@ exports.DataTemplate = (0, react_1.forwardRef)(function (props, ref) {
|
|
|
518
530
|
handleUploadOfflineData: handleUploadOfflineData,
|
|
519
531
|
handleUpdateSelectedData: handleUpdateSelectedData,
|
|
520
532
|
handleExportReadPDF: handleExportReadPDF,
|
|
533
|
+
// INFO: Allow consumer to update the diff baseline externally (e.g. for socket-driven merge)
|
|
534
|
+
handleUpdateBaseline: function (newBaseline) {
|
|
535
|
+
// INFO: Do NOT reset dirtyFields here — the user's pending edits should still be
|
|
536
|
+
// treated as dirty even after a socket merge updates the baseline. dirtyFields is
|
|
537
|
+
// only reset after a successful save.
|
|
538
|
+
programmaticUpdateRef.current = true;
|
|
539
|
+
loadedSelectedData.current = newBaseline
|
|
540
|
+
? JSON.parse(JSON.stringify(newBaseline))
|
|
541
|
+
: null;
|
|
542
|
+
},
|
|
521
543
|
}); });
|
|
522
544
|
(0, react_1.useEffect)(function () {
|
|
523
545
|
handleCheckOfflineDataLength();
|
|
@@ -758,10 +780,22 @@ exports.DataTemplate = (0, react_1.forwardRef)(function (props, ref) {
|
|
|
758
780
|
}
|
|
759
781
|
}, [renderImpSearchFilterConditions]);
|
|
760
782
|
(0, react_1.useEffect)(function () {
|
|
761
|
-
var _a, _b;
|
|
783
|
+
var _a, _b, _c;
|
|
762
784
|
if ((_a = props.bareSettings) === null || _a === void 0 ? void 0 : _a.bareUpdateHandleData) {
|
|
763
785
|
var comparisonResult = (0, updateModule_1.compareUpdatedFields)((_b = previousSelectedData === null || previousSelectedData === void 0 ? void 0 : previousSelectedData.current) !== null && _b !== void 0 ? _b : {}, selectedData);
|
|
764
786
|
var changedAttributeIds = comparisonResult.changedAttributeIds || [];
|
|
787
|
+
// INFO: Dirty tracking — only add to dirtyFields when the change was triggered by
|
|
788
|
+
// user interaction (not programmatic updates like handleUpdateSelectedData or socket merges).
|
|
789
|
+
if ((_c = props.bareSettings) === null || _c === void 0 ? void 0 : _c.bareUpsertPartialUpdate) {
|
|
790
|
+
if (programmaticUpdateRef.current) {
|
|
791
|
+
// INFO: This change was programmatic — do NOT mark fields as dirty
|
|
792
|
+
programmaticUpdateRef.current = false;
|
|
793
|
+
}
|
|
794
|
+
else if (previousSelectedData.current != null) {
|
|
795
|
+
// INFO: User-driven change — mark these fields as dirty
|
|
796
|
+
changedAttributeIds.forEach(function (id) { return dirtyFieldsRef.current.add(id); });
|
|
797
|
+
}
|
|
798
|
+
}
|
|
765
799
|
props.bareSettings.bareUpdateHandleData(selectedData, changedAttributeIds);
|
|
766
800
|
}
|
|
767
801
|
previousSelectedData.current = selectedData;
|
|
@@ -863,6 +897,8 @@ exports.DataTemplate = (0, react_1.forwardRef)(function (props, ref) {
|
|
|
863
897
|
}
|
|
864
898
|
}, [props.id]);
|
|
865
899
|
var handleUpdateSelectedData = function (changeData) {
|
|
900
|
+
// INFO: Mark as programmatic so dirtyFields is NOT populated for these changes
|
|
901
|
+
programmaticUpdateRef.current = true;
|
|
866
902
|
changeData.map(function (eachField) {
|
|
867
903
|
var key = eachField.key, value = eachField.value;
|
|
868
904
|
selectedData[key] = value;
|
|
@@ -2955,22 +2991,22 @@ exports.DataTemplate = (0, react_1.forwardRef)(function (props, ref) {
|
|
|
2955
2991
|
}); };
|
|
2956
2992
|
var handleUploadOfflineData = function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
2957
2993
|
var dataUploadedId, offlineDataResp, offlineData, offlineDataIds, updateDataRes, updateDataList, _loop_1, i, err_18, success, filteredData;
|
|
2958
|
-
var _a;
|
|
2959
|
-
return __generator(this, function (
|
|
2960
|
-
switch (
|
|
2994
|
+
var _a, _b, _c, _d, _e;
|
|
2995
|
+
return __generator(this, function (_f) {
|
|
2996
|
+
switch (_f.label) {
|
|
2961
2997
|
case 0:
|
|
2962
2998
|
setLoading(true);
|
|
2963
2999
|
dataUploadedId = [];
|
|
2964
3000
|
return [4 /*yield*/, indexedDb_1.indexedDb.getValue("local", props.collectionId)];
|
|
2965
3001
|
case 1:
|
|
2966
|
-
offlineDataResp =
|
|
3002
|
+
offlineDataResp = _f.sent();
|
|
2967
3003
|
offlineData = (_a = offlineDataResp === null || offlineDataResp === void 0 ? void 0 : offlineDataResp.data) !== null && _a !== void 0 ? _a : [];
|
|
2968
3004
|
offlineDataIds = offlineData.map(function (eachData) {
|
|
2969
3005
|
return eachData[serverId];
|
|
2970
3006
|
});
|
|
2971
|
-
|
|
3007
|
+
_f.label = 2;
|
|
2972
3008
|
case 2:
|
|
2973
|
-
|
|
3009
|
+
_f.trys.push([2, 8, , 9]);
|
|
2974
3010
|
if (!(offlineData.length > 0)) return [3 /*break*/, 7];
|
|
2975
3011
|
return [4 /*yield*/, readServerQuery.call({
|
|
2976
3012
|
type: "list",
|
|
@@ -2984,42 +3020,91 @@ exports.DataTemplate = (0, react_1.forwardRef)(function (props, ref) {
|
|
|
2984
3020
|
stopLimit: true,
|
|
2985
3021
|
})];
|
|
2986
3022
|
case 3:
|
|
2987
|
-
updateDataRes =
|
|
2988
|
-
updateDataList = updateDataRes === null || updateDataRes === void 0 ? void 0 : updateDataRes.data;
|
|
3023
|
+
updateDataRes = _f.sent();
|
|
3024
|
+
updateDataList = (_b = updateDataRes === null || updateDataRes === void 0 ? void 0 : updateDataRes.data) !== null && _b !== void 0 ? _b : [];
|
|
2989
3025
|
_loop_1 = function (i) {
|
|
2990
|
-
var eachOfflineData, offlineDataId, isUpdate, res;
|
|
2991
|
-
|
|
2992
|
-
|
|
3026
|
+
var eachOfflineData, offlineDataId, storedBaseline, serverDoc, preComplete, isUpdate, res, err_19;
|
|
3027
|
+
var _g;
|
|
3028
|
+
return __generator(this, function (_h) {
|
|
3029
|
+
switch (_h.label) {
|
|
2993
3030
|
case 0:
|
|
2994
3031
|
eachOfflineData = offlineData[i];
|
|
2995
3032
|
return [4 /*yield*/, (0, utils_1.sleep)(300)];
|
|
2996
3033
|
case 1:
|
|
2997
|
-
|
|
3034
|
+
_h.sent();
|
|
2998
3035
|
offlineDataId = eachOfflineData[serverId];
|
|
2999
|
-
|
|
3000
|
-
|
|
3036
|
+
storedBaseline = (_c = eachOfflineData.__offlineBaseline) !== null && _c !== void 0 ? _c : null;
|
|
3037
|
+
delete eachOfflineData.__offlineBaseline;
|
|
3038
|
+
serverDoc = updateDataList.find(function (eachData) { return eachData[serverId] === offlineDataId; });
|
|
3039
|
+
if (storedBaseline) {
|
|
3040
|
+
loadedSelectedData.current = storedBaseline;
|
|
3041
|
+
}
|
|
3042
|
+
else if (serverDoc) {
|
|
3043
|
+
loadedSelectedData.current = JSON.parse(JSON.stringify(serverDoc));
|
|
3044
|
+
}
|
|
3045
|
+
else {
|
|
3046
|
+
loadedSelectedData.current = null;
|
|
3047
|
+
}
|
|
3048
|
+
// INFO: For offline uploads, populate dirtyFields with all non-empty fields
|
|
3049
|
+
// from the offline data. The user explicitly saved these while offline, so they
|
|
3050
|
+
// are all "user-dirty" and should take precedence over server values.
|
|
3051
|
+
dirtyFieldsRef.current.clear();
|
|
3052
|
+
Object.keys(eachOfflineData).forEach(function (key) {
|
|
3053
|
+
if (key === "__offlineBaseline" || key === serverId)
|
|
3054
|
+
return;
|
|
3055
|
+
var val = eachOfflineData[key];
|
|
3056
|
+
var hasValue = val !== undefined &&
|
|
3057
|
+
val !== null &&
|
|
3058
|
+
val !== "" &&
|
|
3059
|
+
!(Array.isArray(val) && val.length === 0) &&
|
|
3060
|
+
val !== 0 &&
|
|
3061
|
+
val !== false;
|
|
3062
|
+
if (hasValue)
|
|
3063
|
+
dirtyFieldsRef.current.add(key);
|
|
3064
|
+
});
|
|
3065
|
+
if (!((_d = props.bareSettings) === null || _d === void 0 ? void 0 : _d.bareUpdateHandlePreComplete)) return [3 /*break*/, 3];
|
|
3066
|
+
return [4 /*yield*/, props.bareSettings.bareUpdateHandlePreComplete(eachOfflineData)];
|
|
3001
3067
|
case 2:
|
|
3002
|
-
|
|
3003
|
-
if (
|
|
3004
|
-
|
|
3005
|
-
|
|
3068
|
+
preComplete = _h.sent();
|
|
3069
|
+
if (!preComplete)
|
|
3070
|
+
return [2 /*return*/, "continue"]; // Skip this item
|
|
3071
|
+
_h.label = 3;
|
|
3072
|
+
case 3:
|
|
3073
|
+
isUpdate = !!serverDoc;
|
|
3074
|
+
return [4 /*yield*/, handleSubmitData(undefined, undefined, undefined, eachOfflineData, offlineDataId, isUpdate)];
|
|
3075
|
+
case 4:
|
|
3076
|
+
res = _h.sent();
|
|
3077
|
+
if (!res) return [3 /*break*/, 8];
|
|
3078
|
+
dataUploadedId.push(offlineDataId);
|
|
3079
|
+
if (!((_e = props.bareSettings) === null || _e === void 0 ? void 0 : _e.bareUpdateHandlePostComplete)) return [3 /*break*/, 8];
|
|
3080
|
+
_h.label = 5;
|
|
3081
|
+
case 5:
|
|
3082
|
+
_h.trys.push([5, 7, , 8]);
|
|
3083
|
+
return [4 /*yield*/, props.bareSettings.bareUpdateHandlePostComplete(__assign((_g = {}, _g[serverId] = res, _g), eachOfflineData))];
|
|
3084
|
+
case 6:
|
|
3085
|
+
_h.sent();
|
|
3086
|
+
return [3 /*break*/, 8];
|
|
3087
|
+
case 7:
|
|
3088
|
+
err_19 = _h.sent();
|
|
3089
|
+
return [3 /*break*/, 8];
|
|
3090
|
+
case 8: return [2 /*return*/];
|
|
3006
3091
|
}
|
|
3007
3092
|
});
|
|
3008
3093
|
};
|
|
3009
3094
|
i = 0;
|
|
3010
|
-
|
|
3095
|
+
_f.label = 4;
|
|
3011
3096
|
case 4:
|
|
3012
3097
|
if (!(i < offlineData.length)) return [3 /*break*/, 7];
|
|
3013
3098
|
return [5 /*yield**/, _loop_1(i)];
|
|
3014
3099
|
case 5:
|
|
3015
|
-
|
|
3016
|
-
|
|
3100
|
+
_f.sent();
|
|
3101
|
+
_f.label = 6;
|
|
3017
3102
|
case 6:
|
|
3018
3103
|
i++;
|
|
3019
3104
|
return [3 /*break*/, 4];
|
|
3020
3105
|
case 7: return [3 /*break*/, 9];
|
|
3021
3106
|
case 8:
|
|
3022
|
-
err_18 =
|
|
3107
|
+
err_18 = _f.sent();
|
|
3023
3108
|
return [3 /*break*/, 9];
|
|
3024
3109
|
case 9:
|
|
3025
3110
|
success = dataUploadedId.length === offlineData.length;
|
|
@@ -3036,7 +3121,7 @@ exports.DataTemplate = (0, react_1.forwardRef)(function (props, ref) {
|
|
|
3036
3121
|
type: props.collectionId,
|
|
3037
3122
|
})];
|
|
3038
3123
|
case 10:
|
|
3039
|
-
|
|
3124
|
+
_f.sent();
|
|
3040
3125
|
handleRefresh();
|
|
3041
3126
|
setLoading(false);
|
|
3042
3127
|
handlePopUpModal(false);
|
|
@@ -3045,7 +3130,7 @@ exports.DataTemplate = (0, react_1.forwardRef)(function (props, ref) {
|
|
|
3045
3130
|
});
|
|
3046
3131
|
}); };
|
|
3047
3132
|
var handleSubmitData = function (type, rowId, columnId, data, offlineId, isOfflineUpdate, isDraft) { return __awaiter(void 0, void 0, void 0, function () {
|
|
3048
|
-
var selectedId_2,
|
|
3133
|
+
var selectedId_2, id_1, 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;
|
|
3049
3134
|
var _a, _b;
|
|
3050
3135
|
var _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s;
|
|
3051
3136
|
return __generator(this, function (_t) {
|
|
@@ -3061,25 +3146,25 @@ exports.DataTemplate = (0, react_1.forwardRef)(function (props, ref) {
|
|
|
3061
3146
|
selectedId_2 = props.id;
|
|
3062
3147
|
else
|
|
3063
3148
|
selectedId_2 = "new";
|
|
3064
|
-
|
|
3149
|
+
id_1 = "";
|
|
3065
3150
|
if (type === "update")
|
|
3066
|
-
|
|
3151
|
+
id_1 = rowId !== null && rowId !== void 0 ? rowId : "";
|
|
3067
3152
|
else if (selectedId_2 === "new" && !showId) {
|
|
3068
3153
|
if (idField && selectedData[idField])
|
|
3069
|
-
|
|
3154
|
+
id_1 = selectedData[idField];
|
|
3070
3155
|
else
|
|
3071
|
-
|
|
3156
|
+
id_1 = (0, uuid_1.v4)();
|
|
3072
3157
|
}
|
|
3073
3158
|
else
|
|
3074
|
-
|
|
3159
|
+
id_1 = (_c = props.id) !== null && _c !== void 0 ? _c : "";
|
|
3075
3160
|
if (offlineId) {
|
|
3076
3161
|
selectedId_2 = offlineId;
|
|
3077
|
-
|
|
3162
|
+
id_1 = offlineId;
|
|
3078
3163
|
}
|
|
3079
3164
|
if (!(isOffline && !offlineId)) return [3 /*break*/, 1];
|
|
3080
3165
|
createSelectedData_1 = selectedData;
|
|
3081
3166
|
return [3 /*break*/, 3];
|
|
3082
|
-
case 1: return [4 /*yield*/, handleUploadImage(
|
|
3167
|
+
case 1: return [4 /*yield*/, handleUploadImage(id_1, data)];
|
|
3083
3168
|
case 2:
|
|
3084
3169
|
createSelectedData_1 = _t.sent();
|
|
3085
3170
|
_t.label = 3;
|
|
@@ -3098,7 +3183,7 @@ exports.DataTemplate = (0, react_1.forwardRef)(function (props, ref) {
|
|
|
3098
3183
|
res = "";
|
|
3099
3184
|
if (!(selectedId_2 === "new")) return [3 /*break*/, 16];
|
|
3100
3185
|
if (!showId)
|
|
3101
|
-
createSelectedData_1[serverId] =
|
|
3186
|
+
createSelectedData_1[serverId] = id_1;
|
|
3102
3187
|
if (isDraft)
|
|
3103
3188
|
createSelectedData_1["baseDraft"] = true;
|
|
3104
3189
|
if (!isOffline) return [3 /*break*/, 9];
|
|
@@ -3109,8 +3194,39 @@ exports.DataTemplate = (0, react_1.forwardRef)(function (props, ref) {
|
|
|
3109
3194
|
case 5:
|
|
3110
3195
|
offlineDataResp = _t.sent();
|
|
3111
3196
|
offlineData = (_e = offlineDataResp === null || offlineDataResp === void 0 ? void 0 : offlineDataResp.data) !== null && _e !== void 0 ? _e : [];
|
|
3112
|
-
|
|
3113
|
-
|
|
3197
|
+
clonedForOffline = (0, updateModule_1.handleClonedDataAttribute)(selectedData, structure, props.devSettings.server, true, showId);
|
|
3198
|
+
tempData = (0, updateModule_1.handleParseOfflineWrite)(clonedForOffline, structure);
|
|
3199
|
+
// INFO: Stamp the _id on the offline entry so subsequent saves can find and update it
|
|
3200
|
+
if (!tempData[serverId])
|
|
3201
|
+
tempData[serverId] = id_1;
|
|
3202
|
+
// INFO: Remove non-serializable keys that IDB's structured clone can't handle
|
|
3203
|
+
delete tempData["update"];
|
|
3204
|
+
// INFO: Store original baseline on first offline save so the upload
|
|
3205
|
+
// diff can identify which fields the user actually changed.
|
|
3206
|
+
if (!tempData.__offlineBaseline) {
|
|
3207
|
+
tempData.__offlineBaseline = loadedSelectedData.current
|
|
3208
|
+
? JSON.parse(JSON.stringify(loadedSelectedData.current))
|
|
3209
|
+
: null;
|
|
3210
|
+
}
|
|
3211
|
+
selectedIndex_3 = -1;
|
|
3212
|
+
offlineData.map(function (eachOfflineData, index) {
|
|
3213
|
+
var offlineDataId = eachOfflineData[serverId];
|
|
3214
|
+
if (id_1 === offlineDataId)
|
|
3215
|
+
selectedIndex_3 = index;
|
|
3216
|
+
return null;
|
|
3217
|
+
});
|
|
3218
|
+
if (selectedIndex_3 >= 0) {
|
|
3219
|
+
// INFO: Update existing entry, carry forward baseline
|
|
3220
|
+
if (!tempData.__offlineBaseline &&
|
|
3221
|
+
offlineData[selectedIndex_3].__offlineBaseline) {
|
|
3222
|
+
tempData.__offlineBaseline =
|
|
3223
|
+
offlineData[selectedIndex_3].__offlineBaseline;
|
|
3224
|
+
}
|
|
3225
|
+
offlineData[selectedIndex_3] = tempData;
|
|
3226
|
+
}
|
|
3227
|
+
else {
|
|
3228
|
+
offlineData.push(tempData);
|
|
3229
|
+
}
|
|
3114
3230
|
return [4 /*yield*/, indexedDb_1.indexedDb.putValue("local", {
|
|
3115
3231
|
data: offlineData,
|
|
3116
3232
|
type: props.collectionId,
|
|
@@ -3120,7 +3236,7 @@ exports.DataTemplate = (0, react_1.forwardRef)(function (props, ref) {
|
|
|
3120
3236
|
res = true;
|
|
3121
3237
|
return [3 /*break*/, 8];
|
|
3122
3238
|
case 7:
|
|
3123
|
-
|
|
3239
|
+
err_20 = _t.sent();
|
|
3124
3240
|
return [3 /*break*/, 8];
|
|
3125
3241
|
case 8: return [3 /*break*/, 15];
|
|
3126
3242
|
case 9:
|
|
@@ -3135,10 +3251,36 @@ exports.DataTemplate = (0, react_1.forwardRef)(function (props, ref) {
|
|
|
3135
3251
|
baseDraftValue;
|
|
3136
3252
|
// INFO: if nothing changed (including baseDraft), skip the write
|
|
3137
3253
|
if (changedAttributeIds.length === 0 && !hasBaseDraftChange)
|
|
3138
|
-
return [2 /*return*/,
|
|
3254
|
+
return [2 /*return*/, id_1];
|
|
3139
3255
|
newRecordData_1 = {};
|
|
3140
3256
|
changedAttributeIds.forEach(function (key) {
|
|
3141
|
-
|
|
3257
|
+
var _a;
|
|
3258
|
+
var newValue = createSelectedData_1[key];
|
|
3259
|
+
var baselineValue = (_a = loadedSelectedData.current) === null || _a === void 0 ? void 0 : _a[key];
|
|
3260
|
+
// INFO: Dirty tracking is the PRIMARY condition.
|
|
3261
|
+
var isUserDirty = dirtyFieldsRef.current.has(key);
|
|
3262
|
+
if (isUserDirty) {
|
|
3263
|
+
// INFO: User explicitly edited this field — always include
|
|
3264
|
+
newRecordData_1[key] = newValue;
|
|
3265
|
+
return;
|
|
3266
|
+
}
|
|
3267
|
+
// INFO: SECONDARY condition (non-empty-wins) — field changed but user didn't touch it
|
|
3268
|
+
var valueIsEmpty = newValue === undefined ||
|
|
3269
|
+
newValue === null ||
|
|
3270
|
+
newValue === "" ||
|
|
3271
|
+
(Array.isArray(newValue) && newValue.length === 0) ||
|
|
3272
|
+
newValue === 0 ||
|
|
3273
|
+
newValue === false;
|
|
3274
|
+
var baselineHasValue = baselineValue !== undefined &&
|
|
3275
|
+
baselineValue !== null &&
|
|
3276
|
+
baselineValue !== "" &&
|
|
3277
|
+
!(Array.isArray(baselineValue) && baselineValue.length === 0) &&
|
|
3278
|
+
baselineValue !== 0 &&
|
|
3279
|
+
baselineValue !== false;
|
|
3280
|
+
if (valueIsEmpty && baselineHasValue) {
|
|
3281
|
+
return;
|
|
3282
|
+
}
|
|
3283
|
+
newRecordData_1[key] = newValue;
|
|
3142
3284
|
});
|
|
3143
3285
|
// INFO: always stamp baseDraft — it is not user-edited so it may
|
|
3144
3286
|
// not appear in changedAttributeIds, but clearing true→false on
|
|
@@ -3151,7 +3293,7 @@ exports.DataTemplate = (0, react_1.forwardRef)(function (props, ref) {
|
|
|
3151
3293
|
newRecordData_1 = createSelectedData_1;
|
|
3152
3294
|
}
|
|
3153
3295
|
return [4 /*yield*/, writeServerQuery.call("update", {
|
|
3154
|
-
id:
|
|
3296
|
+
id: id_1,
|
|
3155
3297
|
data: newRecordData_1,
|
|
3156
3298
|
upsert: true,
|
|
3157
3299
|
})];
|
|
@@ -3168,7 +3310,7 @@ exports.DataTemplate = (0, react_1.forwardRef)(function (props, ref) {
|
|
|
3168
3310
|
}
|
|
3169
3311
|
if (selectedId_2 === "new") {
|
|
3170
3312
|
isCreatingRef.current = true;
|
|
3171
|
-
inflightIdRef.current =
|
|
3313
|
+
inflightIdRef.current = id_1; // INFO: id is the UUID already generated above
|
|
3172
3314
|
}
|
|
3173
3315
|
return [4 /*yield*/, writeServerQuery.call("create", {
|
|
3174
3316
|
data: createSelectedData_1,
|
|
@@ -3203,18 +3345,38 @@ exports.DataTemplate = (0, react_1.forwardRef)(function (props, ref) {
|
|
|
3203
3345
|
return [4 /*yield*/, indexedDb_1.indexedDb.getValue("local", props.collectionId)];
|
|
3204
3346
|
case 18:
|
|
3205
3347
|
offlineDataResp = _t.sent();
|
|
3206
|
-
|
|
3348
|
+
clonedForOffline = (0, updateModule_1.handleClonedDataAttribute)(selectedData, structure, props.devSettings.server, true, showId);
|
|
3349
|
+
tempData = (0, updateModule_1.handleParseOfflineWrite)(clonedForOffline, structure);
|
|
3207
3350
|
tempData[serverId] = selectedId_2;
|
|
3208
|
-
|
|
3351
|
+
// INFO: Remove non-serializable keys that IDB's structured clone can't handle
|
|
3352
|
+
// (e.g. 'update' which is a React element injected by bareUpdateActionComponent)
|
|
3353
|
+
delete tempData["update"];
|
|
3354
|
+
selectedIndex_4 = -1;
|
|
3209
3355
|
offlineData = (_k = offlineDataResp === null || offlineDataResp === void 0 ? void 0 : offlineDataResp.data) !== null && _k !== void 0 ? _k : [];
|
|
3210
3356
|
offlineData.map(function (eachOfflineData, index) {
|
|
3211
3357
|
var offlineDataId = eachOfflineData[serverId];
|
|
3212
3358
|
if (selectedId_2 === offlineDataId)
|
|
3213
|
-
|
|
3359
|
+
selectedIndex_4 = index;
|
|
3214
3360
|
return null;
|
|
3215
3361
|
});
|
|
3216
|
-
if (
|
|
3217
|
-
|
|
3362
|
+
if (selectedIndex_4 >= 0) {
|
|
3363
|
+
// INFO: Carry forward the original baseline from the existing entry
|
|
3364
|
+
if (!tempData.__offlineBaseline &&
|
|
3365
|
+
offlineData[selectedIndex_4].__offlineBaseline) {
|
|
3366
|
+
tempData.__offlineBaseline =
|
|
3367
|
+
offlineData[selectedIndex_4].__offlineBaseline;
|
|
3368
|
+
}
|
|
3369
|
+
offlineData[selectedIndex_4] = tempData;
|
|
3370
|
+
}
|
|
3371
|
+
else {
|
|
3372
|
+
// INFO: First save for this ID — stamp baseline
|
|
3373
|
+
if (!tempData.__offlineBaseline) {
|
|
3374
|
+
tempData.__offlineBaseline = loadedSelectedData.current
|
|
3375
|
+
? JSON.parse(JSON.stringify(loadedSelectedData.current))
|
|
3376
|
+
: null;
|
|
3377
|
+
}
|
|
3378
|
+
offlineData.push(tempData);
|
|
3379
|
+
}
|
|
3218
3380
|
return [4 /*yield*/, indexedDb_1.indexedDb.putValue("local", {
|
|
3219
3381
|
data: offlineData,
|
|
3220
3382
|
type: props.collectionId,
|
|
@@ -3224,7 +3386,7 @@ exports.DataTemplate = (0, react_1.forwardRef)(function (props, ref) {
|
|
|
3224
3386
|
res = true;
|
|
3225
3387
|
return [3 /*break*/, 21];
|
|
3226
3388
|
case 20:
|
|
3227
|
-
|
|
3389
|
+
err_21 = _t.sent();
|
|
3228
3390
|
return [3 /*break*/, 21];
|
|
3229
3391
|
case 21: return [3 /*break*/, 24];
|
|
3230
3392
|
case 22:
|
|
@@ -3240,10 +3402,46 @@ exports.DataTemplate = (0, react_1.forwardRef)(function (props, ref) {
|
|
|
3240
3402
|
baseDraftValue;
|
|
3241
3403
|
// INFO: if nothing changed (including baseDraft), skip the write entirely
|
|
3242
3404
|
if (changedAttributeIds.length === 0 && !hasBaseDraftChange)
|
|
3243
|
-
return [2 /*return*/,
|
|
3405
|
+
return [2 /*return*/, id_1];
|
|
3244
3406
|
dataToSubmit_2 = {};
|
|
3245
3407
|
changedAttributeIds.forEach(function (key) {
|
|
3246
|
-
|
|
3408
|
+
var _a;
|
|
3409
|
+
var newValue = createSelectedData_1[key];
|
|
3410
|
+
var baselineValue = (_a = loadedSelectedData.current) === null || _a === void 0 ? void 0 : _a[key];
|
|
3411
|
+
// INFO: Dirty tracking is the PRIMARY condition.
|
|
3412
|
+
// If the user explicitly interacted with this field (dirtyFields), always include it
|
|
3413
|
+
// — even if the value is empty (user intentionally cleared it).
|
|
3414
|
+
var isUserDirty = dirtyFieldsRef.current.has(key);
|
|
3415
|
+
if (isUserDirty) {
|
|
3416
|
+
// INFO: User explicitly edited this field — always send it (supports intentional clears)
|
|
3417
|
+
dataToSubmit_2[key] = newValue;
|
|
3418
|
+
return;
|
|
3419
|
+
}
|
|
3420
|
+
// INFO: SECONDARY condition (non-empty-wins) — field changed in the diff but the user
|
|
3421
|
+
// did NOT interact with it. This happens when:
|
|
3422
|
+
// (a) Socket merge updated the baseline and the form value differs from new baseline
|
|
3423
|
+
// (b) Programmatic prefill set a value
|
|
3424
|
+
// Guard: if the form value is empty but the baseline has a real value, skip it
|
|
3425
|
+
// to prevent stale empty form fields from clearing another user's data.
|
|
3426
|
+
var valueIsEmpty = newValue === undefined ||
|
|
3427
|
+
newValue === null ||
|
|
3428
|
+
newValue === "" ||
|
|
3429
|
+
(Array.isArray(newValue) && newValue.length === 0) ||
|
|
3430
|
+
newValue === 0 ||
|
|
3431
|
+
newValue === false;
|
|
3432
|
+
var baselineHasValue = baselineValue !== undefined &&
|
|
3433
|
+
baselineValue !== null &&
|
|
3434
|
+
baselineValue !== "" &&
|
|
3435
|
+
!(Array.isArray(baselineValue) && baselineValue.length === 0) &&
|
|
3436
|
+
baselineValue !== 0 &&
|
|
3437
|
+
baselineValue !== false;
|
|
3438
|
+
if (valueIsEmpty && baselineHasValue) {
|
|
3439
|
+
// INFO: Non-empty-wins — skip to prevent clearing server data
|
|
3440
|
+
return;
|
|
3441
|
+
}
|
|
3442
|
+
// INFO: Field changed, user didn't explicitly touch it, but it's not an empty→value conflict
|
|
3443
|
+
// (e.g. programmatic update set a non-empty value). Include it.
|
|
3444
|
+
dataToSubmit_2[key] = newValue;
|
|
3247
3445
|
});
|
|
3248
3446
|
dataToSubmit_2["baseDraft"] = baseDraftValue;
|
|
3249
3447
|
if (offlineId)
|
|
@@ -3267,11 +3465,9 @@ exports.DataTemplate = (0, react_1.forwardRef)(function (props, ref) {
|
|
|
3267
3465
|
unique: uniqueColumnId,
|
|
3268
3466
|
// INFO: bareUpsertPartialUpdate — upsert so the doc is created if it
|
|
3269
3467
|
// doesn't exist yet (covers deterministicId passed directly as props.id).
|
|
3270
|
-
//
|
|
3271
|
-
//
|
|
3272
|
-
upsert: ((_q = props.bareSettings) === null || _q === void 0 ? void 0 : _q.bareUpsertPartialUpdate) &&
|
|
3273
|
-
!offlineId &&
|
|
3274
|
-
!isOfflineUpdate
|
|
3468
|
+
// Also applies to offline upload path so the doc is created if it was
|
|
3469
|
+
// deleted between the existence check and the write call.
|
|
3470
|
+
upsert: ((_q = props.bareSettings) === null || _q === void 0 ? void 0 : _q.bareUpsertPartialUpdate) && !isOfflineUpdate
|
|
3275
3471
|
? true
|
|
3276
3472
|
: undefined,
|
|
3277
3473
|
})];
|
|
@@ -3283,15 +3479,15 @@ exports.DataTemplate = (0, react_1.forwardRef)(function (props, ref) {
|
|
|
3283
3479
|
if (!res) return [3 /*break*/, 31];
|
|
3284
3480
|
if (!(type === "update")) return [3 /*break*/, 27];
|
|
3285
3481
|
if (!columnId) return [3 /*break*/, 26];
|
|
3286
|
-
|
|
3482
|
+
selectedIndex_5 = -1;
|
|
3287
3483
|
tableData.map(function (eachData, index) {
|
|
3288
3484
|
if (eachData.id === rowId || eachData._id === rowId) {
|
|
3289
3485
|
eachData[columnId] = createSelectedData_1[columnId];
|
|
3290
|
-
|
|
3486
|
+
selectedIndex_5 = index;
|
|
3291
3487
|
}
|
|
3292
3488
|
return null;
|
|
3293
3489
|
});
|
|
3294
|
-
return [4 /*yield*/, handleGetListData({ data: tableData[
|
|
3490
|
+
return [4 /*yield*/, handleGetListData({ data: tableData[selectedIndex_5] }, "update", rowId)];
|
|
3295
3491
|
case 25:
|
|
3296
3492
|
_t.sent();
|
|
3297
3493
|
_t.label = 26;
|
|
@@ -3302,14 +3498,14 @@ exports.DataTemplate = (0, react_1.forwardRef)(function (props, ref) {
|
|
|
3302
3498
|
_t.label = 29;
|
|
3303
3499
|
case 29:
|
|
3304
3500
|
if (!((_r = props.bareSettings) === null || _r === void 0 ? void 0 : _r.bareUpdateHandlePostComplete)) return [3 /*break*/, 31];
|
|
3305
|
-
return [4 /*yield*/, props.bareSettings.bareUpdateHandlePostComplete(__assign((_b = {}, _b[serverId] =
|
|
3501
|
+
return [4 /*yield*/, props.bareSettings.bareUpdateHandlePostComplete(__assign((_b = {}, _b[serverId] = id_1, _b), createSelectedData_1))];
|
|
3306
3502
|
case 30:
|
|
3307
3503
|
_t.sent();
|
|
3308
3504
|
_t.label = 31;
|
|
3309
3505
|
case 31: return [3 /*break*/, 34];
|
|
3310
3506
|
case 32:
|
|
3311
|
-
createSelectedData_1[serverId] =
|
|
3312
|
-
return [4 /*yield*/, handleGetListData({ data: [createSelectedData_1] }, selectedId_2 === "new" ? "create" : "update",
|
|
3507
|
+
createSelectedData_1[serverId] = id_1;
|
|
3508
|
+
return [4 /*yield*/, handleGetListData({ data: [createSelectedData_1] }, selectedId_2 === "new" ? "create" : "update", id_1)];
|
|
3313
3509
|
case 33:
|
|
3314
3510
|
_t.sent();
|
|
3315
3511
|
setNotification({
|
|
@@ -3323,23 +3519,23 @@ exports.DataTemplate = (0, react_1.forwardRef)(function (props, ref) {
|
|
|
3323
3519
|
});
|
|
3324
3520
|
_t.label = 34;
|
|
3325
3521
|
case 34:
|
|
3326
|
-
dataId = res ?
|
|
3522
|
+
dataId = res ? id_1 : "";
|
|
3327
3523
|
return [2 /*return*/, dataId];
|
|
3328
3524
|
case 35:
|
|
3329
|
-
|
|
3330
|
-
console.log("error",
|
|
3525
|
+
err_22 = _t.sent();
|
|
3526
|
+
console.log("error", err_22);
|
|
3331
3527
|
// INFO: clear in-flight guard on failure so the next save retries as a create
|
|
3332
3528
|
if (isCreatingRef.current) {
|
|
3333
3529
|
isCreatingRef.current = false;
|
|
3334
3530
|
pendingDraftSaveRef.current = false;
|
|
3335
3531
|
inflightIdRef.current = "";
|
|
3336
3532
|
}
|
|
3337
|
-
if (
|
|
3338
|
-
if (typeof ((_s =
|
|
3533
|
+
if (err_22.response && err_22.response.status === 400) {
|
|
3534
|
+
if (typeof ((_s = err_22.response.data) === null || _s === void 0 ? void 0 : _s.err) === "string")
|
|
3339
3535
|
setNotification({
|
|
3340
3536
|
type: false,
|
|
3341
3537
|
title: "Error",
|
|
3342
|
-
msg:
|
|
3538
|
+
msg: err_22.response.data.err,
|
|
3343
3539
|
});
|
|
3344
3540
|
else
|
|
3345
3541
|
setNotification({
|
|
@@ -3392,11 +3588,11 @@ exports.DataTemplate = (0, react_1.forwardRef)(function (props, ref) {
|
|
|
3392
3588
|
});
|
|
3393
3589
|
}); };
|
|
3394
3590
|
var handleSubmit = function (isDraft) { return __awaiter(void 0, void 0, void 0, function () {
|
|
3395
|
-
var preComplete, res, updatedMarkdownData_1, uploadedData_2, uploadTypes_1,
|
|
3591
|
+
var preComplete, res, updatedMarkdownData_1, uploadedData_2, uploadTypes_1, err_23;
|
|
3396
3592
|
var _a;
|
|
3397
|
-
var _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
|
|
3398
|
-
return __generator(this, function (
|
|
3399
|
-
switch (
|
|
3593
|
+
var _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
|
|
3594
|
+
return __generator(this, function (_p) {
|
|
3595
|
+
switch (_p.label) {
|
|
3400
3596
|
case 0:
|
|
3401
3597
|
// INFO: re-entry guard — if a submit is already in-flight (double-click,
|
|
3402
3598
|
// rapid Enter keypresses, or concurrent bareSaveOnTabChange calls), return
|
|
@@ -3405,9 +3601,9 @@ exports.DataTemplate = (0, react_1.forwardRef)(function (props, ref) {
|
|
|
3405
3601
|
if (isSubmittingRef.current)
|
|
3406
3602
|
return [2 /*return*/];
|
|
3407
3603
|
isSubmittingRef.current = true;
|
|
3408
|
-
|
|
3604
|
+
_p.label = 1;
|
|
3409
3605
|
case 1:
|
|
3410
|
-
|
|
3606
|
+
_p.trys.push([1, 10, , 11]);
|
|
3411
3607
|
setLoading(true);
|
|
3412
3608
|
setModalVisible(true);
|
|
3413
3609
|
preComplete = true;
|
|
@@ -3415,25 +3611,25 @@ exports.DataTemplate = (0, react_1.forwardRef)(function (props, ref) {
|
|
|
3415
3611
|
return [4 /*yield*/, props.bareSettings.bareUpdateHandlePreComplete(selectedData)];
|
|
3416
3612
|
case 2:
|
|
3417
3613
|
preComplete =
|
|
3418
|
-
|
|
3419
|
-
|
|
3614
|
+
_p.sent();
|
|
3615
|
+
_p.label = 3;
|
|
3420
3616
|
case 3:
|
|
3421
3617
|
if (!preComplete)
|
|
3422
3618
|
throw "Error";
|
|
3423
3619
|
if (!((_c = props.bareSettings) === null || _c === void 0 ? void 0 : _c.bareUpdateHandleComplete)) return [3 /*break*/, 5];
|
|
3424
3620
|
return [4 /*yield*/, props.bareSettings.bareUpdateHandleComplete(selectedData)];
|
|
3425
3621
|
case 4:
|
|
3426
|
-
|
|
3622
|
+
_p.sent();
|
|
3427
3623
|
return [3 /*break*/, 9];
|
|
3428
3624
|
case 5: return [4 /*yield*/, handleSubmitData(undefined, undefined, undefined, undefined, undefined, undefined, isDraft)];
|
|
3429
3625
|
case 6:
|
|
3430
|
-
res =
|
|
3626
|
+
res = _p.sent();
|
|
3431
3627
|
if (!res) return [3 /*break*/, 9];
|
|
3432
|
-
if (!((_d = props.bareSettings) === null || _d === void 0 ? void 0 : _d.bareUpdateHandlePostComplete)) return [3 /*break*/, 8];
|
|
3628
|
+
if (!(((_d = props.bareSettings) === null || _d === void 0 ? void 0 : _d.bareUpdateHandlePostComplete) && !isOffline)) return [3 /*break*/, 8];
|
|
3433
3629
|
return [4 /*yield*/, props.bareSettings.bareUpdateHandlePostComplete(__assign((_a = {}, _a[serverId] = res, _a), selectedData))];
|
|
3434
3630
|
case 7:
|
|
3435
|
-
|
|
3436
|
-
|
|
3631
|
+
_p.sent();
|
|
3632
|
+
_p.label = 8;
|
|
3437
3633
|
case 8:
|
|
3438
3634
|
handleCheckOfflineDataLength();
|
|
3439
3635
|
if (isDraft) {
|
|
@@ -3443,7 +3639,10 @@ exports.DataTemplate = (0, react_1.forwardRef)(function (props, ref) {
|
|
|
3443
3639
|
// re-sent on every subsequent save (harmless but wasteful), and the
|
|
3444
3640
|
// "skip write if nothing changed" short-circuit would never trigger.
|
|
3445
3641
|
if ((_e = props.bareSettings) === null || _e === void 0 ? void 0 : _e.bareUpsertPartialUpdate) {
|
|
3446
|
-
loadedSelectedData.current =
|
|
3642
|
+
loadedSelectedData.current = (0, updateModule_1.handleClonedDataAttribute)(selectedData, structure, props.devSettings.server, true, showId);
|
|
3643
|
+
// INFO: Reset dirty tracking after successful save — the new baseline
|
|
3644
|
+
// is the saved state, so all fields start "clean" again.
|
|
3645
|
+
dirtyFieldsRef.current.clear();
|
|
3447
3646
|
}
|
|
3448
3647
|
updatedMarkdownData_1 = {};
|
|
3449
3648
|
structure.forEach(function (eachAttribute) {
|
|
@@ -3480,6 +3679,8 @@ exports.DataTemplate = (0, react_1.forwardRef)(function (props, ref) {
|
|
|
3480
3679
|
});
|
|
3481
3680
|
}
|
|
3482
3681
|
if (Object.keys(updatedMarkdownData_1).length > 0) {
|
|
3682
|
+
// INFO: Post-save markdown/upload data sync is programmatic, not user-driven
|
|
3683
|
+
programmaticUpdateRef.current = true;
|
|
3483
3684
|
setSelectedData(function (prev) { return (__assign(__assign({}, prev), updatedMarkdownData_1)); });
|
|
3484
3685
|
}
|
|
3485
3686
|
if (props.id === "new" || !props.id) {
|
|
@@ -3492,25 +3693,32 @@ exports.DataTemplate = (0, react_1.forwardRef)(function (props, ref) {
|
|
|
3492
3693
|
});
|
|
3493
3694
|
}
|
|
3494
3695
|
else {
|
|
3696
|
+
// INFO: Non-draft (final submit) — reset dirty tracking and rebase baseline.
|
|
3697
|
+
// Usually the component navigates away, but in case it doesn't (e.g. custom onComplete
|
|
3698
|
+
// that stays on the same page), ensure clean state for subsequent interactions.
|
|
3699
|
+
if ((_j = props.bareSettings) === null || _j === void 0 ? void 0 : _j.bareUpsertPartialUpdate) {
|
|
3700
|
+
loadedSelectedData.current = (0, updateModule_1.handleClonedDataAttribute)(selectedData, structure, props.devSettings.server, true, showId);
|
|
3701
|
+
dirtyFieldsRef.current.clear();
|
|
3702
|
+
}
|
|
3495
3703
|
if (props.onComplete) {
|
|
3496
3704
|
props.onComplete(res);
|
|
3497
3705
|
}
|
|
3498
3706
|
else {
|
|
3499
3707
|
if (selectedTab) {
|
|
3500
|
-
(
|
|
3708
|
+
(_l = (_k = props.organise) === null || _k === void 0 ? void 0 : _k.handleNavigate) === null || _l === void 0 ? void 0 : _l.call(_k, "read", res, selectedTab.id);
|
|
3501
3709
|
}
|
|
3502
3710
|
else
|
|
3503
|
-
(
|
|
3711
|
+
(_o = (_m = props.organise) === null || _m === void 0 ? void 0 : _m.handleNavigate) === null || _o === void 0 ? void 0 : _o.call(_m, "read", res, "general");
|
|
3504
3712
|
}
|
|
3505
3713
|
}
|
|
3506
|
-
|
|
3714
|
+
_p.label = 9;
|
|
3507
3715
|
case 9:
|
|
3508
3716
|
setModalVisible(false);
|
|
3509
3717
|
setLoading(false);
|
|
3510
3718
|
isSubmittingRef.current = false;
|
|
3511
3719
|
return [3 /*break*/, 11];
|
|
3512
3720
|
case 10:
|
|
3513
|
-
|
|
3721
|
+
err_23 = _p.sent();
|
|
3514
3722
|
setModalVisible(false);
|
|
3515
3723
|
setLoading(false);
|
|
3516
3724
|
isSubmittingRef.current = false;
|
|
@@ -3540,6 +3748,8 @@ exports.DataTemplate = (0, react_1.forwardRef)(function (props, ref) {
|
|
|
3540
3748
|
case 0:
|
|
3541
3749
|
if (!responseData.data) return [3 /*break*/, 6];
|
|
3542
3750
|
if (!((_b = props.bareSettings) === null || _b === void 0 ? void 0 : _b.bareOffline)) return [3 /*break*/, 2];
|
|
3751
|
+
// INFO: Mark as programmatic so initial data load doesn't populate dirtyFields
|
|
3752
|
+
programmaticUpdateRef.current = true;
|
|
3543
3753
|
setSelectedData(responseData.data);
|
|
3544
3754
|
// INFO: stamp the load baseline so bareUpsertPartialUpdate can diff
|
|
3545
3755
|
// against the original doc rather than the post-edit state.
|
|
@@ -3613,6 +3823,8 @@ exports.DataTemplate = (0, react_1.forwardRef)(function (props, ref) {
|
|
|
3613
3823
|
_h.label = 5;
|
|
3614
3824
|
case 5:
|
|
3615
3825
|
newRespData = _a;
|
|
3826
|
+
// INFO: Mark as programmatic so initial data load doesn't populate dirtyFields
|
|
3827
|
+
programmaticUpdateRef.current = true;
|
|
3616
3828
|
setSelectedData(newRespData);
|
|
3617
3829
|
// INFO: stamp the load baseline so bareUpsertPartialUpdate can diff
|
|
3618
3830
|
// against the original doc rather than the post-edit state.
|
|
@@ -3837,7 +4049,7 @@ exports.DataTemplate = (0, react_1.forwardRef)(function (props, ref) {
|
|
|
3837
4049
|
handleUpdateChangeData(clonedData);
|
|
3838
4050
|
};
|
|
3839
4051
|
var handleOnChangeSelect = function (id, value) { return __awaiter(void 0, void 0, void 0, function () {
|
|
3840
|
-
var _a, data, model, clonedData, refetchReference, currentSchema, allowedWatchedColumnTypes_1, watchedColumns, _i, watchedColumns_1, eachWatched, dependency, referenceRQ, valueRes,
|
|
4052
|
+
var _a, data, model, clonedData, refetchReference, currentSchema, allowedWatchedColumnTypes_1, watchedColumns, _i, watchedColumns_1, eachWatched, dependency, referenceRQ, valueRes, err_24;
|
|
3841
4053
|
return __generator(this, function (_b) {
|
|
3842
4054
|
switch (_b.label) {
|
|
3843
4055
|
case 0:
|
|
@@ -3900,7 +4112,7 @@ exports.DataTemplate = (0, react_1.forwardRef)(function (props, ref) {
|
|
|
3900
4112
|
return [3 /*break*/, 3];
|
|
3901
4113
|
case 6: return [3 /*break*/, 8];
|
|
3902
4114
|
case 7:
|
|
3903
|
-
|
|
4115
|
+
err_24 = _b.sent();
|
|
3904
4116
|
return [3 /*break*/, 8];
|
|
3905
4117
|
case 8:
|
|
3906
4118
|
clonedData[id] = value;
|
|
@@ -3978,7 +4190,7 @@ exports.DataTemplate = (0, react_1.forwardRef)(function (props, ref) {
|
|
|
3978
4190
|
}
|
|
3979
4191
|
};
|
|
3980
4192
|
var handleStepCSV = function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
3981
|
-
var csvList_1, _loop_2, _i, _a, _b, eachKey, eachValue, valid_1, errorValue_1, excelFormData, updateFields, response, open_1,
|
|
4193
|
+
var csvList_1, _loop_2, _i, _a, _b, eachKey, eachValue, valid_1, errorValue_1, excelFormData, updateFields, response, open_1, err_25;
|
|
3982
4194
|
var _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
|
|
3983
4195
|
return __generator(this, function (_p) {
|
|
3984
4196
|
switch (_p.label) {
|
|
@@ -4126,12 +4338,12 @@ exports.DataTemplate = (0, react_1.forwardRef)(function (props, ref) {
|
|
|
4126
4338
|
_p.label = 5;
|
|
4127
4339
|
case 5: return [3 /*break*/, 7];
|
|
4128
4340
|
case 6:
|
|
4129
|
-
|
|
4341
|
+
err_25 = _p.sent();
|
|
4130
4342
|
setLoading(false);
|
|
4131
4343
|
setNotification({
|
|
4132
4344
|
type: false,
|
|
4133
4345
|
title: "Import Error",
|
|
4134
|
-
msg:
|
|
4346
|
+
msg: err_25.message,
|
|
4135
4347
|
});
|
|
4136
4348
|
return [3 /*break*/, 7];
|
|
4137
4349
|
case 7: return [2 /*return*/];
|
|
@@ -4139,7 +4351,7 @@ exports.DataTemplate = (0, react_1.forwardRef)(function (props, ref) {
|
|
|
4139
4351
|
});
|
|
4140
4352
|
}); };
|
|
4141
4353
|
var handleExportCSVData = function (downloadLinkOnly, printOnly) { return __awaiter(void 0, void 0, void 0, function () {
|
|
4142
|
-
var exportQueryList, baseUrl, apiEndpoint, reqData, res, dataList, csvDownloadLink, notificaitonMsg,
|
|
4354
|
+
var exportQueryList, baseUrl, apiEndpoint, reqData, res, dataList, csvDownloadLink, notificaitonMsg, err_26;
|
|
4143
4355
|
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;
|
|
4144
4356
|
return __generator(this, function (_1) {
|
|
4145
4357
|
switch (_1.label) {
|
|
@@ -4213,7 +4425,7 @@ exports.DataTemplate = (0, react_1.forwardRef)(function (props, ref) {
|
|
|
4213
4425
|
setExportCSVEmail((_0 = (_z = props.devSettings.currentUser) === null || _z === void 0 ? void 0 : _z.userEmail) !== null && _0 !== void 0 ? _0 : "");
|
|
4214
4426
|
return [3 /*break*/, 6];
|
|
4215
4427
|
case 5:
|
|
4216
|
-
|
|
4428
|
+
err_26 = _1.sent();
|
|
4217
4429
|
setNotification({
|
|
4218
4430
|
type: true,
|
|
4219
4431
|
title: "Export Failed",
|
|
@@ -4269,7 +4481,7 @@ exports.DataTemplate = (0, react_1.forwardRef)(function (props, ref) {
|
|
|
4269
4481
|
});
|
|
4270
4482
|
}); };
|
|
4271
4483
|
var handleExportReadPDF = function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
4272
|
-
var elementToExport, dimensionsConfig, headerConfig_1, isMobile, scale, html2canvasOptions, originalStyles, captureWidth, captureHeight, canvas, pageWidth, pageHeight, orientation_1, pdf, pixelsToMm, elementWidthMm, elementHeightMm, pageSize, margin, headerHeight, imageDataURL, imageWidth_1, imageHeight_1, hasImage, hasText, img_1,
|
|
4484
|
+
var elementToExport, dimensionsConfig, headerConfig_1, isMobile, scale, html2canvasOptions, originalStyles, captureWidth, captureHeight, canvas, pageWidth, pageHeight, orientation_1, pdf, pixelsToMm, elementWidthMm, elementHeightMm, pageSize, margin, headerHeight, imageDataURL, imageWidth_1, imageHeight_1, hasImage, hasText, img_1, err_27, textHeight, usableWidth, imgHeight, usableHeight, currentY, imgX, imgY, imgW, imgH, finalX, textY, textX, heightLeft, page, currentY, imgX, imgY, imgW, imgH, finalX, textY, textX, sourceY, sourceHeight, pageCanvas, ctx, pageData, pdfBlob, err_28;
|
|
4273
4485
|
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;
|
|
4274
4486
|
return __generator(this, function (_4) {
|
|
4275
4487
|
switch (_4.label) {
|
|
@@ -4440,8 +4652,8 @@ exports.DataTemplate = (0, react_1.forwardRef)(function (props, ref) {
|
|
|
4440
4652
|
headerHeight = imageHeight_1 + 2;
|
|
4441
4653
|
return [3 /*break*/, 13];
|
|
4442
4654
|
case 12:
|
|
4443
|
-
|
|
4444
|
-
console.error("Failed to load PDF header image:",
|
|
4655
|
+
err_27 = _4.sent();
|
|
4656
|
+
console.error("Failed to load PDF header image:", err_27);
|
|
4445
4657
|
console.error("Image source:", headerConfig_1.image.src);
|
|
4446
4658
|
return [3 /*break*/, 13];
|
|
4447
4659
|
case 13:
|
|
@@ -4582,8 +4794,8 @@ exports.DataTemplate = (0, react_1.forwardRef)(function (props, ref) {
|
|
|
4582
4794
|
}
|
|
4583
4795
|
return [3 /*break*/, 17];
|
|
4584
4796
|
case 15:
|
|
4585
|
-
|
|
4586
|
-
console.error("PDF export error:",
|
|
4797
|
+
err_28 = _4.sent();
|
|
4798
|
+
console.error("PDF export error:", err_28);
|
|
4587
4799
|
setNotification({
|
|
4588
4800
|
type: false,
|
|
4589
4801
|
title: "Error",
|
|
@@ -5747,8 +5959,7 @@ exports.DataTemplate = (0, react_1.forwardRef)(function (props, ref) {
|
|
|
5747
5959
|
// INFO: in compact mode, the search input is rendered inline by
|
|
5748
5960
|
// renderListFilterElements, so drop the trailing search element
|
|
5749
5961
|
// from the popup to avoid duplication.
|
|
5750
|
-
var popupFilters = ((_c = props.bareSettings) === null || _c === void 0 ? void 0 : _c.bareCompactMode) &&
|
|
5751
|
-
!((_d = props.organise) === null || _d === void 0 ? void 0 : _d.hideSearch)
|
|
5962
|
+
var popupFilters = ((_c = props.bareSettings) === null || _c === void 0 ? void 0 : _c.bareCompactMode) && !((_d = props.organise) === null || _d === void 0 ? void 0 : _d.hideSearch)
|
|
5752
5963
|
? filterComponent_1.slice(0, -1)
|
|
5753
5964
|
: filterComponent_1;
|
|
5754
5965
|
if (popupFilters.length > 0) {
|