-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
After discussing with @charlesBochet, several fixes are needed on fields: - [x] Disable Boolean field `defaultValue` edition for now (On `defaultValue` update, newly created records are not taking the updated `defaultValue` into account. Setting the `defaultValue` on creation is fine.) - [x] Disable Phone field creation for now - [x] For the Person object, display the "Phone" field as a field of type Phone (right now its type is Text; later we'll migrate it to a proper Phone field). - [x] Fix RawJson field display (displaying `[object Object]` in Record Table cells). - [x] In Settings/Data Model, on Relation field creation/edition, "Object destination" select is not working properly if an object was not manually selected (displays Companies by default but creates a relation to another random object than Companies).
- Loading branch information
1 parent
005045c
commit 7728c09
Showing
23 changed files
with
333 additions
and
168 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 2 additions & 1 deletion
3
...src/modules/object-record/record-field/meta-types/display/components/JsonFieldDisplay.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
...enty-front/src/modules/object-record/record-field/types/guards/isFieldDisplayedAsPhone.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { CoreObjectNameSingular } from '@/object-metadata/types/CoreObjectNameSingular'; | ||
import { FieldMetadataType } from '~/generated-metadata/graphql'; | ||
|
||
import { FieldDefinition } from '../FieldDefinition'; | ||
import { FieldMetadata, FieldTextMetadata } from '../FieldMetadata'; | ||
|
||
// TODO: temporary - remove when 'Phone' field in 'Person' object | ||
// is migrated to use FieldMetadataType.Phone as type. | ||
export const isFieldDisplayedAsPhone = ( | ||
field: Pick<FieldDefinition<FieldMetadata>, 'type' | 'metadata'>, | ||
): field is FieldDefinition<FieldTextMetadata> => | ||
field.metadata.objectMetadataNameSingular === CoreObjectNameSingular.Person && | ||
field.type === FieldMetadataType.Text && | ||
field.metadata.fieldName === 'phone'; |
20 changes: 16 additions & 4 deletions
20
...s/twenty-front/src/modules/object-record/record-field/types/guards/isFieldRawJsonValue.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,20 @@ | ||
import { isNull, isString } from '@sniptt/guards'; | ||
import { z } from 'zod'; | ||
|
||
import { FieldJsonValue } from '../FieldMetadata'; | ||
import { FieldJsonValue, Json } from '../FieldMetadata'; | ||
|
||
// See https://zod.dev/?id=json-type | ||
const literalSchema = z.union([z.string(), z.number(), z.boolean(), z.null()]); | ||
const jsonSchema: z.ZodType<Json> = z.lazy(() => | ||
z.union([literalSchema, z.array(jsonSchema), z.record(jsonSchema)]), | ||
); | ||
|
||
export const jsonWithoutLiteralsSchema: z.ZodType<FieldJsonValue> = z.union([ | ||
z.null(), // Exclude literal values other than null | ||
z.array(jsonSchema), | ||
z.record(jsonSchema), | ||
]); | ||
|
||
// TODO: add zod | ||
export const isFieldRawJsonValue = ( | ||
fieldValue: unknown, | ||
): fieldValue is FieldJsonValue => isString(fieldValue) || isNull(fieldValue); | ||
): fieldValue is FieldJsonValue => | ||
jsonWithoutLiteralsSchema.safeParse(fieldValue).success; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 0 additions & 12 deletions
12
packages/twenty-front/src/modules/object-record/record-field/utils/isFieldValueJson.ts
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.