diff --git a/app/Controller/Task.php b/app/Controller/Task.php index 28db5c288..fc7103ef7 100644 --- a/app/Controller/Task.php +++ b/app/Controller/Task.php @@ -160,23 +160,25 @@ class Task extends Base } $task['score'] = $task['score'] ?: ''; + $ajax = $this->request->isAjax(); $params = array( - 'values' => $task, - 'errors' => array(), - 'task' => $task, - 'users_list' => $this->projectPermission->getUsersList($task['project_id']), - 'colors_list' => $this->color->getList(), - 'categories_list' => $this->category->getList($task['project_id']), - 'ajax' => $this->request->isAjax(), - 'menu' => 'tasks', - 'title' => t('Edit a task') - ); - if ($this->request->isAjax()) { + 'values' => $task, + 'errors' => array(), + 'task' => $task, + 'users_list' => $this->projectPermission->getUsersList($task['project_id']), + 'colors_list' => $this->color->getList(), + 'categories_list' => $this->category->getList($task['project_id']), + 'ajax' => $ajax, + 'menu' => 'tasks', + 'title' => t('Edit a task') + ); + + if ($ajax) { $this->response->html($this->template->load('task_edit', $params)); } 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, 'errors' => $errors, 'task' => $task, @@ -218,7 +220,8 @@ class Task extends Base 'colors_list' => $this->color->getList(), 'categories_list' => $this->category->getList($values['project_id']), 'menu' => 'tasks', - 'title' => t('Edit a task') + 'title' => t('Edit a task'), + 'ajax' => $this->request->isAjax(), ))); } diff --git a/app/Core/Listener.php b/app/Core/Listener.php index 0df641ba6..9c96cd572 100644 --- a/app/Core/Listener.php +++ b/app/Core/Listener.php @@ -8,8 +8,8 @@ namespace Core; * @package core * @author Frederic Guillot */ -interface Listener { - +interface Listener +{ /** * Execute the listener * diff --git a/app/Model/TaskValidator.php b/app/Model/TaskValidator.php index 461c03d40..1c7b0b14e 100644 --- a/app/Model/TaskValidator.php +++ b/app/Model/TaskValidator.php @@ -79,13 +79,35 @@ class TaskValidator extends Base } /** - * Validate task modification + * Validate task modification (form) * * @access public * @param array $values Form values * @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 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( new Validators\Required('id', t('The id is required')), diff --git a/app/Templates/task_edit.php b/app/Templates/task_edit.php index 83a4ca17d..4038717ec 100644 --- a/app/Templates/task_edit.php +++ b/app/Templates/task_edit.php @@ -1,58 +1,51 @@ -
-