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
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ export default function FieldValueList(props: FieldValueListProps) {
const formattedValue = formatItemValue(value);

return (
<Grid item xs={variant === 'stacked' ? 12 : 8} className={variant === 'stacked' ? classes.noPaddingTop : ''}>
<Grid item xs={variant === 'stacked' || !name ? 12 : 8} className={variant === 'stacked' ? classes.noPaddingTop : ''}>
{isHtml ? (
// eslint-disable-next-line react/no-danger
<div dangerouslySetInnerHTML={{ __html: formattedValue }} />
Expand All @@ -78,7 +78,7 @@ export default function FieldValueList(props: FieldValueListProps) {

return (
<Grid container spacing={4} justifyContent='space-between'>
{getGridItemLabel()}
{name ? getGridItemLabel() : null}
{getGridItemValue()}
</Grid>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ export default function Dropdown(props: DropdownProps) {
}, [theDatasource]);

useEffect(() => {
if (!displayMode && listType !== 'associated' && typeof datasource === 'string') {
if (listType !== 'associated' && typeof datasource === 'string') {
getDataPage(datasource, parameters, context).then((results: any) => {
const optionsData: any[] = [];
const displayColumn = getDisplayFieldsMetaData(columns);
Expand Down Expand Up @@ -165,23 +165,31 @@ export default function Dropdown(props: DropdownProps) {

let readOnlyProp = {};

if (displayMode === 'DISPLAY_ONLY') {
return (
<FieldValueList
name={hideLabel ? '' : label}
value={thePConn.getLocalizedValue(value, localePath, thePConn.getLocaleRuleNameFromKeys(localeClass, localeContext, localeName))}
/>
);
}
const displayFn = (displayM, val) => {
if (displayM === 'DISPLAY_ONLY') {
return (
<FieldValueList
name={hideLabel ? '' : label}
// @ts-ignore - Property 'getLocaleRuleNameFromKeys' is private and only accessible within class 'C11nEnv'
value={thePConn.getLocalizedValue(val, localePath, thePConn.getLocaleRuleNameFromKeys(localeClass, localeContext, localeName))}
/>
);
}

if (displayM === 'STACKED_LARGE_VAL') {
return (
<FieldValueList
name={hideLabel ? '' : label}
// @ts-ignore - Property 'getLocaleRuleNameFromKeys' is private and only accessible within class 'C11nEnv'
value={thePConn.getLocalizedValue(val, localePath, thePConn.getLocaleRuleNameFromKeys(localeClass, localeContext, localeName))}
variant='stacked'
/>
);
}
};

if (displayMode === 'STACKED_LARGE_VAL') {
return (
<FieldValueList
name={hideLabel ? '' : label}
value={thePConn.getLocalizedValue(value, localePath, thePConn.getLocaleRuleNameFromKeys(localeClass, localeContext, localeName))}
variant='stacked'
/>
);
if (displayMode) {
return displayFn(displayMode, options.find(option => option.key === value)?.value || value);
}

if (readOnly) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable no-nested-ternary */
import React, { PropsWithChildren, useEffect, useLayoutEffect, useRef, useState } from 'react';
import Table from '@mui/material/Table';
import TableBody from '@mui/material/TableBody';
Expand Down Expand Up @@ -193,13 +192,8 @@ export default function SimpleTableManual(props: PropsWithChildren<SimpleTableMa
});

useEffect(() => {
if (editableMode && !allowEditingInModal) {
// eslint-disable-next-line @typescript-eslint/no-use-before-define
buildElementsForTable();
}
}, [referenceList.length]);

useEffect(() => {
// eslint-disable-next-line @typescript-eslint/no-use-before-define
buildElementsForTable();
if (readOnlyMode || allowEditingInModal) {
// eslint-disable-next-line @typescript-eslint/no-use-before-define
generateRowsData();
Expand Down Expand Up @@ -364,7 +358,7 @@ export default function SimpleTableManual(props: PropsWithChildren<SimpleTableMa
const data: any = [];
rawFields.forEach(item => {
// removing label field from config to hide title in the table cell
item = { ...item, config: { ...item.config, label: '' } };
item = { ...item, config: { ...item.config, label: '', displayMode: readOnlyMode || allowEditingInModal ? 'DISPLAY_ONLY' : undefined } };
const referenceListData = getReferenceList(pConn);
const isDatapage = referenceListData.startsWith('D_');
const pageReferenceValue = isDatapage
Expand Down Expand Up @@ -428,7 +422,11 @@ export default function SimpleTableManual(props: PropsWithChildren<SimpleTableMa
return a[1] - b[1];
});

return stabilizedThis.map(el => el[0]);
const newElements = new Array(stabilizedThis.length);
stabilizedThis.forEach((el, index) => {
newElements[index] = elements[el[1]];
});
return newElements;
}

function _menuClick(event, columnId: string, columnType: string, labelValue: string) {
Expand Down Expand Up @@ -609,7 +607,7 @@ export default function SimpleTableManual(props: PropsWithChildren<SimpleTableMa
{fieldDefs.map((field: any, index) => {
return (
<TableCell key={`head-${displayedColumns[index]}`} className={classes.tableCell}>
{readOnlyMode ? (
{(readOnlyMode || allowEditingInModal) && field.cellRenderer !== 'DeleteIcon' ? (
<div>
<TableSortLabel
active={orderBy === displayedColumns[index]}
Expand Down Expand Up @@ -640,6 +638,7 @@ export default function SimpleTableManual(props: PropsWithChildren<SimpleTableMa
</TableHead>
<TableBody>
{editableMode &&
!allowEditingInModal &&
elements.map((row: any, index) => {
const theKey = `row-${index}`;
return (
Expand Down Expand Up @@ -677,44 +676,37 @@ export default function SimpleTableManual(props: PropsWithChildren<SimpleTableMa
return (
// eslint-disable-next-line react/no-array-index-key
<TableRow key={index}>
{displayedColumns.map(colKey => {
{row.map((item, childIndex) => {
const theColKey = displayedColumns[childIndex];
return (
<TableCell key={colKey} className={classes.tableCell}>
{showDeleteButton && colKey === 'DeleteIcon' ? (
<div>
<MoreIcon
id='table-edit-menu-icon'
className={classes.moreIcon}
onClick={event => {
editMenuClick(event, index);
}}
/>
<Menu id='table-edit-menu' anchorEl={editAnchorEl} keepMounted open={Boolean(editAnchorEl)} onClose={_menuClose}>
<MenuItem onClick={() => editRecord()}>Edit</MenuItem>
<MenuItem onClick={() => deleteRecord()}>Delete</MenuItem>
</Menu>
</div>
) : typeof row[colKey] === 'boolean' && !row[colKey] ? (
'False'
) : typeof row[colKey] === 'boolean' && row[colKey] ? (
'True'
) : (
row[colKey] || '---'
)}
<TableCell key={theColKey} className={classes.tableCell}>
{item}
</TableCell>
);
})}
{showDeleteButton && (
<TableCell key='DeleteIcon' className={classes.tableCell}>
<div>
<MoreIcon
id='table-edit-menu-icon'
className={classes.moreIcon}
onClick={event => {
editMenuClick(event, index);
}}
/>
<Menu id='table-edit-menu' anchorEl={editAnchorEl} keepMounted open={Boolean(editAnchorEl)} onClose={_menuClose}>
<MenuItem onClick={() => editRecord()}>Edit</MenuItem>
<MenuItem onClick={() => deleteRecord()}>Delete</MenuItem>
</Menu>
</div>
</TableCell>
)}
</TableRow>
);
})}
</TableBody>
</Table>
{readOnlyMode && rowData && rowData.length === 0 && (
<div className='no-records' id='no-records'>
No records found.
</div>
)}
{editableMode && referenceList && referenceList.length === 0 && (
{referenceList && referenceList.length === 0 && (
<div className='no-records' id='no-records'>
No records found.
</div>
Expand Down