mirror of
https://github.com/n8n-io/n8n.git
synced 2024-12-24 20:24:05 -08:00
⚡ Minor improvements to ClickUp-Node
This commit is contained in:
parent
15c0eae56d
commit
edd2d39fb1
|
@ -79,13 +79,13 @@ import {
|
||||||
|
|
||||||
import {
|
import {
|
||||||
ITask,
|
ITask,
|
||||||
} from './TaskInterface';
|
} from './TaskInterface';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
IList,
|
IList,
|
||||||
} from './ListInterface';
|
} from './ListInterface';
|
||||||
|
|
||||||
import * as moment from 'moment-timezone';
|
import * as moment from 'moment-timezone';
|
||||||
|
|
||||||
export class ClickUp implements INodeType {
|
export class ClickUp implements INodeType {
|
||||||
description: INodeTypeDescription = {
|
description: INodeTypeDescription = {
|
||||||
|
@ -688,9 +688,9 @@ export class ClickUp implements INodeType {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (type === 'number' || type === 'percentaje'
|
if (type === 'number' || type === 'percentaje'
|
||||||
|| type === 'automatic' || type === 'currency' ) {
|
|| type === 'automatic' || type === 'currency') {
|
||||||
if (additionalFields.stepsStart === undefined
|
if (additionalFields.stepsStart === undefined
|
||||||
|| !additionalFields.stepsEnd === undefined) {
|
|| !additionalFields.stepsEnd === undefined) {
|
||||||
throw new Error('Steps start and steps end fields must be set');
|
throw new Error('Steps start and steps end fields must be set');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -805,7 +805,7 @@ export class ClickUp implements INodeType {
|
||||||
const name = this.getNodeParameter('name', i) as string;
|
const name = this.getNodeParameter('name', i) as string;
|
||||||
const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject;
|
const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject;
|
||||||
const body: ITask = {
|
const body: ITask = {
|
||||||
name,
|
name,
|
||||||
};
|
};
|
||||||
if (additionalFields.customFieldsJson) {
|
if (additionalFields.customFieldsJson) {
|
||||||
const customFields = validateJSON(additionalFields.customFieldsJson as string);
|
const customFields = validateJSON(additionalFields.customFieldsJson as string);
|
||||||
|
@ -1115,7 +1115,7 @@ export class ClickUp implements INodeType {
|
||||||
const timezone = this.getTimezone();
|
const timezone = this.getTimezone();
|
||||||
const body: IDataObject = {
|
const body: IDataObject = {
|
||||||
start: moment.tz(start, timezone).valueOf(),
|
start: moment.tz(start, timezone).valueOf(),
|
||||||
duration: duration * 60000,
|
duration: duration * 60000,
|
||||||
tid: taskId,
|
tid: taskId,
|
||||||
};
|
};
|
||||||
Object.assign(body, additionalFields);
|
Object.assign(body, additionalFields);
|
||||||
|
@ -1140,7 +1140,12 @@ export class ClickUp implements INodeType {
|
||||||
if (operation === 'stop') {
|
if (operation === 'stop') {
|
||||||
const teamId = this.getNodeParameter('team', i) as string;
|
const teamId = this.getNodeParameter('team', i) as string;
|
||||||
responseData = await clickupApiRequest.call(this, 'POST', `/team/${teamId}/time_entries/stop`);
|
responseData = await clickupApiRequest.call(this, 'POST', `/team/${teamId}/time_entries/stop`);
|
||||||
responseData = responseData.data;
|
|
||||||
|
if (responseData.data) {
|
||||||
|
responseData = responseData.data;
|
||||||
|
} else {
|
||||||
|
throw new Error('There seems to be nothing to stop.');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (operation === 'delete') {
|
if (operation === 'delete') {
|
||||||
const teamId = this.getNodeParameter('team', i) as string;
|
const teamId = this.getNodeParameter('team', i) as string;
|
||||||
|
@ -1185,7 +1190,7 @@ export class ClickUp implements INodeType {
|
||||||
const tagNames = this.getNodeParameter('tagNames', i) as string[];
|
const tagNames = this.getNodeParameter('tagNames', i) as string[];
|
||||||
const body: IDataObject = {};
|
const body: IDataObject = {};
|
||||||
body.time_entry_ids = timeEntryIds.split(',');
|
body.time_entry_ids = timeEntryIds.split(',');
|
||||||
body.tags = tagNames.map((tag) => ( JSON.parse(tag).name ));
|
body.tags = tagNames.map((tag) => (JSON.parse(tag).name));
|
||||||
responseData = await clickupApiRequest.call(this, 'DELETE', `/team/${teamId}/time_entries/tags`, body);
|
responseData = await clickupApiRequest.call(this, 'DELETE', `/team/${teamId}/time_entries/tags`, body);
|
||||||
responseData = { success: true };
|
responseData = { success: true };
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import {
|
import {
|
||||||
INodeProperties,
|
INodeProperties,
|
||||||
} from 'n8n-workflow';
|
} from 'n8n-workflow';
|
||||||
|
|
||||||
export const timeEntryOperations = [
|
export const timeEntryOperations = [
|
||||||
{
|
{
|
||||||
|
@ -23,12 +23,12 @@ export const timeEntryOperations = [
|
||||||
{
|
{
|
||||||
name: 'Delete',
|
name: 'Delete',
|
||||||
value: 'delete',
|
value: 'delete',
|
||||||
description:'Delete a time entry',
|
description: 'Delete a time entry',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'Get',
|
name: 'Get',
|
||||||
value: 'get',
|
value: 'get',
|
||||||
description:'Get a time entry',
|
description: 'Get a time entry',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'Get All',
|
name: 'Get All',
|
||||||
|
@ -38,17 +38,17 @@ export const timeEntryOperations = [
|
||||||
{
|
{
|
||||||
name: 'Start',
|
name: 'Start',
|
||||||
value: 'start',
|
value: 'start',
|
||||||
description:'Start a time entry',
|
description: 'Start a time entry',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'Stop',
|
name: 'Stop',
|
||||||
value: 'stop',
|
value: 'stop',
|
||||||
description:'Stop the current running timer',
|
description: 'Stop the current running timer',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'Update',
|
name: 'Update',
|
||||||
value: 'update',
|
value: 'update',
|
||||||
description:'Update a time Entry',
|
description: 'Update a time Entry',
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
default: 'create',
|
default: 'create',
|
||||||
|
@ -58,9 +58,9 @@ export const timeEntryOperations = [
|
||||||
|
|
||||||
export const timeEntryFields = [
|
export const timeEntryFields = [
|
||||||
|
|
||||||
/* -------------------------------------------------------------------------- */
|
/* -------------------------------------------------------------------------- */
|
||||||
/* timeEntry:getAll */
|
/* timeEntry:getAll */
|
||||||
/* -------------------------------------------------------------------------- */
|
/* -------------------------------------------------------------------------- */
|
||||||
{
|
{
|
||||||
displayName: 'Team ID',
|
displayName: 'Team ID',
|
||||||
name: 'team',
|
name: 'team',
|
||||||
|
@ -153,9 +153,10 @@ export const timeEntryFields = [
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
/* -------------------------------------------------------------------------- */
|
|
||||||
/* timeEntry:get */
|
/* -------------------------------------------------------------------------- */
|
||||||
/* -------------------------------------------------------------------------- */
|
/* timeEntry:get */
|
||||||
|
/* -------------------------------------------------------------------------- */
|
||||||
{
|
{
|
||||||
displayName: 'Team ID',
|
displayName: 'Team ID',
|
||||||
name: 'team',
|
name: 'team',
|
||||||
|
@ -213,9 +214,10 @@ export const timeEntryFields = [
|
||||||
},
|
},
|
||||||
required: true,
|
required: true,
|
||||||
},
|
},
|
||||||
/* -------------------------------------------------------------------------- */
|
|
||||||
/* timeEntry:create */
|
/* -------------------------------------------------------------------------- */
|
||||||
/* -------------------------------------------------------------------------- */
|
/* timeEntry:create */
|
||||||
|
/* -------------------------------------------------------------------------- */
|
||||||
{
|
{
|
||||||
displayName: 'Team ID',
|
displayName: 'Team ID',
|
||||||
name: 'team',
|
name: 'team',
|
||||||
|
@ -467,9 +469,10 @@ export const timeEntryFields = [
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
/* -------------------------------------------------------------------------- */
|
|
||||||
/* timeEntry:start */
|
/* -------------------------------------------------------------------------- */
|
||||||
/* -------------------------------------------------------------------------- */
|
/* timeEntry:start */
|
||||||
|
/* -------------------------------------------------------------------------- */
|
||||||
{
|
{
|
||||||
displayName: 'Team ID',
|
displayName: 'Team ID',
|
||||||
name: 'team',
|
name: 'team',
|
||||||
|
@ -539,9 +542,10 @@ export const timeEntryFields = [
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
/* -------------------------------------------------------------------------- */
|
|
||||||
/* timeEntry:stop */
|
/* -------------------------------------------------------------------------- */
|
||||||
/* -------------------------------------------------------------------------- */
|
/* timeEntry:stop */
|
||||||
|
/* -------------------------------------------------------------------------- */
|
||||||
{
|
{
|
||||||
displayName: 'Team ID',
|
displayName: 'Team ID',
|
||||||
name: 'team',
|
name: 'team',
|
||||||
|
@ -562,9 +566,10 @@ export const timeEntryFields = [
|
||||||
},
|
},
|
||||||
required: true,
|
required: true,
|
||||||
},
|
},
|
||||||
/* -------------------------------------------------------------------------- */
|
|
||||||
/* timeEntry:delete */
|
/* -------------------------------------------------------------------------- */
|
||||||
/* -------------------------------------------------------------------------- */
|
/* timeEntry:delete */
|
||||||
|
/* -------------------------------------------------------------------------- */
|
||||||
{
|
{
|
||||||
displayName: 'Team ID',
|
displayName: 'Team ID',
|
||||||
name: 'team',
|
name: 'team',
|
||||||
|
@ -602,9 +607,10 @@ export const timeEntryFields = [
|
||||||
},
|
},
|
||||||
required: true,
|
required: true,
|
||||||
},
|
},
|
||||||
/* -------------------------------------------------------------------------- */
|
|
||||||
/* timeEntry:update */
|
/* -------------------------------------------------------------------------- */
|
||||||
/* -------------------------------------------------------------------------- */
|
/* timeEntry:update */
|
||||||
|
/* -------------------------------------------------------------------------- */
|
||||||
{
|
{
|
||||||
displayName: 'Team ID',
|
displayName: 'Team ID',
|
||||||
name: 'team',
|
name: 'team',
|
||||||
|
|
Loading…
Reference in a new issue