feat(vtiger-crm): add create todo action

This commit is contained in:
Rıdvan Akca
2024-01-16 18:26:58 +03:00
committed by Ali BARIN
parent ab897ada5a
commit fbfa67e471
11 changed files with 633 additions and 1 deletions

View File

@@ -0,0 +1,357 @@
export const fields = [
{
label: 'Name',
key: 'name',
type: 'string',
required: true,
description: '',
variables: true,
},
{
label: 'Assigned To',
key: 'assignedTo',
type: 'string',
required: false,
description: 'Default is the id of the account connected to Automatisch.',
variables: true,
},
{
label: 'Start Date & Time',
key: 'startDateAndTime',
type: 'string',
required: false,
description: 'Format: yyyy-mm-dd',
variables: true,
},
{
label: 'Due Date',
key: 'dueDate',
type: 'string',
required: false,
description: 'Format: yyyy-mm-dd',
variables: true,
},
{
label: 'Stage',
key: 'stage',
type: 'dropdown',
required: true,
description: '',
variables: true,
source: {
type: 'query',
name: 'getDynamicData',
arguments: [
{
name: 'key',
value: 'listTodoOptions',
},
{
name: 'parameters.stage',
value: 'taskstatus',
},
],
},
},
{
label: 'Contact Name',
key: 'contactName',
type: 'dropdown',
required: false,
description: '',
variables: true,
source: {
type: 'query',
name: 'getDynamicData',
arguments: [
{
name: 'key',
value: 'listContacts',
},
],
},
},
{
label: 'Priority',
key: 'priority',
type: 'dropdown',
required: true,
description: '',
variables: true,
options: [
{ label: 'High', value: 'High' },
{ label: 'Medium', value: 'Medium' },
{ label: 'Low', value: 'Low' },
],
},
{
label: 'Send Notification',
key: 'sendNotification',
type: 'dropdown',
required: false,
description: '',
variables: true,
options: [
{ label: 'True', value: 'true' },
{ label: 'False', value: 'false' },
],
},
{
label: 'Location',
key: 'location',
type: 'string',
required: false,
description: '',
variables: true,
},
{
label: 'Record Currency',
key: 'recordCurrency',
type: 'dropdown',
required: false,
description: '',
variables: true,
source: {
type: 'query',
name: 'getDynamicData',
arguments: [
{
name: 'key',
value: 'listRecordCurrencies',
},
],
},
},
{
label: 'Milestone',
key: 'milestone',
type: 'dropdown',
required: false,
description: '',
variables: true,
source: {
type: 'query',
name: 'getDynamicData',
arguments: [
{
name: 'key',
value: 'listMilestones',
},
],
},
},
{
label: 'Previous Task',
key: 'previousTask',
type: 'dropdown',
required: false,
description: '',
variables: true,
source: {
type: 'query',
name: 'getDynamicData',
arguments: [
{
name: 'key',
value: 'listTasks',
},
],
},
},
{
label: 'Parent Task',
key: 'parentTask',
type: 'dropdown',
required: false,
description: '',
variables: true,
source: {
type: 'query',
name: 'getDynamicData',
arguments: [
{
name: 'key',
value: 'listTasks',
},
],
},
},
{
label: 'Task Type',
key: 'taskType',
type: 'dropdown',
required: true,
description: '',
variables: true,
source: {
type: 'query',
name: 'getDynamicData',
arguments: [
{
name: 'key',
value: 'listTodoOptions',
},
{
name: 'parameters.taskType',
value: 'tasktype',
},
],
},
},
{
label: 'Skipped Reason',
key: 'skippedReason',
type: 'dropdown',
required: false,
description: '',
variables: true,
source: {
type: 'query',
name: 'getDynamicData',
arguments: [
{
name: 'key',
value: 'listTodoOptions',
},
{
name: 'parameters.skippedReason',
value: 'skipped_reason',
},
],
},
},
{
label: 'Estimate',
key: 'estimate',
type: 'string',
required: false,
description: '',
variables: true,
},
{
label: 'Related Task',
key: 'relatedTask',
type: 'dropdown',
required: false,
description: '',
variables: true,
source: {
type: 'query',
name: 'getDynamicData',
arguments: [
{
name: 'key',
value: 'listTasks',
},
],
},
},
{
label: 'Project Name',
key: 'projectName',
type: 'dropdown',
required: false,
description: '',
variables: true,
source: {
type: 'query',
name: 'getDynamicData',
arguments: [
{
name: 'key',
value: 'listProjects',
},
],
},
},
{
label: 'Organization Name',
key: 'organizationName',
type: 'dropdown',
required: false,
description: '',
variables: true,
source: {
type: 'query',
name: 'getDynamicData',
arguments: [
{
name: 'key',
value: 'listOrganizations',
},
],
},
},
{
label: 'Send Email Reminder Before',
key: 'sendEmailReminderBefore',
type: 'string',
required: false,
description: '',
variables: true,
},
{
label: 'Description',
key: 'description',
type: 'string',
required: false,
description: '',
variables: true,
},
{
label: 'Is Billable',
key: 'isBillable',
type: 'dropdown',
required: false,
description: '',
variables: true,
options: [
{ label: 'True', value: '1' },
{ label: 'False', value: '-1' },
],
},
{
label: 'Service',
key: 'service',
type: 'dropdown',
required: false,
description: '',
variables: true,
source: {
type: 'query',
name: 'getDynamicData',
arguments: [
{
name: 'key',
value: 'listServices',
},
],
},
},
{
label: 'Rate',
key: 'rate',
type: 'string',
required: false,
description: '',
variables: true,
},
{
label: 'SLA Name',
key: 'slaName',
type: 'dropdown',
required: false,
description: '',
variables: true,
source: {
type: 'query',
name: 'getDynamicData',
arguments: [
{
name: 'key',
value: 'listSlaNames',
},
],
},
},
];

View File

@@ -0,0 +1,78 @@
import defineAction from '../../../../helpers/define-action.js';
import { fields } from './fields.js';
export default defineAction({
name: 'Create todo',
key: 'createTodo',
description: 'Create a new todo.',
arguments: fields,
async run($) {
const {
name,
assignedTo,
startDateAndTime,
dueDate,
stage,
contactName,
priority,
sendNotification,
location,
recordCurrency,
milestone,
previousTask,
parentTask,
taskType,
skippedReason,
estimate,
relatedTask,
projectName,
organizationName,
sendEmailReminderBefore,
description,
isBillable,
service,
rate,
slaName,
} = $.step.parameters;
const elementData = {
subject: name,
assigned_user_id: assignedTo || $.auth.data.userId,
date_start: startDateAndTime,
due_date: dueDate,
taskstatus: stage,
contact_id: contactName,
taskpriority: priority,
sendnotification: sendNotification,
location: location,
record_currency_id: recordCurrency,
milestone: milestone,
dependent_on: previousTask,
parent_task: parentTask,
tasktype: taskType,
skipped_reason: skippedReason,
estimate: estimate,
related_task: relatedTask,
related_project: projectName,
account_id: organizationName,
reminder_time: sendEmailReminderBefore,
description: description,
is_billable: isBillable,
billing_service: service,
rate: rate,
slaid: slaName,
};
const body = {
operation: 'create',
sessionName: $.auth.data.sessionName,
element: JSON.stringify(elementData),
elementType: 'Calendar',
};
const response = await $.http.post('/webservice.php', body);
$.setActionItem({ raw: response.data });
},
});