From 75b829f8aecdaaa8a8e9eb6e4a6a1a92bf5f5e6f Mon Sep 17 00:00:00 2001 From: ricardo Date: Tue, 21 Apr 2020 20:12:20 -0500 Subject: [PATCH] :zap: small improvements --- .../nodes-base/nodes/ClickUp/ClickUp.node.ts | 43 ++++++++------- .../nodes/ClickUp/GoalKeyResultDescription.ts | 6 +-- .../ClickUp/TaskDependencyDescription.ts | 52 ++++++++++++++----- 3 files changed, 68 insertions(+), 33 deletions(-) diff --git a/packages/nodes-base/nodes/ClickUp/ClickUp.node.ts b/packages/nodes-base/nodes/ClickUp/ClickUp.node.ts index 09d9d183b1..b638e8c9e9 100644 --- a/packages/nodes-base/nodes/ClickUp/ClickUp.node.ts +++ b/packages/nodes-base/nodes/ClickUp/ClickUp.node.ts @@ -570,6 +570,18 @@ export class ClickUp implements INodeType { name, type, }; + if (type === 'number' || type === 'currency') { + if (!additionalFields.unit) { + throw new Error('Unit field must be set'); + } + } + if (type === 'number' || type === 'percentaje' + || type === 'automatic' || type === 'currency' ) { + if (additionalFields.stepsStart === undefined + || !additionalFields.stepsEnd === undefined) { + throw new Error('Steps start and steps end fields must be set'); + } + } if (additionalFields.unit) { body.unit = additionalFields.unit as string; } @@ -873,33 +885,28 @@ export class ClickUp implements INodeType { if (resource === 'taskDependency') { if (operation === 'create') { const taskId = this.getNodeParameter('task', i) as string; - const dependsOn = this.getNodeParameter('dependsOn', i) as string; - const dependencyOf = this.getNodeParameter('dependencyOf', i) as string; - if (dependencyOf !== '' && dependsOn !== '' ) { - throw new Error('Both can not be passed in the same request.'); - } + const dependecyIs = this.getNodeParameter('is', i) as string; + const theTaskId = this.getNodeParameter('theTaskId', i) as string; const body: IDataObject = {}; - if (dependsOn) { - body.depends_on = dependsOn; + if (dependecyIs === 'waitingOn') { + body.depends_on = theTaskId; } - if (dependencyOf) { - body.dependency_of = dependencyOf; + if (dependecyIs === 'blocking') { + body.dependency_of = theTaskId; } responseData = await clickupApiRequest.call(this, 'POST', `/task/${taskId}/dependency`, body); responseData = { success: true }; } if (operation === 'delete') { const taskId = this.getNodeParameter('task', i) as string; - const dependsOn = this.getNodeParameter('dependsOn', i) as string; - const dependencyOf = this.getNodeParameter('dependencyOf', i) as string; - if (dependencyOf !== '' && dependsOn !== '' ) { - throw new Error('Both can not be passed in the same request.'); + const dependecyIs = this.getNodeParameter('is', i) as string; + const theTaskId = this.getNodeParameter('theTaskId', i) as string; + + if (dependecyIs === 'waitingOn') { + qs.depends_on = theTaskId; } - if (dependsOn) { - qs.depends_on = dependsOn; - } - if (dependencyOf) { - qs.dependency_of = dependencyOf; + if (dependecyIs === 'blocking') { + qs.dependency_of = theTaskId; } responseData = await clickupApiRequest.call(this, 'DELETE', `/task/${taskId}/dependency`, {}, qs); responseData = { success: true }; diff --git a/packages/nodes-base/nodes/ClickUp/GoalKeyResultDescription.ts b/packages/nodes-base/nodes/ClickUp/GoalKeyResultDescription.ts index 41cb29cb17..657731ac4f 100644 --- a/packages/nodes-base/nodes/ClickUp/GoalKeyResultDescription.ts +++ b/packages/nodes-base/nodes/ClickUp/GoalKeyResultDescription.ts @@ -151,7 +151,7 @@ export const goalKeyResultFields = [ minValue: 0, }, default: 0, - description: 'Required for Percentage, Automatic (when Task IDs or List IDs are filled), Number and Currency', + description: 'Required for Percentage, Automatic, Number and Currency', }, { displayName: 'Steps End', @@ -161,7 +161,7 @@ export const goalKeyResultFields = [ minValue: 0, }, default: 0, - description: 'Required for Percentage, Automatic (when Task IDs or List IDs are filled), Number and Currency', + description: 'Required for Percentage, Automatic, Number and Currency', }, { displayName: 'Task IDs', @@ -257,7 +257,7 @@ export const goalKeyResultFields = [ typeOptions: { minValue: 0, }, - default: 0, + default: 1, }, { displayName: 'Steps End', diff --git a/packages/nodes-base/nodes/ClickUp/TaskDependencyDescription.ts b/packages/nodes-base/nodes/ClickUp/TaskDependencyDescription.ts index 8150394f8c..48f2254358 100644 --- a/packages/nodes-base/nodes/ClickUp/TaskDependencyDescription.ts +++ b/packages/nodes-base/nodes/ClickUp/TaskDependencyDescription.ts @@ -54,10 +54,22 @@ export const taskDependencyFields = [ required: true, }, { - displayName: 'Depends On', - name: 'dependsOn', - type: 'string', + displayName: 'Is', + name: 'is', + type: 'options', default: '', + options: [ + { + name: 'Bloking', + value: 'blocking', + description: `Tasks that can't start until the task above is completed`, + }, + { + name: 'Waiting On', + value: 'waitingOn', + description: `Tasks that must be completed before the task above`, + }, + ], displayOptions: { show: { resource: [ @@ -68,12 +80,13 @@ export const taskDependencyFields = [ ], }, }, + description: 'Dependency type between the two tasks', + required: true, }, { - displayName: 'Dependency Of', - name: 'dependencyOf', + displayName: 'The Task ID', + name: 'theTaskId', type: 'string', - default: '', displayOptions: { show: { resource: [ @@ -84,6 +97,7 @@ export const taskDependencyFields = [ ], }, }, + required: true, }, /* -------------------------------------------------------------------------- */ /* taskDependency:delete */ @@ -106,10 +120,22 @@ export const taskDependencyFields = [ required: true, }, { - displayName: 'Depends On', - name: 'dependsOn', - type: 'string', + displayName: 'Is', + name: 'is', + type: 'options', default: '', + options: [ + { + name: 'Bloking', + value: 'blocking', + description: `Tasks that can't start until the task above is completed`, + }, + { + name: 'Waiting On', + value: 'waitingOn', + description: `Tasks that must be completed before the task above`, + }, + ], displayOptions: { show: { resource: [ @@ -120,12 +146,13 @@ export const taskDependencyFields = [ ], }, }, + description: 'Dependency type between the two tasks', + required: true, }, { - displayName: 'Dependency Of', - name: 'dependencyOf', + displayName: 'The Task ID', + name: 'theTaskId', type: 'string', - default: '', displayOptions: { show: { resource: [ @@ -136,5 +163,6 @@ export const taskDependencyFields = [ ], }, }, + required: true, }, ] as INodeProperties[];