summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
Diffstat (limited to 'app')
-rw-r--r--app/Controller/Projectinfo.php8
-rw-r--r--app/Core/Lexer.php2
-rw-r--r--app/Model/TaskFilter.php27
-rw-r--r--app/Model/TaskFinder.php15
4 files changed, 31 insertions, 21 deletions
diff --git a/app/Controller/Projectinfo.php b/app/Controller/Projectinfo.php
index c30c1652..22b9861c 100644
--- a/app/Controller/Projectinfo.php
+++ b/app/Controller/Projectinfo.php
@@ -45,12 +45,8 @@ class Projectinfo extends Base
->setDirection('DESC');
if ($search !== '') {
-
- // $paginator
- // ->setQuery($this->taskFinder->getSearchQuery($project['id'], $search))
- // ->calculate();
-
- $paginator->setQuery($this->taskFilter->search($search)->filterByProject($project['id'])->getQuery())->calculate();
+ $paginator->setQuery($this->taskFilter->search($search)->filterByProject($project['id'])->getQuery())
+ ->calculate();
$nb_tasks = $paginator->getTotal();
}
diff --git a/app/Core/Lexer.php b/app/Core/Lexer.php
index ccd29588..ad0631d5 100644
--- a/app/Core/Lexer.php
+++ b/app/Core/Lexer.php
@@ -30,6 +30,7 @@ class Lexer
"/^(due:)/" => 'T_DUE',
"/^(status:)/" => 'T_STATUS',
"/^(description:)/" => 'T_DESCRIPTION',
+ "/^(category:)/" => 'T_CATEGORY',
"/^(\s+)/" => 'T_WHITESPACE',
'/^([<=>]{0,2}[0-9]{4}-[0-9]{2}-[0-9]{2})/' => 'T_DATE',
'/^(yesterday|tomorrow|today)/' => 'T_DATE',
@@ -107,6 +108,7 @@ class Lexer
switch ($token['token']) {
case 'T_ASSIGNEE':
case 'T_COLOR':
+ case 'T_CATEGORY':
$next = next($tokens);
if ($next !== false && $next['token'] === 'T_STRING') {
diff --git a/app/Model/TaskFilter.php b/app/Model/TaskFilter.php
index bdfbb190..b14dad0a 100644
--- a/app/Model/TaskFilter.php
+++ b/app/Model/TaskFilter.php
@@ -59,6 +59,9 @@ class TaskFilter extends Base
case 'T_DESCRIPTION':
$this->filterByDescription($value);
break;
+ case 'T_CATEGORY':
+ $this->filterByCategoryName($value);
+ break;
}
}
@@ -203,6 +206,30 @@ class TaskFilter extends Base
}
/**
+ * Filter by category
+ *
+ * @access public
+ * @param array $values List of assignees
+ * @return TaskFilter
+ */
+ public function filterByCategoryName(array $values)
+ {
+ $this->query->join(Category::TABLE, 'id', 'category_id');
+ $this->query->beginOr();
+
+ foreach ($values as $category) {
+ if ($category === 'none') {
+ $this->query->eq(Task::TABLE.'.category_id', 0);
+ }
+ else {
+ $this->query->eq(Category::TABLE.'.name', $category);
+ }
+ }
+
+ $this->query->closeOr();
+ }
+
+ /**
* Filter by assignee
*
* @access public
diff --git a/app/Model/TaskFinder.php b/app/Model/TaskFinder.php
index 9c46f4a9..e007187f 100644
--- a/app/Model/TaskFinder.php
+++ b/app/Model/TaskFinder.php
@@ -27,21 +27,6 @@ class TaskFinder extends Base
}
/**
- * Get query for task search
- *
- * @access public
- * @param integer $project_id Project id
- * @param string $search Search terms
- * @return \PicoDb\Table
- */
- public function getSearchQuery($project_id, $search)
- {
- return $this->getExtendedQuery()
- ->eq('project_id', $project_id)
- ->ilike('title', '%'.$search.'%');
- }
-
- /**
* Get query for assigned user tasks
*
* @access public