@pega/angular-sdk-overrides 24.2.10 → 24.2.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.
Files changed (75) hide show
  1. package/lib/designSystemExtension/material-case-summary/material-case-summary.component.ts +0 -1
  2. package/lib/designSystemExtension/material-details-fields/material-details-fields.component.html +1 -1
  3. package/lib/designSystemExtension/material-details-fields/material-details-fields.component.ts +6 -0
  4. package/lib/designSystemExtension/operator/operator.component.html +1 -1
  5. package/lib/designSystemExtension/operator/operator.component.scss +10 -2
  6. package/lib/designSystemExtension/operator/operator.component.ts +4 -3
  7. package/lib/field/auto-complete/auto-complete.component.html +0 -1
  8. package/lib/field/auto-complete/auto-complete.component.ts +15 -2
  9. package/lib/field/check-box/check-box.component.html +4 -0
  10. package/lib/field/currency/currency.component.ts +19 -13
  11. package/lib/field/date/date.component.html +2 -1
  12. package/lib/field/date-time/date-time.component.html +2 -2
  13. package/lib/field/date-time/date-time.component.ts +17 -3
  14. package/lib/field/decimal/decimal.component.html +1 -0
  15. package/lib/field/decimal/decimal.component.ts +38 -15
  16. package/lib/field/dropdown/dropdown.component.html +1 -0
  17. package/lib/field/dropdown/dropdown.component.ts +18 -4
  18. package/lib/field/email/email.component.ts +17 -7
  19. package/lib/field/integer/integer.component.html +1 -1
  20. package/lib/field/integer/integer.component.ts +16 -6
  21. package/lib/field/list-view-action-buttons/list-view-action-buttons.component.html +1 -1
  22. package/lib/field/list-view-action-buttons/list-view-action-buttons.component.ts +3 -2
  23. package/lib/field/percentage/percentage.component.html +1 -1
  24. package/lib/field/percentage/percentage.component.ts +27 -17
  25. package/lib/field/phone/config-ext.json +1 -1
  26. package/lib/field/phone/phone.component.html +3 -1
  27. package/lib/field/phone/phone.component.ts +6 -13
  28. package/lib/field/radio-buttons/radio-buttons.component.html +3 -6
  29. package/lib/field/rich-text/rich-text.component.ts +12 -3
  30. package/lib/field/text/text.component.ts +6 -4
  31. package/lib/field/text-area/text-area.component.html +4 -2
  32. package/lib/field/text-area/text-area.component.ts +16 -6
  33. package/lib/field/text-input/text-input.component.html +1 -1
  34. package/lib/field/text-input/text-input.component.ts +16 -6
  35. package/lib/field/time/time.component.html +2 -2
  36. package/lib/field/time/time.component.ts +21 -6
  37. package/lib/field/url/url.component.html +1 -1
  38. package/lib/field/url/url.component.ts +16 -6
  39. package/lib/field/user-reference/user-reference.component.html +40 -38
  40. package/lib/field/user-reference/user-reference.component.ts +70 -7
  41. package/lib/infra/Containers/flow-container/flow-container.component.ts +17 -43
  42. package/lib/infra/Containers/flow-container/helpers.ts +2 -2
  43. package/lib/infra/Containers/modal-view-container/modal-view-container.component.html +1 -11
  44. package/lib/infra/Containers/modal-view-container/modal-view-container.component.ts +0 -7
  45. package/lib/infra/action-buttons/action-buttons.component.html +1 -1
  46. package/lib/infra/assignment/assignment.component.html +1 -1
  47. package/lib/infra/assignment/assignment.component.ts +82 -39
  48. package/lib/infra/assignment-card/assignment-card.component.html +1 -0
  49. package/lib/infra/defer-load/defer-load.component.ts +4 -1
  50. package/lib/infra/navbar/navbar.component.ts +0 -2
  51. package/lib/infra/reference/reference.component.ts +77 -90
  52. package/lib/infra/root-container/root-container.component.html +2 -15
  53. package/lib/infra/root-container/root-container.component.ts +24 -27
  54. package/lib/template/base/form-template-base.ts +6 -0
  55. package/lib/template/confirmation/confirmation.component.html +1 -1
  56. package/lib/template/default-form/default-form.component.ts +35 -2
  57. package/lib/template/field-group-template/field-group-template.component.html +7 -7
  58. package/lib/template/field-group-template/field-group-template.component.scss +8 -0
  59. package/lib/template/field-group-template/field-group-template.component.ts +64 -41
  60. package/lib/template/field-value-list/field-value-list.component.html +2 -2
  61. package/lib/template/field-value-list/field-value-list.component.scss +4 -0
  62. package/lib/template/list-view/list-view.component.html +3 -1
  63. package/lib/template/list-view/list-view.component.ts +1 -3
  64. package/lib/template/list-view/listViewHelpers.ts +2 -5
  65. package/lib/template/list-view/utils.ts +2 -5
  66. package/lib/template/simple-table-manual/helpers.ts +9 -7
  67. package/lib/template/simple-table-manual/simple-table-manual.component.html +25 -6
  68. package/lib/template/simple-table-manual/simple-table-manual.component.scss +11 -3
  69. package/lib/template/simple-table-manual/simple-table-manual.component.ts +62 -24
  70. package/lib/template/utils.ts +16 -0
  71. package/lib/widget/feed-container/feed-container.component.ts +0 -2
  72. package/lib/widget/todo/todo.component.html +4 -5
  73. package/lib/widget/todo/todo.component.scss +9 -0
  74. package/lib/widget/todo/todo.component.ts +4 -3
  75. package/package.json +1 -1
