mirror of
https://github.com/solidtime-io/solidtime.git
synced 2026-10-09 22:33:18 +01:00
add time entry filter normalizeation
This commit is contained in:
@@ -111,7 +111,8 @@ class TimeEntryFilter
|
||||
*/
|
||||
public function addMemberIdsFilter(?array $memberIds): self
|
||||
{
|
||||
if ($memberIds === null) {
|
||||
// An empty selection is no constraint, the same as null
|
||||
if ($memberIds === null || count($memberIds) === 0) {
|
||||
return $this;
|
||||
}
|
||||
$this->builder->whereIn('member_id', $memberIds);
|
||||
@@ -181,6 +182,10 @@ class TimeEntryFilter
|
||||
}
|
||||
$includeNone = in_array(self::NONE_VALUE, $clientIds, true);
|
||||
$clientIds = array_values(array_filter($clientIds, fn (string $id): bool => $id !== self::NONE_VALUE));
|
||||
// An empty selection (no client IDs and not filtering for "none") is no constraint, so apply nothing
|
||||
if (count($clientIds) === 0 && ! $includeNone) {
|
||||
return $this;
|
||||
}
|
||||
|
||||
$this->builder->where(function (Builder $builder) use ($clientIds, $includeNone): void {
|
||||
if (count($clientIds) > 0) {
|
||||
@@ -204,6 +209,10 @@ class TimeEntryFilter
|
||||
}
|
||||
$includeNone = in_array(self::NONE_VALUE, $projectIds, true);
|
||||
$projectIds = array_values(array_filter($projectIds, fn (string $id): bool => $id !== self::NONE_VALUE));
|
||||
// An empty selection (no project IDs and not filtering for "none") is no constraint, so apply nothing
|
||||
if (count($projectIds) === 0 && ! $includeNone) {
|
||||
return $this;
|
||||
}
|
||||
|
||||
$this->builder->where(function (Builder $builder) use ($projectIds, $includeNone): void {
|
||||
if (count($projectIds) > 0) {
|
||||
@@ -269,6 +278,10 @@ class TimeEntryFilter
|
||||
}
|
||||
$includeNone = in_array(self::NONE_VALUE, $taskIds, true);
|
||||
$taskIds = array_values(array_filter($taskIds, fn (string $id): bool => $id !== self::NONE_VALUE));
|
||||
// An empty selection (no task IDs and not filtering for "none") is no constraint, so apply nothing
|
||||
if (count($taskIds) === 0 && ! $includeNone) {
|
||||
return $this;
|
||||
}
|
||||
|
||||
$this->builder->where(function (Builder $builder) use ($taskIds, $includeNone): void {
|
||||
if (count($taskIds) > 0) {
|
||||
|
||||
Reference in New Issue
Block a user