blixify-ui-web 1.0.5 → 1.0.6
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":"AAiCA,OAAO,KASN,MAAM,OAAO,CAAC;AA0Ef,OAAO,EACL,iBAAiB,EAKlB,MAAM,kBAAkB,CAAC;AAoB1B,eAAO,MAAM,YAAY,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/data/dataTemplate/index.tsx"],"names":[],"mappings":"AAiCA,OAAO,KASN,MAAM,OAAO,CAAC;AA0Ef,OAAO,EACL,iBAAiB,EAKlB,MAAM,kBAAkB,CAAC;AAoB1B,eAAO,MAAM,YAAY,mFA2iSvB,CAAC"}
|
|
@@ -350,6 +350,18 @@ exports.DataTemplate = (0, react_1.forwardRef)(function (props, ref) {
|
|
|
350
350
|
var mapViewRef = (0, react_1.useRef)(null);
|
|
351
351
|
var prevTabPropsRef = (0, react_1.useRef)(selectedTab);
|
|
352
352
|
var lastUploadedDataRef = (0, react_1.useRef)(null);
|
|
353
|
+
// INFO: stepper create deduplication — guards against concurrent draft saves
|
|
354
|
+
// issuing multiple create calls before the first create resolves.
|
|
355
|
+
// useRef is required (not useState) because refs are synchronously readable
|
|
356
|
+
// within the same event loop tick.
|
|
357
|
+
var isCreatingRef = (0, react_1.useRef)(false);
|
|
358
|
+
var pendingDraftSaveRef = (0, react_1.useRef)(false);
|
|
359
|
+
var inflightIdRef = (0, react_1.useRef)("");
|
|
360
|
+
// INFO: submit re-entry guard — prevents double-click, rapid Enter keypresses,
|
|
361
|
+
// or concurrent bareSaveOnTabChange calls from running handleSubmit twice.
|
|
362
|
+
// useRef is required (not useState) so the guard is readable synchronously
|
|
363
|
+
// before any re-render occurs.
|
|
364
|
+
var isSubmittingRef = (0, react_1.useRef)(false);
|
|
353
365
|
var devSettings = props.devSettings;
|
|
354
366
|
var serverId = (0, utils_1.parseServerId)(devSettings.server);
|
|
355
367
|
var viewType = (_s = (_r = props.organise) === null || _r === void 0 ? void 0 : _r.viewId) !== null && _s !== void 0 ? _s : "general";
|
|
@@ -786,6 +798,18 @@ exports.DataTemplate = (0, react_1.forwardRef)(function (props, ref) {
|
|
|
786
798
|
}
|
|
787
799
|
}
|
|
788
800
|
}, [structure, props.type, readTabSection]);
|
|
801
|
+
// INFO: reset stepper create deduplication refs when the form resets to a
|
|
802
|
+
// fresh create session (props.id changes back to "new"). Without this, a
|
|
803
|
+
// second form session in the same component instance would see
|
|
804
|
+
// isCreatingRef.current === true from the previous session and skip the
|
|
805
|
+
// create entirely.
|
|
806
|
+
(0, react_1.useEffect)(function () {
|
|
807
|
+
if (props.id === "new") {
|
|
808
|
+
isCreatingRef.current = false;
|
|
809
|
+
pendingDraftSaveRef.current = false;
|
|
810
|
+
inflightIdRef.current = "";
|
|
811
|
+
}
|
|
812
|
+
}, [props.id]);
|
|
789
813
|
var handleUpdateSelectedData = function (changeData) {
|
|
790
814
|
changeData.map(function (eachField) {
|
|
791
815
|
var key = eachField.key, value = eachField.value;
|
|
@@ -2970,7 +2994,7 @@ exports.DataTemplate = (0, react_1.forwardRef)(function (props, ref) {
|
|
|
2970
2994
|
return __generator(this, function (_j) {
|
|
2971
2995
|
switch (_j.label) {
|
|
2972
2996
|
case 0:
|
|
2973
|
-
_j.trys.push([0,
|
|
2997
|
+
_j.trys.push([0, 33, , 34]);
|
|
2974
2998
|
selectedId_2 = "";
|
|
2975
2999
|
if (type === "update")
|
|
2976
3000
|
selectedId_2 = rowId !== null && rowId !== void 0 ? rowId : "";
|
|
@@ -3015,7 +3039,7 @@ exports.DataTemplate = (0, react_1.forwardRef)(function (props, ref) {
|
|
|
3015
3039
|
});
|
|
3016
3040
|
}
|
|
3017
3041
|
res = "";
|
|
3018
|
-
if (!(selectedId_2 === "new")) return [3 /*break*/,
|
|
3042
|
+
if (!(selectedId_2 === "new")) return [3 /*break*/, 14];
|
|
3019
3043
|
if (!showId)
|
|
3020
3044
|
createSelectedData_1[serverId] = id;
|
|
3021
3045
|
if (isDraft)
|
|
@@ -3041,24 +3065,51 @@ exports.DataTemplate = (0, react_1.forwardRef)(function (props, ref) {
|
|
|
3041
3065
|
case 7:
|
|
3042
3066
|
err_19 = _j.sent();
|
|
3043
3067
|
return [3 /*break*/, 8];
|
|
3044
|
-
case 8: return [3 /*break*/,
|
|
3045
|
-
case 9:
|
|
3046
|
-
|
|
3047
|
-
|
|
3048
|
-
|
|
3068
|
+
case 8: return [3 /*break*/, 13];
|
|
3069
|
+
case 9:
|
|
3070
|
+
// INFO: stepper create guard — if a create is already in-flight, queue this
|
|
3071
|
+
// draft save and return early. It will be replayed as an update once the
|
|
3072
|
+
// in-flight create resolves.
|
|
3073
|
+
if (selectedId_2 === "new" && isCreatingRef.current) {
|
|
3074
|
+
pendingDraftSaveRef.current = true;
|
|
3075
|
+
return [2 /*return*/, ""];
|
|
3076
|
+
}
|
|
3077
|
+
if (selectedId_2 === "new") {
|
|
3078
|
+
isCreatingRef.current = true;
|
|
3079
|
+
inflightIdRef.current = id; // INFO: id is the UUID already generated above
|
|
3080
|
+
}
|
|
3081
|
+
return [4 /*yield*/, writeServerQuery.call("create", {
|
|
3082
|
+
data: createSelectedData_1,
|
|
3083
|
+
unique: uniqueColumnId,
|
|
3084
|
+
})];
|
|
3049
3085
|
case 10:
|
|
3050
3086
|
//INFO: [CREATE] Create new data
|
|
3051
3087
|
res = _j.sent();
|
|
3052
|
-
|
|
3053
|
-
|
|
3088
|
+
if (!(selectedId_2 === "new")) return [3 /*break*/, 13];
|
|
3089
|
+
isCreatingRef.current = false;
|
|
3090
|
+
if (!pendingDraftSaveRef.current) return [3 /*break*/, 12];
|
|
3091
|
+
pendingDraftSaveRef.current = false;
|
|
3092
|
+
// INFO: replay as update — inflightIdRef.current holds the real _id
|
|
3093
|
+
return [4 /*yield*/, writeServerQuery.call("update", {
|
|
3094
|
+
id: inflightIdRef.current,
|
|
3095
|
+
data: __assign(__assign({}, createSelectedData_1), { baseDraft: true }),
|
|
3096
|
+
})];
|
|
3097
|
+
case 11:
|
|
3098
|
+
// INFO: replay as update — inflightIdRef.current holds the real _id
|
|
3099
|
+
_j.sent();
|
|
3100
|
+
_j.label = 12;
|
|
3054
3101
|
case 12:
|
|
3055
|
-
|
|
3056
|
-
if (!(isOffline && !offlineId)) return [3 /*break*/, 18];
|
|
3102
|
+
inflightIdRef.current = "";
|
|
3057
3103
|
_j.label = 13;
|
|
3058
|
-
case 13:
|
|
3059
|
-
_j.trys.push([13, 16, , 17]);
|
|
3060
|
-
return [4 /*yield*/, indexedDb_1.indexedDb.getValue("local", props.collectionId)];
|
|
3104
|
+
case 13: return [3 /*break*/, 22];
|
|
3061
3105
|
case 14:
|
|
3106
|
+
if (!selectedId_2) return [3 /*break*/, 22];
|
|
3107
|
+
if (!(isOffline && !offlineId)) return [3 /*break*/, 20];
|
|
3108
|
+
_j.label = 15;
|
|
3109
|
+
case 15:
|
|
3110
|
+
_j.trys.push([15, 18, , 19]);
|
|
3111
|
+
return [4 /*yield*/, indexedDb_1.indexedDb.getValue("local", props.collectionId)];
|
|
3112
|
+
case 16:
|
|
3062
3113
|
offlineDataResp = _j.sent();
|
|
3063
3114
|
tempData = (0, updateModule_1.handleParseOfflineWrite)(selectedData, structure);
|
|
3064
3115
|
tempData[serverId] = selectedId_2;
|
|
@@ -3076,15 +3127,15 @@ exports.DataTemplate = (0, react_1.forwardRef)(function (props, ref) {
|
|
|
3076
3127
|
data: offlineData,
|
|
3077
3128
|
type: props.collectionId,
|
|
3078
3129
|
})];
|
|
3079
|
-
case
|
|
3130
|
+
case 17:
|
|
3080
3131
|
_j.sent();
|
|
3081
3132
|
res = true;
|
|
3082
|
-
return [3 /*break*/,
|
|
3083
|
-
case 16:
|
|
3084
|
-
err_20 = _j.sent();
|
|
3085
|
-
return [3 /*break*/, 17];
|
|
3086
|
-
case 17: return [3 /*break*/, 20];
|
|
3133
|
+
return [3 /*break*/, 19];
|
|
3087
3134
|
case 18:
|
|
3135
|
+
err_20 = _j.sent();
|
|
3136
|
+
return [3 /*break*/, 19];
|
|
3137
|
+
case 19: return [3 /*break*/, 22];
|
|
3138
|
+
case 20:
|
|
3088
3139
|
dataToSubmit = void 0;
|
|
3089
3140
|
if (type === "update" && columnId) {
|
|
3090
3141
|
dataToSubmit = (_a = {},
|
|
@@ -3108,14 +3159,14 @@ exports.DataTemplate = (0, react_1.forwardRef)(function (props, ref) {
|
|
|
3108
3159
|
data: dataToSubmit,
|
|
3109
3160
|
unique: uniqueColumnId,
|
|
3110
3161
|
})];
|
|
3111
|
-
case
|
|
3162
|
+
case 21:
|
|
3112
3163
|
res = _j.sent();
|
|
3113
|
-
_j.label =
|
|
3114
|
-
case
|
|
3115
|
-
if (!(type === "update" || type === "create")) return [3 /*break*/,
|
|
3116
|
-
if (!res) return [3 /*break*/,
|
|
3117
|
-
if (!(type === "update")) return [3 /*break*/,
|
|
3118
|
-
if (!columnId) return [3 /*break*/,
|
|
3164
|
+
_j.label = 22;
|
|
3165
|
+
case 22:
|
|
3166
|
+
if (!(type === "update" || type === "create")) return [3 /*break*/, 30];
|
|
3167
|
+
if (!res) return [3 /*break*/, 29];
|
|
3168
|
+
if (!(type === "update")) return [3 /*break*/, 25];
|
|
3169
|
+
if (!columnId) return [3 /*break*/, 24];
|
|
3119
3170
|
selectedIndex_4 = -1;
|
|
3120
3171
|
tableData.map(function (eachData, index) {
|
|
3121
3172
|
if (eachData.id === rowId || eachData._id === rowId) {
|
|
@@ -3125,25 +3176,25 @@ exports.DataTemplate = (0, react_1.forwardRef)(function (props, ref) {
|
|
|
3125
3176
|
return null;
|
|
3126
3177
|
});
|
|
3127
3178
|
return [4 /*yield*/, handleGetListData({ data: tableData[selectedIndex_4] }, "update", rowId)];
|
|
3128
|
-
case
|
|
3129
|
-
_j.sent();
|
|
3130
|
-
_j.label = 22;
|
|
3131
|
-
case 22: return [3 /*break*/, 25];
|
|
3132
|
-
case 23: return [4 /*yield*/, handleGetListData({ data: [createSelectedData_1] }, "create")];
|
|
3133
|
-
case 24:
|
|
3179
|
+
case 23:
|
|
3134
3180
|
_j.sent();
|
|
3135
|
-
_j.label =
|
|
3136
|
-
case
|
|
3137
|
-
|
|
3138
|
-
return [4 /*yield*/, props.bareSettings.bareUpdateHandlePostComplete(__assign((_b = {}, _b[serverId] = id, _b), createSelectedData_1))];
|
|
3181
|
+
_j.label = 24;
|
|
3182
|
+
case 24: return [3 /*break*/, 27];
|
|
3183
|
+
case 25: return [4 /*yield*/, handleGetListData({ data: [createSelectedData_1] }, "create")];
|
|
3139
3184
|
case 26:
|
|
3140
3185
|
_j.sent();
|
|
3141
3186
|
_j.label = 27;
|
|
3142
|
-
case 27:
|
|
3187
|
+
case 27:
|
|
3188
|
+
if (!((_g = props.bareSettings) === null || _g === void 0 ? void 0 : _g.bareUpdateHandlePostComplete)) return [3 /*break*/, 29];
|
|
3189
|
+
return [4 /*yield*/, props.bareSettings.bareUpdateHandlePostComplete(__assign((_b = {}, _b[serverId] = id, _b), createSelectedData_1))];
|
|
3143
3190
|
case 28:
|
|
3191
|
+
_j.sent();
|
|
3192
|
+
_j.label = 29;
|
|
3193
|
+
case 29: return [3 /*break*/, 32];
|
|
3194
|
+
case 30:
|
|
3144
3195
|
createSelectedData_1[serverId] = id;
|
|
3145
3196
|
return [4 /*yield*/, handleGetListData({ data: [createSelectedData_1] }, selectedId_2 === "new" ? "create" : "update", id)];
|
|
3146
|
-
case
|
|
3197
|
+
case 31:
|
|
3147
3198
|
_j.sent();
|
|
3148
3199
|
setNotification({
|
|
3149
3200
|
type: true,
|
|
@@ -3154,13 +3205,19 @@ exports.DataTemplate = (0, react_1.forwardRef)(function (props, ref) {
|
|
|
3154
3205
|
? "Data sucessfully created"
|
|
3155
3206
|
: "Data sucessfully updated",
|
|
3156
3207
|
});
|
|
3157
|
-
_j.label =
|
|
3158
|
-
case
|
|
3208
|
+
_j.label = 32;
|
|
3209
|
+
case 32:
|
|
3159
3210
|
dataId = res ? id : "";
|
|
3160
3211
|
return [2 /*return*/, dataId];
|
|
3161
|
-
case
|
|
3212
|
+
case 33:
|
|
3162
3213
|
err_21 = _j.sent();
|
|
3163
3214
|
console.log("error", err_21);
|
|
3215
|
+
// INFO: clear in-flight guard on failure so the next save retries as a create
|
|
3216
|
+
if (isCreatingRef.current) {
|
|
3217
|
+
isCreatingRef.current = false;
|
|
3218
|
+
pendingDraftSaveRef.current = false;
|
|
3219
|
+
inflightIdRef.current = "";
|
|
3220
|
+
}
|
|
3164
3221
|
if (err_21.response && err_21.response.status === 400) {
|
|
3165
3222
|
if (typeof ((_h = err_21.response.data) === null || _h === void 0 ? void 0 : _h.err) === "string")
|
|
3166
3223
|
setNotification({
|
|
@@ -3175,8 +3232,8 @@ exports.DataTemplate = (0, react_1.forwardRef)(function (props, ref) {
|
|
|
3175
3232
|
msg: "Please contact our administrator for assistance or try your request again later. We apologize for any inconvenience",
|
|
3176
3233
|
});
|
|
3177
3234
|
}
|
|
3178
|
-
return [3 /*break*/,
|
|
3179
|
-
case
|
|
3235
|
+
return [3 /*break*/, 34];
|
|
3236
|
+
case 34: return [2 /*return*/];
|
|
3180
3237
|
}
|
|
3181
3238
|
});
|
|
3182
3239
|
}); };
|
|
@@ -3225,34 +3282,43 @@ exports.DataTemplate = (0, react_1.forwardRef)(function (props, ref) {
|
|
|
3225
3282
|
return __generator(this, function (_m) {
|
|
3226
3283
|
switch (_m.label) {
|
|
3227
3284
|
case 0:
|
|
3228
|
-
|
|
3285
|
+
// INFO: re-entry guard — if a submit is already in-flight (double-click,
|
|
3286
|
+
// rapid Enter keypresses, or concurrent bareSaveOnTabChange calls), return
|
|
3287
|
+
// early. This prevents duplicate creates/updates, double-firing of
|
|
3288
|
+
// bareUpdateHandlePreComplete/Complete, and premature modal dismissal.
|
|
3289
|
+
if (isSubmittingRef.current)
|
|
3290
|
+
return [2 /*return*/];
|
|
3291
|
+
isSubmittingRef.current = true;
|
|
3292
|
+
_m.label = 1;
|
|
3293
|
+
case 1:
|
|
3294
|
+
_m.trys.push([1, 10, , 11]);
|
|
3229
3295
|
setLoading(true);
|
|
3230
3296
|
setModalVisible(true);
|
|
3231
3297
|
preComplete = true;
|
|
3232
|
-
if (!((_b = props.bareSettings) === null || _b === void 0 ? void 0 : _b.bareUpdateHandlePreComplete)) return [3 /*break*/,
|
|
3298
|
+
if (!((_b = props.bareSettings) === null || _b === void 0 ? void 0 : _b.bareUpdateHandlePreComplete)) return [3 /*break*/, 3];
|
|
3233
3299
|
return [4 /*yield*/, props.bareSettings.bareUpdateHandlePreComplete(selectedData)];
|
|
3234
|
-
case
|
|
3300
|
+
case 2:
|
|
3235
3301
|
preComplete =
|
|
3236
3302
|
_m.sent();
|
|
3237
|
-
_m.label =
|
|
3238
|
-
case
|
|
3303
|
+
_m.label = 3;
|
|
3304
|
+
case 3:
|
|
3239
3305
|
if (!preComplete)
|
|
3240
3306
|
throw "Error";
|
|
3241
|
-
if (!((_c = props.bareSettings) === null || _c === void 0 ? void 0 : _c.bareUpdateHandleComplete)) return [3 /*break*/,
|
|
3307
|
+
if (!((_c = props.bareSettings) === null || _c === void 0 ? void 0 : _c.bareUpdateHandleComplete)) return [3 /*break*/, 5];
|
|
3242
3308
|
return [4 /*yield*/, props.bareSettings.bareUpdateHandleComplete(selectedData)];
|
|
3243
|
-
case
|
|
3309
|
+
case 4:
|
|
3244
3310
|
_m.sent();
|
|
3245
|
-
return [3 /*break*/,
|
|
3246
|
-
case
|
|
3247
|
-
case
|
|
3311
|
+
return [3 /*break*/, 9];
|
|
3312
|
+
case 5: return [4 /*yield*/, handleSubmitData(undefined, undefined, undefined, undefined, undefined, undefined, isDraft)];
|
|
3313
|
+
case 6:
|
|
3248
3314
|
res = _m.sent();
|
|
3249
|
-
if (!res) return [3 /*break*/,
|
|
3250
|
-
if (!((_d = props.bareSettings) === null || _d === void 0 ? void 0 : _d.bareUpdateHandlePostComplete)) return [3 /*break*/,
|
|
3315
|
+
if (!res) return [3 /*break*/, 9];
|
|
3316
|
+
if (!((_d = props.bareSettings) === null || _d === void 0 ? void 0 : _d.bareUpdateHandlePostComplete)) return [3 /*break*/, 8];
|
|
3251
3317
|
return [4 /*yield*/, props.bareSettings.bareUpdateHandlePostComplete(__assign((_a = {}, _a[serverId] = res, _a), selectedData))];
|
|
3252
|
-
case 6:
|
|
3253
|
-
_m.sent();
|
|
3254
|
-
_m.label = 7;
|
|
3255
3318
|
case 7:
|
|
3319
|
+
_m.sent();
|
|
3320
|
+
_m.label = 8;
|
|
3321
|
+
case 8:
|
|
3256
3322
|
handleCheckOfflineDataLength();
|
|
3257
3323
|
if (isDraft) {
|
|
3258
3324
|
updatedMarkdownData_1 = {};
|
|
@@ -3313,17 +3379,19 @@ exports.DataTemplate = (0, react_1.forwardRef)(function (props, ref) {
|
|
|
3313
3379
|
(_l = (_k = props.organise) === null || _k === void 0 ? void 0 : _k.handleNavigate) === null || _l === void 0 ? void 0 : _l.call(_k, "read", res, "general");
|
|
3314
3380
|
}
|
|
3315
3381
|
}
|
|
3316
|
-
_m.label =
|
|
3317
|
-
case
|
|
3382
|
+
_m.label = 9;
|
|
3383
|
+
case 9:
|
|
3318
3384
|
setModalVisible(false);
|
|
3319
3385
|
setLoading(false);
|
|
3320
|
-
|
|
3321
|
-
|
|
3386
|
+
isSubmittingRef.current = false;
|
|
3387
|
+
return [3 /*break*/, 11];
|
|
3388
|
+
case 10:
|
|
3322
3389
|
err_22 = _m.sent();
|
|
3323
3390
|
setModalVisible(false);
|
|
3324
3391
|
setLoading(false);
|
|
3325
|
-
|
|
3326
|
-
|
|
3392
|
+
isSubmittingRef.current = false;
|
|
3393
|
+
return [3 /*break*/, 11];
|
|
3394
|
+
case 11: return [2 /*return*/];
|
|
3327
3395
|
}
|
|
3328
3396
|
});
|
|
3329
3397
|
}); };
|