location admin: add active field on Location and LocationType

This commit is contained in:
nobohan 2021-10-22 12:14:32 +02:00
parent 7dc4590580
commit 154416cddf
9 changed files with 105 additions and 2 deletions

View File

@ -20,7 +20,10 @@ class LocationApiController extends ApiController
$query->expr()->eq('e.createdBy', ':user'),
$query->expr()->gte('e.createdAt', ':dateBefore')
),
$query->expr()->eq('e.availableForUsers', "'TRUE'")
$query->expr()->andX(
$query->expr()->eq('e.availableForUsers', "'TRUE'"),
$query->expr()->eq('e.active', "'TRUE'")
)
))
->setParameters([
'user' => $this->getUser(),

View File

@ -58,7 +58,8 @@ class LoadLocationType extends AbstractFixture implements ContainerAwareInterfac
foreach ($arr as $a) {
$locationType = (new LocationType())
->setTitle($a['name'])
->setAvailableForUsers(True)
->setAvailableForUsers(true)
->setActive(true)
->setAddressRequired($a['address_required']);
$manager->persist($locationType);
}

View File

@ -76,6 +76,12 @@ class Location implements TrackCreationInterface, TrackUpdateInterface
*/
private bool $availableForUsers = false;
/**
* @ORM\Column(type="boolean", nullable=true)
* @Serializer\Groups({"read"})
*/
private bool $active = true;
/**
* @ORM\ManyToOne(targetEntity=User::class)
* @Serializer\Groups({"read"})
@ -192,6 +198,18 @@ class Location implements TrackCreationInterface, TrackUpdateInterface
return $this;
}
public function getActive(): ?bool
{
return $this->active;
}
public function setActive(bool $active): self
{
$this->active = $active;
return $this;
}
public function getCreatedBy(): ?User
{
return $this->createdBy;

View File

@ -40,6 +40,12 @@ class LocationType
*/
private bool $availableForUsers = true;
/**
* @ORM\Column(type="boolean", nullable=true)
* @Serializer\Groups({"read"})
*/
private bool $active = true;
/**
* @ORM\Column(type="string", length=32, options={"default"="optional"})
* @Serializer\Groups({"read"})
@ -70,6 +76,18 @@ class LocationType
return $this;
}
public function getActive(): ?bool
{
return $this->active;
}
public function setActive(bool $active): self
{
$this->active = $active;
return $this;
}
public function getAvailableForUsers(): ?bool
{
return $this->availableForUsers;

View File

@ -51,6 +51,14 @@ final class LocationFormType extends AbstractType
'use_valid_from' => false,
'use_valid_to' => false,
'mapped' => false,
])
->add('active', ChoiceType::class,
[
'choices' => [
'Yes' => true,
'No' => false
],
'expanded' => true
]);
}

View File

@ -41,6 +41,14 @@ final class LocationTypeType extends AbstractType
'never' => LocationType::STATUS_NEVER,
],
'expanded' => true
])
->add('active', ChoiceType::class,
[
'choices' => [
'Yes' => true,
'No' => false
],
'expanded' => true
]);
}
}

View File

@ -11,6 +11,7 @@
<th>{{ 'Phonenumber2'|trans }}</th>
<th>{{ 'Email'|trans }}</th>
<th>{{ 'Address'|trans }}</th>
<th>{{ 'Active'|trans }}</th>
</tr>
</thead>
<tbody>
@ -25,6 +26,13 @@
{{ entity.address.street}}, {{ entity.address.streetnumber }}
{% endif %}
</td>
<td style="text-align:center;">
{%- if entity.active -%}
<i class="fa fa-check-square-o"></i>
{%- else -%}
<i class="fa fa-square-o"></i>
{%- endif -%}
</td>
<td>
<ul class="record_actions">
<li>

View File

@ -10,6 +10,7 @@
<th>{{ 'Available for users'|trans }}</th>
<th>{{ 'Address required'|trans }}</th>
<th>{{ 'Contact data'|trans }}</th>
<th>{{ 'Active'|trans }}</th>
</tr>
</thead>
<tbody>
@ -25,6 +26,13 @@
</td>
<td>{{ entity.addressRequired|trans }}</td>
<td>{{ entity.contactData|trans }}</td>
<td style="text-align:center;">
{%- if entity.active -%}
<i class="fa fa-check-square-o"></i>
{%- else -%}
<i class="fa fa-square-o"></i>
{%- endif -%}
</td>
<td>
<ul class="record_actions">
<li>

View File

@ -0,0 +1,31 @@
<?php
declare(strict_types=1);
namespace Chill\Migrations\Main;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
/**
* Add active on Location and LocationType
*/
final class Version20211022094429 extends AbstractMigration
{
public function getDescription(): string
{
return 'Add active on Location and LocationType';
}
public function up(Schema $schema): void
{
$this->addSql('ALTER TABLE chill_main_location ADD active BOOLEAN DEFAULT NULL;');
$this->addSql('ALTER TABLE chill_main_location_type ADD active BOOLEAN DEFAULT NULL;');
}
public function down(Schema $schema): void
{
$this->addSql('ALTER TABLE chill_main_location_type DROP active');
$this->addSql('ALTER TABLE chill_main_location DROP active');
}
}