summaryrefslogtreecommitdiff
path: root/app/Helper/Subtask.php
diff options
context:
space:
mode:
authorFrederic Guillot <fred@kanboard.net>2016-02-04 21:38:53 -0500
committerFrederic Guillot <fred@kanboard.net>2016-02-04 21:38:53 -0500
commit0f2b46dd6a9a1dc17768de2c415f382df95142e8 (patch)
tree55191fce45c7c06b7d2b45834ea4151745c3db77 /app/Helper/Subtask.php
parent346151e103431e8de12520b26daae10676b8faf5 (diff)
Do not refresh the whole page when changing subtask status (work in progress)
Diffstat (limited to 'app/Helper/Subtask.php')
-rw-r--r--app/Helper/Subtask.php38
1 files changed, 20 insertions, 18 deletions
diff --git a/app/Helper/Subtask.php b/app/Helper/Subtask.php
index 5b8d7d90..38074b78 100644
--- a/app/Helper/Subtask.php
+++ b/app/Helper/Subtask.php
@@ -10,38 +10,40 @@ namespace Kanboard\Helper;
*/
class Subtask extends \Kanboard\Core\Base
{
+ public function getTitle(array $subtask)
+ {
+ if ($subtask['status'] == 0) {
+ $html = '<i class="fa fa-square-o fa-fw"></i>';
+ } elseif ($subtask['status'] == 1) {
+ $html = '<i class="fa fa-gears fa-fw"></i>';
+ } else {
+ $html = '<i class="fa fa-check-square-o fa-fw"></i>';
+ }
+
+ return $html.$this->helper->e($subtask['title']);
+ }
+
/**
* Get the link to toggle subtask status
*
* @access public
* @param array $subtask
- * @param string $redirect
* @param integer $project_id
* @return string
*/
- public function toggleStatus(array $subtask, $redirect, $project_id = 0)
+ public function toggleStatus(array $subtask, $project_id)
{
- if ($project_id > 0 && ! $this->helper->user->hasProjectAccess('subtask', 'edit', $project_id)) {
- return trim($this->template->render('subtask/icons', array('subtask' => $subtask))) . $this->helper->e($subtask['title']);
+ if (! $this->helper->user->hasProjectAccess('subtask', 'edit', $project_id)) {
+ return $this->getTitle($subtask);
}
+ $params = array('task_id' => $subtask['task_id'], 'subtask_id' => $subtask['id']);
+
if ($subtask['status'] == 0 && isset($this->sessionStorage->hasSubtaskInProgress) && $this->sessionStorage->hasSubtaskInProgress) {
- return $this->helper->url->link(
- trim($this->template->render('subtask/icons', array('subtask' => $subtask))) . $this->helper->e($subtask['title']),
- 'subtask',
- 'subtaskRestriction',
- array('task_id' => $subtask['task_id'], 'subtask_id' => $subtask['id'], 'redirect' => $redirect),
- false,
- 'popover task-board-popover'
- );
+ return $this->helper->url->link($this->getTitle($subtask), 'SubtaskRestriction', 'popover', $params, false, 'popover');
}
- return $this->helper->url->link(
- trim($this->template->render('subtask/icons', array('subtask' => $subtask))) . $this->helper->e($subtask['title']),
- 'subtask',
- 'toggleStatus',
- array('task_id' => $subtask['task_id'], 'subtask_id' => $subtask['id'], 'redirect' => $redirect)
- );
+ return $this->helper->url->link($this->getTitle($subtask), 'SubtaskStatus', 'change', $params, false, 'ajax-replace');
}
public function selectTitle(array $values, array $errors = array(), array $attributes = array())