Skip to content
Snippets Groups Projects
Commit 306ac795 authored by Arjun Kumar's avatar Arjun Kumar
Browse files

Issue #3485276: Add complete task functionality

parent b9d349e0
Branches
No related tags found
1 merge request!10Issue #3485276: Add complete task functionality
......@@ -43,7 +43,11 @@ class CloseTaskForm extends ConfirmFormBase {
$uri = 'tasks';
$content_id = $this->id;
try{
$response = \Drupal::service('todoist_api.client')->post($uri, null, $content_id);
$current_path = \Drupal::service('path.current')->getPath();
if (preg_match('/\bclose\b/', $current_path)) {
$body['type'] = 'close';
}
$response = \Drupal::service('todoist_api.client')->post($uri, $body, $content_id);
if($response):
$this->messenger()->addStatus($this->t('One task has been completed.'));
$form_state->setRedirect('todoist_api.taskscontroller');
......@@ -51,6 +55,7 @@ class CloseTaskForm extends ConfirmFormBase {
} catch( RequestException $exception) {
\Drupal::logger('error_rest_client')->notice($exception->getMessage());
$form_state->setErrorByName('task', $this->t('Application error. Please try again later.'));
$form_state->setRedirect('todoist_api.taskscontroller');
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment