Skip to content

Commit

Permalink
♻️ [Permanences] Fix naming in app, update admin labels
Browse files Browse the repository at this point in the history
  • Loading branch information
AntoineAresu committed Mar 18, 2024
1 parent a902c95 commit cd5310c
Show file tree
Hide file tree
Showing 9 changed files with 45 additions and 41 deletions.
8 changes: 4 additions & 4 deletions client/src/Pages/Charts.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,16 @@ const Charts = () => {
let nbBeneficiariesAccountsData = {};
let nbStoredDocsData = {};

permanencesContext.permanences.forEach((note: any) => {
permanencesContext.permanences.forEach((permanence: any) => {
nbProAccountsData = {
[formatDate(note.date)]: note.nbProAccounts,
[formatDate(permanence.date)]: permanence.nbProAccounts,
...nbProAccountsData,
};
nbBeneficiariesAccountsData = {
[formatDate(note.date)]: note.nbBeneficiariesAccounts,
[formatDate(permanence.date)]: permanence.nbBeneficiariesAccounts,
...nbBeneficiariesAccountsData,
};
nbStoredDocsData = {[formatDate(note.date)]: note.nbStoredDocs, ...nbStoredDocsData};
nbStoredDocsData = {[formatDate(permanence.date)]: permanence.nbStoredDocs, ...nbStoredDocsData};
});

return (
Expand Down
2 changes: 1 addition & 1 deletion client/src/Services/requests.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export const dropdownsEndpoint = `${apiEndpoint}/dropdowns`;
export const loginEndpoint = `${backendUrl}/login`;
export const googleLoginEndpoint = `${backendUrl}/google-login-trigger`;
export const logoutEndpoint = `${backendUrl}/logout`;
export const permanencesEndpoint = `${apiEndpoint}/notes`;
export const permanencesEndpoint = `${apiEndpoint}/permanences`;
export const tagsEndpoint = `${apiEndpoint}/tags`;
export const workshopsEndpoint = `${apiEndpoint}/workshops`;

Expand Down
5 changes: 3 additions & 2 deletions src/Controller/Admin/CenterCrudController.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,15 @@ public function configureFields(string $pageName): iterable
{
$name = TextField::new('name');
$place = TextField::new('place')->setRequired(false)->setEmptyData(Center::PLACE_DEFAULT_VALUE);
$notes = AssociationField::new('notes');
$permanences = AssociationField::new('permanences')->setLabel('permanences_count');
$workshops = AssociationField::new('workshops')->setLabel('workshops_count');
$tags = AssociationField::new('tags')->setFormTypeOption('by_reference', false);
$id = IntegerField::new('id', 'ID');
$workshop = BooleanField::new('workshop');
$permanence = BooleanField::new('permanence');

if (Crud::PAGE_INDEX === $pageName || Crud::PAGE_DETAIL === $pageName) {
return [$id, $name, $place, $notes, $tags, $workshop, $permanence];
return [$id, $name, $place, $permanences, $workshops, $tags, $permanence, $workshop];
}

return [$name, $place, $tags, $workshop, $permanence];
Expand Down
2 changes: 1 addition & 1 deletion src/Controller/Admin/PermanenceCrudController.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public function configureCrud(Crud $crud): Crud
return $crud
->overrideTemplate('crud/index', 'bundles/EasyAdminBundle/Permanence/index.html.twig')
->setEntityLabelInSingular('Permanence')
->setEntityLabelInPlural('Permanence')
->setEntityLabelInPlural('Permanences')
->setSearchFields(['id', 'hours', 'nbPros', 'nbProAccounts', 'nbBeneficiaries', 'nbBeneficiariesAccounts', 'nbStoredDocs', 'beneficiariesNotes', 'proNotes', 'reconnectNotes', 'attendees']);
}

Expand Down
2 changes: 1 addition & 1 deletion src/Controller/Admin/UserCrudController.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public function configureFields(string $pageName): \Generator
{
yield TextField::new('email');
yield TextField::new('plainPassword', 'Password')->onlyOnForms();
yield AssociationField::new('notes')->onlyOnIndex();
yield AssociationField::new('permanences')->onlyOnIndex();
yield AssociationField::new('workshops')->onlyOnIndex();
yield IntegerField::new('id', 'ID')->onlyOnDetail();
yield BooleanField::new('disabled', 'disabled');
Expand Down
36 changes: 18 additions & 18 deletions src/Entity/Center.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class Center implements \Stringable
/** @var Collection<int, Permanence> */
#[Groups(['read'])]
#[ORM\OneToMany(mappedBy: 'center', targetEntity: Permanence::class)]
private Collection $notes;
private Collection $permanences;

#[Groups(['read'])]
#[ORM\Column(type: Types::STRING, length: 255, nullable: true)]
Expand Down Expand Up @@ -78,7 +78,7 @@ public function __toString(): string

public function __construct()
{
$this->notes = new ArrayCollection();
$this->permanences = new ArrayCollection();
$this->tags = new ArrayCollection();
$this->workshops = new ArrayCollection();
}
Expand All @@ -101,27 +101,27 @@ public function setName(string $name = null): void
/**
* @return Collection<int, Permanence>
*/
public function getNotes(): Collection
public function getPermanences(): Collection
{
return $this->notes;
return $this->permanences;
}

/** @param Collection<int, Permanence> $notes */
public function setNotes(Collection $notes): void
/** @param Collection<int, Permanence> $permanences */
public function setPermanences(Collection $permanences): void
{
$this->notes = $notes;
$this->permanences = $permanences;
}

public function addNote(Permanence $note): self
public function addPermanence(Permanence $permanence): self
{
$this->notes->add($note);
$this->permanences->add($permanence);

return $this;
}

public function removeNote(Permanence $note): self
public function removePermanence(Permanence $permanence): self
{
$this->notes->removeElement($note);
$this->permanences->removeElement($permanence);

return $this;
}
Expand Down Expand Up @@ -168,19 +168,19 @@ public function removeTag(CenterTag $tag): self
#[Groups('read')]
public function getBeneficiariesCount(): int
{
return array_reduce($this->notes->toArray(), fn (int $acc, Permanence $note) => $acc + $note->getNbBeneficiaries(), 0);
return array_reduce($this->permanences->toArray(), fn (int $acc, Permanence $permanence) => $acc + $permanence->getNbBeneficiaries(), 0);
}

#[Groups('read')]
public function getCreatedBeneficiaryCount(): int
{
return $this->getNotesBeneficiariesCount() + $this->getWorkshopsBeneficiariesCount();
return $this->getPermanencesBeneficiariesCount() + $this->getWorkshopsBeneficiariesCount();
}

#[Groups('read')]
public function getNotesBeneficiariesCount(): int
public function getPermanencesBeneficiariesCount(): int
{
return array_reduce($this->notes->toArray(), fn (int $acc, Permanence $note) => $acc + $note->getNbBeneficiariesAccounts(), 0);
return array_reduce($this->permanences->toArray(), fn (int $acc, Permanence $permanence) => $acc + $permanence->getNbBeneficiariesAccounts(), 0);
}

#[Groups('read')]
Expand All @@ -192,7 +192,7 @@ public function getWorkshopsBeneficiariesCount(): int
#[Groups('read')]
public function getStoredDocumentsCount(): int
{
return $this->getWorkshopsStoredDocumentsCount() + $this->getNotesStoredDocumentsCount();
return $this->getWorkshopsStoredDocumentsCount() + $this->getPermanencesStoredDocumentsCount();
}

#[Groups('read')]
Expand All @@ -202,9 +202,9 @@ public function getWorkshopsStoredDocumentsCount(): int
}

#[Groups('read')]
public function getNotesStoredDocumentsCount(): int
public function getPermanencesStoredDocumentsCount(): int
{
return array_reduce($this->notes->toArray(), fn (int $acc, Permanence $note) => $acc + $note->getNbStoredDocs(), 0);
return array_reduce($this->permanences->toArray(), fn (int $acc, Permanence $permanence) => $acc + $permanence->getNbStoredDocs(), 0);
}

#[Groups('read')]
Expand Down
2 changes: 1 addition & 1 deletion src/Entity/Permanence.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
use Symfony\Component\Serializer\Annotation\Groups;

#[ApiResource(
shortName: 'notes',
shortName: 'permanences',
operations: [
new Get(),
new Put(),
Expand Down
20 changes: 10 additions & 10 deletions src/Entity/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class User implements PasswordAuthenticatedUserInterface, UserInterface, \String

/** @var Collection<int, Permanence> */
#[ORM\OneToMany(mappedBy: 'author', targetEntity: Permanence::class)]
private Collection $notes;
private Collection $permanences;

private ?string $plainPassword = null;

Expand All @@ -60,7 +60,7 @@ public function setPlainPassword(string $plainPassword): self

public function __construct()
{
$this->notes = new ArrayCollection();
$this->permanences = new ArrayCollection();
$this->workshops = new ArrayCollection();
}

Expand Down Expand Up @@ -178,26 +178,26 @@ public function eraseCredentials(): void
}

/** @return Collection<int, Permanence> */
public function getNotes(): Collection
public function getPermanences(): Collection
{
return $this->notes;
return $this->permanences;
}

public function setNotes(mixed $notes): void
public function setPermanences(mixed $permanences): void
{
$this->notes = $notes;
$this->permanences = $permanences;
}

public function addNote(Permanence $note): static
public function addPermanence(Permanence $permanence): static
{
$this->notes[] = $note;
$this->permanences[] = $permanence;

return $this;
}

public function removeNote(Permanence $note): static
public function removePermanence(Permanence $permanence): static
{
$this->notes->removeElement($note);
$this->permanences->removeElement($permanence);

return $this;
}
Expand Down
9 changes: 6 additions & 3 deletions translations/messages.fr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,9 @@ Participant Kinds: Types de participants
ParticipantKind: Types de participants
ParticipantKinds: Types de participants
Password: Mot de passe
Permanence: Permanence CFN
permanences_count: Nb Permanences
Permanence: Permanence
Permanences: Permanence
Place: Lieu
Pro Notes: 'Professionnels & Structure : bilan et axes d’amélioration'
ProNotes: Remarques concernant les bénéficiaires
Expand All @@ -59,8 +61,9 @@ UsedEquipment: Outils utilisés
UsedEquipments: Outils utilisés
UsedVault: Utilisation du CFN
User: Utilisateurs
Workshop: Accompagnement numérique
Workshops: Accompagnements numérique
workshops_count: Nb Ateliers
Workshop: Atelier
Workshops: Ateliers
attendees: Participants
author: Créateur
beneficiariesNotes: 'Bénéficiaires : bilan et axes d’amélioration'
Expand Down

0 comments on commit cd5310c

Please sign in to comment.