From 42c6d6d57599c489b41ad84f5242b28bb343c487 Mon Sep 17 00:00:00 2001 From: manasa Date: Fri, 11 Sep 2026 10:43:10 +0530 Subject: [PATCH 1/2] Added support for conditional Add, Edit, and Delete actions, including record-level conditions, in editable EmbeddedData table --- CHANGELOG.md | 2 + .../template/simple-table-manual/helpers.ts | 6 +- .../simple-table-manual.component.html | 40 ++++++++++---- .../simple-table-manual.component.ts | 55 +++++++++++++++++-- 4 files changed, 84 insertions(+), 19 deletions(-) mode change 100644 => 100755 packages/angular-sdk-components/src/lib/_components/template/simple-table-manual/simple-table-manual.component.ts diff --git a/CHANGELOG.md b/CHANGELOG.md index 3422dc92..c351bb4a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,8 @@ * Github: [PR-547](https://github.com/pegasystems/angular-sdk-components/pull/547) * **Added support for instructions in the DefaultForm template.** * Github: [PR-548](https://github.com/pegasystems/angular-sdk-components/pull/548) +* **Added support for conditional Add, Edit, and Delete actions, including record-level conditions, in editable EmbeddedData table.** + * Github: [PR-548](https://github.com/pegasystems/angular-sdk-components/pull/553) ### **Bug fixes** diff --git a/packages/angular-sdk-components/src/lib/_components/template/simple-table-manual/helpers.ts b/packages/angular-sdk-components/src/lib/_components/template/simple-table-manual/helpers.ts index df9ed7a3..3078f590 100644 --- a/packages/angular-sdk-components/src/lib/_components/template/simple-table-manual/helpers.ts +++ b/packages/angular-sdk-components/src/lib/_components/template/simple-table-manual/helpers.ts @@ -233,7 +233,7 @@ export const updateFieldLabels = (fields, configFields, primaryFieldsViewIndex, return labelsOfFields; }; -export const buildFieldsForTable = (configFields, pConnect, showDeleteButton, options) => { +export const buildFieldsForTable = (configFields, pConnect, showActionColumn, options) => { const { primaryFieldsViewIndex, fields } = options; // get resolved field labels for primary fields raw config included in configFields @@ -260,8 +260,8 @@ export const buildFieldsForTable = (configFields, pConnect, showDeleteButton, op }; }); - // ONLY add DELETE_ICON to fields when the table is requested as EDITABLE - if (showDeleteButton) { + // Add the action column when either edit or delete is available. + if (showActionColumn) { fieldDefs.push({ type: 'text', label: '', diff --git a/packages/angular-sdk-components/src/lib/_components/template/simple-table-manual/simple-table-manual.component.html b/packages/angular-sdk-components/src/lib/_components/template/simple-table-manual/simple-table-manual.component.html index 65503c7c..1910c061 100644 --- a/packages/angular-sdk-components/src/lib/_components/template/simple-table-manual/simple-table-manual.component.html +++ b/packages/angular-sdk-components/src/lib/_components/template/simple-table-manual/simple-table-manual.component.html @@ -3,7 +3,14 @@

{{ label }} {{ getResultsText() }}

- +
- + - + + + + + @@ -62,7 +74,13 @@

{{ dCol.config.label }}
@@ -39,20 +46,25 @@

-
-

-
+
+ +
- - + +
-
- +
@@ -81,7 +99,7 @@

diff --git a/packages/angular-sdk-components/src/lib/_components/template/simple-table-manual/simple-table-manual.component.ts b/packages/angular-sdk-components/src/lib/_components/template/simple-table-manual/simple-table-manual.component.ts old mode 100644 new mode 100755 index 8e88795a..99795d91 --- a/packages/angular-sdk-components/src/lib/_components/template/simple-table-manual/simple-table-manual.component.ts +++ b/packages/angular-sdk-components/src/lib/_components/template/simple-table-manual/simple-table-manual.component.ts @@ -39,6 +39,7 @@ interface SimpleTableManualProps { allowActions?: any; allowTableEdit?: boolean; allowRowDelete?: any; + allowRowEdit?: any; editMode?: string; addAndEditRowsWithin?: any; viewForAddAndEditModal?: any; @@ -59,6 +60,12 @@ class Group { } } +interface RowActions { + canEdit: boolean; + canDelete: boolean; + hasAnyAction: boolean; +} + @Component({ selector: 'app-simple-table-manual', templateUrl: './simple-table-manual.component.html', @@ -168,6 +175,12 @@ export class SimpleTableManualComponent implements OnInit, OnDestroy { targetClassLabel: string; localizedVal = PCore.getLocaleUtils().getLocaleValue; localeCategory = 'SimpleTable'; + hideEditRow: any; + hideDeleteRow: boolean; + showEditButton: boolean; + showDeleteButton: boolean; + showActionColumn: boolean; + rowActions: RowActions[] = []; constructor( private angularPConnect: AngularPConnectService, public utils: Utils, @@ -238,7 +251,6 @@ export class SimpleTableManualComponent implements OnInit, OnDestroy { presets, allowActions, allowTableEdit, - allowRowDelete, label: labelProp, propertyLabel, fieldMetadata, @@ -305,9 +317,15 @@ export class SimpleTableManualComponent implements OnInit, OnDestroy { this.editableMode = renderMode === 'Editable'; const isDisplayModeEnabled = displayMode === 'DISPLAY_ONLY'; this.showAddRowButton = !this.readOnlyMode && !simpleTableManualProps.hideAddRow; + this.hideEditRow = simpleTableManualProps.hideEditRow; + this.hideDeleteRow = simpleTableManualProps.hideDeleteRow; this.allowEditingInModal = (editMode ? editMode === 'modal' : addAndEditRowsWithin === 'modal') && !(renderMode === 'ReadOnly' || isDisplayModeEnabled); - const showDeleteButton = this.editableMode && !simpleTableManualProps.hideDeleteRow && evaluateAllowRowAction(allowRowDelete, this.rowData); + this.showEditButton = this.allowEditingInModal && !this.hideEditRow; + this.showDeleteButton = this.editableMode && !this.hideDeleteRow; + this.showActionColumn = this.showEditButton || this.showDeleteButton; + const { allowRowEdit, allowRowDelete } = this.pConn$.getComponentConfig?.() ?? {}; + this.rowActions = this.referenceList.map(row => this.getRowActions(row, allowRowEdit, allowRowDelete)); this.defaultView = editModeConfig ? editModeConfig.defaultView : viewForAddAndEditModal; this.bUseSeparateViewForEdit = editModeConfig ? editModeConfig.useSeparateViewForEdit : useSeparateViewForEdit; this.editView = editModeConfig ? editModeConfig.editView : viewForEditModal; @@ -326,7 +344,7 @@ export class SimpleTableManualComponent implements OnInit, OnDestroy { // Nebula does). It will also have the "label", and "meta" contains the original, // unchanged config info. For now, much of the info here is carried over from // Nebula and we may not end up using it all. - this.fieldDefs = buildFieldsForTable(rawFields, this.pConn$, showDeleteButton, { + this.fieldDefs = buildFieldsForTable(rawFields, this.pConn$, this.showActionColumn, { primaryFieldsViewIndex, fields: resolvedFields }); @@ -364,7 +382,7 @@ export class SimpleTableManualComponent implements OnInit, OnDestroy { } // for edit and adding rows in modal view and to generate readonly list - if (!isEqual(this.prevReferenceList, this.referenceList) && (this.readOnlyMode || this.allowEditingInModal)) { + if (!isEqual(this.prevReferenceList, this.referenceList) && (this.readOnlyMode || this.allowEditingInModal || this.hideEditRow)) { this.generateRowsData(); } @@ -414,6 +432,31 @@ export class SimpleTableManualComponent implements OnInit, OnDestroy { return `${recordsCount || 0} result${recordsCount > 1 ? 's' : ''}`; } + private getRowActions(row: any, allowRowEdit: any, allowRowDelete: any): RowActions { + const canEdit = this.showEditButton && evaluateAllowRowAction(allowRowEdit, row); + const canDelete = this.showDeleteButton && this.isDeleteAllowedForRow(row, allowRowDelete); + + return { + canEdit, + canDelete, + hasAnyAction: canEdit || canDelete + }; + } + + private isDeleteAllowedForRow(row: any, allowRowDelete: any): boolean { + if (allowRowDelete === undefined || allowRowDelete === true) return true; + if (typeof allowRowDelete === 'string' && allowRowDelete.startsWith('@E ')) { + try { + const expression = allowRowDelete.replace('@E ', ''); + // @ts-expect-error - options param is optional per corejs docs + return PCore.getExpressionEngine().evaluate(expression, row); + } catch { + return true; + } + } + return false; + } + sortCompare(a, b): number { let aValue = a[0][this.compareRef]; let bValue = b[0][this.compareRef]; @@ -1021,8 +1064,10 @@ export class SimpleTableManualComponent implements OnInit, OnDestroy { buildElementsForTable() { const context = this.pConn$.getContextName(); + const { allowRowEdit } = this.pConn$.getComponentConfig?.() ?? {}; const eleData: any = []; this.referenceList.forEach((element, index) => { + const isRowEditable = evaluateAllowRowAction(allowRowEdit, element); const data: any = []; data.__originalIndex = index; this.rawFields?.forEach(item => { @@ -1032,7 +1077,7 @@ export class SimpleTableManualComponent implements OnInit, OnDestroy { config: { ...item.config, label: '', - displayMode: this.readOnlyMode || this.allowEditingInModal ? 'DISPLAY_ONLY' : undefined + displayMode: this.readOnlyMode || this.allowEditingInModal || this.hideEditRow || !isRowEditable ? 'DISPLAY_ONLY' : undefined } }; const referenceListData = getReferenceList(this.pConn$); From 217031e32c84f160e0ebb2d18eee48a12ff12cdb Mon Sep 17 00:00:00 2001 From: manasa Date: Fri, 11 Sep 2026 12:34:22 +0530 Subject: [PATCH 2/2] updated changeLog --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c351bb4a..2da44a33 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,7 +6,7 @@ * **Added support for instructions in the DefaultForm template.** * Github: [PR-548](https://github.com/pegasystems/angular-sdk-components/pull/548) * **Added support for conditional Add, Edit, and Delete actions, including record-level conditions, in editable EmbeddedData table.** - * Github: [PR-548](https://github.com/pegasystems/angular-sdk-components/pull/553) + * Github: [PR-553](https://github.com/pegasystems/angular-sdk-components/pull/553) ### **Bug fixes**
{{ dCol.label }} -