Show subtask modification forms in inline popup

This commit is contained in:
Frederic Guillot 2016-02-02 21:28:07 -05:00
parent d6d9e61816
commit 5eb4b570a1
10 changed files with 56 additions and 29 deletions

View File

@ -22,6 +22,7 @@ New features:
Improvements:
* Use inline popup for subtasks modification
* Move homepage menus to the user dropdown
* Have a new task assigned to the creator by default instead of "no assignee"
* Show progress for task links in board tooltips

View File

@ -29,6 +29,23 @@ class Subtask extends Base
return $subtask;
}
/**
* 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
*
@ -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'));
}
}

View File

@ -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>

View File

@ -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>

View File

@ -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>

View File

@ -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'])) ?>

View File

@ -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(

View File

@ -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>

File diff suppressed because one or more lines are too long

View File

@ -13,7 +13,7 @@ Popover.prototype.open = function(link) {
self.app.dropdown.close();
$.get(link, function(content) {
$("body").append('<div id="popover-container"><div id="popover-content">' + content + '</div></div>');
$("body").prepend('<div id="popover-container"><div id="popover-content">' + content + '</div></div>');
self.app.refresh();
self.router.dispatch(this.app);
self.afterOpen();
@ -91,7 +91,7 @@ Popover.prototype.afterSubmit = function(data, request, self) {
var redirect = request.getResponseHeader("X-Ajax-Redirect");
if (redirect) {
window.location = redirect === 'self' ? window.location.href : redirect;
window.location = redirect === 'self' ? window.location.href.split("#")[0] : redirect;
}
else {
$("#popover-content").html(data);