@pega/angular-sdk-overrides 0.23.11 → 0.23.12

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,8 +1,10 @@
1
- import { Component, OnInit, Input, Output, EventEmitter, forwardRef, OnChanges } from '@angular/core';
1
+ import { Component, OnInit, Input, Output, EventEmitter, forwardRef, OnChanges, OnDestroy } from '@angular/core';
2
2
  import { CommonModule } from '@angular/common';
3
3
  import { FormGroup, ReactiveFormsModule } from '@angular/forms';
4
4
  import { ReferenceComponent } from '@pega/angular-sdk-components';
5
5
  import { ComponentMapperComponent } from '@pega/angular-sdk-components';
6
+ import { IdleDetectionService } from '@pega/angular-sdk-components';
7
+ import { ServerConfigService } from '@pega/angular-sdk-components';
6
8
 
7
9
  @Component({
8
10
  selector: 'app-assignment-card',
@@ -11,7 +13,7 @@ import { ComponentMapperComponent } from '@pega/angular-sdk-components';
11
13
  standalone: true,
12
14
  imports: [CommonModule, ReactiveFormsModule, forwardRef(() => ComponentMapperComponent)]
13
15
  })
14
- export class AssignmentCardComponent implements OnInit, OnChanges {
16
+ export class AssignmentCardComponent implements OnInit, OnChanges, OnDestroy {
15
17
  @Input() pConn$: typeof PConnect;
16
18
  @Input() formGroup$: FormGroup;
17
19
  @Input() arMainButtons$: any[];
@@ -21,19 +23,44 @@ export class AssignmentCardComponent implements OnInit, OnChanges {
21
23
 
22
24
  @Output() actionButtonClick: EventEmitter<any> = new EventEmitter();
23
25
 
26
+ constructor(
27
+ private idleService: IdleDetectionService,
28
+ private scservice: ServerConfigService
29
+ ) {}
30
+
24
31
  ngOnInit(): void {
25
- // Children may contain 'reference' component, so we need to
26
- // normalize them
32
+ // Children may contain 'reference' component, so we need to normalize them
27
33
  this.arChildren$ = ReferenceComponent.normalizePConnArray(this.arChildren$);
34
+
35
+ this.checkAndEnableAutoSave();
28
36
  }
29
37
 
30
38
  ngOnChanges() {
31
- // Children may contain 'reference' component, so we need to
32
- // normalize them
39
+ // Children may contain 'reference' component, so we need to normalize them
33
40
  this.arChildren$ = ReferenceComponent.normalizePConnArray(this.arChildren$);
34
41
  }
35
42
 
43
+ ngOnDestroy() {
44
+ this.idleService.stopWatching();
45
+ }
46
+
47
+ async checkAndEnableAutoSave() {
48
+ const sdkConfig = await this.scservice.getSdkConfig();
49
+ const autoSave = sdkConfig.serverConfig.autoSave;
50
+
51
+ if (autoSave) {
52
+ this.idleService.startWatching(() => this.autoSave(), autoSave);
53
+ }
54
+ }
55
+
36
56
  onActionButtonClick(oData: any) {
37
57
  this.actionButtonClick.emit(oData);
38
58
  }
59
+
60
+ autoSave() {
61
+ const context = this.pConn$.getContextName();
62
+ if (PCore.getFormUtils().isStateModified(context)) {
63
+ this.pConn$.getActionsApi().saveAssignment(context);
64
+ }
65
+ }
39
66
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pega/angular-sdk-overrides",
3
- "version": "0.23.11",
3
+ "version": "0.23.12",
4
4
  "description": "Angular SDK - Code for overriding components",
5
5
  "scripts": {
6
6
  "test": "echo \"Error: no test specified\" && exit 1"