@mcurros2/microm 1.1.97-0 → 1.1.98-0

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/dist/index.js CHANGED
@@ -154,8 +154,8 @@ $parcel$export(module.exports, "useEntityForm", function () { return $8b0c683387
154
154
 
155
155
 
156
156
  parcelRequire("2eyXi");
157
- var $lTNXP = parcelRequire("lTNXP");
158
157
  var $iKzSR = parcelRequire("iKzSR");
158
+ var $lTNXP = parcelRequire("lTNXP");
159
159
  parcelRequire("6Rdyz");
160
160
  var $98ddT = parcelRequire("98ddT");
161
161
 
@@ -244,6 +244,7 @@ function $8b0c683387a5432f$export$f1f43a62560a15ec(props) {
244
244
  }, [
245
245
  form
246
246
  ]);
247
+ const lastGetValues = (0, $b4te3$react.useRef)();
247
248
  // Form Handlers
248
249
  const performGetData = (0, $b4te3$react.useCallback)(()=>$8b0c683387a5432f$var$__awaiter(this, void 0, void 0, function*() {
249
250
  setStatus({
@@ -256,11 +257,14 @@ function $8b0c683387a5432f$export$f1f43a62560a15ec(props) {
256
257
  if (ret) {
257
258
  const new_values = (0, $vXZlt.getMantineValuesObject)(form.values, entity.def.columns, true);
258
259
  form.setValues(new_values);
260
+ lastGetValues.current = new_values;
259
261
  const new_status = {
260
262
  loading: false,
261
263
  operationType: "get"
262
264
  };
263
265
  setStatus(new_status);
266
+ form.resetDirty();
267
+ form.resetTouched();
264
268
  }
265
269
  return ret;
266
270
  } catch (e) {
@@ -425,16 +429,13 @@ function $8b0c683387a5432f$export$f1f43a62560a15ec(props) {
425
429
  const removeValidation = (0, $b4te3$react.useCallback)((column)=>{
426
430
  delete validationObject.current[column.name];
427
431
  }, []);
432
+ // getDataOnInit
428
433
  (0, $b4te3$react.useEffect)(()=>{
429
434
  const cancellation = getAbortController.current;
430
435
  if (getDataOnInit) {
431
436
  function getData() {
432
437
  return $8b0c683387a5432f$var$__awaiter(this, void 0, void 0, function*() {
433
- const result = yield performGetData();
434
- if (result) {
435
- form.resetDirty();
436
- form.resetTouched();
437
- }
438
+ yield performGetData();
438
439
  });
439
440
  }
440
441
  getData();
@@ -465,9 +466,9 @@ function $8b0c683387a5432f$export$f1f43a62560a15ec(props) {
465
466
  (0, $b4te3$react.useEffect)(()=>{
466
467
  const handleBeforeUnload = ()=>$8b0c683387a5432f$var$__awaiter(this, void 0, void 0, function*() {
467
468
  try {
468
- if (saveBeforeRemoteNavigation && form.isDirty()) {
469
+ if (saveBeforeRemoteNavigation) {
469
470
  form.validate();
470
- yield saveAndGet();
471
+ if (!(0, $iKzSR.areValuesObjectsEqual)(form.values, lastGetValues.current)) yield saveAndGet();
471
472
  }
472
473
  } catch (ex) {
473
474
  console.error("SaveBeforeRemoteNavigation", ex);
@@ -488,7 +489,7 @@ function $8b0c683387a5432f$export$f1f43a62560a15ec(props) {
488
489
  try {
489
490
  if (saveBeforeLocalNavigation && form.isDirty() && prevLocationRef.current !== window.location.hash) {
490
491
  form.validate();
491
- yield saveAndGet();
492
+ if (!(0, $iKzSR.areValuesObjectsEqual)(form.values, lastGetValues.current)) yield saveAndGet();
492
493
  }
493
494
  } catch (ex) {
494
495
  console.error("SaveBeforeLocalNavigation", ex);