Move task edit form to the task layout
This commit is contained in:
parent
dd7579e5a8
commit
a5337cfe5c
|
|
@ -160,23 +160,25 @@ class Task extends Base
|
|||
}
|
||||
|
||||
$task['score'] = $task['score'] ?: '';
|
||||
$ajax = $this->request->isAjax();
|
||||
|
||||
$params = array(
|
||||
'values' => $task,
|
||||
'errors' => array(),
|
||||
'task' => $task,
|
||||
'users_list' => $this->projectPermission->getUsersList($task['project_id']),
|
||||
'colors_list' => $this->color->getList(),
|
||||
'categories_list' => $this->category->getList($task['project_id']),
|
||||
'ajax' => $this->request->isAjax(),
|
||||
'menu' => 'tasks',
|
||||
'title' => t('Edit a task')
|
||||
);
|
||||
if ($this->request->isAjax()) {
|
||||
'values' => $task,
|
||||
'errors' => array(),
|
||||
'task' => $task,
|
||||
'users_list' => $this->projectPermission->getUsersList($task['project_id']),
|
||||
'colors_list' => $this->color->getList(),
|
||||
'categories_list' => $this->category->getList($task['project_id']),
|
||||
'ajax' => $ajax,
|
||||
'menu' => 'tasks',
|
||||
'title' => t('Edit a task')
|
||||
);
|
||||
|
||||
if ($ajax) {
|
||||
$this->response->html($this->template->load('task_edit', $params));
|
||||
}
|
||||
else {
|
||||
$this->response->html($this->template->layout('task_edit', $params));
|
||||
$this->response->html($this->taskLayout('task_edit', $params));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -209,7 +211,7 @@ class Task extends Base
|
|||
}
|
||||
}
|
||||
|
||||
$this->response->html($this->template->layout('task_edit', array(
|
||||
$this->response->html($this->taskLayout('task_edit', array(
|
||||
'values' => $values,
|
||||
'errors' => $errors,
|
||||
'task' => $task,
|
||||
|
|
@ -218,7 +220,8 @@ class Task extends Base
|
|||
'colors_list' => $this->color->getList(),
|
||||
'categories_list' => $this->category->getList($values['project_id']),
|
||||
'menu' => 'tasks',
|
||||
'title' => t('Edit a task')
|
||||
'title' => t('Edit a task'),
|
||||
'ajax' => $this->request->isAjax(),
|
||||
)));
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -8,8 +8,8 @@ namespace Core;
|
|||
* @package core
|
||||
* @author Frederic Guillot
|
||||
*/
|
||||
interface Listener {
|
||||
|
||||
interface Listener
|
||||
{
|
||||
/**
|
||||
* Execute the listener
|
||||
*
|
||||
|
|
|
|||
|
|
@ -79,13 +79,35 @@ class TaskValidator extends Base
|
|||
}
|
||||
|
||||
/**
|
||||
* Validate task modification
|
||||
* Validate task modification (form)
|
||||
*
|
||||
* @access public
|
||||
* @param array $values Form values
|
||||
* @return array $valid, $errors [0] = Success or not, [1] = List of errors
|
||||
*/
|
||||
public function validateModification(array $values)
|
||||
{
|
||||
$rules = array(
|
||||
new Validators\Required('id', t('The id is required')),
|
||||
new Validators\Required('title', t('The title is required')),
|
||||
);
|
||||
|
||||
$v = new Validator($values, array_merge($rules, $this->commonValidationRules()));
|
||||
|
||||
return array(
|
||||
$v->execute(),
|
||||
$v->getErrors()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate task modification (Api)
|
||||
*
|
||||
* @access public
|
||||
* @param array $values Form values
|
||||
* @return array $valid, $errors [0] = Success or not, [1] = List of errors
|
||||
*/
|
||||
public function validateApiModification(array $values)
|
||||
{
|
||||
$rules = array(
|
||||
new Validators\Required('id', t('The id is required')),
|
||||
|
|
|
|||
|
|
@ -1,58 +1,51 @@
|
|||
<section id="main">
|
||||
<div class="page-header">
|
||||
<h2><?= t('Edit a task') ?></h2>
|
||||
<?php if (! $ajax): ?>
|
||||
<ul>
|
||||
<li><a href="?controller=board&action=show&project_id=<?= $task['project_id'] ?>"><?= t('Back to the board') ?></a></li>
|
||||
</ul>
|
||||
<div class="page-header">
|
||||
<h2><?= t('Edit a task') ?></h2>
|
||||
</div>
|
||||
<section id="task-section">
|
||||
<form method="post" action="?controller=task&action=update&task_id=<?= $task['id'] ?>&ajax=<?= $ajax ?>" autocomplete="off">
|
||||
|
||||
<?= Helper\form_csrf() ?>
|
||||
|
||||
<div class="form-column">
|
||||
|
||||
<?= Helper\form_label(t('Title'), 'title') ?>
|
||||
<?= Helper\form_text('title', $values, $errors, array('required')) ?><br/>
|
||||
|
||||
<?= Helper\form_label(t('Description'), 'description') ?>
|
||||
<?= Helper\form_textarea('description', $values, $errors) ?><br/>
|
||||
<div class="form-help"><a href="http://kanboard.net/documentation/syntax-guide" target="_blank" rel="noreferrer"><?= t('Write your text in Markdown') ?></a></div>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="form-column">
|
||||
<?= Helper\form_hidden('id', $values) ?>
|
||||
<?= Helper\form_hidden('project_id', $values) ?>
|
||||
|
||||
<?= Helper\form_label(t('Assignee'), 'owner_id') ?>
|
||||
<?= Helper\form_select('owner_id', $users_list, $values, $errors) ?><br/>
|
||||
|
||||
<?= Helper\form_label(t('Category'), 'category_id') ?>
|
||||
<?= Helper\form_select('category_id', $categories_list, $values, $errors) ?><br/>
|
||||
|
||||
<?= Helper\form_label(t('Color'), 'color_id') ?>
|
||||
<?= Helper\form_select('color_id', $colors_list, $values, $errors) ?><br/>
|
||||
|
||||
<?= Helper\form_label(t('Complexity'), 'score') ?>
|
||||
<?= Helper\form_number('score', $values, $errors) ?><br/>
|
||||
|
||||
<?= Helper\form_label(t('Due Date'), 'date_due') ?>
|
||||
<?= Helper\form_text('date_due', $values, $errors, array('placeholder="'.t('month/day/year').'"'), 'form-date') ?><br/>
|
||||
<div class="form-help"><?= t('Others formats accepted: %s and %s', date('Y-m-d'), date('Y_m_d')) ?></div>
|
||||
</div>
|
||||
|
||||
<div class="form-actions">
|
||||
<input type="submit" value="<?= t('Save') ?>" class="btn btn-blue"/>
|
||||
<?= t('or') ?>
|
||||
<?php if ($ajax): ?>
|
||||
<a href="?controller=board&action=show&project_id=<?= $task['project_id'] ?>"><?= t('cancel') ?></a>
|
||||
<?php else: ?>
|
||||
<a href="?controller=task&action=show&task_id=<?= $task['id'] ?>"><?= t('cancel') ?></a>
|
||||
<?php endif ?>
|
||||
</div>
|
||||
<section id="task-section">
|
||||
<form method="post" action="?controller=task&action=update&task_id=<?= $task['id'] ?>&ajax=<?= $ajax ?>" autocomplete="off">
|
||||
|
||||
<?= Helper\form_csrf() ?>
|
||||
|
||||
<div class="form-column">
|
||||
|
||||
<?= Helper\form_label(t('Title'), 'title') ?>
|
||||
<?= Helper\form_text('title', $values, $errors, array('required')) ?><br/>
|
||||
|
||||
<?= Helper\form_label(t('Description'), 'description') ?>
|
||||
<?= Helper\form_textarea('description', $values, $errors) ?><br/>
|
||||
<div class="form-help"><a href="http://kanboard.net/documentation/syntax-guide" target="_blank" rel="noreferrer"><?= t('Write your text in Markdown') ?></a></div>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="form-column">
|
||||
<?= Helper\form_hidden('id', $values) ?>
|
||||
<?= Helper\form_hidden('project_id', $values) ?>
|
||||
|
||||
<?= Helper\form_label(t('Assignee'), 'owner_id') ?>
|
||||
<?= Helper\form_select('owner_id', $users_list, $values, $errors) ?><br/>
|
||||
|
||||
<?= Helper\form_label(t('Category'), 'category_id') ?>
|
||||
<?= Helper\form_select('category_id', $categories_list, $values, $errors) ?><br/>
|
||||
|
||||
<?= Helper\form_label(t('Color'), 'color_id') ?>
|
||||
<?= Helper\form_select('color_id', $colors_list, $values, $errors) ?><br/>
|
||||
|
||||
<?= Helper\form_label(t('Complexity'), 'score') ?>
|
||||
<?= Helper\form_number('score', $values, $errors) ?><br/>
|
||||
|
||||
<?= Helper\form_label(t('Due Date'), 'date_due') ?>
|
||||
<?= Helper\form_text('date_due', $values, $errors, array('placeholder="'.t('month/day/year').'"'), 'form-date') ?><br/>
|
||||
<div class="form-help"><?= t('Others formats accepted: %s and %s', date('Y-m-d'), date('Y_m_d')) ?></div>
|
||||
</div>
|
||||
|
||||
<div class="form-actions">
|
||||
<input type="submit" value="<?= t('Save') ?>" class="btn btn-blue"/>
|
||||
<?= t('or') ?>
|
||||
<?php if ($ajax): ?>
|
||||
<a href="?controller=board&action=show&project_id=<?= $task['project_id'] ?>"><?= t('cancel') ?></a>
|
||||
<?php else: ?>
|
||||
<a href="?controller=task&action=show&task_id=<?= $task['id'] ?>"><?= t('cancel') ?></a>
|
||||
<?php endif ?>
|
||||
</div>
|
||||
</form>
|
||||
</section>
|
||||
</form>
|
||||
</section>
|
||||
|
|
|
|||
|
|
@ -222,6 +222,10 @@ textarea.form-error {
|
|||
list-style-type: none;
|
||||
}
|
||||
|
||||
ul.form-errors li {
|
||||
margin-left: 0;
|
||||
}
|
||||
|
||||
.form-help {
|
||||
font-size: 0.8em;
|
||||
color: brown;
|
||||
|
|
|
|||
|
|
@ -211,7 +211,7 @@ $server->register('updateTask', function($id, $title = null, $project_id = null,
|
|||
}
|
||||
}
|
||||
|
||||
list($valid) = $taskValidator->validateModification($values);
|
||||
list($valid) = $taskValidator->validateApiModification($values);
|
||||
return $valid && $task->update($values);
|
||||
});
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue