small improvements

This commit is contained in:
ricardo 2020-04-21 20:12:20 -05:00
parent b395ac0686
commit 75b829f8ae
3 changed files with 68 additions and 33 deletions

View file

@ -570,6 +570,18 @@ export class ClickUp implements INodeType {
name, name,
type, 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) { if (additionalFields.unit) {
body.unit = additionalFields.unit as string; body.unit = additionalFields.unit as string;
} }
@ -873,33 +885,28 @@ export class ClickUp implements INodeType {
if (resource === 'taskDependency') { if (resource === 'taskDependency') {
if (operation === 'create') { if (operation === 'create') {
const taskId = this.getNodeParameter('task', i) as string; const taskId = this.getNodeParameter('task', i) as string;
const dependsOn = this.getNodeParameter('dependsOn', i) as string; const dependecyIs = this.getNodeParameter('is', i) as string;
const dependencyOf = this.getNodeParameter('dependencyOf', i) as string; const theTaskId = this.getNodeParameter('theTaskId', i) as string;
if (dependencyOf !== '' && dependsOn !== '' ) {
throw new Error('Both can not be passed in the same request.');
}
const body: IDataObject = {}; const body: IDataObject = {};
if (dependsOn) { if (dependecyIs === 'waitingOn') {
body.depends_on = dependsOn; body.depends_on = theTaskId;
} }
if (dependencyOf) { if (dependecyIs === 'blocking') {
body.dependency_of = dependencyOf; body.dependency_of = theTaskId;
} }
responseData = await clickupApiRequest.call(this, 'POST', `/task/${taskId}/dependency`, body); responseData = await clickupApiRequest.call(this, 'POST', `/task/${taskId}/dependency`, body);
responseData = { success: true }; responseData = { success: true };
} }
if (operation === 'delete') { if (operation === 'delete') {
const taskId = this.getNodeParameter('task', i) as string; const taskId = this.getNodeParameter('task', i) as string;
const dependsOn = this.getNodeParameter('dependsOn', i) as string; const dependecyIs = this.getNodeParameter('is', i) as string;
const dependencyOf = this.getNodeParameter('dependencyOf', i) as string; const theTaskId = this.getNodeParameter('theTaskId', i) as string;
if (dependencyOf !== '' && dependsOn !== '' ) {
throw new Error('Both can not be passed in the same request.'); if (dependecyIs === 'waitingOn') {
qs.depends_on = theTaskId;
} }
if (dependsOn) { if (dependecyIs === 'blocking') {
qs.depends_on = dependsOn; qs.dependency_of = theTaskId;
}
if (dependencyOf) {
qs.dependency_of = dependencyOf;
} }
responseData = await clickupApiRequest.call(this, 'DELETE', `/task/${taskId}/dependency`, {}, qs); responseData = await clickupApiRequest.call(this, 'DELETE', `/task/${taskId}/dependency`, {}, qs);
responseData = { success: true }; responseData = { success: true };

View file

@ -151,7 +151,7 @@ export const goalKeyResultFields = [
minValue: 0, minValue: 0,
}, },
default: 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', displayName: 'Steps End',
@ -161,7 +161,7 @@ export const goalKeyResultFields = [
minValue: 0, minValue: 0,
}, },
default: 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', displayName: 'Task IDs',
@ -257,7 +257,7 @@ export const goalKeyResultFields = [
typeOptions: { typeOptions: {
minValue: 0, minValue: 0,
}, },
default: 0, default: 1,
}, },
{ {
displayName: 'Steps End', displayName: 'Steps End',

View file

@ -54,10 +54,22 @@ export const taskDependencyFields = [
required: true, required: true,
}, },
{ {
displayName: 'Depends On', displayName: 'Is',
name: 'dependsOn', name: 'is',
type: 'string', type: 'options',
default: '', 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: { displayOptions: {
show: { show: {
resource: [ resource: [
@ -68,12 +80,13 @@ export const taskDependencyFields = [
], ],
}, },
}, },
description: 'Dependency type between the two tasks',
required: true,
}, },
{ {
displayName: 'Dependency Of', displayName: 'The Task ID',
name: 'dependencyOf', name: 'theTaskId',
type: 'string', type: 'string',
default: '',
displayOptions: { displayOptions: {
show: { show: {
resource: [ resource: [
@ -84,6 +97,7 @@ export const taskDependencyFields = [
], ],
}, },
}, },
required: true,
}, },
/* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */
/* taskDependency:delete */ /* taskDependency:delete */
@ -106,10 +120,22 @@ export const taskDependencyFields = [
required: true, required: true,
}, },
{ {
displayName: 'Depends On', displayName: 'Is',
name: 'dependsOn', name: 'is',
type: 'string', type: 'options',
default: '', 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: { displayOptions: {
show: { show: {
resource: [ resource: [
@ -120,12 +146,13 @@ export const taskDependencyFields = [
], ],
}, },
}, },
description: 'Dependency type between the two tasks',
required: true,
}, },
{ {
displayName: 'Dependency Of', displayName: 'The Task ID',
name: 'dependencyOf', name: 'theTaskId',
type: 'string', type: 'string',
default: '',
displayOptions: { displayOptions: {
show: { show: {
resource: [ resource: [
@ -136,5 +163,6 @@ export const taskDependencyFields = [
], ],
}, },
}, },
required: true,
}, },
] as INodeProperties[]; ] as INodeProperties[];