@@ -1,4 +1,4 @@
1
- import { Component, OnInit, Input, forwardRef, OnDestroy, OnChanges } from '@angular/core';
1
+ import { Component, OnInit, Input, forwardRef, OnDestroy, OnChanges, AfterViewInit } from '@angular/core';
2
2
  import { CommonModule } from '@angular/common';
3
3
  import { FormGroup } from '@angular/forms';
4
4
  import { MatButtonModule } from '@angular/material/button';
@@ -6,11 +6,14 @@ import { AngularPConnectData, AngularPConnectService } from '@pega/angular-sdk-c
6
6
  import { buildView, getReferenceList } from '@pega/angular-sdk-components';
7
7
  import { Utils } from '@pega/angular-sdk-components';
8
8
  import { ComponentMapperComponent } from '@pega/angular-sdk-components';
9
+ import { evaluateAllowRowAction } from '@pega/angular-sdk-components';
9
10
 
10
11
  interface FieldGroupTemplateProps {
11
12
  // If any, enter additional props that only exist on this component
12
13
  label?: string;
13
- showLabel?: boolean;
14
+ hideLabel?: boolean;
15
+ allowActions?: any;
16
+ allowRowDelete?: any;
14
17
  referenceList?: any[];
15
18
  contextClass: string;
16
19
  renderMode?: string;
@@ -19,6 +22,7 @@ interface FieldGroupTemplateProps {
19
22
  displayMode?: string;
20
23
  fieldHeader?: string;
21
24
  allowTableEdit: boolean;
25
+ targetClassLabel?: string;
22
26
  }
23
27
 
24
28
  @Component({
@@ -28,26 +32,27 @@ interface FieldGroupTemplateProps {
28
32
  standalone: true,
29
33
  imports: [CommonModule, MatButtonModule, forwardRef(() => ComponentMapperComponent)]
30
34
  })
31
- export class FieldGroupTemplateComponent implements OnInit, OnDestroy, OnChanges {
35
+ export class FieldGroupTemplateComponent implements OnInit, OnDestroy, OnChanges, AfterViewInit {
32
36
  @Input() configProps$: FieldGroupTemplateProps;
33
37
  @Input() pConn$: typeof PConnect;
34
38
  @Input() formGroup$: FormGroup;
35
39
 
36
40
  angularPConnectData: AngularPConnectData = {};
37
- inheritedProps$: object;
41
+
38
42
  showLabel$?: boolean = true;
39
43
  label$?: string;
40
44
  readonlyMode: boolean;
41
45
  contextClass: any;
42
- referenceList: any;
43
- pageReference: any;
44
46
  heading: any;
45
47
  children: any;
46
48
  menuIconOverride$: any;
47
- prevRefLength: number;
48
- allowAddEdit: boolean;
49
+ referenceListLength: number;
49
50
  fieldHeader: any;
50
51
 
52
+ allowAdd = true;
53
+ allowEdit = true;
54
+ allowDelete = true;
55
+
51
56
  constructor(
52
57
  private angularPConnect: AngularPConnectService,
53
58
  private utils: Utils
@@ -58,9 +63,21 @@ export class FieldGroupTemplateComponent implements OnInit, OnDestroy, OnChanges
58
63
  this.angularPConnectData = this.angularPConnect.registerAndSubscribeComponent(this, this.onStateChange);
59
64
  this.updateSelf();
60
65
 
61
- const menuIconOverride$ = 'trash';
62
- if (menuIconOverride$) {
63
- this.menuIconOverride$ = this.utils.getImageSrc(menuIconOverride$, this.utils.getSDKStaticContentUrl());
66
+ this.menuIconOverride$ = this.utils.getImageSrc('trash', this.utils.getSDKStaticContentUrl());
67
+
68
+ const { allowActions, allowTableEdit, referenceList } = this.configProps$;
69
+
70
+ if (allowActions && Object.keys(allowActions).length > 0) {
71
+ this.allowAdd = allowActions.allowAdd ?? allowTableEdit ?? true;
72
+ this.allowEdit = allowActions.allowEdit ?? true;
73
+ this.allowDelete = allowActions.allowDelete ?? allowTableEdit ?? true;
74
+ } else {
75
+ this.allowAdd = allowTableEdit ?? true;
76
+ this.allowDelete = allowTableEdit ?? true;
77
+ }
78
+
79
+ if (referenceList?.length === 0 && (this.allowAdd || this.allowEdit)) {
80
+ this.pConn$.getListActions().insert({ classID: this.contextClass }, referenceList.length);
64
81
  }
65
82
  }
66
83
 
@@ -85,56 +102,57 @@ export class FieldGroupTemplateComponent implements OnInit, OnDestroy, OnChanges
85
102
  const props = changes.configProps$;
86
103
  if (props.currentValue !== props.previousValue) {
87
104
  this.configProps$ = props.currentValue;
105
+
88
106
  if (changes?.pConn$?.currentValue) {
89
107
  this.pConn$ = changes?.pConn$?.currentValue;
90
108
  }
109
+
91
110
  this.updateSelf();
92
111
  }
93
112
  }
94
113
  }
95
114
 
115
+ ngAfterViewInit() {
116
+ const resolvedList = getReferenceList(this.pConn$);
117
+ // @ts-ignore - Expected 3 arguments, but got 1
118
+ this.pConn$.getListActions().initDefaultPageInstructions(resolvedList);
119
+ }
120
+
96
121
  updateSelf() {
97
- this.inheritedProps$ = this.pConn$.getInheritedProps();
98
- this.label$ = this.configProps$.label;
99
- this.showLabel$ = this.configProps$.showLabel;
100
- // label & showLabel within inheritedProps takes precedence over configProps
101
- this.label$ = (this.inheritedProps$ as any).label || this.label$;
102
- this.showLabel$ = (this.inheritedProps$ as any).showLabel || this.showLabel$;
122
+ const inheritedProps: any = this.pConn$.getInheritedProps();
103
123
 
104
- this.allowAddEdit = this.configProps$.allowTableEdit;
124
+ const { label, hideLabel, allowRowDelete, referenceList, fieldHeader, renderMode, displayMode, heading, contextClass, lookForChildInConfig } =
125
+ this.configProps$;
126
+
127
+ // label within inheritedProps takes precedence over configProps
128
+ this.label$ = inheritedProps.label || label;
129
+
130
+ this.showLabel$ = referenceList?.length === 0 || !hideLabel;
105
131
 
106
- const renderMode = this.configProps$.renderMode;
107
- const displayMode = this.configProps$.displayMode;
108
132
  this.readonlyMode = renderMode === 'ReadOnly' || displayMode === 'DISPLAY_ONLY';
109
- this.contextClass = this.configProps$.contextClass;
110
- const lookForChildInConfig = this.configProps$.lookForChildInConfig;
111
- this.heading = this.configProps$.heading ?? 'Row';
112
- this.fieldHeader = this.configProps$.fieldHeader;
133
+
134
+ this.contextClass = contextClass;
135
+ this.heading = heading ?? 'Row';
136
+ this.fieldHeader = fieldHeader;
137
+
113
138
  const resolvedList = getReferenceList(this.pConn$);
114
- this.pageReference = `${this.pConn$.getPageReference()}${resolvedList}`;
115
139
  this.pConn$.setReferenceList(resolvedList);
140
+
116
141
  if (this.readonlyMode) {
117
142
  this.pConn$.setInheritedProp('displayMode', 'DISPLAY_ONLY');
118
143
  }
119
- this.referenceList = this.configProps$.referenceList;
120
- if (this.prevRefLength != this.referenceList.length) {
121
- // eslint-disable-next-line sonarjs/no-collapsible-if
122
- if (!this.readonlyMode) {
123
- if (this.referenceList?.length === 0 && this.allowAddEdit !== false) {
124
- this.addFieldGroupItem();
125
- }
126
- }
127
- const children: any = [];
128
- this.referenceList?.forEach((item, index) => {
129
- children.push({
144
+
145
+ if (this.referenceListLength != referenceList?.length) {
146
+ this.children = referenceList?.map((item, index) => {
147
+ return {
130
148
  id: index,
131
149
  name: this.fieldHeader === 'propertyRef' ? this.getDynamicHeader(item, index) : this.getStaticHeader(this.heading, index),
132
- children: buildView(this.pConn$, index, lookForChildInConfig)
133
- });
150
+ children: buildView(this.pConn$, index, lookForChildInConfig),
151
+ allowRowDelete: evaluateAllowRowAction(allowRowDelete, item)
152
+ };
134
153
  });
135
- this.children = children;
136
154
  }
137
- this.prevRefLength = this.referenceList.length;
155
+ this.referenceListLength = referenceList?.length || 0;
138
156
  }
139
157
 
140
158
  getStaticHeader = (heading, index) => {
@@ -149,10 +167,15 @@ export class FieldGroupTemplateComponent implements OnInit, OnDestroy, OnChanges
149
167
  };
150
168
 
151
169
  addFieldGroupItem() {
152
- this.pConn$.getListActions().insert({ classID: this.contextClass }, this.referenceList.length);
170
+ this.pConn$.getListActions().insert({ classID: this.contextClass }, this.referenceListLength);
153
171
  }
154
172
 
155
173
  deleteFieldGroupItem(index) {
156
174
  this.pConn$.getListActions().deleteEntry(index);
157
175
  }
176
+
177
+ getAddBtnLabel() {
178
+ const { targetClassLabel } = this.configProps$;
179
+ return targetClassLabel ? `+ Add ${targetClassLabel}` : '+ Add';
180
+ }
158
181
  }
@@ -1,5 +1,5 @@
1
- <div *ngIf="displayMode$ === 'DISPLAY_ONLY'; else STACKED_LARGE_VAL" class="psdk-container-labels-left">
2
- <div class="psdk-grid-label">{{ label$ }}</div>
1
+ <div *ngIf="displayMode$ === 'DISPLAY_ONLY'; else STACKED_LARGE_VAL" [ngClass]="label$ ? 'psdk-container-labels-left' : 'psdk-container-nolabels'">
2
+ <div *ngIf="label$" class="psdk-grid-label">{{ label$ }}</div>
3
3
  <div class="psdk-val-labels-left">
4
4
  <ng-container *ngTemplateOutlet="valueTemplate"></ng-container>
5
5
  </div>
@@ -6,6 +6,10 @@
6
6
  align-items: start;
7
7
  padding-block: 8px;
8
8
  }
9
+ .psdk-container-nolabels {
10
+ align-items: start;
11
+ padding-block: 8px;
12
+ }
9
13
  .psdk-value {
10
14
  margin: 8px 0px;
11
15
  }
@@ -180,7 +180,9 @@
180
180
  <tr mat-header-row *matHeaderRowDef="displayedColumns$"></tr>
181
181
  </table>
182
182
  </div>
183
- <div class="psdk-no-records" *ngIf="repeatListData?.length === 0">No Records Found.</div>
183
+ <div class="psdk-no-records" *ngIf="repeatListData?.length === 0">
184
+ {{ utils.getGenericFieldsLocalizedValue('CosmosFields.fields.lists', 'No records found.') }}
185
+ </div>
184
186
  </div>
185
187
  </div>
186
188
  </div>
@@ -23,8 +23,6 @@ import { formatters } from '@pega/angular-sdk-components';
23
23
 
24
24
  import { init } from './listViewHelpers';
25
25
 
26
- declare const window: any;
27
-
28
26
  const SELECTION_MODE = { SINGLE: 'single', MULTI: 'multi' };
29
27
 
30
28
  interface ListViewProps {
@@ -165,7 +163,7 @@ export class ListViewComponent implements OnInit, OnDestroy {
165
163
 
166
164
  constructor(
167
165
  private psService: ProgressSpinnerService,
168
- private utils: Utils
166
+ public utils: Utils
169
167
  ) {}
170
168
 
171
169
  ngOnInit(): void {
@@ -1,8 +1,5 @@
1
1
  import { getContext, readContextResponse } from './utils';
2
2
 
3
- // Remove this and use "real" PCore type once .d.ts is fixed (currently shows 1 error)
4
- declare const PCore: any;
5
-
6
3
  export function init(props) {
7
4
  const {
8
5
  referenceList,
@@ -25,9 +22,9 @@ export function init(props) {
25
22
  let selectionCountThreshold;
26
23
 
27
24
  // promise to fetch metadata
28
- const metaDataPromise = PCore.getAnalyticsUtils().getDataViewMetadata(referenceList, showDynamicFields);
25
+ const metaDataPromise = PCore.getAnalyticsUtils().getDataViewMetadata(referenceList, showDynamicFields, null);
29
26
 
30
- const promisesArray = [metaDataPromise];
27
+ const promisesArray: any = [metaDataPromise];
31
28
 
32
29
  // promise to fetch report configured columns
33
30
  const reportColumnsPromise = PCore.getAnalyticsUtils()
@@ -1,8 +1,5 @@
1
1
  import { getDefaultViewMeta } from './DefaultViewMeta';
2
2
 
3
- // Remove this and use "real" PCore type once .d.ts is fixed (currently shows 5 errors)
4
- declare const PCore: any;
5
-
6
3
  const USER_REFERENCE = 'UserReference';
7
4
  const PAGE = '!P!';
8
5
  const PAGELIST = '!PL!';
@@ -121,7 +118,7 @@ export const isPageListInPath = (propertyName, currentClassID) => {
121
118
  return false;
122
119
  }
123
120
  const [first, ...rest] = propertyName.split('.');
124
- const metadata = PCore.getMetadataUtils().getPropertyMetadata(first, currentClassID);
121
+ const metadata: any = PCore.getMetadataUtils().getPropertyMetadata(first, currentClassID);
125
122
  if (metadata?.type === 'Page List') {
126
123
  return true;
127
124
  }
@@ -205,7 +202,7 @@ export function getConfigEmbeddedFieldsMeta(configFields, classID) {
205
202
  if (value.includes('[')) {
206
203
  value = value.substring(0, value.indexOf('[')) + value.substring(value.indexOf(']') + 1);
207
204
  }
208
- const meta = PCore.getMetadataUtils().getEmbeddedPropertyMetadata(value, classID);
205
+ const meta: any = PCore.getMetadataUtils().getEmbeddedPropertyMetadata(value, classID);
209
206
  meta.fieldID = field;
210
207
  configEmbeddedFieldsMeta.push(meta);
211
208
  }
@@ -44,18 +44,20 @@ function getFieldWidth(field, label) {
44
44
  export const getContext = thePConn => {
45
45
  const contextName = thePConn.getContextName();
46
46
  const pageReference = thePConn.getPageReference();
47
- // 8.7 change = referenceList may now be in top-level of state props,
48
- // not always in config of state props
49
- let { referenceList } = thePConn.getStateProps()?.config || thePConn.getStateProps();
47
+ const { readonlyContextList, referenceList = readonlyContextList } = thePConn.getStateProps()?.config || thePConn.getStateProps();
48
+
50
49
  const pageReferenceForRows = referenceList.startsWith('.') ? `${pageReference}.${referenceList.substring(1)}` : referenceList;
50
+ const viewName = thePConn.viewName;
51
51
 
52
52
  // removing "caseInfo.content" prefix to avoid setting it as a target while preparing pageInstructions
53
- referenceList = pageReferenceForRows.replace(PCore.getConstants().CASE_INFO.CASE_INFO_CONTENT, '');
53
+ // skipping the removal as StateMachine itself is removing this case info prefix while preparing pageInstructions
54
+ // referenceList = pageReferenceForRows.replace(PCore.getConstants().CASE_INFO.CASE_INFO_CONTENT, '');
54
55
 
55
56
  return {
56
57
  contextName,
57
58
  referenceListStr: referenceList,
58
- pageReferenceForRows
59
+ pageReferenceForRows,
60
+ viewName
59
61
  };
60
62
  };
61
63
 
@@ -189,7 +191,7 @@ export const createMetaForTable = (fields, renderMode) => {
189
191
  };
190
192
 
191
193
  export const filterDataByDate = (item, filterObj) => {
192
- let bKeep;
194
+ let bKeep = true;
193
195
  let value = item[filterObj.ref] != null || item[filterObj.ref] != '' ? getSeconds(item[filterObj.ref]) : null;
194
196
  let filterValue = filterObj.containsFilterValue != null && filterObj.containsFilterValue != '' ? getSeconds(filterObj.containsFilterValue) : null;
195
197
 
@@ -237,7 +239,7 @@ export const filterDataByDate = (item, filterObj) => {
237
239
  };
238
240
 
239
241
  export const filterDataByCommonFields = (item, filterObj) => {
240
- let bKeep;
242
+ let bKeep = true;
241
243
  const value = item[filterObj.ref].toLowerCase();
242
244
  const filterValue = filterObj.containsFilterValue.toLowerCase();
243
245
 
@@ -3,8 +3,8 @@
3
3
  <h3 *ngIf="label" className="label" style="font-weight: bold">
4
4
  {{ label }} <span class="results-count">{{ getResultsText() }}</span>
5
5
  </h3>
6
- <table *ngIf="readOnlyMode || allowEditingInModal" mat-table [dataSource]="rowData" class="mat-elevation-z8" id="readonly-table" matSort>
7
- <ng-container *ngFor="let dCol of processedFields" [matColumnDef]="dCol.config.name">
6
+ <table *ngIf="readOnlyMode || allowEditingInModal" mat-table [dataSource]="elementsData" class="mat-elevation-z8" id="readonly-table" matSort>
7
+ <ng-container *ngFor="let dCol of processedFields; let i = index" [matColumnDef]="dCol.config.name">
8
8
  <th mat-header-cell *matHeaderCellDef mat-sort-header (click)="_headerSortClick($event, dCol)" arrowPosition="before">
9
9
  <div>{{ dCol.config.label }}</div>
10
10
  <div class="psdk-mat-header-filter">
@@ -27,7 +27,16 @@
27
27
  </mat-menu>
28
28
  </div>
29
29
  </th>
30
- <td mat-cell *matCellDef="let element">{{ element[dCol.config.name] || '---' }}</td>
30
+ <td mat-cell *matCellDef="let element">
31
+ <component-mapper
32
+ [name]="element[i].getPConnect().getComponentName()"
33
+ [props]="{
34
+ pConn$: element[i].getPConnect(),
35
+ formGroup$: formGroup$
36
+ }"
37
+ errorMsg="Table wants component not yet available: {{ element[i].getPConnect().getComponentName() }}"
38
+ ></component-mapper>
39
+ </td>
31
40
  </ng-container>
32
41
  <ng-container matColumnDef="DeleteIcon">
33
42
  <div *ngIf="allowEditingInModal">
@@ -47,6 +56,11 @@
47
56
  </ng-container>
48
57
  <tr mat-header-row *matHeaderRowDef="displayedColumns"></tr>
49
58
  <tr mat-row *matRowDef="let row; columns: displayedColumns"></tr>
59
+ <tr class="mat-row psdk-no-records" *matNoDataRow>
60
+ <td id="no-records" class="mat-cell" [attr.colspan]="displayedColumns.length">
61
+ {{ utils.getGenericFieldsLocalizedValue('CosmosFields.fields.lists', 'No records found.') }}
62
+ </td>
63
+ </tr>
50
64
  </table>
51
65
  <table *ngIf="editableMode && !allowEditingInModal" mat-table [dataSource]="elementsData" class="mat-elevation-z8" id="editable-table">
52
66
  <ng-container *ngFor="let dCol of fieldDefs; let i = index">
@@ -74,11 +88,16 @@
74
88
  </ng-container>
75
89
  <tr mat-header-row *matHeaderRowDef="displayedColumns"></tr>
76
90
  <tr mat-row *matRowDef="let row; columns: displayedColumns"></tr>
91
+ <tr class="mat-row psdk-no-records" *matNoDataRow>
92
+ <td id="no-records" class="mat-cell" [attr.colspan]="displayedColumns.length">
93
+ {{ utils.getGenericFieldsLocalizedValue('CosmosFields.fields.lists', 'No records found.') }}
94
+ </td>
95
+ </tr>
77
96
  </table>
78
- <div class="psdk-no-records" id="no-records" *ngIf="editableMode && referenceList?.length === 0">No Records Found.</div>
79
- <div class="psdk-no-records" id="no-records" *ngIf="readOnlyMode && rowData?.data?.length === 0">No Records Found.</div>
80
97
  </div>
81
- <button *ngIf="showAddRowButton" mat-button color="primary" style="font-size: 16px" (click)="addRecord()">+ Add</button>
98
+ <button *ngIf="showAddRowButton" mat-button color="primary" style="font-size: 16px" (click)="addRecord()">
99
+ + {{ localizedVal('Add', localeCategory) }}
100
+ </button>
82
101
  </ng-container>
83
102
 
84
103
  <!-- pop overs for filters-->
@@ -5,6 +5,10 @@
5
5
  margin-top: 0.5rem;
6
6
  margin-bottom: 0.5rem;
7
7
  overflow-y: auto;
8
+ box-shadow:
9
+ 0px 2px 1px -1px rgba(0, 0, 0, 0.2),
10
+ 0px 1px 1px 0px rgba(0, 0, 0, 0.14),
11
+ 0px 1px 3px 0px rgba(0, 0, 0, 0.12);
8
12
  }
9
13
 
10
14
  table {
@@ -24,6 +28,12 @@ td.mat-mdc-cell,
24
28
  td.mat-mdc-footer-cell {
25
29
  border-right: 1px solid var(--app-neutral-light-color);
26
30
  padding: 8px !important;
31
+ min-width: 10rem;
32
+ }
33
+
34
+ ::ng-deep th.mat-mdc-header-cell:last-child,
35
+ td.mat-mdc-cell:last-child {
36
+ min-width: 2rem;
27
37
  }
28
38
 
29
39
  ::ng-deep .mat-mdc-button {
@@ -160,9 +170,7 @@ tr.mat-mdc-header-row {
160
170
 
161
171
  .psdk-no-records {
162
172
  height: 56px;
163
- justify-content: center;
164
- display: flex;
165
- align-items: center;
173
+ text-align: center;
166
174
  border: 1px solid var(--app-neutral-light-color);
167
175
  border-top: none;
168
176
  background: var(--app-form-color);
@@ -1,4 +1,3 @@
1
- /* eslint-disable max-classes-per-file */
2
1
  import { Component, OnInit, Input, ViewChild, forwardRef, OnDestroy } from '@angular/core';
3
2
  import { CommonModule } from '@angular/common';
4
3
  import { FormGroup } from '@angular/forms';
@@ -18,11 +17,10 @@ import { AngularPConnectData, AngularPConnectService } from '@pega/angular-sdk-c
18
17
  import { DatapageService } from '@pega/angular-sdk-components';
19
18
  import { getReferenceList } from '@pega/angular-sdk-components';
20
19
  import { buildFieldsForTable, filterDataByCommonFields, filterDataByDate, getContext } from './helpers';
20
+ import { evaluateAllowRowAction } from '@pega/angular-sdk-components';
21
21
  import { Utils } from '@pega/angular-sdk-components';
22
22
  import { getSeconds } from '@pega/angular-sdk-components';
23
23
 
24
- declare const window: any;
25
-
26
24
  interface SimpleTableManualProps {
27
25
  // If any, enter additional props that only exist on this component
28
26
  visibility?: boolean;
@@ -37,7 +35,9 @@ interface SimpleTableManualProps {
37
35
  contextClass?: string;
38
36
  propertyLabel?: string;
39
37
  fieldMetadata?: any;
38
+ allowActions?: any;
40
39
  allowTableEdit?: boolean;
40
+ allowRowDelete?: any;
41
41
  editMode?: string;
42
42
  addAndEditRowsWithin?: any;
43
43
  viewForAddAndEditModal?: any;
@@ -104,6 +104,7 @@ export class SimpleTableManualComponent implements OnInit, OnDestroy {
104
104
  showAddRowButton: boolean;
105
105
  prevReferenceList: any[] = [];
106
106
  elementsData: MatTableDataSource<any>;
107
+ originalElementsData: MatTableDataSource<any>;
107
108
  rawFields: any;
108
109
  label?: string = '';
109
110
  searchIcon$: string;
@@ -160,14 +161,16 @@ export class SimpleTableManualComponent implements OnInit, OnDestroy {
160
161
 
161
162
  isInitialized = false;
162
163
  targetClassLabel: string;
163
-
164
+ localizedVal = PCore.getLocaleUtils().getLocaleValue;
165
+ localeCategory = 'SimpleTable';
164
166
  constructor(
165
167
  private angularPConnect: AngularPConnectService,
166
- private utils: Utils,
168
+ public utils: Utils,
167
169
  private dataPageService: DatapageService
168
170
  ) {}
169
171
 
170
172
  ngOnInit(): void {
173
+ this.elementsData = new MatTableDataSource<any>([]);
171
174
  this.isInitialized = true;
172
175
  // First thing in initialization is registering and subscribing to the AngularPConnect service
173
176
  this.angularPConnectData = this.angularPConnect.registerAndSubscribeComponent(this, this.onStateChange);
@@ -229,7 +232,9 @@ export class SimpleTableManualComponent implements OnInit, OnDestroy {
229
232
  renderMode,
230
233
  children, // destructure children into an array var: "resolvedFields"
231
234
  presets,
235
+ allowActions,
232
236
  allowTableEdit,
237
+ allowRowDelete,
233
238
  label: labelProp,
234
239
  propertyLabel,
235
240
  fieldMetadata,
@@ -243,12 +248,22 @@ export class SimpleTableManualComponent implements OnInit, OnDestroy {
243
248
  targetClassLabel
244
249
  } = this.configProps$;
245
250
 
251
+ const simpleTableManualProps: any = {};
252
+ if (this.checkIfAllowActionsOrRowEditingExist(allowActions) && editMode) {
253
+ simpleTableManualProps.hideAddRow = allowActions?.allowAdd === false;
254
+ simpleTableManualProps.hideDeleteRow = allowActions?.allowDelete === false;
255
+ simpleTableManualProps.hideEditRow = allowActions?.allowEdit === false;
256
+ simpleTableManualProps.disableDragDrop = allowActions?.allowDragDrop === false;
257
+ } else if (allowTableEdit === false) {
258
+ simpleTableManualProps.hideAddRow = true;
259
+ simpleTableManualProps.hideDeleteRow = true;
260
+ simpleTableManualProps.disableDragDrop = true;
261
+ }
262
+
246
263
  this.referenceListStr = getContext(this.pConn$).referenceListStr;
247
264
  this.label = labelProp || propertyLabel;
248
265
  this.parameters = fieldMetadata?.datasource?.parameters;
249
266
  this.targetClassLabel = targetClassLabel;
250
- const hideAddRow = allowTableEdit === false;
251
- const hideDeleteRow = allowTableEdit === false;
252
267
  let { contextClass } = this.configProps$;
253
268
  this.referenceList = referenceList;
254
269
  if (!contextClass) {
@@ -285,10 +300,10 @@ export class SimpleTableManualComponent implements OnInit, OnDestroy {
285
300
  this.readOnlyMode = renderMode === 'ReadOnly';
286
301
  this.editableMode = renderMode === 'Editable';
287
302
  const isDisplayModeEnabled = displayMode === 'DISPLAY_ONLY';
288
- this.showAddRowButton = !this.readOnlyMode && !hideAddRow;
303
+ this.showAddRowButton = !this.readOnlyMode && !simpleTableManualProps.hideAddRow;
289
304
  this.allowEditingInModal =
290
305
  (editMode ? editMode === 'modal' : addAndEditRowsWithin === 'modal') && !(renderMode === 'ReadOnly' || isDisplayModeEnabled);
291
- const showDeleteButton = this.editableMode && !hideDeleteRow;
306
+ const showDeleteButton = this.editableMode && !simpleTableManualProps.hideDeleteRow && evaluateAllowRowAction(allowRowDelete, this.rowData);
292
307
  this.defaultView = editModeConfig ? editModeConfig.defaultView : viewForAddAndEditModal;
293
308
  this.bUseSeparateViewForEdit = editModeConfig ? editModeConfig.useSeparateViewForEdit : useSeparateViewForEdit;
294
309
  this.editView = editModeConfig ? editModeConfig.editView : viewForEditModal;
@@ -327,7 +342,7 @@ export class SimpleTableManualComponent implements OnInit, OnDestroy {
327
342
  });
328
343
 
329
344
  // for adding rows to table when editable and not modal view
330
- if (this.prevReferenceList.length !== this.referenceList.length && this.editableMode && !this.allowEditingInModal) {
345
+ if (this.prevReferenceList.length !== this.referenceList.length) {
331
346
  this.buildElementsForTable();
332
347
  }
333
348
 
@@ -354,6 +369,10 @@ export class SimpleTableManualComponent implements OnInit, OnDestroy {
354
369
  // ties the 3 data structures together.
355
370
  }
356
371
 
372
+ checkIfAllowActionsOrRowEditingExist(newflagobject) {
373
+ return (newflagobject && Object.keys(newflagobject).length > 0) || this.pConn$.getComponentConfig().allowRowEdit;
374
+ }
375
+
357
376
  initializeDefaultPageInstructions() {
358
377
  if (this.isInitialized) {
359
378
  this.isInitialized = false;
@@ -375,8 +394,8 @@ export class SimpleTableManualComponent implements OnInit, OnDestroy {
375
394
  }
376
395
 
377
396
  sortCompare(a, b): number {
378
- let aValue = a[this.compareRef];
379
- let bValue = b[this.compareRef];
397
+ let aValue = a[0][this.compareRef];
398
+ let bValue = b[0][this.compareRef];
380
399
 
381
400
  if (this.compareType == 'Date' || this.compareType == 'DateTime') {
382
401
  aValue = getSeconds(aValue);
@@ -499,17 +518,20 @@ export class SimpleTableManualComponent implements OnInit, OnDestroy {
499
518
  // run through list of elements in path, if menu not in th path, then want to
500
519
  // hide (toggle) the menu
501
520
  const eventPath = event.path;
502
- for (let eventIndex = 0; eventIndex < eventPath.length; eventIndex++) {
503
- if (
504
- eventPath[eventIndex].className == 'psdk-modal-file-top' ||
505
- eventPath[eventIndex].tagName == 'BUTTON' ||
506
- eventPath[eventIndex].tagName == 'MAT-OPTION' ||
507
- eventPath[eventIndex].tagName == 'MAT-INPUT'
508
- ) {
509
- bInPopUp = true;
510
- break;
521
+ if (eventPath) {
522
+ for (let eventIndex = 0; eventIndex < eventPath.length; eventIndex++) {
523
+ if (
524
+ eventPath[eventIndex].className == 'psdk-modal-file-top' ||
525
+ eventPath[eventIndex].tagName == 'BUTTON' ||
526
+ eventPath[eventIndex].tagName == 'MAT-OPTION' ||
527
+ eventPath[eventIndex].tagName == 'MAT-INPUT'
528
+ ) {
529
+ bInPopUp = true;
530
+ break;
531
+ }
511
532
  }
512
533
  }
534
+
513
535
  if (!bInPopUp) {
514
536
  // this.bShowFilterPopover$ = false;
515
537
 
@@ -628,7 +650,8 @@ export class SimpleTableManualComponent implements OnInit, OnDestroy {
628
650
  }
629
651
  }
630
652
 
631
- filterData(item: any) {
653
+ filterData(element: any) {
654
+ const item = element[0];
632
655
  let bKeep = true;
633
656
  for (const filterObj of this.filterByColumns) {
634
657
  if (filterObj.containsFilterValue != '' || filterObj.containsFilter == 'null' || filterObj.containsFilter == 'notnull') {
@@ -642,6 +665,8 @@ export class SimpleTableManualComponent implements OnInit, OnDestroy {
642
665
  bKeep = filterDataByCommonFields(item, filterObj);
643
666
  break;
644
667
  }
668
+ } else if (filterObj.containsFilterValue === '') {
669
+ bKeep = true;
645
670
  }
646
671
 
647
672
  // if don't keep stop filtering
@@ -654,14 +679,22 @@ export class SimpleTableManualComponent implements OnInit, OnDestroy {
654
679
  }
655
680
 
656
681
  filterSortGroupBy() {
657
- let theData = this.originalData.slice();
682
+ let theData = this.originalData.slice().map((item, index) => {
683
+ return [item, index];
684
+ });
658
685
 
659
686
  // last filter config data is global
660
687
  theData = theData.filter(this.filterData.bind(this));
661
688
 
662
689
  // last sort config data is global
663
690
  theData.sort(this.sortCompare.bind(this));
664
- this.rowData.data = theData;
691
+ this.rowData.data = theData.map(item => item[0]);
692
+
693
+ const newElements: any = new Array(this.rowData.data.length);
694
+ theData.forEach((item, index) => {
695
+ newElements[index] = this.originalElementsData[item[1]];
696
+ });
697
+ this.elementsData = newElements;
665
698
  }
666
699
 
667
700
  _headerSortClick(event, columnData) {
@@ -960,6 +993,10 @@ export class SimpleTableManualComponent implements OnInit, OnDestroy {
960
993
  this.referenceList.forEach((element, index) => {
961
994
  const data: any = [];
962
995
  this.rawFields?.forEach(item => {
996
+ item = {
997
+ ...item,
998
+ config: { ...item.config, label: '', displayMode: this.readOnlyMode || this.allowEditingInModal ? 'DISPLAY_ONLY' : undefined }
999
+ };
963
1000
  const referenceListData = getReferenceList(this.pConn$);
964
1001
  const isDatapage = referenceListData.startsWith('D_');
965
1002
  const pageReferenceValue = isDatapage ? `${referenceListData}[${index}]` : `${this.pConn$.getPageReference()}${referenceListData}[${index}]`;
@@ -977,6 +1014,7 @@ export class SimpleTableManualComponent implements OnInit, OnDestroy {
977
1014
  });
978
1015
  eleData.push(data);
979
1016
  });
1017
+ this.originalElementsData = eleData;
980
1018
  this.elementsData = eleData;
981
1019
  }
982
1020
  }