Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@

* **Fixed `TextInput`, `Email`, `URL`, and `TextArea` fields showing an empty value after being hidden and shown again by a visibility condition.**
* Github: [PR-656](https://github.com/pegasystems/angular-sdk-components/pull/656)

* **Fixed `Multiselect` not sending page instructions for values that were already selected, which caused the save request to differ from Constellation.**
* Github: [PR-664](https://github.com/pegasystems/angular-sdk-components/pull/664)

* **Fixed field groups ignoring the list's `uniqueField` (for example, `.EmbedListUUID__`). New rows now get a unique ID, and the page instructions match Constellation.**
* Github: [PR-664](https://github.com/pegasystems/angular-sdk-components/pull/664)
---

### **Dependencies & Infrastructure**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<div [formGroup]="formGroup$">
<div [formGroup]="formGroup$" *ngIf="bVisible$">
<mat-form-field class="psdk-full-width" subscriptSizing="dynamic">
<mat-label>{{ label$ }}</mat-label>
<mat-chip-grid #chipGrid [required]="bRequired$">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { MatIconModule } from '@angular/material/icon';

import { FieldBase } from '../field.base';
import { doSearch, getDisplayFieldsMetaData, getGroupDataForItemsTree, preProcessColumns } from './utils';
import { deleteInstruction, insertInstruction } from '../../../_helpers/instructions-utils';
import { deleteInstruction, insertInstruction, updateNewInstructions } from '../../../_helpers/instructions-utils';
import { handleEvent } from '../../../_helpers/event-util';

@Component({
Expand Down Expand Up @@ -50,6 +50,15 @@ export class MultiselectComponent extends FieldBase {
itemsTree: any[] = [];
trigger: any;

override ngOnInit(): void {
super.ngOnInit();

// Seed default page instructions for already-selected rows (keyed by the list's self-referenced datasource params, e.g. pyID), matching Constellation
if (this.referenceList?.length > 0 && !this.bReadonly$) {
updateNewInstructions(this.pConn$, this.selectionList);
}
}

/**
* Updates the component when there are changes in the state.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { AngularPConnectData, AngularPConnectService } from '../../../_bridge/an
import { buildView, getReferenceList } from '../../../_helpers/field-group-utils';
import { Utils } from '../../../_helpers/utils';
import { ComponentMapperComponent } from '../../../_bridge/component-mapper/component-mapper.component';
import { evaluateAllowRowAction } from '../utils';
import { evaluateAllowRowAction, getNewRowPayload } from '../utils';

interface FieldGroupTemplateProps {
// If any, enter additional props that only exist on this component
Expand All @@ -23,6 +23,7 @@ interface FieldGroupTemplateProps {
fieldHeader?: string;
allowTableEdit: boolean;
targetClassLabel?: string;
uniqueField?: string;
}

@Component({
Expand Down Expand Up @@ -63,7 +64,7 @@ export class FieldGroupTemplateComponent implements OnInit, OnDestroy, OnChanges
const allowEdit = this.allowEdit();
const referenceList = this.configProps$?.referenceList;
if (referenceList?.length === 0 && (allowAdd || allowEdit)) {
this.pConn$.getListActions().insert({ classID: this.contextClass }, referenceList.length);
this.pConn$.getListActions().insert(this.getNewRowPayload(), referenceList.length);
}
});
}
Expand Down Expand Up @@ -133,7 +134,9 @@ export class FieldGroupTemplateComponent implements OnInit, OnDestroy, OnChanges
}

if (this.referenceListLength() != referenceList?.length) {
this.pConn$.getListActions().initDefaultPageInstructions(resolvedList, []);
// uniqueField (e.g. '.EmbedListUUID__') lets core seed a row UUID in the default page instructions, matching Constellation
// @ts-ignore - Argument of type 'undefined' is not assignable to parameter of type 'string[]'
this.pConn$.getListActions().initDefaultPageInstructions(resolvedList, undefined, this.configProps$.uniqueField);

this.children = referenceList?.map((item, index) => {
return {
Expand Down Expand Up @@ -172,7 +175,11 @@ export class FieldGroupTemplateComponent implements OnInit, OnDestroy, OnChanges
};

addFieldGroupItem() {
this.pConn$.getListActions().insert({ classID: this.contextClass }, this.referenceListLength() as number);
this.pConn$.getListActions().insert(this.getNewRowPayload(), this.referenceListLength() as number);
}

getNewRowPayload() {
return getNewRowPayload(this.contextClass, this.configProps$?.uniqueField);
}

deleteFieldGroupItem(index) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,18 @@ export const evaluateAllowRowAction = (allowRowDelete, rowData) => {
return false;
};

/**
* Builds the payload for a new embedded list row. When the list has a uniqueField (e.g. '.EmbedListUUID__'),
* a UUID is seeded for it, matching Constellation behavior.
*/
export function getNewRowPayload(contextClass: string, uniqueField?: string): Record<string, string> {
const payload: Record<string, string> = { classID: contextClass };
if (uniqueField) {
payload[uniqueField.startsWith('.') ? uniqueField.substring(1) : uniqueField] = crypto.randomUUID();
}
return payload;
}

export function prepareCaseSummaryData(caseSummaryRegion, portalSpecificVisibilityChecker?) {
const filterVisibleChildren = children => {
return children
Expand Down
Loading