Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
kohinos-tav
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
3
Merge Requests
3
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
agplv3
kohinos-tav
Commits
62ce2ea5
Commit
62ce2ea5
authored
a year ago
by
Yvon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
use cleaner state values for selfevalformtype operating mode
parent
9f571319
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
21 additions
and
18 deletions
+21
-18
PrestataireAdminController.php
src/Controller/PrestataireAdminController.php
+2
-1
PrestatairesController.php
src/Controller/PrestatairesController.php
+2
-1
DistributorSelfEvalPrestaQuizType.php
src/Form/Type/DistributorSelfEvalPrestaQuizType.php
+1
-1
ProducerSelfEvalPrestaQuizType.php
src/Form/Type/ProducerSelfEvalPrestaQuizType.php
+1
-1
SelfEvalPrestaQuizType.php
src/Form/Type/SelfEvalPrestaQuizType.php
+15
-14
No files found.
src/Controller/PrestataireAdminController.php
View file @
62ce2ea5
...
...
@@ -8,6 +8,7 @@ use App\Entity\Prestataire;
use
App\Enum\MoyenEnum
;
use
App\Form\Type\DistributorSelfEvalPrestaQuizType
;
use
App\Form\Type\ProducerSelfEvalPrestaQuizType
;
use
App\Form\Type\SelfEvalPrestaQuizType
;
use
App\Utils\CustomEntityManager
;
use
DateTime
;
use
Sonata\AdminBundle\Controller\CRUDController
;
...
...
@@ -138,7 +139,7 @@ class PrestataireAdminController extends CRUDController
$quiz
=
$prestataire
->
getSelfEvalPrestaQuiz
();
$formClass
=
Prestataire
::
DISTRIBUTOR
===
$prestataire
->
getMarketChannelFunction
()
?
DistributorSelfEvalPrestaQuizType
::
class
:
ProducerSelfEvalPrestaQuizType
::
class
;
$form
=
$this
->
createForm
(
$formClass
,
$quiz
,
[
"
review"
=>
true
]);
$form
=
$this
->
createForm
(
$formClass
,
$quiz
,
[
"
mode"
=>
SelfEvalPrestaQuizType
::
ADMIN_EDIT
]);
$form
->
handleRequest
(
$request
);
...
...
This diff is collapsed.
Click to expand it.
src/Controller/PrestatairesController.php
View file @
62ce2ea5
...
...
@@ -9,6 +9,7 @@ use App\Entity\Flux;
use
App\Entity\SelfEvalPrestaQuiz
;
use
App\Form\Type\DistributorSelfEvalPrestaQuizType
;
use
App\Form\Type\ProducerSelfEvalPrestaQuizType
;
use
App\Form\Type\SelfEvalPrestaQuizType
;
use
Doctrine\ORM\EntityManagerInterface
;
use
Symfony\Component\HttpFoundation\RedirectResponse
;
use
Symfony\Component\Routing\Annotation\Route
;
...
...
@@ -45,7 +46,7 @@ class PrestatairesController extends FrontController
$quiz
=
$prestataire
->
getSelfEvalPrestaQuiz
();
$formClass
=
Prestataire
::
DISTRIBUTOR
===
$prestataire
->
getMarketChannelFunction
()
?
DistributorSelfEvalPrestaQuizType
::
class
:
ProducerSelfEvalPrestaQuizType
::
class
;
$form
=
$this
->
createForm
(
$formClass
,
$quiz
,
[
"
review"
=>
"readonly"
]);
$form
=
$this
->
createForm
(
$formClass
,
$quiz
,
[
"
mode"
=>
SelfEvalPrestaQuizType
::
READONLY
]);
return
$this
->
render
(
'@kohinos/presta/show.html.twig'
,
[
'presta'
=>
$prestataire
,
...
...
This diff is collapsed.
Click to expand it.
src/Form/Type/DistributorSelfEvalPrestaQuizType.php
View file @
62ce2ea5
...
...
@@ -100,7 +100,7 @@ class DistributorSelfEvalPrestaQuizType extends SelfEvalPrestaQuizType
$builder
->
add
(
'localite_global_comment'
,
TextareaType
::
class
,
$this
->
cmtOpts
);
//Review
if
(
$options
[
'
review'
]
)
{
if
(
$options
[
'
mode'
]
!==
self
::
PRESTA_EDIT
)
{
$this
->
reviewOpts
[
'label'
]
=
"Transparence et juste rémunération : "
.
$this
->
reviewLabel
;
$this
->
reviewOpts
[
'choices'
]
=
$this
->
stdGlobalChoices
;
$builder
->
add
(
'review_transpar_global'
,
ChoiceType
::
class
,
$this
->
reviewOpts
);
...
...
This diff is collapsed.
Click to expand it.
src/Form/Type/ProducerSelfEvalPrestaQuizType.php
View file @
62ce2ea5
...
...
@@ -59,7 +59,7 @@ class ProducerSelfEvalPrestaQuizType extends SelfEvalPrestaQuizType
$builder
->
add
(
'proagdur_global_comment'
,
TextareaType
::
class
,
$this
->
cmtOpts
);
//Review
if
(
$options
[
'
review'
]
)
{
if
(
$options
[
'
mode'
]
!==
self
::
PRESTA_EDIT
)
{
$this
->
reviewOpts
[
'label'
]
=
"Pratiques agricoles durables : "
.
$this
->
reviewLabel
;
$this
->
reviewOpts
[
'choices'
]
=
$this
->
stdGlobalChoices
;
$builder
->
add
(
'review_proagdur_global'
,
ChoiceType
::
class
,
$this
->
reviewOpts
);
...
...
This diff is collapsed.
Click to expand it.
src/Form/Type/SelfEvalPrestaQuizType.php
View file @
62ce2ea5
...
...
@@ -20,6 +20,10 @@ use Symfony\Component\Validator\Constraints\NotNull;
*/
class
SelfEvalPrestaQuizType
extends
AbstractType
{
const
PRESTA_EDIT
=
'presta_edit'
;
const
ADMIN_EDIT
=
'admin_edit'
;
const
READONLY
=
'readonly'
;
protected
$security
;
protected
array
$stdChoices
;
...
...
@@ -57,28 +61,28 @@ class SelfEvalPrestaQuizType extends AbstractType
public
function
buildForm
(
FormBuilderInterface
$builder
,
array
$options
)
{
//options are moved to buildForm as '
review
' option is required to set them up
//options are moved to buildForm as '
mode
' option is required to set them up
$this
->
reviewOpts
=
[
'label'
=>
''
,
'choices'
=>
$this
->
stdChoices
,
'expanded'
=>
true
,
"multiple"
=>
false
,
'constraints'
=>
[
new
NotNull
()],
'disabled'
=>
$options
[
'
review'
]
===
"readonly"
'disabled'
=>
$options
[
'
mode'
]
===
self
::
READONLY
];
$this
->
opts
=
$this
->
reviewOpts
;
$this
->
opts
[
'disabled'
]
=
$options
[
'
review'
]
;
$this
->
opts
[
'disabled'
]
=
$options
[
'
mode'
]
!==
self
::
PRESTA_EDIT
;
$this
->
reviewCmtOpts
=
[
'attr'
=>
[
'placeholder'
=>
$options
[
'
review'
]
===
"readonly"
?
''
:
'Commentaires'
'placeholder'
=>
$options
[
'
mode'
]
===
self
::
READONLY
?
''
:
'Commentaires'
],
'label'
=>
false
,
'required'
=>
false
,
'disabled'
=>
$options
[
'
review'
]
===
"readonly"
'disabled'
=>
$options
[
'
mode'
]
===
self
::
READONLY
];
$this
->
cmtOpts
=
$this
->
reviewCmtOpts
;
$this
->
cmtOpts
[
'disabled'
]
=
$options
[
'
review'
]
;
$this
->
cmtOpts
[
'attr'
][
'placeholder'
]
=
$options
[
'
review'
]
?
''
:
'Commentaires'
;
$this
->
cmtOpts
[
'disabled'
]
=
$options
[
'
mode'
]
!==
self
::
PRESTA_EDIT
;
$this
->
cmtOpts
[
'attr'
][
'placeholder'
]
=
$options
[
'
mode'
]
!==
self
::
PRESTA_EDIT
?
''
:
'Commentaires'
;
/* PARTIE 1 : ACCESSIBILITE ET INCLUSIVITE */
$this
->
opts
[
'label'
]
=
"Géographique et physique : le lieu est-il accessible par différents modes de transport ?"
;
...
...
@@ -138,7 +142,7 @@ class SelfEvalPrestaQuizType extends AbstractType
$builder
->
add
(
'bienetre_global_comment'
,
TextareaType
::
class
,
$this
->
cmtOpts
);
//Review
if
(
$options
[
'
review'
]
)
{
if
(
$options
[
'
mode'
]
!==
self
::
PRESTA_EDIT
)
{
$this
->
reviewOpts
[
'label'
]
=
"Accessibilité et inclusivité : "
.
$this
->
reviewLabel
;
$this
->
reviewOpts
[
'choices'
]
=
$this
->
stdGlobalChoices
;
$builder
->
add
(
'review_accessib_global'
,
ChoiceType
::
class
,
$this
->
reviewOpts
);
...
...
@@ -150,8 +154,8 @@ class SelfEvalPrestaQuizType extends AbstractType
$builder
->
add
(
'review_bienetre_global_comment'
,
TextareaType
::
class
,
$this
->
reviewCmtOpts
);
}
if
(
$options
[
"review"
]
!==
"readonly"
)
{
$builder
->
add
(
'save'
,
SubmitType
::
class
,
[
'label'
=>
$options
[
'
review'
]
?
'Enregistrer'
:
'Envoy
er'
]);
if
(
$options
[
'mode'
]
!==
self
::
READONLY
)
{
$builder
->
add
(
'save'
,
SubmitType
::
class
,
[
'label'
=>
$options
[
'
mode'
]
===
self
::
PRESTA_EDIT
?
'Envoyer'
:
'Enregistr
er'
]);
}
}
...
...
@@ -162,10 +166,7 @@ class SelfEvalPrestaQuizType extends AbstractType
{
$resolver
->
setDefaults
([
'data_class'
=>
SelfEvalPrestaQuiz
::
class
,
//review says if prestataire is filling the form (false),
//if an admin is reviewing (true)
//or if read mode on presta vitrine ("readonly")
'review'
=>
false
'mode'
=>
self
::
PRESTA_EDIT
]);
}
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment