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,
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 };

View file

@ -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',

View file

@ -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[];