Add the posiblity to set multi-select fields with the names (#1892)

*  Add the posiblity to set multi-select fields with the names

* 🐛 Fix issue with expressions

Co-authored-by: Jan Oberhauser <jan.oberhauser@gmail.com>
This commit is contained in:
Ricardo Espinoza
2021-06-13 13:17:39 -04:00
committed by GitHub
parent 68914a1fcf
commit 233fc72dc2
11 changed files with 30 additions and 13 deletions

View File

@@ -47,6 +47,7 @@ import {
databasePageFields,
databasePageOperations,
} from './DatabasePageDescription';
import { getServers } from 'dns';
export class Notion implements INodeType {
description: INodeTypeDescription = {
@@ -215,8 +216,16 @@ export class Notion implements INodeType {
const resource = this.getCurrentNodeParameter('resource') as string;
const operation = this.getCurrentNodeParameter('operation') as string;
const { properties } = await notionApiRequest.call(this, 'GET', `/databases/${databaseId}`);
const useNames = (resource === 'databasePage' && operation === 'getAll');
return (properties[name][type].options).map((option: IDataObject) => ({ name: option.name, value: (['select', 'multi_select'].includes(type) && useNames) ? option.name : option.id }));
if (resource === 'databasePage') {
if (['multi_select', 'select'].includes(type) && operation === 'getAll') {
return (properties[name][type].options)
.map((option: IDataObject) => ({ name: option.name, value: option.name }));
} else if (['multi_select'].includes(type) && ['create', 'update'].includes(operation)) {
return (properties[name][type].options)
.map((option: IDataObject) => ({ name: option.name, value: option.name }));
}
}
return (properties[name][type].options).map((option: IDataObject) => ({ name: option.name, value: option.id }));
},
async getUsers(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]> {
const returnData: INodePropertyOptions[] = [];