Minor improvements to Airtable-Node

This commit is contained in:
Jan Oberhauser
2020-09-18 07:59:10 +02:00
parent 8221cb5d24
commit 30cef2a408

View File

@@ -360,11 +360,11 @@ export class Airtable implements INodeType {
// ---------------------------------- // ----------------------------------
// append + update // append + update
// ---------------------------------- // ----------------------------------
{ {
displayName: 'Typecast', displayName: 'Options',
name: 'typecast', name: 'options',
type: 'boolean', type: 'collection',
placeholder: 'Add Option',
displayOptions: { displayOptions: {
show: { show: {
operation: [ operation: [
@@ -373,10 +373,17 @@ export class Airtable implements INodeType {
], ],
}, },
}, },
default: false, default: {},
description: 'If the Airtable API should attempt mapping of string values for linked records & select options.', 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 addAllFields: boolean;
let fields: string[]; let fields: string[];
let typecast: boolean; let options: IDataObject;
for (let i = 0; i < items.length; i++) { for (let i = 0; i < items.length; i++) {
addAllFields = this.getNodeParameter('addAllFields', i) as boolean; addAllFields = this.getNodeParameter('addAllFields', i) as boolean;
options = this.getNodeParameter('options', i, {}) as IDataObject;
if (addAllFields === true) { if (addAllFields === true) {
// Add all the fields the item has // Add all the fields the item has
@@ -425,9 +434,8 @@ export class Airtable implements INodeType {
body.fields[fieldName] = items[i].json[fieldName]; body.fields[fieldName] = items[i].json[fieldName];
} }
} }
typecast = this.getNodeParameter('typecast', i) as boolean; if (options.typecast === true) {
if (typecast === true) {
body['typecast'] = true; body['typecast'] = true;
} }
@@ -521,9 +529,11 @@ export class Airtable implements INodeType {
let id: string; let id: string;
let updateAllFields: boolean; let updateAllFields: boolean;
let fields: string[]; let fields: string[];
let typecast: boolean; let options: IDataObject;
for (let i = 0; i < items.length; i++) { for (let i = 0; i < items.length; i++) {
updateAllFields = this.getNodeParameter('updateAllFields', i) as boolean; updateAllFields = this.getNodeParameter('updateAllFields', i) as boolean;
options = this.getNodeParameter('options', i, {}) as IDataObject;
if (updateAllFields === true) { if (updateAllFields === true) {
// Update all the fields the item has // Update all the fields the item has
@@ -540,8 +550,7 @@ export class Airtable implements INodeType {
} }
} }
typecast = this.getNodeParameter('typecast', i) as boolean; if (options.typecast === true) {
if (typecast === true) {
body['typecast'] = true; body['typecast'] = true;
} }