feat: add label CRUD

This commit is contained in:
kolaente 2023-10-24 17:01:39 +02:00
parent 31458e205c
commit 92c48ae4f7
Signed by: konrad
GPG Key ID: F40E70337AB24C9B
4 changed files with 180 additions and 4 deletions

View File

@ -52,6 +52,10 @@ export class Vikunja implements INodeType {
name: 'Project',
value: 'project',
},
{
name: 'Label',
value: 'label',
},
],
default: 'task',
},

View File

@ -1,6 +1,81 @@
import {INodeProperties} from 'n8n-workflow'
export const labelProperties: INodeProperties[] = [
{
displayName: 'Operation',
name: 'operation',
type: 'options',
noDataExpression: true,
required: true,
displayOptions: {
show: {
resource: ['label'],
},
},
options: [
{
name: 'Create',
value: 'create',
description: 'Create a label',
action: 'Create a label',
routing: {
request: {
method: 'PUT',
url: '=/labels',
},
},
},
{
name: 'Delete',
value: 'delete',
description: 'Delete a label',
action: 'Delete a label',
routing: {
request: {
method: 'DELETE',
url: '=/labels/{{$parameter.label}}',
},
},
},
{
name: 'Get',
value: 'get',
description: 'Get a label',
action: 'Get a label',
routing: {
request: {
method: 'GET',
url: '=/labels/{{$parameter.label}}',
},
},
},
{
name: 'Get Many',
value: 'getAll',
description: 'Get many labels',
action: 'Get many labels',
routing: {
request: {
method: 'GET',
url: '=/labels',
},
},
},
{
name: 'Update',
value: 'update',
description: 'Update a label',
action: 'Update a label',
routing: {
request: {
method: 'POST',
url: '=/labels/{{$parameter.label}}',
},
},
},
],
default: 'create',
},
{
displayName: 'Label Title or ID',
name: 'label',
@ -25,6 +100,44 @@ export const labelProperties: INodeProperties[] = [
placeholder: '1567890',
},
],
displayOptions: {
show: {
resource: ['label'],
operation: ['get', 'update', 'delete'],
},
},
routing: {
send: {
type: 'body',
property: 'label_id',
},
},
description: 'The label you want to operate on. Choose from the list, or specify an ID.',
},
{
displayName: 'Label Title or ID',
name: 'taskLabel',
type: 'resourceLocator',
default: {mode: 'id', value: ''},
required: true,
modes: [
{
displayName: 'From List',
name: 'list',
type: 'list',
placeholder: 'Select a label…',
typeOptions: {
searchListMethod: 'searchLabels',
searchable: true,
},
},
{
displayName: 'ID',
name: 'id',
type: 'string',
placeholder: '1567890',
},
],
displayOptions: {
show: {
resource: ['task'],
@ -39,4 +152,63 @@ export const labelProperties: INodeProperties[] = [
},
description: 'The label you want to operate on. Choose from the list, or specify an ID.',
},
{
displayName: 'Label Title',
name: 'labelTitle',
type: 'string',
displayOptions: {
show: {
resource: ['label'],
operation: ['create', 'update'],
},
},
routing: {
send: {
type: 'body',
property: 'title',
},
},
default: '',
required: true,
},
{
displayName: 'Description',
name: 'description',
type: 'string',
default: '',
description: 'A description for the label',
typeOptions: {
rows: 4,
},
displayOptions: {
show: {
resource: ['label'],
operation: ['create', 'update'],
},
},
routing: {
send: {
type: 'body',
property: 'description',
},
},
},
{
displayName: 'Label Color',
name: 'hexColor',
type: 'color',
default: '#000000',
displayOptions: {
show: {
resource: ['label'],
operation: ['create', 'update'],
},
},
routing: {
send: {
type: 'body',
property: 'hex_color',
},
},
},
]

View File

@ -68,7 +68,7 @@ export const projectProperties: INodeProperties[] = [
action: 'Update a project',
routing: {
request: {
method: 'GET',
method: 'POST',
url: '=/projects/{{$parameter.project}}',
},
},
@ -392,7 +392,7 @@ export const projectProperties: INodeProperties[] = [
displayName: 'Project Color',
name: 'hexColor',
type: 'color',
default: 'hex_color',
default: '#000000',
routing: {
send: {
type: 'body',

View File

@ -174,7 +174,7 @@ export const taskProperties: INodeProperties[] = [
routing: {
request: {
method: 'DELETE',
url: '=/tasks/{{$parameter.taskId}}/labels/{{$parameter.label}}',
url: '=/tasks/{{$parameter.taskId}}/labels/{{$parameter.taskLabel}}',
},
},
},
@ -369,7 +369,7 @@ export const taskProperties: INodeProperties[] = [
displayName: 'Task Color',
name: 'hexColor',
type: 'color',
default: 'hex_color',
default: '#000000',
routing: {
send: {
type: 'body',