fix: can't set ARR of company to empty (#1474)

This commit is contained in:
Jérémy M 2023-09-06 11:22:42 +02:00 committed by GitHub
parent 91e146ed3e
commit 08b56ec7e2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 9 additions and 6 deletions

View File

@ -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;

View File

@ -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')
);
}

View File

@ -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);