Feat: Add description field to availability

This commit is contained in:
Björn Fromme
2023-10-18 17:18:25 +02:00
parent 4ae28f4f90
commit e8106a270c
6 changed files with 61 additions and 2 deletions
+31
View File
@@ -0,0 +1,31 @@
<?php
declare(strict_types=1);
namespace DoctrineMigrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20231018151251 extends AbstractMigration
{
public function getDescription(): string
{
return '';
}
public function up(Schema $schema): void
{
// this up() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE availability ADD description LONGTEXT DEFAULT NULL');
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE availability DROP description');
}
}
+15
View File
@@ -31,6 +31,9 @@ class Availability implements BlameableEntityInterface, TimestampableEntityInter
#[Assert\GreaterThan(propertyPath: 'dateFrom', message: 'Das Datum muss nach dem Beginndatum liegen')]
private ?\DateTimeImmutable $dateTo = null;
#[ORM\Column(type: Types::TEXT, nullable: true)]
private ?string $description = null;
#[ORM\ManyToOne(inversedBy: 'customAvailabilities')]
private ?Teamer $owner = null;
@@ -76,6 +79,18 @@ class Availability implements BlameableEntityInterface, TimestampableEntityInter
return $this;
}
public function getDescription(): ?string
{
return $this->description;
}
public function setDescription(?string $description): static
{
$this->description = $description;
return $this;
}
public function getOwner(): ?Teamer
{
return $this->owner;
+5
View File
@@ -4,6 +4,7 @@ namespace App\Form;
use App\Entity\Availability;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
@@ -20,6 +21,10 @@ class AvailabilityType extends AbstractType
'label' => 'Datum bis',
'min_date' => new \DateTimeImmutable(),
])
->add('description', TextType::class, [
'label' => 'Anmerkung',
'required' => false,
])
;
}
@@ -2,6 +2,7 @@
<div class="flex flex-col space-y-4 pb-8">
{{ form_row(form.dateFrom) }}
{{ form_row(form.dateTo) }}
{{ form_row(form.description) }}
</div>
<button type="submit" class="btn">
Speichern
@@ -11,12 +11,15 @@
<table class="data-table">
<thead>
<tr>
<th class="w-1/3">
<th class="w-1/4">
{{ knp_pagination_sortable(pagination, 'Datum von', 'availability.dateFrom') }}
</th>
<th class="w-1/3">
<th class="w-1/4">
{{ knp_pagination_sortable(pagination, 'Datum bis', 'availability.dateTo') }}
</th>
<th class="w-1/4">
{{ knp_pagination_sortable(pagination, 'Beschreibung', 'availability.description') }}
</th>
<th></th>
</tr>
</thead>
@@ -29,6 +32,9 @@
<td>
{{ availability.dateTo|date('d.m.Y') }}
</td>
<td>
{{ availability.description|default('-') }}
</td>
<td>
<div class="flex items-center space-x-2 justify-end">
<button type="button"
@@ -2,6 +2,7 @@
<div class="flex flex-col space-y-4 pb-8">
{{ form_row(form.dateFrom) }}
{{ form_row(form.dateTo) }}
{{ form_row(form.description) }}
</div>
<button type="submit" class="btn">
Speichern