Allow searching for filters without a query to match all that have a given filter set
Signed-off-by: Julius Härtl <jus@bitgrid.net>
This commit is contained in:
committed by
backportbot[bot]
parent
65c8c394a8
commit
23580705aa
@@ -383,6 +383,10 @@ class CardMapper extends QBMapper implements IPermissionMapper {
|
|||||||
foreach ($query->getDuedate() as $duedate) {
|
foreach ($query->getDuedate() as $duedate) {
|
||||||
$dueDateColumn = $this->databaseType === 'sqlite3' ? $qb->createFunction('DATETIME(`c`.`duedate`)') : 'c.duedate';
|
$dueDateColumn = $this->databaseType === 'sqlite3' ? $qb->createFunction('DATETIME(`c`.`duedate`)') : 'c.duedate';
|
||||||
$date = $duedate->getValue();
|
$date = $duedate->getValue();
|
||||||
|
if ($date === "") {
|
||||||
|
$qb->andWhere($qb->expr()->isNotNull('c.duedate'));
|
||||||
|
continue;
|
||||||
|
}
|
||||||
$supportedFilters = ['overdue', 'today', 'week', 'month', 'none'];
|
$supportedFilters = ['overdue', 'today', 'week', 'month', 'none'];
|
||||||
if (in_array($date, $supportedFilters, true)) {
|
if (in_array($date, $supportedFilters, true)) {
|
||||||
$currentDate = new DateTime();
|
$currentDate = new DateTime();
|
||||||
@@ -430,6 +434,10 @@ class CardMapper extends QBMapper implements IPermissionMapper {
|
|||||||
foreach ($query->getAssigned() as $index => $assignment) {
|
foreach ($query->getAssigned() as $index => $assignment) {
|
||||||
$qb->innerJoin('c', 'deck_assigned_users', 'au' . $index, $qb->expr()->eq('c.id', 'au' . $index . '.card_id'));
|
$qb->innerJoin('c', 'deck_assigned_users', 'au' . $index, $qb->expr()->eq('c.id', 'au' . $index . '.card_id'));
|
||||||
$assignedQueryValue = $assignment->getValue();
|
$assignedQueryValue = $assignment->getValue();
|
||||||
|
if ($assignedQueryValue === "") {
|
||||||
|
$qb->andWhere($qb->expr()->isNotNull('au' . $index . '.participant'));
|
||||||
|
continue;
|
||||||
|
}
|
||||||
$searchUsers = $this->userManager->searchDisplayName($assignment->getValue());
|
$searchUsers = $this->userManager->searchDisplayName($assignment->getValue());
|
||||||
$users = array_filter($searchUsers, function (IUser $user) use ($assignedQueryValue) {
|
$users = array_filter($searchUsers, function (IUser $user) use ($assignedQueryValue) {
|
||||||
return (mb_strtolower($user->getDisplayName()) === mb_strtolower($assignedQueryValue) || $user->getUID() === $assignedQueryValue);
|
return (mb_strtolower($user->getDisplayName()) === mb_strtolower($assignedQueryValue) || $user->getUID() === $assignedQueryValue);
|
||||||
|
|||||||
@@ -97,19 +97,34 @@ export default {
|
|||||||
return q
|
return q
|
||||||
}
|
}
|
||||||
for (const match of matches) {
|
for (const match of matches) {
|
||||||
let [filter, query] = match.indexOf(':') !== -1 ? match.split(/:(.+)/) : [null, match]
|
let [filter, query] = match.indexOf(':') !== -1 ? match.split(/:(.*)/) : [null, match]
|
||||||
|
const isEmptyQuery = typeof query === 'undefined' || filterOutQuotes(query) === ''
|
||||||
|
|
||||||
if (filter === 'title') {
|
if (filter === 'title') {
|
||||||
|
if (isEmptyQuery) {
|
||||||
|
continue
|
||||||
|
}
|
||||||
hasMatch = hasMatch && card.title.toLowerCase().includes(filterOutQuotes(query).toLowerCase())
|
hasMatch = hasMatch && card.title.toLowerCase().includes(filterOutQuotes(query).toLowerCase())
|
||||||
} else if (filter === 'description') {
|
} else if (filter === 'description') {
|
||||||
|
if (isEmptyQuery) {
|
||||||
|
hasMatch = hasMatch && !!card.description
|
||||||
|
continue
|
||||||
|
}
|
||||||
hasMatch = hasMatch && card.description.toLowerCase().includes(filterOutQuotes(query).toLowerCase())
|
hasMatch = hasMatch && card.description.toLowerCase().includes(filterOutQuotes(query).toLowerCase())
|
||||||
} else if (filter === 'list') {
|
} else if (filter === 'list') {
|
||||||
const stack = this.getters.stackById(card.stackId)
|
if (isEmptyQuery) {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
const stack = getters.stackById(card.stackId)
|
||||||
if (!stack) {
|
if (!stack) {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
hasMatch = hasMatch && stack.title.toLowerCase().includes(filterOutQuotes(query).toLowerCase())
|
hasMatch = hasMatch && stack.title.toLowerCase().includes(filterOutQuotes(query).toLowerCase())
|
||||||
} else if (filter === 'tag') {
|
} else if (filter === 'tag') {
|
||||||
|
if (isEmptyQuery) {
|
||||||
|
hasMatch = hasMatch && card.labels.length > 0
|
||||||
|
continue
|
||||||
|
}
|
||||||
hasMatch = hasMatch && card.labels.findIndex((label) => label.title.toLowerCase().includes(filterOutQuotes(query).toLowerCase())) !== -1
|
hasMatch = hasMatch && card.labels.findIndex((label) => label.title.toLowerCase().includes(filterOutQuotes(query).toLowerCase())) !== -1
|
||||||
} else if (filter === 'date') {
|
} else if (filter === 'date') {
|
||||||
const datediffHour = ((new Date(card.duedate) - new Date()) / 3600 / 1000)
|
const datediffHour = ((new Date(card.duedate) - new Date()) / 3600 / 1000)
|
||||||
@@ -158,6 +173,10 @@ export default {
|
|||||||
}
|
}
|
||||||
|
|
||||||
} else if (filter === 'assigned') {
|
} else if (filter === 'assigned') {
|
||||||
|
if (isEmptyQuery) {
|
||||||
|
hasMatch = hasMatch && card.assignedUsers.length > 0
|
||||||
|
continue
|
||||||
|
}
|
||||||
hasMatch = hasMatch && card.assignedUsers.findIndex((assignment) => {
|
hasMatch = hasMatch && card.assignedUsers.findIndex((assignment) => {
|
||||||
return assignment.participant.primaryKey.toLowerCase() === filterOutQuotes(query).toLowerCase()
|
return assignment.participant.primaryKey.toLowerCase() === filterOutQuotes(query).toLowerCase()
|
||||||
|| assignment.participant.displayname.toLowerCase() === filterOutQuotes(query).toLowerCase()
|
|| assignment.participant.displayname.toLowerCase() === filterOutQuotes(query).toLowerCase()
|
||||||
|
|||||||
Reference in New Issue
Block a user