Skip to content
Merged
Show file tree
Hide file tree
Changes from 13 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

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,8 @@ export class SimpleTableManualComponent extends BaseComponent {
presets,
allowActions,
allowTableEdit,
allowRowDelete,
allowRowEdit,
allowRowDelete: allowRowDeleteExpression,
allowRowEdit: allowRowEditExpression,
label: labelProp,
propertyLabel,
editMode,
Expand All @@ -108,10 +108,13 @@ export class SimpleTableManualComponent extends BaseComponent {
const conditions = this.#calculateConditions(editMode, allowActions, allowTableEdit)

this.referenceListStr = getContext(this.pConn).referenceListStr;
this.props.label = this.pConn.getInheritedProps().label ?? labelProp ?? propertyLabel;
this.props.label = this.pConn.getInheritedProps().label || labelProp || propertyLabel;
this.targetClassLabel = targetClassLabel;
this.props.addButtonLabel = targetClassLabel ? `+ Add ${targetClassLabel}` : "+ Add";
this.referenceList = referenceList;
this.referenceList = referenceList.map((element) => {
element.allowEdit = conditions.allowEditRow && evaluateAllowRowAction(allowRowEditExpression, element)
return element;
});
this.contextClass = this.#getContextClass(configProps);

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

if ((!this.#listsEqual(this.prevReferenceList, this.referenceList))) {
this.#buildRows(rawFields, editableMode, conditions.allowDeleteRow, allowRowDelete, conditions.allowEditRow, allowRowEdit);
this.#buildRows(rawFields);
}
this.props.rows = this.editableRows.map((row, rowIndex) => {
const allowDelete = conditions.allowDeleteRow && evaluateAllowRowAction(allowRowDeleteExpression, this.referenceList[rowIndex])
const showEditButton = editableMode && this.allowEditingInModal && this.referenceList[rowIndex].allowEdit
const showDeleteButton = editableMode && allowDelete
return {
cellComponentIds: row.cells.map((cell) => cell.component.compId),
showEditButton: showEditButton,
showDeleteButton: showDeleteButton
}
});
this.prevReferenceList = this.referenceList;
this.componentsManager.onComponentPropsUpdate(this)
}
Expand Down Expand Up @@ -200,13 +213,10 @@ export class SimpleTableManualComponent extends BaseComponent {
}
}

#buildRows(rawFields, editableMode, allowDelete, allowRowDeleteExpression, allowEdit, allowRowEditExpression) {
#buildRows(rawFields) {
const context = this.pConn.getContextName();
const newEditableRows = [];
this.referenceList.forEach((element, rowIndex) => {
const showDeleteButton = editableMode && allowDelete && evaluateAllowRowAction(allowRowDeleteExpression, element);
const showEditButton = editableMode && allowEdit && evaluateAllowRowAction(allowRowEditExpression, element) && this.allowEditingInModal;

const editableRow = this.editableRows[rowIndex];
const newEditableCells = [];
rawFields?.forEach((item, cellIndex) => {
Expand All @@ -216,7 +226,7 @@ export class SimpleTableManualComponent extends BaseComponent {
config: {
...item.config,
label: '',
displayMode: this.readOnlyMode || this.allowEditingInModal ? 'DISPLAY_ONLY' : undefined
displayMode: this.readOnlyMode || this.allowEditingInModal || !element.allowEdit ? 'DISPLAY_ONLY' : undefined
}
};
const referenceListData = getReferenceList(this.pConn);
Expand All @@ -238,20 +248,9 @@ export class SimpleTableManualComponent extends BaseComponent {
newEditableCells.push({ component: newComponent })
}
});
newEditableRows.push({
cells: newEditableCells,
showEditButton: showEditButton,
showDeleteButton: showDeleteButton
});
newEditableRows.push({ cells: newEditableCells});
});
this.editableRows = newEditableRows;
this.props.rows = newEditableRows.map((row) => {
return {
cellComponentIds: row.cells.map((cell) => cell.component.compId),
showEditButton: row.showEditButton,
showDeleteButton: row.showDeleteButton
}
});
}

#addSimpleTableRow() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,10 @@ export class ViewComponent extends ContainerBaseComponent {

const template = this.#resolveTemplateType(configProps);
const label = configProps.label ?? "";
const showLabel = configProps.showLabel || this.DETAILS_TEMPLATES.includes(template) || this.props.showLabel;

const showLabel = (configProps.showLabel || this.DETAILS_TEMPLATES.includes(template)) ?? this.props.showLabel;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think right side of this expression (after ?? operator) will never be used.

const isTemplateWithHeader = !this.NO_HEADER_TEMPLATES.includes(template);
this.props.label = inheritedProps.label ?? label;
this.props.showLabel = (inheritedProps.showLabel ?? showLabel) && !this.NO_HEADER_TEMPLATES.includes(template);
this.props.showLabel = (inheritedProps.showLabel || showLabel) && isTemplateWithHeader;
this.props.visible = configProps.visibility ?? this.props.visible;

if (this.READ_ONLY_DETAILS_TEMPLATES.includes(template)) {
Expand Down
Loading