Skip to content

Commit cce4029

Browse files
committed
Create Field improvements
1 parent c8b4554 commit cce4029

File tree

1 file changed

+33
-10
lines changed

1 file changed

+33
-10
lines changed

components/airtable_oauth/actions/create-field/create-field.mjs

Lines changed: 33 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import constants from "../../sources/common/constants.mjs";
12
import common from "../common/common.mjs";
23

34
export default {
@@ -8,23 +9,45 @@ export default {
89
type: "action",
910
props: {
1011
...common.props,
11-
field: {
12+
name: {
1213
type: "string",
13-
label: "Field",
14-
description: "A JSON object representing the field. [See the documentation](https://airtable.com/developers/web/api/model/field-type) for supported field types, the write format for field options, and other specifics for certain field types.",
14+
label: "Field Name",
15+
description: "The name of the field",
16+
},
17+
type: {
18+
type: "string",
19+
label: "Field Type",
20+
description: "The field type. [See the documentation](https://airtable.com/developers/web/api/model/field-type) for more information.",
21+
options: constants.FIELD_TYPES,
22+
},
23+
description: {
24+
type: "string",
25+
label: "Field Description",
26+
description: "The description of the field",
27+
optional: true,
28+
},
29+
options: {
30+
type: "object",
31+
label: "Field Options",
32+
description: "The options for the field as a JSON object, e.g. `{ \"color\": \"greenBright\" }`. Each type has a specific set of options - [see the documentation](https://airtable.com/developers/web/api/field-model) for more information.",
33+
optional: true,
1534
},
1635
},
1736
async run({ $ }) {
18-
const field = typeof this.field === "object"
19-
? this.field
20-
: JSON.parse(this.field);
21-
const data = {
22-
...field,
23-
};
37+
const {
38+
description, name, options, type,
39+
} = this;
2440
const response = await this.airtable.createField({
2541
baseId: this.baseId.value,
2642
tableId: this.tableId.value,
27-
data,
43+
data: {
44+
name,
45+
type,
46+
description,
47+
options: typeof options === "string"
48+
? JSON.parse(options)
49+
: options,
50+
},
2851
$,
2952
});
3053

0 commit comments

Comments
 (0)