summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorFrederic Guillot <fred@kanboard.net>2016-02-02 21:28:07 -0500
committerFrederic Guillot <fred@kanboard.net>2016-02-02 21:28:07 -0500
commit5eb4b570a12a590a98c66d253b0ba54c6062a997 (patch)
tree8878e26b1970a2096047cff0b7bf2fba5f962117 /app
parentd6d9e61816a6d7000449f86f057dd1c97820cf4a (diff)
Show subtask modification forms in inline popup
Diffstat (limited to 'app')
-rw-r--r--app/Controller/Subtask.php30
-rw-r--r--app/Template/subtask/create.php4
-rw-r--r--app/Template/subtask/edit.php4
-rw-r--r--app/Template/subtask/remove.php2
-rw-r--r--app/Template/subtask/show.php22
-rw-r--r--app/Template/task/show.php1
-rw-r--r--app/Template/task/sidebar.php15
7 files changed, 52 insertions, 26 deletions
diff --git a/app/Controller/Subtask.php b/app/Controller/Subtask.php
index 526962a9..9fe15c9d 100644
--- a/app/Controller/Subtask.php
+++ b/app/Controller/Subtask.php
@@ -30,6 +30,23 @@ class Subtask extends Base
}
/**
+ * Show list of subtasks
+ */
+ public function show()
+ {
+ $task = $this->getTask();
+
+ $this->response->html($this->helper->layout->task('subtask/show', array(
+ 'users_list' => $this->projectUserRole->getAssignableUsersList($task['project_id']),
+ 'task' => $task,
+ 'project' => $this->getProject(),
+ 'subtasks' => $this->subtask->getAll($task['id']),
+ 'editable' => true,
+ 'redirect' => 'subtask',
+ )));
+ }
+
+ /**
* Creation form
*
* @access public
@@ -73,10 +90,10 @@ class Subtask extends Base
}
if (isset($values['another_subtask']) && $values['another_subtask'] == 1) {
- $this->response->redirect($this->helper->url->to('subtask', 'create', array('project_id' => $task['project_id'], 'task_id' => $task['id'], 'another_subtask' => 1)));
+ return $this->create(array('project_id' => $task['project_id'], 'task_id' => $task['id'], 'another_subtask' => 1));
}
- $this->response->redirect($this->helper->url->to('task', 'show', array('project_id' => $task['project_id'], 'task_id' => $task['id']), 'subtasks'));
+ return $this->response->redirect($this->helper->url->to('task', 'show', array('project_id' => $task['project_id'], 'task_id' => $task['id']), 'subtasks'), true);
}
$this->create($values, $errors);
@@ -122,7 +139,7 @@ class Subtask extends Base
$this->flash->failure(t('Unable to update your sub-task.'));
}
- $this->response->redirect($this->helper->url->to('task', 'show', array('project_id' => $task['project_id'], 'task_id' => $task['id']), 'subtasks'));
+ return $this->response->redirect($this->helper->url->to('task', 'show', array('project_id' => $task['project_id'], 'task_id' => $task['id'])), true);
}
$this->edit($values, $errors);
@@ -161,7 +178,7 @@ class Subtask extends Base
$this->flash->failure(t('Unable to remove this sub-task.'));
}
- $this->response->redirect($this->helper->url->to('task', 'show', array('project_id' => $task['project_id'], 'task_id' => $task['id']), 'subtasks'));
+ $this->response->redirect($this->helper->url->to('task', 'show', array('project_id' => $task['project_id'], 'task_id' => $task['id'])), true);
}
/**
@@ -249,6 +266,8 @@ class Subtask extends Base
$this->response->redirect($this->helper->url->to('board', 'show', array('project_id' => $task['project_id'])));
case 'dashboard':
$this->response->redirect($this->helper->url->to('app', 'index'));
+ case 'subtask':
+ $this->response->redirect($this->helper->url->to('subtask', 'show', array('task_id' => $task['id'], 'project_id' => $task['project_id'])));
default:
$this->response->redirect($this->helper->url->to('task', 'show', array('task_id' => $task['id'], 'project_id' => $task['project_id']), 'subtasks'));
}
@@ -267,8 +286,9 @@ class Subtask extends Base
$subtask_id = $this->request->getIntegerParam('subtask_id');
$direction = $this->request->getStringParam('direction');
$method = $direction === 'up' ? 'moveUp' : 'moveDown';
+ $redirect = $this->request->getStringParam('redirect', 'task');
$this->subtask->$method($task_id, $subtask_id);
- $this->response->redirect($this->helper->url->to('task', 'show', array('project_id' => $project_id, 'task_id' => $task_id), 'subtasks'));
+ $this->response->redirect($this->helper->url->to($redirect, 'show', array('project_id' => $project_id, 'task_id' => $task_id), 'subtasks'));
}
}
diff --git a/app/Template/subtask/create.php b/app/Template/subtask/create.php
index e237619e..8fffd3a9 100644
--- a/app/Template/subtask/create.php
+++ b/app/Template/subtask/create.php
@@ -2,7 +2,7 @@
<h2><?= t('Add a sub-task') ?></h2>
</div>
-<form method="post" action="<?= $this->url->href('subtask', 'save', array('task_id' => $task['id'], 'project_id' => $task['project_id'])) ?>" autocomplete="off">
+<form class="popover-form" method="post" action="<?= $this->url->href('subtask', 'save', array('task_id' => $task['id'], 'project_id' => $task['project_id'])) ?>" autocomplete="off">
<?= $this->form->csrf() ?>
<?= $this->form->hidden('task_id', $values) ?>
@@ -15,6 +15,6 @@
<div class="form-actions">
<input type="submit" value="<?= t('Save') ?>" class="btn btn-blue">
<?= t('or') ?>
- <?= $this->url->link(t('cancel'), 'task', 'show', array('task_id' => $task['id'], 'project_id' => $task['project_id'])) ?>
+ <?= $this->url->link(t('cancel'), 'task', 'show', array('task_id' => $task['id'], 'project_id' => $task['project_id']), false, 'close-popover') ?>
</div>
</form>
diff --git a/app/Template/subtask/edit.php b/app/Template/subtask/edit.php
index ca028108..acce625e 100644
--- a/app/Template/subtask/edit.php
+++ b/app/Template/subtask/edit.php
@@ -2,7 +2,7 @@
<h2><?= t('Edit a sub-task') ?></h2>
</div>
-<form method="post" action="<?= $this->url->href('subtask', 'update', array('task_id' => $task['id'], 'project_id' => $task['project_id'], 'subtask_id' => $subtask['id'])) ?>" autocomplete="off">
+<form class="popover-form" method="post" action="<?= $this->url->href('subtask', 'update', array('task_id' => $task['id'], 'project_id' => $task['project_id'], 'subtask_id' => $subtask['id'])) ?>" autocomplete="off">
<?= $this->form->csrf() ?>
<?= $this->form->hidden('id', $values) ?>
@@ -15,6 +15,6 @@
<div class="form-actions">
<input type="submit" value="<?= t('Save') ?>" class="btn btn-blue">
<?= t('or') ?>
- <?= $this->url->link(t('cancel'), 'task', 'show', array('task_id' => $task['id'], 'project_id' => $task['project_id'])) ?>
+ <?= $this->url->link(t('cancel'), 'task', 'show', array('task_id' => $task['id'], 'project_id' => $task['project_id']), false, 'close-popover') ?>
</div>
</form>
diff --git a/app/Template/subtask/remove.php b/app/Template/subtask/remove.php
index 65ade31d..9aef6842 100644
--- a/app/Template/subtask/remove.php
+++ b/app/Template/subtask/remove.php
@@ -12,6 +12,6 @@
<div class="form-actions">
<?= $this->url->link(t('Yes'), 'subtask', 'remove', array('task_id' => $task['id'], 'project_id' => $task['project_id'], 'subtask_id' => $subtask['id']), true, 'btn btn-red') ?>
<?= t('or') ?>
- <?= $this->url->link(t('cancel'), 'task', 'show', array('task_id' => $task['id'], 'project_id' => $task['project_id'])) ?>
+ <?= $this->url->link(t('cancel'), 'task', 'show', array('task_id' => $task['id'], 'project_id' => $task['project_id']), false, 'close-popover') ?>
</div>
</div> \ No newline at end of file
diff --git a/app/Template/subtask/show.php b/app/Template/subtask/show.php
index 6945840f..027e9495 100644
--- a/app/Template/subtask/show.php
+++ b/app/Template/subtask/show.php
@@ -1,9 +1,10 @@
+<div class="page-header">
+ <h2><?= t('Sub-Tasks') ?></h2>
+</div>
+
<div id="subtasks" class="task-show-section">
<?php if (! empty($subtasks)): ?>
- <div class="page-header">
- <h2><?= t('Sub-Tasks') ?></h2>
- </div>
<?php $first_position = $subtasks[0]['position']; ?>
<?php $last_position = $subtasks[count($subtasks) - 1]['position']; ?>
@@ -20,7 +21,7 @@
<tr>
<td>
<?php if ($editable): ?>
- <?= $this->subtask->toggleStatus($subtask, 'task') ?>
+ <?= $this->subtask->toggleStatus($subtask, $redirect) ?>
<?php else: ?>
<?= $this->render('subtask/icons', array('subtask' => $subtask)) . $this->e($subtask['title']) ?>
<?php endif ?>
@@ -66,19 +67,19 @@
<ul>
<?php if ($subtask['position'] != $first_position): ?>
<li>
- <?= $this->url->link(t('Move Up'), 'subtask', 'movePosition', array('project_id' => $project['id'], 'task_id' => $subtask['task_id'], 'subtask_id' => $subtask['id'], 'direction' => 'up'), true) ?>
+ <?= $this->url->link(t('Move Up'), 'subtask', 'movePosition', array('project_id' => $project['id'], 'task_id' => $subtask['task_id'], 'subtask_id' => $subtask['id'], 'direction' => 'up', 'redirect' => $redirect), true) ?>
</li>
<?php endif ?>
<?php if ($subtask['position'] != $last_position): ?>
<li>
- <?= $this->url->link(t('Move Down'), 'subtask', 'movePosition', array('project_id' => $project['id'], 'task_id' => $subtask['task_id'], 'subtask_id' => $subtask['id'], 'direction' => 'down'), true) ?>
+ <?= $this->url->link(t('Move Down'), 'subtask', 'movePosition', array('project_id' => $project['id'], 'task_id' => $subtask['task_id'], 'subtask_id' => $subtask['id'], 'direction' => 'down', 'redirect' => $redirect), true) ?>
</li>
<?php endif ?>
<li>
- <?= $this->url->link(t('Edit'), 'subtask', 'edit', array('task_id' => $task['id'], 'project_id' => $task['project_id'], 'subtask_id' => $subtask['id'])) ?>
+ <?= $this->url->link(t('Edit'), 'subtask', 'edit', array('task_id' => $task['id'], 'project_id' => $task['project_id'], 'subtask_id' => $subtask['id']), false, 'popover') ?>
</li>
<li>
- <?= $this->url->link(t('Remove'), 'subtask', 'confirm', array('task_id' => $task['id'], 'project_id' => $task['project_id'], 'subtask_id' => $subtask['id'])) ?>
+ <?= $this->url->link(t('Remove'), 'subtask', 'confirm', array('task_id' => $task['id'], 'project_id' => $task['project_id'], 'subtask_id' => $subtask['id']), false, 'popover') ?>
</li>
</ul>
</div>
@@ -90,11 +91,6 @@
<?php endif ?>
<?php if ($editable && $this->user->hasProjectAccess('subtask', 'save', $task['project_id'])): ?>
- <?php if (empty($subtasks)): ?>
- <div class="page-header">
- <h2><?= t('Sub-Tasks') ?></h2>
- </div>
- <?php endif ?>
<form method="post" action="<?= $this->url->href('subtask', 'save', array('task_id' => $task['id'], 'project_id' => $task['project_id'])) ?>" autocomplete="off">
<?= $this->form->csrf() ?>
<?= $this->form->hidden('task_id', array('task_id' => $task['id'])) ?>
diff --git a/app/Template/task/show.php b/app/Template/task/show.php
index 5fd73afb..246c8f33 100644
--- a/app/Template/task/show.php
+++ b/app/Template/task/show.php
@@ -19,6 +19,7 @@
'project' => $project,
'users_list' => isset($users_list) ? $users_list : array(),
'editable' => $this->user->hasProjectAccess('subtask', 'edit', $project['id']),
+ 'redirect' => 'task',
)) ?>
<?= $this->render('tasklink/show', array(
diff --git a/app/Template/task/sidebar.php b/app/Template/task/sidebar.php
index b5a2c4b4..81cd3434 100644
--- a/app/Template/task/sidebar.php
+++ b/app/Template/task/sidebar.php
@@ -22,6 +22,18 @@
<?= $this->hook->render('template:task:sidebar:information') ?>
</ul>
+ <h2><?= t('Sub-Tasks') ?></h2>
+ <ul>
+ <li <?= $this->app->checkMenuSelection('subtask', 'show') ?>>
+ <?= $this->url->link(t('View all sub-tasks'), 'subtask', 'show', array('task_id' => $task['id'], 'project_id' => $task['project_id'])) ?>
+ </li>
+ <?php if ($this->user->hasProjectAccess('subtask', 'create', $task['project_id'])): ?>
+ <li <?= $this->app->checkMenuSelection('subtask', 'create') ?>>
+ <?= $this->url->link(t('Add a sub-task'), 'subtask', 'create', array('task_id' => $task['id'], 'project_id' => $task['project_id']), false, 'popover') ?>
+ </li>
+ <?php endif ?>
+ </ul>
+
<h2><?= t('Links') ?></h2>
<ul>
<li <?= $this->app->checkMenuSelection('tasklink', 'show') ?>>
@@ -52,9 +64,6 @@
<li <?= $this->app->checkMenuSelection('taskmodification', 'recurrence') ?>>
<?= $this->url->link(t('Edit recurrence'), 'taskmodification', 'recurrence', array('task_id' => $task['id'], 'project_id' => $task['project_id'])) ?>
</li>
- <li <?= $this->app->checkMenuSelection('subtask', 'create') ?>>
- <?= $this->url->link(t('Add a sub-task'), 'subtask', 'create', array('task_id' => $task['id'], 'project_id' => $task['project_id'])) ?>
- </li>
<li <?= $this->app->checkMenuSelection('comment', 'create') ?>>
<?= $this->url->link(t('Add a comment'), 'comment', 'create', array('task_id' => $task['id'], 'project_id' => $task['project_id'])) ?>
</li>