From 6d65cfd88343aadc68e4963e66dcdc0688b4346c Mon Sep 17 00:00:00 2001 From: Francois Ferrand Date: Thu, 26 Jun 2014 15:52:39 +0200 Subject: Use popover to edit task and description directly from board. - Click on 'description' icon opens the 'edit-description' page. - Edit task and edit description now open in popover, like the assign dialog. --- app/Controller/Task.php | 65 +++++++++++++++++++++++---------- app/Templates/board_task.php | 10 ++--- app/Templates/task_edit.php | 11 +++++- app/Templates/task_edit_description.php | 7 +++- assets/js/board.js | 6 +-- 5 files changed, 68 insertions(+), 31 deletions(-) diff --git a/app/Controller/Task.php b/app/Controller/Task.php index d44ba268..15482afc 100644 --- a/app/Controller/Task.php +++ b/app/Controller/Task.php @@ -162,17 +162,24 @@ class Task extends Base $task['score'] = $task['score'] ?: ''; - $this->response->html($this->template->layout('task_edit', array( - 'values' => $task, - 'errors' => array(), - 'task' => $task, - 'columns_list' => $this->board->getColumnsList($task['project_id']), - 'users_list' => $this->project->getUsersList($task['project_id']), - 'colors_list' => $this->task->getColors(), - 'categories_list' => $this->category->getList($task['project_id']), - 'menu' => 'tasks', - 'title' => t('Edit a task') - ))); + $params = array( + 'values' => $task, + 'errors' => array(), + 'task' => $task, + 'columns_list' => $this->board->getColumnsList($task['project_id']), + 'users_list' => $this->project->getUsersList($task['project_id']), + 'colors_list' => $this->task->getColors(), + 'categories_list' => $this->category->getList($task['project_id']), + 'ajax' => $this->request->isAjax(), + 'menu' => 'tasks', + 'title' => t('Edit a task') + ); + if ($this->request->isAjax()) { + $this->response->html($this->template->load('task_edit', $params)); + } + else { + $this->response->html($this->template->layout('task_edit', $params)); + } } /** @@ -191,7 +198,13 @@ class Task extends Base if ($this->task->update($values)) { $this->session->flash(t('Task updated successfully.')); - $this->response->redirect('?controller=task&action=show&task_id='.$values['id']); + + if ($this->request->getIntegerParam('ajax')) { + $this->response->redirect('?controller=board&action=show&project_id='.$task['project_id']); + } + else { + $this->response->redirect('?controller=task&action=show&task_id='.$values['id']); + } } else { $this->session->flashError(t('Unable to update your task.')); @@ -357,13 +370,20 @@ class Task extends Base { $task = $this->getTask(); - $this->response->html($this->taskLayout('task_edit_description', array( - 'values' => $task, - 'errors' => array(), - 'task' => $task, - 'menu' => 'tasks', - 'title' => t('Edit the description') - ))); + $params = array( + 'values' => $task, + 'errors' => array(), + 'task' => $task, + 'ajax' => $this->request->isAjax(), + 'menu' => 'tasks', + 'title' => t('Edit the description') + ); + if ($this->request->isAjax()) { + $this->response->html($this->template->load('task_edit_description', $params)); + } + else { + $this->response->html($this->taskLayout('task_edit_description', $params)); + } } /** @@ -387,7 +407,12 @@ class Task extends Base $this->session->flashError(t('Unable to update your task.')); } - $this->response->redirect('?controller=task&action=show&task_id='.$task['id']); + if ($this->request->getIntegerParam('ajax')) { + $this->response->redirect('?controller=board&action=show&project_id='.$task['project_id']); + } + else { + $this->response->redirect('?controller=task&action=show&task_id='.$task['id']); + } } $this->response->html($this->taskLayout('task_edit_description', array( diff --git a/app/Templates/board_task.php b/app/Templates/board_task.php index fa745ac1..89f768e0 100644 --- a/app/Templates/board_task.php +++ b/app/Templates/board_task.php @@ -20,13 +20,13 @@ - # - + # - - + - + @@ -69,8 +69,8 @@ - + '> - \ No newline at end of file + diff --git a/app/Templates/task_edit.php b/app/Templates/task_edit.php index 015f746d..07c3539b 100644 --- a/app/Templates/task_edit.php +++ b/app/Templates/task_edit.php @@ -1,12 +1,14 @@
-
+ @@ -47,7 +49,12 @@
- + + + + + +
diff --git a/app/Templates/task_edit_description.php b/app/Templates/task_edit_description.php index 550dac73..ba0d3887 100644 --- a/app/Templates/task_edit_description.php +++ b/app/Templates/task_edit_description.php @@ -2,7 +2,7 @@

-
+ @@ -13,6 +13,11 @@
+ + + +
+ diff --git a/assets/js/board.js b/assets/js/board.js index f43f3f57..0487005d 100644 --- a/assets/js/board.js +++ b/assets/js/board.js @@ -15,14 +15,14 @@ }); // Open assignee popover - $(".task-board-user a").click(function(e) { + $(".task-board-popover").click(function(e) { e.preventDefault(); e.stopPropagation(); - var taskId = $(this).parent().parent().attr("data-task-id"); + var href = $(this).attr('href'); - $.get("?controller=board&action=assign&task_id=" + taskId, function(data) { + $.get(href, function(data) { popover_show(data); }); }); -- cgit v1.2.3