mirror of
https://github.com/n8n-io/n8n.git
synced 2024-11-11 12:26:30 +03:00
⚡ Minor improvements to ClickUp-Node
This commit is contained in:
parent
0ee2a0bbce
commit
59a81b81a0
@ -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);
|
||||
}
|
||||
|
@ -210,22 +210,6 @@ export const taskFields = [
|
||||
required: true,
|
||||
description: 'The first name on the task',
|
||||
},
|
||||
{
|
||||
displayName: 'JSON Parameters',
|
||||
name: 'jsonParameters',
|
||||
type: 'boolean',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'task',
|
||||
],
|
||||
operation: [
|
||||
'create',
|
||||
]
|
||||
},
|
||||
},
|
||||
default: false,
|
||||
},
|
||||
{
|
||||
displayName: 'Additional Fields',
|
||||
name: 'additionalFields',
|
||||
@ -256,6 +240,16 @@ export const taskFields = [
|
||||
|
||||
default: [],
|
||||
},
|
||||
{
|
||||
displayName: 'Custom Fields JSON',
|
||||
name: 'customFieldsJson',
|
||||
type: 'json',
|
||||
typeOptions: {
|
||||
alwaysOpenEditWindow: true,
|
||||
},
|
||||
default: '',
|
||||
description: 'Custom fields to set as JSON in the format:<br />[{"id": "", "value": ""}]',
|
||||
},
|
||||
{
|
||||
displayName: 'Content',
|
||||
name: 'content',
|
||||
@ -346,28 +340,6 @@ export const taskFields = [
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
displayName: 'Custom Fields',
|
||||
name: 'customFieldsJson',
|
||||
type: 'json',
|
||||
typeOptions: {
|
||||
alwaysOpenEditWindow: true,
|
||||
},
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'task',
|
||||
],
|
||||
operation: [
|
||||
'create',
|
||||
],
|
||||
jsonParameters: [
|
||||
true,
|
||||
],
|
||||
},
|
||||
},
|
||||
default: '',
|
||||
},
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* task:update */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
@ -764,7 +736,7 @@ export const taskFields = [
|
||||
name: 'includeClosed',
|
||||
type: 'boolean',
|
||||
default: false,
|
||||
description: 'the api does not include closed tasks. Set this to true and dont send a status filter to include closed tasks',
|
||||
description: 'The response does by default not include closed tasks. Set this to true and dont send a status filter to include closed tasks.',
|
||||
},
|
||||
{
|
||||
displayName: 'Order By',
|
||||
@ -864,7 +836,7 @@ export const taskFields = [
|
||||
],
|
||||
},
|
||||
},
|
||||
description: 'Task ID',
|
||||
description: 'The ID of the task to add custom field to.',
|
||||
},
|
||||
{
|
||||
displayName: 'Field ID',
|
||||
@ -882,7 +854,26 @@ export const taskFields = [
|
||||
],
|
||||
},
|
||||
},
|
||||
description: 'Task ID',
|
||||
description: 'The ID of the field to add custom field to.',
|
||||
},
|
||||
{
|
||||
displayName: 'Value is JSON',
|
||||
name: 'jsonParse',
|
||||
type: 'boolean',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'task',
|
||||
],
|
||||
operation: [
|
||||
'setCustomField',
|
||||
]
|
||||
},
|
||||
},
|
||||
default: false,
|
||||
description: `The value is JSON and will be parsed as such. Is needed<br />
|
||||
if for example needed for labels which expects the value<br />
|
||||
to be an array.`,
|
||||
},
|
||||
{
|
||||
displayName: 'Value',
|
||||
@ -900,6 +891,6 @@ export const taskFields = [
|
||||
],
|
||||
},
|
||||
},
|
||||
description: 'Value',
|
||||
description: 'The value to set on custom field.',
|
||||
},
|
||||
] as INodeProperties[];
|
||||
|
Loading…
Reference in New Issue
Block a user