Skip to content

Commit

Permalink
fix: singleSelect null value not being posted in form submit and add …
Browse files Browse the repository at this point in the history
…mapping support for heading in globalConfig
  • Loading branch information
harshpatel-crest committed Apr 23, 2021
1 parent 74c7c6a commit 94e11c3
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 12 deletions.
2 changes: 1 addition & 1 deletion ui/src/main/webapp/components/SingleInputComponent.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ function SingleInputComponent(props) {
<Button
appearance="secondary"
icon={<Clear />}
onClick={() => restProps.handleChange(field, null)}
onClick={() => restProps.handleChange(field, '')}
/>
</>
)}
Expand Down
9 changes: 6 additions & 3 deletions ui/src/main/webapp/components/table/CustomTable.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,13 @@ function CustomTable({
? unifiedConfigs.pages.inputs.table
: unifiedConfigs.pages.configuration.tabs.filter((x) => x.name === serviceName)[0]
.table;
const { moreInfo } = tableConfig;
const { moreInfo, header } = tableConfig;
const headers = tableConfig.header;

const statusMapping = moreInfo?.find((x) => x.field === 'disabled')?.mapping;
const headerMapping = {}
header.forEach(x => {
headerMapping[x.field] = x.mapping
})

const serviceToStyleMap = {};
unifiedConfigs.pages.inputs.services.forEach((x) => {
Expand Down Expand Up @@ -236,7 +239,7 @@ function CustomTable({
key={row.id}
row={row}
columns={columns}
statusMapping={statusMapping}
headerMapping={headerMapping}
{...{
handleEditActionClick,
handleCloneActionClick,
Expand Down
26 changes: 18 additions & 8 deletions ui/src/main/webapp/components/table/CustomTableRow.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ function CustomTableRow(props) {
const {
row,
columns,
statusMapping,
headerMapping,
handleToggleActionClick,
handleEditActionClick,
handleCloneActionClick,
Expand Down Expand Up @@ -87,7 +87,9 @@ function CustomTableRow(props) {
statusContent = <WaitSpinner />;
} else if (row.disabled) {
statusContent =
statusMapping && statusMapping[row.disabled] ? statusMapping[row.disabled] : 'Disabled';
headerMapping?.disabled && headerMapping.disabled[row.disabled]
? headerMapping.disabled[row.disabled]
: 'Disabled';
}

return (
Expand Down Expand Up @@ -118,13 +120,13 @@ function CustomTableRow(props) {
appearance="toggle"
className="toggle_switch"
selectedLabel={_(
statusMapping && statusMapping.false
? statusMapping.false
headerMapping?.disabled?.false
? headerMapping.disabled.false
: 'Enabled'
)}
unselectedLabel={_(
statusMapping && statusMapping.true
? statusMapping.true
headerMapping?.disabled?.true
? headerMapping.disabled.true
: 'Disabled'
)}
/>
Expand All @@ -136,7 +138,15 @@ function CustomTableRow(props) {
cellHTML = rowActionsPrimaryButton(row);
} else {
cellHTML = (
<Table.Cell key={header.field}>{row[header.field]}</Table.Cell>
<Table.Cell key={header.field}>
{headerMapping[header.field] &&
Object.prototype.hasOwnProperty.call(
headerMapping[header.field],
row[header.field]
)
? headerMapping[header.field][row[header.field]]
: row[header.field]}
</Table.Cell>
);
}
return cellHTML;
Expand All @@ -149,7 +159,7 @@ function CustomTableRow(props) {
CustomTableRow.propTypes = {
row: PropTypes.any,
columns: PropTypes.array,
statusMapping: PropTypes.object,
headerMapping: PropTypes.object,
handleToggleActionClick: PropTypes.func,
handleEditActionClick: PropTypes.func,
handleCloneActionClick: PropTypes.func,
Expand Down

0 comments on commit 94e11c3

Please sign in to comment.