Fix column not being saved properly (#1429)

* Fix email column not being saved

* Fix URL fields not being clearable

* Fix phone number clearing
This commit is contained in:
Ragnar Laud 2023-09-04 16:42:10 +03:00 committed by GitHub
parent 3a0f02f2f2
commit 1a71f61d24
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 20 additions and 2 deletions

View File

@ -30,7 +30,7 @@ export function GenericEditableURLCellEditMode({ columnDefinition }: OwnProps) {
function handleSubmit(newText: string) {
if (newText === fieldValue) return;
if (!isURL(newText)) return;
if (newText !== '' && !isURL(newText)) return;
setFieldValue(newText);

View File

@ -85,7 +85,10 @@ export function PhoneCellEdit({
const wrapperRef = useRef<HTMLDivElement | null>(null);
function handleSubmit() {
if (isPossiblePhoneNumber(internalValue ?? '')) {
if (
internalValue === undefined ||
isPossiblePhoneNumber(internalValue ?? '')
) {
onSubmit(internalValue ?? '');
}
}

View File

@ -10,6 +10,8 @@ import { isViewFieldDoubleText } from '@/ui/editable-field/types/guards/isViewFi
import { isViewFieldDoubleTextChip } from '@/ui/editable-field/types/guards/isViewFieldDoubleTextChip';
import { isViewFieldDoubleTextChipValue } from '@/ui/editable-field/types/guards/isViewFieldDoubleTextChipValue';
import { isViewFieldDoubleTextValue } from '@/ui/editable-field/types/guards/isViewFieldDoubleTextValue';
import { isViewFieldEmail } from '@/ui/editable-field/types/guards/isViewFieldEmail';
import { isViewFieldEmailValue } from '@/ui/editable-field/types/guards/isViewFieldEmailValue';
import { isViewFieldMoney } from '@/ui/editable-field/types/guards/isViewFieldMoney';
import { isViewFieldMoneyValue } from '@/ui/editable-field/types/guards/isViewFieldMoneyValue';
import { isViewFieldNumber } from '@/ui/editable-field/types/guards/isViewFieldNumber';
@ -183,6 +185,19 @@ export function useUpdateEntityField() {
) {
const newContent = newFieldValueUnknown;
updateEntity({
variables: {
where: { id: currentEntityId },
data: { [columnDefinition.metadata.fieldName]: newContent },
},
});
// Email
} else if (
isViewFieldEmail(columnDefinition) &&
isViewFieldEmailValue(newFieldValueUnknown)
) {
const newContent = newFieldValueUnknown;
updateEntity({
variables: {
where: { id: currentEntityId },