Skip to content

Commit 1e0f464

Browse files
TASK-1828886-3: EmbeddedData tables tests (#99)
1 parent 83b17fd commit 1e0f464

File tree

21 files changed

+6619
-83
lines changed

21 files changed

+6619
-83
lines changed

samples/android-cmp-app/src/androidInstrumentedTest/kotlin/com/pega/constellation/sdk/kmp/samples/androidcmpapp/test/cases/EmbeddedDataTest.kt

Lines changed: 261 additions & 48 deletions
Large diffs are not rendered by default.

scripts/dxcomponents/components/containers/templates/simple-table-manual.component.js

Lines changed: 21 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,8 @@ export class SimpleTableManualComponent extends BaseComponent {
9191
presets,
9292
allowActions,
9393
allowTableEdit,
94-
allowRowDelete,
95-
allowRowEdit,
94+
allowRowDelete: allowRowDeleteExpression,
95+
allowRowEdit: allowRowEditExpression,
9696
label: labelProp,
9797
propertyLabel,
9898
editMode,
@@ -108,10 +108,13 @@ export class SimpleTableManualComponent extends BaseComponent {
108108
const conditions = this.#calculateConditions(editMode, allowActions, allowTableEdit)
109109

110110
this.referenceListStr = getContext(this.pConn).referenceListStr;
111-
this.props.label = this.pConn.getInheritedProps().label ?? labelProp ?? propertyLabel;
111+
this.props.label = this.pConn.getInheritedProps().label || labelProp || propertyLabel;
112112
this.targetClassLabel = targetClassLabel;
113113
this.props.addButtonLabel = targetClassLabel ? `+ Add ${targetClassLabel}` : "+ Add";
114-
this.referenceList = referenceList;
114+
this.referenceList = referenceList.map((element) => {
115+
element.allowEdit = conditions.allowEditRow && evaluateAllowRowAction(allowRowEditExpression, element)
116+
return element;
117+
});
115118
this.contextClass = this.#getContextClass(configProps);
116119

117120
this.pConn.setReferenceList(getReferenceList(this.pConn));
@@ -141,8 +144,18 @@ export class SimpleTableManualComponent extends BaseComponent {
141144
this.props.columnLabels = this.#getColumnLabels(fieldDefs, resolvedFields);
142145

143146
if ((!this.#listsEqual(this.prevReferenceList, this.referenceList))) {
144-
this.#buildRows(rawFields, editableMode, conditions.allowDeleteRow, allowRowDelete, conditions.allowEditRow, allowRowEdit);
147+
this.#buildRows(rawFields);
145148
}
149+
this.props.rows = this.editableRows.map((row, rowIndex) => {
150+
const allowDelete = conditions.allowDeleteRow && evaluateAllowRowAction(allowRowDeleteExpression, this.referenceList[rowIndex])
151+
const showEditButton = editableMode && this.allowEditingInModal && this.referenceList[rowIndex].allowEdit
152+
const showDeleteButton = editableMode && allowDelete
153+
return {
154+
cellComponentIds: row.cells.map((cell) => cell.component.compId),
155+
showEditButton: showEditButton,
156+
showDeleteButton: showDeleteButton
157+
}
158+
});
146159
this.prevReferenceList = this.referenceList;
147160
this.componentsManager.onComponentPropsUpdate(this)
148161
}
@@ -200,13 +213,10 @@ export class SimpleTableManualComponent extends BaseComponent {
200213
}
201214
}
202215

203-
#buildRows(rawFields, editableMode, allowDelete, allowRowDeleteExpression, allowEdit, allowRowEditExpression) {
216+
#buildRows(rawFields) {
204217
const context = this.pConn.getContextName();
205218
const newEditableRows = [];
206219
this.referenceList.forEach((element, rowIndex) => {
207-
const showDeleteButton = editableMode && allowDelete && evaluateAllowRowAction(allowRowDeleteExpression, element);
208-
const showEditButton = editableMode && allowEdit && evaluateAllowRowAction(allowRowEditExpression, element) && this.allowEditingInModal;
209-
210220
const editableRow = this.editableRows[rowIndex];
211221
const newEditableCells = [];
212222
rawFields?.forEach((item, cellIndex) => {
@@ -216,7 +226,7 @@ export class SimpleTableManualComponent extends BaseComponent {
216226
config: {
217227
...item.config,
218228
label: '',
219-
displayMode: this.readOnlyMode || this.allowEditingInModal ? 'DISPLAY_ONLY' : undefined
229+
displayMode: this.readOnlyMode || this.allowEditingInModal || !element.allowEdit ? 'DISPLAY_ONLY' : undefined
220230
}
221231
};
222232
const referenceListData = getReferenceList(this.pConn);
@@ -238,20 +248,9 @@ export class SimpleTableManualComponent extends BaseComponent {
238248
newEditableCells.push({ component: newComponent })
239249
}
240250
});
241-
newEditableRows.push({
242-
cells: newEditableCells,
243-
showEditButton: showEditButton,
244-
showDeleteButton: showDeleteButton
245-
});
251+
newEditableRows.push({ cells: newEditableCells});
246252
});
247253
this.editableRows = newEditableRows;
248-
this.props.rows = newEditableRows.map((row) => {
249-
return {
250-
cellComponentIds: row.cells.map((cell) => cell.component.compId),
251-
showEditButton: row.showEditButton,
252-
showDeleteButton: row.showDeleteButton
253-
}
254-
});
255254
}
256255

257256
#addSimpleTableRow() {

scripts/dxcomponents/components/containers/view.component.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,10 +77,10 @@ export class ViewComponent extends ContainerBaseComponent {
7777

7878
const template = this.#resolveTemplateType(configProps);
7979
const label = configProps.label ?? "";
80-
const showLabel = configProps.showLabel || this.DETAILS_TEMPLATES.includes(template) || this.props.showLabel;
81-
80+
const showLabel = configProps.showLabel || this.DETAILS_TEMPLATES.includes(template);
81+
const isTemplateWithHeader = !this.NO_HEADER_TEMPLATES.includes(template);
8282
this.props.label = inheritedProps.label ?? label;
83-
this.props.showLabel = (inheritedProps.showLabel ?? showLabel) && !this.NO_HEADER_TEMPLATES.includes(template);
83+
this.props.showLabel = (inheritedProps.showLabel || showLabel) && isTemplateWithHeader;
8484
this.props.visible = configProps.visibility ?? this.props.visible;
8585

8686
if (this.READ_ONLY_DETAILS_TEMPLATES.includes(template)) {

0 commit comments

Comments
 (0)