From 37c6616e50dbce2a298a27513b9882bb105405b0 Mon Sep 17 00:00:00 2001 From: Frédéric Guillot Date: Mon, 24 Nov 2014 21:32:03 -0500 Subject: Integrate tooltips and code cleanup/fix bugs, see #166 --- app/Controller/Board.php | 70 ++++++++++++++++++++++++++++++++++++++ app/Controller/Subtask.php | 10 ++---- app/Model/Acl.php | 2 +- app/Model/SubTask.php | 22 ++++++++++++ app/Template/board/comments.php | 13 +++++++ app/Template/board/description.php | 5 +++ app/Template/board/files.php | 14 ++++++++ app/Template/board/subtasks.php | 16 +++++++++ app/Template/board/task.php | 8 ++--- app/Template/subtask/icons.php | 7 ++++ app/Template/subtask_show.php | 8 +---- app/helpers.php | 5 +-- 12 files changed, 158 insertions(+), 22 deletions(-) create mode 100644 app/Template/board/comments.php create mode 100644 app/Template/board/description.php create mode 100644 app/Template/board/files.php create mode 100644 app/Template/board/subtasks.php create mode 100644 app/Template/subtask/icons.php (limited to 'app') diff --git a/app/Controller/Board.php b/app/Controller/Board.php index bdc82136..f04e847f 100644 --- a/app/Controller/Board.php +++ b/app/Controller/Board.php @@ -405,4 +405,74 @@ class Board extends Base $this->response->status(401); } } + + /** + * Get subtasks on mouseover + * + * @access public + */ + public function subtasks() + { + $task = $this->getTask(); + $this->response->html($this->template->load('board/subtasks', array( + 'subtasks' => $this->subTask->getAll($task['id']) + ))); + } + + /** + * Change the status of a subtask from the mouseover + * + * @access public + */ + public function toggleSubtask() + { + $task = $this->getTask(); + $this->subTask->toggleStatus($this->request->getIntegerParam('subtask_id')); + + $this->response->html($this->template->load('board/subtasks', array( + 'subtasks' => $this->subTask->getAll($task['id']) + ))); + } + + /** + * Display all attachments during the task mouseover + * + * @access public + */ + public function attachments() + { + $task = $this->getTask(); + + $this->response->html($this->template->load('board/files', array( + 'files' => $this->file->getAll($task['id']) + ))); + } + + /** + * Display comments during a task mouseover + * + * @access public + */ + public function comments() + { + $task = $this->getTask(); + + $this->response->html($this->template->load('board/comments', array( + 'comments' => $this->comment->getAll($task['id']) + ))); + } + + /** + * Display the description + * + * @access public + */ + public function description() + { + $task = $this->getTask(); + + $this->response->html($this->template->load('board/description', array( + 'task' => $task + ))); + } } diff --git a/app/Controller/Subtask.php b/app/Controller/Subtask.php index bc50b5e1..e48e7767 100644 --- a/app/Controller/Subtask.php +++ b/app/Controller/Subtask.php @@ -183,15 +183,9 @@ class Subtask extends Base public function toggleStatus() { $task = $this->getTask(); - $subtask = $this->getSubtask(); - - $value = array( - 'id' => $subtask['id'], - 'status' => ($subtask['status'] + 1) % 3, - 'task_id' => $task['id'], - ); + $subtask_id = $this->request->getIntegerParam('subtask_id'); - if (! $this->subTask->update($value)) { + if (! $this->subTask->toggleStatus($subtask_id)) { $this->session->flashError(t('Unable to update your sub-task.')); } diff --git a/app/Model/Acl.php b/app/Model/Acl.php index d96d5deb..4a5032d3 100644 --- a/app/Model/Acl.php +++ b/app/Model/Acl.php @@ -32,8 +32,8 @@ class Acl extends Base */ private $user_actions = array( 'app' => array('index', 'preview'), - 'board' => array('index', 'show', 'save', 'check', 'changeassignee', 'updateassignee', 'changecategory', 'updatecategory', 'movecolumn', 'edit', 'update', 'add', 'confirm', 'remove'), 'project' => array('index', 'show', 'exporttasks', 'exportdaily', 'share', 'edit', 'update', 'users', 'remove', 'duplicate', 'disable', 'enable', 'activity', 'search', 'tasks', 'create', 'save'), + 'board' => array('index', 'show', 'save', 'check', 'changeassignee', 'updateassignee', 'changecategory', 'updatecategory', 'movecolumn', 'edit', 'update', 'add', 'confirm', 'remove', 'subtasks', 'togglesubtask', 'attachments', 'comments', 'description'), 'user' => array('edit', 'forbidden', 'logout', 'show', 'external', 'unlinkgoogle', 'unlinkgithub', 'sessions', 'removesession', 'last', 'notifications', 'password'), 'comment' => array('create', 'save', 'confirm', 'remove', 'update', 'edit', 'forbidden'), 'file' => array('create', 'save', 'download', 'confirm', 'remove', 'open', 'image'), diff --git a/app/Model/SubTask.php b/app/Model/SubTask.php index 6e61330b..1faad680 100644 --- a/app/Model/SubTask.php +++ b/app/Model/SubTask.php @@ -171,6 +171,28 @@ class SubTask extends Base return $result; } + /** + * Change the status of subtask + * + * Todo -> In progress -> Done -> Todo -> etc... + * + * @access public + * @param integer $subtask_id + * @return bool + */ + public function toggleStatus($subtask_id) + { + $subtask = $this->getById($subtask_id); + + $values = array( + 'id' => $subtask['id'], + 'status' => ($subtask['status'] + 1) % 3, + 'task_id' => $subtask['task_id'], + ); + + return $this->update($values); + } + /** * Remove * diff --git a/app/Template/board/comments.php b/app/Template/board/comments.php new file mode 100644 index 00000000..83d6bd9a --- /dev/null +++ b/app/Template/board/comments.php @@ -0,0 +1,13 @@ +
+ +

