fix: Custom fields lacks empty tag (#7777)
This PR fixes this issue #7250 --------- Co-authored-by: Félix Malfait <felix@twenty.com>
This commit is contained in:
@ -46,6 +46,18 @@ describe('isFieldValueEmpty', () => {
|
|||||||
fieldValue: { foo: 'bar' },
|
fieldValue: { foo: 'bar' },
|
||||||
}),
|
}),
|
||||||
).toBe(false);
|
).toBe(false);
|
||||||
|
expect(
|
||||||
|
isFieldValueEmpty({
|
||||||
|
fieldDefinition: relationFieldDefinition,
|
||||||
|
fieldValue: [],
|
||||||
|
}),
|
||||||
|
).toBe(true);
|
||||||
|
expect(
|
||||||
|
isFieldValueEmpty({
|
||||||
|
fieldDefinition: relationFieldDefinition,
|
||||||
|
fieldValue: [{ id: '123' }],
|
||||||
|
}),
|
||||||
|
).toBe(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should return correct value for select field', () => {
|
it('should return correct value for select field', () => {
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
import { isString } from '@sniptt/guards';
|
import { isArray, isNonEmptyArray, isString } from '@sniptt/guards';
|
||||||
|
|
||||||
import { FieldDefinition } from '@/object-record/record-field/types/FieldDefinition';
|
import { FieldDefinition } from '@/object-record/record-field/types/FieldDefinition';
|
||||||
import { FieldMetadata } from '@/object-record/record-field/types/FieldMetadata';
|
import { FieldMetadata } from '@/object-record/record-field/types/FieldMetadata';
|
||||||
@ -58,7 +58,6 @@ export const isFieldValueEmpty = ({
|
|||||||
isFieldNumber(fieldDefinition) ||
|
isFieldNumber(fieldDefinition) ||
|
||||||
isFieldRating(fieldDefinition) ||
|
isFieldRating(fieldDefinition) ||
|
||||||
isFieldBoolean(fieldDefinition) ||
|
isFieldBoolean(fieldDefinition) ||
|
||||||
isFieldRelation(fieldDefinition) ||
|
|
||||||
isFieldRawJson(fieldDefinition) ||
|
isFieldRawJson(fieldDefinition) ||
|
||||||
isFieldRichText(fieldDefinition) ||
|
isFieldRichText(fieldDefinition) ||
|
||||||
isFieldPosition(fieldDefinition)
|
isFieldPosition(fieldDefinition)
|
||||||
@ -73,11 +72,19 @@ export const isFieldValueEmpty = ({
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (isFieldRelation(fieldDefinition)) {
|
||||||
|
if (isArray(fieldValue)) {
|
||||||
|
return !isNonEmptyArray(fieldValue);
|
||||||
|
}
|
||||||
|
return isValueEmpty(fieldValue);
|
||||||
|
}
|
||||||
|
|
||||||
if (isFieldMultiSelect(fieldDefinition) || isFieldArray(fieldDefinition)) {
|
if (isFieldMultiSelect(fieldDefinition) || isFieldArray(fieldDefinition)) {
|
||||||
return (
|
return (
|
||||||
!isFieldArrayValue(fieldValue) ||
|
!isFieldArrayValue(fieldValue) ||
|
||||||
!isFieldMultiSelectValue(fieldValue, selectOptionValues) ||
|
!isFieldMultiSelectValue(fieldValue, selectOptionValues) ||
|
||||||
!isDefined(fieldValue)
|
!isDefined(fieldValue) ||
|
||||||
|
!isNonEmptyArray(fieldValue)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user