Add filter by task link
This commit is contained in:
@@ -39,6 +39,7 @@ class Lexer
|
||||
"/^(swimlane:)/" => 'T_SWIMLANE',
|
||||
"/^(ref:)/" => 'T_REFERENCE',
|
||||
"/^(reference:)/" => 'T_REFERENCE',
|
||||
"/^(link:)/" => 'T_LINK',
|
||||
"/^(\s+)/" => 'T_WHITESPACE',
|
||||
'/^([<=>]{0,2}[0-9]{4}-[0-9]{2}-[0-9]{2})/' => 'T_DATE',
|
||||
'/^(yesterday|tomorrow|today)/' => 'T_DATE',
|
||||
@@ -118,6 +119,7 @@ class Lexer
|
||||
case 'T_COLUMN':
|
||||
case 'T_PROJECT':
|
||||
case 'T_SWIMLANE':
|
||||
case 'T_LINK':
|
||||
$next = next($tokens);
|
||||
|
||||
if ($next !== false && $next['token'] === 'T_STRING') {
|
||||
|
||||
@@ -30,6 +30,7 @@ class TaskFilter extends Base
|
||||
'T_COLUMN' => 'filterByColumnName',
|
||||
'T_REFERENCE' => 'filterByReference',
|
||||
'T_SWIMLANE' => 'filterBySwimlaneName',
|
||||
'T_LINK' => 'filterByLinkName',
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -107,6 +108,22 @@ class TaskFilter extends Base
|
||||
->neq(Subtask::TABLE.'.status', Subtask::STATUS_DONE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new link query
|
||||
*
|
||||
* @access public
|
||||
* @return \PicoDb\Table
|
||||
*/
|
||||
public function createLinkQuery()
|
||||
{
|
||||
return $this->db->table(TaskLink::TABLE)
|
||||
->columns(
|
||||
TaskLink::TABLE.'.task_id',
|
||||
Link::TABLE.'.label'
|
||||
)
|
||||
->join(Link::TABLE, 'id', 'link_id', TaskLink::TABLE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Clone the filter
|
||||
*
|
||||
@@ -506,6 +523,30 @@ class TaskFilter extends Base
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter by link
|
||||
*
|
||||
* @access public
|
||||
* @param array $values List of links
|
||||
* @return TaskFilter
|
||||
*/
|
||||
public function filterByLinkName(array $values)
|
||||
{
|
||||
$this->query->beginOr();
|
||||
|
||||
$link_query = $this->createLinkQuery()->in(Link::TABLE.'.label', $values);
|
||||
$matching_task_ids = $link_query->findAllByColumn('task_id');
|
||||
if (empty($matching_task_ids)) {
|
||||
$this->query->eq(Task::TABLE.'.id', 0);
|
||||
} else {
|
||||
$this->query->in(Task::TABLE.'.id', $matching_task_ids);
|
||||
}
|
||||
|
||||
$this->query->closeOr();
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter by due date
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user