+ @ +

+ +
+
+ +
+
+ +
diff --git a/app/Template/board/description.php b/app/Template/board/description.php new file mode 100644 index 00000000..85e042dd --- /dev/null +++ b/app/Template/board/description.php @@ -0,0 +1,5 @@ +
+
+ +
+
\ No newline at end of file diff --git a/app/Template/board/files.php b/app/Template/board/files.php new file mode 100644 index 00000000..66d5bff9 --- /dev/null +++ b/app/Template/board/files.php @@ -0,0 +1,14 @@ +
+ + + + $file['id'], 'task_id' => $file['task_id']) + ) ?> + +
+ +
diff --git a/app/Template/board/subtasks.php b/app/Template/board/subtasks.php new file mode 100644 index 00000000..c7f995d7 --- /dev/null +++ b/app/Template/board/subtasks.php @@ -0,0 +1,16 @@ +
+ + $subtask)) ?> + + $subtask['task_id'], 'subtask_id' => $subtask['id']) + ) ?> + + + +
+ +
\ No newline at end of file diff --git a/app/Template/board/task.php b/app/Template/board/task.php index 02ae46c1..e29ff2bb 100644 --- a/app/Template/board/task.php +++ b/app/Template/board/task.php @@ -90,19 +90,19 @@
- + - + - + - + diff --git a/app/Template/subtask/icons.php b/app/Template/subtask/icons.php new file mode 100644 index 00000000..1f31d51f --- /dev/null +++ b/app/Template/subtask/icons.php @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/app/Template/subtask_show.php b/app/Template/subtask_show.php index 29f4bfd1..686b160e 100644 --- a/app/Template/subtask_show.php +++ b/app/Template/subtask_show.php @@ -19,13 +19,7 @@ - - - - - - - + $subtask)) ?> $task['id'], 'subtask_id' => $subtask['id'])) ?> diff --git a/app/helpers.php b/app/helpers.php index 6c8e8955..0129853f 100644 --- a/app/helpers.php +++ b/app/helpers.php @@ -574,11 +574,12 @@ function form_numeric($name, $values = array(), array $errors = array(), array $ * @param array $params Url parameters * @param boolean $csrf Add a CSRF token * @param string $class CSS class attribute + * @param boolean $new_tab Open the link in a new tab * @return string */ -function a($label, $controller, $action, array $params = array(), $csrf = false, $class = '', $title = '') +function a($label, $controller, $action, array $params = array(), $csrf = false, $class = '', $title = '', $new_tab = false) { - return ''.$label.''; + return ''.$label.''; } /** -- cgit v1.2.3