Display meta-fields in datatables (#1116)
This commit is contained in:
@@ -20,7 +20,7 @@ final class ActivityMetaDefinitionEvent extends Event
|
||||
/**
|
||||
* @var Activity
|
||||
*/
|
||||
protected $entity;
|
||||
private $entity;
|
||||
|
||||
public function __construct(Activity $entity)
|
||||
{
|
||||
|
||||
76
src/Event/ActivityMetaDisplayEvent.php
Normal file
76
src/Event/ActivityMetaDisplayEvent.php
Normal file
@@ -0,0 +1,76 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Kimai time-tracking app.
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace App\Event;
|
||||
|
||||
use App\Entity\MetaTableTypeInterface;
|
||||
use App\Repository\Query\ActivityQuery;
|
||||
use App\Repository\Query\BaseQuery;
|
||||
use Symfony\Contracts\EventDispatcher\Event;
|
||||
|
||||
/**
|
||||
* Dynamically find possible meta fields for a activity query.
|
||||
*/
|
||||
final class ActivityMetaDisplayEvent extends Event implements MetaDisplayEventInterface
|
||||
{
|
||||
public const EXPORT = 'export';
|
||||
public const ACTIVITY = 'activity';
|
||||
|
||||
/**
|
||||
* @var ActivityQuery
|
||||
*/
|
||||
private $query;
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $location;
|
||||
/**
|
||||
* @var MetaTableTypeInterface[]
|
||||
*/
|
||||
private $fields = [];
|
||||
|
||||
public function __construct(ActivityQuery $query, string $location)
|
||||
{
|
||||
$this->query = $query;
|
||||
$this->location = $location;
|
||||
}
|
||||
|
||||
/**
|
||||
* If you want to filter where your meta-field will be displayed, use the query settings.
|
||||
*
|
||||
* @return ActivityQuery
|
||||
*/
|
||||
public function getQuery(): BaseQuery
|
||||
{
|
||||
return $this->query;
|
||||
}
|
||||
|
||||
/**
|
||||
* If you want to filter where your meta-field will be displayed, check the current location.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getLocation(): string
|
||||
{
|
||||
return $this->location;
|
||||
}
|
||||
|
||||
public function addField(MetaTableTypeInterface $meta)
|
||||
{
|
||||
$this->fields[] = $meta;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return MetaTableTypeInterface[]
|
||||
*/
|
||||
public function getFields(): array
|
||||
{
|
||||
return $this->fields;
|
||||
}
|
||||
}
|
||||
@@ -20,7 +20,7 @@ final class CustomerMetaDefinitionEvent extends Event
|
||||
/**
|
||||
* @var Customer
|
||||
*/
|
||||
protected $entity;
|
||||
private $entity;
|
||||
|
||||
public function __construct(Customer $entity)
|
||||
{
|
||||
|
||||
76
src/Event/CustomerMetaDisplayEvent.php
Normal file
76
src/Event/CustomerMetaDisplayEvent.php
Normal file
@@ -0,0 +1,76 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Kimai time-tracking app.
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace App\Event;
|
||||
|
||||
use App\Entity\MetaTableTypeInterface;
|
||||
use App\Repository\Query\BaseQuery;
|
||||
use App\Repository\Query\CustomerQuery;
|
||||
use Symfony\Contracts\EventDispatcher\Event;
|
||||
|
||||
/**
|
||||
* Dynamically find possible meta fields for a customer query.
|
||||
*/
|
||||
final class CustomerMetaDisplayEvent extends Event implements MetaDisplayEventInterface
|
||||
{
|
||||
public const EXPORT = 'export';
|
||||
public const CUSTOMER = 'customer';
|
||||
|
||||
/**
|
||||
* @var CustomerQuery
|
||||
*/
|
||||
private $query;
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $location;
|
||||
/**
|
||||
* @var MetaTableTypeInterface[]
|
||||
*/
|
||||
private $fields = [];
|
||||
|
||||
public function __construct(CustomerQuery $query, string $location)
|
||||
{
|
||||
$this->query = $query;
|
||||
$this->location = $location;
|
||||
}
|
||||
|
||||
/**
|
||||
* If you want to filter where your meta-field will be displayed, use the query settings.
|
||||
*
|
||||
* @return CustomerQuery
|
||||
*/
|
||||
public function getQuery(): BaseQuery
|
||||
{
|
||||
return $this->query;
|
||||
}
|
||||
|
||||
/**
|
||||
* If you want to filter where your meta-field will be displayed, check the current location.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getLocation(): string
|
||||
{
|
||||
return $this->location;
|
||||
}
|
||||
|
||||
public function addField(MetaTableTypeInterface $meta)
|
||||
{
|
||||
$this->fields[] = $meta;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return MetaTableTypeInterface[]
|
||||
*/
|
||||
public function getFields(): array
|
||||
{
|
||||
return $this->fields;
|
||||
}
|
||||
}
|
||||
42
src/Event/MetaDisplayEventInterface.php
Normal file
42
src/Event/MetaDisplayEventInterface.php
Normal file
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Kimai time-tracking app.
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace App\Event;
|
||||
|
||||
use App\Entity\MetaTableTypeInterface;
|
||||
use App\Repository\Query\BaseQuery;
|
||||
|
||||
interface MetaDisplayEventInterface
|
||||
{
|
||||
/**
|
||||
* If you want to filter where your meta-field will be displayed, use the query settings.
|
||||
*
|
||||
* @return BaseQuery
|
||||
*/
|
||||
public function getQuery(): BaseQuery;
|
||||
|
||||
/**
|
||||
* If you want to filter where your meta-field will be displayed, check the current location.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getLocation(): string;
|
||||
|
||||
/**
|
||||
* @return MetaTableTypeInterface[]
|
||||
*/
|
||||
public function getFields(): array;
|
||||
|
||||
/**
|
||||
* Adds a field that should be displayed.
|
||||
*
|
||||
* @param MetaTableTypeInterface $meta
|
||||
*/
|
||||
public function addField(MetaTableTypeInterface $meta);
|
||||
}
|
||||
@@ -20,7 +20,7 @@ final class ProjectMetaDefinitionEvent extends Event
|
||||
/**
|
||||
* @var Project
|
||||
*/
|
||||
protected $entity;
|
||||
private $entity;
|
||||
|
||||
public function __construct(Project $entity)
|
||||
{
|
||||
|
||||
76
src/Event/ProjectMetaDisplayEvent.php
Normal file
76
src/Event/ProjectMetaDisplayEvent.php
Normal file
@@ -0,0 +1,76 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Kimai time-tracking app.
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace App\Event;
|
||||
|
||||
use App\Entity\MetaTableTypeInterface;
|
||||
use App\Repository\Query\BaseQuery;
|
||||
use App\Repository\Query\ProjectQuery;
|
||||
use Symfony\Contracts\EventDispatcher\Event;
|
||||
|
||||
/**
|
||||
* Dynamically find possible meta fields for a project query.
|
||||
*/
|
||||
final class ProjectMetaDisplayEvent extends Event implements MetaDisplayEventInterface
|
||||
{
|
||||
public const EXPORT = 'export';
|
||||
public const PROJECT = 'project';
|
||||
|
||||
/**
|
||||
* @var ProjectQuery
|
||||
*/
|
||||
private $query;
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $location;
|
||||
/**
|
||||
* @var MetaTableTypeInterface[]
|
||||
*/
|
||||
private $fields = [];
|
||||
|
||||
public function __construct(ProjectQuery $query, string $location)
|
||||
{
|
||||
$this->query = $query;
|
||||
$this->location = $location;
|
||||
}
|
||||
|
||||
/**
|
||||
* If you want to filter where your meta-field will be displayed, use the query settings.
|
||||
*
|
||||
* @return ProjectQuery
|
||||
*/
|
||||
public function getQuery(): BaseQuery
|
||||
{
|
||||
return $this->query;
|
||||
}
|
||||
|
||||
/**
|
||||
* If you want to filter where your meta-field will be displayed, check the current location.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getLocation(): string
|
||||
{
|
||||
return $this->location;
|
||||
}
|
||||
|
||||
public function addField(MetaTableTypeInterface $meta)
|
||||
{
|
||||
$this->fields[] = $meta;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return MetaTableTypeInterface[]
|
||||
*/
|
||||
public function getFields(): array
|
||||
{
|
||||
return $this->fields;
|
||||
}
|
||||
}
|
||||
@@ -20,7 +20,7 @@ final class TimesheetMetaDefinitionEvent extends Event
|
||||
/**
|
||||
* @var Timesheet
|
||||
*/
|
||||
protected $entity;
|
||||
private $entity;
|
||||
|
||||
public function __construct(Timesheet $entity)
|
||||
{
|
||||
|
||||
79
src/Event/TimesheetMetaDisplayEvent.php
Normal file
79
src/Event/TimesheetMetaDisplayEvent.php
Normal file
@@ -0,0 +1,79 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Kimai time-tracking app.
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace App\Event;
|
||||
|
||||
use App\Entity\MetaTableTypeInterface;
|
||||
use App\Repository\Query\BaseQuery;
|
||||
use App\Repository\Query\TimesheetQuery;
|
||||
use Symfony\Contracts\EventDispatcher\Event;
|
||||
|
||||
/**
|
||||
* Dynamically find possible meta fields for a timesheet query.
|
||||
*/
|
||||
final class TimesheetMetaDisplayEvent extends Event implements MetaDisplayEventInterface
|
||||
{
|
||||
public const EXPORT = 'export';
|
||||
public const TIMESHEET = 'timesheet';
|
||||
public const TEAM_TIMESHEET = 'team-timesheet';
|
||||
public const TIMESHEET_EXPORT = 'timesheet-export';
|
||||
public const TEAM_TIMESHEET_EXPORT = 'team-timesheet-export';
|
||||
|
||||
/**
|
||||
* @var TimesheetQuery
|
||||
*/
|
||||
private $query;
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $location;
|
||||
/**
|
||||
* @var MetaTableTypeInterface[]
|
||||
*/
|
||||
private $fields = [];
|
||||
|
||||
public function __construct(TimesheetQuery $query, string $location)
|
||||
{
|
||||
$this->query = $query;
|
||||
$this->location = $location;
|
||||
}
|
||||
|
||||
/**
|
||||
* If you want to filter where your meta-field will be displayed, use the query settings.
|
||||
*
|
||||
* @return TimesheetQuery
|
||||
*/
|
||||
public function getQuery(): BaseQuery
|
||||
{
|
||||
return $this->query;
|
||||
}
|
||||
|
||||
/**
|
||||
* If you want to filter where your meta-field will be displayed, check the current location.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getLocation(): string
|
||||
{
|
||||
return $this->location;
|
||||
}
|
||||
|
||||
public function addField(MetaTableTypeInterface $meta)
|
||||
{
|
||||
$this->fields[] = $meta;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return MetaTableTypeInterface[]
|
||||
*/
|
||||
public function getFields(): array
|
||||
{
|
||||
return $this->fields;
|
||||
}
|
||||
}
|
||||
59
src/Event/UserPreferenceDisplayEvent.php
Normal file
59
src/Event/UserPreferenceDisplayEvent.php
Normal file
@@ -0,0 +1,59 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Kimai time-tracking app.
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace App\Event;
|
||||
|
||||
use App\Entity\UserPreference;
|
||||
use Symfony\Contracts\EventDispatcher\Event;
|
||||
|
||||
/**
|
||||
* Dynamically find possible user preferences to display.
|
||||
*/
|
||||
final class UserPreferenceDisplayEvent extends Event
|
||||
{
|
||||
public const EXPORT = 'export';
|
||||
public const USERS = 'users';
|
||||
|
||||
/**
|
||||
* @var UserPreference[]
|
||||
*/
|
||||
protected $preferences = [];
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $location;
|
||||
|
||||
public function __construct(string $location)
|
||||
{
|
||||
$this->location = $location;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return UserPreference[]
|
||||
*/
|
||||
public function getPreferences(): array
|
||||
{
|
||||
return $this->preferences;
|
||||
}
|
||||
|
||||
public function addPreference(UserPreference $preference)
|
||||
{
|
||||
$this->preferences[] = $preference;
|
||||
}
|
||||
|
||||
/**
|
||||
* If you want to filter where the preference will be displayed, check the current location.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getLocation(): string
|
||||
{
|
||||
return $this->location;
|
||||
}
|
||||
}
|
||||
@@ -62,7 +62,7 @@ final class UserPreferenceEvent extends Event
|
||||
public function addUserPreference(UserPreference $preference)
|
||||
{
|
||||
foreach ($this->preferences as $pref) {
|
||||
if ($pref->getName() == $preference->getName()) {
|
||||
if (strtolower($pref->getName()) === strtolower($preference->getName())) {
|
||||
throw new \InvalidArgumentException(
|
||||
'Cannot add preference, one with the name "' . $preference->getName() . '" is already existing'
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user