Skip to content

Commit

Permalink
Merge pull request #98 from kiloutyg/97-change-commentary-process
Browse files Browse the repository at this point in the history
added the checkbox mechanism to reduce time to archive and close ncfs
  • Loading branch information
kiloutyg authored Jul 9, 2024
2 parents a725860 + c3b3408 commit 61338d6
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 12 deletions.
15 changes: 10 additions & 5 deletions assets/controllers/archiving_commentary_controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import { Controller } from '@hotwired/stimulus';

export default class archivingCommentaryController extends Controller {

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

static targets = ['archivingCommentary', 'archivingCommentaryMessage', 'archivingButton', 'archivingCheckbox'
];
connect() {
// Initialization code or leave empty if not needed
}
Expand All @@ -13,13 +13,18 @@ export default class archivingCommentaryController extends Controller {
const commentary = this.archivingCommentaryTarget.value.trim();
const isValid = commentary.length > 5;

if (isValid) {
console.log("has the checkbox been checked? " + this.archivingCheckboxTarget.checked);
const checked = this.archivingCheckboxTarget.checked;

if (isValid || checked) {
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.
this.archivingCommentaryMessageTarget.textContent = "Format invalide. Veuillez saisir un commentaire plus complet ou cocher la case.";
this.archivingCommentaryMessageTarget.style.color = "darkred"; // Display the message in red color.
this.archivingButtonTarget.disabled = true;
this.archivingButtonTarget.hidden = true;
}
}

Expand Down
11 changes: 8 additions & 3 deletions assets/controllers/closing_commentary_controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Controller } from '@hotwired/stimulus';

export default class closingCommentaryController extends Controller {

static targets = ['closingCommentary', 'closingCommentaryMessage', 'closingButton'];
static targets = ['closingCommentary', 'closingCommentaryMessage', 'closingButton', 'closingCheckbox'];

connect() {
// Initialization code or leave empty if not needed
Expand All @@ -13,13 +13,18 @@ export default class closingCommentaryController extends Controller {
const commentary = this.closingCommentaryTarget.value.trim();
const isValid = commentary.length > 5;

if (isValid) {
console.log("has the checkbox been checked? " + this.closingCheckboxTarget.checked);
const checked = this.closingCheckboxTarget.checked;

if (isValid || checked) {
this.closingCommentaryMessageTarget.textContent = "";
this.closingButtonTarget.disabled = false;
this.closingButtonTarget.hidden = false;
} else {
this.closingCommentaryMessageTarget.textContent = "Format invalide. Veuillez saisir un commentaire plus complet.";
this.closingCommentaryMessageTarget.style.color = "red"; // Display the message in red color.
this.closingCommentaryMessageTarget.style.color = "darkred"; // Display the message in red color.
this.closingButtonTarget.disabled = true;
this.closingButtonTarget.hidden = true;
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/Controller/AdminController.php
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,7 @@ public function closeEntity(Request $request, string $entityType, int $id): Resp
$user = $this->getUser()->getUsername();

$commentary = $request->request->get('closingCommentary');
if ($entityType == "efnc" && $commentary == null) {
if ($entityType == "efnc" && $commentary == null && $request->request->get('closingCheckbox') === "false") {
$this->addFlash('danger', 'Un commentaire est requis pour archiver une EFNC');
return $this->redirect($originUrl);
}
Expand Down Expand Up @@ -393,7 +393,7 @@ public function archiveEntity(Request $request, string $entityType, int $id): Re
$user = $this->getUser()->getUsername();
$commentary = $request->request->get('archivingCommentary');

if ($entityType == "efnc" && $commentary == null) {
if ($entityType == "efnc" && $commentary == null && $request->request->get('archivingCheckbox') === "false") {
$this->addFlash('danger', 'Un commentaire est requis pour archiver une EFNC');
return $this->redirect($originUrl);
}
Expand Down
35 changes: 33 additions & 2 deletions templates/services/efnc/modification/form_modification.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -212,10 +212,26 @@
class="row justify-content-md-center">
<div
class="col-md-12">

<label
for="archivingCommentary"
class="form-label text-white">
Commentaire d'archivage obligatoire, si la fiche ne respecte pas le standard prévu (Ecrire le commentaire pour faire apparaitre le bouton d'archivage)
Commentaire d'archivage obligatoire, si la fiche ne respecte pas le standard prévu (Ecrire le commentaire pour faire apparaitre le bouton d'archivage ou, si pas de commentaire, cocher:
<input
class="btn-check m-0"
type="checkbox"
id="archivingCheckbox"
name="archivingCheckbox"
value="true"
data-archiving-commentary-target="archivingCheckbox"
data-action="click->archiving-commentary#archivingCommentary">
<label
autocomplete="off"
class="btn btn-outline-info m-0 mb-1"
for="archivingCheckbox">
Archiver la FNC pour non validité
</label>
)
<div
data-archiving-commentary-target="archivingCommentaryMessage"
class="archivingCommentaryMessage-message d-flex justify-content-evenly"></div>
Expand Down Expand Up @@ -257,7 +273,22 @@
<label
for="closingCommentary"
class="form-label text-white">
Commentaire de cloture obligatoire, si les actions sont cloturées dans le PDCA de l'UAP concerné (Ecrire le commentaire pour faire apparaitre le bouton de cloture)
Commentaire de cloture obligatoire, si les actions sont cloturées dans le PDCA de l'UAP concerné (Ecrire le commentaire pour faire apparaitre le bouton de cloture ou si absence de récurrence cocher :
<input
class="btn-check m-0"
type="checkbox"
id="closingCheckbox"
name="closingCheckbox"
value="true"
data-closing-commentary-target="closingCheckbox"
data-action="click->closing-commentary#closingCommentary">
<label
autocomplete="off"
class="btn btn-outline-info m-0 mb-1"
for="closingCheckbox">
Clore la FNC pour non récurrence
</label>
)
<div
data-closing-commentary-target="closingCommentaryMessage"
class="closingCommentaryMessage-message d-flex justify-content-evenly"></div>
Expand Down

0 comments on commit 61338d6

Please sign in to comment.