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 @@
+ = t('Do you really want to remove this sub-task?') ?> +
+ += Helper\escape($subtask['title']) ?>
+ +- = t('Do you really want to remove this sub-task?') ?> -
- -= Helper\escape($subtask['title']) ?>
- -