cat-qw-lib 0.43.34 → 0.43.37
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
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
|
-
import { EventEmitter, Component, Input, Output, Injectable, ViewChild, ViewEncapsulation, inject, Pipe, Directive, NgModule, APP_INITIALIZER } from '@angular/core';
|
|
2
|
+
import { EventEmitter, Component, Input, Output, Injectable, ViewChild, ViewEncapsulation, inject, HostListener, Pipe, Directive, NgModule, APP_INITIALIZER } from '@angular/core';
|
|
3
3
|
import * as i1 from '@angular/common';
|
|
4
4
|
import { CommonModule } from '@angular/common';
|
|
5
5
|
import * as i3$1 from '@angular/forms';
|
|
@@ -160,6 +160,7 @@ class SHARED {
|
|
|
160
160
|
static SEMICOLON_STRING = ";";
|
|
161
161
|
static COLON_STRING = ":";
|
|
162
162
|
static PAGINATOR = "paginator";
|
|
163
|
+
static BROWSER_WARNING = 'You have unsaved changes. Do you really want to leave?';
|
|
163
164
|
}
|
|
164
165
|
const statusList = [
|
|
165
166
|
{ name: 'All' },
|
|
@@ -717,8 +718,12 @@ class BaseControlComponent {
|
|
|
717
718
|
return this.record[this.attributeModel.name];
|
|
718
719
|
}
|
|
719
720
|
checkUnsavedChanges() {
|
|
721
|
+
console.log("1=> initialRecord", this.initialRecord);
|
|
722
|
+
console.log("2=> Record", this.record);
|
|
720
723
|
const sanitizedInitialRecord = this.normalizeRecord(this.initialRecord);
|
|
721
724
|
const sanitizedCurrentRecord = this.normalizeRecord(this.record);
|
|
725
|
+
console.log("3=> currentRecord", sanitizedCurrentRecord);
|
|
726
|
+
console.log("4=> Initial Record", sanitizedInitialRecord);
|
|
722
727
|
const hasChanges = JSON.stringify(sanitizedInitialRecord) !== JSON.stringify(sanitizedCurrentRecord);
|
|
723
728
|
this.formStateService.selectIsFormSaved().subscribe((res) => {
|
|
724
729
|
if (res) {
|
|
@@ -726,9 +731,11 @@ class BaseControlComponent {
|
|
|
726
731
|
}
|
|
727
732
|
else {
|
|
728
733
|
if (!res && hasChanges) {
|
|
734
|
+
console.log("hasChange");
|
|
729
735
|
this.formStateService.setShowConfirmation(true);
|
|
730
736
|
}
|
|
731
737
|
if (!res && !hasChanges) {
|
|
738
|
+
console.log("No hasChange");
|
|
732
739
|
this.formStateService.setShowConfirmation(false);
|
|
733
740
|
}
|
|
734
741
|
}
|
|
@@ -1331,7 +1338,6 @@ class BaseFormComponent {
|
|
|
1331
1338
|
onSave = new EventEmitter();
|
|
1332
1339
|
onFormNavigate = new EventEmitter();
|
|
1333
1340
|
onCancel = new EventEmitter();
|
|
1334
|
-
isConfirmDialogOpen = false;
|
|
1335
1341
|
constructor(formStateService, service, validatorService, router, activatedRoute, baseStore, baseQuery) {
|
|
1336
1342
|
this.formStateService = formStateService;
|
|
1337
1343
|
this.service = service;
|
|
@@ -1359,31 +1365,13 @@ class BaseFormComponent {
|
|
|
1359
1365
|
this.recordChange.next(res);
|
|
1360
1366
|
});
|
|
1361
1367
|
}
|
|
1362
|
-
window.addEventListener('beforeunload', this.beforeUnloadHandler);
|
|
1363
1368
|
}
|
|
1364
|
-
|
|
1369
|
+
handleBeforeUnload(event) {
|
|
1365
1370
|
this.formStateService.setIsFormNavigating(true);
|
|
1366
1371
|
this.formStateService.selectShowConfirmation().subscribe((showConfirmation) => {
|
|
1367
1372
|
if (showConfirmation) {
|
|
1368
1373
|
event.preventDefault();
|
|
1369
|
-
event.returnValue =
|
|
1370
|
-
this.showPrimeNgConfirm();
|
|
1371
|
-
return event.returnValue;
|
|
1372
|
-
}
|
|
1373
|
-
});
|
|
1374
|
-
};
|
|
1375
|
-
showPrimeNgConfirm() {
|
|
1376
|
-
this.confirmationService.confirm({
|
|
1377
|
-
message: 'You have unsaved changes! Do you really want to leave?',
|
|
1378
|
-
header: 'Confirm Navigation',
|
|
1379
|
-
icon: 'pi pi-exclamation-triangle',
|
|
1380
|
-
accept: () => {
|
|
1381
|
-
this.isConfirmDialogOpen = false;
|
|
1382
|
-
window.removeEventListener('beforeunload', this.beforeUnloadHandler); // Allow browser navigation
|
|
1383
|
-
window.location.href = window.location.href;
|
|
1384
|
-
},
|
|
1385
|
-
reject: () => {
|
|
1386
|
-
this.isConfirmDialogOpen = false;
|
|
1374
|
+
event.returnValue = SHARED.BROWSER_WARNING;
|
|
1387
1375
|
}
|
|
1388
1376
|
});
|
|
1389
1377
|
}
|
|
@@ -1489,7 +1477,7 @@ class BaseFormComponent {
|
|
|
1489
1477
|
this.formStateService.setIsFormSaved(false);
|
|
1490
1478
|
}
|
|
1491
1479
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.4", ngImport: i0, type: BaseFormComponent, deps: [{ token: FormStateService }, { token: BaseService }, { token: ValidatorService }, { token: i4$3.Router }, { token: i4$3.ActivatedRoute }, { token: BaseStore }, { token: BaseQuery }], target: i0.ɵɵFactoryTarget.Component });
|
|
1492
|
-
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "19.0.4", type: BaseFormComponent, isStandalone: true, selector: "base-form", outputs: { onSave: "onSave", onFormNavigate: "onFormNavigate", onCancel: "onCancel" }, providers: [ValidatorService, ConfirmationService], ngImport: i0, template: "<p>base-form works!</p>\r\n", styles: [""] });
|
|
1480
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "19.0.4", type: BaseFormComponent, isStandalone: true, selector: "base-form", outputs: { onSave: "onSave", onFormNavigate: "onFormNavigate", onCancel: "onCancel" }, host: { listeners: { "window:beforeunload": "handleBeforeUnload($event)" } }, providers: [ValidatorService, ConfirmationService], ngImport: i0, template: "<p>base-form works!</p>\r\n", styles: [""] });
|
|
1493
1481
|
}
|
|
1494
1482
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.4", ngImport: i0, type: BaseFormComponent, decorators: [{
|
|
1495
1483
|
type: Component,
|
|
@@ -1500,6 +1488,9 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.4", ngImpor
|
|
|
1500
1488
|
type: Output
|
|
1501
1489
|
}], onCancel: [{
|
|
1502
1490
|
type: Output
|
|
1491
|
+
}], handleBeforeUnload: [{
|
|
1492
|
+
type: HostListener,
|
|
1493
|
+
args: ['window:beforeunload', ['$event']]
|
|
1503
1494
|
}] } });
|
|
1504
1495
|
|
|
1505
1496
|
class DateParserService {
|