From fca5c89e0db5c6ea2e36320f55fa0819f215f647 Mon Sep 17 00:00:00 2001 From: Gwildor Sok Date: Sun, 3 Mar 2024 22:10:58 +0100 Subject: [PATCH] [142] Add workgroups --- src/Controller/Admin/MemberCrud.php | 10 ++-- src/Controller/Admin/WorkGroupCrud.php | 39 ++++++++++++++ src/Entity/WorkGroup.php | 75 ++++++++++++++++++++++++++ 3 files changed, 120 insertions(+), 4 deletions(-) create mode 100644 src/Controller/Admin/WorkGroupCrud.php create mode 100644 src/Entity/WorkGroup.php diff --git a/src/Controller/Admin/MemberCrud.php b/src/Controller/Admin/MemberCrud.php index 44cb1a4..d0a2654 100644 --- a/src/Controller/Admin/MemberCrud.php +++ b/src/Controller/Admin/MemberCrud.php @@ -50,15 +50,17 @@ public function configureCrud(Crud $crud): Crud return $crud ->setEntityLabelInSingular('lid') ->setEntityLabelInPlural('Leden') - ->setSearchFields(['id', 'firstName', 'lastName', 'email', 'phone', 'city', 'postCode', 'currentMembershipStatus.name']) + ->setSearchFields(['id', 'firstName', 'lastName', 'email', 'phone', 'city', 'postCode', 'currentMembershipStatus.name'])//, 'workGroups.name']) TODO: fix ; } public function configureFilters(Filters $filters): Filters { return $filters - ->add(EntityFilter::new('division')) - ->add(EntityFilter::new('currentMembershipStatus')); + ->add(EntityFilter::new('division', 'Afdeling')) + ->add(EntityFilter::new('currentMembershipStatus', 'Lidmaatschapstype')) + /* ->add(EntityFilter::new('workGroups', 'Werkgroepen')) */ TODO: fix + ; } public function configureActions(Actions $actions): Actions { @@ -183,7 +185,7 @@ public function configureFields(string $pageName): iterable $fields[] = BooleanField::new('isAdmin', 'Toegang tot administratie') ->hideOnIndex(); } - array_push($fields, + array_push($fields, FormField::addPanel('Contactinformatie'), EmailField::new('email', 'E-mailadres')->setDisabled(!$isAdmin), TextField::new('phone', 'Telefoonnummer')->setDisabled(!$isAdmin), diff --git a/src/Controller/Admin/WorkGroupCrud.php b/src/Controller/Admin/WorkGroupCrud.php new file mode 100644 index 0000000..529bba8 --- /dev/null +++ b/src/Controller/Admin/WorkGroupCrud.php @@ -0,0 +1,39 @@ +setEntityLabelInSingular('werkgroep') + ->setEntityLabelInPlural('Werkgroepen') + ->setEntityPermission('ROLE_ADMIN') + ; + } + + public function configureFields(string $pageName): iterable + { + return [ + IdField::new('id')->hideOnForm(), + TextField::new('name', 'Werkgroepnaam'), + AssociationField::new('contact', 'Contactpersoon'), + AssociationField::new('members', 'Leden')->hideOnIndex(), + FormField::addPanel('Contactinformatie'), + AssociationField::new('email', 'E-mailadres'), + ]; + } + +} diff --git a/src/Entity/WorkGroup.php b/src/Entity/WorkGroup.php new file mode 100644 index 0000000..607d27a --- /dev/null +++ b/src/Entity/WorkGroup.php @@ -0,0 +1,75 @@ +members = new ArrayCollection(); + } + + public function __toString() { + return $this->name; + } + + public function getId(): ?int { return $this->id; } + + public function getName(): string { return $this->name; } + public function setName(string $name): void { $this->name = $name; } + + public function getMembers(): Collection { return $this->members; } + + public function addMember(Member $member): self { + if (!$this->members->contains($member)) { + $this->members[] = $member; + } + return $this; + } + public function removeMember(Member $member): self { + if ($this->members->contains($member)) { + $this->members->removeElement($member); + } + return $this; + } + + public function getContact(): ?Member { return $this->contact; } + public function setContact(?Member $contact): void { $this->contact = $contact; } + + public function getEmail(): ?Email { return $this->email; } + public function setEmail(?Email $email): void { $this->email = $email; } +}