diff --git a/app/Controller/Subtask.php b/app/Controller/Subtask.php index e48e77676..948f3c769 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 1faad6808..f301ad620 100644 --- a/app/Model/SubTask.php +++ b/app/Model/SubTask.php @@ -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')), diff --git a/app/Template/subtask_create.php b/app/Template/subtask/create.php similarity index 80% rename from app/Template/subtask_create.php rename to app/Template/subtask/create.php index c8ee556bb..40a6da3d5 100644 --- a/app/Template/subtask_create.php +++ b/app/Template/subtask/create.php @@ -2,7 +2,7 @@

-
+ @@ -22,6 +22,6 @@
- + $task['id'])) ?>
diff --git a/app/Template/subtask_edit.php b/app/Template/subtask/edit.php similarity index 80% rename from app/Template/subtask_edit.php rename to app/Template/subtask/edit.php index 91690d0a7..88ea6175f 100644 --- a/app/Template/subtask_edit.php +++ b/app/Template/subtask/edit.php @@ -2,7 +2,7 @@

-
+ @@ -27,6 +27,6 @@
- + $task['id'])) ?>
diff --git a/app/Template/subtask/remove.php b/app/Template/subtask/remove.php new file mode 100644 index 000000000..74245a7a3 --- /dev/null +++ b/app/Template/subtask/remove.php @@ -0,0 +1,17 @@ + + +
+

+ +

+ +

+ +
+ $task['id'], 'subtask_id' => $subtask['id']), true, 'btn btn-red') ?> + + $task['id'])) ?> +
+
\ No newline at end of file diff --git a/app/Template/subtask_show.php b/app/Template/subtask/show.php similarity index 100% rename from app/Template/subtask_show.php rename to app/Template/subtask/show.php diff --git a/app/Template/subtask_remove.php b/app/Template/subtask_remove.php deleted file mode 100644 index 12c99cf1b..000000000 --- a/app/Template/subtask_remove.php +++ /dev/null @@ -1,16 +0,0 @@ - - -
-

- -

- -

- -
- - -
-
\ No newline at end of file diff --git a/app/Template/task_show.php b/app/Template/task_show.php index a4b49cefe..d1264d2e7 100644 --- a/app/Template/task_show.php +++ b/app/Template/task_show.php @@ -1,7 +1,7 @@ $task, 'project' => $project)) ?> $values, 'date_format' => $date_format, 'date_formats' => $date_formats)) ?> $task)) ?> - $task, 'subtasks' => $subtasks)) ?> + $task, 'subtasks' => $subtasks)) ?> $timesheet)) ?> $task, 'files' => $files)) ?> $task, 'comments' => $comments, 'project' => $project)) ?> \ No newline at end of file diff --git a/assets/css/app.css b/assets/css/app.css index b71626da3..7c42433f2 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 34bc099d1..125223e21 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 8890bea01..e9a50b35f 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); });