mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
make somes changes on model: to manage isVisible field option + others
This commit is contained in:
parent
48f3c440a2
commit
b418d13190
@ -248,6 +248,16 @@ class ActivityType
|
||||
*/
|
||||
private string $socialActionsLabel = '';
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="smallint", nullable=false, options={"default"=1})
|
||||
*/
|
||||
private int $locationVisible = self::FIELD_INVISIBLE;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="string", nullable=false, options={"default"=""})
|
||||
*/
|
||||
private string $locationLabel = '';
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="float", options={"default"="0.0"})
|
||||
*/
|
||||
@ -820,4 +830,29 @@ class ActivityType
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getLocationVisible(): ?int
|
||||
{
|
||||
return $this->locationVisible;
|
||||
}
|
||||
|
||||
public function setLocationVisible(int $locationVisible): self
|
||||
{
|
||||
$this->locationVisible = $locationVisible;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getLocationLabel(): ?string
|
||||
{
|
||||
return $this->locationLabel;
|
||||
}
|
||||
|
||||
public function setLocationLabel(string $locationLabel): self
|
||||
{
|
||||
$this->locationLabel = $locationLabel;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -302,18 +302,9 @@ class ActivityType extends AbstractType
|
||||
;
|
||||
}
|
||||
|
||||
/*
|
||||
if ($activityType->isVisible('location')) {
|
||||
$builder
|
||||
->add('location', HiddenType::class)
|
||||
->get('location')
|
||||
->addModelTransformer(new CallbackTransformer(
|
||||
function () {},
|
||||
function () {}
|
||||
))
|
||||
;
|
||||
$builder->add('location', HiddenType::class);
|
||||
}
|
||||
*/
|
||||
|
||||
if ($activityType->isVisible('emergency')) {
|
||||
$builder->add('emergency', CheckboxType::class, [
|
||||
|
@ -65,7 +65,7 @@ export default {
|
||||
}))
|
||||
},
|
||||
customLabel(value) {
|
||||
return `${value.type.title.fr} ${value.name}`;
|
||||
return `${value.locationType.title.fr} ${value.name}`;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -54,7 +54,10 @@
|
||||
{{ form_row(edit_form.date) }}
|
||||
{% endif %}
|
||||
|
||||
<div id="location"></div>
|
||||
{%- if edit_form.location is defined -%}
|
||||
{{ form_row(edit_form.location) }}
|
||||
<div id="location"></div>
|
||||
{% endif %}
|
||||
|
||||
{%- if edit_form.durationTime is defined -%}
|
||||
{{ form_row(edit_form.durationTime) }}
|
||||
|
@ -55,7 +55,10 @@
|
||||
{{ form_row(form.date) }}
|
||||
{% endif %}
|
||||
|
||||
<div id="location"></div>
|
||||
{%- if form.location is defined -%}
|
||||
{{ form_row(form.location) }}
|
||||
<div id="location"></div>
|
||||
{% endif %}
|
||||
|
||||
{%- if form.durationTime is defined -%}
|
||||
{{ form_row(form.durationTime) }}
|
||||
|
@ -29,7 +29,7 @@ class Location implements TrackCreationInterface, TrackUpdateInterface
|
||||
* @ORM\JoinColumn(nullable=false)
|
||||
* @Serializer\Groups({"read"})
|
||||
*/
|
||||
private ?LocationType $type = null;
|
||||
private ?LocationType $locationType = null;
|
||||
|
||||
/**
|
||||
* @ORM\OneToOne(targetEntity=Address::class, cascade={"persist", "remove"})
|
||||
@ -104,14 +104,14 @@ class Location implements TrackCreationInterface, TrackUpdateInterface
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function getType(): ?LocationType
|
||||
public function getLocationType(): ?LocationType
|
||||
{
|
||||
return $this->type;
|
||||
return $this->locationType;
|
||||
}
|
||||
|
||||
public function setType(?LocationType $type): self
|
||||
public function setLocationType(?LocationType $locationType): self
|
||||
{
|
||||
$this->type = $type;
|
||||
$this->locationType = $locationType;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
@ -12,9 +12,9 @@ use Symfony\Component\Serializer\Annotation as Serializer;
|
||||
*/
|
||||
class LocationType
|
||||
{
|
||||
const STATUS_OPTIONAL = 'facultatif';
|
||||
const STATUS_REQUIRED = 'obligatoire';
|
||||
const STATUS_NEVER = 'jamais';
|
||||
const STATUS_OPTIONAL = 'optional';
|
||||
const STATUS_REQUIRED = 'required';
|
||||
const STATUS_NEVER = 'never';
|
||||
|
||||
/**
|
||||
* @ORM\Id
|
||||
@ -37,16 +37,16 @@ class LocationType
|
||||
private bool $availableForUsers = true;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="string", length=32)
|
||||
* @ORM\Column(type="string", length=32, options={"default"="optional"})
|
||||
* @Serializer\Groups({"read"})
|
||||
*/
|
||||
private ?string $addressRequired = null;
|
||||
private string $addressRequired = self::STATUS_OPTIONAL;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="string", length=32)
|
||||
* @ORM\Column(type="string", length=32, options={"default"="optional"})
|
||||
* @Serializer\Groups({"read"})
|
||||
*/
|
||||
private ?string $contactData = null;
|
||||
private string $contactData = self::STATUS_OPTIONAL;
|
||||
|
||||
|
||||
public function getId(): ?int
|
||||
|
@ -21,15 +21,18 @@ final class Version20211012141336 extends AbstractMigration
|
||||
{
|
||||
$this->addSql('CREATE SEQUENCE chill_main_location_id_seq INCREMENT BY 1 MINVALUE 1 START 1');
|
||||
$this->addSql('CREATE SEQUENCE chill_main_location_type_id_seq INCREMENT BY 1 MINVALUE 1 START 1');
|
||||
$this->addSql('CREATE TABLE chill_main_location (id INT NOT NULL, type_id INT NOT NULL, address_id INT DEFAULT NULL, name VARCHAR(255) DEFAULT NULL, phonenumber1 VARCHAR(64) DEFAULT NULL, phonenumber2 VARCHAR(64) DEFAULT NULL, email VARCHAR(255) DEFAULT NULL, availableForUsers BOOLEAN NOT NULL, createdAt TIMESTAMP(0) WITHOUT TIME ZONE DEFAULT NULL, updatedAt TIMESTAMP(0) WITHOUT TIME ZONE DEFAULT NULL, createdBy_id INT DEFAULT NULL, updatedBy_id INT DEFAULT NULL, PRIMARY KEY(id))');
|
||||
$this->addSql('CREATE INDEX IDX_90E4736AC54C8C93 ON chill_main_location (type_id)');
|
||||
$this->addSql('CREATE TABLE chill_main_location (id INT NOT NULL, address_id INT DEFAULT NULL, name VARCHAR(255) DEFAULT NULL, phonenumber1 VARCHAR(64) DEFAULT NULL, phonenumber2 VARCHAR(64) DEFAULT NULL, email VARCHAR(255) DEFAULT NULL, availableForUsers BOOLEAN NOT NULL, createdAt TIMESTAMP(0) WITHOUT TIME ZONE DEFAULT NULL, updatedAt TIMESTAMP(0) WITHOUT TIME ZONE DEFAULT NULL, locationType_id INT NOT NULL, createdBy_id INT DEFAULT NULL, updatedBy_id INT DEFAULT NULL, PRIMARY KEY(id))');
|
||||
|
||||
$this->addSql('CREATE INDEX IDX_90E4736AB8B0DA8E ON chill_main_location (locationType_id)');
|
||||
$this->addSql('CREATE UNIQUE INDEX UNIQ_90E4736AF5B7AF75 ON chill_main_location (address_id)');
|
||||
$this->addSql('CREATE INDEX IDX_90E4736A3174800F ON chill_main_location (createdBy_id)');
|
||||
$this->addSql('CREATE INDEX IDX_90E4736A65FF1AEC ON chill_main_location (updatedBy_id)');
|
||||
|
||||
$this->addSql('COMMENT ON COLUMN chill_main_location.createdAt IS \'(DC2Type:datetime_immutable)\'');
|
||||
$this->addSql('COMMENT ON COLUMN chill_main_location.updatedAt IS \'(DC2Type:datetime_immutable)\'');
|
||||
$this->addSql('CREATE TABLE chill_main_location_type (id INT NOT NULL, title JSON NOT NULL, availableForUsers BOOLEAN NOT NULL, addressRequired VARCHAR(32) NOT NULL, contactData VARCHAR(32) NOT NULL, PRIMARY KEY(id))');
|
||||
$this->addSql('ALTER TABLE chill_main_location ADD CONSTRAINT FK_90E4736AC54C8C93 FOREIGN KEY (type_id) REFERENCES chill_main_location_type (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
|
||||
$this->addSql('CREATE TABLE chill_main_location_type (id INT NOT NULL, title JSON NOT NULL, availableForUsers BOOLEAN NOT NULL, addressRequired VARCHAR(32) DEFAULT \'optional\' NOT NULL, contactData VARCHAR(32) DEFAULT \'optional\' NOT NULL, PRIMARY KEY(id))');
|
||||
|
||||
$this->addSql('ALTER TABLE chill_main_location ADD CONSTRAINT FK_90E4736AB8B0DA8E FOREIGN KEY (locationType_id) REFERENCES chill_main_location_type (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
|
||||
$this->addSql('ALTER TABLE chill_main_location ADD CONSTRAINT FK_90E4736AF5B7AF75 FOREIGN KEY (address_id) REFERENCES chill_main_address (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
|
||||
$this->addSql('ALTER TABLE chill_main_location ADD CONSTRAINT FK_90E4736A3174800F FOREIGN KEY (createdBy_id) REFERENCES users (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
|
||||
$this->addSql('ALTER TABLE chill_main_location ADD CONSTRAINT FK_90E4736A65FF1AEC FOREIGN KEY (updatedBy_id) REFERENCES users (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
|
||||
@ -45,13 +48,14 @@ final class Version20211012141336 extends AbstractMigration
|
||||
|
||||
public function down(Schema $schema): void
|
||||
{
|
||||
|
||||
$this->addSql('ALTER TABLE activity DROP CONSTRAINT FK_AC74095A64D218E');
|
||||
$this->addSql('ALTER TABLE activity DROP location_id');
|
||||
|
||||
$this->addSql('ALTER TABLE chill_calendar.calendar DROP CONSTRAINT FK_712315AC64D218E');
|
||||
$this->addSql('ALTER TABLE chill_calendar.calendar DROP location_id');
|
||||
|
||||
$this->addSql('ALTER TABLE chill_main_location DROP CONSTRAINT FK_90E4736AC54C8C93');
|
||||
$this->addSql('ALTER TABLE chill_main_location DROP CONSTRAINT FK_90E4736AB8B0DA8E');
|
||||
|
||||
$this->addSql('DROP SEQUENCE chill_main_location_id_seq CASCADE');
|
||||
$this->addSql('DROP SEQUENCE chill_main_location_type_id_seq CASCADE');
|
||||
|
@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Chill\Migrations\Main;
|
||||
|
||||
use Doctrine\DBAL\Schema\Schema;
|
||||
use Doctrine\Migrations\AbstractMigration;
|
||||
|
||||
final class Version20211013124455 extends AbstractMigration
|
||||
{
|
||||
public function getDescription(): string
|
||||
{
|
||||
return 'add location visible admin option';
|
||||
}
|
||||
|
||||
public function up(Schema $schema): void
|
||||
{
|
||||
$this->addSql('ALTER TABLE activitytype ADD locationVisible SMALLINT DEFAULT 1 NOT NULL');
|
||||
$this->addSql('ALTER TABLE activitytype ADD locationLabel VARCHAR(255) DEFAULT \'\' NOT NULL');
|
||||
|
||||
// fix old migration !?
|
||||
$this->addSql('ALTER TABLE activitytype ALTER category_id DROP DEFAULT');
|
||||
|
||||
}
|
||||
|
||||
public function down(Schema $schema): void
|
||||
{
|
||||
$this->addSql('ALTER TABLE activitytype DROP locationVisible');
|
||||
$this->addSql('ALTER TABLE activitytype DROP locationLabel');
|
||||
|
||||
// fix old migration !?
|
||||
$this->addSql('ALTER TABLE activitytype ALTER category_id SET DEFAULT 1');
|
||||
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user