Display meta-fields in datatables (#1116)
This commit is contained in:
@@ -170,7 +170,7 @@ class Activity implements EntityWithMetaFields
|
||||
public function getMetaField(string $name): ?MetaTableTypeInterface
|
||||
{
|
||||
foreach ($this->meta as $field) {
|
||||
if ($field->getName() === $name) {
|
||||
if (strtolower($field->getName()) === strtolower($name)) {
|
||||
return $field;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -411,7 +411,7 @@ class Customer implements EntityWithMetaFields
|
||||
public function getMetaField(string $name): ?MetaTableTypeInterface
|
||||
{
|
||||
foreach ($this->meta as $field) {
|
||||
if ($field->getName() === $name) {
|
||||
if (strtolower($field->getName()) === strtolower($name)) {
|
||||
return $field;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -148,4 +148,19 @@ interface MetaTableTypeInterface
|
||||
* @return MetaTableTypeInterface
|
||||
*/
|
||||
public function setLabel(string $label): MetaTableTypeInterface;
|
||||
|
||||
/**
|
||||
* Set an array of options for the FormType.
|
||||
*
|
||||
* @param array $options
|
||||
* @return MetaTableTypeInterface
|
||||
*/
|
||||
public function setOptions(array $options): MetaTableTypeInterface;
|
||||
|
||||
/**
|
||||
* Returns an array with options for the FormType.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getOptions(): array;
|
||||
}
|
||||
|
||||
@@ -70,6 +70,12 @@ trait MetaTableTypeTrait
|
||||
*/
|
||||
private $constraints = [];
|
||||
|
||||
/**
|
||||
* An array of options for the form element
|
||||
* @var array
|
||||
*/
|
||||
private $options = [];
|
||||
|
||||
public function getName(): ?string
|
||||
{
|
||||
if (null === $this->name) {
|
||||
@@ -183,7 +189,10 @@ trait MetaTableTypeTrait
|
||||
->setType($meta->getType())
|
||||
->setConstraints($meta->getConstraints())
|
||||
->setIsRequired($meta->isRequired())
|
||||
->setIsVisible($meta->isVisible());
|
||||
->setIsVisible($meta->isVisible())
|
||||
->setLabel($meta->getLabel())
|
||||
->setOptions($meta->getOptions())
|
||||
;
|
||||
|
||||
return $this;
|
||||
}
|
||||
@@ -203,4 +212,16 @@ trait MetaTableTypeTrait
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setOptions(array $options): MetaTableTypeInterface
|
||||
{
|
||||
$this->options = $options;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getOptions(): array
|
||||
{
|
||||
return $this->options;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -220,7 +220,7 @@ class Project implements EntityWithMetaFields
|
||||
public function getMetaField(string $name): ?MetaTableTypeInterface
|
||||
{
|
||||
foreach ($this->meta as $field) {
|
||||
if ($field->getName() === $name) {
|
||||
if (strtolower($field->getName()) === strtolower($name)) {
|
||||
return $field;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -463,7 +463,7 @@ class Timesheet implements EntityWithMetaFields, InvoiceItemInterface
|
||||
public function getMetaField(string $name): ?MetaTableTypeInterface
|
||||
{
|
||||
foreach ($this->meta as $field) {
|
||||
if ($field->getName() === $name) {
|
||||
if (strtolower($field->getName()) === strtolower($name)) {
|
||||
return $field;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
|
||||
namespace App\Entity;
|
||||
|
||||
use App\Form\Type\YesNoType;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\IntegerType;
|
||||
@@ -96,18 +97,11 @@ class UserPreference
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return User
|
||||
*/
|
||||
public function getUser(): User
|
||||
public function getUser(): ?User
|
||||
{
|
||||
return $this->user;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param User $user
|
||||
* @return UserPreference
|
||||
*/
|
||||
public function setUser(User $user): UserPreference
|
||||
{
|
||||
$this->user = $user;
|
||||
@@ -115,18 +109,11 @@ class UserPreference
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getName()
|
||||
public function getName(): ?string
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $name
|
||||
* @return UserPreference
|
||||
*/
|
||||
public function setName(string $name): UserPreference
|
||||
{
|
||||
$this->name = $name;
|
||||
@@ -140,6 +127,7 @@ class UserPreference
|
||||
public function getValue()
|
||||
{
|
||||
switch ($this->type) {
|
||||
case YesNoType::class:
|
||||
case CheckboxType::class:
|
||||
return (bool) $this->value;
|
||||
case IntegerType::class:
|
||||
@@ -169,34 +157,24 @@ class UserPreference
|
||||
* @param string $type
|
||||
* @return UserPreference
|
||||
*/
|
||||
public function setType(string $type)
|
||||
public function setType(string $type): UserPreference
|
||||
{
|
||||
$this->type = $type;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getType()
|
||||
public function getType(): ?string
|
||||
{
|
||||
return $this->type;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function isEnabled(): bool
|
||||
{
|
||||
return $this->enabled;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bool $enabled
|
||||
* @return UserPreference
|
||||
*/
|
||||
public function setEnabled(bool $enabled)
|
||||
public function setEnabled(bool $enabled): UserPreference
|
||||
{
|
||||
$this->enabled = $enabled;
|
||||
|
||||
@@ -259,4 +237,13 @@ class UserPreference
|
||||
{
|
||||
return $this->options;
|
||||
}
|
||||
|
||||
public function getLabel(): ?string
|
||||
{
|
||||
if (isset($this->options['label'])) {
|
||||
return $this->options['label'];
|
||||
}
|
||||
|
||||
return $this->name;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user