Skip to content

Commit

Permalink
delete feature flipping espace docu #2558
Browse files Browse the repository at this point in the history
  • Loading branch information
hmeneuvrier committed May 15, 2024
1 parent 1145569 commit 704f089
Show file tree
Hide file tree
Showing 10 changed files with 30 additions and 65 deletions.
1 change: 0 additions & 1 deletion .env
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ WIDGET_SIGNALEMENT_TERRITOIRE_CACHE_EXPIRED_AFTER=30 #second
WIDGET_ESABORA_EVENTS_CACHE_EXPIRED_AFTER=3600 #second
FEATURE_ASK_VISITE_ENABLE=1
FEATURE_OILHI_ENABLE=1
FEATURE_DOCUMENTS_ENABLE=1
CRON_ENABLE=1
MAIL_ENABLE=1
ESABORA_CRON_CLOCK_SLEEP_INTERVAL=60 #second
Expand Down
1 change: 0 additions & 1 deletion .env.sample
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ WIREMOCK_HOSTNAME=histologe_wiremock
WIREMOCK_PORT=8080
FEATURE_OILHI_ENABLE=1
FEATURE_ASK_VISITE_ENABLE=1
FEATURE_DOCUMENTS_ENABLE=1
CRON_ENABLE=1
MAIL_ENABLE=1
ESABORA_CRON_CLOCK_SLEEP_INTERVAL=60 #second
Expand Down
1 change: 0 additions & 1 deletion config/services.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ parameters:
mail_enable: '%env(bool:MAIL_ENABLE)%'
feature_ask_visite: '%env(FEATURE_ASK_VISITE_ENABLE)%'
feature_oilhi_enable: '%env(bool:FEATURE_OILHI_ENABLE)%'
feature_documents_enable: '%env(bool:FEATURE_DOCUMENTS_ENABLE)%'
feature_signalement_liste_enable: '%env(bool:FEATURE_LIST_FILTER_ENABLE)%'
platform_name: 'Histologe'
matomo_enable: '%env(bool:MATOMO_ENABLE)%'
Expand Down
4 changes: 2 additions & 2 deletions src/Controller/Back/SignalementController.php
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,6 @@ public function viewSignalement(
'listConcludeProcedures' => $listConcludeProcedures,
'partnersCanVisite' => $partnerVisite,
'pendingVisites' => $interventionRepository->getPendingVisitesForSignalement($signalement),
'isDocumentsEnabled' => $parameterBag->get('feature_documents_enable'),
'allPhotosOrdered' => $allPhotosOrdered,
]);
}
Expand Down Expand Up @@ -248,7 +247,8 @@ public function newDeleteSignalement(
$this->denyAccessUnlessGranted('SIGN_DELETE', $signalement);
if ($this->isCsrfTokenValid(
'signalement_delete_'.$signalement->getId(),
$request->getPayload()->get('_token'))
$request->getPayload()->get('_token')
)
) {
$signalement->setStatut(Signalement::STATUS_ARCHIVED);
$doctrine->getManager()->persist($signalement);
Expand Down
24 changes: 7 additions & 17 deletions src/Controller/Back/SignalementFileController.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
use Doctrine\ORM\EntityManagerInterface;
use League\Flysystem\FilesystemException;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\DependencyInjection\Attribute\Autowire;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
Expand Down Expand Up @@ -57,10 +56,7 @@ public function addFileSignalement(
Signalement $signalement,
Request $request,
EntityManagerInterface $entityManager,
SuiviManager $suiviManager,
SignalementFileProcessor $signalementFileProcessor,
#[Autowire(env: 'FEATURE_DOCUMENTS_ENABLE')]
bool $featureDocumentsEnable
SignalementFileProcessor $signalementFileProcessor
): Response {
$this->denyAccessUnlessGranted('FILE_CREATE', $signalement);
if (!$this->isCsrfTokenValid('signalement_add_file_'.$signalement->getId(), $request->get('_token')) || !$files = $request->files->get('signalement-add-file')) {
Expand Down Expand Up @@ -89,18 +85,12 @@ public function addFileSignalement(

return $this->redirect($this->generateUrl('back_signalement_view', ['uuid' => $signalement->getUuid()]));
}
if ($featureDocumentsEnable) {
$signalementFileProcessor->addFilesToSignalement(
fileList: $fileList,
signalement: $signalement,
user: $this->getUser(),
isWaitingSuivi: true
);
} else {
$filesList = $signalementFileProcessor->addFilesToSignalement($fileList, $signalement, $this->getUser());
$suivi = $suiviManager->createInstanceForFilesSignalement($this->getUser(), $signalement, $filesList);
$entityManager->persist($suivi);
}
$signalementFileProcessor->addFilesToSignalement(
fileList: $fileList,
signalement: $signalement,
user: $this->getUser(),
isWaitingSuivi: true
);
$entityManager->persist($signalement);
$entityManager->flush();
if ($request->isXmlHttpRequest()) {
Expand Down
1 change: 0 additions & 1 deletion src/Security/Voter/FileVoter.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ private function canView(Signalement $subject, User $user = null): bool
private function canEdit(File $file, User $user): bool
{
return $this->canCreate($file->getSignalement(), $user)
&& $this->parameterBag->get('feature_documents_enable')
&& (
$this->isFileUploadedByUser($file, $user)
||
Expand Down
2 changes: 1 addition & 1 deletion templates/back/signalement/view.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
{% if canEditNDE %}
{% include '_partials/_modal_edit_nde.html.twig' %}
{% endif %}
{% if (is_granted('FILE_CREATE', signalement) and isDocumentsEnabled) %}
{% if is_granted('FILE_CREATE', signalement) %}
{% include '_partials/_modal_upload_files.html.twig' %}
{% endif %}
{% if is_granted('ROLE_ADMIN') %}
Expand Down
55 changes: 17 additions & 38 deletions templates/back/signalement/view/photos-documents.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -6,53 +6,32 @@
</div>
<div class="fr-col-3 fr-col-md-6 fr-text--right">
{% if (is_granted('FILE_CREATE', signalement)) %}
{% if isDocumentsEnabled %}
<ul class="fr-btns-group fr-btns-group--inline fr-btns-group--sm fr-btns-group--right fr-btns-group--icon-left">
<ul class="fr-btns-group fr-btns-group--inline fr-btns-group--sm fr-btns-group--right fr-btns-group--icon-left">
<li>
<button
class="fr-btn fr-btn--secondary fr-icon-file-add-line open-modal-upload-files-btn"
data-fr-opened="false"
aria-controls="fr-modal-upload-files"
data-file-type="document"
data-file-filter={{filesFilter}}
>
Ajouter des documents
</button>
</li>
{% if filesFilter is same as 'situation' %}
<li>
<button
class="fr-btn fr-btn--secondary fr-icon-file-add-line open-modal-upload-files-btn"
class="fr-btn fr-btn--secondary fr-icon-image-add-line open-modal-upload-files-btn"
data-fr-opened="false"
aria-controls="fr-modal-upload-files"
data-file-type="document"
data-file-type="photo"
data-file-filter={{filesFilter}}
>
Ajouter des documents
Ajouter des photos
</button>
</li>
{% if filesFilter is same as 'situation' %}
<li>
<button
class="fr-btn fr-btn--secondary fr-icon-image-add-line open-modal-upload-files-btn"
data-fr-opened="false"
aria-controls="fr-modal-upload-files"
data-file-type="photo"
data-file-filter={{filesFilter}}
>
Ajouter des photos
</button>
</li>
{% endif %}
</ul>
{% else %}
<form method="POST" enctype="multipart/form-data" class="inline-form" action="{{ path('back_signalement_add_file',{uuid:signalement.uuid}) }}">
<label class="fr-btn fr-btn--sm fr-fi-file-fill fr-btn--icon-left"> Ajouter des documents
<input type="file" accept="application/*" name="signalement-add-file[documents][]" class="fr-hidden fr-input--file-signalement" multiple>
</label>
<input type="hidden" name="_token" value="{{ csrf_token('signalement_add_file_'~signalement.id) }}">
<input type="hidden" name="document_type" value="{{ enum('App\\Entity\\Enum\\DocumentType').AUTRE.name }}">
</form>
{% if filesFilter is same as 'situation' %}
<form method="POST" enctype="multipart/form-data" class="inline-form" action="{{ path('back_signalement_add_file',{uuid:signalement.uuid}) }}">
<label class="fr-btn fr-btn--sm fr-btn--secondary fr-btn--icon-left fr-icon-camera-fill"> Ajouter des photos
<input type="file" accept="image/*" name="signalement-add-file[photos][]" class="fr-hidden fr-input--file-signalement" multiple>
</label>
<input type="hidden" name="_token" value="{{ csrf_token('signalement_add_file_'~signalement.id) }}">
<input type="hidden" name="document_type" value="{{ enum('App\\Entity\\Enum\\DocumentType').AUTRE.name }}">
</form>
{% endif %}
{% endif %}


</ul>
{% endif %}
</div>
{% if filesFilter is same as 'situation' %}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
{% include 'back/signalement/view/visites/modals/visites-modal-reschedule.html.twig' %}
{% elseif intervention.status is same as constant('App\\Entity\\Intervention::STATUS_DONE') %}
{% include 'back/signalement/view/visites/modals/visites-modal-edit.html.twig' %}
{% if (is_granted('FILE_CREATE', signalement) and isDocumentsEnabled) %}
{% if is_granted('FILE_CREATE', signalement) %}
{% include 'back/signalement/view/visites/modals/visites-modal-upload-files.html.twig' %}
{% endif %}
{% endif %}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
{% endif %}
{% elseif intervention.status is same as constant('App\\Entity\\Intervention::STATUS_DONE') %}
{% if signalement.interventions is empty or intervention.files is empty or intervention.getRapportDeVisite is empty%}
{% if isDocumentsEnabled and is_granted('INTERVENTION_EDIT_VISITE', intervention) %}
{% if is_granted('INTERVENTION_EDIT_VISITE', intervention) %}
<button
class="fr-btn fr-fi-file-fill"
aria-controls="edit-visite-modal-{{intervention.id}}"
Expand All @@ -47,7 +47,7 @@
<span aria-hidden="true" class="fr-fi-file-line fr-icon--sm"></span> Voir le rapport de visite
</a>
{% endif %}
{% if isDocumentsEnabled and is_granted('INTERVENTION_EDIT_VISITE', intervention)%}
{% if is_granted('INTERVENTION_EDIT_VISITE', intervention)%}
<button
class="fr-btn fr-btn--secondary fr-icon-camera-fill open-modal-upload-files-btn"
data-fr-opened="false"
Expand Down

0 comments on commit 704f089

Please sign in to comment.