From 30cef2a408558fc3f5cd1d000fe03f0f3386678a Mon Sep 17 00:00:00 2001 From: Jan Oberhauser Date: Fri, 18 Sep 2020 07:59:10 +0200 Subject: [PATCH] :zap: Minor improvements to Airtable-Node --- .../nodes/Airtable/Airtable.node.ts | 37 ++++++++++++------- 1 file changed, 23 insertions(+), 14 deletions(-) diff --git a/packages/nodes-base/nodes/Airtable/Airtable.node.ts b/packages/nodes-base/nodes/Airtable/Airtable.node.ts index 42a5c29007..9f22b3d2b8 100644 --- a/packages/nodes-base/nodes/Airtable/Airtable.node.ts +++ b/packages/nodes-base/nodes/Airtable/Airtable.node.ts @@ -360,11 +360,11 @@ export class Airtable implements INodeType { // ---------------------------------- // append + update // ---------------------------------- - { - displayName: 'Typecast', - name: 'typecast', - type: 'boolean', + displayName: 'Options', + name: 'options', + type: 'collection', + placeholder: 'Add Option', displayOptions: { show: { operation: [ @@ -373,10 +373,17 @@ export class Airtable implements INodeType { ], }, }, - default: false, - description: 'If the Airtable API should attempt mapping of string values for linked records & select options.', + default: {}, + options: [ + { + displayName: 'Typecast', + name: 'typecast', + type: 'boolean', + default: false, + description: 'If the Airtable API should attempt mapping of string values for linked records & select options.', + }, + ], }, - ], }; @@ -407,9 +414,11 @@ export class Airtable implements INodeType { let addAllFields: boolean; let fields: string[]; - let typecast: boolean; + let options: IDataObject; + for (let i = 0; i < items.length; i++) { addAllFields = this.getNodeParameter('addAllFields', i) as boolean; + options = this.getNodeParameter('options', i, {}) as IDataObject; if (addAllFields === true) { // Add all the fields the item has @@ -425,9 +434,8 @@ export class Airtable implements INodeType { body.fields[fieldName] = items[i].json[fieldName]; } } - - typecast = this.getNodeParameter('typecast', i) as boolean; - if (typecast === true) { + + if (options.typecast === true) { body['typecast'] = true; } @@ -521,9 +529,11 @@ export class Airtable implements INodeType { let id: string; let updateAllFields: boolean; let fields: string[]; - let typecast: boolean; + let options: IDataObject; + for (let i = 0; i < items.length; i++) { updateAllFields = this.getNodeParameter('updateAllFields', i) as boolean; + options = this.getNodeParameter('options', i, {}) as IDataObject; if (updateAllFields === true) { // Update all the fields the item has @@ -540,8 +550,7 @@ export class Airtable implements INodeType { } } - typecast = this.getNodeParameter('typecast', i) as boolean; - if (typecast === true) { + if (options.typecast === true) { body['typecast'] = true; }