cat-qw-lib 0.43.62 → 0.43.64
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/fesm2022/cat-qw-lib.mjs
CHANGED
|
@@ -1399,18 +1399,34 @@ class BaseFormComponent {
|
|
|
1399
1399
|
});
|
|
1400
1400
|
}
|
|
1401
1401
|
handleBeforeUnload(event) {
|
|
1402
|
-
const
|
|
1403
|
-
const
|
|
1402
|
+
const sanitizedInitialRecord = this.normalizeRecord(this.initialRecord);
|
|
1403
|
+
const sanitizedCurrentRecord = this.normalizeRecord(this.record);
|
|
1404
|
+
const hasChanges = JSON.stringify(sanitizedInitialRecord) !== JSON.stringify(sanitizedCurrentRecord);
|
|
1405
|
+
const isSaved = this.formStateService.getIsFormSaved();
|
|
1404
1406
|
if (hasChanges && !isSaved) {
|
|
1405
1407
|
event.preventDefault();
|
|
1406
1408
|
event.returnValue = SHARED.BROWSER_WARNING;
|
|
1407
1409
|
}
|
|
1408
1410
|
}
|
|
1409
1411
|
checkUnsavedChanges() {
|
|
1410
|
-
const
|
|
1411
|
-
const
|
|
1412
|
+
const sanitizedInitialRecord = this.normalizeRecord(this.initialRecord);
|
|
1413
|
+
const sanitizedCurrentRecord = this.normalizeRecord(this.record);
|
|
1414
|
+
const hasChanges = JSON.stringify(sanitizedInitialRecord) !== JSON.stringify(sanitizedCurrentRecord);
|
|
1415
|
+
const isSaved = this.formStateService.getIsFormSaved();
|
|
1412
1416
|
this.formStateService.setShowConfirmation(hasChanges && !isSaved);
|
|
1413
1417
|
}
|
|
1418
|
+
normalizeRecord(record) {
|
|
1419
|
+
if (!record)
|
|
1420
|
+
return {};
|
|
1421
|
+
return Object.keys(record).reduce((acc, key) => {
|
|
1422
|
+
let value = record[key];
|
|
1423
|
+
if (value === undefined || value === SHARED.EMPTY) {
|
|
1424
|
+
value = undefined;
|
|
1425
|
+
}
|
|
1426
|
+
acc[key] = value;
|
|
1427
|
+
return acc;
|
|
1428
|
+
}, {});
|
|
1429
|
+
}
|
|
1414
1430
|
handleSubmit() {
|
|
1415
1431
|
const validateRecords = this.validatorService
|
|
1416
1432
|
? this.validatorService.handleValidateRecords(this.record)
|