diff --git a/CHANGELOG.md b/CHANGELOG.md index 410527ce..2c1d25be 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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** diff --git a/packages/angular-sdk-components/src/lib/_components/field/multiselect/multiselect.component.html b/packages/angular-sdk-components/src/lib/_components/field/multiselect/multiselect.component.html index b6406a92..802c653d 100644 --- a/packages/angular-sdk-components/src/lib/_components/field/multiselect/multiselect.component.html +++ b/packages/angular-sdk-components/src/lib/_components/field/multiselect/multiselect.component.html @@ -1,4 +1,4 @@ -
+
{{ label$ }} diff --git a/packages/angular-sdk-components/src/lib/_components/field/multiselect/multiselect.component.ts b/packages/angular-sdk-components/src/lib/_components/field/multiselect/multiselect.component.ts index b41a5fc4..c95d7261 100644 --- a/packages/angular-sdk-components/src/lib/_components/field/multiselect/multiselect.component.ts +++ b/packages/angular-sdk-components/src/lib/_components/field/multiselect/multiselect.component.ts @@ -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({ @@ -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. */ diff --git a/packages/angular-sdk-components/src/lib/_components/template/field-group-template/field-group-template.component.ts b/packages/angular-sdk-components/src/lib/_components/template/field-group-template/field-group-template.component.ts index 29773f08..cb7ec16e 100644 --- a/packages/angular-sdk-components/src/lib/_components/template/field-group-template/field-group-template.component.ts +++ b/packages/angular-sdk-components/src/lib/_components/template/field-group-template/field-group-template.component.ts @@ -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 @@ -23,6 +23,7 @@ interface FieldGroupTemplateProps { fieldHeader?: string; allowTableEdit: boolean; targetClassLabel?: string; + uniqueField?: string; } @Component({ @@ -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); } }); } @@ -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 { @@ -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) { diff --git a/packages/angular-sdk-components/src/lib/_components/template/utils.ts b/packages/angular-sdk-components/src/lib/_components/template/utils.ts index 16cfebc1..3de03c19 100644 --- a/packages/angular-sdk-components/src/lib/_components/template/utils.ts +++ b/packages/angular-sdk-components/src/lib/_components/template/utils.ts @@ -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 { + const payload: Record = { 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