From 20b60bc628a7c28cb7780e06073df68a821adc19 Mon Sep 17 00:00:00 2001 From: Frédéric Guillot Date: Wed, 26 Nov 2014 21:04:46 -0500 Subject: Move subtask templates to a subfolder --- app/Controller/Subtask.php | 40 ++++++++++--------------- app/Model/SubTask.php | 23 +++++++++++++++ app/Template/subtask/create.php | 27 +++++++++++++++++ app/Template/subtask/edit.php | 32 ++++++++++++++++++++ app/Template/subtask/remove.php | 17 +++++++++++ app/Template/subtask/show.php | 65 +++++++++++++++++++++++++++++++++++++++++ app/Template/subtask_create.php | 27 ----------------- app/Template/subtask_edit.php | 32 -------------------- app/Template/subtask_remove.php | 16 ---------- app/Template/subtask_show.php | 65 ----------------------------------------- app/Template/task_show.php | 2 +- assets/css/app.css | 1 + assets/css/form.css | 1 + jsonrpc.php | 2 +- 14 files changed, 184 insertions(+), 166 deletions(-) create mode 100644 app/Template/subtask/create.php create mode 100644 app/Template/subtask/edit.php create mode 100644 app/Template/subtask/remove.php create mode 100644 app/Template/subtask/show.php delete mode 100644 app/Template/subtask_create.php delete mode 100644 app/Template/subtask_edit.php delete mode 100644 app/Template/subtask_remove.php delete mode 100644 app/Template/subtask_show.php 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 @@ -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 new file mode 100644 index 00000000..40a6da3d --- /dev/null +++ b/app/Template/subtask/create.php @@ -0,0 +1,27 @@ + + +
+ + + + + + +
+ + +
+ + +
+ + + +
+ + + $task['id'])) ?> +
+
diff --git a/app/Template/subtask/edit.php b/app/Template/subtask/edit.php new file mode 100644 index 00000000..88ea6175 --- /dev/null +++ b/app/Template/subtask/edit.php @@ -0,0 +1,32 @@ + + +
+ + + + + + + +
+ + +
+ + +
+ + +
+ + +
+ +
+ + + $task['id'])) ?> +
+
diff --git a/app/Template/subtask/remove.php b/app/Template/subtask/remove.php new file mode 100644 index 00000000..74245a7a --- /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 new file mode 100644 index 00000000..686b160e --- /dev/null +++ b/app/Template/subtask/show.php @@ -0,0 +1,65 @@ + +
+ + + + + + + + + + + + + + + + + + + + + + + + +
+ $subtask)) ?> + + + $task['id'], 'subtask_id' => $subtask['id'])) ?> + + + + + + + + + + + + + + + + + $task['id'], 'subtask_id' => $subtask['id'])) ?> + + $task['id'], 'subtask_id' => $subtask['id'])) ?> +
+ + +
+ + $task['id'])) ?> + + +
+ + +
+ diff --git a/app/Template/subtask_create.php b/app/Template/subtask_create.php deleted file mode 100644 index c8ee556b..00000000 --- a/app/Template/subtask_create.php +++ /dev/null @@ -1,27 +0,0 @@ - - -
- - - - - - -
- - -
- - -
- - - -
- - - -
-
diff --git a/app/Template/subtask_edit.php b/app/Template/subtask_edit.php deleted file mode 100644 index 91690d0a..00000000 --- a/app/Template/subtask_edit.php +++ /dev/null @@ -1,32 +0,0 @@ - - -
- - - - - - - -
- - -
- - -
- - -
- - -
- -
- - - -
-
diff --git a/app/Template/subtask_remove.php b/app/Template/subtask_remove.php deleted file mode 100644 index 12c99cf1..00000000 --- a/app/Template/subtask_remove.php +++ /dev/null @@ -1,16 +0,0 @@ - - -
-

- -

- -

- -
- - -
-
\ No newline at end of file diff --git a/app/Template/subtask_show.php b/app/Template/subtask_show.php deleted file mode 100644 index 686b160e..00000000 --- a/app/Template/subtask_show.php +++ /dev/null @@ -1,65 +0,0 @@ - -
- - - - - - - - - - - - - - - - - - - - - - - - -
- $subtask)) ?> - - - $task['id'], 'subtask_id' => $subtask['id'])) ?> - - - - - - - - - - - - - - - - - $task['id'], 'subtask_id' => $subtask['id'])) ?> - - $task['id'], 'subtask_id' => $subtask['id'])) ?> -
- - -
- - $task['id'])) ?> - - -
- - -
- 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 @@ $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 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); }); -- cgit v1.2.3