From 3b56cc818b5348331904f3d3966c3e61592f6714 Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Tue, 18 Jan 2022 11:08:24 +0100 Subject: [PATCH 01/30] entities + migration created --- .../Entity/Person/PersonResource.php | 255 ++++++++++++++++++ .../Entity/Person/PersonResourceKind.php | 69 +++++ .../migrations/Version20220118100237.php | 231 ++++++++++++++++ 3 files changed, 555 insertions(+) create mode 100644 src/Bundle/ChillPersonBundle/Entity/Person/PersonResource.php create mode 100644 src/Bundle/ChillPersonBundle/Entity/Person/PersonResourceKind.php create mode 100644 src/Bundle/ChillPersonBundle/migrations/Version20220118100237.php diff --git a/src/Bundle/ChillPersonBundle/Entity/Person/PersonResource.php b/src/Bundle/ChillPersonBundle/Entity/Person/PersonResource.php new file mode 100644 index 000000000..21adbea5e --- /dev/null +++ b/src/Bundle/ChillPersonBundle/Entity/Person/PersonResource.php @@ -0,0 +1,255 @@ +comment = new CommentEmbeddable(); + } + + /** + * GETTERS + */ + + public function getId(): ?int + { + return $this->id; + } + + public function getFreeText(): ?string + { + return $this->freeText; + } + + public function getComment(): CommentEmbeddable + { + return $this->comment; + } + + public function getKind(): ?PersonResourceKind + { + return $this->kind; + } + + public function getPersonOwner(): ?Person + { + return $this->personOwner; + } + + public function getPerson(): ?Person + { + return $this->person; + } + + public function getThirdParty(): ?ThirdParty + { + return $this->thirdParty; + } + + public function getCreatedAt(): ?DateTimeInterface + { + return $this->createdAt; + } + + public function getCreatedBy(): ?User + { + return $this->createdBy; + } + + public function getUpdatedAt(): ?DateTimeInterface + { + return $this->updatedAt; + } + + public function getUpdatedBy(): ?User + { + return $this->updatedBy; + } + + /** + * SETTERS + */ + + public function setFreeText(?string $freeText): self + { + $this->freeText = $freeText; + + if ('' !== $freeText) { + $this->setPerson(null); + $this->setThirdParty(null); + } + + return $this; + } + + public function setComment(CommentEmbeddable $comment): self + { + $this->comment = $comment; + + return $this; + } + + public function setKind(?PersonResourceKind $kind): self + { + $this->kind = $kind; + + return $this; + } + + public function setPersonOwner(?Person $personOwner): self + { + $this->personOwner = $personOwner; + + return $this; + } + + public function setPerson(?Person $person): self + { + $this->person = $person; + + if (null !== $person) { + $this->setFreeText(""); + $this->setThirdParty(null); + } + + return $this; + } + + public function setThirdParty(?ThirdParty $thirdParty): self + { + $this->thirdParty = $thirdParty; + + if (null !== $thirdParty) { + $this->setFreeText(""); + $this->setPerson(null); + } + + return $this; + } + + public function setCreatedAt(DateTimeInterface $createdAt): self + { + $this->createdAt = $createdAt; + + return $this; + } + + public function setCreatedBy(?User $createdBy): self + { + $this->createdBy = $createdBy; + + return $this; + } + + public function setUpdatedAt(DateTimeInterface $updatedAt): self + { + $this->updatedAt = $updatedAt; + + return $this; + } + + public function setUpdatedBy(?User $updatedBy): self + { + $this->updatedBy = $updatedBy; + + return $this; + } + +} diff --git a/src/Bundle/ChillPersonBundle/Entity/Person/PersonResourceKind.php b/src/Bundle/ChillPersonBundle/Entity/Person/PersonResourceKind.php new file mode 100644 index 000000000..03b2aa858 --- /dev/null +++ b/src/Bundle/ChillPersonBundle/Entity/Person/PersonResourceKind.php @@ -0,0 +1,69 @@ +id; + } + + public function getIsActive(): bool + { + return $this->isActive; + } + + public function getLabel(): ?array + { + return $this->label; + } + + public function setLabel(array $label): self + { + $this->label = $label; + + return $this; + } + + public function setIsActive(bool $isActive): self + { + $this->isActive = $isActive; + + return $this; + } +} diff --git a/src/Bundle/ChillPersonBundle/migrations/Version20220118100237.php b/src/Bundle/ChillPersonBundle/migrations/Version20220118100237.php new file mode 100644 index 000000000..8f58b42b0 --- /dev/null +++ b/src/Bundle/ChillPersonBundle/migrations/Version20220118100237.php @@ -0,0 +1,231 @@ +addSql('DROP SEQUENCE chill_person_accompanying_period_work_eval_doc_id_seq CASCADE'); + $this->addSql('CREATE SEQUENCE chill_person_resource_id_seq INCREMENT BY 1 MINVALUE 1 START 1'); + $this->addSql('CREATE SEQUENCE chill_person_resource_kind_id_seq INCREMENT BY 1 MINVALUE 1 START 1'); + $this->addSql('CREATE TABLE chill_person_resource (id INT NOT NULL, person_id INT DEFAULT NULL, kind_id INT DEFAULT NULL, freeText TEXT DEFAULT NULL, createdAt TIMESTAMP(0) WITHOUT TIME ZONE NOT NULL, updatedAt TIMESTAMP(0) WITHOUT TIME ZONE DEFAULT NULL, comment_comment TEXT DEFAULT NULL, comment_date TIMESTAMP(0) WITHOUT TIME ZONE DEFAULT NULL, comment_userId INT DEFAULT NULL, personOwner_id INT NOT NULL, thirdParty_id INT DEFAULT NULL, createdBy_id INT NOT NULL, updatedBy_id INT DEFAULT NULL, PRIMARY KEY(id))'); + $this->addSql('CREATE INDEX IDX_FA5B7D92D19C515B ON chill_person_resource (personOwner_id)'); + $this->addSql('CREATE INDEX IDX_FA5B7D92217BBB47 ON chill_person_resource (person_id)'); + $this->addSql('CREATE INDEX IDX_FA5B7D923EA5CAB0 ON chill_person_resource (thirdParty_id)'); + $this->addSql('CREATE INDEX IDX_FA5B7D9230602CA9 ON chill_person_resource (kind_id)'); + $this->addSql('CREATE INDEX IDX_FA5B7D923174800F ON chill_person_resource (createdBy_id)'); + $this->addSql('CREATE INDEX IDX_FA5B7D9265FF1AEC ON chill_person_resource (updatedBy_id)'); + $this->addSql('CREATE TABLE chill_person_resource_kind (id INT NOT NULL, label JSON NOT NULL, isActive BOOLEAN NOT NULL, PRIMARY KEY(id))'); + $this->addSql('ALTER TABLE chill_person_resource ADD CONSTRAINT FK_FA5B7D92D19C515B FOREIGN KEY (personOwner_id) REFERENCES chill_person_person (id) NOT DEFERRABLE INITIALLY IMMEDIATE'); + $this->addSql('ALTER TABLE chill_person_resource ADD CONSTRAINT FK_FA5B7D92217BBB47 FOREIGN KEY (person_id) REFERENCES chill_person_person (id) NOT DEFERRABLE INITIALLY IMMEDIATE'); + $this->addSql('ALTER TABLE chill_person_resource ADD CONSTRAINT FK_FA5B7D923EA5CAB0 FOREIGN KEY (thirdParty_id) REFERENCES chill_3party.third_party (id) NOT DEFERRABLE INITIALLY IMMEDIATE'); + $this->addSql('ALTER TABLE chill_person_resource ADD CONSTRAINT FK_FA5B7D9230602CA9 FOREIGN KEY (kind_id) REFERENCES chill_person_resource_kind (id) NOT DEFERRABLE INITIALLY IMMEDIATE'); + $this->addSql('ALTER TABLE chill_person_resource ADD CONSTRAINT FK_FA5B7D923174800F FOREIGN KEY (createdBy_id) REFERENCES users (id) NOT DEFERRABLE INITIALLY IMMEDIATE'); + $this->addSql('ALTER TABLE chill_person_resource ADD CONSTRAINT FK_FA5B7D9265FF1AEC FOREIGN KEY (updatedBy_id) REFERENCES users (id) NOT DEFERRABLE INITIALLY IMMEDIATE'); + // $this->addSql('DROP TABLE chill_main_address_legacy'); + // $this->addSql('ALTER INDEX idx_ac74095a550b0c53 RENAME TO IDX_AC74095AD7FA8EF0'); + // $this->addSql('ALTER INDEX idx_55026b0cc54c8c93 RENAME TO IDX_AC74095AC54C8C93'); + // $this->addSql('ALTER INDEX idx_55026b0c217bbb47 RENAME TO IDX_AC74095A217BBB47'); + // $this->addSql('ALTER INDEX idx_55026b0c682b5931 RENAME TO IDX_AC74095A682B5931'); + // $this->addSql('ALTER INDEX idx_55026b0ca76ed395 RENAME TO IDX_AC74095AA76ED395'); + // $this->addSql('ALTER TABLE activityreason ALTER name SET NOT NULL'); + // $this->addSql('ALTER INDEX idx_654a2fcd12469de2 RENAME TO IDX_AF82522312469DE2'); + // $this->addSql('ALTER TABLE activityreasoncategory ALTER name SET NOT NULL'); + // $this->addSql('DROP INDEX internal_center_geom_idx'); + // $this->addSql('DROP INDEX chill_custom_main_address_filtering_idx'); + // $this->addSql('ALTER TABLE chill_main_address DROP customs'); + // $this->addSql('ALTER TABLE chill_main_address ALTER isnoaddress DROP DEFAULT'); + // $this->addSql('ALTER TABLE chill_main_address ALTER point TYPE geometry(POINT,4326)'); + // $this->addSql('ALTER TABLE chill_main_address ALTER point DROP DEFAULT'); + // $this->addSql('DROP INDEX chill_internal_address_reference_canonicalized'); + // $this->addSql('DROP INDEX address_refid'); + // $this->addSql('ALTER TABLE chill_main_address_reference ALTER point TYPE geometry(POINT,4326)'); + // $this->addSql('ALTER TABLE chill_main_address_reference ALTER point DROP DEFAULT'); + // $this->addSql('CREATE INDEX address_refid ON chill_main_address_reference (refId) WHERE refid != \'\''); + // $this->addSql('ALTER TABLE chill_main_location ALTER active DROP DEFAULT'); + // $this->addSql('ALTER TABLE chill_main_location_type ALTER active DROP DEFAULT'); + // $this->addSql('ALTER TABLE chill_main_location_type ALTER editablebyusers DROP DEFAULT'); + // $this->addSql('ALTER TABLE chill_main_location_type ALTER editablebyusers SET NOT NULL'); + // $this->addSql('ALTER INDEX idx_154a075fef1a9d84 RENAME TO IDX_589D51B4EF1A9D84'); + // $this->addSql('ALTER INDEX idx_154a075fa76ed395 RENAME TO IDX_589D51B4A76ED395'); + // $this->addSql('DROP INDEX chill_internal_postal_code_canonicalized'); + // $this->addSql('ALTER TABLE chill_main_postal_code ALTER center TYPE geometry(POINT,4326)'); + // $this->addSql('ALTER TABLE chill_main_postal_code ALTER center DROP DEFAULT'); + // $this->addSql('CREATE INDEX search_name_code ON chill_main_postal_code (code, label)'); + // $this->addSql('ALTER INDEX idx_64a4a621504cb38d RENAME TO IDX_E260A868504CB38D'); + // $this->addSql('DROP INDEX participations_no_overlap'); + // $this->addSql('DROP INDEX thirdparty_unique'); + // $this->addSql('DROP INDEX person_unique'); + // $this->addSql('CREATE UNIQUE INDEX thirdparty_unique ON chill_person_accompanying_period_resource (thirdparty_id, accompanyingperiod_id)'); + // $this->addSql('CREATE UNIQUE INDEX person_unique ON chill_person_accompanying_period_resource (person_id, accompanyingperiod_id)'); + // $this->addSql('ALTER TABLE chill_person_accompanying_period_work DROP CONSTRAINT fk_b694fb3616d9d9b'); + // $this->addSql('DROP INDEX idx_b694fb3616d9d9b'); + // $this->addSql('ALTER TABLE chill_person_household DROP CONSTRAINT fk_household_comment_embeddable_user'); + // $this->addSql('DROP INDEX IDX_BE50A270116F5FA9'); + // $this->addSql('DROP INDEX household_members_not_overlaps'); + // $this->addSql('DROP INDEX chill_custom_person_household_members_sharing_idx'); + // $this->addSql('ALTER TABLE chill_person_household_members ALTER startdate TYPE DATE'); + // $this->addSql('ALTER TABLE chill_person_household_members ALTER startdate DROP DEFAULT'); + // $this->addSql('ALTER TABLE chill_person_household_members ALTER enddate TYPE DATE'); + // $this->addSql('ALTER TABLE chill_person_household_members ALTER enddate DROP DEFAULT'); + // $this->addSql('COMMENT ON COLUMN chill_person_household_members.startDate IS \'(DC2Type:date_immutable)\''); + // $this->addSql('COMMENT ON COLUMN chill_person_household_members.endDate IS \'(DC2Type:date_immutable)\''); + // $this->addSql('ALTER TABLE chill_person_marital_status ALTER id TYPE VARCHAR(7)'); + // $this->addSql('DROP INDEX mobilenumber_trgm_idx'); + // $this->addSql('DROP INDEX fullnamecanonical_trgm_idx'); + // $this->addSql('DROP INDEX chill_custom_fullnamecanonical_only_trgm_idx_gin'); + // $this->addSql('DROP INDEX phonenumber_trgm_idx'); + // $this->addSql('ALTER TABLE chill_person_person DROP cfdata_old'); + // $this->addSql('ALTER TABLE chill_person_person ALTER maritalstatus_id TYPE VARCHAR(7)'); + // $this->addSql('ALTER TABLE chill_person_person ALTER phonenumber DROP DEFAULT'); + // $this->addSql('ALTER TABLE chill_person_person ALTER cfdata SET NOT NULL'); + // $this->addSql('ALTER TABLE chill_person_person ALTER mobilenumber DROP DEFAULT'); + // $this->addSql('ALTER INDEX idx_person_center RENAME TO IDX_BF210A145932F377'); + // $this->addSql('ALTER INDEX idx_3370d4403818da5 RENAME TO IDX_BF210A143818DA5'); + // $this->addSql('ALTER INDEX idx_bf210a145521be40 RENAME TO IDX_BF210A14D7D03CE3'); + // $this->addSql('ALTER INDEX idx_3370d4401c9da55 RENAME TO IDX_BF210A141C9DA55'); + // $this->addSql('ALTER TABLE persons_spoken_languages DROP CONSTRAINT FK_7201106F217BBB47'); + // $this->addSql('ALTER TABLE persons_spoken_languages DROP CONSTRAINT FK_7201106F82F1BAF4'); + // $this->addSql('ALTER TABLE persons_spoken_languages ADD CONSTRAINT FK_7201106F217BBB47 FOREIGN KEY (person_id) REFERENCES chill_person_person (id) NOT DEFERRABLE INITIALLY IMMEDIATE'); + // $this->addSql('ALTER TABLE persons_spoken_languages ADD CONSTRAINT FK_7201106F82F1BAF4 FOREIGN KEY (language_id) REFERENCES language (id) NOT DEFERRABLE INITIALLY IMMEDIATE'); + // $this->addSql('ALTER TABLE chill_person_relations ALTER isactive DROP NOT NULL'); + // $this->addSql('ALTER TABLE custom_field_long_choice_options ALTER internal_key DROP DEFAULT'); + // $this->addSql('ALTER TABLE customfield ALTER required DROP DEFAULT'); + // $this->addSql('ALTER TABLE customfield ALTER required SET NOT NULL'); + // $this->addSql('ALTER INDEX idx_40fb5d6dfec418b RENAME TO IDX_7A6FDBEFEC418B'); + // $this->addSql('ALTER INDEX idx_286dc95df53b66 RENAME TO IDX_7A48DF7F5DF53B66'); + // $this->addSql('ALTER TABLE customfieldsgroup ALTER options DROP DEFAULT'); + // $this->addSql('ALTER TABLE customfieldsgroup ALTER options SET NOT NULL'); + // $this->addSql('ALTER TABLE chill_vendee.geographical_unit_association ADD CONSTRAINT FK_981D5C95D58FA2A4 FOREIGN KEY (geographicalUnit_id) REFERENCES chill_vendee.geographical_unit (id) NOT DEFERRABLE INITIALLY IMMEDIATE'); + // $this->addSql('ALTER TABLE chill_vendee.geographical_unit_association ADD CONSTRAINT FK_981D5C95A76ED395 FOREIGN KEY (user_id) REFERENCES users (id) NOT DEFERRABLE INITIALLY IMMEDIATE'); + // $this->addSql('ALTER INDEX idx_a14d8f3d447bbb3b RENAME TO IDX_A14D8F3D96DF1F10'); + // $this->addSql('ALTER TABLE permission_groups ALTER flags DROP DEFAULT'); + // $this->addSql('DROP INDEX "primary"'); + // $this->addSql('ALTER TABLE chill_vendee.security_profile_jobs ADD PRIMARY KEY (profile_id, job_id)'); + // $this->addSql('ALTER TABLE chill_vendee.security_profile_action ALTER profile_id DROP NOT NULL'); + // $this->addSql('ALTER TABLE chill_vendee.security_profile_action ALTER action SET NOT NULL'); + // $this->addSql('DROP INDEX chill_custom_canonicalized_trgm_idx_gist'); + // $this->addSql('DROP INDEX uniq_93f763ae217bbb47'); + // $this->addSql('ALTER TABLE chill_vendee.vendee_person ALTER situationprofessionellestartdate TYPE DATE'); + // $this->addSql('ALTER TABLE chill_vendee.vendee_person ALTER situationprofessionellestartdate DROP DEFAULT'); + // $this->addSql('COMMENT ON COLUMN chill_vendee.vendee_person.situationProfessionelleStartDate IS \'(DC2Type:date_immutable)\''); + // $this->addSql('ALTER TABLE chill_vendee.vendeeperson_entourage ADD CONSTRAINT FK_4D319FFEF57537C3 FOREIGN KEY (vendeeperson_id) REFERENCES chill_vendee.vendee_person (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE'); + // $this->addSql('ALTER INDEX chill_vendee.idx_1a4b602deef79338 RENAME TO IDX_DD0A4C00EEF79338'); + } + + public function down(Schema $schema): void + { + // this down() migration is auto-generated, please modify it to your needs + // $this->addSql('CREATE SCHEMA public'); + $this->addSql('ALTER TABLE chill_person_resource DROP CONSTRAINT FK_FA5B7D9230602CA9'); + $this->addSql('DROP SEQUENCE chill_person_resource_id_seq CASCADE'); + $this->addSql('DROP SEQUENCE chill_person_resource_kind_id_seq CASCADE'); + // $this->addSql('CREATE SEQUENCE chill_person_accompanying_period_work_eval_doc_id_seq INCREMENT BY 1 MINVALUE 1 START 1'); + // $this->addSql('CREATE TABLE chill_main_address_legacy (id INT DEFAULT NULL, postcode_id INT DEFAULT NULL, street VARCHAR(255) DEFAULT NULL, streetnumber VARCHAR(255) DEFAULT NULL, validfrom DATE DEFAULT NULL, isnoaddress BOOLEAN DEFAULT NULL, customs JSONB DEFAULT NULL, floor VARCHAR(16) DEFAULT NULL, corridor VARCHAR(16) DEFAULT NULL, steps VARCHAR(16) DEFAULT NULL, buildingname VARCHAR(255) DEFAULT NULL, flat VARCHAR(16) DEFAULT NULL, distribution VARCHAR(255) DEFAULT NULL, extra VARCHAR(255) DEFAULT NULL, validto DATE DEFAULT NULL, point VARCHAR(255) DEFAULT NULL, linkedtothirdparty_id INT DEFAULT NULL)'); + $this->addSql('DROP TABLE chill_person_resource'); + $this->addSql('DROP TABLE chill_person_resource_kind'); + // $this->addSql('ALTER TABLE chill_main_location_type ALTER active SET DEFAULT \'true\''); + // $this->addSql('ALTER TABLE chill_main_location_type ALTER editableByUsers SET DEFAULT \'true\''); + // $this->addSql('ALTER TABLE chill_main_location_type ALTER editableByUsers DROP NOT NULL'); + // $this->addSql('ALTER TABLE persons_spoken_languages DROP CONSTRAINT fk_7201106f217bbb47'); + // $this->addSql('ALTER TABLE persons_spoken_languages DROP CONSTRAINT fk_7201106f82f1baf4'); + // $this->addSql('ALTER TABLE persons_spoken_languages ADD CONSTRAINT fk_7201106f217bbb47 FOREIGN KEY (person_id) REFERENCES chill_person_person (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE'); + // $this->addSql('ALTER TABLE persons_spoken_languages ADD CONSTRAINT fk_7201106f82f1baf4 FOREIGN KEY (language_id) REFERENCES language (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE'); + // $this->addSql('ALTER INDEX idx_589d51b4ef1a9d84 RENAME TO idx_154a075fef1a9d84'); + // $this->addSql('ALTER INDEX idx_589d51b4a76ed395 RENAME TO idx_154a075fa76ed395'); + // $this->addSql('ALTER TABLE chill_vendee.vendee_person ALTER situationProfessionelleStartDate TYPE DATE'); + // $this->addSql('ALTER TABLE chill_vendee.vendee_person ALTER situationProfessionelleStartDate DROP DEFAULT'); + // $this->addSql('COMMENT ON COLUMN chill_vendee.vendee_person.situationprofessionellestartdate IS NULL'); + // $this->addSql('CREATE UNIQUE INDEX uniq_93f763ae217bbb47 ON chill_vendee.vendee_person (person_id)'); + // $this->addSql('ALTER TABLE chill_vendee.geographical_unit_association DROP CONSTRAINT FK_981D5C95D58FA2A4'); + // $this->addSql('ALTER TABLE chill_vendee.geographical_unit_association DROP CONSTRAINT FK_981D5C95A76ED395'); + // $this->addSql('DROP INDEX person_unique'); + // $this->addSql('DROP INDEX thirdparty_unique'); + // $this->addSql('CREATE UNIQUE INDEX person_unique ON chill_person_accompanying_period_resource (person_id, accompanyingperiod_id) WHERE (person_id IS NOT NULL)'); + // $this->addSql('CREATE UNIQUE INDEX thirdparty_unique ON chill_person_accompanying_period_resource (thirdparty_id, accompanyingperiod_id) WHERE (thirdparty_id IS NOT NULL)'); + // $this->addSql('CREATE INDEX participations_no_overlap ON chill_person_accompanying_period_participation (person_id, accompanyingperiod_id)'); + // $this->addSql('ALTER TABLE chill_main_location ALTER active SET DEFAULT \'true\''); + // $this->addSql('ALTER INDEX idx_ac74095aa76ed395 RENAME TO idx_55026b0ca76ed395'); + // $this->addSql('ALTER INDEX idx_ac74095a682b5931 RENAME TO idx_55026b0c682b5931'); + // $this->addSql('ALTER INDEX idx_ac74095a217bbb47 RENAME TO idx_55026b0c217bbb47'); + // $this->addSql('ALTER INDEX idx_ac74095ac54c8c93 RENAME TO idx_55026b0cc54c8c93'); + // $this->addSql('ALTER INDEX idx_ac74095ad7fa8ef0 RENAME TO IDX_AC74095A550B0C53'); + // $this->addSql('ALTER TABLE chill_person_person ADD cfdata_old TEXT DEFAULT NULL'); + // $this->addSql('ALTER TABLE chill_person_person ALTER cFData DROP NOT NULL'); + // $this->addSql('ALTER TABLE chill_person_person ALTER mobilenumber SET DEFAULT \'\''); + // $this->addSql('ALTER TABLE chill_person_person ALTER phonenumber SET DEFAULT \'\''); + // $this->addSql('ALTER TABLE chill_person_person ALTER maritalStatus_id TYPE VARCHAR(10)'); + // $this->addSql('COMMENT ON COLUMN chill_person_person.cfdata_old IS \'(DC2Type:array)\''); + // $this->addSql('CREATE INDEX mobilenumber_trgm_idx ON chill_person_person (mobilenumber)'); + // $this->addSql('CREATE INDEX fullnamecanonical_trgm_idx ON chill_person_person (center_id, fullnamecanonical)'); + // $this->addSql('CREATE INDEX chill_custom_fullnamecanonical_only_trgm_idx_gin ON chill_person_person (fullnamecanonical)'); + // $this->addSql('CREATE INDEX phonenumber_trgm_idx ON chill_person_person (phonenumber)'); + // $this->addSql('ALTER INDEX idx_bf210a141c9da55 RENAME TO idx_3370d4401c9da55'); + // $this->addSql('ALTER INDEX idx_bf210a143818da5 RENAME TO idx_3370d4403818da5'); + // $this->addSql('ALTER INDEX idx_bf210a145932f377 RENAME TO idx_person_center'); + // $this->addSql('ALTER INDEX idx_bf210a14d7d03ce3 RENAME TO IDX_BF210A145521BE40'); + // $this->addSql('ALTER TABLE chill_person_household ADD CONSTRAINT fk_household_comment_embeddable_user FOREIGN KEY (comment_members_userid) REFERENCES users (id) NOT DEFERRABLE INITIALLY IMMEDIATE'); + // $this->addSql('CREATE INDEX IDX_BE50A270116F5FA9 ON chill_person_household (comment_members_userid)'); + // $this->addSql('CREATE INDEX idx_b694fb3616d9d9b ON chill_person_accompanying_period_work (handlingthierparty_id)'); + // $this->addSql('ALTER TABLE chill_main_address ADD customs JSONB DEFAULT \'[]\''); + // $this->addSql('ALTER TABLE chill_main_address ALTER isNoAddress SET DEFAULT \'false\''); + // $this->addSql('ALTER TABLE chill_main_address ALTER point TYPE VARCHAR(255)'); + // $this->addSql('ALTER TABLE chill_main_address ALTER point DROP DEFAULT'); + // $this->addSql('CREATE INDEX chill_custom_main_address_filtering_idx ON chill_main_address (id, validfrom, validto)'); + // $this->addSql('ALTER TABLE chill_vendee.vendeeperson_entourage DROP CONSTRAINT FK_4D319FFEF57537C3'); + // $this->addSql('ALTER TABLE chill_person_household_members ALTER endDate TYPE DATE'); + // $this->addSql('ALTER TABLE chill_person_household_members ALTER endDate DROP DEFAULT'); + // $this->addSql('ALTER TABLE chill_person_household_members ALTER startDate TYPE DATE'); + // $this->addSql('ALTER TABLE chill_person_household_members ALTER startDate DROP DEFAULT'); + // $this->addSql('COMMENT ON COLUMN chill_person_household_members.enddate IS NULL'); + // $this->addSql('COMMENT ON COLUMN chill_person_household_members.startdate IS NULL'); + // $this->addSql('CREATE INDEX household_members_not_overlaps ON chill_person_household_members (person_id) WHERE (sharedhousehold IS TRUE)'); + // $this->addSql('CREATE INDEX chill_custom_person_household_members_sharing_idx ON chill_person_household_members (person_id, startdate, enddate, household_id) WHERE (sharedhousehold IS TRUE)'); + // $this->addSql('ALTER INDEX chill_vendee.idx_dd0a4c00eef79338 RENAME TO idx_1a4b602deef79338'); + // $this->addSql('CREATE INDEX chill_custom_canonicalized_trgm_idx_gist ON chill_3party.third_party (canonicalized) WHERE (active IS TRUE)'); + // $this->addSql('ALTER INDEX idx_a14d8f3d96df1f10 RENAME TO idx_a14d8f3d447bbb3b'); + // $this->addSql('DROP INDEX address_refid'); + // $this->addSql('ALTER TABLE chill_main_address_reference ALTER point TYPE VARCHAR(255)'); + // $this->addSql('ALTER TABLE chill_main_address_reference ALTER point DROP DEFAULT'); + // $this->addSql('CREATE INDEX chill_internal_address_reference_canonicalized ON chill_main_address_reference (postcode_id, addresscanonical)'); + // $this->addSql('CREATE INDEX address_refid ON chill_main_address_reference (refid) WHERE ((refid)::text <> \'\'::text)'); + // $this->addSql('ALTER INDEX idx_e260a868504cb38d RENAME TO idx_64a4a621504cb38d'); + // $this->addSql('ALTER TABLE chill_vendee.security_profile_action ALTER profile_id SET NOT NULL'); + // $this->addSql('ALTER TABLE chill_vendee.security_profile_action ALTER action DROP NOT NULL'); + // $this->addSql('DROP INDEX security_profile_jobs_pkey'); + // $this->addSql('ALTER TABLE chill_vendee.security_profile_jobs ADD PRIMARY KEY (job_id, profile_id)'); + // $this->addSql('CREATE INDEX internal_center_geom_idx ON chill_vendee.center_polygon (geom)'); + // $this->addSql('DROP INDEX search_name_code'); + // $this->addSql('ALTER TABLE chill_main_postal_code ALTER center TYPE VARCHAR(255)'); + // $this->addSql('ALTER TABLE chill_main_postal_code ALTER center DROP DEFAULT'); + // $this->addSql('CREATE INDEX chill_internal_postal_code_canonicalized ON chill_main_postal_code (canonical) WHERE (origin = 0)'); + // $this->addSql('ALTER TABLE permission_groups ALTER flags SET DEFAULT \'[]\''); + // $this->addSql('ALTER TABLE chill_person_marital_status ALTER id TYPE VARCHAR(10)'); + // $this->addSql('ALTER TABLE chill_person_relations ALTER isActive SET NOT NULL'); + // $this->addSql('ALTER TABLE custom_field_long_choice_options ALTER internal_key SET DEFAULT \'\''); + // $this->addSql('ALTER INDEX idx_7a48df7f5df53b66 RENAME TO idx_286dc95df53b66'); + // $this->addSql('ALTER TABLE customfield ALTER required SET DEFAULT \'false\''); + // $this->addSql('ALTER TABLE customfield ALTER required DROP NOT NULL'); + // $this->addSql('ALTER INDEX idx_7a6fdbefec418b RENAME TO idx_40fb5d6dfec418b'); + // $this->addSql('ALTER TABLE customfieldsgroup ALTER options SET DEFAULT \'{}\''); + // $this->addSql('ALTER TABLE customfieldsgroup ALTER options DROP NOT NULL'); + // $this->addSql('ALTER TABLE activityreason ALTER name DROP NOT NULL'); + // $this->addSql('ALTER INDEX idx_af82522312469de2 RENAME TO idx_654a2fcd12469de2'); + // $this->addSql('ALTER TABLE activityreasoncategory ALTER name DROP NOT NULL'); + } +} From ff0b0678a5de58abc49f76e8cd59a2fde1b655b4 Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Tue, 18 Jan 2022 11:11:29 +0100 Subject: [PATCH 02/30] changelog entry added --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8c78c7a3c..89e67e21c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -20,6 +20,7 @@ and this project adheres to * vuejs: add validation on required fields for AddPerson, Address and Location components * vuejs: treat 422 validation errors in locations and AddPerson components * [person]: space added between deathdate and age in twig renderbox (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/380) +* [person]: possibility to add person resources (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/382) ## Test releases From 6e4bfd45c6ccd4104e5b3244fbb0e6ac18738293 Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Tue, 18 Jan 2022 13:55:09 +0100 Subject: [PATCH 03/30] route and menu entry added in person menu + start of templates/controller --- .../Controller/PersonResourceController.php | 43 +++++++++++++ .../Menu/PersonMenuBuilder.php | 10 +++ .../Repository/PersonResourceRepository.php | 61 +++++++++++++++++++ .../views/PersonResource/list.html.twig | 32 ++++++++++ .../ChillPersonBundle/config/routes.yaml | 4 ++ .../translations/messages.fr.yml | 5 ++ 6 files changed, 155 insertions(+) create mode 100644 src/Bundle/ChillPersonBundle/Controller/PersonResourceController.php create mode 100644 src/Bundle/ChillPersonBundle/Repository/PersonResourceRepository.php create mode 100644 src/Bundle/ChillPersonBundle/Resources/views/PersonResource/list.html.twig diff --git a/src/Bundle/ChillPersonBundle/Controller/PersonResourceController.php b/src/Bundle/ChillPersonBundle/Controller/PersonResourceController.php new file mode 100644 index 000000000..e02b6e4c3 --- /dev/null +++ b/src/Bundle/ChillPersonBundle/Controller/PersonResourceController.php @@ -0,0 +1,43 @@ +personResourceRepository = $personResourceRepository; + $this->personRepository = $personRepository; + } + + public function listAction($person_id) + { + dump($person_id); + $person = $this->personRepository->find($person_id); + dump($person); + return $this->render( + 'ChillPersonBundle:PersonResource:list.html.twig', + [ + 'person' => $person + ] + ); + } +} \ No newline at end of file diff --git a/src/Bundle/ChillPersonBundle/Menu/PersonMenuBuilder.php b/src/Bundle/ChillPersonBundle/Menu/PersonMenuBuilder.php index d83fa29dd..228309737 100644 --- a/src/Bundle/ChillPersonBundle/Menu/PersonMenuBuilder.php +++ b/src/Bundle/ChillPersonBundle/Menu/PersonMenuBuilder.php @@ -96,6 +96,16 @@ class PersonMenuBuilder implements LocalMenuBuilderInterface 'order' => 100, ]); } + + $menu->addChild($this->translator->trans('person_resources_menu'), [ + 'route' => 'chill_person_resource_list', + 'routeParameters' => [ + 'person_id' => $parameters['person']->getId(), + ], + ]) + ->setExtras([ + 'order' => 99999, + ]); } public static function getMenuIds(): array diff --git a/src/Bundle/ChillPersonBundle/Repository/PersonResourceRepository.php b/src/Bundle/ChillPersonBundle/Repository/PersonResourceRepository.php new file mode 100644 index 000000000..1874bec05 --- /dev/null +++ b/src/Bundle/ChillPersonBundle/Repository/PersonResourceRepository.php @@ -0,0 +1,61 @@ +repository = $entityManager->getRepository(PersonResource::class); + } + + public function find($id): ?PersonResource + { + return $this->repository->find($id); + } + + /** + * @return PersonResource[] + */ + public function findAll(): array + { + return $this->repository->findAll(); + } + + /** + * @param mixed|null $limit + * @param mixed|null $offset + * + * @return PersonResource[] + */ + public function findBy(array $criteria, ?array $orderBy = null, $limit = null, $offset = null): array + { + return $this->repository->findBy($criteria, $orderBy, $limit, $offset); + } + + public function findOneBy(array $criteria): ?PersonResource + { + return $this->repository->findOneBy($criteria); + } + + public function getClassName(): string + { + return PersonResource::class; + } +} \ No newline at end of file diff --git a/src/Bundle/ChillPersonBundle/Resources/views/PersonResource/list.html.twig b/src/Bundle/ChillPersonBundle/Resources/views/PersonResource/list.html.twig new file mode 100644 index 000000000..8e943c43a --- /dev/null +++ b/src/Bundle/ChillPersonBundle/Resources/views/PersonResource/list.html.twig @@ -0,0 +1,32 @@ +{% extends "@ChillPerson/Person/layout.html.twig" %} + +{% set activeRouteKey = 'chill_person_resource_list' %} + +{% block title %}{{ 'Person resources'|trans|capitalize ~ ' ' ~ person|chill_entity_render_string }}{% endblock %} + +{% block personcontent %} + +{{ person }} +
+
+
+
Hello
+
there
+
+
+
How
+
are
+
+
+
+
+
you
+
doing
+
+
+
today
+
?
+
+
+
+{% endblock %} \ No newline at end of file diff --git a/src/Bundle/ChillPersonBundle/config/routes.yaml b/src/Bundle/ChillPersonBundle/config/routes.yaml index bbcb7c39b..3fbf38c0d 100644 --- a/src/Bundle/ChillPersonBundle/config/routes.yaml +++ b/src/Bundle/ChillPersonBundle/config/routes.yaml @@ -55,6 +55,10 @@ chill_person_accompanying_period_re_open: path: /{_locale}/person/{person_id}/accompanying-period/{period_id}/re-open controller: Chill\PersonBundle\Controller\AccompanyingPeriodController::reOpenAction +chill_person_resource_list: + path: /{_locale}/person/resource/{person_id}/general + controller: Chill\PersonBundle\Controller\PersonResourceController::listAction + chill_person_address_list: path: /{_locale}/person/{person_id}/address/list controller: Chill\PersonBundle\Controller\PersonAddressController::listAction diff --git a/src/Bundle/ChillPersonBundle/translations/messages.fr.yml b/src/Bundle/ChillPersonBundle/translations/messages.fr.yml index 5d0e2b16a..e2758034e 100644 --- a/src/Bundle/ChillPersonBundle/translations/messages.fr.yml +++ b/src/Bundle/ChillPersonBundle/translations/messages.fr.yml @@ -220,6 +220,11 @@ Delete accompanying period: Supprimer la période d'accompagnement Are you sure you want to remove the accompanying period "%id%" ?: Êtes-vous sûr de vouloir supprimer la période d'accompagnement %id% ? The accompanying course has been successfully removed.: La période d'accompagnement a été supprimée. +# person resource + +person_resources_menu: "Ressources" +Person resources: 'Réssources de la personne' + # pickAPersonType Pick a person: Choisir une personne From 58ac4b01ef9f61a72a23a8d40155d15ea3de7911 Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Tue, 18 Jan 2022 14:54:03 +0100 Subject: [PATCH 04/30] form created + general layout of templates --- .../Controller/PersonResourceController.php | 9 ++- .../Form/PersonResourceType.php | 79 +++++++++++++++++++ .../views/PersonResource/create.html.twig | 24 ++++++ .../views/PersonResource/list.html.twig | 18 +++-- .../translations/messages.fr.yml | 3 +- 5 files changed, 121 insertions(+), 12 deletions(-) create mode 100644 src/Bundle/ChillPersonBundle/Form/PersonResourceType.php create mode 100644 src/Bundle/ChillPersonBundle/Resources/views/PersonResource/create.html.twig diff --git a/src/Bundle/ChillPersonBundle/Controller/PersonResourceController.php b/src/Bundle/ChillPersonBundle/Controller/PersonResourceController.php index e02b6e4c3..6db871e5b 100644 --- a/src/Bundle/ChillPersonBundle/Controller/PersonResourceController.php +++ b/src/Bundle/ChillPersonBundle/Controller/PersonResourceController.php @@ -11,6 +11,7 @@ declare(strict_types=1); namespace Chill\PersonBundle\Controller; +use Chill\PersonBundle\Form\PersonResourceType; use Chill\PersonBundle\Repository\PersonRepository; use Chill\PersonBundle\Repository\PersonResourceRepository; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; @@ -30,13 +31,15 @@ final class PersonResourceController extends AbstractController public function listAction($person_id) { - dump($person_id); $person = $this->personRepository->find($person_id); - dump($person); + + $form = $this->createForm(PersonResourceType::class); + return $this->render( 'ChillPersonBundle:PersonResource:list.html.twig', [ - 'person' => $person + 'person' => $person, + 'form' => $form->createView() ] ); } diff --git a/src/Bundle/ChillPersonBundle/Form/PersonResourceType.php b/src/Bundle/ChillPersonBundle/Form/PersonResourceType.php new file mode 100644 index 000000000..8863d705c --- /dev/null +++ b/src/Bundle/ChillPersonBundle/Form/PersonResourceType.php @@ -0,0 +1,79 @@ +categoryRender = $categoryRender; + } + + public function buildForm(FormBuilderInterface $builder, array $options) + { + $builder + ->add('kind', EntityType::class, [ + 'label' => 'Type', + 'required' => true, + 'class' => PersonResourceKind::class, + 'query_builder' => static function (EntityRepository $er) { + $qb = $er->createQueryBuilder('pr'); + $qb->where($qb->expr()->eq('pr.isActive', 'TRUE')); + return $qb; + }, + 'choice_label' => function (PersonResourceKind $personResourceKind) { + $options = []; + return $this->categoryRender->renderString($personResourceKind, $options); + } + ]) + ->add('linkedEntity', ChoiceType::class, [ + 'choices' => [ + 'Usager' => 'person', + 'Tiers' => 'thirdparty', + 'Description libre' => 'freeText' + ], + 'expanded' => true, + 'label' => 'Associer un' + ]) + ->add('comment', ChillTextareaType::class, [ + 'label' => 'Note', + 'required' => false + ]); + } + + public function configureOptions(OptionsResolver $resolver): void + { + $resolver->setDefaults([ + 'data_class' => PersonResource::class, + ]); + } + + // public function getBlockPrefix(): string + // { + // return 'chill_personbundle_personresource'; + // } + +} \ No newline at end of file diff --git a/src/Bundle/ChillPersonBundle/Resources/views/PersonResource/create.html.twig b/src/Bundle/ChillPersonBundle/Resources/views/PersonResource/create.html.twig new file mode 100644 index 000000000..9ba297d8b --- /dev/null +++ b/src/Bundle/ChillPersonBundle/Resources/views/PersonResource/create.html.twig @@ -0,0 +1,24 @@ +
+ +

