Improvements to ClickUp-Node (#921)

This commit is contained in:
Ricardo Espinoza 2020-09-06 15:38:18 -04:00 committed by GitHub
parent d64c767ebd
commit f24afcd86f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 297 additions and 8 deletions

View file

@ -99,7 +99,7 @@ export class ClickUp implements INodeType {
{
name: 'clickUpApi',
required: true,
}
},
],
properties: [
{
@ -296,7 +296,7 @@ export class ClickUp implements INodeType {
const { tags } = await clickupApiRequest.call(this, 'GET', `/space/${spaceId}/tag`);
for (const tag of tags) {
const tagName = tag.name;
const tagId = tag.id;
const tagId = tag.name;
returnData.push({
name: tagName,
value: tagId,
@ -320,6 +320,23 @@ export class ClickUp implements INodeType {
}
return returnData;
},
// Get all the custom fields to display them to user so that he can
// select them easily
async getCustomFields(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]> {
const listId = this.getCurrentNodeParameter('list') as string;
const returnData: INodePropertyOptions[] = [];
const { fields } = await clickupApiRequest.call(this, 'GET', `/list/${listId}/field`);
for (const field of fields) {
const fieldName = field.name;
const fieldId = field.id;
returnData.push({
name: fieldName,
value: fieldId,
});
}
return returnData;
},
},
};
@ -846,6 +863,22 @@ export class ClickUp implements INodeType {
if (filters.dateUpdatedLt) {
qs.date_updated_lt = new Date(filters.dateUpdatedLt as string).getTime();
}
if (filters.customFieldsUi) {
const customFieldsValues = (filters.customFieldsUi as IDataObject).customFieldsValues as IDataObject[];
if (customFieldsValues) {
const customFields: IDataObject[] = [];
for (const customFieldValue of customFieldsValues) {
customFields.push({
field_id: customFieldValue.fieldId,
operator: (customFieldValue.operator === 'equal') ? '=' : customFieldValue.operator,
value: customFieldValue.value as string,
});
}
qs.custom_fields = JSON.stringify(customFields);
}
}
const listId = this.getNodeParameter('list', i) as string;
if (returnAll === true) {
responseData = await clickupApiRequestAllItems.call(this, 'tasks', 'GET', `/list/${listId}/task`, {}, qs);
@ -855,6 +888,19 @@ export class ClickUp implements INodeType {
responseData = responseData.splice(0, qs.limit);
}
}
if (operation === 'member') {
const taskId = this.getNodeParameter('id', i) as string;
const returnAll = this.getNodeParameter('returnAll', i) as boolean;
if (returnAll === true) {
responseData = await clickupApiRequest.call(this, 'GET', `/task/${taskId}/member`, {}, qs);
responseData = responseData.members;
} else {
qs.limit = this.getNodeParameter('limit', i) as number;
responseData = await clickupApiRequest.call(this, 'GET', `/task/${taskId}/member`, {}, qs);
responseData = responseData.members;
responseData = responseData.splice(0, qs.limit);
}
}
if (operation === 'setCustomField') {
const taskId = this.getNodeParameter('task', i) as string;
const fieldId = this.getNodeParameter('field', i) as string;
@ -984,6 +1030,19 @@ export class ClickUp implements INodeType {
responseData = await clickupApiRequest.call(this, 'POST', `/folder/${folderId}/list`, body);
}
}
if (operation === 'member') {
const listId = this.getNodeParameter('id', i) as string;
const returnAll = this.getNodeParameter('returnAll', i) as boolean;
if (returnAll === true) {
responseData = await clickupApiRequest.call(this, 'GET', `/list/${listId}/member`, {}, qs);
responseData = responseData.members;
} else {
qs.limit = this.getNodeParameter('limit', i) as number;
responseData = await clickupApiRequest.call(this, 'GET', `/list/${listId}/member`, {}, qs);
responseData = responseData.members;
responseData = responseData.splice(0, qs.limit);
}
}
if (operation === 'customFields') {
const listId = this.getNodeParameter('list', i) as string;
responseData = await clickupApiRequest.call(this, 'GET', `/list/${listId}/field`);

View file

@ -40,6 +40,11 @@ export const listOperations = [
value: 'getAll',
description: 'Get all lists',
},
{
name: 'Member',
value: 'member',
description: 'Get list members',
},
{
name: 'Update',
value: 'update',
@ -229,6 +234,68 @@ export const listFields = [
],
},
/* -------------------------------------------------------------------------- */
/* list:member */
/* -------------------------------------------------------------------------- */
{
displayName: 'List ID',
name: 'id',
type: 'string',
default: '',
required: true,
displayOptions: {
show: {
resource: [
'list',
],
operation: [
'member',
],
},
},
description: 'Task ID',
},
{
displayName: 'Return All',
name: 'returnAll',
type: 'boolean',
displayOptions: {
show: {
resource: [
'list',
],
operation: [
'member',
],
},
},
default: true,
description: 'If all results should be returned or only up to a given limit.',
},
{
displayName: 'Limit',
name: 'limit',
type: 'number',
displayOptions: {
show: {
resource: [
'list',
],
operation: [
'member',
],
returnAll: [
false,
],
},
},
typeOptions: {
minValue: 1,
maxValue: 100,
},
default: 50,
description: 'How many results to return.',
},
/* -------------------------------------------------------------------------- */
/* list:customFields */
/* -------------------------------------------------------------------------- */
{

View file

@ -31,12 +31,17 @@ export const taskOperations = [
description: 'Get a task',
},
{
name: 'Get all',
name: 'Get All',
value: 'getAll',
description: 'Get all tasks',
},
{
name: 'Set custom field',
name: 'Member',
value: 'member',
description: 'Get task members',
},
{
name: 'Set Custom Field',
value: 'setCustomField',
description: 'Set a custom field',
},
@ -95,7 +100,7 @@ export const taskFields = [
loadOptionsMethod: 'getSpaces',
loadOptionsDependsOn: [
'team',
]
],
},
required: true,
},
@ -190,7 +195,7 @@ export const taskFields = [
loadOptionsMethod: 'getLists',
loadOptionsDependsOn: [
'folder',
]
],
},
required: true,
},
@ -239,7 +244,6 @@ export const taskFields = [
typeOptions: {
loadOptionsMethod: 'getAssignees',
},
default: [],
},
{
@ -302,6 +306,12 @@ export const taskFields = [
description: 'Integer mapping as 1 : Urgent, 2 : High, 3 : Normal, 4 : Low',
default: 3,
},
{
displayName: 'Start Date',
name: 'startDate',
type: 'dateTime',
default: '',
},
{
displayName: 'Start Date Time',
name: 'startDateTime',
@ -457,6 +467,12 @@ export const taskFields = [
default: '',
description: 'status'
},
{
displayName: 'Start Date',
name: 'startDate',
type: 'dateTime',
default: '',
},
{
displayName: 'Start Date Time',
name: 'startDateTime',
@ -631,7 +647,7 @@ export const taskFields = [
loadOptionsMethod: 'getLists',
loadOptionsDependsOn: [
'folder',
]
],
},
required: true,
},
@ -712,6 +728,91 @@ export const taskFields = [
default: [],
},
{
displayName: 'Custom Fields',
name: 'customFieldsUi',
placeholder: 'Add Custom Field',
type: 'fixedCollection',
typeOptions: {
multipleValues: true,
},
description: 'Filter by custom fields ',
default: {},
options: [
{
name: 'customFieldsValues',
displayName: 'Custom Field',
values: [
{
displayName: 'Field ID',
name: 'fieldId',
type: 'options',
typeOptions: {
loadOptionsMethod: 'getCustomFields',
},
default: '',
description: 'The ID of the field to add custom field to.',
},
{
displayName: 'Operator',
name: 'operator',
type: 'options',
options: [
{
name: 'Equal',
value: 'equal',
},
{
name: '<',
value: '<',
},
{
name: '<=',
value: '<=',
},
{
name: '>',
value: '>',
},
{
name: '>=',
value: '>=',
},
{
name: '!=',
value: '!=',
},
{
name: 'Is Null',
value: 'IS NULL',
},
{
name: 'Is Not Null',
value: 'IS NOT NULL',
},
],
default: 'equal',
description: 'The value to set on custom field.',
},
{
displayName: 'Value',
name: 'value',
type: 'string',
displayOptions: {
hide: {
operator: [
'IS NULL',
'IS NOT NULL',
],
},
},
default: '',
description: 'The value to set on custom field.',
},
],
},
],
},
{
displayName: 'Date Created Greater Than',
name: 'dateCreatedGt',
@ -841,6 +942,68 @@ export const taskFields = [
description: 'task ID',
},
/* -------------------------------------------------------------------------- */
/* task:member */
/* -------------------------------------------------------------------------- */
{
displayName: 'Task ID',
name: 'id',
type: 'string',
default: '',
required: true,
displayOptions: {
show: {
resource: [
'task',
],
operation: [
'member',
],
},
},
description: 'Task ID',
},
{
displayName: 'Return All',
name: 'returnAll',
type: 'boolean',
displayOptions: {
show: {
resource: [
'task',
],
operation: [
'member',
],
},
},
default: true,
description: 'If all results should be returned or only up to a given limit.',
},
{
displayName: 'Limit',
name: 'limit',
type: 'number',
displayOptions: {
show: {
resource: [
'task',
],
operation: [
'member',
],
returnAll: [
false,
],
},
},
typeOptions: {
minValue: 1,
maxValue: 100,
},
default: 50,
description: 'How many results to return.',
},
/* -------------------------------------------------------------------------- */
/* task:setCustomField */
/* -------------------------------------------------------------------------- */
{