From 48ee733f9e2d0519150a881b18bf5510d6ed8e29 Mon Sep 17 00:00:00 2001 From: Frederic Guillot Date: Thu, 14 Jul 2016 11:29:15 -0400 Subject: Added search filter for task priority --- ChangeLog | 1 + app/Filter/TaskPriorityFilter.php | 38 ++++++++++++++++++++++ app/ServiceProvider/FilterProvider.php | 2 ++ tests/units/Filter/TaskPriorityFilterTest.php | 47 +++++++++++++++++++++++++++ 4 files changed, 88 insertions(+) create mode 100644 app/Filter/TaskPriorityFilter.php create mode 100644 tests/units/Filter/TaskPriorityFilterTest.php diff --git a/ChangeLog b/ChangeLog index 881c3020..097ec68e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -4,6 +4,7 @@ Version 1.0.32 (unreleased) New features: * New automated action to close tasks without activity in a specific column +* Added search filter for task priority * Added the possibility to hide tasks in dashboard for a specific column Improvements: diff --git a/app/Filter/TaskPriorityFilter.php b/app/Filter/TaskPriorityFilter.php new file mode 100644 index 00000000..75f6ae3d --- /dev/null +++ b/app/Filter/TaskPriorityFilter.php @@ -0,0 +1,38 @@ +query->eq(TaskModel::TABLE.'.priority', $this->value); + return $this; + } +} diff --git a/app/ServiceProvider/FilterProvider.php b/app/ServiceProvider/FilterProvider.php index 20281a09..436288dc 100644 --- a/app/ServiceProvider/FilterProvider.php +++ b/app/ServiceProvider/FilterProvider.php @@ -21,6 +21,7 @@ use Kanboard\Filter\TaskDueDateFilter; use Kanboard\Filter\TaskIdFilter; use Kanboard\Filter\TaskLinkFilter; use Kanboard\Filter\TaskModificationDateFilter; +use Kanboard\Filter\TaskPriorityFilter; use Kanboard\Filter\TaskProjectFilter; use Kanboard\Filter\TaskReferenceFilter; use Kanboard\Filter\TaskStatusFilter; @@ -137,6 +138,7 @@ class FilterProvider implements ServiceProviderInterface ->withFilter(TaskColorFilter::getInstance() ->setColorModel($c['colorModel']) ) + ->withFilter(new TaskPriorityFilter()) ->withFilter(new TaskColumnFilter()) ->withFilter(new TaskCommentFilter()) ->withFilter(TaskCreationDateFilter::getInstance() diff --git a/tests/units/Filter/TaskPriorityFilterTest.php b/tests/units/Filter/TaskPriorityFilterTest.php new file mode 100644 index 00000000..4c95ddce --- /dev/null +++ b/tests/units/Filter/TaskPriorityFilterTest.php @@ -0,0 +1,47 @@ +container); + $taskCreation = new TaskCreationModel($this->container); + $projectModel = new ProjectModel($this->container); + $query = $taskFinder->getExtendedQuery(); + + $this->assertEquals(1, $projectModel->create(array('name' => 'Test'))); + $this->assertEquals(1, $taskCreation->create(array('title' => 'Test', 'project_id' => 1, 'priority' => 2))); + + $filter = new TaskPriorityFilter(); + $filter->withQuery($query); + $filter->withValue(2); + $filter->apply(); + + $this->assertCount(1, $query->findAll()); + } + + public function testWithNoPriority() + { + $taskFinder = new TaskFinderModel($this->container); + $taskCreation = new TaskCreationModel($this->container); + $projectModel = new ProjectModel($this->container); + $query = $taskFinder->getExtendedQuery(); + + $this->assertEquals(1, $projectModel->create(array('name' => 'Test'))); + $this->assertEquals(1, $taskCreation->create(array('title' => 'Test', 'project_id' => 1))); + + $filter = new TaskPriorityFilter(); + $filter->withQuery($query); + $filter->withValue(2); + $filter->apply(); + + $this->assertCount(0, $query->findAll()); + } +} -- cgit v1.2.3