Some improvements to Asana project additions

This commit is contained in:
Jan Oberhauser 2022-02-26 11:10:40 +01:00
parent 0a92e616b6
commit d7a26da699
2 changed files with 51 additions and 14 deletions

View file

@ -1,4 +1,4 @@
import {IExecuteFunctions,} from 'n8n-core'; import { IExecuteFunctions } from 'n8n-core';
import { import {
IDataObject, IDataObject,
@ -12,11 +12,17 @@ import {
NodeOperationError, NodeOperationError,
} from 'n8n-workflow'; } from 'n8n-workflow';
import {asanaApiRequest, asanaApiRequestAllItems, getTaskFields, getWorkspaces,} from './GenericFunctions'; import {
asanaApiRequest,
asanaApiRequestAllItems,
getColorOptions,
getTaskFields,
getWorkspaces,
} from './GenericFunctions';
import * as moment from 'moment-timezone'; import * as moment from 'moment-timezone';
import {snakeCase,} from 'change-case'; import { snakeCase } from 'change-case';
export class Asana implements INodeType { export class Asana implements INodeType {
description: INodeTypeDescription = { description: INodeTypeDescription = {
@ -1600,8 +1606,9 @@ export class Asana implements INodeType {
{ {
displayName: 'Color', displayName: 'Color',
name: 'color', name: 'color',
type: 'string', type: 'options',
default: '', options: getColorOptions(),
default: 'none',
description: 'Color of the project.', description: 'Color of the project.',
}, },
{ {
@ -1793,10 +1800,9 @@ export class Asana implements INodeType {
description: 'The workspace in which to get users.', description: 'The workspace in which to get users.',
}, },
{ {
displayName: 'Project', displayName: 'Project ID',
name: 'projectId', name: 'id',
type: 'string', type: 'string',
options: [],
default: '', default: '',
required: true, required: true,
displayOptions: { displayOptions: {
@ -1809,7 +1815,7 @@ export class Asana implements INodeType {
], ],
}, },
}, },
description: 'The project to update info on.', description: 'The ID of the project to update the data of.',
}, },
{ {
displayName: 'Update Fields', displayName: 'Update Fields',
@ -1832,8 +1838,9 @@ export class Asana implements INodeType {
{ {
displayName: 'Color', displayName: 'Color',
name: 'color', name: 'color',
type: 'string', type: 'options',
default: '', options: getColorOptions(),
default: 'none',
description: 'Color of the project.', description: 'Color of the project.',
}, },
{ {
@ -2488,9 +2495,9 @@ export class Asana implements INodeType {
endpoint = `/projects/${projectId}`; endpoint = `/projects/${projectId}`;
responseData = await asanaApiRequest.call(this, requestMethod, endpoint, body, qs); asanaApiRequest.call(this, requestMethod, endpoint, body, qs);
responseData = responseData.data; responseData = { success: true };
} }
if (operation === 'get') { if (operation === 'get') {
@ -2548,7 +2555,7 @@ export class Asana implements INodeType {
// ---------------------------------- // ----------------------------------
// project:update // project:update
// ---------------------------------- // ----------------------------------
const projectId = this.getNodeParameter('projectId', i) as string; const projectId = this.getNodeParameter('id', i) as string;
const updateFields = this.getNodeParameter('updateFields', i) as IDataObject; const updateFields = this.getNodeParameter('updateFields', i) as IDataObject;
// request parameters // request parameters

View file

@ -86,6 +86,36 @@ export async function getWorkspaces(this: ILoadOptionsFunctions): Promise<INodeP
return returnData; return returnData;
} }
export function getColorOptions(): INodePropertyOptions[] {
return [
'dark-blue',
'dark-brown',
'dark-green',
'dark-orange',
'dark-pink',
'dark-purple',
'dark-red',
'dark-teal',
'dark-warm-gray',
'light-blue',
'light-green',
'light-orange',
'light-pink',
'light-purple',
'light-red',
'light-teal',
'light-warm-gray',
'light-yellow',
'none',
].map(value => {
return {
name: value,
value: value,
};
});
}
export function getTaskFields() { export function getTaskFields() {
return [ return [
'*', '*',