summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFrédéric Guillot <fred@kanboard.net>2014-11-26 21:04:46 -0500
committerFrédéric Guillot <fred@kanboard.net>2014-11-26 21:04:46 -0500
commit20b60bc628a7c28cb7780e06073df68a821adc19 (patch)
treeb51360727b274cbab78771748cb0e87fc0c677c6
parentc6b9a2a92e60cb4488748d597a9df14c556236d3 (diff)
Move subtask templates to a subfolder
-rw-r--r--app/Controller/Subtask.php40
-rw-r--r--app/Model/SubTask.php23
-rw-r--r--app/Template/subtask/create.php (renamed from app/Template/subtask_create.php)4
-rw-r--r--app/Template/subtask/edit.php (renamed from app/Template/subtask_edit.php)4
-rw-r--r--app/Template/subtask/remove.php (renamed from app/Template/subtask_remove.php)5
-rw-r--r--app/Template/subtask/show.php (renamed from app/Template/subtask_show.php)0
-rw-r--r--app/Template/task_show.php2
-rw-r--r--assets/css/app.css1
-rw-r--r--assets/css/form.css1
-rw-r--r--jsonrpc.php2
10 files changed, 50 insertions, 32 deletions
diff --git a/app/Controller/Subtask.php b/app/Controller/Subtask.php
index e48e7767..948f3c76 100644
--- a/app/Controller/Subtask.php
+++ b/app/Controller/Subtask.php
@@ -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,
)));
diff --git a/app/Model/SubTask.php b/app/Model/SubTask.php
index 1faad680..f301ad62 100644
--- a/app/Model/SubTask.php
+++ b/app/Model/SubTask.php
@@ -267,6 +267,29 @@ class SubTask extends Base
$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')),
+ new Validators\Required('task_id', t('The task id is required')),
);
$v = new Validator($values, array_merge($rules, $this->commonValidationRules()));
diff --git a/app/Template/subtask_create.php b/app/Template/subtask/create.php
index c8ee556b..40a6da3d 100644
--- a/app/Template/subtask_create.php
+++ b/app/Template/subtask/create.php
@@ -2,7 +2,7 @@
<h2><?= t('Add a sub-task') ?></h2>
</div>
-<form method="post" action="?controller=subtask&amp;action=save&amp;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&amp;action=show&amp;task_id=<?= $task['id'] ?>"><?= t('cancel') ?></a>
+ <?= Helper\a(t('cancel'), 'task', 'show', array('task_id' => $task['id'])) ?>
</div>
</form>
diff --git a/app/Template/subtask_edit.php b/app/Template/subtask/edit.php
index 91690d0a..88ea6175 100644
--- a/app/Template/subtask_edit.php
+++ b/app/Template/subtask/edit.php
@@ -2,7 +2,7 @@
<h2><?= t('Edit a sub-task') ?></h2>
</div>
-<form method="post" action="?controller=subtask&amp;action=update&amp;task_id=<?= $task['id'] ?>&amp;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&amp;action=show&amp;task_id=<?= $task['id'] ?>"><?= t('cancel') ?></a>
+ <?= Helper\a(t('cancel'), 'task', 'show', array('task_id' => $task['id'])) ?>
</div>
</form>
diff --git a/app/Template/subtask_remove.php b/app/Template/subtask/remove.php
index 12c99cf1..74245a7a 100644
--- a/app/Template/subtask_remove.php
+++ b/app/Template/subtask/remove.php
@@ -10,7 +10,8 @@
<p><strong><?= Helper\escape($subtask['title']) ?></strong></p>
<div class="form-actions">
- <a href="?controller=subtask&amp;action=remove&amp;task_id=<?= $task['id'] ?>&amp;subtask_id=<?= $subtask['id'].Helper\param_csrf() ?>" class="btn btn-red"><?= t('Yes') ?></a>
- <?= t('or') ?> <a href="?controller=task&amp;action=show&amp;task_id=<?= $task['id'] ?>#subtasks"><?= t('cancel') ?></a>
+ <?= 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> \ No newline at end of file
diff --git a/app/Template/subtask_show.php b/app/Template/subtask/show.php
index 686b160e..686b160e 100644
--- a/app/Template/subtask_show.php
+++ b/app/Template/subtask/show.php
diff --git a/app/Template/task_show.php b/app/Template/task_show.php
index a4b49cef..d1264d2e 100644
--- a/app/Template/task_show.php
+++ b/app/Template/task_show.php
@@ -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)) ?> \ No newline at end of file
diff --git a/assets/css/app.css b/assets/css/app.css
index b71626da..7c42433f 100644
--- a/assets/css/app.css
+++ b/assets/css/app.css
@@ -254,6 +254,7 @@ textarea.form-error {
input.form-error:focus,
textarea.form-error:focus {
box-shadow: none;
+ border: 2px solid #b94a48;
}
.form-required {
diff --git a/assets/css/form.css b/assets/css/form.css
index 34bc099d..125223e2 100644
--- a/assets/css/form.css
+++ b/assets/css/form.css
@@ -87,6 +87,7 @@ textarea.form-error {
input.form-error:focus,
textarea.form-error:focus {
box-shadow: none;
+ border: 2px solid #b94a48;
}
.form-required {
diff --git a/jsonrpc.php b/jsonrpc.php
index 8890bea0..e9a50b35 100644
--- a/jsonrpc.php
+++ b/jsonrpc.php
@@ -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);
});