blixify-ui-web 1.2.260 → 1.2.261

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;AAmHf,OAAO,EACL,iBAAiB,EAIlB,MAAM,kBAAkB,CAAC;AAkI1B,eAAO,MAAM,qBAAqB,OAAO,CAAC;AA6C1C,eAAO,MAAM,yBAAyB,UAAW,GAAG,YAYnD,CAAC;AAEF,eAAO,MAAM,YAAY,mFA2ogBvB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/data/dataTemplate/index.tsx"],"names":[],"mappings":"AAqCA,OAAO,KASN,MAAM,OAAO,CAAC;AAmHf,OAAO,EACL,iBAAiB,EAIlB,MAAM,kBAAkB,CAAC;AAkI1B,eAAO,MAAM,qBAAqB,OAAO,CAAC;AA6C1C,eAAO,MAAM,yBAAyB,UAAW,GAAG,YAYnD,CAAC;AAEF,eAAO,MAAM,YAAY,mFA0sgBvB,CAAC"}
@@ -733,6 +733,17 @@ exports.DataTemplate = (0, react_1.forwardRef)(function (rawProps, ref) {
733
733
  // Intentionally separate from previousSelectedData, which advances on every
734
734
  // edit and therefore cannot serve as a stable submit baseline.
735
735
  var loadedSelectedData = (0, react_1.useRef)(null);
736
+ // INFO: the form edits a saved record — opened on one (not "new") and, for a
737
+ // deterministic-id upsert form (bareUpsertPartialUpdate), one that was found.
738
+ // A record not found yet is new: its defaults still prefill. Read at the time
739
+ // it is called — the ref is set as the record loads, and after its first save.
740
+ var handleIsSavedRecord = function () {
741
+ var _a;
742
+ return !!props.id &&
743
+ props.id !== "new" &&
744
+ (!((_a = props.bareSettings) === null || _a === void 0 ? void 0 : _a.bareUpsertPartialUpdate) ||
745
+ !!loadedSelectedData.current);
746
+ };
736
747
  // INFO: untouched DB doc for the current read record
737
748
  var rawReadData = (0, react_1.useRef)(null);
738
749
  // INFO: live-stream SSE client — created on mount when bareSocketName is set
@@ -4686,13 +4697,15 @@ exports.DataTemplate = (0, react_1.forwardRef)(function (rawProps, ref) {
4686
4697
  }
4687
4698
  });
4688
4699
  }); };
4689
- var handleUploadImage = function (id, data) { return __awaiter(void 0, void 0, void 0, function () {
4700
+ // INFO: isUpdate — the record already exists, so an emptied field is saved
4701
+ // empty rather than prefilled with its default (handleCastDataAttribute)
4702
+ var handleUploadImage = function (id, data, isUpdate) { return __awaiter(void 0, void 0, void 0, function () {
4690
4703
  var clonedSelectedData, objectAttribute, _i, objectAttribute_1, eachObject, listObjectAttribute, _a, listObjectAttribute_1, eachObject;
4691
4704
  var _b, _c, _d, _e;
4692
4705
  return __generator(this, function (_f) {
4693
4706
  switch (_f.label) {
4694
4707
  case 0:
4695
- clonedSelectedData = (0, updateModule_1.handleClonedDataAttribute)(data !== null && data !== void 0 ? data : selectedData, structure, props.devSettings.server, true, showId);
4708
+ clonedSelectedData = (0, updateModule_1.handleClonedDataAttribute)(data !== null && data !== void 0 ? data : selectedData, structure, props.devSettings.server, true, showId, isUpdate);
4696
4709
  return [4 /*yield*/, handleParseMarkdownField(id, clonedSelectedData, structure, modalFormInputRefs)];
4697
4710
  case 1:
4698
4711
  //INFO: Parse & Upload Data "Markdown attributes with delayed images"
@@ -5979,7 +5992,7 @@ exports.DataTemplate = (0, react_1.forwardRef)(function (rawProps, ref) {
5979
5992
  });
5980
5993
  }); };
5981
5994
  var handleSubmitData = function (type, rowId, columnId, data, offlineId, isOfflineUpdate, isDraft) { return __awaiter(void 0, void 0, void 0, function () {
5982
- var selectedId, id, createSelectedData_1, uniqueDataStructure, uniqueColumnId, res, offlineDataResp, offlineData, clonedForOffline, tempData, selectedIndex_3, err_19, isUniqueIdFieldCreate, isExistingDoc, newRecordData_1, changedAttributeIds, baseDraftValue, hasBaseDraftChange, offlineDataResp, clonedForOffline, tempData, selectedIndex_4, offlineData, err_20, dataToSubmit_2, changedAttributeIds, baseDraftValue, hasBaseDraftChange, operationType, currentRow, wentToServer, dataId, err_21, offlineDataResp, offlineData, clonedForOffline, tempData, selectedIndex_5, _a;
5995
+ var selectedId, id, handleIsSavedSubmit, createSelectedData_1, uniqueDataStructure, uniqueColumnId, res, offlineDataResp, offlineData, clonedForOffline, tempData, selectedIndex_3, err_19, isUniqueIdFieldCreate, isExistingDoc, newRecordData_1, changedAttributeIds, baseDraftValue, hasBaseDraftChange, offlineDataResp, clonedForOffline, tempData, selectedIndex_4, offlineData, err_20, dataToSubmit_2, changedAttributeIds, baseDraftValue, hasBaseDraftChange, operationType, currentRow, wentToServer, dataId, err_21, offlineDataResp, offlineData, clonedForOffline, tempData, selectedIndex_5, _a;
5983
5996
  var _b, _c, _d, _e;
5984
5997
  var _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y;
5985
5998
  return __generator(this, function (_z) {
@@ -5987,6 +6000,16 @@ exports.DataTemplate = (0, react_1.forwardRef)(function (rawProps, ref) {
5987
6000
  case 0:
5988
6001
  selectedId = "";
5989
6002
  id = "";
6003
+ handleIsSavedSubmit = function () {
6004
+ var _a;
6005
+ if (type === "update")
6006
+ return true;
6007
+ if (offlineId)
6008
+ return !!isOfflineUpdate;
6009
+ return (selectedId !== "new" &&
6010
+ (!((_a = props.bareSettings) === null || _a === void 0 ? void 0 : _a.bareUpsertPartialUpdate) ||
6011
+ !!loadedSelectedData.current));
6012
+ };
5990
6013
  _z.label = 1;
5991
6014
  case 1:
5992
6015
  _z.trys.push([1, 39, , 45]);
@@ -6017,7 +6040,7 @@ exports.DataTemplate = (0, react_1.forwardRef)(function (rawProps, ref) {
6017
6040
  !offlineId)) return [3 /*break*/, 2];
6018
6041
  createSelectedData_1 = selectedData;
6019
6042
  return [3 /*break*/, 4];
6020
- case 2: return [4 /*yield*/, handleUploadImage(id, data)];
6043
+ case 2: return [4 /*yield*/, handleUploadImage(id, data, handleIsSavedSubmit())];
6021
6044
  case 3:
6022
6045
  createSelectedData_1 = _z.sent();
6023
6046
  _z.label = 4;
@@ -6223,7 +6246,7 @@ exports.DataTemplate = (0, react_1.forwardRef)(function (rawProps, ref) {
6223
6246
  return [4 /*yield*/, indexedDb_1.indexedDb.getValue("local", props.collectionId)];
6224
6247
  case 19:
6225
6248
  offlineDataResp = _z.sent();
6226
- clonedForOffline = (0, updateModule_1.handleClonedDataAttribute)(selectedData, structure, props.devSettings.server, true, showId);
6249
+ clonedForOffline = (0, updateModule_1.handleClonedDataAttribute)(selectedData, structure, props.devSettings.server, true, showId, handleIsSavedSubmit());
6227
6250
  tempData = (0, updateModule_1.handleParseOfflineWrite)(clonedForOffline, structure);
6228
6251
  tempData[serverId] = selectedId;
6229
6252
  // INFO: Remove non-serializable keys that IDB's structured clone can't handle
@@ -6438,7 +6461,7 @@ exports.DataTemplate = (0, react_1.forwardRef)(function (rawProps, ref) {
6438
6461
  case 41:
6439
6462
  offlineDataResp = _z.sent();
6440
6463
  offlineData = (_y = offlineDataResp === null || offlineDataResp === void 0 ? void 0 : offlineDataResp.data) !== null && _y !== void 0 ? _y : [];
6441
- clonedForOffline = (0, updateModule_1.handleClonedDataAttribute)(selectedData, structure, props.devSettings.server, true, showId);
6464
+ clonedForOffline = (0, updateModule_1.handleClonedDataAttribute)(selectedData, structure, props.devSettings.server, true, showId, handleIsSavedSubmit());
6442
6465
  tempData = (0, updateModule_1.handleParseOfflineWrite)(clonedForOffline, structure);
6443
6466
  if (!tempData[serverId])
6444
6467
  tempData[serverId] = id;
@@ -6588,7 +6611,7 @@ exports.DataTemplate = (0, react_1.forwardRef)(function (rawProps, ref) {
6588
6611
  // re-sent on every subsequent save (harmless but wasteful), and the
6589
6612
  // "skip write if nothing changed" short-circuit would never trigger.
6590
6613
  if ((_c = props.bareSettings) === null || _c === void 0 ? void 0 : _c.bareUpsertPartialUpdate) {
6591
- loadedSelectedData.current = (0, updateModule_1.handleClonedDataAttribute)(selectedData, structure, props.devSettings.server, true, showId);
6614
+ loadedSelectedData.current = (0, updateModule_1.handleClonedDataAttribute)(selectedData, structure, props.devSettings.server, true, showId, true);
6592
6615
  // INFO: Reset dirty tracking after successful save — the new baseline
6593
6616
  // is the saved state, so all fields start "clean" again.
6594
6617
  dirtyFieldsRef.current.clear();
@@ -6651,7 +6674,7 @@ exports.DataTemplate = (0, react_1.forwardRef)(function (rawProps, ref) {
6651
6674
  // Usually the component navigates away, but in case it doesn't (e.g. custom onComplete
6652
6675
  // that stays on the same page), ensure clean state for subsequent interactions.
6653
6676
  if ((_g = props.bareSettings) === null || _g === void 0 ? void 0 : _g.bareUpsertPartialUpdate) {
6654
- loadedSelectedData.current = (0, updateModule_1.handleClonedDataAttribute)(selectedData, structure, props.devSettings.server, true, showId);
6677
+ loadedSelectedData.current = (0, updateModule_1.handleClonedDataAttribute)(selectedData, structure, props.devSettings.server, true, showId, true);
6655
6678
  dirtyFieldsRef.current.clear();
6656
6679
  }
6657
6680
  if (props.onComplete) {
@@ -6860,6 +6883,11 @@ exports.DataTemplate = (0, react_1.forwardRef)(function (rawProps, ref) {
6860
6883
  }
6861
6884
  });
6862
6885
  }); };
6886
+ // INFO: isUpdate — the data being changed belongs to records that already
6887
+ // exist, so a field emptied while editing is not prefilled with its default
6888
+ // again. An object or list item is a new entry (keeps its prefill); a batch
6889
+ // update edits saved records; the main form edits one when it was opened on
6890
+ // a record rather than "new".
6863
6891
  var handleOnChangeData = function () {
6864
6892
  var _a;
6865
6893
  if (modalVisible && selectedObjectStructureId) {
@@ -6869,18 +6897,21 @@ exports.DataTemplate = (0, react_1.forwardRef)(function (rawProps, ref) {
6869
6897
  return {
6870
6898
  data: selectedObjectData,
6871
6899
  model: (_a = filterObjectModel === null || filterObjectModel === void 0 ? void 0 : filterObjectModel.objectData) !== null && _a !== void 0 ? _a : [],
6900
+ isUpdate: false,
6872
6901
  };
6873
6902
  }
6874
6903
  else if (batchUpdateModal && batchUpdateData.columnId) {
6875
6904
  return {
6876
6905
  data: batchUpdateData.columnData,
6877
6906
  model: structure,
6907
+ isUpdate: true,
6878
6908
  };
6879
6909
  }
6880
6910
  else {
6881
6911
  return {
6882
6912
  data: selectedData,
6883
6913
  model: structure,
6914
+ isUpdate: handleIsSavedRecord(),
6884
6915
  };
6885
6916
  }
6886
6917
  };
@@ -6894,7 +6925,9 @@ exports.DataTemplate = (0, react_1.forwardRef)(function (rawProps, ref) {
6894
6925
  if (selectedModel) {
6895
6926
  //INFO: [UPDATE] Update data via batch modal
6896
6927
  var clonedData = JSON.parse(JSON.stringify(data));
6897
- (0, updateModule_1.handleCastDataAttribute)(selectedModel, data, clonedData, dbModule, true);
6928
+ (0, updateModule_1.handleCastDataAttribute)(selectedModel, data, clonedData, dbModule, true,
6929
+ // INFO: a batch update edits saved records — no default prefill
6930
+ true);
6898
6931
  setBatchUpdateData({
6899
6932
  columnId: batchUpdateData.columnId,
6900
6933
  columnData: (_a = {},
@@ -6909,16 +6942,16 @@ exports.DataTemplate = (0, react_1.forwardRef)(function (rawProps, ref) {
6909
6942
  }
6910
6943
  };
6911
6944
  var handleOnChangeFile = function (e) {
6912
- var _a = handleOnChangeData(), data = _a.data, model = _a.model;
6913
- var clonedData = (0, updateModule_1.handleClonedDataAttribute)(data, model, props.devSettings.server, false, remainId);
6945
+ var _a = handleOnChangeData(), data = _a.data, model = _a.model, isUpdate = _a.isUpdate;
6946
+ var clonedData = (0, updateModule_1.handleClonedDataAttribute)(data, model, props.devSettings.server, false, remainId, isUpdate);
6914
6947
  clonedData[e.target.id] =
6915
6948
  e.target.files.length > 0 ? e.target.files[0] : undefined;
6916
6949
  handleUpdateChangeData(clonedData);
6917
6950
  };
6918
6951
  var handleOnChangeFiles = function (id, value, action) {
6919
6952
  var _a, _b;
6920
- var _c = handleOnChangeData(), data = _c.data, model = _c.model;
6921
- var clonedData = (0, updateModule_1.handleClonedDataAttribute)(data, model, props.devSettings.server, false, remainId);
6953
+ var _c = handleOnChangeData(), data = _c.data, model = _c.model, isUpdate = _c.isUpdate;
6954
+ var clonedData = (0, updateModule_1.handleClonedDataAttribute)(data, model, props.devSettings.server, false, remainId, isUpdate);
6922
6955
  var previousData = clonedData[id] && clonedData[id]["data"] ? clonedData[id]["data"] : [];
6923
6956
  var previousUploadData = clonedData[id] && clonedData[id]["upload"]
6924
6957
  ? clonedData[id]["upload"]
@@ -6985,7 +7018,7 @@ exports.DataTemplate = (0, react_1.forwardRef)(function (rawProps, ref) {
6985
7018
  }
6986
7019
  };
6987
7020
  var handleSignatureComplete = function (dataURL, id) {
6988
- var model = handleOnChangeData().model;
7021
+ var _a = handleOnChangeData(), model = _a.model, isUpdate = _a.isUpdate;
6989
7022
  // Helper function to determine if we should preserve the existing token
6990
7023
  var shouldPreserveToken = function (currentValue, newDataURL) {
6991
7024
  // If newDataURL is empty but there's an existing token, preserve it
@@ -7003,7 +7036,7 @@ exports.DataTemplate = (0, react_1.forwardRef)(function (rawProps, ref) {
7003
7036
  if (modalVisible && selectedObjectStructureId) {
7004
7037
  // For modal case, update selectedObjectData
7005
7038
  setSelectedObjectData(function (prevObjectData) {
7006
- var clonedData = (0, updateModule_1.handleClonedDataAttribute)(prevObjectData, model, props.devSettings.server, false, remainId);
7039
+ var clonedData = (0, updateModule_1.handleClonedDataAttribute)(prevObjectData, model, props.devSettings.server, false, remainId, isUpdate);
7007
7040
  // Preserve token if dataURL is empty and there's an existing token
7008
7041
  if (shouldPreserveToken(clonedData[id], dataURL)) {
7009
7042
  // Don't overwrite - keep the existing token
@@ -7038,7 +7071,7 @@ exports.DataTemplate = (0, react_1.forwardRef)(function (rawProps, ref) {
7038
7071
  // Normal case: Use functional update to ensure we're working with the latest state
7039
7072
  // This prevents the issue where handleClonedDataAttribute copies stale state
7040
7073
  setSelectedData(function (prevSelectedData) {
7041
- var clonedData = (0, updateModule_1.handleClonedDataAttribute)(prevSelectedData, model, props.devSettings.server, false, remainId);
7074
+ var clonedData = (0, updateModule_1.handleClonedDataAttribute)(prevSelectedData, model, props.devSettings.server, false, remainId, isUpdate);
7042
7075
  // If dataURL is empty but there's an existing token, preserve it
7043
7076
  // This happens when signature validation passes but user didn't draw a new signature
7044
7077
  // or when user cleared but didn't draw anything new
@@ -7056,24 +7089,24 @@ exports.DataTemplate = (0, react_1.forwardRef)(function (rawProps, ref) {
7056
7089
  // But we can verify it worked by checking in the next render or at submission
7057
7090
  };
7058
7091
  var handleOnChangeAddress = function (id, address) {
7059
- var _a = handleOnChangeData(), data = _a.data, model = _a.model;
7060
- var clonedData = (0, updateModule_1.handleClonedDataAttribute)(data, model, props.devSettings.server, false, remainId);
7092
+ var _a = handleOnChangeData(), data = _a.data, model = _a.model, isUpdate = _a.isUpdate;
7093
+ var clonedData = (0, updateModule_1.handleClonedDataAttribute)(data, model, props.devSettings.server, false, remainId, isUpdate);
7061
7094
  clonedData[id] = address;
7062
7095
  handleUpdateChangeData(clonedData);
7063
7096
  };
7064
7097
  var handleOnChangeText = function (e) {
7065
- var _a = handleOnChangeData(), data = _a.data, model = _a.model;
7098
+ var _a = handleOnChangeData(), data = _a.data, model = _a.model, isUpdate = _a.isUpdate;
7066
7099
  data[e.target.id] = e.target.value;
7067
- var clonedData = (0, updateModule_1.handleClonedDataAttribute)(data, model, props.devSettings.server, false, remainId);
7100
+ var clonedData = (0, updateModule_1.handleClonedDataAttribute)(data, model, props.devSettings.server, false, remainId, isUpdate);
7068
7101
  handleUpdateChangeData(clonedData);
7069
7102
  };
7070
7103
  var handleOnChangeSelect = function (id, value) { return __awaiter(void 0, void 0, void 0, function () {
7071
- var _a, data, model, clonedData, refetchReference, currentSchema, allowedWatchedColumnTypes_1, watchedColumns, _i, watchedColumns_1, eachWatched, dependency, referenceRQ, valueRes, err_24;
7104
+ var _a, data, model, isUpdate, clonedData, refetchReference, currentSchema, allowedWatchedColumnTypes_1, watchedColumns, _i, watchedColumns_1, eachWatched, dependency, referenceRQ, valueRes, err_24;
7072
7105
  return __generator(this, function (_b) {
7073
7106
  switch (_b.label) {
7074
7107
  case 0:
7075
- _a = handleOnChangeData(), data = _a.data, model = _a.model;
7076
- clonedData = (0, updateModule_1.handleClonedDataAttribute)(data, model, props.devSettings.server, false, remainId);
7108
+ _a = handleOnChangeData(), data = _a.data, model = _a.model, isUpdate = _a.isUpdate;
7109
+ clonedData = (0, updateModule_1.handleClonedDataAttribute)(data, model, props.devSettings.server, false, remainId, isUpdate);
7077
7110
  refetchReference = false;
7078
7111
  if (!((Array.isArray(value) && value.includes("creation")) ||
7079
7112
  value === "creation")) return [3 /*break*/, 1];
@@ -7145,14 +7178,14 @@ exports.DataTemplate = (0, react_1.forwardRef)(function (rawProps, ref) {
7145
7178
  });
7146
7179
  }); };
7147
7180
  var handleOnChangeDate = function (id, value) {
7148
- var _a = handleOnChangeData(), data = _a.data, model = _a.model;
7149
- var clonedData = (0, updateModule_1.handleClonedDataAttribute)(data, model, props.devSettings.server, false, remainId);
7181
+ var _a = handleOnChangeData(), data = _a.data, model = _a.model, isUpdate = _a.isUpdate;
7182
+ var clonedData = (0, updateModule_1.handleClonedDataAttribute)(data, model, props.devSettings.server, false, remainId, isUpdate);
7150
7183
  clonedData[id] = value;
7151
7184
  handleUpdateChangeData(clonedData);
7152
7185
  };
7153
7186
  var handleOnChangeMarkdown = function (id, value) {
7154
- var _a = handleOnChangeData(), data = _a.data, model = _a.model;
7155
- var clonedData = (0, updateModule_1.handleClonedDataAttribute)(data, model, props.devSettings.server, false, remainId);
7187
+ var _a = handleOnChangeData(), data = _a.data, model = _a.model, isUpdate = _a.isUpdate;
7188
+ var clonedData = (0, updateModule_1.handleClonedDataAttribute)(data, model, props.devSettings.server, false, remainId, isUpdate);
7156
7189
  clonedData[id] = value;
7157
7190
  handleUpdateChangeData(clonedData);
7158
7191
  };
@@ -9612,6 +9645,8 @@ exports.DataTemplate = (0, react_1.forwardRef)(function (rawProps, ref) {
9612
9645
  id: props.id,
9613
9646
  isObject: isObject,
9614
9647
  isObjectList: isObjectList,
9648
+ // INFO: a saved record shows its empty fields empty, not prefilled
9649
+ isUpdate: handleIsSavedRecord(),
9615
9650
  lib: {
9616
9651
  axios: (_a = props.lib) === null || _a === void 0 ? void 0 : _a.axios,
9617
9652
  Transition: (_b = props === null || props === void 0 ? void 0 : props.lib) === null || _b === void 0 ? void 0 : _b.Transition,