{{ 'Add a person resource'|trans }}

+ + {{ form_start(form, {'attr' : {'id' : 'create-form'}}) }} + + {{ form_row(form.kind) }} + + {{ form_row(form.linkedEntity) }} + + {{ form_row(form.comment) }} + + + + {{ form_end(form) }} + +
\ No newline at end of file diff --git a/src/Bundle/ChillPersonBundle/Resources/views/PersonResource/list.html.twig b/src/Bundle/ChillPersonBundle/Resources/views/PersonResource/list.html.twig index 8e943c43a..b931c4f95 100644 --- a/src/Bundle/ChillPersonBundle/Resources/views/PersonResource/list.html.twig +++ b/src/Bundle/ChillPersonBundle/Resources/views/PersonResource/list.html.twig @@ -6,27 +6,29 @@ {% block personcontent %} -{{ person }}
-
Hello
-
there
+
Name of resource
+
kind of resource
-
+ {#
How
are
-
+
#}
-
you
+
comment zone
doing
-
today
-
?
+ {#
today
#} +
Buttons
+ +{% include "@ChillPerson/PersonResource/create.html.twig" %} + {% endblock %} \ No newline at end of file diff --git a/src/Bundle/ChillPersonBundle/translations/messages.fr.yml b/src/Bundle/ChillPersonBundle/translations/messages.fr.yml index e2758034e..e7d4b3a1b 100644 --- a/src/Bundle/ChillPersonBundle/translations/messages.fr.yml +++ b/src/Bundle/ChillPersonBundle/translations/messages.fr.yml @@ -223,7 +223,8 @@ The accompanying course has been successfully removed.: La période d'accompagne # person resource person_resources_menu: "Ressources" -Person resources: 'Réssources de la personne' +Person resources: "Réssources de la personne" +Add a person resource: "Ajouter une réssource" # pickAPersonType Pick a person: Choisir une personne From 001e2f96229007d7737781dae28a355fd32662e8 Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Wed, 19 Jan 2022 09:48:39 +0100 Subject: [PATCH 05/30] js files put in place + select menus added for selecting person/thirdparty/... show-hide not working yet --- .../Controller/PersonResourceController.php | 24 ++++++++++- .../Entity/Person/PersonResourceKind.php | 10 ++--- .../Form/PersonResourceType.php | 40 ++++++++++++++++--- .../public/page/person_resource/index.js | 33 +++++++++++++++ .../views/PersonResource/create.html.twig | 14 ++++++- .../views/PersonResource/list.html.twig | 6 ++- .../ChillPersonBundle/chill.webpack.config.js | 1 + .../translations/messages.fr.yml | 4 +- 8 files changed, 116 insertions(+), 16 deletions(-) create mode 100644 src/Bundle/ChillPersonBundle/Resources/public/page/person_resource/index.js diff --git a/src/Bundle/ChillPersonBundle/Controller/PersonResourceController.php b/src/Bundle/ChillPersonBundle/Controller/PersonResourceController.php index 6db871e5b..799967c82 100644 --- a/src/Bundle/ChillPersonBundle/Controller/PersonResourceController.php +++ b/src/Bundle/ChillPersonBundle/Controller/PersonResourceController.php @@ -11,30 +11,50 @@ declare(strict_types=1); namespace Chill\PersonBundle\Controller; +use Chill\PersonBundle\Entity\Person\PersonResource; use Chill\PersonBundle\Form\PersonResourceType; use Chill\PersonBundle\Repository\PersonRepository; use Chill\PersonBundle\Repository\PersonResourceRepository; +use Doctrine\ORM\EntityManagerInterface; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; +use Symfony\Component\HttpFoundation\Request; final class PersonResourceController extends AbstractController { private PersonResourceRepository $personResourceRepository; + private PersonRepository $personRepository; + private EntityManagerInterface $em; public function __construct( PersonResourceRepository $personResourceRepository, - PersonRepository $personRepository + PersonRepository $personRepository, + EntityManagerInterface $em ) { $this->personResourceRepository = $personResourceRepository; $this->personRepository = $personRepository; + $this->em = $em; } - public function listAction($person_id) + public function listAction(Request $request, $person_id) { $person = $this->personRepository->find($person_id); + $personResource = new PersonResource(); $form = $this->createForm(PersonResourceType::class); + $form->handleRequest($request); + + if ($request->getMethod() === Request::METHOD_POST && $form->isValid()) { + $this->em->persist($personResource); + $this->em->flush(); + + return $this->redirectToRoute( + 'chill_person_resource', + ['person_id' => $person->getId()] + ); + } + return $this->render( 'ChillPersonBundle:PersonResource:list.html.twig', [ diff --git a/src/Bundle/ChillPersonBundle/Entity/Person/PersonResourceKind.php b/src/Bundle/ChillPersonBundle/Entity/Person/PersonResourceKind.php index 03b2aa858..619382f68 100644 --- a/src/Bundle/ChillPersonBundle/Entity/Person/PersonResourceKind.php +++ b/src/Bundle/ChillPersonBundle/Entity/Person/PersonResourceKind.php @@ -31,7 +31,7 @@ class PersonResourceKind /** * @ORM\Column(type="json", length=255) */ - private array $label; + private array $title; /** * @ORM\Column(type="boolean") @@ -48,14 +48,14 @@ class PersonResourceKind return $this->isActive; } - public function getLabel(): ?array + public function getTitle(): ?array { - return $this->label; + return $this->title; } - public function setLabel(array $label): self + public function setTitle(array $title): self { - $this->label = $label; + $this->title = $title; return $this; } diff --git a/src/Bundle/ChillPersonBundle/Form/PersonResourceType.php b/src/Bundle/ChillPersonBundle/Form/PersonResourceType.php index 8863d705c..fabc30e5e 100644 --- a/src/Bundle/ChillPersonBundle/Form/PersonResourceType.php +++ b/src/Bundle/ChillPersonBundle/Form/PersonResourceType.php @@ -13,8 +13,12 @@ namespace Chill\PersonBundle\Form; use Chill\AsideActivityBundle\Templating\Entity\CategoryRender; use Chill\MainBundle\Form\Type\ChillTextareaType; +use Chill\PersonBundle\Entity\Person; use Chill\PersonBundle\Entity\Person\PersonResource; use Chill\PersonBundle\Entity\Person\PersonResourceKind; +use Chill\PersonBundle\Templating\Entity\PersonRender; +use Chill\ThirdPartyBundle\Entity\ThirdParty; +use Chill\ThirdPartyBundle\Templating\Entity\ThirdPartyRender; use Doctrine\ORM\EntityRepository; use Symfony\Bridge\Doctrine\Form\Type\EntityType; use Symfony\Component\Form\AbstractType; @@ -26,10 +30,14 @@ use Symfony\Component\OptionsResolver\OptionsResolver; final class PersonResourceType extends AbstractType { private CategoryRender $categoryRender; + private PersonRender $personRender; + private ThirdPartyRender $thirdPartyRender; - public function __construct(CategoryRender $categoryRender) + public function __construct(CategoryRender $categoryRender, PersonRender $personRender, ThirdPartyRender $thirdPartyRender) { $this->categoryRender = $categoryRender; + $this->personRender = $personRender; + $this->thirdPartyRender = $thirdPartyRender; } public function buildForm(FormBuilderInterface $builder, array $options) @@ -58,6 +66,28 @@ final class PersonResourceType extends AbstractType 'expanded' => true, 'label' => 'Associer un' ]) + ->add('person', EntityType::class, [ + 'label' => 'Usager', + 'class' => Person::class, + 'required' => false, + 'choice_label' => function (Person $person) { + $options = []; + return $this->personRender->renderString($person, $options); + } + ]) + ->add('thirdparty', EntityType::class, [ + 'label' => 'Tiers', + 'class' => ThirdParty::class, + 'required' => false, + 'choice_label' => function (ThirdParty $thirdParty) { + $options = []; + return $this->thirdPartyRender->renderString($thirdParty, $options); + } + ]) + ->add('freetext', ChillTextareaType::class, [ + 'label' => 'Description libre', + 'required' => false + ]) ->add('comment', ChillTextareaType::class, [ 'label' => 'Note', 'required' => false @@ -71,9 +101,9 @@ final class PersonResourceType extends AbstractType ]); } - // public function getBlockPrefix(): string - // { - // return 'chill_personbundle_personresource'; - // } + public function getBlockPrefix(): string + { + return 'chill_personbundle_person_resource'; + } } \ No newline at end of file diff --git a/src/Bundle/ChillPersonBundle/Resources/public/page/person_resource/index.js b/src/Bundle/ChillPersonBundle/Resources/public/page/person_resource/index.js new file mode 100644 index 000000000..8ef2021f1 --- /dev/null +++ b/src/Bundle/ChillPersonBundle/Resources/public/page/person_resource/index.js @@ -0,0 +1,33 @@ +import {ShowHide} from 'ChillMainAssets/lib/show_hide/show_hide.js'; + +window.addEventListener('DOMContentLoaded', function() { + let + linkedEntityContainer = document.querySelector('#linked-entity'), + personContainer = document.querySelector('#person-entity'), + thirdpartyContainer = document.querySelector('#thirdparty-entity'), + freetextContainer = document.querySelector('#freetext-entity') + ; + + if (null === linkedEntityContainer) { + return; + } + + new ShowHide({ + debug: true, + load_event: null, + froms: [linkedEntityContainer], + container: [personContainer, thirdpartyContainer, freetextContainer], + test: function(containers, arg2, arg3) { + for (let container of containers) { + for (let input of container.querySelectorAll('input')) { + if (!input.checked) { + return true; + } else { + return false; + } + } + } + + }, + }) +}); diff --git a/src/Bundle/ChillPersonBundle/Resources/views/PersonResource/create.html.twig b/src/Bundle/ChillPersonBundle/Resources/views/PersonResource/create.html.twig index 9ba297d8b..74bdeb57e 100644 --- a/src/Bundle/ChillPersonBundle/Resources/views/PersonResource/create.html.twig +++ b/src/Bundle/ChillPersonBundle/Resources/views/PersonResource/create.html.twig @@ -6,7 +6,19 @@ {{ form_row(form.kind) }} - {{ form_row(form.linkedEntity) }} +
+ {{ form_row(form.linkedEntity) }} +
+ +
+ {{ form_row(form.person) }} +
+
+ {{ form_row(form.thirdparty) }} +
+
+ {{ form_row(form.freetext) }} +
{{ form_row(form.comment) }} diff --git a/src/Bundle/ChillPersonBundle/Resources/views/PersonResource/list.html.twig b/src/Bundle/ChillPersonBundle/Resources/views/PersonResource/list.html.twig index b931c4f95..844f39d41 100644 --- a/src/Bundle/ChillPersonBundle/Resources/views/PersonResource/list.html.twig +++ b/src/Bundle/ChillPersonBundle/Resources/views/PersonResource/list.html.twig @@ -20,7 +20,7 @@
comment zone
-
doing
+
....
{#
today
#} @@ -31,4 +31,8 @@ {% include "@ChillPerson/PersonResource/create.html.twig" %} +{% endblock %} + +{% block js %} + {# {{ encore_entry_script_tags('page_person_resource') }} #} {% endblock %} \ No newline at end of file diff --git a/src/Bundle/ChillPersonBundle/chill.webpack.config.js b/src/Bundle/ChillPersonBundle/chill.webpack.config.js index 7a8b79c7c..9cf6717fd 100644 --- a/src/Bundle/ChillPersonBundle/chill.webpack.config.js +++ b/src/Bundle/ChillPersonBundle/chill.webpack.config.js @@ -18,4 +18,5 @@ module.exports = function(encore, entries) encore.addEntry('page_person', __dirname + '/Resources/public/page/person/index.js'); encore.addEntry('page_accompanying_course_index_person_locate', __dirname + '/Resources/public/page/accompanying_course_index/person_locate.js'); encore.addEntry('page_accompanying_course_index_masonry', __dirname + '/Resources/public/page/accompanying_course_index/masonry.js'); + encore.addEntry('page_person_resource', __dirname + '/Resources/public/page/person_resource/index.js'); }; diff --git a/src/Bundle/ChillPersonBundle/translations/messages.fr.yml b/src/Bundle/ChillPersonBundle/translations/messages.fr.yml index e7d4b3a1b..7165d7084 100644 --- a/src/Bundle/ChillPersonBundle/translations/messages.fr.yml +++ b/src/Bundle/ChillPersonBundle/translations/messages.fr.yml @@ -223,8 +223,8 @@ The accompanying course has been successfully removed.: La période d'accompagne # person resource person_resources_menu: "Ressources" -Person resources: "Réssources de la personne" -Add a person resource: "Ajouter une réssource" +Person resources: "Ressources de la personne" +Add a person resource: "Ajouter une ressource" # pickAPersonType Pick a person: Choisir une personne From 96dc711b4ff102bd09c642896693aa9602b8c4bf Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Wed, 19 Jan 2022 19:38:57 +0100 Subject: [PATCH 06/30] migration adjusted --- .../migrations/Version20220118100237.php | 231 ------------------ .../migrations/Version20220119155944.php | 50 ++++ 2 files changed, 50 insertions(+), 231 deletions(-) delete mode 100644 src/Bundle/ChillPersonBundle/migrations/Version20220118100237.php create mode 100644 src/Bundle/ChillPersonBundle/migrations/Version20220119155944.php diff --git a/src/Bundle/ChillPersonBundle/migrations/Version20220118100237.php b/src/Bundle/ChillPersonBundle/migrations/Version20220118100237.php deleted file mode 100644 index 8f58b42b0..000000000 --- a/src/Bundle/ChillPersonBundle/migrations/Version20220118100237.php +++ /dev/null @@ -1,231 +0,0 @@ -addSql('DROP SEQUENCE chill_person_accompanying_period_work_eval_doc_id_seq CASCADE'); - $this->addSql('CREATE SEQUENCE chill_person_resource_id_seq INCREMENT BY 1 MINVALUE 1 START 1'); - $this->addSql('CREATE SEQUENCE chill_person_resource_kind_id_seq INCREMENT BY 1 MINVALUE 1 START 1'); - $this->addSql('CREATE TABLE chill_person_resource (id INT NOT NULL, person_id INT DEFAULT NULL, kind_id INT DEFAULT NULL, freeText TEXT DEFAULT NULL, createdAt TIMESTAMP(0) WITHOUT TIME ZONE NOT NULL, updatedAt TIMESTAMP(0) WITHOUT TIME ZONE DEFAULT NULL, comment_comment TEXT DEFAULT NULL, comment_date TIMESTAMP(0) WITHOUT TIME ZONE DEFAULT NULL, comment_userId INT DEFAULT NULL, personOwner_id INT NOT NULL, thirdParty_id INT DEFAULT NULL, createdBy_id INT NOT NULL, updatedBy_id INT DEFAULT NULL, PRIMARY KEY(id))'); - $this->addSql('CREATE INDEX IDX_FA5B7D92D19C515B ON chill_person_resource (personOwner_id)'); - $this->addSql('CREATE INDEX IDX_FA5B7D92217BBB47 ON chill_person_resource (person_id)'); - $this->addSql('CREATE INDEX IDX_FA5B7D923EA5CAB0 ON chill_person_resource (thirdParty_id)'); - $this->addSql('CREATE INDEX IDX_FA5B7D9230602CA9 ON chill_person_resource (kind_id)'); - $this->addSql('CREATE INDEX IDX_FA5B7D923174800F ON chill_person_resource (createdBy_id)'); - $this->addSql('CREATE INDEX IDX_FA5B7D9265FF1AEC ON chill_person_resource (updatedBy_id)'); - $this->addSql('CREATE TABLE chill_person_resource_kind (id INT NOT NULL, label JSON NOT NULL, isActive BOOLEAN NOT NULL, PRIMARY KEY(id))'); - $this->addSql('ALTER TABLE chill_person_resource ADD CONSTRAINT FK_FA5B7D92D19C515B FOREIGN KEY (personOwner_id) REFERENCES chill_person_person (id) NOT DEFERRABLE INITIALLY IMMEDIATE'); - $this->addSql('ALTER TABLE chill_person_resource ADD CONSTRAINT FK_FA5B7D92217BBB47 FOREIGN KEY (person_id) REFERENCES chill_person_person (id) NOT DEFERRABLE INITIALLY IMMEDIATE'); - $this->addSql('ALTER TABLE chill_person_resource ADD CONSTRAINT FK_FA5B7D923EA5CAB0 FOREIGN KEY (thirdParty_id) REFERENCES chill_3party.third_party (id) NOT DEFERRABLE INITIALLY IMMEDIATE'); - $this->addSql('ALTER TABLE chill_person_resource ADD CONSTRAINT FK_FA5B7D9230602CA9 FOREIGN KEY (kind_id) REFERENCES chill_person_resource_kind (id) NOT DEFERRABLE INITIALLY IMMEDIATE'); - $this->addSql('ALTER TABLE chill_person_resource ADD CONSTRAINT FK_FA5B7D923174800F FOREIGN KEY (createdBy_id) REFERENCES users (id) NOT DEFERRABLE INITIALLY IMMEDIATE'); - $this->addSql('ALTER TABLE chill_person_resource ADD CONSTRAINT FK_FA5B7D9265FF1AEC FOREIGN KEY (updatedBy_id) REFERENCES users (id) NOT DEFERRABLE INITIALLY IMMEDIATE'); - // $this->addSql('DROP TABLE chill_main_address_legacy'); - // $this->addSql('ALTER INDEX idx_ac74095a550b0c53 RENAME TO IDX_AC74095AD7FA8EF0'); - // $this->addSql('ALTER INDEX idx_55026b0cc54c8c93 RENAME TO IDX_AC74095AC54C8C93'); - // $this->addSql('ALTER INDEX idx_55026b0c217bbb47 RENAME TO IDX_AC74095A217BBB47'); - // $this->addSql('ALTER INDEX idx_55026b0c682b5931 RENAME TO IDX_AC74095A682B5931'); - // $this->addSql('ALTER INDEX idx_55026b0ca76ed395 RENAME TO IDX_AC74095AA76ED395'); - // $this->addSql('ALTER TABLE activityreason ALTER name SET NOT NULL'); - // $this->addSql('ALTER INDEX idx_654a2fcd12469de2 RENAME TO IDX_AF82522312469DE2'); - // $this->addSql('ALTER TABLE activityreasoncategory ALTER name SET NOT NULL'); - // $this->addSql('DROP INDEX internal_center_geom_idx'); - // $this->addSql('DROP INDEX chill_custom_main_address_filtering_idx'); - // $this->addSql('ALTER TABLE chill_main_address DROP customs'); - // $this->addSql('ALTER TABLE chill_main_address ALTER isnoaddress DROP DEFAULT'); - // $this->addSql('ALTER TABLE chill_main_address ALTER point TYPE geometry(POINT,4326)'); - // $this->addSql('ALTER TABLE chill_main_address ALTER point DROP DEFAULT'); - // $this->addSql('DROP INDEX chill_internal_address_reference_canonicalized'); - // $this->addSql('DROP INDEX address_refid'); - // $this->addSql('ALTER TABLE chill_main_address_reference ALTER point TYPE geometry(POINT,4326)'); - // $this->addSql('ALTER TABLE chill_main_address_reference ALTER point DROP DEFAULT'); - // $this->addSql('CREATE INDEX address_refid ON chill_main_address_reference (refId) WHERE refid != \'\''); - // $this->addSql('ALTER TABLE chill_main_location ALTER active DROP DEFAULT'); - // $this->addSql('ALTER TABLE chill_main_location_type ALTER active DROP DEFAULT'); - // $this->addSql('ALTER TABLE chill_main_location_type ALTER editablebyusers DROP DEFAULT'); - // $this->addSql('ALTER TABLE chill_main_location_type ALTER editablebyusers SET NOT NULL'); - // $this->addSql('ALTER INDEX idx_154a075fef1a9d84 RENAME TO IDX_589D51B4EF1A9D84'); - // $this->addSql('ALTER INDEX idx_154a075fa76ed395 RENAME TO IDX_589D51B4A76ED395'); - // $this->addSql('DROP INDEX chill_internal_postal_code_canonicalized'); - // $this->addSql('ALTER TABLE chill_main_postal_code ALTER center TYPE geometry(POINT,4326)'); - // $this->addSql('ALTER TABLE chill_main_postal_code ALTER center DROP DEFAULT'); - // $this->addSql('CREATE INDEX search_name_code ON chill_main_postal_code (code, label)'); - // $this->addSql('ALTER INDEX idx_64a4a621504cb38d RENAME TO IDX_E260A868504CB38D'); - // $this->addSql('DROP INDEX participations_no_overlap'); - // $this->addSql('DROP INDEX thirdparty_unique'); - // $this->addSql('DROP INDEX person_unique'); - // $this->addSql('CREATE UNIQUE INDEX thirdparty_unique ON chill_person_accompanying_period_resource (thirdparty_id, accompanyingperiod_id)'); - // $this->addSql('CREATE UNIQUE INDEX person_unique ON chill_person_accompanying_period_resource (person_id, accompanyingperiod_id)'); - // $this->addSql('ALTER TABLE chill_person_accompanying_period_work DROP CONSTRAINT fk_b694fb3616d9d9b'); - // $this->addSql('DROP INDEX idx_b694fb3616d9d9b'); - // $this->addSql('ALTER TABLE chill_person_household DROP CONSTRAINT fk_household_comment_embeddable_user'); - // $this->addSql('DROP INDEX IDX_BE50A270116F5FA9'); - // $this->addSql('DROP INDEX household_members_not_overlaps'); - // $this->addSql('DROP INDEX chill_custom_person_household_members_sharing_idx'); - // $this->addSql('ALTER TABLE chill_person_household_members ALTER startdate TYPE DATE'); - // $this->addSql('ALTER TABLE chill_person_household_members ALTER startdate DROP DEFAULT'); - // $this->addSql('ALTER TABLE chill_person_household_members ALTER enddate TYPE DATE'); - // $this->addSql('ALTER TABLE chill_person_household_members ALTER enddate DROP DEFAULT'); - // $this->addSql('COMMENT ON COLUMN chill_person_household_members.startDate IS \'(DC2Type:date_immutable)\''); - // $this->addSql('COMMENT ON COLUMN chill_person_household_members.endDate IS \'(DC2Type:date_immutable)\''); - // $this->addSql('ALTER TABLE chill_person_marital_status ALTER id TYPE VARCHAR(7)'); - // $this->addSql('DROP INDEX mobilenumber_trgm_idx'); - // $this->addSql('DROP INDEX fullnamecanonical_trgm_idx'); - // $this->addSql('DROP INDEX chill_custom_fullnamecanonical_only_trgm_idx_gin'); - // $this->addSql('DROP INDEX phonenumber_trgm_idx'); - // $this->addSql('ALTER TABLE chill_person_person DROP cfdata_old'); - // $this->addSql('ALTER TABLE chill_person_person ALTER maritalstatus_id TYPE VARCHAR(7)'); - // $this->addSql('ALTER TABLE chill_person_person ALTER phonenumber DROP DEFAULT'); - // $this->addSql('ALTER TABLE chill_person_person ALTER cfdata SET NOT NULL'); - // $this->addSql('ALTER TABLE chill_person_person ALTER mobilenumber DROP DEFAULT'); - // $this->addSql('ALTER INDEX idx_person_center RENAME TO IDX_BF210A145932F377'); - // $this->addSql('ALTER INDEX idx_3370d4403818da5 RENAME TO IDX_BF210A143818DA5'); - // $this->addSql('ALTER INDEX idx_bf210a145521be40 RENAME TO IDX_BF210A14D7D03CE3'); - // $this->addSql('ALTER INDEX idx_3370d4401c9da55 RENAME TO IDX_BF210A141C9DA55'); - // $this->addSql('ALTER TABLE persons_spoken_languages DROP CONSTRAINT FK_7201106F217BBB47'); - // $this->addSql('ALTER TABLE persons_spoken_languages DROP CONSTRAINT FK_7201106F82F1BAF4'); - // $this->addSql('ALTER TABLE persons_spoken_languages ADD CONSTRAINT FK_7201106F217BBB47 FOREIGN KEY (person_id) REFERENCES chill_person_person (id) NOT DEFERRABLE INITIALLY IMMEDIATE'); - // $this->addSql('ALTER TABLE persons_spoken_languages ADD CONSTRAINT FK_7201106F82F1BAF4 FOREIGN KEY (language_id) REFERENCES language (id) NOT DEFERRABLE INITIALLY IMMEDIATE'); - // $this->addSql('ALTER TABLE chill_person_relations ALTER isactive DROP NOT NULL'); - // $this->addSql('ALTER TABLE custom_field_long_choice_options ALTER internal_key DROP DEFAULT'); - // $this->addSql('ALTER TABLE customfield ALTER required DROP DEFAULT'); - // $this->addSql('ALTER TABLE customfield ALTER required SET NOT NULL'); - // $this->addSql('ALTER INDEX idx_40fb5d6dfec418b RENAME TO IDX_7A6FDBEFEC418B'); - // $this->addSql('ALTER INDEX idx_286dc95df53b66 RENAME TO IDX_7A48DF7F5DF53B66'); - // $this->addSql('ALTER TABLE customfieldsgroup ALTER options DROP DEFAULT'); - // $this->addSql('ALTER TABLE customfieldsgroup ALTER options SET NOT NULL'); - // $this->addSql('ALTER TABLE chill_vendee.geographical_unit_association ADD CONSTRAINT FK_981D5C95D58FA2A4 FOREIGN KEY (geographicalUnit_id) REFERENCES chill_vendee.geographical_unit (id) NOT DEFERRABLE INITIALLY IMMEDIATE'); - // $this->addSql('ALTER TABLE chill_vendee.geographical_unit_association ADD CONSTRAINT FK_981D5C95A76ED395 FOREIGN KEY (user_id) REFERENCES users (id) NOT DEFERRABLE INITIALLY IMMEDIATE'); - // $this->addSql('ALTER INDEX idx_a14d8f3d447bbb3b RENAME TO IDX_A14D8F3D96DF1F10'); - // $this->addSql('ALTER TABLE permission_groups ALTER flags DROP DEFAULT'); - // $this->addSql('DROP INDEX "primary"'); - // $this->addSql('ALTER TABLE chill_vendee.security_profile_jobs ADD PRIMARY KEY (profile_id, job_id)'); - // $this->addSql('ALTER TABLE chill_vendee.security_profile_action ALTER profile_id DROP NOT NULL'); - // $this->addSql('ALTER TABLE chill_vendee.security_profile_action ALTER action SET NOT NULL'); - // $this->addSql('DROP INDEX chill_custom_canonicalized_trgm_idx_gist'); - // $this->addSql('DROP INDEX uniq_93f763ae217bbb47'); - // $this->addSql('ALTER TABLE chill_vendee.vendee_person ALTER situationprofessionellestartdate TYPE DATE'); - // $this->addSql('ALTER TABLE chill_vendee.vendee_person ALTER situationprofessionellestartdate DROP DEFAULT'); - // $this->addSql('COMMENT ON COLUMN chill_vendee.vendee_person.situationProfessionelleStartDate IS \'(DC2Type:date_immutable)\''); - // $this->addSql('ALTER TABLE chill_vendee.vendeeperson_entourage ADD CONSTRAINT FK_4D319FFEF57537C3 FOREIGN KEY (vendeeperson_id) REFERENCES chill_vendee.vendee_person (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE'); - // $this->addSql('ALTER INDEX chill_vendee.idx_1a4b602deef79338 RENAME TO IDX_DD0A4C00EEF79338'); - } - - public function down(Schema $schema): void - { - // this down() migration is auto-generated, please modify it to your needs - // $this->addSql('CREATE SCHEMA public'); - $this->addSql('ALTER TABLE chill_person_resource DROP CONSTRAINT FK_FA5B7D9230602CA9'); - $this->addSql('DROP SEQUENCE chill_person_resource_id_seq CASCADE'); - $this->addSql('DROP SEQUENCE chill_person_resource_kind_id_seq CASCADE'); - // $this->addSql('CREATE SEQUENCE chill_person_accompanying_period_work_eval_doc_id_seq INCREMENT BY 1 MINVALUE 1 START 1'); - // $this->addSql('CREATE TABLE chill_main_address_legacy (id INT DEFAULT NULL, postcode_id INT DEFAULT NULL, street VARCHAR(255) DEFAULT NULL, streetnumber VARCHAR(255) DEFAULT NULL, validfrom DATE DEFAULT NULL, isnoaddress BOOLEAN DEFAULT NULL, customs JSONB DEFAULT NULL, floor VARCHAR(16) DEFAULT NULL, corridor VARCHAR(16) DEFAULT NULL, steps VARCHAR(16) DEFAULT NULL, buildingname VARCHAR(255) DEFAULT NULL, flat VARCHAR(16) DEFAULT NULL, distribution VARCHAR(255) DEFAULT NULL, extra VARCHAR(255) DEFAULT NULL, validto DATE DEFAULT NULL, point VARCHAR(255) DEFAULT NULL, linkedtothirdparty_id INT DEFAULT NULL)'); - $this->addSql('DROP TABLE chill_person_resource'); - $this->addSql('DROP TABLE chill_person_resource_kind'); - // $this->addSql('ALTER TABLE chill_main_location_type ALTER active SET DEFAULT \'true\''); - // $this->addSql('ALTER TABLE chill_main_location_type ALTER editableByUsers SET DEFAULT \'true\''); - // $this->addSql('ALTER TABLE chill_main_location_type ALTER editableByUsers DROP NOT NULL'); - // $this->addSql('ALTER TABLE persons_spoken_languages DROP CONSTRAINT fk_7201106f217bbb47'); - // $this->addSql('ALTER TABLE persons_spoken_languages DROP CONSTRAINT fk_7201106f82f1baf4'); - // $this->addSql('ALTER TABLE persons_spoken_languages ADD CONSTRAINT fk_7201106f217bbb47 FOREIGN KEY (person_id) REFERENCES chill_person_person (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE'); - // $this->addSql('ALTER TABLE persons_spoken_languages ADD CONSTRAINT fk_7201106f82f1baf4 FOREIGN KEY (language_id) REFERENCES language (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE'); - // $this->addSql('ALTER INDEX idx_589d51b4ef1a9d84 RENAME TO idx_154a075fef1a9d84'); - // $this->addSql('ALTER INDEX idx_589d51b4a76ed395 RENAME TO idx_154a075fa76ed395'); - // $this->addSql('ALTER TABLE chill_vendee.vendee_person ALTER situationProfessionelleStartDate TYPE DATE'); - // $this->addSql('ALTER TABLE chill_vendee.vendee_person ALTER situationProfessionelleStartDate DROP DEFAULT'); - // $this->addSql('COMMENT ON COLUMN chill_vendee.vendee_person.situationprofessionellestartdate IS NULL'); - // $this->addSql('CREATE UNIQUE INDEX uniq_93f763ae217bbb47 ON chill_vendee.vendee_person (person_id)'); - // $this->addSql('ALTER TABLE chill_vendee.geographical_unit_association DROP CONSTRAINT FK_981D5C95D58FA2A4'); - // $this->addSql('ALTER TABLE chill_vendee.geographical_unit_association DROP CONSTRAINT FK_981D5C95A76ED395'); - // $this->addSql('DROP INDEX person_unique'); - // $this->addSql('DROP INDEX thirdparty_unique'); - // $this->addSql('CREATE UNIQUE INDEX person_unique ON chill_person_accompanying_period_resource (person_id, accompanyingperiod_id) WHERE (person_id IS NOT NULL)'); - // $this->addSql('CREATE UNIQUE INDEX thirdparty_unique ON chill_person_accompanying_period_resource (thirdparty_id, accompanyingperiod_id) WHERE (thirdparty_id IS NOT NULL)'); - // $this->addSql('CREATE INDEX participations_no_overlap ON chill_person_accompanying_period_participation (person_id, accompanyingperiod_id)'); - // $this->addSql('ALTER TABLE chill_main_location ALTER active SET DEFAULT \'true\''); - // $this->addSql('ALTER INDEX idx_ac74095aa76ed395 RENAME TO idx_55026b0ca76ed395'); - // $this->addSql('ALTER INDEX idx_ac74095a682b5931 RENAME TO idx_55026b0c682b5931'); - // $this->addSql('ALTER INDEX idx_ac74095a217bbb47 RENAME TO idx_55026b0c217bbb47'); - // $this->addSql('ALTER INDEX idx_ac74095ac54c8c93 RENAME TO idx_55026b0cc54c8c93'); - // $this->addSql('ALTER INDEX idx_ac74095ad7fa8ef0 RENAME TO IDX_AC74095A550B0C53'); - // $this->addSql('ALTER TABLE chill_person_person ADD cfdata_old TEXT DEFAULT NULL'); - // $this->addSql('ALTER TABLE chill_person_person ALTER cFData DROP NOT NULL'); - // $this->addSql('ALTER TABLE chill_person_person ALTER mobilenumber SET DEFAULT \'\''); - // $this->addSql('ALTER TABLE chill_person_person ALTER phonenumber SET DEFAULT \'\''); - // $this->addSql('ALTER TABLE chill_person_person ALTER maritalStatus_id TYPE VARCHAR(10)'); - // $this->addSql('COMMENT ON COLUMN chill_person_person.cfdata_old IS \'(DC2Type:array)\''); - // $this->addSql('CREATE INDEX mobilenumber_trgm_idx ON chill_person_person (mobilenumber)'); - // $this->addSql('CREATE INDEX fullnamecanonical_trgm_idx ON chill_person_person (center_id, fullnamecanonical)'); - // $this->addSql('CREATE INDEX chill_custom_fullnamecanonical_only_trgm_idx_gin ON chill_person_person (fullnamecanonical)'); - // $this->addSql('CREATE INDEX phonenumber_trgm_idx ON chill_person_person (phonenumber)'); - // $this->addSql('ALTER INDEX idx_bf210a141c9da55 RENAME TO idx_3370d4401c9da55'); - // $this->addSql('ALTER INDEX idx_bf210a143818da5 RENAME TO idx_3370d4403818da5'); - // $this->addSql('ALTER INDEX idx_bf210a145932f377 RENAME TO idx_person_center'); - // $this->addSql('ALTER INDEX idx_bf210a14d7d03ce3 RENAME TO IDX_BF210A145521BE40'); - // $this->addSql('ALTER TABLE chill_person_household ADD CONSTRAINT fk_household_comment_embeddable_user FOREIGN KEY (comment_members_userid) REFERENCES users (id) NOT DEFERRABLE INITIALLY IMMEDIATE'); - // $this->addSql('CREATE INDEX IDX_BE50A270116F5FA9 ON chill_person_household (comment_members_userid)'); - // $this->addSql('CREATE INDEX idx_b694fb3616d9d9b ON chill_person_accompanying_period_work (handlingthierparty_id)'); - // $this->addSql('ALTER TABLE chill_main_address ADD customs JSONB DEFAULT \'[]\''); - // $this->addSql('ALTER TABLE chill_main_address ALTER isNoAddress SET DEFAULT \'false\''); - // $this->addSql('ALTER TABLE chill_main_address ALTER point TYPE VARCHAR(255)'); - // $this->addSql('ALTER TABLE chill_main_address ALTER point DROP DEFAULT'); - // $this->addSql('CREATE INDEX chill_custom_main_address_filtering_idx ON chill_main_address (id, validfrom, validto)'); - // $this->addSql('ALTER TABLE chill_vendee.vendeeperson_entourage DROP CONSTRAINT FK_4D319FFEF57537C3'); - // $this->addSql('ALTER TABLE chill_person_household_members ALTER endDate TYPE DATE'); - // $this->addSql('ALTER TABLE chill_person_household_members ALTER endDate DROP DEFAULT'); - // $this->addSql('ALTER TABLE chill_person_household_members ALTER startDate TYPE DATE'); - // $this->addSql('ALTER TABLE chill_person_household_members ALTER startDate DROP DEFAULT'); - // $this->addSql('COMMENT ON COLUMN chill_person_household_members.enddate IS NULL'); - // $this->addSql('COMMENT ON COLUMN chill_person_household_members.startdate IS NULL'); - // $this->addSql('CREATE INDEX household_members_not_overlaps ON chill_person_household_members (person_id) WHERE (sharedhousehold IS TRUE)'); - // $this->addSql('CREATE INDEX chill_custom_person_household_members_sharing_idx ON chill_person_household_members (person_id, startdate, enddate, household_id) WHERE (sharedhousehold IS TRUE)'); - // $this->addSql('ALTER INDEX chill_vendee.idx_dd0a4c00eef79338 RENAME TO idx_1a4b602deef79338'); - // $this->addSql('CREATE INDEX chill_custom_canonicalized_trgm_idx_gist ON chill_3party.third_party (canonicalized) WHERE (active IS TRUE)'); - // $this->addSql('ALTER INDEX idx_a14d8f3d96df1f10 RENAME TO idx_a14d8f3d447bbb3b'); - // $this->addSql('DROP INDEX address_refid'); - // $this->addSql('ALTER TABLE chill_main_address_reference ALTER point TYPE VARCHAR(255)'); - // $this->addSql('ALTER TABLE chill_main_address_reference ALTER point DROP DEFAULT'); - // $this->addSql('CREATE INDEX chill_internal_address_reference_canonicalized ON chill_main_address_reference (postcode_id, addresscanonical)'); - // $this->addSql('CREATE INDEX address_refid ON chill_main_address_reference (refid) WHERE ((refid)::text <> \'\'::text)'); - // $this->addSql('ALTER INDEX idx_e260a868504cb38d RENAME TO idx_64a4a621504cb38d'); - // $this->addSql('ALTER TABLE chill_vendee.security_profile_action ALTER profile_id SET NOT NULL'); - // $this->addSql('ALTER TABLE chill_vendee.security_profile_action ALTER action DROP NOT NULL'); - // $this->addSql('DROP INDEX security_profile_jobs_pkey'); - // $this->addSql('ALTER TABLE chill_vendee.security_profile_jobs ADD PRIMARY KEY (job_id, profile_id)'); - // $this->addSql('CREATE INDEX internal_center_geom_idx ON chill_vendee.center_polygon (geom)'); - // $this->addSql('DROP INDEX search_name_code'); - // $this->addSql('ALTER TABLE chill_main_postal_code ALTER center TYPE VARCHAR(255)'); - // $this->addSql('ALTER TABLE chill_main_postal_code ALTER center DROP DEFAULT'); - // $this->addSql('CREATE INDEX chill_internal_postal_code_canonicalized ON chill_main_postal_code (canonical) WHERE (origin = 0)'); - // $this->addSql('ALTER TABLE permission_groups ALTER flags SET DEFAULT \'[]\''); - // $this->addSql('ALTER TABLE chill_person_marital_status ALTER id TYPE VARCHAR(10)'); - // $this->addSql('ALTER TABLE chill_person_relations ALTER isActive SET NOT NULL'); - // $this->addSql('ALTER TABLE custom_field_long_choice_options ALTER internal_key SET DEFAULT \'\''); - // $this->addSql('ALTER INDEX idx_7a48df7f5df53b66 RENAME TO idx_286dc95df53b66'); - // $this->addSql('ALTER TABLE customfield ALTER required SET DEFAULT \'false\''); - // $this->addSql('ALTER TABLE customfield ALTER required DROP NOT NULL'); - // $this->addSql('ALTER INDEX idx_7a6fdbefec418b RENAME TO idx_40fb5d6dfec418b'); - // $this->addSql('ALTER TABLE customfieldsgroup ALTER options SET DEFAULT \'{}\''); - // $this->addSql('ALTER TABLE customfieldsgroup ALTER options DROP NOT NULL'); - // $this->addSql('ALTER TABLE activityreason ALTER name DROP NOT NULL'); - // $this->addSql('ALTER INDEX idx_af82522312469de2 RENAME TO idx_654a2fcd12469de2'); - // $this->addSql('ALTER TABLE activityreasoncategory ALTER name DROP NOT NULL'); - } -} diff --git a/src/Bundle/ChillPersonBundle/migrations/Version20220119155944.php b/src/Bundle/ChillPersonBundle/migrations/Version20220119155944.php new file mode 100644 index 000000000..e35bf12d7 --- /dev/null +++ b/src/Bundle/ChillPersonBundle/migrations/Version20220119155944.php @@ -0,0 +1,50 @@ +addSql('CREATE SEQUENCE chill_person_resource_id_seq INCREMENT BY 1 MINVALUE 1 START 1'); + $this->addSql('CREATE SEQUENCE chill_person_resource_kind_id_seq INCREMENT BY 1 MINVALUE 1 START 1'); + $this->addSql('CREATE TABLE chill_person_resource (id INT NOT NULL, person_id INT DEFAULT NULL, kind_id INT DEFAULT NULL, freeText TEXT DEFAULT NULL, createdAt TIMESTAMP(0) WITHOUT TIME ZONE NOT NULL, updatedAt TIMESTAMP(0) WITHOUT TIME ZONE DEFAULT NULL, comment_comment TEXT DEFAULT NULL, comment_date TIMESTAMP(0) WITHOUT TIME ZONE DEFAULT NULL, comment_userId INT DEFAULT NULL, personOwner_id INT NOT NULL, thirdParty_id INT DEFAULT NULL, createdBy_id INT NOT NULL, updatedBy_id INT DEFAULT NULL, PRIMARY KEY(id))'); + $this->addSql('CREATE INDEX IDX_FA5B7D92D19C515B ON chill_person_resource (personOwner_id)'); + $this->addSql('CREATE INDEX IDX_FA5B7D92217BBB47 ON chill_person_resource (person_id)'); + $this->addSql('CREATE INDEX IDX_FA5B7D923EA5CAB0 ON chill_person_resource (thirdParty_id)'); + $this->addSql('CREATE INDEX IDX_FA5B7D9230602CA9 ON chill_person_resource (kind_id)'); + $this->addSql('CREATE INDEX IDX_FA5B7D923174800F ON chill_person_resource (createdBy_id)'); + $this->addSql('CREATE INDEX IDX_FA5B7D9265FF1AEC ON chill_person_resource (updatedBy_id)'); + $this->addSql('CREATE TABLE chill_person_resource_kind (id INT NOT NULL, title JSON NOT NULL, isActive BOOLEAN NOT NULL, PRIMARY KEY(id))'); + $this->addSql('ALTER TABLE chill_person_resource ADD CONSTRAINT FK_FA5B7D92D19C515B FOREIGN KEY (personOwner_id) REFERENCES chill_person_person (id) NOT DEFERRABLE INITIALLY IMMEDIATE'); + $this->addSql('ALTER TABLE chill_person_resource ADD CONSTRAINT FK_FA5B7D92217BBB47 FOREIGN KEY (person_id) REFERENCES chill_person_person (id) NOT DEFERRABLE INITIALLY IMMEDIATE'); + $this->addSql('ALTER TABLE chill_person_resource ADD CONSTRAINT FK_FA5B7D923EA5CAB0 FOREIGN KEY (thirdParty_id) REFERENCES chill_3party.third_party (id) NOT DEFERRABLE INITIALLY IMMEDIATE'); + $this->addSql('ALTER TABLE chill_person_resource ADD CONSTRAINT FK_FA5B7D9230602CA9 FOREIGN KEY (kind_id) REFERENCES chill_person_resource_kind (id) NOT DEFERRABLE INITIALLY IMMEDIATE'); + $this->addSql('ALTER TABLE chill_person_resource ADD CONSTRAINT FK_FA5B7D923174800F FOREIGN KEY (createdBy_id) REFERENCES users (id) NOT DEFERRABLE INITIALLY IMMEDIATE'); + $this->addSql('ALTER TABLE chill_person_resource ADD CONSTRAINT FK_FA5B7D9265FF1AEC FOREIGN KEY (updatedBy_id) REFERENCES users (id) NOT DEFERRABLE INITIALLY IMMEDIATE'); + } + + public function down(Schema $schema): void + { + // this down() migration is auto-generated, please modify it to your needs + $this->addSql('ALTER TABLE chill_person_resource DROP CONSTRAINT FK_FA5B7D9230602CA9'); + $this->addSql('DROP SEQUENCE chill_person_resource_id_seq CASCADE'); + $this->addSql('DROP SEQUENCE chill_person_resource_kind_id_seq CASCADE'); + $this->addSql('DROP TABLE chill_person_resource'); + $this->addSql('DROP TABLE chill_person_resource_kind'); + } +} From 2bdf1166984ac17a40be33e3786187b71d3fa6dc Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Wed, 19 Jan 2022 19:46:01 +0100 Subject: [PATCH 07/30] adjustments to form + rendering of resource kinds --- .../Controller/PersonResourceController.php | 1 + .../Form/PersonResourceType.php | 18 ++----- .../views/PersonResource/create.html.twig | 33 +++++++++--- .../Templating/Entity/ResourceKindRender.php | 52 +++++++++++++++++++ 4 files changed, 84 insertions(+), 20 deletions(-) create mode 100644 src/Bundle/ChillPersonBundle/Templating/Entity/ResourceKindRender.php diff --git a/src/Bundle/ChillPersonBundle/Controller/PersonResourceController.php b/src/Bundle/ChillPersonBundle/Controller/PersonResourceController.php index 799967c82..c770c03bc 100644 --- a/src/Bundle/ChillPersonBundle/Controller/PersonResourceController.php +++ b/src/Bundle/ChillPersonBundle/Controller/PersonResourceController.php @@ -46,6 +46,7 @@ final class PersonResourceController extends AbstractController $form->handleRequest($request); if ($request->getMethod() === Request::METHOD_POST && $form->isValid()) { + dump($personResource); $this->em->persist($personResource); $this->em->flush(); diff --git a/src/Bundle/ChillPersonBundle/Form/PersonResourceType.php b/src/Bundle/ChillPersonBundle/Form/PersonResourceType.php index fabc30e5e..6db7be525 100644 --- a/src/Bundle/ChillPersonBundle/Form/PersonResourceType.php +++ b/src/Bundle/ChillPersonBundle/Form/PersonResourceType.php @@ -17,6 +17,7 @@ use Chill\PersonBundle\Entity\Person; use Chill\PersonBundle\Entity\Person\PersonResource; use Chill\PersonBundle\Entity\Person\PersonResourceKind; use Chill\PersonBundle\Templating\Entity\PersonRender; +use Chill\PersonBundle\Templating\Entity\ResourceKindRender; use Chill\ThirdPartyBundle\Entity\ThirdParty; use Chill\ThirdPartyBundle\Templating\Entity\ThirdPartyRender; use Doctrine\ORM\EntityRepository; @@ -29,13 +30,13 @@ use Symfony\Component\OptionsResolver\OptionsResolver; final class PersonResourceType extends AbstractType { - private CategoryRender $categoryRender; + private ResourceKindRender $resourceKindRender; private PersonRender $personRender; private ThirdPartyRender $thirdPartyRender; - public function __construct(CategoryRender $categoryRender, PersonRender $personRender, ThirdPartyRender $thirdPartyRender) + public function __construct(ResourceKindRender $resourceKindRender, PersonRender $personRender, ThirdPartyRender $thirdPartyRender) { - $this->categoryRender = $categoryRender; + $this->resourceKindRender = $resourceKindRender; $this->personRender = $personRender; $this->thirdPartyRender = $thirdPartyRender; } @@ -54,18 +55,9 @@ final class PersonResourceType extends AbstractType }, 'choice_label' => function (PersonResourceKind $personResourceKind) { $options = []; - return $this->categoryRender->renderString($personResourceKind, $options); + return $this->resourceKindRender->renderString($personResourceKind, $options); } ]) - ->add('linkedEntity', ChoiceType::class, [ - 'choices' => [ - 'Usager' => 'person', - 'Tiers' => 'thirdparty', - 'Description libre' => 'freeText' - ], - 'expanded' => true, - 'label' => 'Associer un' - ]) ->add('person', EntityType::class, [ 'label' => 'Usager', 'class' => Person::class, diff --git a/src/Bundle/ChillPersonBundle/Resources/views/PersonResource/create.html.twig b/src/Bundle/ChillPersonBundle/Resources/views/PersonResource/create.html.twig index 74bdeb57e..86c4ef9d1 100644 --- a/src/Bundle/ChillPersonBundle/Resources/views/PersonResource/create.html.twig +++ b/src/Bundle/ChillPersonBundle/Resources/views/PersonResource/create.html.twig @@ -7,7 +7,27 @@ {{ form_row(form.kind) }}
- {{ form_row(form.linkedEntity) }} +
+
+ Associer un +
+
+
+ + +
+
+ + +
+
+ + +
+
+
+
+
@@ -21,13 +41,12 @@
{{ form_row(form.comment) }} - -
    -
\ No newline at end of file From 963b0b1ed26bbf1d180703aa2b1f0c4f899c2c13 Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Tue, 25 Jan 2022 16:06:27 +0100 Subject: [PATCH 25/30] bugfixes in display of dynamicPicker --- .../public/lib/show_hide/show_hide.js | 2 +- .../public/module/pick-entity/index.js | 47 ++++++++++++++++--- .../public/vuejs/PickEntity/PickEntity.vue | 6 ++- .../page/person_resource/showhide-input.js | 6 +-- 4 files changed, 50 insertions(+), 11 deletions(-) diff --git a/src/Bundle/ChillMainBundle/Resources/public/lib/show_hide/show_hide.js b/src/Bundle/ChillMainBundle/Resources/public/lib/show_hide/show_hide.js index edda5a03d..f2bcc9b45 100644 --- a/src/Bundle/ChillMainBundle/Resources/public/lib/show_hide/show_hide.js +++ b/src/Bundle/ChillMainBundle/Resources/public/lib/show_hide/show_hide.js @@ -39,7 +39,7 @@ var ShowHide = function(options) { contents.push(el); } container_content.push(contents); - console.log('container content', container_content); + // console.log('container content', container_content); } // attach the listener on each input diff --git a/src/Bundle/ChillMainBundle/Resources/public/module/pick-entity/index.js b/src/Bundle/ChillMainBundle/Resources/public/module/pick-entity/index.js index 329ac4e6c..c3786f137 100644 --- a/src/Bundle/ChillMainBundle/Resources/public/module/pick-entity/index.js +++ b/src/Bundle/ChillMainBundle/Resources/public/module/pick-entity/index.js @@ -5,18 +5,22 @@ import { appMessages } from 'ChillMainAssets/vuejs/PickEntity/i18n'; const i18n = _createI18n(appMessages); -window.addEventListener('DOMContentLoaded', function(e) { +let appsOnPage = new Map(); - let apps = document.querySelectorAll('[data-module="pick-dynamic"]'); + +function loadDynamicPicker(element) { + + let apps = element.querySelectorAll('[data-module="pick-dynamic"]'); apps.forEach(function(el) { const isMultiple = parseInt(el.dataset.multiple) === 1, - input = document.querySelector('[data-input-uniqid="'+ el.dataset.uniqid +'"]'), - picked = isMultiple ? JSON.parse(input.value) : [JSON.parse(input.value)]; + uniqId = el.dataset.uniqid, + input = element.querySelector('[data-input-uniqid="'+ el.dataset.uniqid +'"]'), + picked = (isMultiple) ? (JSON.parse(input.value)) : ((input.value === '[]') ? (null) : ([JSON.parse(input.value)])); - createApp({ + const app = createApp({ template: ' { +// let uniqId = el.dataset.uniqid; +// console.log(uniqId); +// if (appsOnPage.has(uniqId)) { +// appsOnPage.get(uniqId).unmount(); +// console.log('App has been unmounted') +// appsOnPage.delete(uniqId); +// } +// }) +// }) + +document.addEventListener('DOMContentLoaded', function(e) { + console.log('loaded event', e) + loadDynamicPicker(document) +}) + + + + + diff --git a/src/Bundle/ChillMainBundle/Resources/public/vuejs/PickEntity/PickEntity.vue b/src/Bundle/ChillMainBundle/Resources/public/vuejs/PickEntity/PickEntity.vue index 43f3ebf94..137224691 100644 --- a/src/Bundle/ChillMainBundle/Resources/public/vuejs/PickEntity/PickEntity.vue +++ b/src/Bundle/ChillMainBundle/Resources/public/vuejs/PickEntity/PickEntity.vue @@ -1,5 +1,5 @@