Skip to content

Commit

Permalink
fix: can't set ARR of company to empty (#1474)
Browse files Browse the repository at this point in the history
  • Loading branch information
magrinj authored Sep 6, 2023
1 parent 91e146e commit 08b56ec
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
2 changes: 1 addition & 1 deletion front/src/modules/ui/editable-field/types/ViewField.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ export type ViewFieldDateValue = string;
export type ViewFieldPhoneValue = string;
export type ViewFieldEmailValue = string;
export type ViewFieldBooleanValue = boolean;
export type ViewFieldMoneyValue = number;
export type ViewFieldMoneyValue = number | null;
export type ViewFieldURLValue = string;
export type ViewFieldNumberValue = number | null;
export type ViewFieldProbabilityValue = number;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,8 @@ import { ViewFieldMoneyValue } from '../ViewField';
export function isViewFieldMoneyValue(
fieldValue: unknown,
): fieldValue is ViewFieldMoneyValue {
return typeof fieldValue === 'number';
return (
fieldValue === null ||
(fieldValue !== undefined && typeof fieldValue === 'number')
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,17 @@ export function GenericEditableMoneyCellEditMode({
if (newText === fieldValue) return;

try {
const numberValue = parseInt(newText);
const numberValue = newText !== '' ? parseInt(newText) : null;

if (isNaN(numberValue)) {
if (numberValue && isNaN(numberValue)) {
throw new Error('Not a number');
}

if (numberValue > 2000000000) {
if (numberValue && numberValue > 2000000000) {
throw new Error('Number too big');
}

setFieldValue(numberValue.toString());
setFieldValue(numberValue ? numberValue.toString() : '');

if (currentRowEntityId && updateField) {
updateField(currentRowEntityId, columnDefinition, numberValue);
Expand Down

0 comments on commit 08b56ec

Please sign in to comment.