diff --git a/assets/css/app.css b/assets/css/app.css index 8d89f01c2..dbb302fd2 100644 --- a/assets/css/app.css +++ b/assets/css/app.css @@ -881,8 +881,5 @@ tr td.task-orange, /* confirmation box */ .confirm { max-width: 700px; - padding-top: 5px; - padding-bottom: 5px; - padding-left: 15px; - border-left: 2px dotted #ddd; + font-size: 1.1em; } diff --git a/controllers/base.php b/controllers/base.php index 37353ff0e..07c5db632 100644 --- a/controllers/base.php +++ b/controllers/base.php @@ -289,7 +289,7 @@ abstract class Base $hide_comment_form = true; } - $this->response->html($this->template->layout('task_show', array( + $this->response->html($this->taskLayout('task_show', array( 'hide_comment_form' => isset($hide_comment_form), 'comment_edit_form' => $comment_edit_form, 'comment_form' => $comment_form, @@ -302,4 +302,19 @@ abstract class Base 'title' => $task['title'], ))); } + + /** + * Common layout for task views + * + * @access protected + * @param string $template Template name + * @param array $params Template parameters + */ + protected function taskLayout($template, array $params) + { + $content = $this->template->load($template, $params); + $params['task_content_for_layout'] = $content; + + return $this->template->layout('task_layout', $params); + } } diff --git a/controllers/task.php b/controllers/task.php index 9065c576b..f5738a559 100644 --- a/controllers/task.php +++ b/controllers/task.php @@ -253,7 +253,7 @@ class Task extends Base $this->session->flashError(t('Unable to close this task.')); } - $this->response->redirect('?controller=board&action=show&project_id='.$task['project_id']); + $this->response->redirect('?controller=task&action=show&task_id='.$task['id']); } /** @@ -263,12 +263,12 @@ class Task extends Base */ public function confirmClose() { - $task = $this->task->getById($this->request->getIntegerParam('task_id')); + $task = $this->task->getById($this->request->getIntegerParam('task_id'), true); if (! $task) $this->notfound(); $this->checkProjectPermissions($task['project_id']); - $this->response->html($this->template->layout('task_close', array( + $this->response->html($this->taskLayout('task_close', array( 'task' => $task, 'menu' => 'tasks', 'title' => t('Close a task') @@ -293,7 +293,7 @@ class Task extends Base $this->session->flashError(t('Unable to open this task.')); } - $this->response->redirect('?controller=board&action=show&project_id='.$task['project_id']); + $this->response->redirect('?controller=task&action=show&task_id='.$task['id']); } /** @@ -302,16 +302,56 @@ class Task extends Base * @access public */ public function confirmOpen() + { + $task = $this->task->getById($this->request->getIntegerParam('task_id'), true); + + if (! $task) $this->notfound(); + $this->checkProjectPermissions($task['project_id']); + + $this->response->html($this->taskLayout('task_open', array( + 'task' => $task, + 'menu' => 'tasks', + 'title' => t('Open a task') + ))); + } + + /** + * Remove a task + * + * @access public + */ + public function remove() { $task = $this->task->getById($this->request->getIntegerParam('task_id')); if (! $task) $this->notfound(); $this->checkProjectPermissions($task['project_id']); - $this->response->html($this->template->layout('task_open', array( + 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']); + } + + /** + * Confirmation dialog before removing a task + * + * @access public + */ + public function confirmRemove() + { + $task = $this->task->getById($this->request->getIntegerParam('task_id'), true); + + if (! $task) $this->notfound(); + $this->checkProjectPermissions($task['project_id']); + + $this->response->html($this->taskLayout('task_remove', array( 'task' => $task, 'menu' => 'tasks', - 'title' => t('Open a task') + 'title' => t('Remove a task') ))); } diff --git a/locales/es_ES/translations.php b/locales/es_ES/translations.php index ea7da4ba7..e1d54c03d 100644 --- a/locales/es_ES/translations.php +++ b/locales/es_ES/translations.php @@ -305,4 +305,8 @@ return array( // 'Login with my Google Account' => '', // 'Project not found.' => '', // 'Task #%d' => '', + // 'Task removed successfully.' => '', + // 'Unable to remove this task.' => '', + // 'Remove a task' => '', + // 'Do you really want to remove this task: "%s"?' => '', ); diff --git a/locales/fr_FR/translations.php b/locales/fr_FR/translations.php index 0db189011..ac216c9b3 100644 --- a/locales/fr_FR/translations.php +++ b/locales/fr_FR/translations.php @@ -305,4 +305,8 @@ return array( 'Login with my Google Account' => 'Se connecter avec mon compte Google', 'Project not found.' => 'Projet introuvable.', 'Task #%d' => 'Tâche n°%d', + 'Task removed successfully.' => 'Tâche supprimée avec succès.', + 'Unable to remove this task.' => 'Impossible de supprimer cette tâche.', + 'Remove a task' => 'Supprimer une tâche', + 'Do you really want to remove this task: "%s"?' => 'Voulez-vous vraiment supprimer cette tâche « %s » ?', ); diff --git a/locales/pl_PL/translations.php b/locales/pl_PL/translations.php index d2018ef8c..a8feb8075 100644 --- a/locales/pl_PL/translations.php +++ b/locales/pl_PL/translations.php @@ -310,4 +310,8 @@ return array( // 'Login with my Google Account' => '', // 'Project not found.' => '', // 'Task #%d' => '', + // 'Task removed successfully.' => '', + // 'Unable to remove this task.' => '', + // 'Remove a task' => '', + // 'Do you really want to remove this task: "%s"?' => '', ); diff --git a/locales/pt_BR/translations.php b/locales/pt_BR/translations.php index 9ef5a7f8a..ffb578c58 100644 --- a/locales/pt_BR/translations.php +++ b/locales/pt_BR/translations.php @@ -306,4 +306,8 @@ return array( // 'Login with my Google Account' => '', // 'Project not found.' => '', // 'Task #%d' => '', + // 'Task removed successfully.' => '', + // 'Unable to remove this task.' => '', + // 'Remove a task' => '', + // 'Do you really want to remove this task: "%s"?' => '', ); diff --git a/models/acl.php b/models/acl.php index 4ab3ff411..0d1cd06e3 100644 --- a/models/acl.php +++ b/models/acl.php @@ -34,7 +34,7 @@ class Acl extends Base 'app' => array('index'), 'board' => array('index', 'show', 'assign', 'assigntask', 'save', 'check'), 'project' => array('tasks', 'index', 'forbidden', 'search'), - 'task' => array('show', 'create', 'save', 'edit', 'update', 'close', 'confirmclose', 'open', 'confirmopen', 'description', 'duplicate'), + 'task' => array('show', 'create', 'save', 'edit', 'update', 'close', 'confirmclose', 'open', 'confirmopen', 'description', 'duplicate', 'remove', 'confirmremove'), 'comment' => array('save', 'confirm', 'remove', 'update', 'edit'), 'user' => array('index', 'edit', 'update', 'forbidden', 'logout', 'index', 'unlinkgoogle'), 'config' => array('index', 'removeremembermetoken'), diff --git a/templates/task_close.php b/templates/task_close.php index 6bc32813e..3531b37d8 100644 --- a/templates/task_close.php +++ b/templates/task_close.php @@ -1,16 +1,10 @@ -
- +
+

+ +

-
-

- -

- -
- - -
+
+ +
-
\ No newline at end of file + \ No newline at end of file diff --git a/templates/task_layout.php b/templates/task_layout.php new file mode 100644 index 000000000..9a6bbd000 --- /dev/null +++ b/templates/task_layout.php @@ -0,0 +1,16 @@ +
+ +
+ + $task)) ?> + +
+ +
+
+
\ No newline at end of file diff --git a/templates/task_remove.php b/templates/task_remove.php new file mode 100644 index 000000000..1aa9503bf --- /dev/null +++ b/templates/task_remove.php @@ -0,0 +1,10 @@ +
+

+ +

+ +
+ + +
+
\ No newline at end of file diff --git a/templates/task_show.php b/templates/task_show.php index b16a20a01..f0cea4101 100644 --- a/templates/task_show.php +++ b/templates/task_show.php @@ -1,121 +1,89 @@ -
-
+ + \ No newline at end of file diff --git a/templates/task_sidebar.php b/templates/task_sidebar.php new file mode 100644 index 000000000..314d52143 --- /dev/null +++ b/templates/task_sidebar.php @@ -0,0 +1,17 @@ +
+

+
+ +
+
\ No newline at end of file