Ensure that null values are accepted for the numeric columns in react-data-grid. Fixes #7405

This commit is contained in:
Aditya Toshniwal 2022-05-24 15:02:06 +05:30 committed by Akshay Joshi
parent 04fa7dee68
commit c5ca45c461
3 changed files with 7 additions and 5 deletions

View File

@ -32,3 +32,4 @@ Bug fixes
| `Issue #7399 <https://redmine.postgresql.org/issues/7399>`_ - Added missing toggle case keyboard shortcuts to the query tool.
| `Issue #7402 <https://redmine.postgresql.org/issues/7402>`_ - Ensure that Dashboard graphs should be refreshed on changing the node from the browser tree.
| `Issue #7403 <https://redmine.postgresql.org/issues/7403>`_ - Fixed an issue where comments on domain constraints were not visible when selecting a domain node.
| `Issue #7405 <https://redmine.postgresql.org/issues/7405>`_ - Ensure that null values are accepted for the numeric columns in react-data-grid.

View File

@ -264,7 +264,7 @@ export function NumberEditor({row, column, onRowChange, onClose}) {
value={value}
onChange={(e)=>{
if(column.can_edit) {
onRowChange({ ...row, [column.key]: e.target.value });
onRowChange({ ...row, [column.key]: (e.target.value == '' ? null : e.target.value)});
}
}}
onBlur={onBlur}

View File

@ -18,13 +18,13 @@ const useStyles = makeStyles((theme)=>({
}
}));
function NullAndDefaultFormatter({value, column, children}) {
function NullAndDefaultFormatter({value, column, children, style}) {
const classes = useStyles();
if (_.isUndefined(value) && column.has_default_val) {
return <span className={classes.disabledCell}>[default]</span>;
return <div className={classes.disabledCell} style={style}>[default]</div>;
} else if ((_.isUndefined(value) && column.not_null) ||
(_.isUndefined(value) || _.isNull(value))) {
return <span className={classes.disabledCell}>[null]</span>;
return <div className={classes.disabledCell} style={style}>[null]</div>;
}
return children;
}
@ -32,6 +32,7 @@ NullAndDefaultFormatter.propTypes = {
value: PropTypes.any,
column: PropTypes.object,
children: CustomPropTypes.children,
style: PropTypes.object,
};
const FormatterPropTypes = {
@ -54,7 +55,7 @@ TextFormatter.propTypes = FormatterPropTypes;
export function NumberFormatter({row, column}) {
let value = row[column.key];
return (
<NullAndDefaultFormatter value={value} column={column}>
<NullAndDefaultFormatter value={value} column={column} style={{textAlign: 'right'}}>
<div style={{textAlign: 'right'}}>{value}</div>
</NullAndDefaultFormatter>
);