Add the possibility to add a description directly from the task show view
This commit is contained in:
@@ -39,6 +39,42 @@ class Task extends Base
|
|||||||
$this->response->text('FAILED');
|
$this->response->text('FAILED');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Display the template show task, common between different task view
|
||||||
|
private function showTask(array $task, array $comment_form = array(), array $description_form = array())
|
||||||
|
{
|
||||||
|
if (empty($comment_form)) {
|
||||||
|
|
||||||
|
$comment_form = array(
|
||||||
|
'values' => array(
|
||||||
|
'task_id' => $task['id'],
|
||||||
|
'user_id' => $this->acl->getUserId()
|
||||||
|
),
|
||||||
|
'errors' => array()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (empty($description_form)) {
|
||||||
|
|
||||||
|
$description_form = array(
|
||||||
|
'values' => array(
|
||||||
|
'id' => $task['id'],
|
||||||
|
),
|
||||||
|
'errors' => array()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->response->html($this->template->layout('task_show', array(
|
||||||
|
'comment_form' => $comment_form,
|
||||||
|
'description_form' => $description_form,
|
||||||
|
'comments' => $this->comment->getAll($task['id']),
|
||||||
|
'task' => $task,
|
||||||
|
'columns_list' => $this->board->getColumnsList($task['project_id']),
|
||||||
|
'colors_list' => $this->task->getColors(),
|
||||||
|
'menu' => 'tasks',
|
||||||
|
'title' => $task['title'],
|
||||||
|
)));
|
||||||
|
}
|
||||||
|
|
||||||
// Show a task
|
// Show a task
|
||||||
public function show()
|
public function show()
|
||||||
{
|
{
|
||||||
@@ -47,16 +83,7 @@ class Task extends Base
|
|||||||
if (! $task) $this->notfound();
|
if (! $task) $this->notfound();
|
||||||
$this->checkProjectPermissions($task['project_id']);
|
$this->checkProjectPermissions($task['project_id']);
|
||||||
|
|
||||||
$this->response->html($this->template->layout('task_show', array(
|
$this->showTask($task);
|
||||||
'comments' => $this->comment->getAll($task['id']),
|
|
||||||
'comment_errors' => array(),
|
|
||||||
'comment_values' => array('task_id' => $task['id'], 'user_id' => $this->acl->getUserId()),
|
|
||||||
'task' => $task,
|
|
||||||
'columns_list' => $this->board->getColumnsList($task['project_id']),
|
|
||||||
'colors_list' => $this->task->getColors(),
|
|
||||||
'menu' => 'tasks',
|
|
||||||
'title' => $task['title'],
|
|
||||||
)));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add a comment
|
// Add a comment
|
||||||
@@ -82,16 +109,40 @@ class Task extends Base
|
|||||||
$this->response->redirect('?controller=task&action=show&task_id='.$task['id']);
|
$this->response->redirect('?controller=task&action=show&task_id='.$task['id']);
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->response->html($this->template->layout('task_show', array(
|
$this->showTask(
|
||||||
'comments' => $this->comment->getAll($task['id']),
|
$task,
|
||||||
'comment_errors' => $errors,
|
array('values' => $values, 'errors' => $errors)
|
||||||
'comment_values' => $values,
|
);
|
||||||
'task' => $task,
|
}
|
||||||
'columns_list' => $this->board->getColumnsList($task['project_id']),
|
|
||||||
'colors_list' => $this->task->getColors(),
|
// Add a description from the show task page
|
||||||
'menu' => 'tasks',
|
public function description()
|
||||||
'title' => $task['title'],
|
{
|
||||||
)));
|
$task = $this->task->getById($this->request->getIntegerParam('task_id'), true);
|
||||||
|
$values = $this->request->getValues();
|
||||||
|
|
||||||
|
if (! $task) $this->notfound();
|
||||||
|
$this->checkProjectPermissions($task['project_id']);
|
||||||
|
|
||||||
|
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.'));
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->response->redirect('?controller=task&action=show&task_id='.$task['id']);
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->showTask(
|
||||||
|
$task,
|
||||||
|
array(),
|
||||||
|
array('values' => $values, 'errors' => $errors)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Display a form to create a new task
|
// Display a form to create a new task
|
||||||
|
|||||||
@@ -207,4 +207,8 @@ return array(
|
|||||||
'Write your text in Markdown' => 'Écrivez votre texte en Markdown',
|
'Write your text in Markdown' => 'Écrivez votre texte en Markdown',
|
||||||
'Leave a comment' => 'Laissez un commentaire',
|
'Leave a comment' => 'Laissez un commentaire',
|
||||||
'Comment is required' => 'Le commentaire est obligatoire',
|
'Comment is required' => 'Le commentaire est obligatoire',
|
||||||
|
'Leave a description' => 'Laissez une description',
|
||||||
|
'Comment added successfully.' => 'Commentaire ajouté avec succès.',
|
||||||
|
'Unable to create your comment.' => 'Impossible de sauvegarder votre commentaire.',
|
||||||
|
'The description is required' => 'La description est obligatoire',
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -211,4 +211,7 @@ return array(
|
|||||||
//'Write your text in Markdown' => '',
|
//'Write your text in Markdown' => '',
|
||||||
//'Leave a comment' => '',
|
//'Leave a comment' => '',
|
||||||
//'Comment is required' => '',
|
//'Comment is required' => '',
|
||||||
|
//'Comment added successfully.' => '',
|
||||||
|
//'Unable to create your comment.' => '',
|
||||||
|
//'The description is required' => '',
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ class Acl extends Base
|
|||||||
'app' => array('index'),
|
'app' => array('index'),
|
||||||
'board' => array('index', 'show', 'assign', 'assigntask', 'save'),
|
'board' => array('index', 'show', 'assign', 'assigntask', 'save'),
|
||||||
'project' => array('tasks', 'index', 'forbidden'),
|
'project' => array('tasks', 'index', 'forbidden'),
|
||||||
'task' => array('show', 'create', 'save', 'edit', 'update', 'close', 'confirmclose', 'open', 'confirmopen', 'comment'),
|
'task' => array('show', 'create', 'save', 'edit', 'update', 'close', 'confirmclose', 'open', 'confirmopen', 'comment', 'description'),
|
||||||
'user' => array('index', 'edit', 'update', 'forbidden', 'logout', 'index'),
|
'user' => array('index', 'edit', 'update', 'forbidden', 'logout', 'index'),
|
||||||
'config' => array('index'),
|
'config' => array('index'),
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -192,6 +192,20 @@ class Task extends Base
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function validateDescriptionCreation(array $values)
|
||||||
|
{
|
||||||
|
$v = new Validator($values, array(
|
||||||
|
new Validators\Required('id', t('The id is required')),
|
||||||
|
new Validators\Integer('id', t('This value must be an integer')),
|
||||||
|
new Validators\Required('description', t('The description is required')),
|
||||||
|
));
|
||||||
|
|
||||||
|
return array(
|
||||||
|
$v->execute(),
|
||||||
|
$v->getErrors()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
public function validateModification(array $values)
|
public function validateModification(array $values)
|
||||||
{
|
{
|
||||||
$v = new Validator($values, array(
|
$v = new Validator($values, array(
|
||||||
|
|||||||
@@ -53,11 +53,22 @@
|
|||||||
</ul>
|
</ul>
|
||||||
</article>
|
</article>
|
||||||
|
|
||||||
|
<h3><?= t('Description') ?></h3>
|
||||||
<?php if ($task['description']): ?>
|
<?php if ($task['description']): ?>
|
||||||
<h3><?= t('Description') ?></h3>
|
|
||||||
<article id="description" class="markdown">
|
<article id="description" class="markdown">
|
||||||
<?= Helper\markdown($task['description']) ?: t('There is no description.') ?>
|
<?= Helper\markdown($task['description']) ?: t('There is no description.') ?>
|
||||||
</article>
|
</article>
|
||||||
|
<?php else: ?>
|
||||||
|
<form method="post" action="?controller=task&action=description&task_id=<?= $task['id'] ?>" autocomplete="off">
|
||||||
|
|
||||||
|
<?= Helper\form_hidden('id', $description_form['values']) ?>
|
||||||
|
<?= Helper\form_textarea('description', $description_form['values'], $description_form['errors'], array('required', 'placeholder="'.t('Leave a description').'"')) ?><br/>
|
||||||
|
<div class="form-help"><a href="http://en.wikipedia.org/wiki/Markdown#Example" target="_blank"><?= t('Write your text in Markdown') ?></a></div>
|
||||||
|
|
||||||
|
<div class="form-actions">
|
||||||
|
<input type="submit" value="<?= t('Save') ?>" class="btn btn-blue"/>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
<?php endif ?>
|
<?php endif ?>
|
||||||
|
|
||||||
<h3><?= t('Comments') ?></h3>
|
<h3><?= t('Comments') ?></h3>
|
||||||
@@ -74,9 +85,9 @@
|
|||||||
|
|
||||||
<form method="post" action="?controller=task&action=comment&task_id=<?= $task['id'] ?>" autocomplete="off">
|
<form method="post" action="?controller=task&action=comment&task_id=<?= $task['id'] ?>" autocomplete="off">
|
||||||
|
|
||||||
<?= Helper\form_hidden('task_id', $comment_values) ?>
|
<?= Helper\form_hidden('task_id', $comment_form['values']) ?>
|
||||||
<?= Helper\form_hidden('user_id', $comment_values) ?>
|
<?= Helper\form_hidden('user_id', $comment_form['values']) ?>
|
||||||
<?= Helper\form_textarea('comment', $comment_values, $comment_errors, array('required', 'placeholder="'.t('Leave a comment').'"'), 'comment-textarea') ?><br/>
|
<?= Helper\form_textarea('comment', $comment_form['values'], $comment_form['errors'], array('required', 'placeholder="'.t('Leave a comment').'"'), 'comment-textarea') ?><br/>
|
||||||
<div class="form-help"><a href="http://en.wikipedia.org/wiki/Markdown#Example" target="_blank"><?= t('Write your text in Markdown') ?></a></div>
|
<div class="form-help"><a href="http://en.wikipedia.org/wiki/Markdown#Example" target="_blank"><?= t('Write your text in Markdown') ?></a></div>
|
||||||
|
|
||||||
<div class="form-actions">
|
<div class="form-actions">
|
||||||
|
|||||||
Reference in New Issue
Block a user