summaryrefslogtreecommitdiff
path: root/app/Filter
diff options
context:
space:
mode:
authorFrederic Guillot <fred@kanboard.net>2016-10-09 20:35:30 -0400
committerFrederic Guillot <fred@kanboard.net>2016-10-09 20:35:30 -0400
commit71ad04cd66531aa29d8859d7115ec47acf8b89c3 (patch)
tree0ca55c12af017e16921c3a52dea6364395552ecf /app/Filter
parentd7e92cf290f4694e16fea67caa1970ddd5fcb0c4 (diff)
Add filter tag:none
Diffstat (limited to 'app/Filter')
-rw-r--r--app/Filter/TaskTagFilter.php31
1 files changed, 25 insertions, 6 deletions
diff --git a/app/Filter/TaskTagFilter.php b/app/Filter/TaskTagFilter.php
index 01b6f625..98be5554 100644
--- a/app/Filter/TaskTagFilter.php
+++ b/app/Filter/TaskTagFilter.php
@@ -56,12 +56,11 @@ class TaskTagFilter extends BaseFilter implements FilterInterface
*/
public function apply()
{
- $task_ids = $this->db
- ->table(TagModel::TABLE)
- ->ilike(TagModel::TABLE.'.name', $this->value)
- ->asc(TagModel::TABLE.'.project_id')
- ->join(TaskTagModel::TABLE, 'tag_id', 'id')
- ->findAllByColumn(TaskTagModel::TABLE.'.task_id');
+ if ($this->value === 'none') {
+ $task_ids = $this->getTaskIdsWithoutTags();
+ } else {
+ $task_ids = $this->getTaskIdsWithGivenTag();
+ }
if (empty($task_ids)) {
$task_ids = array(-1);
@@ -71,4 +70,24 @@ class TaskTagFilter extends BaseFilter implements FilterInterface
return $this;
}
+
+ protected function getTaskIdsWithoutTags()
+ {
+ return $this->db
+ ->table(TaskModel::TABLE)
+ ->asc(TaskModel::TABLE . '.project_id')
+ ->left(TaskTagModel::TABLE, 'tg', 'task_id', TaskModel::TABLE, 'id')
+ ->isNull('tg.tag_id')
+ ->findAllByColumn(TaskModel::TABLE . '.id');
+ }
+
+ protected function getTaskIdsWithGivenTag()
+ {
+ return $this->db
+ ->table(TagModel::TABLE)
+ ->ilike(TagModel::TABLE.'.name', $this->value)
+ ->asc(TagModel::TABLE.'.project_id')
+ ->join(TaskTagModel::TABLE, 'tag_id', 'id')
+ ->findAllByColumn(TaskTagModel::TABLE.'.task_id');
+ }
}