mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 01:56:46 +00:00
⚡ Minor improvements to ClickUp-Node
This commit is contained in:
@@ -53,14 +53,14 @@ export class ClickUp implements INodeType {
|
||||
name: 'resource',
|
||||
type: 'options',
|
||||
options: [
|
||||
{
|
||||
name: 'Task',
|
||||
value: 'task',
|
||||
},
|
||||
{
|
||||
name: 'List',
|
||||
value: 'list',
|
||||
},
|
||||
{
|
||||
name: 'Task',
|
||||
value: 'task',
|
||||
},
|
||||
],
|
||||
default: 'task',
|
||||
description: 'Resource to consume.',
|
||||
@@ -219,11 +219,17 @@ export class ClickUp implements INodeType {
|
||||
if (operation === 'create') {
|
||||
const listId = this.getNodeParameter('list', i) as string;
|
||||
const name = this.getNodeParameter('name', i) as string;
|
||||
const jsonActive = this.getNodeParameter('jsonParameters', i) as boolean;
|
||||
const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject;
|
||||
const body: ITask = {
|
||||
name,
|
||||
};
|
||||
if (additionalFields.customFieldsJson) {
|
||||
const customFields = validateJSON(additionalFields.customFieldsJson as string);
|
||||
if (customFields === undefined) {
|
||||
throw new Error('Custom Fields: Invalid JSON');
|
||||
}
|
||||
body.custom_fields = customFields;
|
||||
}
|
||||
if (additionalFields.content) {
|
||||
body.content = additionalFields.content as string;
|
||||
}
|
||||
@@ -264,13 +270,6 @@ export class ClickUp implements INodeType {
|
||||
delete body.content;
|
||||
body.markdown_content = additionalFields.content as string;
|
||||
}
|
||||
if (jsonActive) {
|
||||
const customFields = validateJSON(this.getNodeParameter('customFieldsJson', i) as string);
|
||||
if (customFields === undefined) {
|
||||
throw new Error('Custom Fields: Invalid JSON');
|
||||
}
|
||||
body.custom_fields = customFields;
|
||||
}
|
||||
responseData = await clickupApiRequest.call(this, 'POST', `/list/${listId}/task`, body);
|
||||
}
|
||||
if (operation === 'update') {
|
||||
@@ -373,11 +372,20 @@ export class ClickUp implements INodeType {
|
||||
const taskId = this.getNodeParameter('task', i) as string;
|
||||
const fieldId = this.getNodeParameter('field', i) as string;
|
||||
const value = this.getNodeParameter('value', i) as string;
|
||||
const jsonParse = this.getNodeParameter('jsonParse', i) as boolean;
|
||||
|
||||
const body: IDataObject = {};
|
||||
body.value = value;
|
||||
//@ts-ignore
|
||||
if (!isNaN(value)) {
|
||||
body.value = parseInt(value, 10);
|
||||
if (jsonParse === true) {
|
||||
body.value = validateJSON(body.value);
|
||||
if (body.value === undefined) {
|
||||
throw new Error('Value is invalid JSON!');
|
||||
}
|
||||
} else {
|
||||
//@ts-ignore
|
||||
if (!isNaN(body.value)) {
|
||||
body.value = parseInt(body.value, 10);
|
||||
}
|
||||
}
|
||||
responseData = await clickupApiRequest.call(this, 'POST', `/task/${taskId}/field/${fieldId}`, body);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user