mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-20 11:22:15 +00:00
Add task create and update
This commit is contained in:
@@ -9,7 +9,7 @@ export const clientOperations = [
|
|||||||
type: 'options',
|
type: 'options',
|
||||||
displayOptions: {
|
displayOptions: {
|
||||||
show: {
|
show: {
|
||||||
resource
|
resource,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
options: [
|
options: [
|
||||||
@@ -47,7 +47,7 @@ export const clientFields = [
|
|||||||
type: 'boolean',
|
type: 'boolean',
|
||||||
displayOptions: {
|
displayOptions: {
|
||||||
show: {
|
show: {
|
||||||
resource
|
resource,
|
||||||
operation: [
|
operation: [
|
||||||
'getAll',
|
'getAll',
|
||||||
],
|
],
|
||||||
@@ -62,7 +62,7 @@ export const clientFields = [
|
|||||||
type: 'number',
|
type: 'number',
|
||||||
displayOptions: {
|
displayOptions: {
|
||||||
show: {
|
show: {
|
||||||
resource
|
resource,
|
||||||
operation: [
|
operation: [
|
||||||
'getAll',
|
'getAll',
|
||||||
],
|
],
|
||||||
@@ -86,7 +86,7 @@ export const clientFields = [
|
|||||||
default: {},
|
default: {},
|
||||||
displayOptions: {
|
displayOptions: {
|
||||||
show: {
|
show: {
|
||||||
resource
|
resource,
|
||||||
operation: [
|
operation: [
|
||||||
'getAll',
|
'getAll',
|
||||||
],
|
],
|
||||||
|
|||||||
@@ -546,6 +546,36 @@ export class Harvest implements INodeType {
|
|||||||
const responseData: IDataObject[] = await getAllResource.call(this, resource, i);
|
const responseData: IDataObject[] = await getAllResource.call(this, resource, i);
|
||||||
returnData.push.apply(returnData, responseData);
|
returnData.push.apply(returnData, responseData);
|
||||||
|
|
||||||
|
} else if (operation === 'create') {
|
||||||
|
// ----------------------------------
|
||||||
|
// create
|
||||||
|
// ----------------------------------
|
||||||
|
|
||||||
|
requestMethod = 'POST';
|
||||||
|
endpoint = resource;
|
||||||
|
|
||||||
|
body.name = this.getNodeParameter('name', i) as string;
|
||||||
|
|
||||||
|
const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject;
|
||||||
|
Object.assign(body, additionalFields);
|
||||||
|
|
||||||
|
const responseData = await harvestApiRequest.call(this, requestMethod, qs, endpoint, body);
|
||||||
|
returnData.push(responseData);
|
||||||
|
|
||||||
|
} else if (operation === 'update') {
|
||||||
|
// ----------------------------------
|
||||||
|
// createByDuration
|
||||||
|
// ----------------------------------
|
||||||
|
|
||||||
|
requestMethod = 'POST';
|
||||||
|
endpoint = resource;
|
||||||
|
|
||||||
|
const updateFields = this.getNodeParameter('updateFields', i) as IDataObject;
|
||||||
|
Object.assign(qs, updateFields);
|
||||||
|
|
||||||
|
const responseData = await harvestApiRequest.call(this, requestMethod, qs, endpoint, body);
|
||||||
|
returnData.push(responseData);
|
||||||
|
|
||||||
} else if (operation === 'delete') {
|
} else if (operation === 'delete') {
|
||||||
// ----------------------------------
|
// ----------------------------------
|
||||||
// delete
|
// delete
|
||||||
|
|||||||
@@ -21,6 +21,16 @@ export const taskOperations = [
|
|||||||
value: 'getAll',
|
value: 'getAll',
|
||||||
description: 'Get data of all tasks',
|
description: 'Get data of all tasks',
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: 'Create',
|
||||||
|
value: 'create',
|
||||||
|
description: `Create a task`,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'Update',
|
||||||
|
value: 'update',
|
||||||
|
description: `Update a task`,
|
||||||
|
},
|
||||||
{
|
{
|
||||||
name: 'Delete',
|
name: 'Delete',
|
||||||
value: 'delete',
|
value: 'delete',
|
||||||
@@ -158,5 +168,125 @@ export const taskFields = [
|
|||||||
description: 'The ID of the task you wan to delete.',
|
description: 'The ID of the task you wan to delete.',
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/* -------------------------------------------------------------------------- */
|
||||||
|
/* task:create */
|
||||||
|
/* -------------------------------------------------------------------------- */
|
||||||
|
{
|
||||||
|
displayName: 'Name',
|
||||||
|
name: 'name',
|
||||||
|
type: 'string',
|
||||||
|
displayOptions: {
|
||||||
|
show: {
|
||||||
|
operation: [
|
||||||
|
'create',
|
||||||
|
],
|
||||||
|
resource,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
default: '',
|
||||||
|
required: true,
|
||||||
|
description: 'The name of the task.',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
displayName: 'Additional Fields',
|
||||||
|
name: 'additionalFields',
|
||||||
|
type: 'collection',
|
||||||
|
placeholder: 'Add Field',
|
||||||
|
displayOptions: {
|
||||||
|
show: {
|
||||||
|
operation: [
|
||||||
|
'create',
|
||||||
|
],
|
||||||
|
resource,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
default: {},
|
||||||
|
options: [
|
||||||
|
{
|
||||||
|
displayName: 'Billable By Default',
|
||||||
|
name: 'billable_by_default',
|
||||||
|
type: 'boolean',
|
||||||
|
default: '',
|
||||||
|
description: 'Used in determining whether default tasks should be marked billable when creating a new project. Defaults to true.'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
displayName: 'Default Hourly Rate',
|
||||||
|
name: 'default_hourly_rate',
|
||||||
|
type: 'string',
|
||||||
|
default: '0',
|
||||||
|
description: 'The default hourly rate to use for this task when it is added to a project. Defaults to 0.'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
displayName: 'Is Default',
|
||||||
|
name: 'is_default',
|
||||||
|
type: 'boolean',
|
||||||
|
default: false,
|
||||||
|
description: 'Whether this task should be automatically added to future projects. Defaults to false.'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
displayName: 'Is Active',
|
||||||
|
name: 'is_active',
|
||||||
|
type: 'boolean',
|
||||||
|
default: true,
|
||||||
|
description: 'Whether this task is active or archived. Defaults to true'
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
/* -------------------------------------------------------------------------- */
|
||||||
|
/* task:update */
|
||||||
|
/* -------------------------------------------------------------------------- */
|
||||||
|
{
|
||||||
|
displayName: 'Update Fields',
|
||||||
|
name: 'updateFields',
|
||||||
|
type: 'collection',
|
||||||
|
placeholder: 'Update Field',
|
||||||
|
displayOptions: {
|
||||||
|
show: {
|
||||||
|
operation: [
|
||||||
|
'update',
|
||||||
|
],
|
||||||
|
resource,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
default: {},
|
||||||
|
options: [
|
||||||
|
{
|
||||||
|
displayName: 'Name',
|
||||||
|
name: 'name',
|
||||||
|
type: 'string',
|
||||||
|
default: '',
|
||||||
|
description: 'Name of the task.'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
displayName: 'Billable By Default',
|
||||||
|
name: 'billable_by_default',
|
||||||
|
type: 'boolean',
|
||||||
|
default: '',
|
||||||
|
description: 'Used in determining whether default tasks should be marked billable when creating a new project. Defaults to true.'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
displayName: 'Default Hourly Rate',
|
||||||
|
name: 'default_hourly_rate',
|
||||||
|
type: 'string',
|
||||||
|
default: '0',
|
||||||
|
description: 'The default hourly rate to use for this task when it is added to a project. Defaults to 0.'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
displayName: 'Is Default',
|
||||||
|
name: 'is_default',
|
||||||
|
type: 'boolean',
|
||||||
|
default: false,
|
||||||
|
description: 'Whether this task should be automatically added to future projects. Defaults to false.'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
displayName: 'Is Active',
|
||||||
|
name: 'is_active',
|
||||||
|
type: 'boolean',
|
||||||
|
default: true,
|
||||||
|
description: 'Whether this task is active or archived. Defaults to true'
|
||||||
|
}
|
||||||
|
],
|
||||||
|
},
|
||||||
|
|
||||||
|
|
||||||
] as INodeProperties[];
|
] as INodeProperties[];
|
||||||
|
|||||||
Reference in New Issue
Block a user