import changes on address from chill main

This commit is contained in:
Julien Fastré 2021-03-18 13:14:37 +01:00
parent 490ea5bd72
commit a2f6773f5a
4 changed files with 81 additions and 3 deletions

View File

@ -146,3 +146,13 @@ Version 1.5.21
- [CRUD] Forward query parameters when pushing button "save and new" in "create" page;
- [Show/hide] Take selects input into account;
Version 1.5.23
==============
- [address] allow to add custom fields to addresses
Version 1.5.24
==============
- [bugfix] add missing migration files

View File

@ -58,19 +58,22 @@ class Address
* True if the address is a "no address", aka homeless person, ...
*
* @var bool
* @ORM\Column(type="boolean")
*/
private $isNoAddress = false;
/**
* Address constructor.
* A list of metadata, added by customizable fields
*
* @var array
*/
private $customs = [];
public function __construct()
{
$this->validFrom = new \DateTime();
}
/**
* Get id
*
@ -205,6 +208,29 @@ class Address
return $this;
}
/**
* Get customs informations in the address
*
* @return array
*/
public function getCustoms(): array
{
return $this->customs;
}
/**
* Store custom informations in the address
*
* @param array $customs
* @return $this
*/
public function setCustoms(array $customs): self
{
$this->customs = $customs;
return $this;
}
/**
* Validate the address.
*

View File

@ -187,3 +187,13 @@
</div>
{% endif %}
{% endblock %}
{% block address_widget %}
{% for entry in form %}
{% if entry.vars.name != 'customs' %}
{{ form_row(entry) }}
{% else %}
{{ form_widget(entry) }}
{% endif %}
{% endfor %}
{% endblock %}

View File

@ -0,0 +1,32 @@
<?php declare(strict_types=1);
namespace Application\Migrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
/**
* Add custom data in address
*/
final class Version20210308111926 extends AbstractMigration
{
public function up(Schema $schema) : void
{
$this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'postgresql', 'Migration can only be executed safely on \'postgresql\'.');
$this->addSql('ALTER TABLE chill_main_address ADD customs JSONB DEFAULT \'[]\'');
}
public function down(Schema $schema) : void
{
$this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'postgresql', 'Migration can only be executed safely on \'postgresql\'.');
$this->addSql('ALTER TABLE chill_main_address DROP customs');
}
public function getDescription(): string
{
return "Add custom data in addresses";
}
}