mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-06-29 21:14:29 +02:00
Added filters for creationDate and lastModified state
This commit is contained in:
parent
798eb4c1bc
commit
d3a42cd989
6 changed files with 137 additions and 9 deletions
10
src/DataTables/Filters/Constraints/DateTimeConstraint.php
Normal file
10
src/DataTables/Filters/Constraints/DateTimeConstraint.php
Normal file
|
@ -0,0 +1,10 @@
|
|||
<?php
|
||||
|
||||
namespace App\DataTables\Filters\Constraints;
|
||||
|
||||
/**
|
||||
* An alias of NumberConstraint to use to filter on a DateTime
|
||||
*/
|
||||
class DateTimeConstraint extends NumberConstraint
|
||||
{
|
||||
}
|
|
@ -12,13 +12,13 @@ class NumberConstraint extends AbstractConstraint
|
|||
|
||||
/**
|
||||
* The value1 used for comparison (this is the main one used for all mono-value comparisons)
|
||||
* @var float|null
|
||||
* @var float|null|int|\DateTimeInterface
|
||||
*/
|
||||
protected $value1;
|
||||
|
||||
/**
|
||||
* The second value used when operator is RANGE; this is the upper bound of the range
|
||||
* @var float|null
|
||||
* @var float|null|int|\DateTimeInterface
|
||||
*/
|
||||
protected $value2;
|
||||
|
||||
|
@ -28,7 +28,7 @@ class NumberConstraint extends AbstractConstraint
|
|||
protected $operator;
|
||||
|
||||
/**
|
||||
* @return float|mixed|null
|
||||
* @return float|int|null|\DateTimeInterface
|
||||
*/
|
||||
public function getValue1()
|
||||
{
|
||||
|
@ -36,7 +36,7 @@ class NumberConstraint extends AbstractConstraint
|
|||
}
|
||||
|
||||
/**
|
||||
* @param float|mixed|null $value1
|
||||
* @param float|int|\DateTimeInterface|null $value1
|
||||
*/
|
||||
public function setValue1($value1): void
|
||||
{
|
||||
|
@ -44,7 +44,7 @@ class NumberConstraint extends AbstractConstraint
|
|||
}
|
||||
|
||||
/**
|
||||
* @return float|mixed|null
|
||||
* @return float|int|null
|
||||
*/
|
||||
public function getValue2()
|
||||
{
|
||||
|
@ -52,7 +52,7 @@ class NumberConstraint extends AbstractConstraint
|
|||
}
|
||||
|
||||
/**
|
||||
* @param float|mixed|null $value2
|
||||
* @param float|int|null $value2
|
||||
*/
|
||||
public function setValue2($value2): void
|
||||
{
|
||||
|
@ -60,7 +60,7 @@ class NumberConstraint extends AbstractConstraint
|
|||
}
|
||||
|
||||
/**
|
||||
* @return mixed|string
|
||||
* @return string
|
||||
*/
|
||||
public function getOperator(): string
|
||||
{
|
||||
|
@ -68,7 +68,7 @@ class NumberConstraint extends AbstractConstraint
|
|||
}
|
||||
|
||||
/**
|
||||
* @param mixed|string $operator
|
||||
* @param string $operator
|
||||
*/
|
||||
public function setOperator(?string $operator): void
|
||||
{
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
namespace App\DataTables\Filters;
|
||||
|
||||
use App\DataTables\Filters\Constraints\BooleanConstraint;
|
||||
use App\DataTables\Filters\Constraints\DateTimeConstraint;
|
||||
use App\DataTables\Filters\Constraints\NumberConstraint;
|
||||
use App\DataTables\Filters\Constraints\TextConstraint;
|
||||
use Doctrine\ORM\QueryBuilder;
|
||||
|
@ -27,6 +28,12 @@ class PartFilter implements FilterInterface
|
|||
/** @var NumberConstraint */
|
||||
protected $mass;
|
||||
|
||||
/** @var DateTimeConstraint */
|
||||
protected $lastModified;
|
||||
|
||||
/** @var DateTimeConstraint */
|
||||
protected $addedDate;
|
||||
|
||||
/**
|
||||
* @return BooleanConstraint|false
|
||||
*/
|
||||
|
@ -58,13 +65,33 @@ class PartFilter implements FilterInterface
|
|||
return $this->description;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return DateTimeConstraint
|
||||
*/
|
||||
public function getLastModified(): DateTimeConstraint
|
||||
{
|
||||
return $this->lastModified;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return DateTimeConstraint
|
||||
*/
|
||||
public function getAddedDate(): DateTimeConstraint
|
||||
{
|
||||
return $this->addedDate;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->favorite = new BooleanConstraint('part.favorite');
|
||||
$this->favorite =
|
||||
$this->needsReview = new BooleanConstraint('part.needs_review');
|
||||
$this->mass = new NumberConstraint('part.mass');
|
||||
$this->name = new TextConstraint('part.name');
|
||||
$this->description = new TextConstraint('part.description');
|
||||
$this->addedDate = new DateTimeConstraint('part.addedDate');
|
||||
$this->lastModified = new DateTimeConstraint('part.lastModified');
|
||||
}
|
||||
|
||||
public function apply(QueryBuilder $queryBuilder): void
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue