fix(Todoist Node): Make Section Name optional in Move Task operation (#10732)
This commit is contained in:
@@ -34,6 +34,7 @@ export interface Command {
|
||||
uuid: string;
|
||||
temp_id?: string;
|
||||
args: {
|
||||
parent_id?: string;
|
||||
id?: number;
|
||||
section_id?: number;
|
||||
project_id?: number | string;
|
||||
@@ -251,7 +252,10 @@ export class MoveHandler implements OperationHandler {
|
||||
async handleOperation(ctx: Context, itemIndex: number): Promise<TodoistResponse> {
|
||||
//https://api.todoist.com/sync/v9/sync
|
||||
const taskId = ctx.getNodeParameter('taskId', itemIndex) as number;
|
||||
const section = ctx.getNodeParameter('section', itemIndex) as number;
|
||||
const projectId = ctx.getNodeParameter('project', itemIndex, undefined, {
|
||||
extractValue: true,
|
||||
}) as number;
|
||||
const nodeVersion = ctx.getNode().typeVersion;
|
||||
|
||||
const body: SyncRequest = {
|
||||
commands: [
|
||||
@@ -260,14 +264,28 @@ export class MoveHandler implements OperationHandler {
|
||||
uuid: uuid(),
|
||||
args: {
|
||||
id: taskId,
|
||||
section_id: section,
|
||||
// Set section_id only if node version is below 2.1
|
||||
...(nodeVersion < 2.1
|
||||
? { section_id: ctx.getNodeParameter('section', itemIndex) as number }
|
||||
: {}),
|
||||
},
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
await todoistSyncRequest.call(ctx, body);
|
||||
if (nodeVersion >= 2.1) {
|
||||
const options = ctx.getNodeParameter('options', itemIndex, {}) as IDataObject;
|
||||
// Only one of parent_id, section_id, or project_id must be set to move the task
|
||||
if (options.parent) {
|
||||
body.commands[0].args.parent_id = options.parent as string;
|
||||
} else if (options.section) {
|
||||
body.commands[0].args.section_id = options.section as number;
|
||||
} else {
|
||||
body.commands[0].args.project_id = projectId;
|
||||
}
|
||||
}
|
||||
|
||||
await todoistSyncRequest.call(ctx, body);
|
||||
return { success: true };
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user