Skip to content

Commit

Permalink
Merge pull request #70 from kiloutyg/66-need-to-change-lastmodifier-t…
Browse files Browse the repository at this point in the history
…o-be-just-a-string-and-not-a-relation-to-eliminate-issue-with-user-deletioln-in-the-future-and-keep-tracebility

66 need to change lastmodifier to be just a string and not a relation to eliminate issue with user deletioln in the future and keep tracebility
  • Loading branch information
kiloutyg authored Mar 19, 2024
2 parents 83c325c + 274ae0c commit d2e0ea2
Show file tree
Hide file tree
Showing 4 changed files with 82 additions and 54 deletions.
5 changes: 3 additions & 2 deletions src/Controller/EFNCController.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public function formModificationDisplay(int $efncID, Request $request): Response
} else if ($request->getMethod() == 'POST') {
if ($this->getUser() !== null) {
if ($this->authChecker->isGranted('ROLE_ADMIN')) {
$user = $this->getUser();
$user = $this->getUser()->getUsername();
$form1->handleRequest($request);
if ($form1->isValid() && $form1->isSubmitted()) {
$result = $this->formModificationService->modifyNCForm(
Expand Down Expand Up @@ -151,7 +151,8 @@ public function closeEntity(Request $request, string $entityType, int $id): Resp

if ($this->getUser() !== null) {
if ($this->authChecker->isGranted('ROLE_MASTER_ADMIN')) {
$result = $this->entityDeletionService->closeEntity($entityType, $id); // Implement this method in your service
$user = $this->getUser()->getUsername();
$result = $this->entityDeletionService->closeEntity($entityType, $id, $commentary = null, $user); // Implement this method in your service
if ($result == false) {
$this->addFlash('danger', 'L\'élément n\'a pas pu être clôturé');
return $this->redirectToRoute('app_base', []);
Expand Down
3 changes: 2 additions & 1 deletion src/Service/EntityDeletionService.php
Original file line number Diff line number Diff line change
Expand Up @@ -533,7 +533,7 @@ public function unarchiveEntity(string $entityType, int $id): bool
}


public function closeEntity(string $entityType, int $id): bool
public function closeEntity(string $entityType, int $id, string $commentary = null, string $user = null): bool
{
$repository = null;
switch ($entityType) {
Expand All @@ -553,6 +553,7 @@ public function closeEntity(string $entityType, int $id): bool
}

if ($entityType === 'efnc') {
$entity->setLastModifier($user);
$entity->setArchived(true);
$entity->setStatus(true);
}
Expand Down
3 changes: 2 additions & 1 deletion src/Service/FormModificationService.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ public function __construct(
public function modifyNCForm(
EFNC $efnc,
Request $request,
FormInterface $form1
FormInterface $form1,
string $user = null
) {
$now = new \DateTime();

Expand Down
125 changes: 75 additions & 50 deletions templates/services/efnc/modification/form_modification.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -171,70 +171,95 @@
class="d-grid gap-2 d-md-flex justify-content-md-center mt-5 text-white">
Derniere modification effectué par

{{ EFNC.LastModifier.username|capitalize|split('.')|first }}
{{ EFNC.LastModifier.username|upper|split('.')|last }}
{{ EFNC.LastModifier|capitalize|split('.')|first }}
{{ EFNC.LastModifier|upper|split('.')|last }}
</div>
{% endif %}
<div
class="d-grid gap-2 d-md-flex justify-content-md-center mt-1 textwhite">
<button
type="submit"
class="btn btn-primary mb-3 submit-EFNCform-modification">
Modifier
</button>
</div>
{% if EFNC.archived is null and EFNC.status is null %}
<div
class="d-grid gap-2 d-md-flex justify-content-md-center mt-3 textwhite">
<button
type="submit"
class="btn btn-primary mb-1 submit-EFNCform-modification">
Modifier
</button>
</div>
{% endif %}


{% endif %}
</div>
{{ form_end(form1) }}
<form
method="post"
action="{{ path('app_archive_entity', {entityType: 'efnc', id: EFNC.id}) }}">
{% if EFNC.archived is null and EFNC.status is null %}

<form
method="post"
action="{{ path('app_archive_entity', {entityType: 'efnc', id: EFNC.id}) }}">

<div
class="container mt-2 mb-2"
data-controller="archiving-commentary">
<div
class="row justify-content-md-center">
class="container mt-2 mb-2"
data-controller="archiving-commentary">
<div
class="col-md-12">
<label
for="archivingCommentary"
class="form-label text-white">
Commentaire d'archivage obligatoire
<div
data-archiving-commentary-target="archivingCommentaryMessage"
class="archivingCommentaryMessage-message d-flex justify-content-evenly"></div>
</label>
<textarea
class="form-control"
id="archivingCommentary"
name="archivingCommentary"
data-archiving-commentary-target="archivingCommentary"
data-action="keyup->archiving-commentary#archivingCommentary"></textarea>
class="row justify-content-md-center">
<div
class="col-md-12">
<label
for="archivingCommentary"
class="form-label text-white">
Commentaire d'archivage obligatoire
<div
data-archiving-commentary-target="archivingCommentaryMessage"
class="archivingCommentaryMessage-message d-flex justify-content-evenly"></div>
</label>
<textarea
class="form-control"
id="archivingCommentary"
name="archivingCommentary"
data-archiving-commentary-target="archivingCommentary"
data-action="keyup->archiving-commentary#archivingCommentary"></textarea>
</div>
</div>
</div>
<div
class="d-grid gap-2 d-md-flex justify-content-md-center mt-2">
<button
type="submit"
class="btn btn-danger archive-EFNC"
data-archiving-commentary-target="archivingButton"
hidden
disabled>
Archiver
</button>
{% if is_granted('ROLE_MASTER_ADMIN') %}
<a
<div
class="d-grid gap-2 d-md-flex justify-content-md-center mt-2">
<button
type="submit"
class="btn btn-danger archive-EFNC"
href="{{path('app_close_entity', {entityType: 'efnc', id: EFNC.id})}}">
Cloturer
</a>
{% endif %}
data-archiving-commentary-target="archivingButton"
hidden
disabled>
Archiver
</button>
{% if is_granted('ROLE_MASTER_ADMIN') %}
<a
class="btn btn-danger archive-EFNC"
href="{{path('app_close_entity', {entityType: 'efnc', id: EFNC.id})}}">
Cloturer
</a>
{% endif %}
</div>
</div>
</form>
{% elseif EFNC.archived is same as(true) and EFNC.status is null %}
<div
class="d-grid gap-2 d-md-flex justify-content-md-center mt-2 mb-2 text-white">
Archivage effectué par

{{ EFNC.LastModifier|capitalize|split('.')|first }}
{{ EFNC.LastModifier|upper|split('.')|last }}

avec le commentaire suivant :
{{ EFNC.archivingCommentary }}
</div>
</form>
{% elseif EFNC.archived is same as(true) and EFNC.status is not null %}
<div
class="d-grid gap-2 d-md-flex justify-content-md-center mt-2 mb-2 text-white">
Cloture effectué par

{{ EFNC.LastModifier|capitalize|split('.')|first }}
{{ EFNC.LastModifier|upper|split('.')|last }}
</div>
{% endif %}

</div>
</div>
{% endblock %}

0 comments on commit d2e0ea2

Please sign in to comment.