{% block crud_content_header %}
{{ ('crud.'~crud_name~'.title_edit')|trans }}
{% endblock crud_content_header %} diff --git a/src/Bundle/ChillMainBundle/Resources/views/CRUD/_new_content.html.twig b/src/Bundle/ChillMainBundle/Resources/views/CRUD/_new_content.html.twig index 4c2003617..906a77d0d 100644 --- a/src/Bundle/ChillMainBundle/Resources/views/CRUD/_new_content.html.twig +++ b/src/Bundle/ChillMainBundle/Resources/views/CRUD/_new_content.html.twig @@ -1,10 +1,11 @@ +{% set formId = crudMainFormId|default('crud_main_form') %}
{% block crud_content_header %}
{{ ('crud.' ~ crud_name ~ '.title_new')|trans({'%crud_name%' : crud_name }) }}
{% endblock crud_content_header %} {% block crud_content_form %} - {{ form_start(form) }} + {{ form_start(form, { 'attr' : { 'id': formId } }) }} {% block crud_content_form_rows %} {% for f in form %}{% if f.vars.name != 'submit' %} @@ -14,6 +15,8 @@ {% block crud_content_after_form %}{% endblock %} + {{ form_end(form) }} + {% block crud_content_form_actions %}-
{% block content_form_actions_back %}
@@ -25,21 +28,21 @@
{% endblock %}
{% block content_form_actions_save_and_close %}
- - {% endblock %} {% block content_form_actions_save_and_show %}
-
-
+ {{ 'crud.new.save_and_show'|trans }}
{% endblock %}
{% block content_form_actions_save_and_new %}
-
-
+ {{ 'crud.new.save_and_new'|trans }}
diff --git a/src/Bundle/ChillMainBundle/Resources/views/Form/fields.html.twig b/src/Bundle/ChillMainBundle/Resources/views/Form/fields.html.twig
index ce406286b..2179d1366 100644
--- a/src/Bundle/ChillMainBundle/Resources/views/Form/fields.html.twig
+++ b/src/Bundle/ChillMainBundle/Resources/views/Form/fields.html.twig
@@ -198,3 +198,15 @@
{{ form_widget(entry) }}
{% endfor %}
{% endblock comment_widget %}
+
+{% block pick_center_widget %}
+ {{ form_widget(form.center) }}
+{% endblock pick_center_widget %}
+
+{% block pick_center_row %}
+ {% if (not form.vars.is_hidden) %}
+ {{ block('form_row') }}
+ {% else %}
+ {{ form_widget(form.center) }}
+ {% endif %}
+{% endblock %}
diff --git a/src/Bundle/ChillMainBundle/config/services/form.yaml b/src/Bundle/ChillMainBundle/config/services/form.yaml
index c5cde5da0..b28ced053 100644
--- a/src/Bundle/ChillMainBundle/config/services/form.yaml
+++ b/src/Bundle/ChillMainBundle/config/services/form.yaml
@@ -36,7 +36,7 @@ services:
tags:
- { name: form.type, alias: select2_chill_language }
- Chill\MainBundle\Form\Type\CenterType:
+ Chill\MainBundle\Form\Type\PickCenterType:
autowire: true
autoconfigure: true
diff --git a/src/Bundle/ChillPersonBundle/Form/CreationPersonType.php b/src/Bundle/ChillPersonBundle/Form/CreationPersonType.php
index 36d088c25..8fa95fe4f 100644
--- a/src/Bundle/ChillPersonBundle/Form/CreationPersonType.php
+++ b/src/Bundle/ChillPersonBundle/Form/CreationPersonType.php
@@ -22,7 +22,9 @@
namespace Chill\PersonBundle\Form;
use Chill\MainBundle\Form\Event\CustomizeFormEvent;
+use Chill\MainBundle\Repository\CenterRepository;
use Chill\PersonBundle\Entity\Person;
+use Chill\PersonBundle\Security\Authorization\PersonVoter;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
@@ -30,12 +32,11 @@ use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Component\Form\Extension\Core\DataTransformer\DateTimeToStringTransformer;
use Symfony\Component\Form\Extension\Core\Type\HiddenType;
use Chill\MainBundle\Form\Type\ChillDateType;
-use Chill\MainBundle\Form\Type\CenterType;
+use Chill\MainBundle\Form\Type\PickCenterType;
use Chill\PersonBundle\Form\Type\GenderType;
use Chill\MainBundle\Form\Type\DataTransformer\CenterTransformer;
use Chill\PersonBundle\Config\ConfigPersonAltNamesHelper;
use Chill\PersonBundle\Form\Type\PersonAltNameType;
-use Chill\MainBundle\Form\Type\Export\PickCenterType;
final class CreationPersonType extends AbstractType
{
@@ -43,11 +44,7 @@ final class CreationPersonType extends AbstractType
// TODO: See if this is still valid and update accordingly.
const NAME = 'chill_personbundle_person_creation';
- /**
- *
- * @var CenterTransformer
- */
- private $centerTransformer;
+ private CenterRepository $centerRepository;
/**
*
@@ -58,11 +55,11 @@ final class CreationPersonType extends AbstractType
private EventDispatcherInterface $dispatcher;
public function __construct(
- CenterTransformer $centerTransformer,
+ CenterRepository $centerRepository,
ConfigPersonAltNamesHelper $configPersonAltNamesHelper,
EventDispatcherInterface $dispatcher
) {
- $this->centerTransformer = $centerTransformer;
+ $this->centerTransformer = $centerRepository;
$this->configPersonAltNamesHelper = $configPersonAltNamesHelper;
$this->dispatcher = $dispatcher;
}
@@ -82,8 +79,9 @@ final class CreationPersonType extends AbstractType
->add('gender', GenderType::class, array(
'required' => true, 'placeholder' => null
))
- ->add('center', CenterType::class, [
- 'required' => false
+ ->add('center', PickCenterType::class, [
+ 'required' => false,
+ 'role' => PersonVoter::CREATE,
])
;
diff --git a/src/Bundle/ChillThirdPartyBundle/Controller/ThirdPartyController.php b/src/Bundle/ChillThirdPartyBundle/Controller/ThirdPartyController.php
index 83df22991..224280d85 100644
--- a/src/Bundle/ChillThirdPartyBundle/Controller/ThirdPartyController.php
+++ b/src/Bundle/ChillThirdPartyBundle/Controller/ThirdPartyController.php
@@ -71,7 +71,7 @@ final class ThirdPartyController extends CRUDController
/**
* @Route("/new", name="chill_3party_3party_new")
*/
- public function newAction(Request $request)
+ public function newActionkk(Request $request)
{
$this->denyAccessUnlessGranted(ThirdPartyVoter::CREATE);
@@ -115,7 +115,7 @@ final class ThirdPartyController extends CRUDController
* @Route("/{thirdparty_id}/update", name="chill_3party_3party_update")
* @ParamConverter("thirdParty", options={"id": "thirdparty_id"})
*/
- public function updateAction(ThirdParty $thirdParty, Request $request)
+ public function updateActionkk(ThirdParty $thirdParty, Request $request)
{
$this->denyAccessUnlessGranted(ThirdPartyVoter::CREATE);
diff --git a/src/Bundle/ChillThirdPartyBundle/DependencyInjection/ChillThirdPartyExtension.php b/src/Bundle/ChillThirdPartyBundle/DependencyInjection/ChillThirdPartyExtension.php
index b6fa70130..bdf21c05a 100644
--- a/src/Bundle/ChillThirdPartyBundle/DependencyInjection/ChillThirdPartyExtension.php
+++ b/src/Bundle/ChillThirdPartyBundle/DependencyInjection/ChillThirdPartyExtension.php
@@ -71,7 +71,16 @@ class ChillThirdPartyExtension extends Extension implements PrependExtensionInte
'role' => ThirdPartyVoter::SHOW,
],
'new' => [
+ 'template' => '@ChillThirdParty/ThirdParty/new.html.twig',
'role' => ThirdPartyVoter::CREATE,
+ ],
+ 'edit' => [
+ 'template' => '@ChillThirdParty/ThirdParty/update.html.twig',
+ 'role' => ThirdPartyVoter::UPDATE,
+ ],
+ 'view' => [
+ 'template' => '@ChillThirdParty/ThirdParty/view.html.twig',
+ 'role' => ThirdPartyVoter::SHOW,
]
]
diff --git a/src/Bundle/ChillThirdPartyBundle/Form/ThirdPartyType.php b/src/Bundle/ChillThirdPartyBundle/Form/ThirdPartyType.php
index 8eae938f6..20c843e71 100644
--- a/src/Bundle/ChillThirdPartyBundle/Form/ThirdPartyType.php
+++ b/src/Bundle/ChillThirdPartyBundle/Form/ThirdPartyType.php
@@ -3,8 +3,10 @@
namespace Chill\ThirdPartyBundle\Form;
use Chill\MainBundle\Entity\Address;
+use Chill\MainBundle\Form\Type\PickCenterType;
use Chill\MainBundle\Form\Type\ChillTextareaType;
use Chill\MainBundle\Templating\TranslatableStringHelper;
+use Chill\ThirdPartyBundle\Entity\ThirdParty;
use Chill\ThirdPartyBundle\Entity\ThirdPartyCategory;
use Chill\ThirdPartyBundle\Entity\ThirdPartyCivility;
use Chill\ThirdPartyBundle\Entity\ThirdPartyProfession;
@@ -129,12 +131,22 @@ class ThirdPartyType extends AbstractType
->add('comment', ChillTextareaType::class, [
'required' => false
])
+ ->add('centers', PickCenterType::class, [
+ 'role' => $this->om->contains($options['data']) ?
+ ThirdPartyVoter::UPDATE : ThirdPartyVoter::CREATE,
+ 'choice_options' => [
+ 'multiple' => true,
+ 'attr' => ['class' => 'select2']
+ ]
+ ])
+ /*
->add('centers', EntityType::class, [
'choices' => $this->getReachableCenters($options),
'class' => \Chill\MainBundle\Entity\Center::class,
'multiple' => true,
'attr' => ['class' => 'select2']
])
+ */
;
$builder
@@ -228,12 +240,14 @@ class ThirdPartyType extends AbstractType
public function configureOptions(OptionsResolver $resolver)
{
$resolver->setDefaults(array(
- 'data_class' => 'Chill\ThirdPartyBundle\Entity\ThirdParty'
+ 'data_class' => ThirdParty::class
));
+ /*
$resolver->setRequired('usage')
->setAllowedValues('usage', ['create', 'update'])
;
+ */
}
/**
diff --git a/src/Bundle/ChillThirdPartyBundle/Resources/views/ThirdParty/_form.html.twig b/src/Bundle/ChillThirdPartyBundle/Resources/views/ThirdParty/_form.html.twig
new file mode 100644
index 000000000..9fb8fd56e
--- /dev/null
+++ b/src/Bundle/ChillThirdPartyBundle/Resources/views/ThirdParty/_form.html.twig
@@ -0,0 +1,53 @@
+{% if form.civility is defined %}
+ {{ form_row(form.civility) }}
+{% endif %}
+
+ {{ form_row(form.name) }}
+
+ {% if form.nameCompany is defined %}
+ {{ form_row(form.nameCompany) }}
+ {{ form_row(form.acronym) }}
+ {% endif %}
+
+ {% if form.profession is defined %}
+ {{ form_row(form.profession) }}
+ {% endif %}
+
+ {{ form_row(form.types) }}
+ {{ form_row(form.categories) }}
+
+ {{ form_row(form.telephone) }}
+ {{ form_row(form.email) }}
+
+ - - + {% endif %} {% if is_granted('CHILL_3PARTY_3PARTY_SHOW', tp) %}
- - + {% endif %}
- - - {{ 'Back to the list'|trans }} - - -
- - - -
- - {{ form_widget(form.submit, {'label': 'Create', 'attr': {'class': 'btn btn-new' }}) }} - -
- {{ 'Name'|trans }} -
- - {% if thirdParty.isLeaf == true %}{{ thirdParty.civility }}{% endif %} - {{ thirdParty.name }} - - - {% if thirdParty.isLeaf == false %} -
- {{ 'thirdparty.NameCompany'|trans }} -
- - {% if thirdParty.nameCompany == null %} - {{ 'No nameCompany given'|trans }} - {% else %} - {{ thirdParty.nameCompany }} - {% endif %} - - -
- {{ 'thirdparty.Acronym'|trans }} -
- - {% if thirdParty.acronym == null %} - {{ 'No acronym given'|trans }} - {% else %} - {{ thirdParty.acronym }} - {% endif %} - - {% endif %} - -
- {{ 'Type'|trans }} - {% set types = [] %} - {% for t in thirdParty.types %} - {% set types = types|merge( [ ('chill_3party.key_label.'~t)|trans ] ) %} - {% endfor %} -
- - {{ types|join(', ') }} - - -
- {{ 'Phonenumber'|trans }} -
- - {% if thirdParty.telephone == null %} - {{ 'No phone given'|trans }} - {% else %} - - {{ thirdParty.telephone|chill_print_or_message("thirdparty.No_phonenumber") }} - - {% endif %} - - -
- {{ 'email'|trans }}
- -
- - {% if thirdParty.email == null %} - {{ 'No email given'|trans }} - {% else %} - - {{ thirdParty.email|chill_print_or_message("thirdparty.No_email") }} - - {% endif %} - - -
- {{ 'Address'|trans }} -
- - {% if thirdParty.address == null %} - {{ 'No address given'|trans }} - {% else %} - {{ thirdParty.address|chill_entity_render_box({'with_valid_from': false, 'extended_infos': true }) }} - {% endif %} - - -
- {{ 'Comment'|trans }} -
-
- {% if thirdParty.comment is not empty %}
-
- {{ thirdParty.comment|chill_markdown_to_html }} -
- {% endif %} -
-
- - {{ 'Centers'|trans }} -
- {{ 'The party is visible in those centers'|trans }} : {{ thirdParty.centers|join(', ') }} - -
- - - {{ 'Back to the list'|trans }} - - - - {% if is_granted('CHILL_3PARTY_3PARTY_UPDATE', thirdParty) %} -
- - - {{ 'Update'|trans }} - - - {% endif %} -
- {{ 'Name'|trans }} +
- + {% if thirdParty.isLeaf == true %}{{ thirdParty.civility }}{% endif %} + {{ thirdParty.name }} + + + {% if thirdParty.isLeaf == false %} +
- {{ 'thirdparty.NameCompany'|trans }} +
- + {% if thirdParty.nameCompany == null %} + {{ 'No nameCompany given'|trans }} + {% else %} + {{ thirdParty.nameCompany }} + {% endif %} + + +
- {{ 'thirdparty.Acronym'|trans }} +
- + {% if thirdParty.acronym == null %} + {{ 'No acronym given'|trans }} + {% else %} + {{ thirdParty.acronym }} + {% endif %} + + {% endif %} + +
- {{ 'Type'|trans }} + {% set types = [] %} + {% for t in thirdParty.types %} + {% set types = types|merge( [ ('chill_3party.key_label.'~t)|trans ] ) %} + {% endfor %} +
- + {{ types|join(', ') }} + + +
- {{ 'Phonenumber'|trans }} +
- + {% if thirdParty.telephone == null %} + {{ 'No phone given'|trans }} + {% else %} + + {{ thirdParty.telephone|chill_print_or_message("thirdparty.No_phonenumber") }} + + {% endif %} + + +
- {{ 'email'|trans }}
- +
- + {% if thirdParty.email == null %} + {{ 'No email given'|trans }} + {% else %} + + {{ thirdParty.email|chill_print_or_message("thirdparty.No_email") }} + + {% endif %} + + +
- {{ 'Address'|trans }} +
- + {% if thirdParty.address == null %} + {{ 'No address given'|trans }} + {% else %} + {{ thirdParty.address|chill_entity_render_box({'with_valid_from': false, 'extended_infos': true }) }} + {% endif %} + + +
- {{ 'Comment'|trans }} +
-
+ {% if thirdParty.comment is not empty %}
+
+ {{ thirdParty.comment|chill_markdown_to_html }} +
+ {% endif %} +
+
+ - {{ 'Centers'|trans }} +
- {{ 'The party is visible in those centers'|trans }} : {{ thirdParty.centers|join(', ') }} + +
+ {{ form_label(form.address) }}
+ {{ form_widget(form.address) }}
+
+
+{{ form_row(form.comment) }}
+ {{ form_row(form.centers) }}
+
+ {{ form_row(form.active) }}
diff --git a/src/Bundle/ChillThirdPartyBundle/Resources/views/ThirdParty/index.html.twig b/src/Bundle/ChillThirdPartyBundle/Resources/views/ThirdParty/index.html.twig
index a7ddb0f3c..e59cdb451 100644
--- a/src/Bundle/ChillThirdPartyBundle/Resources/views/ThirdParty/index.html.twig
+++ b/src/Bundle/ChillThirdPartyBundle/Resources/views/ThirdParty/index.html.twig
@@ -77,12 +77,12 @@
+ {% if thirdParty.address %}
+ {# include vue_address component #}
+ {% include '@ChillMain/Address/_insert_vue_address.html.twig' with {
+ targetEntity: { name: 'thirdparty', id: thirdParty.id },
+ mode: 'edit',
+ addressId: thirdParty.address.id,
+ buttonSize: 'btn-sm',
+ } %}
+ {#
+ backUrl: path('chill_3party_3party_new'),
+ #}
+ {% else %}
+ {# include vue_address component #}
+ {% include '@ChillMain/Address/_insert_vue_address.html.twig' with {
+ targetEntity: { name: 'thirdparty', id: thirdParty.id },
+ mode: 'new',
+ buttonSize: 'btn-sm',
+ buttonText: 'Create a new address',
+ modalTitle: 'Create a new address',
+ } %}
+ {% endif %}
+
+-
{% if is_granted('CHILL_3PARTY_3PARTY_UPDATE', tp) %}
-
-
-
+ {% embed '@ChillMain/CRUD/_new_content.html.twig' %}
+ {% block crud_content_header %}
+ {{ 'Create third party'|trans }}
- - {{ form_start(form) }} - - {% if form.civility is defined %} - {{ form_row(form.civility) }} - {% endif %} - - {{ form_row(form.name) }} - - {% if form.nameCompany is defined %} - {{ form_row(form.nameCompany) }} - {{ form_row(form.acronym) }} - {% endif %} - - {% if form.profession is defined %} - {{ form_row(form.profession) }} - {% endif %} - - {{ form_row(form.types) }} - {{ form_row(form.categories) }} - - {{ form_row(form.telephone) }} - {{ form_row(form.email) }} - -
- {{ form_label(form.address) }}
- {{ form_widget(form.address) }}
-
-
- {{ form_row(form.comment) }}
- {{ form_row(form.centers) }}
-
- {{ form_row(form.active) }}
-
-
- {% if thirdParty.address %}
- {# include vue_address component #}
- {% include '@ChillMain/Address/_insert_vue_address.html.twig' with {
- targetEntity: { name: 'thirdparty', id: thirdParty.id },
- mode: 'edit',
- addressId: thirdParty.address.id,
- buttonSize: 'btn-sm',
- } %}
- {#
- backUrl: path('chill_3party_3party_new'),
- #}
- {% else %}
- {# include vue_address component #}
- {% include '@ChillMain/Address/_insert_vue_address.html.twig' with {
- targetEntity: { name: 'thirdparty', id: thirdParty.id },
- mode: 'new',
- buttonSize: 'btn-sm',
- buttonText: 'Create a new address',
- modalTitle: 'Create a new address',
- } %}
- {% endif %}
-
- -
-
{{ 'Create third party'|trans }}
+ {% endblock %} + {% block crud_content_form_rows %} + {% include '@ChillThirdParty/ThirdParty/_form.html.twig' %} + {% endblock %} + {% endembed %}
-
-{% endblock %}
diff --git a/src/Bundle/ChillThirdPartyBundle/Resources/views/ThirdParty/update.html.twig b/src/Bundle/ChillThirdPartyBundle/Resources/views/ThirdParty/update.html.twig
index 4433d934b..605d91c73 100644
--- a/src/Bundle/ChillThirdPartyBundle/Resources/views/ThirdParty/update.html.twig
+++ b/src/Bundle/ChillThirdPartyBundle/Resources/views/ThirdParty/update.html.twig
@@ -1,30 +1,47 @@
{% extends "@ChillMain/layout.html.twig" %}
+{% set thirdParty = entity %}
+
{% block title 'Update third party %name%'|trans({ '%name%': thirdParty.name }) %}
{% block content %}
+
-
-
-
-
- - {{ title_ }} - - {{ (thirdParty.active ? 'Active' : 'Inactive')|trans }} - -
- - --
-
-
-
-
+
+{% endblock %}
+
+
+{% block content_not %}
+ {% embed '@ChillMain/CRUD/_edit_content.html.twig' %}
+ {% block crud_content_header %}
+
+ + {{ 'Update third party %name%'|trans({ '%name%': thirdParty.name }) }} + + {{ (thirdParty.active ? 'Active' : 'Inactive')|trans }} + +
+ {% endblock %} + {% block crud_content_form_rows %} +
+ {% if thirdParty.updatedAt != null %}
+ {{ 'thirdparty.UpdatedAt.short'|trans ~ thirdParty.updatedAt|format_date('short') }}
+ {% else %}
+ {{ 'thirdparty.CreatedAt.short'|trans ~ thirdParty.createdAt|format_date('short') }}
+ {% endif %}
+ {% if thirdParty.updatedBy != null %}
+ {{ 'thirdparty.UpdateBy.short'|trans ~ thirdParty.updatedBy.usernameCanonical }}
+ {% endif %}
+
+ {% include '@ChillThirdParty/ThirdParty/_form.html.twig' %}
+ {% endblock %}
+ {% endembed %}
+
-
- {{ 'Update third party %name%'|trans({ '%name%': thirdParty.name }) }} - - {{ (thirdParty.active ? 'Active' : 'Inactive')|trans }} - -
-
- {% if thirdParty.updatedAt != null %}
- {{ 'thirdparty.UpdatedAt.short'|trans ~ thirdParty.updatedAt|format_date('short') }}
- {% else %}
- {{ 'thirdparty.CreatedAt.short'|trans ~ thirdParty.createdAt|format_date('short') }}
- {% endif %}
- {% if thirdParty.updatedBy != null %}
- {{ 'thirdparty.UpdateBy.short'|trans ~ thirdParty.updatedBy.usernameCanonical }}
- {% endif %}
-
{{ form_start(form) }}
diff --git a/src/Bundle/ChillThirdPartyBundle/Resources/views/ThirdParty/view.html.twig b/src/Bundle/ChillThirdPartyBundle/Resources/views/ThirdParty/view.html.twig
new file mode 100644
index 000000000..5209a5f30
--- /dev/null
+++ b/src/Bundle/ChillThirdPartyBundle/Resources/views/ThirdParty/view.html.twig
@@ -0,0 +1,110 @@
+{% extends "@ChillMain/layout.html.twig" %}
+
+{% set thirdParty = entity %}
+{% set title_ = 'Show third party %name%'|trans({'%name%' : thirdParty.name }) %}
+
+{% block title title_ %}
+
+{% block content %}
+
+
+{% endblock %}
+ {% embed '@ChillMain/CRUD/_view_content.html.twig' %}
+ {% block crud_content_header %}
+
++ {{ title_ }} + + {{ (thirdParty.active ? 'Active' : 'Inactive')|trans }} + +
+ {% endblock %} + + {% block crud_content_view_details %} +-
+
+