From 471e46e70294684efc6d7edfc814d5b9ca04738b Mon Sep 17 00:00:00 2001 From: Frederic Guillot Date: Wed, 1 Jul 2015 19:32:51 -0400 Subject: Add project and column attributes for advanced search --- app/Core/Lexer.php | 4 ++++ app/Model/TaskFilter.php | 50 +++++++++++++++++++++++++++++++++++++++++-- app/Template/search/index.php | 17 ++++++++++++++- 3 files changed, 68 insertions(+), 3 deletions(-) (limited to 'app') diff --git a/app/Core/Lexer.php b/app/Core/Lexer.php index ad0631d5..d277f998 100644 --- a/app/Core/Lexer.php +++ b/app/Core/Lexer.php @@ -31,6 +31,8 @@ class Lexer "/^(status:)/" => 'T_STATUS', "/^(description:)/" => 'T_DESCRIPTION', "/^(category:)/" => 'T_CATEGORY', + "/^(column:)/" => 'T_COLUMN', + "/^(project:)/" => 'T_PROJECT', "/^(\s+)/" => 'T_WHITESPACE', '/^([<=>]{0,2}[0-9]{4}-[0-9]{2}-[0-9]{2})/' => 'T_DATE', '/^(yesterday|tomorrow|today)/' => 'T_DATE', @@ -109,6 +111,8 @@ class Lexer case 'T_ASSIGNEE': case 'T_COLOR': case 'T_CATEGORY': + case 'T_COLUMN': + case 'T_PROJECT': $next = next($tokens); if ($next !== false && $next['token'] === 'T_STRING') { diff --git a/app/Model/TaskFilter.php b/app/Model/TaskFilter.php index 4a086078..31080cb5 100644 --- a/app/Model/TaskFilter.php +++ b/app/Model/TaskFilter.php @@ -62,6 +62,12 @@ class TaskFilter extends Base case 'T_CATEGORY': $this->filterByCategoryName($value); break; + case 'T_PROJECT': + $this->filterByProjectName($value); + break; + case 'T_COLUMN': + $this->filterByColumnName($value); + break; } } @@ -189,6 +195,29 @@ class TaskFilter extends Base return $this; } + /** + * Filter by project name + * + * @access public + * @param array $values List of project name + * @return TaskFilter + */ + public function filterByProjectName(array $values) + { + $this->query->beginOr(); + + foreach ($values as $project) { + if (ctype_digit($project)) { + $this->query->eq(Task::TABLE.'.project_id', $project); + } + else { + $this->query->ilike(Project::TABLE.'.name', $project); + } + } + + $this->query->closeOr(); + } + /** * Filter by category id * @@ -325,6 +354,24 @@ class TaskFilter extends Base return $this; } + /** + * Filter by column name + * + * @access public + * @param array $values List of column name + * @return TaskFilter + */ + public function filterByColumnName(array $values) + { + $this->query->beginOr(); + + foreach ($values as $project) { + $this->query->ilike(Board::TABLE.'.title', $project); + } + + $this->query->closeOr(); + } + /** * Filter by swimlane * @@ -382,7 +429,6 @@ class TaskFilter extends Base */ public function filterByDueDate($date) { - $this->query->neq(Task::TABLE.'.date_due', ''); $this->query->neq(Task::TABLE.'.date_due', 0); $this->query->notNull(Task::TABLE.'.date_due'); return $this->filterWithOperator(Task::TABLE.'.date_due', $date, true); @@ -452,7 +498,7 @@ class TaskFilter extends Base */ public function findAll() { - return $this->query->findAll(); + return $this->query->asc(Task::TABLE.'.id')->findAll(); } /** diff --git a/app/Template/search/index.php b/app/Template/search/index.php index 058f428d..47a926f4 100644 --- a/app/Template/search/index.php +++ b/app/Template/search/index.php @@ -15,7 +15,22 @@ - isEmpty()): ?> + +
+

+

project:"My project" assignee:me due:tomorrow

+ +

+
+ isEmpty()): ?>

isEmpty()): ?> render('search/results', array( -- cgit v1.2.3