Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lets save this and pass to the correction about the lastmodifier stu… #67

Merged
merged 1 commit into from
Mar 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions assets/controllers/archiving_commentary_controller.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { Controller } from '@hotwired/stimulus';

export default class extends Controller {

static targets = ['archivingCommentary', 'archivingCommentaryMessage', 'archivingButton'];

archivingCommentary() {
console.log("archivingCommentary" + this.archivingCommentaryTarget.value);
const commentary = this.archivingCommentaryTarget.value.trim();
const isValid = commentary.length > 5;

if (isValid) {
this.archivingCommentaryMessageTarget.textContent = "";
this.archivingButtonTarget.disabled = false;
this.archivingButtonTarget.hidden = false;
} else {
this.archivingCommentaryMessageTarget.textContent = "Format invalide. Veuillez saisir un commentaire plus complet.";
this.archivingCommentaryMessageTarget.style.color = "red"; // Display the message in red color.
}
}
}
3 changes: 2 additions & 1 deletion src/Controller/AdminController.php
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,8 @@ public function productVersionCreation(Request $request): Response
public function archiveEntity(Request $request, string $entityType, int $id): Response
{
$originUrl = $request->headers->get('referer');
$result = $this->entityDeletionService->archivedEntity($entityType, $id);
$this->logger->info('Archive entity: ' . $entityType . ' ' . $id . ' full request: ' . json_encode($request->getContent()));
$result = $this->entityDeletionService->archivedEntity($entityType, $id, $request);
if ($result == false) {
$this->addFlash('danger', 'L\'élément n\'a pas pu être archivé');
return $this->redirect($originUrl);
Expand Down
15 changes: 15 additions & 0 deletions src/Entity/EFNC.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,9 @@ class EFNC
#[ORM\ManyToOne(inversedBy: 'eFNCs')]
private ?User $lastModifier = null;

#[ORM\Column(type: Types::TEXT, nullable: true)]
private ?string $archivingCommentary = null;


public function __construct()
{
Expand Down Expand Up @@ -538,4 +541,16 @@ public function setLastModifier(?User $lastModifier): static

return $this;
}

public function getArchivingCommentary(): ?string
{
return $this->archivingCommentary;
}

public function setArchivingCommentary(?string $archivingCommentary): static
{
$this->archivingCommentary = $archivingCommentary;

return $this;
}
}
6 changes: 4 additions & 2 deletions src/Service/EntityDeletionService.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@


use Doctrine\ORM\EntityManagerInterface;
use Psr\Log\LoggerInterface;

use Psr\Log\LoggerInterface;

use App\Repository\UserRepository;
use App\Repository\TeamRepository;
Expand Down Expand Up @@ -83,7 +83,7 @@ public function __construct(
}

// This function is responsible for deleting an entity and its related entities from the database and the server filesystem
public function archivedEntity(string $entityType, int $id): bool
public function archivedEntity(string $entityType, int $id, string $commentary = null, string $user = null): bool
{
// Get the repository for the entity type
$repository = null;
Expand Down Expand Up @@ -141,6 +141,8 @@ public function archivedEntity(string $entityType, int $id): bool
$this->em->remove($entity);
}
if ($entityType === 'efnc') {
$entity->setLastModifier($user);
$entity->setArchivingCommentary($commentary);
$entity->setArchived(true);
}
if ($entityType === 'team') {
Expand Down
Empty file modified templates/services/efnc/display/closed_efnc_list.html.twig
100644 → 100755
Empty file.
66 changes: 49 additions & 17 deletions templates/services/efnc/modification/form_modification.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -165,12 +165,16 @@
</div>

{% if is_granted('ROLE_ADMIN') %}
<div
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 }}
</div>
{% if EFNC.LastModifier is null %}
{% else %}
<div
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 }}
</div>
{% endif %}
<div
class="d-grid gap-2 d-md-flex justify-content-md-center mt-1 textwhite">
<button
Expand All @@ -180,21 +184,49 @@
</button>
</div>
<div
class="d-grid gap-2 d-md-flex justify-content-md-center mt-5">
<a
class="btn btn-danger archive-EFNC"
href="{{path('app_archive_entity', {entityType: 'efnc', id: EFNC.id})}}">
Archiver
</a>
{% if is_granted('ROLE_MASTER_ADMIN') %}

class="container mt-5"
data-controller="archiving-commentary">
<div
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
class="d-grid gap-2 d-md-flex justify-content-md-center mt-2">
<a
id="archivingButton"
name="archivingButton"
data-archiving-commentary-target="archivingButton"
class="btn btn-danger archive-EFNC"
href="{{path('app_close_entity', {entityType: 'efnc', id: EFNC.id})}}">
Cloturer
href="{{path('app_archive_entity', {entityType: 'efnc', id: EFNC.id})}}" hidden
disabled>
Archiver
</a>
{% 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>
{% endif %}
</div>

{% endif %}
</div>
{{ form_end(form1) }}
Expand Down
Loading
Loading