diff options
author | Frédéric Guillot <contact@fredericguillot.com> | 2014-02-23 21:20:25 -0500 |
---|---|---|
committer | Frédéric Guillot <contact@fredericguillot.com> | 2014-02-23 21:20:25 -0500 |
commit | 4b7a72e931a52753855c8993c65ec8a017555f72 (patch) | |
tree | 20dfc9e82dc3f2026bc14e9538a5df668ffec201 | |
parent | 50051e776f9183471570f2688d0a85f92b309a3c (diff) |
Add the possibility to change the assignee directly from the board
-rw-r--r-- | controllers/board.php | 35 | ||||
-rw-r--r-- | locales/fr_FR/translations.php | 18 | ||||
-rw-r--r-- | locales/pl_PL/translations.php | 2 | ||||
-rw-r--r-- | models/task.php | 17 | ||||
-rw-r--r-- | templates/board_assign.php | 35 | ||||
-rw-r--r-- | templates/board_index.php | 4 |
6 files changed, 101 insertions, 10 deletions
diff --git a/controllers/board.php b/controllers/board.php index e8b161e7..832ab60f 100644 --- a/controllers/board.php +++ b/controllers/board.php @@ -4,6 +4,41 @@ namespace Controller; class Board extends Base { + // Change a task assignee directly from the board + public function assign() + { + $task = $this->task->getById($this->request->getIntegerParam('task_id')); + $project = $this->project->get($task['project_id']); + $projects = $this->project->getListByStatus(\Model\Project::ACTIVE); + + $this->response->html($this->template->layout('board_assign', array( + 'errors' => array(), + 'values' => $task, + 'users_list' => $this->user->getList(), + 'projects' => $projects, + 'current_project_id' => $project['id'], + 'current_project_name' => $project['name'], + 'menu' => 'boards', + 'title' => t('Change assignee').' - '.$task['title'], + ))); + } + + // Validate an assignee change + public function assignTask() + { + $values = $this->request->getValues(); + list($valid,) = $this->task->validateAssigneeModification($values); + + if ($valid && $this->task->update($values)) { + $this->session->flash(t('Task updated successfully.')); + } + else { + $this->session->flashError(t('Unable to update your task.')); + } + + $this->response->redirect('?controller=board&action=show&project_id='.$values['project_id']); + } + // Display the public version of a board // Access checked by a simple token, no user login, read only, auto-refresh public function readonly() diff --git a/locales/fr_FR/translations.php b/locales/fr_FR/translations.php index 4e38e052..1e9f1148 100644 --- a/locales/fr_FR/translations.php +++ b/locales/fr_FR/translations.php @@ -27,7 +27,7 @@ return array( 'Unassigned' => 'Non assigné', 'View this task' => 'Visualiser cette tâche', 'Remove user' => 'Supprimer un utilisateur', - 'Do you really want to remove this user: "%s"?' => 'Voulez-vous vraiment supprimer cet utilisateur : "%s" ?', + 'Do you really want to remove this user: "%s"?' => 'Voulez-vous vraiment supprimer cet utilisateur : « %s » ?', 'New user' => 'Ajouter un utilisateur', 'All users' => 'Tous les utilisateurs', 'Username' => 'Nom d\'utilisateur', @@ -65,22 +65,22 @@ return array( 'Disable' => 'Désactiver', 'Enable' => 'Activer', 'New project' => 'Nouveau projet', - 'Do you really want to remove this project: "%s"?' => 'Voulez-vous vraiment supprimer ce projet : "%s" ?', + 'Do you really want to remove this project: "%s"?' => 'Voulez-vous vraiment supprimer ce projet : « %s » ?', 'Remove project' => 'Supprimer le projet', 'boards' => 'tableaux', - 'Edit the board for "%s"' => 'Modifier le tableau pour "%s"', + 'Edit the board for "%s"' => 'Modifier le tableau pour « %s »', 'All projects' => 'Tous les projets', 'Change columns' => 'Changer les colonnes', 'Add a new column' => 'Ajouter une nouvelle colonne', 'Title' => 'Titre', 'Add Column' => 'Nouvelle colonne', - 'Project "%s"' => 'Projet "%s"', + 'Project "%s"' => 'Projet « %s »', 'No body assigned' => 'Personne assigné', 'Assigned to %s' => 'Assigné à %s', 'Remove a column' => 'Supprimer une colonne', 'Remove a column from a board' => 'Supprimer une colonne d\'un tableau', 'Unable to remove this column.' => 'Impossible de supprimer cette colonne.', - 'Do you really want to remove this column: "%s"?' => 'Voulez vraiment supprimer cette colonne : "%s" ?', + 'Do you really want to remove this column: "%s"?' => 'Voulez vraiment supprimer cette colonne : « %s » ?', 'This action will REMOVE ALL TASKS associated to this column!' => 'Cette action va supprimer toutes les tâches associées à cette colonne !', 'settings' => 'préférences', 'Application Settings' => 'Paramètres de l\'application', @@ -95,7 +95,7 @@ return array( 'User Settings' => 'Paramètres utilisateur', 'My default project:' => 'Mon projet par défaut : ', 'Close a task' => 'Fermer une tâche', - 'Do you really want to close this task: "%s"?' => 'Voulez-vous vraiment fermer cettre tâche : "%s" ?', + 'Do you really want to close this task: "%s"?' => 'Voulez-vous vraiment fermer cettre tâche : « %s » ?', 'Edit a task' => 'Modifier une tâche', 'Column' => 'Colonne', 'Color' => 'Couleur', @@ -103,7 +103,7 @@ return array( 'Create another task' => 'Créer une autre tâche', 'New task' => 'Nouvelle tâche', 'Open a task' => 'Ouvrir une tâche', - 'Do you really want to open this task: "%s"?' => 'Voulez-vous vraiment ouvrir cette tâche : "%s" ?', + 'Do you really want to open this task: "%s"?' => 'Voulez-vous vraiment ouvrir cette tâche : « %s » ?', 'Back to the board' => 'Retour au tableau', 'Created on %B %e, %G at %k:%M %p' => 'Créé le %e %B %G à %k:%M', 'There is no body assigned' => 'Il n\'y a personne d\'assigné à cette tâche', @@ -176,9 +176,11 @@ return array( 'No task' => 'Aucune tâche', 'completed tasks' => 'tâches terminées', 'List of projects' => 'Liste des projets', - 'Completed tasks for "%s"' => 'Tâches terminées pour "%s"', + 'Completed tasks for "%s"' => 'Tâches terminées pour « %s »', '%d closed tasks' => '%d tâches terminées', 'no task for this project' => 'aucune tâche pour ce projet', 'Public link' => 'Accès public', 'There is no column in your project!' => 'Il n\'y a aucune colonne dans votre projet !', + 'Change assignee' => 'Changer la personne assignée', + 'Change assignee for the task "%s"' => 'Changer la personne assignée pour la tâche « %s »', ); diff --git a/locales/pl_PL/translations.php b/locales/pl_PL/translations.php index b1ecd1ed..bbbcd4d5 100644 --- a/locales/pl_PL/translations.php +++ b/locales/pl_PL/translations.php @@ -183,5 +183,7 @@ return array( /* Missing translations: 'There is no column in your project!' => '', + 'Change assignee' => '', + 'Change assignee for the task "%s"' => '', */ ); diff --git a/models/task.php b/models/task.php index 9d23baf0..e227cc95 100644 --- a/models/task.php +++ b/models/task.php @@ -209,4 +209,21 @@ class Task extends Base $v->getErrors() ); } + + public function validateAssigneeModification(array $values) + { + $v = new Validator($values, array( + new Validators\Required('id', t('The id is required')), + new Validators\Integer('id', t('This value must be an integer')), + new Validators\Required('project_id', t('The project is required')), + new Validators\Integer('project_id', t('This value must be an integer')), + new Validators\Required('owner_id', t('This value is required')), + new Validators\Integer('owner_id', t('This value must be an integer')), + )); + + return array( + $v->execute(), + $v->getErrors() + ); + } } diff --git a/templates/board_assign.php b/templates/board_assign.php new file mode 100644 index 00000000..74448a5c --- /dev/null +++ b/templates/board_assign.php @@ -0,0 +1,35 @@ +<section id="main"> + + <div class="page-header board"> + <h2> + <?= t('Project "%s"', $current_project_name) ?> + </h2> + <ul> + <?php foreach ($projects as $project_id => $project_name): ?> + <?php if ($project_id != $current_project_id): ?> + <li> + <a href="?controller=board&action=show&project_id=<?= $project_id ?>"><?= Helper\escape($project_name) ?></a> + </li> + <?php endif ?> + <?php endforeach ?> + </ul> + </div> + + <section> + <h3><?= t('Change assignee for the task "%s"', $values['title']) ?></h3> + <form method="post" action="?controller=board&action=assignTask" autocomplete="off"> + + <?= Helper\form_hidden('id', $values) ?> + <?= Helper\form_hidden('project_id', $values) ?> + + <?= Helper\form_label(t('Assignee'), 'owner_id') ?> + <?= Helper\form_select('owner_id', $users_list, $values, $errors) ?><br/> + + <div class="form-actions"> + <input type="submit" value="<?= t('Save') ?>" class="btn btn-blue"/> + <?= t('or') ?> <a href="?controller=board&action=show&project_id=<?= $values['project_id'] ?>"><?= t('cancel') ?></a> + </div> + </form> + </section> + +</div>
\ No newline at end of file diff --git a/templates/board_index.php b/templates/board_index.php index 274e8227..ff10a70b 100644 --- a/templates/board_index.php +++ b/templates/board_index.php @@ -46,9 +46,9 @@ <span class="task-user"> <?php if (! empty($task['owner_id'])): ?> - <?= t('Assigned to %s', $task['username']) ?> + <a href="?controller=board&action=assign&task_id=<?= $task['id'] ?>" title="<?= t('Change assignee') ?>"><?= t('Assigned to %s', $task['username']) ?></a> <?php else: ?> - <span class="task-nobody"><?= t('No body assigned') ?></span> + <a href="?controller=board&action=assign&task_id=<?= $task['id'] ?>" title="<?= t('Change assignee') ?>" class="task-nobody"><?= t('No body assigned') ?></a> <?php endif ?> </span> |