Improve task controller and fix bug description popover
This commit is contained in:
@@ -233,27 +233,21 @@ class Task extends Base
|
|||||||
*/
|
*/
|
||||||
public function close()
|
public function close()
|
||||||
{
|
{
|
||||||
$this->checkCSRFParam();
|
|
||||||
$task = $this->getTask();
|
$task = $this->getTask();
|
||||||
|
|
||||||
if ($this->task->close($task['id'])) {
|
if ($this->request->getStringParam('confirmation') === 'yes') {
|
||||||
$this->session->flash(t('Task closed successfully.'));
|
|
||||||
} else {
|
$this->checkCSRFParam();
|
||||||
$this->session->flashError(t('Unable to close this task.'));
|
|
||||||
|
if ($this->task->close($task['id'])) {
|
||||||
|
$this->session->flash(t('Task closed successfully.'));
|
||||||
|
} else {
|
||||||
|
$this->session->flashError(t('Unable to close this task.'));
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->response->redirect('?controller=task&action=show&task_id='.$task['id']);
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->response->redirect('?controller=task&action=show&task_id='.$task['id']);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Confirmation dialog before to close a task
|
|
||||||
*
|
|
||||||
* @access public
|
|
||||||
*/
|
|
||||||
public function confirmClose()
|
|
||||||
{
|
|
||||||
$task = $this->getTask();
|
|
||||||
|
|
||||||
$this->response->html($this->taskLayout('task_close', array(
|
$this->response->html($this->taskLayout('task_close', array(
|
||||||
'task' => $task,
|
'task' => $task,
|
||||||
'menu' => 'tasks',
|
'menu' => 'tasks',
|
||||||
@@ -268,27 +262,21 @@ class Task extends Base
|
|||||||
*/
|
*/
|
||||||
public function open()
|
public function open()
|
||||||
{
|
{
|
||||||
$this->checkCSRFParam();
|
|
||||||
$task = $this->getTask();
|
$task = $this->getTask();
|
||||||
|
|
||||||
if ($this->task->open($task['id'])) {
|
if ($this->request->getStringParam('confirmation') === 'yes') {
|
||||||
$this->session->flash(t('Task opened successfully.'));
|
|
||||||
} else {
|
$this->checkCSRFParam();
|
||||||
$this->session->flashError(t('Unable to open this task.'));
|
|
||||||
|
if ($this->task->open($task['id'])) {
|
||||||
|
$this->session->flash(t('Task opened successfully.'));
|
||||||
|
} else {
|
||||||
|
$this->session->flashError(t('Unable to open this task.'));
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->response->redirect('?controller=task&action=show&task_id='.$task['id']);
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->response->redirect('?controller=task&action=show&task_id='.$task['id']);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Confirmation dialog before to open a task
|
|
||||||
*
|
|
||||||
* @access public
|
|
||||||
*/
|
|
||||||
public function confirmOpen()
|
|
||||||
{
|
|
||||||
$task = $this->getTask();
|
|
||||||
|
|
||||||
$this->response->html($this->taskLayout('task_open', array(
|
$this->response->html($this->taskLayout('task_open', array(
|
||||||
'task' => $task,
|
'task' => $task,
|
||||||
'menu' => 'tasks',
|
'menu' => 'tasks',
|
||||||
@@ -303,27 +291,21 @@ class Task extends Base
|
|||||||
*/
|
*/
|
||||||
public function remove()
|
public function remove()
|
||||||
{
|
{
|
||||||
$this->checkCSRFParam();
|
|
||||||
$task = $this->getTask();
|
$task = $this->getTask();
|
||||||
|
|
||||||
if ($this->task->remove($task['id'])) {
|
if ($this->request->getStringParam('confirmation') === 'yes') {
|
||||||
$this->session->flash(t('Task removed successfully.'));
|
|
||||||
} else {
|
$this->checkCSRFParam();
|
||||||
$this->session->flashError(t('Unable to remove this task.'));
|
|
||||||
|
if ($this->task->remove($task['id'])) {
|
||||||
|
$this->session->flash(t('Task removed successfully.'));
|
||||||
|
} else {
|
||||||
|
$this->session->flashError(t('Unable to remove this task.'));
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->response->redirect('?controller=board&action=show&project_id='.$task['project_id']);
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->response->redirect('?controller=board&action=show&project_id='.$task['project_id']);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Confirmation dialog before removing a task
|
|
||||||
*
|
|
||||||
* @access public
|
|
||||||
*/
|
|
||||||
public function confirmRemove()
|
|
||||||
{
|
|
||||||
$task = $this->getTask();
|
|
||||||
|
|
||||||
$this->response->html($this->taskLayout('task_remove', array(
|
$this->response->html($this->taskLayout('task_remove', array(
|
||||||
'task' => $task,
|
'task' => $task,
|
||||||
'menu' => 'tasks',
|
'menu' => 'tasks',
|
||||||
@@ -366,20 +348,49 @@ class Task extends Base
|
|||||||
*
|
*
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
public function editDescription()
|
public function description()
|
||||||
{
|
{
|
||||||
$task = $this->getTask();
|
$task = $this->getTask();
|
||||||
|
$ajax = $this->request->isAjax() || $this->request->getIntegerParam('ajax');
|
||||||
|
|
||||||
|
if ($this->request->isPost()) {
|
||||||
|
|
||||||
|
$values = $this->request->getValues();
|
||||||
|
|
||||||
|
list($valid, $errors) = $this->task->validateDescriptionCreation($values);
|
||||||
|
|
||||||
|
if ($valid) {
|
||||||
|
|
||||||
|
if ($this->task->update($values)) {
|
||||||
|
$this->session->flash(t('Task updated successfully.'));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$this->session->flashError(t('Unable to update your task.'));
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($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']);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$values = $task;
|
||||||
|
$errors = array();
|
||||||
|
}
|
||||||
|
|
||||||
$params = array(
|
$params = array(
|
||||||
'values' => $task,
|
'values' => $values,
|
||||||
'errors' => array(),
|
'errors' => $errors,
|
||||||
'task' => $task,
|
'task' => $task,
|
||||||
'ajax' => $this->request->isAjax(),
|
'ajax' => $ajax,
|
||||||
'menu' => 'tasks',
|
'menu' => 'tasks',
|
||||||
'title' => t('Edit the description'),
|
'title' => t('Edit the description'),
|
||||||
);
|
);
|
||||||
|
|
||||||
if ($this->request->isAjax()) {
|
if ($ajax) {
|
||||||
$this->response->html($this->template->load('task_edit_description', $params));
|
$this->response->html($this->template->load('task_edit_description', $params));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -387,44 +398,6 @@ class Task extends Base
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Save and validation the description
|
|
||||||
*
|
|
||||||
* @access public
|
|
||||||
*/
|
|
||||||
public function saveDescription()
|
|
||||||
{
|
|
||||||
$task = $this->getTask();
|
|
||||||
$values = $this->request->getValues();
|
|
||||||
|
|
||||||
list($valid, $errors) = $this->task->validateDescriptionCreation($values);
|
|
||||||
|
|
||||||
if ($valid) {
|
|
||||||
|
|
||||||
if ($this->task->update($values)) {
|
|
||||||
$this->session->flash(t('Task updated successfully.'));
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
$this->session->flashError(t('Unable to update your task.'));
|
|
||||||
}
|
|
||||||
|
|
||||||
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(
|
|
||||||
'values' => $values,
|
|
||||||
'errors' => $errors,
|
|
||||||
'task' => $task,
|
|
||||||
'menu' => 'tasks',
|
|
||||||
'title' => t('Edit the description')
|
|
||||||
)));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Move a task to another project
|
* Move a task to another project
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -37,23 +37,7 @@ class Acl extends Base
|
|||||||
'comment' => array('create', 'save', 'confirm', 'remove', 'update', 'edit', 'forbidden'),
|
'comment' => array('create', 'save', 'confirm', 'remove', 'update', 'edit', 'forbidden'),
|
||||||
'file' => array('create', 'save', 'download', 'confirm', 'remove', 'open', 'image'),
|
'file' => array('create', 'save', 'download', 'confirm', 'remove', 'open', 'image'),
|
||||||
'subtask' => array('create', 'save', 'edit', 'update', 'confirm', 'remove'),
|
'subtask' => array('create', 'save', 'edit', 'update', 'confirm', 'remove'),
|
||||||
'task' => array(
|
'task' => array('show', 'create', 'save', 'edit', 'update', 'close', 'open', 'duplicate', 'remove', 'description', 'move', 'copy'),
|
||||||
'show',
|
|
||||||
'create',
|
|
||||||
'save',
|
|
||||||
'edit',
|
|
||||||
'update',
|
|
||||||
'close',
|
|
||||||
'confirmclose',
|
|
||||||
'open',
|
|
||||||
'confirmopen',
|
|
||||||
'duplicate',
|
|
||||||
'remove',
|
|
||||||
'confirmremove',
|
|
||||||
'editdescription',
|
|
||||||
'savedescription',
|
|
||||||
'move',
|
|
||||||
),
|
|
||||||
);
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -69,7 +69,7 @@
|
|||||||
<?php endif ?>
|
<?php endif ?>
|
||||||
|
|
||||||
<?php if (! empty($task['description'])): ?>
|
<?php if (! empty($task['description'])): ?>
|
||||||
<a class="task-board-popover" href='?controller=task&action=editDescription&task_id=<?= $task['id'] ?>'><i class="fa fa-file-text-o" title="<?= t('Description') ?>"></i></a>
|
<a class="task-description-popover" href="?controller=task&action=description&task_id=<?= $task['id'] ?>"><i class="fa fa-file-text-o" title="<?= t('Description') ?>" data-href="?controller=task&action=description&task_id=<?= $task['id'] ?>"></i></a>
|
||||||
<?php endif ?>
|
<?php endif ?>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
</p>
|
</p>
|
||||||
|
|
||||||
<div class="form-actions">
|
<div class="form-actions">
|
||||||
<a href="?controller=task&action=close&task_id=<?= $task['id'].Helper\param_csrf() ?>" class="btn btn-red"><?= t('Yes') ?></a>
|
<a href="?controller=task&action=close&confirmation=yes&task_id=<?= $task['id'].Helper\param_csrf() ?>" class="btn btn-red"><?= t('Yes') ?></a>
|
||||||
<?= t('or') ?> <a href="?controller=task&action=show&task_id=<?= $task['id'] ?>"><?= t('cancel') ?></a>
|
<?= t('or') ?> <a href="?controller=task&action=show&task_id=<?= $task['id'] ?>"><?= t('cancel') ?></a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -2,7 +2,7 @@
|
|||||||
<h2><?= t('Edit the description') ?></h2>
|
<h2><?= t('Edit the description') ?></h2>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<form method="post" action="?controller=task&action=saveDescription&task_id=<?= $task['id'] ?>&ajax=<?= $ajax ?>" autocomplete="off">
|
<form method="post" action="?controller=task&action=description&task_id=<?= $task['id'] ?>&ajax=<?= $ajax ?>" autocomplete="off">
|
||||||
|
|
||||||
<?= Helper\form_csrf() ?>
|
<?= Helper\form_csrf() ?>
|
||||||
|
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
</p>
|
</p>
|
||||||
|
|
||||||
<div class="form-actions">
|
<div class="form-actions">
|
||||||
<a href="?controller=task&action=open&task_id=<?= $task['id'].Helper\param_csrf() ?>" class="btn btn-red"><?= t('Yes') ?></a>
|
<a href="?controller=task&action=open&confirmation=yes&task_id=<?= $task['id'].Helper\param_csrf() ?>" class="btn btn-red"><?= t('Yes') ?></a>
|
||||||
<?= t('or') ?> <a href="?controller=task&action=show&task_id=<?= $task['id'] ?>"><?= t('cancel') ?></a>
|
<?= t('or') ?> <a href="?controller=task&action=show&task_id=<?= $task['id'] ?>"><?= t('cancel') ?></a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -8,7 +8,7 @@
|
|||||||
</p>
|
</p>
|
||||||
|
|
||||||
<div class="form-actions">
|
<div class="form-actions">
|
||||||
<a href="?controller=task&action=remove&task_id=<?= $task['id'].Helper\param_csrf() ?>" class="btn btn-red"><?= t('Yes') ?></a>
|
<a href="?controller=task&action=remove&confirmation=yes&task_id=<?= $task['id'].Helper\param_csrf() ?>" class="btn btn-red"><?= t('Yes') ?></a>
|
||||||
<?= t('or') ?> <a href="?controller=task&action=show&task_id=<?= $task['id'] ?>"><?= t('cancel') ?></a>
|
<?= t('or') ?> <a href="?controller=task&action=show&task_id=<?= $task['id'] ?>"><?= t('cancel') ?></a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -4,7 +4,7 @@
|
|||||||
<ul>
|
<ul>
|
||||||
<li><a href="?controller=task&action=show&task_id=<?= $task['id'] ?>"><?= t('Summary') ?></a></li>
|
<li><a href="?controller=task&action=show&task_id=<?= $task['id'] ?>"><?= t('Summary') ?></a></li>
|
||||||
<li><a href="?controller=task&action=edit&task_id=<?= $task['id'] ?>"><?= t('Edit the task') ?></a></li>
|
<li><a href="?controller=task&action=edit&task_id=<?= $task['id'] ?>"><?= t('Edit the task') ?></a></li>
|
||||||
<li><a href="?controller=task&action=editDescription&task_id=<?= $task['id'] ?>"><?= t('Edit the description') ?></a></li>
|
<li><a href="?controller=task&action=description&task_id=<?= $task['id'] ?>"><?= t('Edit the description') ?></a></li>
|
||||||
<li><a href="?controller=subtask&action=create&task_id=<?= $task['id'] ?>"><?= t('Add a sub-task') ?></a></li>
|
<li><a href="?controller=subtask&action=create&task_id=<?= $task['id'] ?>"><?= t('Add a sub-task') ?></a></li>
|
||||||
<li><a href="?controller=comment&action=create&task_id=<?= $task['id'] ?>"><?= t('Add a comment') ?></a></li>
|
<li><a href="?controller=comment&action=create&task_id=<?= $task['id'] ?>"><?= t('Add a comment') ?></a></li>
|
||||||
<li><a href="?controller=file&action=create&task_id=<?= $task['id'] ?>"><?= t('Attach a document') ?></a></li>
|
<li><a href="?controller=file&action=create&task_id=<?= $task['id'] ?>"><?= t('Attach a document') ?></a></li>
|
||||||
@@ -13,12 +13,12 @@
|
|||||||
<li><a href="?controller=task&action=move&project_id=<?= $task['project_id'] ?>&task_id=<?= $task['id'] ?>"><?= t('Move to another project') ?></a></li>
|
<li><a href="?controller=task&action=move&project_id=<?= $task['project_id'] ?>&task_id=<?= $task['id'] ?>"><?= t('Move to another project') ?></a></li>
|
||||||
<li>
|
<li>
|
||||||
<?php if ($task['is_active'] == 1): ?>
|
<?php if ($task['is_active'] == 1): ?>
|
||||||
<a href="?controller=task&action=confirmClose&task_id=<?= $task['id'] ?>"><?= t('Close this task') ?></a>
|
<a href="?controller=task&action=close&task_id=<?= $task['id'] ?>"><?= t('Close this task') ?></a>
|
||||||
<?php else: ?>
|
<?php else: ?>
|
||||||
<a href="?controller=task&action=confirmOpen&task_id=<?= $task['id'] ?>"><?= t('Open this task') ?></a>
|
<a href="?controller=task&action=open&task_id=<?= $task['id'] ?>"><?= t('Open this task') ?></a>
|
||||||
<?php endif ?>
|
<?php endif ?>
|
||||||
</li>
|
</li>
|
||||||
<li><a href="?controller=task&action=confirmRemove&task_id=<?= $task['id'] ?>"><?= t('Remove') ?></a></li>
|
<li><a href="?controller=task&action=remove&task_id=<?= $task['id'] ?>"><?= t('Remove') ?></a></li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -9,22 +9,30 @@ var Kanboard = (function() {
|
|||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
|
|
||||||
$.get(e.target.getAttribute("href"), function(content) {
|
var link = e.target.getAttribute("href");
|
||||||
|
|
||||||
$("body").append('<div id="popover-container"><div id="popover-content">' + content + '</div></div>');
|
if (! link) {
|
||||||
|
link = e.target.getAttribute("data-href");
|
||||||
|
}
|
||||||
|
|
||||||
$("#popover-container").click(function() {
|
if (link) {
|
||||||
$(this).remove();
|
$.get(link, function(content) {
|
||||||
|
|
||||||
|
$("body").append('<div id="popover-container"><div id="popover-content">' + content + '</div></div>');
|
||||||
|
|
||||||
|
$("#popover-container").click(function() {
|
||||||
|
$(this).remove();
|
||||||
|
});
|
||||||
|
|
||||||
|
$("#popover-content").click(function(e) {
|
||||||
|
e.stopPropagation();
|
||||||
|
});
|
||||||
|
|
||||||
|
if (callback) {
|
||||||
|
callback();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
}
|
||||||
$("#popover-content").click(function(e) {
|
|
||||||
e.stopPropagation();
|
|
||||||
});
|
|
||||||
|
|
||||||
if (callback) {
|
|
||||||
callback();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
},
|
},
|
||||||
|
|
||||||
// Return true if the page is visible
|
// Return true if the page is visible
|
||||||
@@ -89,6 +97,9 @@ Kanboard.Board = (function() {
|
|||||||
Kanboard.Popover(e, Kanboard.Task.Init);
|
Kanboard.Popover(e, Kanboard.Task.Init);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Description popover
|
||||||
|
$(".task-description-popover").click(Kanboard.Popover);
|
||||||
|
|
||||||
// Redirect to the task details page
|
// Redirect to the task details page
|
||||||
$("[data-task-id]").each(function() {
|
$("[data-task-id]").each(function() {
|
||||||
$(this).click(function() {
|
$(this).click(function() {
|
||||||
|
|||||||
Reference in New Issue
Block a user