mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
continue CRUD user
This commit is contained in:
parent
b5c2dd7bd2
commit
72b1916da8
@ -118,7 +118,7 @@ class CRUDController extends AbstractController
|
||||
$form->handleRequest($request);
|
||||
|
||||
if ($form->isSubmitted() && $form->isValid()) {
|
||||
$this->onFormValid($entity, $form, $request);
|
||||
$this->onFormValid($action, $entity, $form, $request);
|
||||
$em = $this->getDoctrine()->getManager();
|
||||
|
||||
$this->onPreRemove($action, $entity, $form, $request);
|
||||
@ -607,7 +607,7 @@ class CRUDController extends AbstractController
|
||||
$form->handleRequest($request);
|
||||
|
||||
if ($form->isSubmitted() && $form->isValid()) {
|
||||
$this->onFormValid($entity, $form, $request);
|
||||
$this->onFormValid($action, $entity, $form, $request);
|
||||
$em = $this->getDoctrine()->getManager();
|
||||
|
||||
$this->onPreFlush($action, $entity, $form, $request);
|
||||
@ -706,7 +706,7 @@ class CRUDController extends AbstractController
|
||||
$form->handleRequest($request);
|
||||
|
||||
if ($form->isSubmitted() && $form->isValid()) {
|
||||
$this->onFormValid($entity, $form, $request);
|
||||
$this->onFormValid($action, $entity, $form, $request);
|
||||
$em = $this->getDoctrine()->getManager();
|
||||
|
||||
$this->onPrePersist($action, $entity, $form, $request);
|
||||
@ -716,7 +716,7 @@ class CRUDController extends AbstractController
|
||||
$this->onPreFlush($action, $entity, $form, $request);
|
||||
$em->flush();
|
||||
$this->onPostFlush($action, $entity, $form, $request);
|
||||
$this->getPaginatorFactory();
|
||||
|
||||
$this->addFlash('success', $this->generateFormSuccessMessage($action, $entity));
|
||||
|
||||
$result = $this->onBeforeRedirectAfterSubmission($action, $entity, $form, $request);
|
||||
@ -1084,12 +1084,7 @@ class CRUDController extends AbstractController
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param object $entity
|
||||
* @param FormInterface $form
|
||||
* @param Request $request
|
||||
*/
|
||||
protected function onFormValid(object $entity, FormInterface $form, Request $request)
|
||||
protected function onFormValid(string $action, object $entity, FormInterface $form, Request $request)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -4,8 +4,10 @@ namespace Chill\MainBundle\Controller;
|
||||
|
||||
use Chill\MainBundle\CRUD\Controller\AbstractCRUDController;
|
||||
use Chill\MainBundle\CRUD\Controller\CRUDController;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||
use Symfony\Component\Form\FormInterface;
|
||||
use Symfony\Component\HttpFoundation\RedirectResponse;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
|
||||
use Chill\MainBundle\Entity\User;
|
||||
@ -13,10 +15,10 @@ use Chill\MainBundle\Form\UserType;
|
||||
use Chill\MainBundle\Entity\GroupCenter;
|
||||
use Chill\MainBundle\Form\Type\ComposedGroupCenterType;
|
||||
use Chill\MainBundle\Form\UserPasswordType;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\Security\Core\Encoder\PasswordEncoderInterface;
|
||||
use Symfony\Component\Security\Core\Encoder\UserPasswordEncoderInterface;
|
||||
use Symfony\Component\Validator\Validator\ValidatorInterface;
|
||||
use Symfony\Component\Routing\Annotation\Route;
|
||||
use Sensio\Bundle\FrameworkExtraBundle\Request\ParamConverter;
|
||||
|
||||
|
||||
/**
|
||||
@ -48,63 +50,38 @@ class UserController extends CRUDController
|
||||
* @param ValidatorInterface $validator
|
||||
*/
|
||||
public function __construct(
|
||||
LoggerInterface $logger,
|
||||
LoggerInterface $chillLogger,
|
||||
ValidatorInterface $validator,
|
||||
UserPasswordEncoderInterface $passwordEncoder
|
||||
) {
|
||||
$this->logger = $logger;
|
||||
$this->logger = $chillLogger;
|
||||
$this->validator = $validator;
|
||||
$this->passwordEncoder = $passwordEncoder;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new User entity.
|
||||
*
|
||||
*/
|
||||
public function new(Request $request): Response
|
||||
protected function createFormFor(string $action, $entity, string $formClass = null, array $formOptions = []): FormInterface
|
||||
{
|
||||
$user = new User();
|
||||
$form = $this->createCreateForm($user);
|
||||
$form->handleRequest($request);
|
||||
|
||||
if ($form->isSubmitted() && $form->isValid()) {
|
||||
$em = $this->getDoctrine()->getManager();
|
||||
|
||||
$user->setPassword($this->passwordEncoder
|
||||
->encodePassword($user, $form['plainPassword']->getData()));
|
||||
|
||||
$em->persist($user);
|
||||
$em->flush();
|
||||
|
||||
return $this->redirect($this->generateUrl('admin_user_show', array('id' => $user->getId())));
|
||||
} elseif ($form->isSubmitted() && !$form->isValid()){
|
||||
|
||||
// for "new", add special config
|
||||
if ('new' === $action) {
|
||||
return $this->createForm(UserType::class, $entity, array(
|
||||
'is_creation' => true
|
||||
));
|
||||
}
|
||||
|
||||
return $this->render('@ChillMain/User/new.html.twig', array(
|
||||
'entity' => $user,
|
||||
'form' => $form->createView(),
|
||||
));
|
||||
// default behaviour
|
||||
return parent::createFormFor($action, $entity, $formClass, $formOptions);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a form to create a User entity.
|
||||
*
|
||||
* @param User $entity The entity
|
||||
*
|
||||
* @return \Symfony\Component\Form\Form The form
|
||||
*/
|
||||
private function createCreateForm(User $entity)
|
||||
protected function onPrePersist(string $action, $entity, FormInterface $form, Request $request)
|
||||
{
|
||||
$form = $this->createForm(UserType::class, $entity, array(
|
||||
'action' => $this->generateUrl('admin_user_create'),
|
||||
'method' => 'POST',
|
||||
'is_creation' => true
|
||||
));
|
||||
// for "new", encode the password
|
||||
if ('new' === $action) {
|
||||
$entity->setPassword($this->passwordEncoder
|
||||
->encodePassword($entity, $form['plainPassword']->getData()));
|
||||
}
|
||||
|
||||
$form->add('submit', SubmitType::class, array('label' => 'Create'));
|
||||
|
||||
return $form;
|
||||
// default behaviour
|
||||
parent::onPrePersist($action, $entity, $form, $request);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -126,55 +103,63 @@ class UserController extends CRUDController
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* Displays a form to edit an existing User entity.
|
||||
*
|
||||
*/
|
||||
public function editAction($id)
|
||||
|
||||
protected function generateTemplateParameter(string $action, $entity, Request $request, array $defaultTemplateParameters = [])
|
||||
{
|
||||
$em = $this->getDoctrine()->getManager();
|
||||
|
||||
$user = $em->getRepository('ChillMainBundle:User')->find($id);
|
||||
|
||||
if (!$user) {
|
||||
throw $this->createNotFoundException('Unable to find User entity.');
|
||||
// add mini-forms for edit action
|
||||
if ("edit" === $action) {
|
||||
return array_merge(
|
||||
$defaultTemplateParameters,
|
||||
[
|
||||
'add_groupcenter_form' => $this->createAddLinkGroupCenterForm($entity, $request)->createView(),
|
||||
'delete_groupcenter_form' => array_map(
|
||||
function(\Symfony\Component\Form\Form $form) {
|
||||
return $form->createView();
|
||||
},
|
||||
iterator_to_array($this->getDeleteLinkGroupCenterByUser($entity, $request), true)
|
||||
)
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
$editForm = $this->createEditForm($user);
|
||||
|
||||
return $this->render('@ChillMain/User/edit.html.twig', array(
|
||||
'entity' => $user,
|
||||
'edit_form' => $editForm->createView(),
|
||||
'add_groupcenter_form' => $this->createAddLinkGroupCenterForm($user)->createView(),
|
||||
'delete_groupcenter_form' => array_map(
|
||||
function(\Symfony\Component\Form\Form $form) {
|
||||
return $form->createView();
|
||||
|
||||
},
|
||||
iterator_to_array($this->getDeleteLinkGroupCenterByUser($user), true))
|
||||
));
|
||||
// default behaviour
|
||||
return parent::generateTemplateParameter($action, $entity, $request, $defaultTemplateParameters);
|
||||
}
|
||||
|
||||
/**
|
||||
* Displays a form to edit the user password.
|
||||
*
|
||||
* @Route("/{_locale}/admin/user/{id}/edit_password", name="admin_user_edit_password")
|
||||
*/
|
||||
public function editPasswordAction($id)
|
||||
public function editPasswordAction(User $user, Request $request)
|
||||
{
|
||||
$em = $this->getDoctrine()->getManager();
|
||||
$editForm = $this->createEditPasswordForm($user, $request);
|
||||
$editForm->handleRequest($request);
|
||||
|
||||
$user = $em->getRepository('ChillMainBundle:User')->find($id);
|
||||
if ($editForm->isSubmitted() && $editForm->isValid()) {
|
||||
$password = $editForm->get('new_password')->getData();
|
||||
|
||||
if (!$user) {
|
||||
throw $this->createNotFoundException('Unable to find User entity.');
|
||||
// logging for prod
|
||||
$this->logger->info('update password for an user', [
|
||||
'by' => $this->getUser()->getUsername(),
|
||||
'user' => $user->getUsername()
|
||||
]);
|
||||
|
||||
$user->setPassword($this->passwordEncoder->encodePassword($user, $password));
|
||||
|
||||
$this->getDoctrine()->getManager()->flush();
|
||||
$this->addFlash('success', $this->get('translator')->trans('Password successfully updated!'));
|
||||
|
||||
return $this->redirect(
|
||||
$request->query->has('returnPath') ? $request->query->get('returnPath') :
|
||||
$this->generateUrl('chill_crud_admin_user_edit', ['id' => $user->getId()])
|
||||
);
|
||||
}
|
||||
|
||||
$editForm = $this->createEditPasswordForm($user);
|
||||
|
||||
return $this->render('@ChillMain/User/edit_password.html.twig', array(
|
||||
return $this->render('@ChillMain/User/edit_password.html.twig', [
|
||||
'entity' => $user,
|
||||
'edit_form' => $editForm->createView()
|
||||
));
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -186,9 +171,6 @@ class UserController extends CRUDController
|
||||
private function createEditPasswordForm(User $user)
|
||||
{
|
||||
return $this->createForm(UserPasswordType::class, null, array(
|
||||
'action' =>
|
||||
$this->generateUrl('admin_user_update_password', array('id' => $user->getId())),
|
||||
'method' => 'PUT',
|
||||
'user' => $user
|
||||
))
|
||||
->add('submit', SubmitType::class, array('label' => 'Change password'))
|
||||
@ -196,7 +178,11 @@ class UserController extends CRUDController
|
||||
;
|
||||
}
|
||||
|
||||
public function deleteLinkGroupCenterAction($uid, $gcid)
|
||||
/**
|
||||
* @Route("/{_locale}/admin/main/user/{uid}/delete_link_groupcenter/{gcid}",
|
||||
* name="admin_user_delete_groupcenter")
|
||||
*/
|
||||
public function deleteLinkGroupCenterAction($uid, $gcid, Request $request): RedirectResponse
|
||||
{
|
||||
$em = $this->getDoctrine()->getManager();
|
||||
|
||||
@ -218,7 +204,7 @@ class UserController extends CRUDController
|
||||
} catch (\RuntimeException $ex) {
|
||||
$this->addFlash('error', $this->get('translator')->trans($ex->getMessage()));
|
||||
|
||||
return $this->redirect($this->generateUrl('admin_user_edit', array('id' => $uid)));
|
||||
return $this->redirect($this->generateUrl('chill_crud_admin_user_edit', array('id' => $uid)));
|
||||
}
|
||||
|
||||
$em->flush();
|
||||
@ -226,11 +212,15 @@ class UserController extends CRUDController
|
||||
$this->addFlash('success', $this->get('translator')
|
||||
->trans('The permissions where removed.'));
|
||||
|
||||
return $this->redirect($this->generateUrl('admin_user_edit', array('id' => $uid)));
|
||||
return $this->redirect($this->generateUrl('chill_crud_admin_user_edit', array('id' => $uid)));
|
||||
|
||||
}
|
||||
|
||||
public function addLinkGroupCenterAction(Request $request, $uid)
|
||||
/**
|
||||
* @Route("/{_locale}/admin/main/user/{uid}/add_link_groupcenter",
|
||||
* name="admin_user_add_groupcenter")
|
||||
*/
|
||||
public function addLinkGroupCenterAction(Request $request, $uid): RedirectResponse
|
||||
{
|
||||
$em = $this->getDoctrine()->getManager();
|
||||
|
||||
@ -240,7 +230,7 @@ class UserController extends CRUDController
|
||||
throw $this->createNotFoundException('Unable to find User entity.');
|
||||
}
|
||||
|
||||
$form = $this->createAddLinkGroupCenterForm($user);
|
||||
$form = $this->createAddLinkGroupCenterForm($user, $request);
|
||||
$form->handleRequest($request);
|
||||
|
||||
if ($form->isValid()) {
|
||||
@ -254,8 +244,12 @@ class UserController extends CRUDController
|
||||
$this->addFlash('success', $this->get('translator')->trans('The '
|
||||
. 'permissions have been successfully added to the user'));
|
||||
|
||||
return $this->redirect($this->generateUrl('admin_user_edit',
|
||||
array('id' => $uid)));
|
||||
$returnPathParams = $request->query->has('returnPath') ?
|
||||
['returnPath' => $request->query->get('returnPath')] : [];
|
||||
|
||||
return $this->redirect($this->generateUrl('chill_crud_admin_user_edit',
|
||||
\array_merge(['id' => $uid], $returnPathParams)));
|
||||
|
||||
} else {
|
||||
foreach($this->validator->validate($user) as $error)
|
||||
$this->addFlash('error', $error->getMessage());
|
||||
@ -293,104 +287,6 @@ class UserController extends CRUDController
|
||||
return $groupCenterManaged;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a form to edit a User entity.
|
||||
*
|
||||
* @param User $user The entity
|
||||
*
|
||||
* @return \Symfony\Component\Form\Form The form
|
||||
*/
|
||||
private function createEditForm(User $user)
|
||||
{
|
||||
$form = $this->createForm(UserType::class, $user, array(
|
||||
'action' => $this->generateUrl('admin_user_update', array('id' => $user->getId())),
|
||||
'method' => 'PUT',
|
||||
));
|
||||
|
||||
$form->add('submit', SubmitType::class, array('label' => 'Update'));
|
||||
|
||||
return $form;
|
||||
}
|
||||
|
||||
/**
|
||||
* Edits an existing User entity.
|
||||
*
|
||||
*/
|
||||
public function updateAction(Request $request, $id)
|
||||
{
|
||||
$em = $this->getDoctrine()->getManager();
|
||||
|
||||
$user = $em->getRepository('ChillMainBundle:User')->find($id);
|
||||
|
||||
if (!$user) {
|
||||
throw $this->createNotFoundException('Unable to find User entity.');
|
||||
}
|
||||
|
||||
$editForm = $this->createEditForm($user);
|
||||
$editForm->handleRequest($request);
|
||||
|
||||
if ($editForm->isValid()) {
|
||||
$em->flush();
|
||||
|
||||
return $this->redirect($this->generateUrl('admin_user_edit', array('id' => $id)));
|
||||
}
|
||||
|
||||
return $this->render('@ChillMain/User/edit.html.twig', array(
|
||||
'entity' => $user,
|
||||
'edit_form' => $editForm->createView(),
|
||||
'add_groupcenter_form' => $this->createAddLinkGroupCenterForm($user)->createView(),
|
||||
'delete_groupcenter_form' => array_map(
|
||||
function(\Symfony\Component\Form\Form $form) {
|
||||
return $form->createView();
|
||||
|
||||
},
|
||||
iterator_to_array($this->getDeleteLinkGroupCenterByUser($user), true))
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* Edits the user password
|
||||
*
|
||||
*/
|
||||
public function updatePasswordAction(Request $request, $id)
|
||||
{
|
||||
$em = $this->getDoctrine()->getManager();
|
||||
|
||||
$user = $em->getRepository('ChillMainBundle:User')->find($id);
|
||||
|
||||
if (!$user) {
|
||||
throw $this->createNotFoundException('Unable to find User entity.');
|
||||
}
|
||||
|
||||
$editForm = $this->createEditPasswordForm($user);
|
||||
$editForm->handleRequest($request);
|
||||
|
||||
if ($editForm->isValid()) {
|
||||
$password = $editForm->get('new_password')->getData();
|
||||
|
||||
// logging for prod
|
||||
$this->logger->info('update password for an user', [
|
||||
'by' => $this->getUser()->getUsername(),
|
||||
'user' => $user->getUsername()
|
||||
]);
|
||||
|
||||
$user->setPassword($this->get('security.password_encoder')
|
||||
->encodePassword($user, $password));
|
||||
|
||||
$em->flush();
|
||||
|
||||
$this->addFlash('success', $this->get('translator')->trans('Password successfully updated!'));
|
||||
|
||||
return $this->redirect($this->generateUrl('admin_user_edit', array('id' => $id)));
|
||||
}
|
||||
|
||||
return $this->render('@ChillMain/User/edit_password.html.twig', array(
|
||||
'entity' => $user,
|
||||
'edit_form' => $editForm->createView(),
|
||||
));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Creates a form to delete a link to a GroupCenter
|
||||
*
|
||||
@ -398,11 +294,13 @@ class UserController extends CRUDController
|
||||
*
|
||||
* @return \Symfony\Component\Form\Form The form
|
||||
*/
|
||||
private function createDeleteLinkGroupCenterForm(User $user, GroupCenter $groupCenter)
|
||||
private function createDeleteLinkGroupCenterForm(User $user, GroupCenter $groupCenter, $request)
|
||||
{
|
||||
$returnPathParams = $request->query->has('returnPath') ? ['returnPath' => $request->query->get('returnPath')] : [];
|
||||
|
||||
return $this->createFormBuilder()
|
||||
->setAction($this->generateUrl('admin_user_delete_group_center',
|
||||
array('uid' => $user->getId(), 'gcid' => $groupCenter->getId())))
|
||||
->setAction($this->generateUrl('admin_user_delete_groupcenter',
|
||||
array_merge($returnPathParams, ['uid' => $user->getId(), 'gcid' => $groupCenter->getId()])))
|
||||
->setMethod('DELETE')
|
||||
->add('submit', SubmitType::class, array('label' => 'Delete'))
|
||||
->getForm()
|
||||
@ -415,11 +313,13 @@ class UserController extends CRUDController
|
||||
* @param User $user
|
||||
* @return \Symfony\Component\Form\Form
|
||||
*/
|
||||
private function createAddLinkGroupCenterForm(User $user)
|
||||
private function createAddLinkGroupCenterForm(User $user, Request $request)
|
||||
{
|
||||
$returnPathParams = $request->query->has('returnPath') ? ['returnPath' => $request->query->get('returnPath')] : [];
|
||||
|
||||
return $this->createFormBuilder()
|
||||
->setAction($this->generateUrl('admin_user_add_group_center',
|
||||
array('uid' => $user->getId())))
|
||||
->setAction($this->generateUrl('admin_user_add_groupcenter',
|
||||
array_merge($returnPathParams, ['uid' => $user->getId()])))
|
||||
->setMethod('POST')
|
||||
->add(self::FORM_GROUP_CENTER_COMPOSED, ComposedGroupCenterType::class)
|
||||
->add('submit', SubmitType::class, array('label' => 'Add a new groupCenter'))
|
||||
@ -431,11 +331,11 @@ class UserController extends CRUDController
|
||||
*
|
||||
* @param User $user
|
||||
*/
|
||||
private function getDeleteLinkGroupCenterByUser(User $user)
|
||||
private function getDeleteLinkGroupCenterByUser(User $user, Request $request)
|
||||
{
|
||||
foreach ($user->getGroupCenters() as $groupCenter) {
|
||||
yield $groupCenter->getId() => $this
|
||||
->createDeleteLinkGroupCenterForm($user, $groupCenter);
|
||||
->createDeleteLinkGroupCenterForm($user, $groupCenter, $request);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -307,9 +307,11 @@ class ChillMainExtension extends Extension implements PrependExtensionInterface,
|
||||
],
|
||||
'new' => [
|
||||
'role' => 'ROLE_ADMIN',
|
||||
'template' => '@ChillMain/User/new.html.twig'
|
||||
],
|
||||
'edit' => [
|
||||
'role' => 'ROLE_ADMIN',
|
||||
'template' => '@ChillMain/User/edit.html.twig'
|
||||
]
|
||||
]
|
||||
]
|
||||
|
@ -47,9 +47,9 @@ class UserType extends AbstractType
|
||||
])
|
||||
->add('label', TextType::class)
|
||||
->add('mainCenter', EntityType::class, [
|
||||
'label' => 'main center',
|
||||
'label' => 'Main center',
|
||||
'required' => false,
|
||||
'placeholder' => 'choose a main center',
|
||||
'placeholder' => 'Choose a main center',
|
||||
'class' => Center::class,
|
||||
'query_builder' => function (EntityRepository $er) {
|
||||
$qb = $er->createQueryBuilder('c');
|
||||
@ -59,16 +59,16 @@ class UserType extends AbstractType
|
||||
}
|
||||
])
|
||||
->add('mainScope', EntityType::class, [
|
||||
'label' => 'Choose a main scope',
|
||||
'label' => 'Main scope',
|
||||
'required' => false,
|
||||
'placeholder' => 'choose a main scope',
|
||||
'placeholder' => 'Choose a main scope',
|
||||
'class' => Scope::class,
|
||||
'choice_label' => function (Scope $c) {
|
||||
return $this->translatableStringHelper->localize($c->getName());
|
||||
},
|
||||
])
|
||||
->add('userJob', EntityType::class, [
|
||||
'label' => 'Choose a job',
|
||||
'label' => 'user job',
|
||||
'required' => false,
|
||||
'placeholder' => 'choose a job',
|
||||
'class' => UserJob::class,
|
||||
|
@ -1,17 +1,22 @@
|
||||
{% set formId = crudMainFormId|default('crud_main_form') %}
|
||||
<div class="{% block crud_content_main_div_class %}{% endblock %}">
|
||||
{% block crud_content_header %}
|
||||
<h1>{{ ('crud.'~crud_name~'.title_edit')|trans }}</h1>
|
||||
{% 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 %}
|
||||
{{ form_row(f) }}
|
||||
{% endfor %}
|
||||
{% endblock crud_content_form_rows %}
|
||||
|
||||
{{ form_end(form) }}
|
||||
|
||||
{% block crud_content_after_form %}{% endblock %}
|
||||
|
||||
{% block crud_content_form_actions %}
|
||||
<ul class="record_actions sticky-form-buttons">
|
||||
{% block content_form_actions_back %}
|
||||
@ -30,7 +35,7 @@
|
||||
</li>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
{% endblock content_form_actions_delete %}
|
||||
{% endblock content_form_actions_delete %}
|
||||
{% block content_form_actions_view %}
|
||||
{% if chill_crud_action_exists(crud_name, 'view') %}
|
||||
{% if is_granted(chill_crud_config('role', crud_name, 'view'), entity) %}
|
||||
@ -39,17 +44,17 @@
|
||||
</li>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
{% endblock content_form_actions_view %}
|
||||
{% endblock content_form_actions_view %}
|
||||
{% block content_form_actions_save_and_close %}
|
||||
<li class="">
|
||||
<button type="submit" name="submit" value="save-and-close" class="btn btn-update">
|
||||
<button type="submit" name="submit" value="save-and-close" class="btn btn-update" form="{{ formId }}">
|
||||
{{ 'crud.edit.save_and_close'|trans }}
|
||||
</button>
|
||||
</li>
|
||||
{% endblock %}
|
||||
{% block content_form_actions_save_and_show %}
|
||||
<li class="">
|
||||
<button type="submit" name="submit" value="save-and-show" class="btn btn-update">
|
||||
<button type="submit" name="submit" value="save-and-show" class="btn btn-update" form="{{ formId }}">
|
||||
{{ 'crud.edit.save_and_show'|trans }}
|
||||
</button>
|
||||
</li>
|
||||
@ -58,6 +63,5 @@
|
||||
</ul>
|
||||
{% endblock %}
|
||||
|
||||
{{ form_end(form) }}
|
||||
{% endblock %}
|
||||
</div>
|
||||
|
@ -5,14 +5,16 @@
|
||||
|
||||
{% block crud_content_form %}
|
||||
{{ form_start(form) }}
|
||||
|
||||
|
||||
{% block crud_content_form_rows %}
|
||||
{% for f in form %}{% if f.vars.name != 'submit' %}
|
||||
{{ form_row(f) }}
|
||||
{% endif %}{% endfor %}
|
||||
{% endblock crud_content_form_rows %}
|
||||
|
||||
{% block crud_content_form_actions %}
|
||||
{% block crud_content_after_form %}{% endblock %}
|
||||
|
||||
{% block crud_content_form_actions %}
|
||||
<ul class="record_actions sticky-form-buttons">
|
||||
{% block content_form_actions_back %}
|
||||
<li class="cancel">
|
||||
@ -20,7 +22,7 @@
|
||||
{{ 'Cancel'|trans }}
|
||||
</a>
|
||||
</li>
|
||||
{% endblock %}
|
||||
{% endblock %}
|
||||
{% block content_form_actions_save_and_close %}
|
||||
<li class="">
|
||||
<button type="submit" name="submit" value="save-and-close" class="btn btn-create">
|
||||
|
@ -1,78 +1,55 @@
|
||||
{% extends '@ChillMain/Admin/layout_permissions.html.twig' %}
|
||||
|
||||
{% block title %}{{ 'User edit'|trans }}{% endblock %}
|
||||
{% extends '@ChillMain/Admin/Permission/layout_crud_permission_index.html.twig' %}
|
||||
|
||||
{% block admin_content -%}
|
||||
<h1>{{ 'User edit'|trans }}</h1>
|
||||
{% embed '@ChillMain/CRUD/_edit_content.html.twig' %}
|
||||
{% block crud_content_after_form %}
|
||||
<h2>{{ 'Permissions granted'|trans }}</h2>
|
||||
|
||||
{{ form_start(edit_form) }}
|
||||
|
||||
{{ form_row(edit_form.username) }}
|
||||
{{ form_row(edit_form.email) }}
|
||||
{{ form_row(edit_form.enabled, { 'label': "User'status"}) }}
|
||||
|
||||
{{ form_widget(edit_form.submit, { 'attr': { 'class' : 'btn btn-chill-green center' } } ) }}
|
||||
<a href="{{ path('admin_user_edit_password', { 'id' : entity.id }) }}" class="btn btn-chill-orange">{{ 'Edit password'|trans }}</a>
|
||||
|
||||
{{ form_end(edit_form) }}
|
||||
|
||||
<h2>{{ 'Permissions granted'|trans }}</h2>
|
||||
|
||||
{% if entity.groupcenters|length > 0 %}
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>{{ 'Permission group'|trans }}</th>
|
||||
<th>{{ 'Center'|trans }}</th>
|
||||
<th> </th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for groupcenter in entity.groupcenters %}
|
||||
<tr>
|
||||
<td>
|
||||
{% if entity.groupcenters|length > 0 %}
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>{{ 'Permission group'|trans }}</th>
|
||||
<th>{{ 'Center'|trans }}</th>
|
||||
<th> </th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for groupcenter in entity.groupcenters %}
|
||||
<tr>
|
||||
<td>
|
||||
<span class="user_group permissionsgroup">
|
||||
{{ groupcenter.permissionsgroup.name }}
|
||||
</span>
|
||||
</td>
|
||||
<td>
|
||||
</td>
|
||||
<td>
|
||||
<span class="user_group center">
|
||||
{{ groupcenter.center.name }}
|
||||
</span>
|
||||
</td>
|
||||
<td>
|
||||
{{ form_start(delete_groupcenter_form[groupcenter.id]) }}
|
||||
{{ form_row(delete_groupcenter_form[groupcenter.id].submit, { 'attr': { 'class': 'btn btn-chill-red' } } ) }}
|
||||
{{ form_rest(delete_groupcenter_form[groupcenter.id]) }}
|
||||
{{ form_end(delete_groupcenter_form[groupcenter.id]) }}
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
{% else %}
|
||||
<p>{{ 'Any permissions granted to this user'|trans }}.</p>
|
||||
{% endif %}
|
||||
|
||||
<h3>{{ 'Grant new permissions'|trans }}</h3>
|
||||
|
||||
{{ form_start(add_groupcenter_form) }}
|
||||
{{ form_row(add_groupcenter_form.composed_groupcenter.center) }}
|
||||
{{ form_row(add_groupcenter_form.composed_groupcenter.permissionsgroup) }}
|
||||
{{ form_row(add_groupcenter_form.submit, { 'attr' : { 'class': 'btn btn-chill-green' } } ) }}
|
||||
</td>
|
||||
<td>
|
||||
{{ form_start(delete_groupcenter_form[groupcenter.id]) }}
|
||||
{{ form_row(delete_groupcenter_form[groupcenter.id].submit, { 'attr': { 'class': 'btn btn-chill-red' } } ) }}
|
||||
{{ form_rest(delete_groupcenter_form[groupcenter.id]) }}
|
||||
{{ form_end(delete_groupcenter_form[groupcenter.id]) }}
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
{% else %}
|
||||
<p>{{ 'Any permissions granted to this user'|trans }}.</p>
|
||||
{% endif %}
|
||||
|
||||
{{ form_end(add_groupcenter_form) }}
|
||||
|
||||
<ul class="record_actions">
|
||||
<li>
|
||||
<a href="{{ path('admin_user_show', { 'id': entity.id }) }}">
|
||||
{{ 'show'|trans }}
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="{{ path('admin_user') }}">
|
||||
{{ 'Back to the list'|trans }}
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
<h3>{{ 'Grant new permissions'|trans }}</h3>
|
||||
|
||||
{{ form_start(add_groupcenter_form) }}
|
||||
{{ form_row(add_groupcenter_form.composed_groupcenter.center) }}
|
||||
{{ form_row(add_groupcenter_form.composed_groupcenter.permissionsgroup) }}
|
||||
{{ form_row(add_groupcenter_form.submit, { 'attr' : { 'class': 'btn btn-chill-green' } } ) }}
|
||||
|
||||
{{ form_end(add_groupcenter_form) }}
|
||||
|
||||
{% endblock %}
|
||||
{% endembed %}
|
||||
{% endblock %}
|
||||
|
@ -1,4 +1,4 @@
|
||||
{% extends '@ChillMain/Admin/layout_permissions.html.twig' %}
|
||||
{% extends '@ChillMain/Admin/Permission/layout_crud_permission_index.html.twig' %}
|
||||
|
||||
{% block title %}{{ 'Edit password for %username%'|trans( { '%username%': entity.username } ) }}{% endblock %}
|
||||
|
||||
@ -7,19 +7,17 @@
|
||||
|
||||
{{ form_start(edit_form) }}
|
||||
{{ form_row(edit_form.new_password) }}
|
||||
{{ form_widget(edit_form.submit, { 'attr': { 'class': 'btn btn-chill-orange' } } ) }}
|
||||
|
||||
<ul class="record_actions">
|
||||
<li class="cancel">
|
||||
<a href="{{ chill_return_path_or('chill_crud_admin_user_index') }}" class="btn btn-cancel">
|
||||
{{ 'Cancel'|trans }}
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
{{ form_widget(edit_form.submit, { 'attr': { 'class': 'btn btn-edit' } } ) }}
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
{{ form_end(edit_form) }}
|
||||
|
||||
<ul class="record_actions">
|
||||
<li>
|
||||
<a href="{{ path('admin_user') }}">
|
||||
{{ 'Back to the list'|trans }}
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="{{ path('admin_user_edit', { 'id' : entity.id }) }}">
|
||||
{{ 'Back to the user edition'|trans }}
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
{% endblock %}
|
||||
|
@ -41,14 +41,14 @@
|
||||
<td>
|
||||
<ul class="record_actions">
|
||||
<li>
|
||||
<a class="btn btn-edit" href="{{ path('admin_user_edit', { 'id': entity.id }) }}"></a>
|
||||
<a class="btn btn-edit" href="{{ path('chill_crud_admin_user_edit', { 'id': entity.id }) }}"></a>
|
||||
</li>
|
||||
<li>
|
||||
<a class="btn btn-edit chill-red" href="{{ path('admin_user_edit_password', { 'id' : entity.id }) }}">{{ 'Edit password'|trans }}</a>
|
||||
<a class="btn btn-chill-red" href="{{ path('admin_user_edit_password', { 'id' : entity.id }) }}" title="{{ 'Edit password'|trans|e('html_attr') }}"><i class="fa fa-asterisk"></i><i class="fa fa-asterisk"></i><i class="fa fa-asterisk"></i></a>
|
||||
</li>
|
||||
{% if is_granted('ROLE_ALLOWED_TO_SWITCH') %}
|
||||
<li>
|
||||
<a class="btn chill-blue" href="{{ path('chill_main_homepage', {'_switch_user': entity.username }) }}" title="{{ "Impersonate"|trans|e('html_attr') }}"><i class="fa fa-universal-access"></i></a>
|
||||
<a class="btn btn-chill-blue" href="{{ path('chill_main_homepage', {'_switch_user': entity.username }) }}" title="{{ "Impersonate"|trans|e('html_attr') }}"><i class="fa fa-user-secret"></i></a>
|
||||
</li>
|
||||
{% endif %}
|
||||
</ul>
|
||||
@ -59,54 +59,3 @@
|
||||
{% endblock %}
|
||||
{% endembed %}
|
||||
{% endblock %}
|
||||
|
||||
{#
|
||||
|
||||
<table class="records_list">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>{{ 'Username'|trans|capitalize }}</th>
|
||||
<th>{{ 'Actions'|trans|capitalize }}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for entity in entities %}
|
||||
<tr class="{% if entity.isEnabled == false %}user-disabled{% else %}user-enabled{% endif %}" >
|
||||
<td><a href="{{ path('admin_user_show', { 'id': entity.id }) }}">{{ entity.username }}</a></td>
|
||||
<td>
|
||||
<ul>
|
||||
<li>
|
||||
<a href="{{ path('admin_user_show', { 'id': entity.id }) }}">{{ 'show'|trans }}</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="{{ path('admin_user_edit', { 'id': entity.id }) }}">{{ 'edit'|trans }}</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="{{ path('admin_user_edit_password', { 'id' : entity.id }) }}">{{ 'Edit password'|trans }}</a>
|
||||
</li>
|
||||
|
||||
{% if is_granted('ROLE_ALLOWED_TO_SWITCH') %}
|
||||
<li>
|
||||
<a href="{{ path('chill_main_homepage', {'_switch_user': entity.username }) }}">
|
||||
{{ 'Impersonate'|trans }}
|
||||
</a>
|
||||
</li>
|
||||
{% endif %}
|
||||
</ul>
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<ul>
|
||||
<li>
|
||||
<a href="{{ path('admin_user_new') }}">
|
||||
{{ 'Add a new user'|trans|capitalize }}
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
{% endblock admin_content %}
|
||||
|
||||
#}
|
||||
|
@ -1,22 +1,7 @@
|
||||
{% extends '@ChillMain/Admin/layout_permissions.html.twig' %}
|
||||
|
||||
{% block title %}{{ 'User creation'|trans }}{% endblock %}
|
||||
{% extends '@ChillMain/Admin/Permission/layout_crud_permission_index.html.twig' %}
|
||||
|
||||
{% block admin_content -%}
|
||||
<h1>{{ 'User creation'|trans }}</h1>
|
||||
|
||||
{{ form_start(form) }}
|
||||
{{ form_row(form.username) }}
|
||||
{{ form_row(form.email) }}
|
||||
{{ form_row(form.plainPassword) }}
|
||||
{{ form_widget(form.submit, { 'attr' : { 'class': 'btn btn-chill-blue' } }) }}
|
||||
{{ form_end(form) }}
|
||||
|
||||
<ul class="record_actions">
|
||||
<li>
|
||||
<a href="{{ path('admin_user') }}">
|
||||
{{ 'Back to the list'|trans }}
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
{% embed '@ChillMain/CRUD/_new_content.html.twig' %}
|
||||
{% block content_form_actions_save_and_show %}{% endblock %}
|
||||
{% endembed %}
|
||||
{% endblock %}
|
||||
|
@ -24,10 +24,6 @@ class PermissionMenuBuilder implements \Chill\MainBundle\Routing\LocalMenuBuilde
|
||||
]);
|
||||
|
||||
$menu->addChild('List users', [
|
||||
'route' => 'admin_user'
|
||||
])->setExtras(['order' => 400]);
|
||||
|
||||
$menu->addChild('List users CRUD', [
|
||||
'route' => 'chill_crud_admin_user_index'
|
||||
])->setExtras(['order' => 400]);
|
||||
|
||||
|
@ -1,44 +1,44 @@
|
||||
admin_user:
|
||||
path: /
|
||||
controller: Chill\MainBundle\Controller\UserController::indexAction
|
||||
|
||||
admin_user_show:
|
||||
path: /{id}/show
|
||||
controller: Chill\MainBundle\Controller\UserController::showAction
|
||||
|
||||
admin_user_new:
|
||||
path: /new
|
||||
controller: Chill\MainBundle\Controller\UserController::newAction
|
||||
|
||||
admin_user_create:
|
||||
path: /create
|
||||
controller: Chill\MainBundle\Controller\UserController::createAction
|
||||
methods: POST
|
||||
|
||||
admin_user_edit:
|
||||
path: /{id}/edit
|
||||
controller: Chill\MainBundle\Controller\UserController::editAction
|
||||
|
||||
admin_user_edit_password:
|
||||
path: /{id}/edit_password
|
||||
controller: Chill\MainBundle\Controller\UserController::editPasswordAction
|
||||
|
||||
admin_user_update:
|
||||
path: /{id}/update
|
||||
controller: Chill\MainBundle\Controller\UserController::updateAction
|
||||
methods: [POST, PUT]
|
||||
|
||||
admin_user_update_password:
|
||||
path: /{id}/update_password
|
||||
controller: Chill\MainBundle\Controller\UserController::updatePasswordAction
|
||||
methods: [POST, PUT]
|
||||
|
||||
admin_user_delete_group_center:
|
||||
path: /{uid}/delete_link_groupcenter/{gcid}
|
||||
controller: Chill\MainBundle\Controller\UserController::deleteLinkGroupCenterAction
|
||||
methods: [DELETE]
|
||||
|
||||
admin_user_add_group_center:
|
||||
path: /{uid}/add_link_groupcenter
|
||||
controller: Chill\MainBundle\Controller\UserController::addLinkGroupCenterAction
|
||||
methods: [POST]
|
||||
#admin_user:
|
||||
# path: /
|
||||
# controller: Chill\MainBundle\Controller\UserController::indexAction
|
||||
#
|
||||
#admin_user_show:
|
||||
# path: /{id}/show
|
||||
# controller: Chill\MainBundle\Controller\UserController::showAction
|
||||
#
|
||||
#admin_user_new:
|
||||
# path: /new
|
||||
# controller: Chill\MainBundle\Controller\UserController::newAction
|
||||
#
|
||||
#admin_user_create:
|
||||
# path: /create
|
||||
# controller: Chill\MainBundle\Controller\UserController::createAction
|
||||
# methods: POST
|
||||
#
|
||||
#admin_user_edit:
|
||||
# path: /{id}/edit
|
||||
# controller: Chill\MainBundle\Controller\UserController::editAction
|
||||
#
|
||||
#admin_user_edit_password:
|
||||
# path: /{id}/edit_password
|
||||
# controller: Chill\MainBundle\Controller\UserController::editPasswordAction
|
||||
#
|
||||
#admin_user_update:
|
||||
# path: /{id}/update
|
||||
# controller: Chill\MainBundle\Controller\UserController::updateAction
|
||||
# methods: [POST, PUT]
|
||||
#
|
||||
#admin_user_update_password:
|
||||
# path: /{id}/update_password
|
||||
# controller: Chill\MainBundle\Controller\UserController::updatePasswordAction
|
||||
# methods: [POST, PUT]
|
||||
#
|
||||
#admin_user_delete_group_center:
|
||||
# path: /{uid}/delete_link_groupcenter/{gcid}
|
||||
# controller: Chill\MainBundle\Controller\UserController::deleteLinkGroupCenterAction
|
||||
# methods: [DELETE]
|
||||
#
|
||||
#admin_user_add_group_center:
|
||||
# path: /{uid}/add_link_groupcenter
|
||||
# controller: Chill\MainBundle\Controller\UserController::addLinkGroupCenterAction
|
||||
# methods: [POST]
|
||||
|
Loading…
x
Reference in New Issue
Block a user