From ef1fea4509a8bd475c9d77ab63764378f1b5067b Mon Sep 17 00:00:00 2001 From: Olivier Maridat Date: Tue, 10 Mar 2015 14:32:23 +0100 Subject: Add an item "Add a link" in the dropdown menu of a task in the board view --- app/Controller/Tasklink.php | 16 ++++++++++++++++ app/Template/board/task_menu.php | 1 + app/Template/tasklink/create.php | 8 ++++++-- 3 files changed, 23 insertions(+), 2 deletions(-) (limited to 'app') diff --git a/app/Controller/Tasklink.php b/app/Controller/Tasklink.php index 61b7fab8..59ce0433 100644 --- a/app/Controller/Tasklink.php +++ b/app/Controller/Tasklink.php @@ -36,6 +36,7 @@ class Tasklink extends Base public function create(array $values = array(), array $errors = array()) { $task = $this->getTask(); + $ajax = $this->request->isAjax() || $this->request->getIntegerParam('ajax'); if (empty($values)) { $values = array( @@ -43,6 +44,17 @@ class Tasklink extends Base ); } + if ($ajax) { + $this->response->html($this->template->render('tasklink/create', array( + 'values' => $values, + 'errors' => $errors, + 'task' => $task, + 'labels' => $this->link->getList(0, false), + 'title' => t('Add a new link'), + 'ajax' => $ajax, + ))); + } + $this->response->html($this->taskLayout('tasklink/create', array( 'values' => $values, 'errors' => $errors, @@ -61,6 +73,7 @@ class Tasklink extends Base { $task = $this->getTask(); $values = $this->request->getValues(); + $ajax = $this->request->isAjax() || $this->request->getIntegerParam('ajax'); list($valid, $errors) = $this->taskLink->validateCreation($values); @@ -68,6 +81,9 @@ class Tasklink extends Base if ($this->taskLink->create($values['task_id'], $values['opposite_task_id'], $values['link_id'])) { $this->session->flash(t('Link added successfully.')); + if ($ajax) { + $this->response->redirect($this->helper->url('board', 'show', array('project_id' => $task['project_id']))); + } $this->response->redirect($this->helper->url('task', 'show', array('task_id' => $task['id'], 'project_id' => $task['project_id'])).'#links'); } else { diff --git a/app/Template/board/task_menu.php b/app/Template/board/task_menu.php index bbf12291..35104b66 100644 --- a/app/Template/board/task_menu.php +++ b/app/Template/board/task_menu.php @@ -6,6 +6,7 @@
  • a(t('Change category'), 'board', 'changeCategory', array('task_id' => $task['id'], 'project_id' => $task['project_id']), false, 'task-board-popover') ?>
  • a(t('Change description'), 'task', 'description', array('task_id' => $task['id'], 'project_id' => $task['project_id']), false, 'task-board-popover') ?>
  • a(t('Add a comment'), 'comment', 'create', array('task_id' => $task['id'], 'project_id' => $task['project_id']), false, 'task-board-popover') ?>
  • +
  • a(t('Add a link'), 'tasklink', 'create', array('task_id' => $task['id'], 'project_id' => $task['project_id']), false, 'task-board-popover') ?>
  • a(t('Edit this task'), 'task', 'edit', array('task_id' => $task['id'], 'project_id' => $task['project_id']), false, 'task-board-popover') ?>
  • a(t('Close this task'), 'task', 'close', array('task_id' => $task['id'], 'project_id' => $task['project_id'], 'redirect' => 'board'), false, 'task-board-popover') ?>
  • diff --git a/app/Template/tasklink/create.php b/app/Template/tasklink/create.php index fb438cd8..aec3b34a 100644 --- a/app/Template/tasklink/create.php +++ b/app/Template/tasklink/create.php @@ -2,7 +2,7 @@

    -
    + formCsrf() ?> formHidden('task_id', $values) ?> @@ -22,6 +22,10 @@
    - a(t('cancel'), 'task', 'show', array('task_id' => $task['id'], 'project_id' => $task['project_id'])) ?> + + a(t('cancel'), 'board', 'show', array('project_id' => $task['project_id'])) ?> + + a(t('cancel'), 'task', 'show', array('task_id' => $task['id'], 'project_id' => $task['project_id'])) ?> +
    \ No newline at end of file -- cgit v1.2.3