From 029538846181309e9135a17f893e874b2e90f72b Mon Sep 17 00:00:00 2001 From: Frédéric Guillot Date: Fri, 8 Feb 2019 13:53:13 -0800 Subject: Add new actions to reorder tasks by column --- app/Controller/TaskReorderController.php | 36 ++++++++++++++++ app/Core/Base.php | 1 + app/Locale/bs_BA/translations.php | 6 +++ app/Locale/ca_ES/translations.php | 6 +++ app/Locale/cs_CZ/translations.php | 6 +++ app/Locale/da_DK/translations.php | 6 +++ app/Locale/de_DE/translations.php | 6 +++ app/Locale/el_GR/translations.php | 6 +++ app/Locale/es_ES/translations.php | 6 +++ app/Locale/fi_FI/translations.php | 6 +++ app/Locale/fr_FR/translations.php | 6 +++ app/Locale/hr_HR/translations.php | 6 +++ app/Locale/hu_HU/translations.php | 6 +++ app/Locale/id_ID/translations.php | 6 +++ app/Locale/it_IT/translations.php | 6 +++ app/Locale/ja_JP/translations.php | 6 +++ app/Locale/ko_KR/translations.php | 6 +++ app/Locale/my_MY/translations.php | 6 +++ app/Locale/nb_NO/translations.php | 6 +++ app/Locale/nl_NL/translations.php | 6 +++ app/Locale/pl_PL/translations.php | 6 +++ app/Locale/pt_BR/translations.php | 6 +++ app/Locale/pt_PT/translations.php | 6 +++ app/Locale/ro_RO/translations.php | 6 +++ app/Locale/ru_RU/translations.php | 6 +++ app/Locale/sr_Latn_RS/translations.php | 6 +++ app/Locale/sv_SE/translations.php | 6 +++ app/Locale/th_TH/translations.php | 6 +++ app/Locale/tr_TR/translations.php | 6 +++ app/Locale/uk_UA/translations.php | 6 +++ app/Locale/vi_VN/translations.php | 6 +++ app/Locale/zh_CN/translations.php | 6 +++ app/Locale/zh_TW/translations.php | 6 +++ app/Model/TaskReorderModel.php | 74 ++++++++++++++++++++++++++++++++ app/ServiceProvider/ClassProvider.php | 1 + app/Template/board/table_column.php | 23 +++++++++- 36 files changed, 320 insertions(+), 1 deletion(-) create mode 100644 app/Controller/TaskReorderController.php create mode 100644 app/Model/TaskReorderModel.php (limited to 'app') diff --git a/app/Controller/TaskReorderController.php b/app/Controller/TaskReorderController.php new file mode 100644 index 00000000..32bdfc52 --- /dev/null +++ b/app/Controller/TaskReorderController.php @@ -0,0 +1,36 @@ +getProject(); + + if (! $this->helper->user->hasProjectAccess('TaskModificationController', 'update', $project['id'])) { + throw new AccessForbiddenException(); + } + + $swimlaneID = $this->request->getIntegerParam('swimlane_id'); + $columnID = $this->request->getIntegerParam('column_id'); + $direction = $this->request->getStringParam('direction'); + $sort = $this->request->getStringParam('sort'); + + switch ($sort) { + case 'priority': + $this->taskReorderModel->reorderByPriority($project['id'], $swimlaneID, $columnID, $direction); + break; + case 'assignee-priority': + $this->taskReorderModel->reorderByAssigneeAndPriority($project['id'], $swimlaneID, $columnID, $direction); + break; + case 'assignee': + $this->taskReorderModel->reorderByAssignee($project['id'], $swimlaneID, $columnID, $direction); + break; + } + + $this->response->redirect($this->helper->url->to('BoardViewController', 'show', ['project_id' => $project['id']])); + } +} diff --git a/app/Core/Base.php b/app/Core/Base.php index 709327a7..3535a339 100644 --- a/app/Core/Base.php +++ b/app/Core/Base.php @@ -142,6 +142,7 @@ use Pimple\Container; * @property \Kanboard\Model\TaskLinkModel $taskLinkModel * @property \Kanboard\Model\TaskModificationModel $taskModificationModel * @property \Kanboard\Model\TaskPositionModel $taskPositionModel + * @property \Kanboard\Model\TaskReorderModel $taskReorderModel * @property \Kanboard\Model\TaskStatusModel $taskStatusModel * @property \Kanboard\Model\TaskTagModel $taskTagModel * @property \Kanboard\Model\TaskMetadataModel $taskMetadataModel diff --git a/app/Locale/bs_BA/translations.php b/app/Locale/bs_BA/translations.php index daf9d9e6..f226d027 100644 --- a/app/Locale/bs_BA/translations.php +++ b/app/Locale/bs_BA/translations.php @@ -1392,4 +1392,10 @@ return array( // 'Destination swimlane' => '', // 'Assign a category when the task is moved to a specific swimlane' => '', // 'Move the task to another swimlane when the category is changed' => '', + // 'Reorder this column by priority (ASC)' => '', + // 'Reorder this column by priority (DESC)' => '', + // 'Reorder this column by assignee and priority (ASC)' => '', + // 'Reorder this column by assignee and priority (DESC)' => '', + // 'Reorder this column by assignee (A-Z)' => '', + // 'Reorder this column by assignee (Z-A)' => '', ); diff --git a/app/Locale/ca_ES/translations.php b/app/Locale/ca_ES/translations.php index 58efe43b..60a9278d 100644 --- a/app/Locale/ca_ES/translations.php +++ b/app/Locale/ca_ES/translations.php @@ -1392,4 +1392,10 @@ return array( // 'Destination swimlane' => '', // 'Assign a category when the task is moved to a specific swimlane' => '', // 'Move the task to another swimlane when the category is changed' => '', + // 'Reorder this column by priority (ASC)' => '', + // 'Reorder this column by priority (DESC)' => '', + // 'Reorder this column by assignee and priority (ASC)' => '', + // 'Reorder this column by assignee and priority (DESC)' => '', + // 'Reorder this column by assignee (A-Z)' => '', + // 'Reorder this column by assignee (Z-A)' => '', ); diff --git a/app/Locale/cs_CZ/translations.php b/app/Locale/cs_CZ/translations.php index c885ebef..a7fa4082 100644 --- a/app/Locale/cs_CZ/translations.php +++ b/app/Locale/cs_CZ/translations.php @@ -1392,4 +1392,10 @@ return array( // 'Destination swimlane' => '', // 'Assign a category when the task is moved to a specific swimlane' => '', // 'Move the task to another swimlane when the category is changed' => '', + // 'Reorder this column by priority (ASC)' => '', + // 'Reorder this column by priority (DESC)' => '', + // 'Reorder this column by assignee and priority (ASC)' => '', + // 'Reorder this column by assignee and priority (DESC)' => '', + // 'Reorder this column by assignee (A-Z)' => '', + // 'Reorder this column by assignee (Z-A)' => '', ); diff --git a/app/Locale/da_DK/translations.php b/app/Locale/da_DK/translations.php index 2add59da..e404ed77 100644 --- a/app/Locale/da_DK/translations.php +++ b/app/Locale/da_DK/translations.php @@ -1392,4 +1392,10 @@ return array( 'Destination swimlane' => 'Mål spor', 'Assign a category when the task is moved to a specific swimlane' => 'Tildele kategori når opgave flyttes til anført spor', 'Move the task to another swimlane when the category is changed' => 'Flytte opgave til andet spor når kategori ændres', + // 'Reorder this column by priority (ASC)' => '', + // 'Reorder this column by priority (DESC)' => '', + // 'Reorder this column by assignee and priority (ASC)' => '', + // 'Reorder this column by assignee and priority (DESC)' => '', + // 'Reorder this column by assignee (A-Z)' => '', + // 'Reorder this column by assignee (Z-A)' => '', ); diff --git a/app/Locale/de_DE/translations.php b/app/Locale/de_DE/translations.php index 9805019d..d716cfc9 100644 --- a/app/Locale/de_DE/translations.php +++ b/app/Locale/de_DE/translations.php @@ -1392,4 +1392,10 @@ return array( // 'Destination swimlane' => '', // 'Assign a category when the task is moved to a specific swimlane' => '', // 'Move the task to another swimlane when the category is changed' => '', + // 'Reorder this column by priority (ASC)' => '', + // 'Reorder this column by priority (DESC)' => '', + // 'Reorder this column by assignee and priority (ASC)' => '', + // 'Reorder this column by assignee and priority (DESC)' => '', + // 'Reorder this column by assignee (A-Z)' => '', + // 'Reorder this column by assignee (Z-A)' => '', ); diff --git a/app/Locale/el_GR/translations.php b/app/Locale/el_GR/translations.php index 12cb44b3..73d0a74e 100644 --- a/app/Locale/el_GR/translations.php +++ b/app/Locale/el_GR/translations.php @@ -1392,4 +1392,10 @@ return array( // 'Destination swimlane' => '', // 'Assign a category when the task is moved to a specific swimlane' => '', // 'Move the task to another swimlane when the category is changed' => '', + // 'Reorder this column by priority (ASC)' => '', + // 'Reorder this column by priority (DESC)' => '', + // 'Reorder this column by assignee and priority (ASC)' => '', + // 'Reorder this column by assignee and priority (DESC)' => '', + // 'Reorder this column by assignee (A-Z)' => '', + // 'Reorder this column by assignee (Z-A)' => '', ); diff --git a/app/Locale/es_ES/translations.php b/app/Locale/es_ES/translations.php index 56317bc4..275960ec 100644 --- a/app/Locale/es_ES/translations.php +++ b/app/Locale/es_ES/translations.php @@ -1392,4 +1392,10 @@ return array( // 'Destination swimlane' => '', // 'Assign a category when the task is moved to a specific swimlane' => '', // 'Move the task to another swimlane when the category is changed' => '', + // 'Reorder this column by priority (ASC)' => '', + // 'Reorder this column by priority (DESC)' => '', + // 'Reorder this column by assignee and priority (ASC)' => '', + // 'Reorder this column by assignee and priority (DESC)' => '', + // 'Reorder this column by assignee (A-Z)' => '', + // 'Reorder this column by assignee (Z-A)' => '', ); diff --git a/app/Locale/fi_FI/translations.php b/app/Locale/fi_FI/translations.php index 02e58f06..aa675269 100644 --- a/app/Locale/fi_FI/translations.php +++ b/app/Locale/fi_FI/translations.php @@ -1392,4 +1392,10 @@ return array( // 'Destination swimlane' => '', // 'Assign a category when the task is moved to a specific swimlane' => '', // 'Move the task to another swimlane when the category is changed' => '', + // 'Reorder this column by priority (ASC)' => '', + // 'Reorder this column by priority (DESC)' => '', + // 'Reorder this column by assignee and priority (ASC)' => '', + // 'Reorder this column by assignee and priority (DESC)' => '', + // 'Reorder this column by assignee (A-Z)' => '', + // 'Reorder this column by assignee (Z-A)' => '', ); diff --git a/app/Locale/fr_FR/translations.php b/app/Locale/fr_FR/translations.php index 73db8364..1df707c8 100644 --- a/app/Locale/fr_FR/translations.php +++ b/app/Locale/fr_FR/translations.php @@ -1392,4 +1392,10 @@ return array( 'Destination swimlane' => 'Swimlane de destination', 'Assign a category when the task is moved to a specific swimlane' => 'Assigner une catégorie lorsque la tâche est déplaçée dans une swimlane spécifique', 'Move the task to another swimlane when the category is changed' => 'Déplaçer la tâche dans une autre swimlane lorsque la catégorie est modifiée', + 'Reorder this column by priority (ASC)' => 'Réorganiser cette colonne par priorité (ASC)', + 'Reorder this column by priority (DESC)' => 'Réorganiser cette colonne par priorité (DESC)', + 'Reorder this column by assignee and priority (ASC)' => 'Réorganiser cette colonne par assigné et par priorité (ASC)', + 'Reorder this column by assignee and priority (DESC)' => 'Réorganiser cette colonne par assigné et par priorité (DESC)', + 'Reorder this column by assignee (A-Z)' => 'Réorganiser cette colonne par assigné (A-Z)', + 'Reorder this column by assignee (Z-A)' => 'Réorganiser cette colonne par assigné (Z-A)', ); diff --git a/app/Locale/hr_HR/translations.php b/app/Locale/hr_HR/translations.php index 72739963..f6cf08c4 100644 --- a/app/Locale/hr_HR/translations.php +++ b/app/Locale/hr_HR/translations.php @@ -1392,4 +1392,10 @@ return array( // 'Destination swimlane' => '', // 'Assign a category when the task is moved to a specific swimlane' => '', // 'Move the task to another swimlane when the category is changed' => '', + // 'Reorder this column by priority (ASC)' => '', + // 'Reorder this column by priority (DESC)' => '', + // 'Reorder this column by assignee and priority (ASC)' => '', + // 'Reorder this column by assignee and priority (DESC)' => '', + // 'Reorder this column by assignee (A-Z)' => '', + // 'Reorder this column by assignee (Z-A)' => '', ); diff --git a/app/Locale/hu_HU/translations.php b/app/Locale/hu_HU/translations.php index 5b689f9f..550c50f5 100644 --- a/app/Locale/hu_HU/translations.php +++ b/app/Locale/hu_HU/translations.php @@ -1392,4 +1392,10 @@ return array( // 'Destination swimlane' => '', // 'Assign a category when the task is moved to a specific swimlane' => '', // 'Move the task to another swimlane when the category is changed' => '', + // 'Reorder this column by priority (ASC)' => '', + // 'Reorder this column by priority (DESC)' => '', + // 'Reorder this column by assignee and priority (ASC)' => '', + // 'Reorder this column by assignee and priority (DESC)' => '', + // 'Reorder this column by assignee (A-Z)' => '', + // 'Reorder this column by assignee (Z-A)' => '', ); diff --git a/app/Locale/id_ID/translations.php b/app/Locale/id_ID/translations.php index 07937a75..fd1ce47a 100644 --- a/app/Locale/id_ID/translations.php +++ b/app/Locale/id_ID/translations.php @@ -1392,4 +1392,10 @@ return array( // 'Destination swimlane' => '', // 'Assign a category when the task is moved to a specific swimlane' => '', // 'Move the task to another swimlane when the category is changed' => '', + // 'Reorder this column by priority (ASC)' => '', + // 'Reorder this column by priority (DESC)' => '', + // 'Reorder this column by assignee and priority (ASC)' => '', + // 'Reorder this column by assignee and priority (DESC)' => '', + // 'Reorder this column by assignee (A-Z)' => '', + // 'Reorder this column by assignee (Z-A)' => '', ); diff --git a/app/Locale/it_IT/translations.php b/app/Locale/it_IT/translations.php index 32c547bd..b6d723f0 100644 --- a/app/Locale/it_IT/translations.php +++ b/app/Locale/it_IT/translations.php @@ -1392,4 +1392,10 @@ return array( // 'Destination swimlane' => '', // 'Assign a category when the task is moved to a specific swimlane' => '', // 'Move the task to another swimlane when the category is changed' => '', + // 'Reorder this column by priority (ASC)' => '', + // 'Reorder this column by priority (DESC)' => '', + // 'Reorder this column by assignee and priority (ASC)' => '', + // 'Reorder this column by assignee and priority (DESC)' => '', + // 'Reorder this column by assignee (A-Z)' => '', + // 'Reorder this column by assignee (Z-A)' => '', ); diff --git a/app/Locale/ja_JP/translations.php b/app/Locale/ja_JP/translations.php index 5add2476..9cd3495d 100644 --- a/app/Locale/ja_JP/translations.php +++ b/app/Locale/ja_JP/translations.php @@ -1392,4 +1392,10 @@ return array( // 'Destination swimlane' => '', // 'Assign a category when the task is moved to a specific swimlane' => '', // 'Move the task to another swimlane when the category is changed' => '', + // 'Reorder this column by priority (ASC)' => '', + // 'Reorder this column by priority (DESC)' => '', + // 'Reorder this column by assignee and priority (ASC)' => '', + // 'Reorder this column by assignee and priority (DESC)' => '', + // 'Reorder this column by assignee (A-Z)' => '', + // 'Reorder this column by assignee (Z-A)' => '', ); diff --git a/app/Locale/ko_KR/translations.php b/app/Locale/ko_KR/translations.php index fc172513..a57f6c2f 100644 --- a/app/Locale/ko_KR/translations.php +++ b/app/Locale/ko_KR/translations.php @@ -1392,4 +1392,10 @@ return array( // 'Destination swimlane' => '', // 'Assign a category when the task is moved to a specific swimlane' => '', // 'Move the task to another swimlane when the category is changed' => '', + // 'Reorder this column by priority (ASC)' => '', + // 'Reorder this column by priority (DESC)' => '', + // 'Reorder this column by assignee and priority (ASC)' => '', + // 'Reorder this column by assignee and priority (DESC)' => '', + // 'Reorder this column by assignee (A-Z)' => '', + // 'Reorder this column by assignee (Z-A)' => '', ); diff --git a/app/Locale/my_MY/translations.php b/app/Locale/my_MY/translations.php index 68eb82e0..2b6b5669 100644 --- a/app/Locale/my_MY/translations.php +++ b/app/Locale/my_MY/translations.php @@ -1392,4 +1392,10 @@ return array( // 'Destination swimlane' => '', // 'Assign a category when the task is moved to a specific swimlane' => '', // 'Move the task to another swimlane when the category is changed' => '', + // 'Reorder this column by priority (ASC)' => '', + // 'Reorder this column by priority (DESC)' => '', + // 'Reorder this column by assignee and priority (ASC)' => '', + // 'Reorder this column by assignee and priority (DESC)' => '', + // 'Reorder this column by assignee (A-Z)' => '', + // 'Reorder this column by assignee (Z-A)' => '', ); diff --git a/app/Locale/nb_NO/translations.php b/app/Locale/nb_NO/translations.php index e063b993..9bda0ae1 100644 --- a/app/Locale/nb_NO/translations.php +++ b/app/Locale/nb_NO/translations.php @@ -1392,4 +1392,10 @@ return array( // 'Destination swimlane' => '', // 'Assign a category when the task is moved to a specific swimlane' => '', // 'Move the task to another swimlane when the category is changed' => '', + // 'Reorder this column by priority (ASC)' => '', + // 'Reorder this column by priority (DESC)' => '', + // 'Reorder this column by assignee and priority (ASC)' => '', + // 'Reorder this column by assignee and priority (DESC)' => '', + // 'Reorder this column by assignee (A-Z)' => '', + // 'Reorder this column by assignee (Z-A)' => '', ); diff --git a/app/Locale/nl_NL/translations.php b/app/Locale/nl_NL/translations.php index c6802dec..d32e6d90 100644 --- a/app/Locale/nl_NL/translations.php +++ b/app/Locale/nl_NL/translations.php @@ -1392,4 +1392,10 @@ return array( // 'Destination swimlane' => '', // 'Assign a category when the task is moved to a specific swimlane' => '', // 'Move the task to another swimlane when the category is changed' => '', + // 'Reorder this column by priority (ASC)' => '', + // 'Reorder this column by priority (DESC)' => '', + // 'Reorder this column by assignee and priority (ASC)' => '', + // 'Reorder this column by assignee and priority (DESC)' => '', + // 'Reorder this column by assignee (A-Z)' => '', + // 'Reorder this column by assignee (Z-A)' => '', ); diff --git a/app/Locale/pl_PL/translations.php b/app/Locale/pl_PL/translations.php index 58a1de82..4b5581fa 100644 --- a/app/Locale/pl_PL/translations.php +++ b/app/Locale/pl_PL/translations.php @@ -1392,4 +1392,10 @@ return array( // 'Destination swimlane' => '', // 'Assign a category when the task is moved to a specific swimlane' => '', // 'Move the task to another swimlane when the category is changed' => '', + // 'Reorder this column by priority (ASC)' => '', + // 'Reorder this column by priority (DESC)' => '', + // 'Reorder this column by assignee and priority (ASC)' => '', + // 'Reorder this column by assignee and priority (DESC)' => '', + // 'Reorder this column by assignee (A-Z)' => '', + // 'Reorder this column by assignee (Z-A)' => '', ); diff --git a/app/Locale/pt_BR/translations.php b/app/Locale/pt_BR/translations.php index b41e0c64..0d0b3b83 100644 --- a/app/Locale/pt_BR/translations.php +++ b/app/Locale/pt_BR/translations.php @@ -1392,4 +1392,10 @@ return array( 'Destination swimlane' => 'Raia de destino', 'Assign a category when the task is moved to a specific swimlane' => 'Atribuir uma categoria quando a tarefa for movida para uma raia específica', 'Move the task to another swimlane when the category is changed' => 'Mover a tarefa para outra raia quando a categoria é alterada', + // 'Reorder this column by priority (ASC)' => '', + // 'Reorder this column by priority (DESC)' => '', + // 'Reorder this column by assignee and priority (ASC)' => '', + // 'Reorder this column by assignee and priority (DESC)' => '', + // 'Reorder this column by assignee (A-Z)' => '', + // 'Reorder this column by assignee (Z-A)' => '', ); diff --git a/app/Locale/pt_PT/translations.php b/app/Locale/pt_PT/translations.php index ada3c81c..edbfec69 100644 --- a/app/Locale/pt_PT/translations.php +++ b/app/Locale/pt_PT/translations.php @@ -1392,4 +1392,10 @@ return array( // 'Destination swimlane' => '', // 'Assign a category when the task is moved to a specific swimlane' => '', // 'Move the task to another swimlane when the category is changed' => '', + // 'Reorder this column by priority (ASC)' => '', + // 'Reorder this column by priority (DESC)' => '', + // 'Reorder this column by assignee and priority (ASC)' => '', + // 'Reorder this column by assignee and priority (DESC)' => '', + // 'Reorder this column by assignee (A-Z)' => '', + // 'Reorder this column by assignee (Z-A)' => '', ); diff --git a/app/Locale/ro_RO/translations.php b/app/Locale/ro_RO/translations.php index 3f0f6f4f..e3d39a77 100644 --- a/app/Locale/ro_RO/translations.php +++ b/app/Locale/ro_RO/translations.php @@ -1392,4 +1392,10 @@ return array( // 'Destination swimlane' => '', // 'Assign a category when the task is moved to a specific swimlane' => '', // 'Move the task to another swimlane when the category is changed' => '', + // 'Reorder this column by priority (ASC)' => '', + // 'Reorder this column by priority (DESC)' => '', + // 'Reorder this column by assignee and priority (ASC)' => '', + // 'Reorder this column by assignee and priority (DESC)' => '', + // 'Reorder this column by assignee (A-Z)' => '', + // 'Reorder this column by assignee (Z-A)' => '', ); diff --git a/app/Locale/ru_RU/translations.php b/app/Locale/ru_RU/translations.php index 82135dc7..4dfc401e 100644 --- a/app/Locale/ru_RU/translations.php +++ b/app/Locale/ru_RU/translations.php @@ -1392,4 +1392,10 @@ return array( // 'Destination swimlane' => '', // 'Assign a category when the task is moved to a specific swimlane' => '', // 'Move the task to another swimlane when the category is changed' => '', + // 'Reorder this column by priority (ASC)' => '', + // 'Reorder this column by priority (DESC)' => '', + // 'Reorder this column by assignee and priority (ASC)' => '', + // 'Reorder this column by assignee and priority (DESC)' => '', + // 'Reorder this column by assignee (A-Z)' => '', + // 'Reorder this column by assignee (Z-A)' => '', ); diff --git a/app/Locale/sr_Latn_RS/translations.php b/app/Locale/sr_Latn_RS/translations.php index 4e501cf9..9dba713f 100644 --- a/app/Locale/sr_Latn_RS/translations.php +++ b/app/Locale/sr_Latn_RS/translations.php @@ -1392,4 +1392,10 @@ return array( // 'Destination swimlane' => '', // 'Assign a category when the task is moved to a specific swimlane' => '', // 'Move the task to another swimlane when the category is changed' => '', + // 'Reorder this column by priority (ASC)' => '', + // 'Reorder this column by priority (DESC)' => '', + // 'Reorder this column by assignee and priority (ASC)' => '', + // 'Reorder this column by assignee and priority (DESC)' => '', + // 'Reorder this column by assignee (A-Z)' => '', + // 'Reorder this column by assignee (Z-A)' => '', ); diff --git a/app/Locale/sv_SE/translations.php b/app/Locale/sv_SE/translations.php index be88f1b1..ccd72005 100644 --- a/app/Locale/sv_SE/translations.php +++ b/app/Locale/sv_SE/translations.php @@ -1392,4 +1392,10 @@ return array( // 'Destination swimlane' => '', // 'Assign a category when the task is moved to a specific swimlane' => '', // 'Move the task to another swimlane when the category is changed' => '', + // 'Reorder this column by priority (ASC)' => '', + // 'Reorder this column by priority (DESC)' => '', + // 'Reorder this column by assignee and priority (ASC)' => '', + // 'Reorder this column by assignee and priority (DESC)' => '', + // 'Reorder this column by assignee (A-Z)' => '', + // 'Reorder this column by assignee (Z-A)' => '', ); diff --git a/app/Locale/th_TH/translations.php b/app/Locale/th_TH/translations.php index 3d4c27db..3ee97493 100644 --- a/app/Locale/th_TH/translations.php +++ b/app/Locale/th_TH/translations.php @@ -1392,4 +1392,10 @@ return array( // 'Destination swimlane' => '', // 'Assign a category when the task is moved to a specific swimlane' => '', // 'Move the task to another swimlane when the category is changed' => '', + // 'Reorder this column by priority (ASC)' => '', + // 'Reorder this column by priority (DESC)' => '', + // 'Reorder this column by assignee and priority (ASC)' => '', + // 'Reorder this column by assignee and priority (DESC)' => '', + // 'Reorder this column by assignee (A-Z)' => '', + // 'Reorder this column by assignee (Z-A)' => '', ); diff --git a/app/Locale/tr_TR/translations.php b/app/Locale/tr_TR/translations.php index 3c3b1cd2..ad79c8aa 100644 --- a/app/Locale/tr_TR/translations.php +++ b/app/Locale/tr_TR/translations.php @@ -1392,4 +1392,10 @@ return array( // 'Destination swimlane' => '', // 'Assign a category when the task is moved to a specific swimlane' => '', // 'Move the task to another swimlane when the category is changed' => '', + // 'Reorder this column by priority (ASC)' => '', + // 'Reorder this column by priority (DESC)' => '', + // 'Reorder this column by assignee and priority (ASC)' => '', + // 'Reorder this column by assignee and priority (DESC)' => '', + // 'Reorder this column by assignee (A-Z)' => '', + // 'Reorder this column by assignee (Z-A)' => '', ); diff --git a/app/Locale/uk_UA/translations.php b/app/Locale/uk_UA/translations.php index dd049154..e56dc659 100644 --- a/app/Locale/uk_UA/translations.php +++ b/app/Locale/uk_UA/translations.php @@ -1392,4 +1392,10 @@ return array( // 'Destination swimlane' => '', // 'Assign a category when the task is moved to a specific swimlane' => '', // 'Move the task to another swimlane when the category is changed' => '', + // 'Reorder this column by priority (ASC)' => '', + // 'Reorder this column by priority (DESC)' => '', + // 'Reorder this column by assignee and priority (ASC)' => '', + // 'Reorder this column by assignee and priority (DESC)' => '', + // 'Reorder this column by assignee (A-Z)' => '', + // 'Reorder this column by assignee (Z-A)' => '', ); diff --git a/app/Locale/vi_VN/translations.php b/app/Locale/vi_VN/translations.php index 31e5d540..fa22254d 100644 --- a/app/Locale/vi_VN/translations.php +++ b/app/Locale/vi_VN/translations.php @@ -1392,4 +1392,10 @@ return array( // 'Destination swimlane' => '', // 'Assign a category when the task is moved to a specific swimlane' => '', // 'Move the task to another swimlane when the category is changed' => '', + // 'Reorder this column by priority (ASC)' => '', + // 'Reorder this column by priority (DESC)' => '', + // 'Reorder this column by assignee and priority (ASC)' => '', + // 'Reorder this column by assignee and priority (DESC)' => '', + // 'Reorder this column by assignee (A-Z)' => '', + // 'Reorder this column by assignee (Z-A)' => '', ); diff --git a/app/Locale/zh_CN/translations.php b/app/Locale/zh_CN/translations.php index bcea8ae3..feb7495c 100644 --- a/app/Locale/zh_CN/translations.php +++ b/app/Locale/zh_CN/translations.php @@ -1392,4 +1392,10 @@ return array( 'Destination swimlane' => '目标泳道', 'Assign a category when the task is moved to a specific swimlane' => '将移动到指定泳道的任务设定分类', 'Move the task to another swimlane when the category is changed' => '当分类改变时将任务移动到另一个泳道', + // 'Reorder this column by priority (ASC)' => '', + // 'Reorder this column by priority (DESC)' => '', + // 'Reorder this column by assignee and priority (ASC)' => '', + // 'Reorder this column by assignee and priority (DESC)' => '', + // 'Reorder this column by assignee (A-Z)' => '', + // 'Reorder this column by assignee (Z-A)' => '', ); diff --git a/app/Locale/zh_TW/translations.php b/app/Locale/zh_TW/translations.php index 5e657196..631aa026 100644 --- a/app/Locale/zh_TW/translations.php +++ b/app/Locale/zh_TW/translations.php @@ -1392,4 +1392,10 @@ return array( // 'Destination swimlane' => '', // 'Assign a category when the task is moved to a specific swimlane' => '', // 'Move the task to another swimlane when the category is changed' => '', + // 'Reorder this column by priority (ASC)' => '', + // 'Reorder this column by priority (DESC)' => '', + // 'Reorder this column by assignee and priority (ASC)' => '', + // 'Reorder this column by assignee and priority (DESC)' => '', + // 'Reorder this column by assignee (A-Z)' => '', + // 'Reorder this column by assignee (Z-A)' => '', ); diff --git a/app/Model/TaskReorderModel.php b/app/Model/TaskReorderModel.php new file mode 100644 index 00000000..db72274c --- /dev/null +++ b/app/Model/TaskReorderModel.php @@ -0,0 +1,74 @@ +db->startTransaction(); + + $taskIDs = $this->db->table(TaskModel::TABLE) + ->eq('project_id', $projectID) + ->eq('swimlane_id', $swimlaneID) + ->eq('column_id', $columnID) + ->orderBy('priority', $direction) + ->asc('id') + ->findAllByColumn('id'); + + $this->reorderTasks($taskIDs); + + $this->db->closeTransaction(); + } + + public function reorderByAssigneeAndPriority($projectID, $swimlaneID, $columnID, $direction) + { + $this->db->startTransaction(); + + $taskIDs = $this->db->table(TaskModel::TABLE) + ->eq('tasks.project_id', $projectID) + ->eq('tasks.swimlane_id', $swimlaneID) + ->eq('tasks.column_id', $columnID) + ->asc('u.name') + ->asc('u.username') + ->orderBy('tasks.priority', $direction) + ->left(UserModel::TABLE, 'u', 'id', TaskModel::TABLE, 'owner_id') + ->findAllByColumn('tasks.id'); + + $this->reorderTasks($taskIDs); + + $this->db->closeTransaction(); + } + + public function reorderByAssignee($projectID, $swimlaneID, $columnID, $direction) + { + $this->db->startTransaction(); + + $taskIDs = $this->db->table(TaskModel::TABLE) + ->eq('tasks.project_id', $projectID) + ->eq('tasks.swimlane_id', $swimlaneID) + ->eq('tasks.column_id', $columnID) + ->orderBy('u.name', $direction) + ->orderBy('u.username', $direction) + ->orderBy('u.id', $direction) + ->left(UserModel::TABLE, 'u', 'id', TaskModel::TABLE, 'owner_id') + ->findAllByColumn('tasks.id'); + + $this->reorderTasks($taskIDs); + + $this->db->closeTransaction(); + } + + protected function reorderTasks(array $taskIDs) + { + $i = 1; + foreach ($taskIDs as $taskID) { + $this->db->table(TaskModel::TABLE) + ->eq('id', $taskID) + ->update(['position' => $i]); + $i++; + } + } +} diff --git a/app/ServiceProvider/ClassProvider.php b/app/ServiceProvider/ClassProvider.php index 7f05dfae..b012d80b 100644 --- a/app/ServiceProvider/ClassProvider.php +++ b/app/ServiceProvider/ClassProvider.php @@ -85,6 +85,7 @@ class ClassProvider implements ServiceProviderInterface 'TaskLinkModel', 'TaskModificationModel', 'TaskPositionModel', + 'TaskReorderModel', 'TaskStatusModel', 'TaskTagModel', 'TaskMetadataModel', diff --git a/app/Template/board/table_column.php b/app/Template/board/table_column.php index 765d05a9..5b81d709 100644 --- a/app/Template/board/table_column.php +++ b/app/Template/board/table_column.php @@ -48,6 +48,27 @@ + 0 && $this->user->hasProjectAccess('TaskModificationController', 'update', $column['project_id'])): ?> +
  • + url->icon('sort-numeric-asc', t('Reorder this column by priority (ASC)'), 'TaskReorderController', 'reorderColumn', ['sort' => 'priority', 'direction' => 'asc', 'project_id' => $column['project_id'], 'column_id' => $column['id'], 'swimlane_id' => $swimlane['id']]) ?> +
  • +
  • + url->icon('sort-numeric-desc', t('Reorder this column by priority (DESC)'), 'TaskReorderController', 'reorderColumn', ['sort' => 'priority', 'direction' => 'desc', 'project_id' => $column['project_id'], 'column_id' => $column['id'], 'swimlane_id' => $swimlane['id']]) ?> +
  • +
  • + url->icon('sort-amount-asc', t('Reorder this column by assignee and priority (ASC)'), 'TaskReorderController', 'reorderColumn', ['sort' => 'assignee-priority', 'direction' => 'asc', 'project_id' => $column['project_id'], 'column_id' => $column['id'], 'swimlane_id' => $swimlane['id']]) ?> +
  • +
  • + url->icon('sort-amount-desc', t('Reorder this column by assignee and priority (DESC)'), 'TaskReorderController', 'reorderColumn', ['sort' => 'assignee-priority', 'direction' => 'desc', 'project_id' => $column['project_id'], 'column_id' => $column['id'], 'swimlane_id' => $swimlane['id']]) ?> +
  • +
  • + url->icon('sort-alpha-asc', t('Reorder this column by assignee (A-Z)'), 'TaskReorderController', 'reorderColumn', ['sort' => 'assignee', 'direction' => 'asc', 'project_id' => $column['project_id'], 'column_id' => $column['id'], 'swimlane_id' => $swimlane['id']]) ?> +
  • +
  • + url->icon('sort-alpha-desc', t('Reorder this column by assignee (Z-A)'), 'TaskReorderController', 'reorderColumn', ['sort' => 'assignee', 'direction' => 'desc', 'project_id' => $column['project_id'], 'column_id' => $column['id'], 'swimlane_id' => $swimlane['id']]) ?> +
  • + + hook->render('template:board:column:dropdown', array('swimlane' => $swimlane, 'column' => $column)) ?> @@ -81,7 +102,7 @@ - hook->render('template:board:column:header', array('swimlane' => $swimlane, 'column' => $column)) ?> + hook->render('template:board:column:header', array('swimlane' => $swimlane, 'column' => $column)) ?> -- cgit v1.2.3