🔀 Merge branch 'Robarelli-master'

This commit is contained in:
Jan Oberhauser 2020-06-13 17:46:45 +02:00
commit 75e96a35bb
2 changed files with 279 additions and 0 deletions

View file

@ -15,6 +15,21 @@ export const boardItemOperations = [
}, },
}, },
options: [ options: [
{
name: 'Add Update',
value: 'addUpdate',
description: `Add an update to an item.`,
},
{
name: 'Change Column Value',
value: 'changeColumnValue',
description: 'Change a column value for a board item',
},
{
name: 'Change Multiple Column Values',
value: 'changeMultipleColumnValues',
description: 'Change multiple column values for a board item',
},
{ {
name: 'Create', name: 'Create',
value: 'create', value: 'create',
@ -48,6 +63,192 @@ export const boardItemOperations = [
export const boardItemFields = [ export const boardItemFields = [
/* -------------------------------------------------------------------------- */
/* boardItem:addUpdate */
/* -------------------------------------------------------------------------- */
{
displayName: 'Item ID',
name: 'itemId',
type: 'string',
default: '',
required: true,
displayOptions: {
show: {
resource: [
'boardItem',
],
operation: [
'addUpdate',
],
},
},
description: 'The unique identifier of the item to add update to.',
},
{
displayName: 'Update Text',
name: 'value',
type: 'string',
required: true,
default: '',
displayOptions: {
show: {
resource: [
'boardItem',
],
operation: [
'addUpdate',
],
},
},
description: 'The update text to add.',
},
/* -------------------------------------------------------------------------- */
/* boardItem:changeColumnValue */
/* -------------------------------------------------------------------------- */
{
displayName: 'Board ID',
name: 'boardId',
type: 'options',
typeOptions: {
loadOptionsMethod: 'getBoards',
},
default: '',
required: true,
displayOptions: {
show: {
resource: [
'boardItem',
],
operation: [
'changeColumnValue',
],
},
},
description: 'The unique identifier of the board.',
},
{
displayName: 'Item ID',
name: 'itemId',
type: 'string',
default: '',
required: true,
displayOptions: {
show: {
resource: [
'boardItem',
],
operation: [
'changeColumnValue',
],
},
},
description: 'The unique identifier of the item to to change column of.',
},
{
displayName: 'Column ID',
name: 'columnId',
type: 'options',
typeOptions: {
loadOptionsMethod: 'getColumns',
loadOptionsDependsOn: [
'boardId'
],
},
default: '',
required: true,
displayOptions: {
show: {
resource: [
'boardItem',
],
operation: [
'changeColumnValue',
],
},
},
description: `The column's unique identifier.`,
},
{
displayName: 'Value',
name: 'value',
type: 'json',
required: true,
default: '',
displayOptions: {
show: {
resource: [
'boardItem',
],
operation: [
'changeColumnValue',
],
},
},
description: 'The column value in JSON format. Documentation can be found <a href="https://monday.com/developers/v2#mutations-section-columns-change-column-value" target="_blank">here</a>.',
},
/* -------------------------------------------------------------------------- */
/* boardItem:changeMultipleColumnValues */
/* -------------------------------------------------------------------------- */
{
displayName: 'Board ID',
name: 'boardId',
type: 'options',
typeOptions: {
loadOptionsMethod: 'getBoards',
},
default: '',
required: true,
displayOptions: {
show: {
resource: [
'boardItem',
],
operation: [
'changeMultipleColumnValues',
],
},
},
description: 'The unique identifier of the board.',
},
{
displayName: 'Item ID',
name: 'itemId',
type: 'string',
default: '',
required: true,
displayOptions: {
show: {
resource: [
'boardItem',
],
operation: [
'changeMultipleColumnValues',
],
},
},
description: `Item's ID`
},
{
displayName: 'Column Values',
name: 'columnValues',
type: 'json',
required: true,
default: '',
displayOptions: {
show: {
resource: [
'boardItem',
],
operation: [
'changeMultipleColumnValues',
],
},
},
description: 'The column fields and values in JSON format. Documentation can be found <a href="https://monday.com/developers/v2#mutations-section-columns-change-multiple-column-values" target="_blank">here</a>.',
typeOptions: {
alwaysOpenEditWindow: true,
},
},
/* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */
/* boardItem:create */ /* boardItem:create */
/* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */

View file

@ -455,6 +455,84 @@ export class MondayCom implements INodeType {
} }
} }
if (resource === 'boardItem') { if (resource === 'boardItem') {
if (operation === 'addUpdate') {
const itemId = parseInt((this.getNodeParameter('itemId', i) as string), 10);
const value = this.getNodeParameter('value', i) as string;
const body: IGraphqlBody = {
query:
`mutation ($itemId: Int!, $value: String!) {
create_update (item_id: $itemId, body: $value) {
id
}
}`,
variables: {
itemId,
value,
},
};
responseData = await mondayComApiRequest.call(this, body);
responseData = responseData.data.create_update;
}
if (operation === 'changeColumnValue') {
const boardId = parseInt(this.getNodeParameter('boardId', i) as string, 10);
const itemId = parseInt((this.getNodeParameter('itemId', i) as string), 10);
const columnId = this.getNodeParameter('columnId', i) as string;
const value = this.getNodeParameter('value', i) as string;
const body: IGraphqlBody = {
query:
`mutation ($boardId: Int!, $itemId: Int!, $columnId: String!, $value: JSON!) {
change_column_value (board_id: $boardId, item_id: $itemId, column_id: $columnId, value: $value) {
id
}
}`,
variables: {
boardId,
itemId,
columnId,
},
};
try {
JSON.parse(value);
} catch (e) {
throw new Error('Custom Values must be a valid JSON');
}
body.variables.value = JSON.stringify(JSON.parse(value));
responseData = await mondayComApiRequest.call(this, body);
responseData = responseData.data.change_column_value;
}
if (operation === 'changeMultipleColumnValues') {
const boardId = parseInt(this.getNodeParameter('boardId', i) as string, 10);
const itemId = parseInt((this.getNodeParameter('itemId', i) as string), 10);
const columnValues = this.getNodeParameter('columnValues', i) as string;
const body: IGraphqlBody = {
query:
`mutation ($boardId: Int!, $itemId: Int!, $columnValues: JSON!) {
change_multiple_column_values (board_id: $boardId, item_id: $itemId, column_values: $columnValues) {
id
}
}`,
variables: {
boardId,
itemId,
},
};
try {
JSON.parse(columnValues);
} catch (e) {
throw new Error('Custom Values must be a valid JSON');
}
body.variables.columnValues = JSON.stringify(JSON.parse(columnValues));
responseData = await mondayComApiRequest.call(this, body);
responseData = responseData.data.change_multiple_column_values;
}
if (operation === 'create') { if (operation === 'create') {
const boardId = parseInt(this.getNodeParameter('boardId', i) as string, 10); const boardId = parseInt(this.getNodeParameter('boardId', i) as string, 10);
const groupId = this.getNodeParameter('groupId', i) as string; const groupId = this.getNodeParameter('groupId', i) as string;