Commit 5a42967a by Damien Moulard

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

parent 1ac5109e
......@@ -344,3 +344,10 @@ form[name="formEncaissement"] label {
/**
* END Success check animation.
*/
.prestaquizz_temporary_save_container {
position: fixed;
bottom: 0;
right: 1rem;
z-index: 2;
}
\ No newline at end of file
......@@ -633,4 +633,17 @@ $(function() {
});
}
});
/**
* On prestataire self evaluation quizz, remove all required attributes in form on click on the temporary save button.
* Set form hidden data to not 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");
});
});
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.7536af12.js"
"/build/app.7e72c532.js"
],
"css": [
"/build/app.95a5ad0e.css"
"/build/app.20b881c9.css"
]
},
"admin": {
......
{
"build/app.css": "/build/app.95a5ad0e.css",
"build/app.js": "/build/app.7536af12.js",
"build/app.css": "/build/app.20b881c9.css",
"build/app.js": "/build/app.7e72c532.js",
"build/admin.css": "/build/admin.5dc0eea7.css",
"build/admin.js": "/build/admin.cee4d78d.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,13 +285,18 @@ class IndexController extends AbstractController
$formClass = Prestataire::DISTRIBUTOR === $presta->getMarketChannelFunction() ?
DistributorSelfEvalPrestaQuizType::class : ProducerSelfEvalPrestaQuizType::class;
// 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()) {
$presta->setSelfEvalPrestaQuiz($quiz);
$quiz->isSubmitted = $form->get('submit_presta_quizz')->getData() == '1';
$this->em->persist($quiz);
$this->em->flush();
......
......@@ -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;
/**
*
......@@ -67,7 +67,6 @@ class SelfEvalPrestaQuizType extends AbstractType
'choices' => $this->stdChoices,
'expanded' => true,
"multiple" => false,
'constraints' => [new NotNull()],
'disabled' => $options['mode'] === self::READONLY
];
$this->opts = $this->reviewOpts;
......@@ -155,8 +154,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