diff options
author | Frederic Guillot <fred@kanboard.net> | 2016-11-06 20:08:36 -0500 |
---|---|---|
committer | Frederic Guillot <fred@kanboard.net> | 2016-11-06 20:08:36 -0500 |
commit | e5c63f4ecc78e144659bf83947a19d996f60b490 (patch) | |
tree | fe7abc757f3692dbede251b793103b98780fd93e /app | |
parent | f758ddfc5e7d5d26d9a23b8c75fa6884159ecd72 (diff) |
Load external tasks asynchronously from task view page
Diffstat (limited to 'app')
-rw-r--r-- | app/Controller/ExternalTaskViewController.php | 30 | ||||
-rw-r--r-- | app/Core/ExternalTask/ExternalTaskProviderInterface.php | 7 | ||||
-rw-r--r-- | app/Template/task/details.php | 4 |
3 files changed, 41 insertions, 0 deletions
diff --git a/app/Controller/ExternalTaskViewController.php b/app/Controller/ExternalTaskViewController.php new file mode 100644 index 00000000..4ffc4763 --- /dev/null +++ b/app/Controller/ExternalTaskViewController.php @@ -0,0 +1,30 @@ +<?php + +namespace Kanboard\Controller; + +use Kanboard\Core\ExternalTask\ExternalTaskException; + +/** + * Class ExternalTaskViewController + * + * @package Kanboard\Controller + * @author Frederic Guillot + */ +class ExternalTaskViewController extends BaseController +{ + public function show() + { + try { + $task = $this->getTask(); + $taskProvider = $this->externalTaskManager->getProvider($task['external_provider']); + $externalTask = $taskProvider->retrieve($task['external_uri']); + + $this->response->html($this->template->render($taskProvider->getViewTemplate(), array( + 'task' => $task, + 'external_task' => $externalTask, + ))); + } catch (ExternalTaskException $e) { + $this->response->html('<div class="alert alert-error">'.$e->getMessage().'</div>'); + } + } +} diff --git a/app/Core/ExternalTask/ExternalTaskProviderInterface.php b/app/Core/ExternalTask/ExternalTaskProviderInterface.php index af1dffec..7706a773 100644 --- a/app/Core/ExternalTask/ExternalTaskProviderInterface.php +++ b/app/Core/ExternalTask/ExternalTaskProviderInterface.php @@ -44,6 +44,13 @@ interface ExternalTaskProviderInterface public function getCreationFormTemplate(); /** + * Get task view template name + * + * @return string + */ + public function getViewTemplate(); + + /** * Build external task URI based on import form values * * @param array $values diff --git a/app/Template/task/details.php b/app/Template/task/details.php index a39c1bab..8d22af52 100644 --- a/app/Template/task/details.php +++ b/app/Template/task/details.php @@ -160,6 +160,10 @@ <?php endif ?> </div> + <?php if (! empty($task['external_uri']) && ! empty($task['external_provider'])): ?> + <external-task-view url="<?= $this->url->href('ExternalTaskViewController', 'show', array('project_id' => $task['project_id'], 'task_id' => $task['id'])) ?>"></external-task-view> + <?php endif ?> + <?php if ($editable && empty($task['date_started'])): ?> <div class="buttons-header"> <?= $this->url->button('fa-play', t('Set start date'), 'TaskModificationController', 'start', array('task_id' => $task['id'], 'project_id' => $task['project_id'])) ?> |