mirror of
https://github.com/solidtime-io/solidtime.git
synced 2026-08-14 03:02:15 +01:00
Rename tag_filter parameter to tag_match_type
This commit is contained in:
@@ -56,7 +56,7 @@ class ReportPropertiesDto implements Castable
|
||||
*/
|
||||
public ?Collection $tagIds = null;
|
||||
|
||||
public ?string $tagFilter = null;
|
||||
public ?string $tagMatchType = null;
|
||||
|
||||
/**
|
||||
* @var Collection<int, string>|null
|
||||
@@ -117,7 +117,7 @@ class ReportPropertiesDto implements Castable
|
||||
$dto->clientIds = $data->clientIds !== null ? ReportPropertiesDto::idArrayToCollection($data->clientIds) : null;
|
||||
$dto->projectIds = $data->projectIds !== null ? ReportPropertiesDto::idArrayToCollection($data->projectIds) : null;
|
||||
$dto->tagIds = $data->tagIds !== null ? ReportPropertiesDto::idArrayToCollection($data->tagIds) : null;
|
||||
$dto->tagFilter = isset($data->tagFilter) ? ReportPropertiesDto::tagFilterValue($data->tagFilter) : null;
|
||||
$dto->tagMatchType = isset($data->tagMatchType) ? ReportPropertiesDto::tagMatchTypeValue($data->tagMatchType) : null;
|
||||
$dto->taskIds = $data->taskIds ? ReportPropertiesDto::idArrayToCollection($data->taskIds) : null;
|
||||
$dto->group = TimeEntryAggregationType::from($data->group);
|
||||
$dto->subGroup = TimeEntryAggregationType::from($data->subGroup);
|
||||
@@ -147,7 +147,7 @@ class ReportPropertiesDto implements Castable
|
||||
'clientIds' => $value->clientIds?->toArray(),
|
||||
'projectIds' => $value->projectIds?->toArray(),
|
||||
'tagIds' => $value->tagIds?->toArray(),
|
||||
'tagFilter' => $value->tagFilter,
|
||||
'tagMatchType' => $value->tagMatchType,
|
||||
'taskIds' => $value->taskIds?->toArray(),
|
||||
'group' => $value->group->value,
|
||||
'subGroup' => $value->subGroup->value,
|
||||
@@ -191,19 +191,19 @@ class ReportPropertiesDto implements Castable
|
||||
/**
|
||||
* @return 'contains'|'not_contains'|null
|
||||
*/
|
||||
public static function tagFilterValue(mixed $tagFilter): ?string
|
||||
public static function tagMatchTypeValue(mixed $tagMatchType): ?string
|
||||
{
|
||||
if ($tagFilter === null) {
|
||||
if ($tagMatchType === null) {
|
||||
return null;
|
||||
}
|
||||
if (! is_string($tagFilter)) {
|
||||
throw new \InvalidArgumentException('The given tag filter is not a string');
|
||||
if (! is_string($tagMatchType)) {
|
||||
throw new \InvalidArgumentException('The given tag match type is not a string');
|
||||
}
|
||||
if (! in_array($tagFilter, [TimeEntryFilter::TAG_FILTER_CONTAINS, TimeEntryFilter::TAG_FILTER_NOT_CONTAINS], true)) {
|
||||
throw new \InvalidArgumentException('The given tag filter is not valid');
|
||||
if (! in_array($tagMatchType, [TimeEntryFilter::TAG_MATCH_TYPE_CONTAINS, TimeEntryFilter::TAG_MATCH_TYPE_NOT_CONTAINS], true)) {
|
||||
throw new \InvalidArgumentException('The given tag match type is not valid');
|
||||
}
|
||||
|
||||
return $tagFilter;
|
||||
return $tagMatchType;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -238,9 +238,9 @@ class ReportPropertiesDto implements Castable
|
||||
$this->tagIds = $tagIds !== null ? ReportPropertiesDto::idArrayToCollection($tagIds) : null;
|
||||
}
|
||||
|
||||
public function setTagFilter(mixed $tagFilter): void
|
||||
public function setTagMatchType(mixed $tagMatchType): void
|
||||
{
|
||||
$this->tagFilter = ReportPropertiesDto::tagFilterValue($tagFilter);
|
||||
$this->tagMatchType = ReportPropertiesDto::tagMatchTypeValue($tagMatchType);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -14,9 +14,9 @@ class TimeEntryFilter
|
||||
{
|
||||
public const string NONE_VALUE = 'none';
|
||||
|
||||
public const string TAG_FILTER_CONTAINS = 'contains';
|
||||
public const string TAG_MATCH_TYPE_CONTAINS = 'contains';
|
||||
|
||||
public const string TAG_FILTER_NOT_CONTAINS = 'not_contains';
|
||||
public const string TAG_MATCH_TYPE_NOT_CONTAINS = 'not_contains';
|
||||
|
||||
/**
|
||||
* @var Builder<TimeEntry>
|
||||
@@ -196,17 +196,17 @@ class TimeEntryFilter
|
||||
/**
|
||||
* @param array<string>|null $tagIds
|
||||
*/
|
||||
public function addTagIdsFilter(?array $tagIds, ?string $tagFilter = self::TAG_FILTER_CONTAINS): self
|
||||
public function addTagIdsFilter(?array $tagIds, ?string $tagMatchType = self::TAG_MATCH_TYPE_CONTAINS): self
|
||||
{
|
||||
if ($tagIds === null) {
|
||||
return $this;
|
||||
}
|
||||
if ($tagFilter === null) {
|
||||
$tagFilter = self::TAG_FILTER_CONTAINS;
|
||||
if ($tagMatchType === null) {
|
||||
$tagMatchType = self::TAG_MATCH_TYPE_CONTAINS;
|
||||
}
|
||||
if (! in_array($tagFilter, [self::TAG_FILTER_CONTAINS, self::TAG_FILTER_NOT_CONTAINS], true)) {
|
||||
Log::warning('Invalid tag filter value', ['value' => $tagFilter]);
|
||||
$tagFilter = self::TAG_FILTER_CONTAINS;
|
||||
if (! in_array($tagMatchType, [self::TAG_MATCH_TYPE_CONTAINS, self::TAG_MATCH_TYPE_NOT_CONTAINS], true)) {
|
||||
Log::warning('Invalid tag match type value', ['value' => $tagMatchType]);
|
||||
$tagMatchType = self::TAG_MATCH_TYPE_CONTAINS;
|
||||
}
|
||||
$includeNone = in_array(self::NONE_VALUE, $tagIds, true);
|
||||
$tagIds = array_values(array_filter($tagIds, fn (string $id): bool => $id !== self::NONE_VALUE));
|
||||
@@ -227,7 +227,7 @@ class TimeEntryFilter
|
||||
}
|
||||
};
|
||||
|
||||
if ($tagFilter === self::TAG_FILTER_NOT_CONTAINS) {
|
||||
if ($tagMatchType === self::TAG_MATCH_TYPE_NOT_CONTAINS) {
|
||||
$this->builder->where(function (Builder $builder) use ($tagCondition, $includeNone): void {
|
||||
$builder->whereNot($tagCondition);
|
||||
if (! $includeNone) {
|
||||
|
||||
Reference in New Issue
Block a user