mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-21 07:03:49 +00:00
fix canonicalization and show only active children in form
This commit is contained in:
@@ -85,6 +85,10 @@ class ThirdParty implements TrackCreationInterface, TrackUpdateInterface
|
||||
private ?string $nameCompany = "";
|
||||
|
||||
/**
|
||||
* Canonicalized form composed of name, company name and acronym.
|
||||
*
|
||||
* This field is read-only, and is generated on database side.
|
||||
*
|
||||
* @ORM\Column(name="canonicalized", type="text", options={"default":""})
|
||||
*/
|
||||
private ?string $canonicalized = "";
|
||||
@@ -116,7 +120,7 @@ class ThirdParty implements TrackCreationInterface, TrackUpdateInterface
|
||||
/**
|
||||
* Contact Persons: One Institutional ThirdParty has Many Contact Persons
|
||||
* @ORM\OneToMany(targetEntity="Chill\ThirdPartyBundle\Entity\ThirdParty", mappedBy="parent",
|
||||
* cascade={"persist"})
|
||||
* cascade={"persist"}, orphanRemoval=true)
|
||||
* @var ThirdParty[]|Collection
|
||||
* @Assert\Valid(traverse=true)
|
||||
*/
|
||||
@@ -319,6 +323,17 @@ class ThirdParty implements TrackCreationInterface, TrackUpdateInterface
|
||||
return $this->email;
|
||||
}
|
||||
|
||||
public function isContactDataAnonymous(): bool
|
||||
{
|
||||
return $this->contactDataAnonymous;
|
||||
}
|
||||
|
||||
public function setContactDataAnonymous(bool $contactDataAnonymous): ThirdParty
|
||||
{
|
||||
$this->contactDataAnonymous = $contactDataAnonymous;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set comment.
|
||||
*
|
||||
@@ -570,6 +585,47 @@ class ThirdParty implements TrackCreationInterface, TrackUpdateInterface
|
||||
return $this->children;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the children where active = true
|
||||
*
|
||||
* @return Collection
|
||||
*/
|
||||
public function getActiveChildren(): Collection
|
||||
{
|
||||
return $this->children->filter(fn (ThirdParty $tp) => $tp->getActive());
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a child and set the child as active
|
||||
*
|
||||
* Method used in conjonction with getActiveChildren in form.
|
||||
*
|
||||
* @internal use the method addChild
|
||||
* @param ThirdParty $child
|
||||
* @return $this
|
||||
*/
|
||||
public function addActiveChild(ThirdParty $child): self
|
||||
{
|
||||
$child->setActive(true);
|
||||
|
||||
return $this->addChild($child);
|
||||
}
|
||||
|
||||
/**
|
||||
* mark the child as unactive, but keep the child existing in the
|
||||
* database. To effectively remove the child, use removeChild instead.
|
||||
*
|
||||
* @param ThirdParty $child
|
||||
* @return $this
|
||||
*/
|
||||
public function removeActiveChild(ThirdParty $child): self
|
||||
{
|
||||
$child->setActive(false);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param ThirdParty $child
|
||||
* @return $this
|
||||
@@ -583,13 +639,17 @@ class ThirdParty implements TrackCreationInterface, TrackUpdateInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the child from the database.
|
||||
*
|
||||
* If you want to keep the child into the database
|
||||
* but desactivate it, use removeActiveChildren instead.
|
||||
*
|
||||
* @param ThirdParty $child
|
||||
* @return $this
|
||||
*/
|
||||
public function removeChild(ThirdParty $child): self
|
||||
{
|
||||
$this->children->removeElement($child);
|
||||
$child->setActive(false);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
Reference in New Issue
Block a user