From 9e61792df65de2dc32db63b814c0bfda09f7b9f9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ce=CC=81dric=20Boirard?= Date: Tue, 18 Mar 2025 16:25:15 +0100 Subject: [PATCH 1/3] Add link allowed as an allowed field for email/tel MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Cédric Boirard --- plugins/airtable/src/FieldMapping.tsx | 4 +++- plugins/airtable/src/data.ts | 23 ++++++++++++++++++++++- 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/plugins/airtable/src/FieldMapping.tsx b/plugins/airtable/src/FieldMapping.tsx index 4cc370a49..999ed9c7b 100644 --- a/plugins/airtable/src/FieldMapping.tsx +++ b/plugins/airtable/src/FieldMapping.tsx @@ -1,4 +1,4 @@ -import type { ManagedCollection, EditableManagedCollectionField, Field, } from "framer-plugin" +import type { ManagedCollection, EditableManagedCollectionField, Field } from "framer-plugin" import type { DataSource, PossibleField } from "./data" import { framer } from "framer-plugin" @@ -199,6 +199,8 @@ export function FieldMapping({ collection, dataSource, initialSlugFieldId }: Fie } as PossibleField case "image": return { ...field, type: "image" } as PossibleField + case "string": + return { ...field, type: "string" } as PossibleField default: return field } diff --git a/plugins/airtable/src/data.ts b/plugins/airtable/src/data.ts index a8627cd3c..89b370448 100644 --- a/plugins/airtable/src/data.ts +++ b/plugins/airtable/src/data.ts @@ -137,13 +137,21 @@ export async function inferFields(collection: ManagedCollection, table: Airtable break case "singleLineText": + fields.push({ + ...fieldMetadata, + airtableType: fieldSchema.type, + type: "string", + allowedTypes: ["string"], + }) + break + case "email": case "phoneNumber": fields.push({ ...fieldMetadata, airtableType: fieldSchema.type, type: "string", - allowedTypes: ["string"], + allowedTypes: ["string", "link"], }) break @@ -301,6 +309,19 @@ function getFieldDataEntryForFieldSchema(fieldSchema: PossibleField, value: unkn case "image": case "file": if (typeof value === "string") { + if (fieldSchema.airtableType === "email") { + return { + value: `mailto:${value}`, + type: "link", + } + } + if (fieldSchema.airtableType === "phoneNumber") { + return { + value: `tel:${value}`, + type: "link", + } + } + return { value, type: "string", From e2c32564e310f6fb336aa0ecec6f62d078cd4063 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ce=CC=81dric=20Boirard?= Date: Tue, 18 Mar 2025 16:25:31 +0100 Subject: [PATCH 2/3] Set default when enums are not specified MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Cédric Boirard --- plugins/airtable/src/data.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/plugins/airtable/src/data.ts b/plugins/airtable/src/data.ts index 89b370448..34ecf5170 100644 --- a/plugins/airtable/src/data.ts +++ b/plugins/airtable/src/data.ts @@ -459,12 +459,20 @@ export async function getItems(dataSource: DataSource, slugFieldId: string) { switch (field.type) { case "string": case "formattedText": - case "enum": fieldData[field.id] = { value: "", type: field.type, } break + case "enum": + console.warn( + `Missing value for field “${field.name}” on item “${item.id}”, it will be set to the first case.` + ) + fieldData[field.id] = { + value: field.cases[0].id, + type: "enum", + } + break case "boolean": fieldData[field.id] = { value: false, From be91db2bc4c00bb11f83b49fb4e0b8d9073b7dd9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ce=CC=81dric=20Boirard?= Date: Tue, 18 Mar 2025 16:39:18 +0100 Subject: [PATCH 3/3] Use the field type instead of always string MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Cédric Boirard --- plugins/airtable/src/data.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/airtable/src/data.ts b/plugins/airtable/src/data.ts index 34ecf5170..28929c8dd 100644 --- a/plugins/airtable/src/data.ts +++ b/plugins/airtable/src/data.ts @@ -324,7 +324,7 @@ function getFieldDataEntryForFieldSchema(fieldSchema: PossibleField, value: unkn return { value, - type: "string", + type: fieldSchema.type, } }