Move subtask templates to a subfolder
This commit is contained in:
parent
c6b9a2a92e
commit
20b60bc628
|
|
@ -32,16 +32,20 @@ class Subtask extends Base
|
|||
*
|
||||
* @access public
|
||||
*/
|
||||
public function create()
|
||||
public function create(array $values = array(), array $errors = array())
|
||||
{
|
||||
$task = $this->getTask();
|
||||
|
||||
$this->response->html($this->taskLayout('subtask_create', array(
|
||||
'values' => array(
|
||||
if (empty($values)) {
|
||||
$values = array(
|
||||
'task_id' => $task['id'],
|
||||
'another_subtask' => $this->request->getIntegerParam('another_subtask', 0)
|
||||
),
|
||||
'errors' => array(),
|
||||
);
|
||||
}
|
||||
|
||||
$this->response->html($this->taskLayout('subtask/create', array(
|
||||
'values' => $values,
|
||||
'errors' => $errors,
|
||||
'users_list' => $this->projectPermission->getMemberList($task['project_id']),
|
||||
'task' => $task,
|
||||
)));
|
||||
|
|
@ -75,12 +79,7 @@ class Subtask extends Base
|
|||
$this->response->redirect('?controller=task&action=show&task_id='.$task['id'].'#subtasks');
|
||||
}
|
||||
|
||||
$this->response->html($this->taskLayout('subtask_create', array(
|
||||
'values' => $values,
|
||||
'errors' => $errors,
|
||||
'users_list' => $this->projectPermission->getMemberList($task['project_id']),
|
||||
'task' => $task,
|
||||
)));
|
||||
$this->create($values, $errors);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -88,14 +87,14 @@ class Subtask extends Base
|
|||
*
|
||||
* @access public
|
||||
*/
|
||||
public function edit()
|
||||
public function edit(array $values = array(), array $errors = array())
|
||||
{
|
||||
$task = $this->getTask();
|
||||
$subtask = $this->getSubTask();
|
||||
|
||||
$this->response->html($this->taskLayout('subtask_edit', array(
|
||||
'values' => $subtask,
|
||||
'errors' => array(),
|
||||
$this->response->html($this->taskLayout('subtask/edit', array(
|
||||
'values' => empty($values) ? $subtask : $values,
|
||||
'errors' => $errors,
|
||||
'users_list' => $this->projectPermission->getMemberList($task['project_id']),
|
||||
'status_list' => $this->subTask->getStatusList(),
|
||||
'subtask' => $subtask,
|
||||
|
|
@ -128,14 +127,7 @@ class Subtask extends Base
|
|||
$this->response->redirect('?controller=task&action=show&task_id='.$task['id'].'#subtasks');
|
||||
}
|
||||
|
||||
$this->response->html($this->taskLayout('subtask_edit', array(
|
||||
'values' => $values,
|
||||
'errors' => $errors,
|
||||
'users_list' => $this->projectPermission->getMemberList($task['project_id']),
|
||||
'status_list' => $this->subTask->getStatusList(),
|
||||
'subtask' => $subtask,
|
||||
'task' => $task,
|
||||
)));
|
||||
$this->edit($values, $errors);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -148,7 +140,7 @@ class Subtask extends Base
|
|||
$task = $this->getTask();
|
||||
$subtask = $this->getSubtask();
|
||||
|
||||
$this->response->html($this->taskLayout('subtask_remove', array(
|
||||
$this->response->html($this->taskLayout('subtask/remove', array(
|
||||
'subtask' => $subtask,
|
||||
'task' => $task,
|
||||
)));
|
||||
|
|
|
|||
|
|
@ -263,6 +263,29 @@ class SubTask extends Base
|
|||
* @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 subtask id is required')),
|
||||
new Validators\Required('task_id', t('The task 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 API modification
|
||||
*
|
||||
* @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 subtask id is required')),
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
<h2><?= t('Add a sub-task') ?></h2>
|
||||
</div>
|
||||
|
||||
<form method="post" action="?controller=subtask&action=save&task_id=<?= $task['id'] ?>" autocomplete="off">
|
||||
<form method="post" action="<?= Helper\u('subtask', 'save', array('task_id' => $task['id'])) ?>" autocomplete="off">
|
||||
|
||||
<?= Helper\form_csrf() ?>
|
||||
|
||||
|
|
@ -22,6 +22,6 @@
|
|||
<div class="form-actions">
|
||||
<input type="submit" value="<?= t('Save') ?>" class="btn btn-blue"/>
|
||||
<?= t('or') ?>
|
||||
<a href="?controller=task&action=show&task_id=<?= $task['id'] ?>"><?= t('cancel') ?></a>
|
||||
<?= Helper\a(t('cancel'), 'task', 'show', array('task_id' => $task['id'])) ?>
|
||||
</div>
|
||||
</form>
|
||||
|
|
@ -2,7 +2,7 @@
|
|||
<h2><?= t('Edit a sub-task') ?></h2>
|
||||
</div>
|
||||
|
||||
<form method="post" action="?controller=subtask&action=update&task_id=<?= $task['id'] ?>&subtask_id=<?= $subtask['id'] ?>" autocomplete="off">
|
||||
<form method="post" action="<?= Helper\u('subtask', 'update', array('task_id' => $task['id'], 'subtask_id' => $subtask['id'])) ?>" autocomplete="off">
|
||||
|
||||
<?= Helper\form_csrf() ?>
|
||||
|
||||
|
|
@ -27,6 +27,6 @@
|
|||
<div class="form-actions">
|
||||
<input type="submit" value="<?= t('Save') ?>" class="btn btn-blue"/>
|
||||
<?= t('or') ?>
|
||||
<a href="?controller=task&action=show&task_id=<?= $task['id'] ?>"><?= t('cancel') ?></a>
|
||||
<?= Helper\a(t('cancel'), 'task', 'show', array('task_id' => $task['id'])) ?>
|
||||
</div>
|
||||
</form>
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
<div class="page-header">
|
||||
<h2><?= t('Remove a sub-task') ?></h2>
|
||||
</div>
|
||||
|
||||
<div class="confirm">
|
||||
<p class="alert alert-info">
|
||||
<?= t('Do you really want to remove this sub-task?') ?>
|
||||
</p>
|
||||
|
||||
<p><strong><?= Helper\escape($subtask['title']) ?></strong></p>
|
||||
|
||||
<div class="form-actions">
|
||||
<?= Helper\a(t('Yes'), 'subtask', 'remove', array('task_id' => $task['id'], 'subtask_id' => $subtask['id']), true, 'btn btn-red') ?>
|
||||
<?= t('or') ?>
|
||||
<?= Helper\a(t('cancel'), 'task', 'show', array('task_id' => $task['id'])) ?>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -1,16 +0,0 @@
|
|||
<div class="page-header">
|
||||
<h2><?= t('Remove a sub-task') ?></h2>
|
||||
</div>
|
||||
|
||||
<div class="confirm">
|
||||
<p class="alert alert-info">
|
||||
<?= t('Do you really want to remove this sub-task?') ?>
|
||||
</p>
|
||||
|
||||
<p><strong><?= Helper\escape($subtask['title']) ?></strong></p>
|
||||
|
||||
<div class="form-actions">
|
||||
<a href="?controller=subtask&action=remove&task_id=<?= $task['id'] ?>&subtask_id=<?= $subtask['id'].Helper\param_csrf() ?>" class="btn btn-red"><?= t('Yes') ?></a>
|
||||
<?= t('or') ?> <a href="?controller=task&action=show&task_id=<?= $task['id'] ?>#subtasks"><?= t('cancel') ?></a>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
<?= Helper\template('task_details', array('task' => $task, 'project' => $project)) ?>
|
||||
<?= Helper\template('task_time', array('values' => $values, 'date_format' => $date_format, 'date_formats' => $date_formats)) ?>
|
||||
<?= Helper\template('task_show_description', array('task' => $task)) ?>
|
||||
<?= Helper\template('subtask_show', array('task' => $task, 'subtasks' => $subtasks)) ?>
|
||||
<?= Helper\template('subtask/show', array('task' => $task, 'subtasks' => $subtasks)) ?>
|
||||
<?= Helper\template('task_timesheet', array('timesheet' => $timesheet)) ?>
|
||||
<?= Helper\template('file/show', array('task' => $task, 'files' => $files)) ?>
|
||||
<?= Helper\template('task_comments', array('task' => $task, 'comments' => $comments, 'project' => $project)) ?>
|
||||
|
|
@ -254,6 +254,7 @@ textarea.form-error {
|
|||
input.form-error:focus,
|
||||
textarea.form-error:focus {
|
||||
box-shadow: none;
|
||||
border: 2px solid #b94a48;
|
||||
}
|
||||
|
||||
.form-required {
|
||||
|
|
|
|||
|
|
@ -87,6 +87,7 @@ textarea.form-error {
|
|||
input.form-error:focus,
|
||||
textarea.form-error:focus {
|
||||
box-shadow: none;
|
||||
border: 2px solid #b94a48;
|
||||
}
|
||||
|
||||
.form-required {
|
||||
|
|
|
|||
|
|
@ -333,7 +333,7 @@ $server->register('updateSubtask', function($id, $task_id, $title = null, $user_
|
|||
}
|
||||
}
|
||||
|
||||
list($valid,) = $subTaskModel->validateModification($values);
|
||||
list($valid,) = $subTaskModel->validateApiModification($values);
|
||||
return $valid && $subTaskModel->update($values);
|
||||
});
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue