Project 'cooperatic/kohinos-tav' was moved to 'agplv3/kohinos-tav'. Please update any links and bookmarks that may still have the old path.
Commit 95e2b8dd by Yvon Kerdoncuff

Merge branch '5868-presta-self-eval-save-and-come-back-later' into 'ssa-gironde'

add save and come back later button on prestataire self eval quizz

See merge request cooperatic/kohinos-tav!56
parents 8be42f4b 04f1d040
......@@ -345,6 +345,17 @@ form[name="formEncaissement"] label {
border: 5px solid #CBC3E3;
}
/**
* END Success check animation.
*/
.prestaquizz_temporary_save_container {
position: fixed;
bottom: 0;
right: 1rem;
z-index: 2;
}
.presta-products-family {
display: flex;
margin-bottom: 1rem;
......@@ -386,4 +397,4 @@ form[name="formEncaissement"] label {
margin-top: -0.25rem;
text-align: right;
font-style: italic;
}
\ No newline at end of file
}
......@@ -634,6 +634,22 @@ $(function() {
}
});
// Reset hidden data on prestataire self evaluation quizz, for definitive form submition
$('#formDistributorSelfEvalPrestaQuiz_submit_presta_quizz').val('1');
/**
* On prestataire self evaluation quizz, remove all required attributes in form on click on the temporary save button.
* Set form hidden data to not definitively submit the form.
*/
$("#formDistributorSelfEvalPrestaQuiz_temporary_save").on("click", (e) => {
e.preventDefault();
$('form[name="formDistributorSelfEvalPrestaQuiz"] input').removeAttr('required');
$('#formDistributorSelfEvalPrestaQuiz_submit_presta_quizz').val('0');
$('form[name="formDistributorSelfEvalPrestaQuiz"]').trigger("submit");
});
/**
* Delete a PrestataireProductFamily node on icon click
* @param {Event} e
......
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -3,10 +3,10 @@
"app": {
"js": [
"/build/runtime.6ad5c9da.js",
"/build/app.a853f656.js"
"/build/app.94b71822.js"
],
"css": [
"/build/app.89f95ed2.css"
"/build/app.c40ef51c.css"
]
},
"admin": {
......
{
"build/app.css": "/build/app.89f95ed2.css",
"build/app.js": "/build/app.a853f656.js",
"build/app.css": "/build/app.c40ef51c.css",
"build/app.js": "/build/app.94b71822.js",
"build/admin.css": "/build/admin.5dc0eea7.css",
"build/admin.js": "/build/admin.86a2d986.js",
"build/runtime.js": "/build/runtime.6ad5c9da.js",
......
......@@ -124,6 +124,8 @@ class IndexController extends AbstractController
'Suite à la modification de votre mot de passe, pensez à mettre à jour votre code de paiment pour pouvoir effectuer des achats.'
);
}
// Redirect prestaire at login if self evaluation process is enabled
list($redirRoute,$presta) = $this->getAndDispatchPrestataire('index');
if ($redirRoute) {
return $this->redirectToRoute($redirRoute);
......@@ -185,7 +187,8 @@ class IndexController extends AbstractController
}
//Go to "all forms already sent, please just wait now" page if questionnaire has been submitted already
if ($presta->getSelfEvalPrestaQuiz()) {
$prestaQuizz = $presta->getSelfEvalPrestaQuiz();
if ($prestaQuizz && $prestaQuizz->isSubmitted) {
$destination = 'prestaquiz-sent';
return $destination !== $origin ? [$destination, $presta] : [null, $presta];
}
......@@ -282,25 +285,33 @@ class IndexController extends AbstractController
$formClass = Prestataire::DISTRIBUTOR === $presta->getMarketChannelFunction() ?
DistributorSelfEvalPrestaQuizType::class : ProducerSelfEvalPrestaQuizType::class;
$quiz = new SelfEvalPrestaQuiz();
// Get existing form if it has been saved for future completion
$quiz = $presta->getSelfEvalPrestaQuiz();
if (null == $quiz) {
$quiz = new SelfEvalPrestaQuiz();
}
$form = $this->createForm($formClass, $quiz);
$form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid()) {
$definitiveSubmit = $form->get('submit_presta_quizz')->getData() == '1';
$presta->setSelfEvalPrestaQuiz($quiz);
$quiz->isSubmitted = $definitiveSubmit;
$this->em->persist($quiz);
$this->em->flush();
//Send email !
$this->notifyGestionnaireAfterPrestaquizSent($presta);
if ($definitiveSubmit) {
$this->notifyGestionnaireAfterPrestaquizSent($presta);
}
list($redirRoute,$presta) = $this->getAndDispatchPrestataire('prestaquiz-selfeval');
if ($redirRoute) {
return $this->redirectToRoute($redirRoute);
}
}
$tmpl = Prestataire::DISTRIBUTOR === $presta->getMarketChannelFunction() ?
'@kohinos/tav/prestaquiz/distributor.html.twig'
: '@kohinos/tav/prestaquiz/producer.html.twig';
......
......@@ -393,5 +393,10 @@ class SelfEvalPrestaQuiz
* @ORM\Column(type="text", nullable=true)
*/
public $review_localite_global_comment;
/**
* As the form been fully submitted?
* @var bool
* @ORM\Column(type="boolean", nullable=false, options={"default" : false})
*/
public $isSubmitted;
}
......@@ -7,10 +7,10 @@ use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
use Symfony\Component\Form\Extension\Core\Type\TextareaType;
use Symfony\Component\Form\Extension\Core\Type\HiddenType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Component\Security\Core\Security;
use Symfony\Component\Validator\Constraints\NotNull;
/**
*
......@@ -68,7 +68,6 @@ class SelfEvalPrestaQuizType extends AbstractType
'choices' => $this->stdChoices,
'expanded' => true,
"multiple" => false,
'constraints' => [new NotNull()],
'disabled' => $options['mode'] === self::READONLY
];
$this->opts = $this->reviewOpts;
......@@ -161,8 +160,17 @@ class SelfEvalPrestaQuizType extends AbstractType
}
if($options['mode'] !== self::READONLY) {
$builder->add('submit_presta_quizz', HiddenType::class, [
"mapped" => false,
"data" => 1,
"empty_data" => 1
]);
$builder->add('save', SubmitType::class, ['label' => $options['mode'] === self::PRESTA_EDIT ? 'Envoyer' : 'Enregistrer']);
}
if($options['mode'] == self::PRESTA_EDIT) {
$builder->add('temporary_save', SubmitType::class, ['label' => 'Sauvegarder afin de revenir plus tard']);
}
}
/**
......
<?php
declare(strict_types=1);
namespace DoctrineMigrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20240227100023 extends AbstractMigration
{
public function getDescription() : string
{
return '';
}
public function up(Schema $schema) : void
{
// this up() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE selfevalprestaquiz ADD is_submitted TINYINT(1) DEFAULT \'0\' NOT NULL');
}
public function down(Schema $schema) : void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE selfevalprestaquiz DROP is_submitted');
}
}
......@@ -127,4 +127,10 @@
<br/>
<br/>
{% if form.temporary_save is defined %}
<div class="prestaquizz_temporary_save_container">
{{ form_row(form.temporary_save) }}
</div>
{% endif %}
{{ form_end(form) }}
\ No newline at end of file
......@@ -80,4 +80,10 @@
<br/>
<br/>
{% if form.temporary_save is defined %}
<div class="prestaquizz_temporary_save_container">
{{ form_row(form.temporary_save) }}
</div>
{% endif %}
{{ form_end(form) }}
\ No newline at end of file
{% if object.selfevalprestaquiz %}
{% if object.selfevalprestaquiz and object.selfevalprestaquiz.isSubmitted %}
<a class="btn btn-sm btn-default" href="{{ admin.generateObjectUrl('reviewprestaquiz', object) }}">
Revue QCM
</a>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment