Move task edit form to the task layout
This commit is contained in:
@@ -160,23 +160,25 @@ class Task extends Base
|
|||||||
}
|
}
|
||||||
|
|
||||||
$task['score'] = $task['score'] ?: '';
|
$task['score'] = $task['score'] ?: '';
|
||||||
|
$ajax = $this->request->isAjax();
|
||||||
|
|
||||||
$params = array(
|
$params = array(
|
||||||
'values' => $task,
|
'values' => $task,
|
||||||
'errors' => array(),
|
'errors' => array(),
|
||||||
'task' => $task,
|
'task' => $task,
|
||||||
'users_list' => $this->projectPermission->getUsersList($task['project_id']),
|
'users_list' => $this->projectPermission->getUsersList($task['project_id']),
|
||||||
'colors_list' => $this->color->getList(),
|
'colors_list' => $this->color->getList(),
|
||||||
'categories_list' => $this->category->getList($task['project_id']),
|
'categories_list' => $this->category->getList($task['project_id']),
|
||||||
'ajax' => $this->request->isAjax(),
|
'ajax' => $ajax,
|
||||||
'menu' => 'tasks',
|
'menu' => 'tasks',
|
||||||
'title' => t('Edit a task')
|
'title' => t('Edit a task')
|
||||||
);
|
);
|
||||||
if ($this->request->isAjax()) {
|
|
||||||
|
if ($ajax) {
|
||||||
$this->response->html($this->template->load('task_edit', $params));
|
$this->response->html($this->template->load('task_edit', $params));
|
||||||
}
|
}
|
||||||
else {
|
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,
|
'values' => $values,
|
||||||
'errors' => $errors,
|
'errors' => $errors,
|
||||||
'task' => $task,
|
'task' => $task,
|
||||||
@@ -218,7 +220,8 @@ class Task extends Base
|
|||||||
'colors_list' => $this->color->getList(),
|
'colors_list' => $this->color->getList(),
|
||||||
'categories_list' => $this->category->getList($values['project_id']),
|
'categories_list' => $this->category->getList($values['project_id']),
|
||||||
'menu' => 'tasks',
|
'menu' => 'tasks',
|
||||||
'title' => t('Edit a task')
|
'title' => t('Edit a task'),
|
||||||
|
'ajax' => $this->request->isAjax(),
|
||||||
)));
|
)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -8,8 +8,8 @@ namespace Core;
|
|||||||
* @package core
|
* @package core
|
||||||
* @author Frederic Guillot
|
* @author Frederic Guillot
|
||||||
*/
|
*/
|
||||||
interface Listener {
|
interface Listener
|
||||||
|
{
|
||||||
/**
|
/**
|
||||||
* Execute the listener
|
* Execute the listener
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -79,13 +79,35 @@ class TaskValidator extends Base
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Validate task modification
|
* Validate task modification (form)
|
||||||
*
|
*
|
||||||
* @access public
|
* @access public
|
||||||
* @param array $values Form values
|
* @param array $values Form values
|
||||||
* @return array $valid, $errors [0] = Success or not, [1] = List of errors
|
* @return array $valid, $errors [0] = Success or not, [1] = List of errors
|
||||||
*/
|
*/
|
||||||
public function validateModification(array $values)
|
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(
|
$rules = array(
|
||||||
new Validators\Required('id', t('The id is required')),
|
new Validators\Required('id', t('The id is required')),
|
||||||
|
|||||||
@@ -1,58 +1,51 @@
|
|||||||
<section id="main">
|
<div class="page-header">
|
||||||
<div class="page-header">
|
<h2><?= t('Edit a task') ?></h2>
|
||||||
<h2><?= t('Edit a task') ?></h2>
|
</div>
|
||||||
<?php if (! $ajax): ?>
|
<section id="task-section">
|
||||||
<ul>
|
<form method="post" action="?controller=task&action=update&task_id=<?= $task['id'] ?>&ajax=<?= $ajax ?>" autocomplete="off">
|
||||||
<li><a href="?controller=board&action=show&project_id=<?= $task['project_id'] ?>"><?= t('Back to the board') ?></a></li>
|
|
||||||
</ul>
|
<?= 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 ?>
|
<?php endif ?>
|
||||||
</div>
|
</div>
|
||||||
<section id="task-section">
|
</form>
|
||||||
<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>
|
|
||||||
</section>
|
</section>
|
||||||
|
|||||||
@@ -222,6 +222,10 @@ textarea.form-error {
|
|||||||
list-style-type: none;
|
list-style-type: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ul.form-errors li {
|
||||||
|
margin-left: 0;
|
||||||
|
}
|
||||||
|
|
||||||
.form-help {
|
.form-help {
|
||||||
font-size: 0.8em;
|
font-size: 0.8em;
|
||||||
color: brown;
|
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);
|
return $valid && $task->update($values);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user