use Lc\SovBundle\Field\CollectionField; | use Lc\SovBundle\Field\CollectionField; | ||||
use Lc\SovBundle\Field\GalleryManagerField; | use Lc\SovBundle\Field\GalleryManagerField; | ||||
use Lc\SovBundle\Form\Type\Crud\PositionType; | use Lc\SovBundle\Form\Type\Crud\PositionType; | ||||
use Lc\SovBundle\Translation\TranslatorAdmin; | |||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; | |||||
use Symfony\Component\Form\Extension\Core\Type\CollectionType; | use Symfony\Component\Form\Extension\Core\Type\CollectionType; | ||||
use Symfony\Component\Form\Extension\Core\Type\TextType; | use Symfony\Component\Form\Extension\Core\Type\TextType; | ||||
use Symfony\Component\HttpFoundation\RequestStack; | use Symfony\Component\HttpFoundation\RequestStack; | ||||
protected $session; | protected $session; | ||||
protected $request; | protected $request; | ||||
protected $em; | protected $em; | ||||
public function __construct(SessionInterface $session, RequestStack $request, EntityManager $em) | |||||
protected $translatorAdmin; | |||||
public function __construct( | |||||
SessionInterface $session, | |||||
RequestStack $request, | |||||
EntityManager $em, | |||||
TranslatorAdmin $translatorAdmin | |||||
) | |||||
{ | { | ||||
$this->session = $session; | $this->session = $session; | ||||
$this->request = $request; | $this->request = $request; | ||||
$this->em = $em; | $this->em = $em; | ||||
$this->translatorAdmin = $translatorAdmin; | |||||
} | } | ||||
public function configureActions(Actions $actions): Actions | public function configureActions(Actions $actions): Actions | ||||
/* Translatable */ | /* Translatable */ | ||||
if ($this->isInstanceOf(TranslatableInterface::class)) { | if ($this->isInstanceOf(TranslatableInterface::class)) { | ||||
$actions->update( | $actions->update( | ||||
Crud::PAGE_INDEX, | |||||
Action::EDIT, | |||||
function (Action $action) { | |||||
$action->setTemplatePath('@LcSov/adminlte/crud/action/translatable.html.twig'); | |||||
Crud::PAGE_INDEX, | |||||
Action::EDIT, | |||||
function (Action $action) { | |||||
$action->setTemplatePath('@LcSov/adminlte/crud/action/translatable.html.twig'); | |||||
return $action; | |||||
} | |||||
return $action; | |||||
} | |||||
); | ); | ||||
} | } | ||||
/* Boutons des actions dans les listes */ | /* Boutons des actions dans les listes */ | ||||
$actionsArray[Crud::PAGE_INDEX] = [ | $actionsArray[Crud::PAGE_INDEX] = [ | ||||
Action::NEW => [ | |||||
'icon' => 'plus', | |||||
'label' => 'Créer', | |||||
'add_class'=>'btn-sm' | |||||
], | |||||
Action::EDIT => [ | |||||
'class' => 'btn btn-sm btn-primary', | |||||
'icon' => 'edit', | |||||
'label' => false, | |||||
'html_attributes'=> array('data-toggle'=> 'tooltip', 'title'=> 'Éditer') | |||||
], | |||||
Action::DELETE => [ | |||||
'icon' => 'trash', | |||||
'dropdown' => true, | |||||
], | |||||
Action::BATCH_DELETE => [ | |||||
'class' => 'btn btn-sm btn-danger', | |||||
'icon' => 'trash', | |||||
], | |||||
Action::NEW => [ | |||||
'icon' => 'plus', | |||||
'label' => $this->translatorAdmin->transAction('create'), | |||||
'add_class' => 'btn-sm' | |||||
], | |||||
Action::EDIT => [ | |||||
'class' => 'btn btn-sm btn-primary', | |||||
'icon' => 'edit', | |||||
'label' => false, | |||||
'html_attributes' => array( | |||||
'data-toggle' => 'tooltip', | |||||
'title' => $this->translatorAdmin->transAction('edit') | |||||
) | |||||
], | |||||
Action::DELETE => [ | |||||
'icon' => 'trash', | |||||
'dropdown' => true, | |||||
'label' => $this->translatorAdmin->transAction('delete') | |||||
], | |||||
Action::BATCH_DELETE => [ | |||||
'class' => 'btn btn-sm btn-danger', | |||||
'icon' => 'trash', | |||||
'label' => $this->translatorAdmin->transAction('delete') | |||||
], | |||||
]; | ]; | ||||
/* Boutons des actions dans l'édition */ | /* Boutons des actions dans l'édition */ | ||||
$actionSaveAndReturn = [ | $actionSaveAndReturn = [ | ||||
'add_class' => 'float-right', | |||||
'icon' => 'check', | |||||
'add_class' => 'float-right', | |||||
'icon' => 'check', | |||||
'label' => $this->translatorAdmin->transAction('save_and_return') | |||||
]; | ]; | ||||
$actionIndex = [ | $actionIndex = [ | ||||
'icon' => 'chevron-left', | |||||
'class' => 'btn btn-link', | |||||
'icon' => 'chevron-left', | |||||
'class' => 'btn btn-link', | |||||
'label' => $this->translatorAdmin->transAction('back_index') | |||||
]; | ]; | ||||
$actionsArray[Crud::PAGE_EDIT] = [ | $actionsArray[Crud::PAGE_EDIT] = [ | ||||
Action::SAVE_AND_CONTINUE => [ | |||||
'class' => 'btn btn-info float-right', | |||||
], | |||||
Action::DELETE => [ | |||||
'icon' => 'trash', | |||||
'class' => 'btn btn-outline-danger action-delete', | |||||
], | |||||
Action::SAVE_AND_RETURN => $actionSaveAndReturn, | |||||
Action::INDEX => $actionIndex, | |||||
Action::SAVE_AND_CONTINUE => [ | |||||
'class' => 'btn btn-info float-right', | |||||
'label' => $this->translatorAdmin->transAction('save_and_continue') | |||||
], | |||||
Action::DELETE => [ | |||||
'icon' => 'trash', | |||||
'class' => 'btn btn-outline-danger action-delete', | |||||
'label' => $this->translatorAdmin->transAction('delete') | |||||
], | |||||
Action::SAVE_AND_RETURN => $actionSaveAndReturn, | |||||
Action::INDEX => $actionIndex, | |||||
]; | ]; | ||||
$actionsArray[Crud::PAGE_NEW] = [ | $actionsArray[Crud::PAGE_NEW] = [ | ||||
Action::SAVE_AND_ADD_ANOTHER => [ | |||||
'class' => 'btn btn-info float-right', | |||||
], | |||||
Action::SAVE_AND_RETURN => $actionSaveAndReturn, | |||||
Action::INDEX => $actionIndex, | |||||
Action::SAVE_AND_ADD_ANOTHER => [ | |||||
'class' => 'btn btn-info float-right', | |||||
'label' => $this->translatorAdmin->transAction('save_and_add_another') | |||||
], | |||||
Action::SAVE_AND_RETURN => $actionSaveAndReturn, | |||||
Action::INDEX => $actionIndex, | |||||
]; | ]; | ||||
$actions->add(Crud::PAGE_EDIT, Action::INDEX); | $actions->add(Crud::PAGE_EDIT, Action::INDEX); | ||||
$actions->add(Crud::PAGE_NEW, Action::INDEX); | $actions->add(Crud::PAGE_NEW, Action::INDEX); | ||||
if ($this->isInstanceOf(SortableInterface::class)) { | if ($this->isInstanceOf(SortableInterface::class)) { | ||||
$sortAction = Action::new('sort', 'Ordonner', 'fa fa-sort') | |||||
->linkToCrudAction('sort') | |||||
->setCssClass('btn btn-sm btn-success') | |||||
->createAsGlobalAction(); | |||||
$sortAction = Action::new('sort', $this->translatorAdmin->transAction('sort'), 'fa fa-sort') | |||||
->linkToCrudAction('sort') | |||||
->setCssClass('btn btn-sm btn-success') | |||||
->createAsGlobalAction(); | |||||
$actions->add(Crud::PAGE_INDEX, $sortAction); | $actions->add(Crud::PAGE_INDEX, $sortAction); | ||||
} | } | ||||
if ($this->isInstanceOf(TreeInterface::class)) { | if ($this->isInstanceOf(TreeInterface::class)) { | ||||
$indexChildAction = Action::new('index_children', 'Afficher les enfants', 'fa fa-list') | |||||
->linkToCrudAction(Action::INDEX) | |||||
->setLabel('') | |||||
->setHtmlAttributes(array('data-toggle'=> 'tooltip', 'title'=> 'Afficher les enfants')) | |||||
->setTemplatePath('@LcSov/adminlte/crud/action/index_children.html.twig') | |||||
->setCssClass('btn btn-sm btn-success'); | |||||
$backParentAction = Action::new('index_parent', 'Retour au parent', 'fa fa-chevron-left') | |||||
->linkToCrudAction(Action::INDEX) | |||||
->setCssClass('btn btn-sm btn-info') | |||||
->createAsGlobalAction(); | |||||
$indexChildAction = Action::new( | |||||
'index_children', | |||||
$this->translatorAdmin->transAction('index_children'), | |||||
'fa fa-list' | |||||
) | |||||
->linkToCrudAction(Action::INDEX) | |||||
->setLabel('') | |||||
->setHtmlAttributes(array('data-toggle' => 'tooltip', 'title' => 'Afficher les enfants')) | |||||
->setTemplatePath('@LcSov/adminlte/crud/action/index_children.html.twig') | |||||
->setCssClass('btn btn-sm btn-success'); | |||||
$backParentAction = Action::new( | |||||
'index_parent', | |||||
$this->translatorAdmin->transAction('index_parent'), | |||||
'fa fa-chevron-left' | |||||
) | |||||
->linkToCrudAction(Action::INDEX) | |||||
->setCssClass('btn btn-sm btn-info') | |||||
->createAsGlobalAction(); | |||||
$actions->add(Crud::PAGE_INDEX, $backParentAction); | $actions->add(Crud::PAGE_INDEX, $backParentAction); | ||||
$actions->add(Crud::PAGE_INDEX, $indexChildAction); | $actions->add(Crud::PAGE_INDEX, $indexChildAction); | ||||
foreach ($actionsArray as $crudActionName => $actionsStyle) { | foreach ($actionsArray as $crudActionName => $actionsStyle) { | ||||
foreach ($actionsStyle as $actionName => $button) { | foreach ($actionsStyle as $actionName => $button) { | ||||
$actions->update( | $actions->update( | ||||
$crudActionName, | |||||
$actionName, | |||||
function (Action $action) use ($button) { | |||||
if (isset($button['add_class'])) { | |||||
$action->addCssClass($button['add_class']); | |||||
} | |||||
if (isset($button['class'])) { | |||||
$action->setCssClass($button['class']); | |||||
} | |||||
if (isset($button['icon'])) { | |||||
$action->setIcon('fa fa-'.$button['icon']); | |||||
} | |||||
if (isset($button['label'])) { | |||||
$action->setLabel($button['label']); | |||||
} | |||||
if (isset($button['dropdown']) && $button['dropdown']) { | |||||
$action->addCssClass('in-dropdown'); | |||||
} | |||||
if (isset($button['html_attributes']) && $button['html_attributes']) { | |||||
$action->setHtmlAttributes( $button['html_attributes']); | |||||
} | |||||
return $action; | |||||
$crudActionName, | |||||
$actionName, | |||||
function (Action $action) use ($button) { | |||||
if (isset($button['add_class'])) { | |||||
$action->addCssClass($button['add_class']); | |||||
} | |||||
if (isset($button['class'])) { | |||||
$action->setCssClass($button['class']); | |||||
} | |||||
if (isset($button['icon'])) { | |||||
$action->setIcon('fa fa-' . $button['icon']); | |||||
} | |||||
if (isset($button['label'])) { | |||||
$action->setLabel($button['label']); | |||||
} | |||||
if (isset($button['dropdown']) && $button['dropdown']) { | |||||
$action->addCssClass('in-dropdown'); | |||||
} | |||||
if (isset($button['html_attributes']) && $button['html_attributes']) { | |||||
$action->setHtmlAttributes($button['html_attributes']); | |||||
} | } | ||||
return $action; | |||||
} | |||||
); | ); | ||||
} | } | ||||
} | } | ||||
$crud = parent::configureCrud($crud); | $crud = parent::configureCrud($crud); | ||||
$this->setMaxResults($crud); | $this->setMaxResults($crud); | ||||
if($this->isInstanceOf(SortableInterface::class)){ | |||||
if ($this->isInstanceOf(SortableInterface::class)) { | |||||
$crud->setDefaultSort(['position' => 'ASC']); | $crud->setDefaultSort(['position' => 'ASC']); | ||||
} | } | ||||
return $crud; | return $crud; | ||||
{ | { | ||||
$entityClass = $this->getEntityFqcn(); | $entityClass = $this->getEntityFqcn(); | ||||
$paramListMaxResults = 'listMaxResults'; | $paramListMaxResults = 'listMaxResults'; | ||||
$paramSessionListMaxResults = $entityClass.'-'.$paramListMaxResults; | |||||
$paramSessionListMaxResults = $entityClass . '-' . $paramListMaxResults; | |||||
$requestListMaxResults = $this->request->getCurrentRequest()->get($paramListMaxResults); | $requestListMaxResults = $this->request->getCurrentRequest()->get($paramListMaxResults); | ||||
if ($requestListMaxResults) { | if ($requestListMaxResults) { | ||||
$this->session->set($paramSessionListMaxResults, $requestListMaxResults); | $this->session->set($paramSessionListMaxResults, $requestListMaxResults); | ||||
} | } | ||||
$maxResults = $this->session->get($paramSessionListMaxResults) ? $this->session->get( | $maxResults = $this->session->get($paramSessionListMaxResults) ? $this->session->get( | ||||
$paramSessionListMaxResults | |||||
$paramSessionListMaxResults | |||||
) : 30; | ) : 30; | ||||
$crud->setPaginatorPageSize($maxResults); | $crud->setPaginatorPageSize($maxResults); | ||||
{ | { | ||||
if ($this->isInstanceOf(SortableInterface::class)) { | if ($this->isInstanceOf(SortableInterface::class)) { | ||||
$seoPanel = [ | $seoPanel = [ | ||||
FormField::addPanel('Seo'), | |||||
TextField::new('metaTitle')->setLabel('Meta Title')->setHelp( | |||||
'Affiché dans les résultats de recherche Google' | |||||
FormField::addPanel('seo')->setTemplateName('crud/field/generic'), | |||||
TextField::new('metaTitle')->setLabel('Meta Title')->setHelp( | |||||
'Affiché dans les résultats de recherche Google' | |||||
)->hideOnIndex(), | |||||
TextareaField::new('metaDescription')->setLabel('Meta description')->setHelp( | |||||
'Affiché dans les résultats de recherche Google' | |||||
)->hideOnIndex(), | |||||
CollectionField::new('oldUrls') | |||||
->setFormTypeOption('entry_type', TextType::class)->setLabel( | |||||
'Anciennes urls du document' | |||||
)->hideOnIndex(), | )->hideOnIndex(), | ||||
TextareaField::new('metaDescription')->setLabel('Meta description')->setHelp( | |||||
'Affiché dans les résultats de recherche Google' | |||||
)->hideOnIndex(), | |||||
CollectionField::new('oldUrls') | |||||
->setFormTypeOption('entry_type', TextType::class)->setLabel( | |||||
'Anciennes urls du document' | |||||
)->hideOnIndex(), | |||||
]; | ]; | ||||
} | } | ||||
if ($this->isInstanceOf(DevAliasInterface::class)) { | if ($this->isInstanceOf(DevAliasInterface::class)) { | ||||
$confPanel = [ | $confPanel = [ | ||||
FormField::addPanel('Conf'), | |||||
TextField::new('devAlias')->hideOnIndex(), | |||||
FormField::addPanel('configuration')->setTemplateName('crud/field/generic'), | |||||
TextField::new('devAlias')->hideOnIndex(), | |||||
]; | ]; | ||||
} | } | ||||
$fields = FieldCollection::new($this->configureFields(Crud::PAGE_INDEX)); | $fields = FieldCollection::new($this->configureFields(Crud::PAGE_INDEX)); | ||||
$filters = $this->get(FilterFactory::class)->create( | $filters = $this->get(FilterFactory::class)->create( | ||||
$context->getCrud()->getFiltersConfig(), | |||||
$fields, | |||||
$context->getEntity() | |||||
$context->getCrud()->getFiltersConfig(), | |||||
$fields, | |||||
$context->getEntity() | |||||
); | ); | ||||
$queryBuilder = $this->createIndexQueryBuilder($context->getSearch(), $context->getEntity(), $fields, $filters); | $queryBuilder = $this->createIndexQueryBuilder($context->getSearch(), $context->getEntity(), $fields, $filters); | ||||
$paginator = $this->get(PaginatorFactory::class)->create($queryBuilder); | $paginator = $this->get(PaginatorFactory::class)->create($queryBuilder); | ||||
$this->get(EntityFactory::class)->processFieldsForAll($entities, $fields); | $this->get(EntityFactory::class)->processFieldsForAll($entities, $fields); | ||||
$sortableForm = $this->createFormBuilder(array('entities', $paginator->getResults())) | $sortableForm = $this->createFormBuilder(array('entities', $paginator->getResults())) | ||||
->add( | |||||
'entities', | |||||
CollectionType::class, | |||||
array( | |||||
'required' => true, | |||||
'allow_add' => true, | |||||
'entry_type' => PositionType::class, | |||||
) | |||||
->add( | |||||
'entities', | |||||
CollectionType::class, | |||||
array( | |||||
'required' => true, | |||||
'allow_add' => true, | |||||
'entry_type' => PositionType::class, | |||||
) | ) | ||||
->getForm(); | |||||
) | |||||
->getForm(); | |||||
$entityManager = $this->getDoctrine()->getManagerForClass($this->getEntityFqcn()); | $entityManager = $this->getDoctrine()->getManagerForClass($this->getEntityFqcn()); | ||||
$repository = $entityManager->getRepository($this->getEntityFqcn()); | $repository = $entityManager->getRepository($this->getEntityFqcn()); | ||||
$sortableForm->handleRequest($context->getRequest()); | $sortableForm->handleRequest($context->getRequest()); | ||||
} | } | ||||
$url = $this->get(AdminUrlGenerator::class) | $url = $this->get(AdminUrlGenerator::class) | ||||
->setAction(Action::INDEX) | |||||
->generateUrl(); | |||||
$this->addFlash('success', 'Position modifié', array()); | |||||
->setAction(Action::INDEX) | |||||
->generateUrl(); | |||||
$this->addFlash('success', $this->translatorAdmin->transFlashMessage('sort'), array()); | |||||
return $this->redirect($url); | return $this->redirect($url); | ||||
} | } | ||||
$responseParameters = $this->configureResponseParameters( | $responseParameters = $this->configureResponseParameters( | ||||
KeyValueStore::new( | |||||
[ | |||||
'pageName' => Crud::PAGE_INDEX, | |||||
'templatePath' => '@LcSov/adminlte/crud/sort.html.twig', | |||||
'entities' => $entities, | |||||
'paginator' => $paginator, | |||||
'global_actions' => array(), | |||||
'batch_actions' => array(), | |||||
'filters' => $filters, | |||||
'sortable_form' => $sortableForm, | |||||
] | |||||
) | |||||
KeyValueStore::new( | |||||
[ | |||||
'pageName' => Crud::PAGE_INDEX, | |||||
'templatePath' => '@LcSov/adminlte/crud/sort.html.twig', | |||||
'entities' => $entities, | |||||
'paginator' => $paginator, | |||||
'global_actions' => array(), | |||||
'batch_actions' => array(), | |||||
'filters' => $filters, | |||||
'sortable_form' => $sortableForm, | |||||
] | |||||
) | |||||
); | ); | ||||
$responseParameters->set('fields', $this->configureFields('index')); | $responseParameters->set('fields', $this->configureFields('index')); | ||||
$event = new AfterCrudActionEvent($context, $responseParameters); | $event = new AfterCrudActionEvent($context, $responseParameters); | ||||
$filters | $filters | ||||
); | ); | ||||
dump(get_defined_vars()); | |||||
if ($this->isInstanceOf(TreeInterface::class)) { | if ($this->isInstanceOf(TreeInterface::class)) { | ||||
$entityId = $searchDto->getRequest()->get('entityId'); | $entityId = $searchDto->getRequest()->get('entityId'); | ||||
if ($entityId !== null) { | if ($entityId !== null) { | ||||
return $queryBuilder; | return $queryBuilder; | ||||
} | } | ||||
public function edit(AdminContext $context) | |||||
{ | |||||
$response = parent::edit($context);; | |||||
// on vide le flash bag si édition en ajax (notification déjà affichée en Javascript) | |||||
if ($context->getRequest()->isXmlHttpRequest()) { | |||||
$this->session->getFlashBag()->clear(); | |||||
} | |||||
return $response; | |||||
} | |||||
public function isInstanceOf(string $interfaceName): bool | public function isInstanceOf(string $interfaceName): bool | ||||
{ | { | ||||
return in_array($interfaceName, class_implements($this->getEntityFqcn())); | return in_array($interfaceName, class_implements($this->getEntityFqcn())); |
public function configureDashboard(): Dashboard | public function configureDashboard(): Dashboard | ||||
{ | { | ||||
return Dashboard::new() | return Dashboard::new() | ||||
// the name visible to end users | |||||
->setTitle('LA CLIC !') | |||||
// you can include HTML contents too (e.g. to link to an image) | |||||
->setTitle('<img src="assets/img/laclic.png" width="100px">') | |||||
// the path defined in this method is passed to the Twig asset() function | |||||
->setFaviconPath('favicon.svg') | |||||
// the domain used by default is 'messages' | |||||
->setTranslationDomain('lcadmin'); | |||||
// the name visible to end users | |||||
->setTitle('LA CLIC !') | |||||
// you can include HTML contents too (e.g. to link to an image) | |||||
->setTitle('<img src="assets/img/laclic.png" width="100px">') | |||||
// the path defined in this method is passed to the Twig asset() function | |||||
->setFaviconPath('favicon.svg') | |||||
// the domain used by default is 'messages' | |||||
->setTranslationDomain('admin'); | |||||
} | } | ||||
public function configureAssets(): Assets | public function configureAssets(): Assets | ||||
$assets->addWebpackEncoreEntry('adminlte-index'); | $assets->addWebpackEncoreEntry('adminlte-index'); | ||||
$assets->addWebpackEncoreEntry('adminlte-form'); | $assets->addWebpackEncoreEntry('adminlte-form'); | ||||
$assets->addWebpackEncoreEntry('adminlte-sort'); | $assets->addWebpackEncoreEntry('adminlte-sort'); | ||||
$assets->addWebpackEncoreEntry('adminlte-field-collection'); | |||||
$assets->addWebpackEncoreEntry('adminlte-field-filemanager'); | |||||
return $assets; | return $assets; | ||||
} | } | ||||
// user menu with some menu items already created ("sign out", "exit impersonation", etc.) | // user menu with some menu items already created ("sign out", "exit impersonation", etc.) | ||||
// if you prefer to create the user menu from scratch, use: return UserMenu::new()->... | // if you prefer to create the user menu from scratch, use: return UserMenu::new()->... | ||||
return parent::configureUserMenu($user) | return parent::configureUserMenu($user) | ||||
// use the given $user object to get the user name | |||||
->setName($user->getName()) | |||||
// use this method if you don't want to display the name of the user | |||||
//->displayUserName(false) | |||||
->displayUserAvatar(false) | |||||
// you can also pass an email address to use gravatar's service | |||||
->setGravatarEmail($user->getEmail()) | |||||
// use the given $user object to get the user name | |||||
->setName($user->getName()) | |||||
// use this method if you don't want to display the name of the user | |||||
//->displayUserName(false) | |||||
->displayUserAvatar(false) | |||||
// you can also pass an email address to use gravatar's service | |||||
->setGravatarEmail($user->getEmail()) | |||||
// you can use any type of menu item, except submenus | |||||
->setMenuItems( | |||||
[ | |||||
//MenuItem::linkToRoute('My Profile', 'fa fa-id-card', '', ['...' => '...']), | |||||
MenuItem::linkToLogout('Déconnexion', 'sign-out-alt'), | |||||
//MenuItem::linkToLogout('Déconnexion', 'sign-out-alt') | |||||
] | |||||
); | |||||
// you can use any type of menu item, except submenus | |||||
->setMenuItems( | |||||
[ | |||||
//MenuItem::linkToRoute('My Profile', 'fa fa-id-card', '', ['...' => '...']), | |||||
MenuItem::linkToLogout('Déconnexion', 'sign-out-alt'), | |||||
//MenuItem::linkToLogout('Déconnexion', 'sign-out-alt') | |||||
] | |||||
); | |||||
} | } | ||||
public function configureCrud(): Crud | public function configureCrud(): Crud | ||||
$crud = Crud::new(); | $crud = Crud::new(); | ||||
return $crud | return $crud | ||||
->overrideTemplates( | |||||
[ | |||||
'layout' => '@LcSov/adminlte/layout.html.twig', | |||||
'main_menu' => '@LcSov/adminlte/block/menu.html.twig', | |||||
'crud/index' => '@LcSov/adminlte/crud/index.html.twig', | |||||
'crud/paginator' => '@LcSov/adminlte/crud/paginator.html.twig', | |||||
'crud/edit' => '@LcSov/adminlte/crud/edit.html.twig', | |||||
'crud/new' => '@LcSov/adminlte/crud/new.html.twig', | |||||
//'crud/action' => '@LcSov/adminlte/crud/action/action.html.twig', | |||||
] | |||||
) | |||||
->setFormThemes( | |||||
[ | |||||
'@LcSov/adminlte/crud/form_theme.html.twig', | |||||
'@FOSCKEditor/Form/ckeditor_widget.html.twig' | |||||
] | |||||
); | |||||
->overrideTemplates( | |||||
[ | |||||
'layout' => '@LcSov/adminlte/layout.html.twig', | |||||
'main_menu' => '@LcSov/adminlte/block/menu.html.twig', | |||||
'crud/index' => '@LcSov/adminlte/crud/index.html.twig', | |||||
'crud/paginator' => '@LcSov/adminlte/crud/paginator.html.twig', | |||||
'crud/edit' => '@LcSov/adminlte/crud/edit.html.twig', | |||||
'crud/new' => '@LcSov/adminlte/crud/new.html.twig', | |||||
'flash_messages' => '@LcSov/adminlte/block/flash_messages.html.twig', | |||||
] | |||||
) | |||||
->setFormThemes( | |||||
[ | |||||
'@LcSov/adminlte/crud/form_theme.html.twig', | |||||
'@FOSCKEditor/Form/ckeditor_widget.html.twig' | |||||
] | |||||
); | |||||
} | } | ||||
} | } |
namespace Lc\SovBundle\Controller\Admin; | namespace Lc\SovBundle\Controller\Admin; | ||||
use EasyCorp\Bundle\EasyAdminBundle\Dto\EntityDto; | |||||
use EasyCorp\Bundle\EasyAdminBundle\Provider\AdminContextProvider; | |||||
use Lc\SovBundle\Doctrine\EntityManager; | use Lc\SovBundle\Doctrine\EntityManager; | ||||
use Lc\SovBundle\Form\Type\User\ChangePasswordFormType; | use Lc\SovBundle\Form\Type\User\ChangePasswordFormType; | ||||
use Lc\SovBundle\Form\Type\User\ProfileFormType; | use Lc\SovBundle\Form\Type\User\ProfileFormType; | ||||
use Lc\SovBundle\Model\User\User; | |||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; | use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; | ||||
use Symfony\Component\HttpFoundation\Request; | use Symfony\Component\HttpFoundation\Request; | ||||
use Symfony\Component\HttpFoundation\Response; | use Symfony\Component\HttpFoundation\Response; | ||||
use Symfony\Component\Security\Core\Encoder\UserPasswordEncoderInterface; | use Symfony\Component\Security\Core\Encoder\UserPasswordEncoderInterface; | ||||
use Symfony\Component\Translation\TranslatableMessage; | |||||
class UserController extends AbstractController | class UserController extends AbstractController | ||||
{ | { | ||||
protected $em; | protected $em; | ||||
public function __construct(EntityManager $em) | public function __construct(EntityManager $em) | ||||
$this->em->update($user); | $this->em->update($user); | ||||
$this->em->flush(); | $this->em->flush(); | ||||
$this->addFlash('success', new TranslatableMessage('form.account_profile.message.success', [], 'admin')); | |||||
} | } | ||||
return $this->render( | return $this->render( | ||||
'@LcSov/user/profile.html.twig', | '@LcSov/user/profile.html.twig', | ||||
[ | [ | ||||
'form' => $form->createView() | |||||
'form' => $form->createView(), | |||||
] | ] | ||||
); | ); | ||||
} | } | ||||
if ($form->isSubmitted() && $form->isValid()) { | if ($form->isSubmitted() && $form->isValid()) { | ||||
$user = $form->getData(); | $user = $form->getData(); | ||||
$plainPassword = $form->get('plainPassword')->getData(); | |||||
$plainPassword = $form->get('plain_password')->getData(); | |||||
// @TODO : créer UserManager | // @TODO : créer UserManager | ||||
$newPasswordEncoded = $passwordEncoder->encodePassword($user, $plainPassword); | $newPasswordEncoded = $passwordEncoder->encodePassword($user, $plainPassword); | ||||
$this->em->update($user); | $this->em->update($user); | ||||
$this->em->flush(); | $this->em->flush(); | ||||
$this->addFlash('success', new TranslatableMessage('form.account_password.message.success', [], 'admin')); | |||||
} | } | ||||
return $this->render( | return $this->render( | ||||
'@LcSov/user/change_password.html.twig', | '@LcSov/user/change_password.html.twig', | ||||
[ | [ | ||||
'entity_class' => User::class, | |||||
'form' => $form->createView() | 'form' => $form->createView() | ||||
] | ] | ||||
); | ); |
<?php | |||||
namespace Lc\SovBundle\EventSubscriber; | |||||
use EasyCorp\Bundle\EasyAdminBundle\Event\AfterEntityDeletedEvent; | |||||
use EasyCorp\Bundle\EasyAdminBundle\Event\AfterEntityPersistedEvent; | |||||
use EasyCorp\Bundle\EasyAdminBundle\Event\AfterEntityUpdatedEvent; | |||||
use Symfony\Component\EventDispatcher\EventSubscriberInterface; | |||||
use Symfony\Component\HttpFoundation\Session\SessionInterface; | |||||
use Symfony\Component\Translation\TranslatableMessage; | |||||
class EasyAdminEventSubscriber implements EventSubscriberInterface | |||||
{ | |||||
protected $session ; | |||||
public function __construct(SessionInterface $session) | |||||
{ | |||||
$this->session = $session ; | |||||
} | |||||
public static function getSubscribedEvents(): array | |||||
{ | |||||
return [ | |||||
AfterEntityPersistedEvent::class => ['flashMessageAfterPersist'], | |||||
AfterEntityUpdatedEvent::class => ['flashMessageAfterUpdate'], | |||||
AfterEntityDeletedEvent::class => ['flashMessageAfterDelete'], | |||||
]; | |||||
} | |||||
public function flashMessageAfterPersist(AfterEntityPersistedEvent $event): void | |||||
{ | |||||
$this->session->getFlashBag()->add('success', new TranslatableMessage('flash_message.create', [ | |||||
'%name%' => (string) $event->getEntityInstance(), | |||||
])); | |||||
} | |||||
public function flashMessageAfterUpdate(AfterEntityUpdatedEvent $event): void | |||||
{ | |||||
$this->session->getFlashBag()->add('success', new TranslatableMessage('flash_message.update', [ | |||||
'%name%' => (string) $event->getEntityInstance(), | |||||
])); | |||||
} | |||||
public function flashMessageAfterDelete(AfterEntityDeletedEvent $event): void | |||||
{ | |||||
$this->session->getFlashBag()->add('success', new TranslatableMessage('flash_message.delete', [ | |||||
'%name%' => (string) $event->getEntityInstance(), | |||||
])); | |||||
} | |||||
} |
->setLabel($label) | ->setLabel($label) | ||||
->setTemplatePath('@LcSov/adminlte/crud/field/collection.html.twig') | ->setTemplatePath('@LcSov/adminlte/crud/field/collection.html.twig') | ||||
->setFormType(CollectionType::class) | ->setFormType(CollectionType::class) | ||||
->addWebpackEncoreEntries('adminlte-field-collection') | |||||
/*->addWebpackEncoreEntries('adminlte-field-collection')*/ | |||||
->setFormTypeOption('allow_add', true) | ->setFormTypeOption('allow_add', true) | ||||
->setFormTypeOption('allow_delete', true) | ->setFormTypeOption('allow_delete', true) | ||||
->setFormTypeOption('entry_options', array('label' => false)) | ->setFormTypeOption('entry_options', array('label' => false)) |
->setProperty($propertyName) | ->setProperty($propertyName) | ||||
->setLabel($label) | ->setLabel($label) | ||||
->setTemplatePath('@LcSov/adminlte/crud/field/file.html.twig') | ->setTemplatePath('@LcSov/adminlte/crud/field/file.html.twig') | ||||
->addWebpackEncoreEntries('adminlte-field-filemanager') | |||||
/*->addWebpackEncoreEntries('adminlte-field-filemanager')*/ | |||||
->setCustomOption('managerDir', 'file') | |||||
->setCustomOption('type', 'file') | |||||
->setFormType(FileManagerType::class) | ->setFormType(FileManagerType::class) | ||||
->addCssClass('field-text') | ->addCssClass('field-text') | ||||
->setCustomOption(self::OPTION_MAX_LENGTH, null) | ->setCustomOption(self::OPTION_MAX_LENGTH, null) |
->setTemplatePath('@LcSov/adminlte/crud/field/collection.html.twig') | ->setTemplatePath('@LcSov/adminlte/crud/field/collection.html.twig') | ||||
->setFormType(CollectionType::class) | ->setFormType(CollectionType::class) | ||||
->addCssClass('field-collection') | ->addCssClass('field-collection') | ||||
->addWebpackEncoreEntries('adminlte-field-collection') | |||||
->addWebpackEncoreEntries('adminlte-field-filemanager') | |||||
/*->addWebpackEncoreEntries('adminlte-field-collection') | |||||
->addWebpackEncoreEntries('adminlte-field-filemanager')*/ | |||||
->setFormTypeOption('allow_add', true) | ->setFormTypeOption('allow_add', true) | ||||
->setFormTypeOption('allow_delete', true) | ->setFormTypeOption('allow_delete', true) | ||||
->setFormTypeOption('entry_options', array('label'=> false)) | ->setFormTypeOption('entry_options', array('label'=> false)) | ||||
->setFormTypeOption('entry_type', FileManagerType::class) | ->setFormTypeOption('entry_type', FileManagerType::class) | ||||
->setFormTypeOption('attr', array('class'=> 'field-collection-group')) | ->setFormTypeOption('attr', array('class'=> 'field-collection-group')) | ||||
->setFormTypeOption('row_attr', array('data-sortable'=> true)) | ->setFormTypeOption('row_attr', array('data-sortable'=> true)) | ||||
->setCustomOption('managerDir', 'image') | |||||
->setCustomOption('type', 'image') | |||||
->hideOnIndex(); | ->hideOnIndex(); | ||||
//->setEntryType(FileManagerType::class); | //->setEntryType(FileManagerType::class); |
->setTemplatePath('@LcSov/adminlte/crud/field/image.html.twig') | ->setTemplatePath('@LcSov/adminlte/crud/field/image.html.twig') | ||||
->addWebpackEncoreEntries('adminlte-field-filemanager') | ->addWebpackEncoreEntries('adminlte-field-filemanager') | ||||
->setFormType(FileManagerType::class) | ->setFormType(FileManagerType::class) | ||||
->setCustomOption('managerDir', 'image') | |||||
->setCustomOption('type', 'image') | |||||
->addCssClass('field-text') | ->addCssClass('field-text') | ||||
->setCustomOption(self::OPTION_MAX_LENGTH, null) | ->setCustomOption(self::OPTION_MAX_LENGTH, null) | ||||
->setCustomOption(self::OPTION_RENDER_AS_HTML, false); | ->setCustomOption(self::OPTION_RENDER_AS_HTML, false); |
use Lc\SovBundle\DataTransformer\FileManagerTypeToDataTransformer; | use Lc\SovBundle\DataTransformer\FileManagerTypeToDataTransformer; | ||||
use Lc\SovBundle\Entity\File\File; | use Lc\SovBundle\Entity\File\File; | ||||
use Lc\SovBundle\Doctrine\Extension\FileInterface; | |||||
use Lc\SovBundle\Model\File\FileInterface; | |||||
use Lc\SovBundle\Doctrine\EntityManager; | use Lc\SovBundle\Doctrine\EntityManager; | ||||
use Symfony\Component\Form\AbstractType; | use Symfony\Component\Form\AbstractType; | ||||
use Symfony\Component\Form\DataTransformerInterface; | use Symfony\Component\Form\DataTransformerInterface; |
use Lc\SovBundle\Doctrine\EntityManager; | use Lc\SovBundle\Doctrine\EntityManager; | ||||
use Lc\SovBundle\Model\User\UserInterface; | use Lc\SovBundle\Model\User\UserInterface; | ||||
use Lc\SovBundle\Translation\TranslatorAdmin; | |||||
use Symfony\Component\Form\AbstractType; | use Symfony\Component\Form\AbstractType; | ||||
use Symfony\Component\Form\Extension\Core\Type\PasswordType; | use Symfony\Component\Form\Extension\Core\Type\PasswordType; | ||||
use Symfony\Component\Form\Extension\Core\Type\RepeatedType; | use Symfony\Component\Form\Extension\Core\Type\RepeatedType; | ||||
use Symfony\Component\Form\FormBuilderInterface; | use Symfony\Component\Form\FormBuilderInterface; | ||||
use Symfony\Component\OptionsResolver\OptionsResolver; | use Symfony\Component\OptionsResolver\OptionsResolver; | ||||
use Symfony\Component\Security\Core\Validator\Constraints\UserPassword; | use Symfony\Component\Security\Core\Validator\Constraints\UserPassword; | ||||
use Symfony\Component\Translation\TranslatableMessage; | |||||
use Symfony\Component\Validator\Constraints\NotBlank; | use Symfony\Component\Validator\Constraints\NotBlank; | ||||
class ChangePasswordFormType extends AbstractType | class ChangePasswordFormType extends AbstractType | ||||
{ | { | ||||
protected $em ; | |||||
protected $em; | |||||
protected $translatorAdmin; | |||||
public function __construct(EntityManager $em) | |||||
public function __construct(EntityManager $em, TranslatorAdmin $translatorAdmin) | |||||
{ | { | ||||
$this->em = $em ; | |||||
$this->em = $em; | |||||
$this->translatorAdmin = $translatorAdmin; | |||||
} | } | ||||
/** | /** | ||||
'current_password', | 'current_password', | ||||
PasswordType::class, | PasswordType::class, | ||||
[ | [ | ||||
'label' => 'Mot de passe actuel', | |||||
'label' => 'form.account_password.field.current_password', | |||||
'mapped' => false, | 'mapped' => false, | ||||
'constraints' => [ | 'constraints' => [ | ||||
new NotBlank(), | new NotBlank(), | ||||
); | ); | ||||
$builder->add( | $builder->add( | ||||
'plainPassword', | |||||
'plain_password', | |||||
RepeatedType::class, | RepeatedType::class, | ||||
[ | [ | ||||
'type' => PasswordType::class, | 'type' => PasswordType::class, | ||||
'mapped' => false, | 'mapped' => false, | ||||
'first_options' => ['label' => 'Nouveau mot de passe'], | |||||
'second_options' => ['label' => 'Nouveau mot de passe (confirmation)'], | |||||
'invalid_message' => 'Les deux mots de passe ne correspondent pas.', | |||||
'first_options' => ['label' => 'form.account_password.field.new_password'], | |||||
'second_options' => ['label' => 'form.account_password.field.new_password_repeat'], | |||||
'invalid_message' => $this->translatorAdmin->trans('form.account_password.message.invalid_passwords'), | |||||
] | ] | ||||
); | ); | ||||
'submit', | 'submit', | ||||
SubmitType::class, | SubmitType::class, | ||||
array( | array( | ||||
'label' => 'Sauvegarder' | |||||
'label' => $this->translatorAdmin->transAction('save') | |||||
) | ) | ||||
); | ); | ||||
} | } |
use Lc\SovBundle\DataTransformer\FileManagerTypeToDataTransformer; | use Lc\SovBundle\DataTransformer\FileManagerTypeToDataTransformer; | ||||
use Lc\SovBundle\Doctrine\EntityManager; | use Lc\SovBundle\Doctrine\EntityManager; | ||||
use Lc\SovBundle\Entity\File\File; | |||||
use Lc\SovBundle\Doctrine\Extension\FileInterface; | |||||
use Lc\SovBundle\Model\File\FileInterface; | |||||
use Lc\SovBundle\Model\User\UserInterface; | use Lc\SovBundle\Model\User\UserInterface; | ||||
use Lc\SovBundle\Translation\TranslatorAdmin; | |||||
use Symfony\Component\Form\AbstractType; | use Symfony\Component\Form\AbstractType; | ||||
use Symfony\Component\Form\Extension\Core\Type\EmailType; | use Symfony\Component\Form\Extension\Core\Type\EmailType; | ||||
use Symfony\Component\Form\Extension\Core\Type\SubmitType; | use Symfony\Component\Form\Extension\Core\Type\SubmitType; | ||||
use Symfony\Component\Form\Extension\Core\Type\TextType; | use Symfony\Component\Form\Extension\Core\Type\TextType; | ||||
use Symfony\Component\Form\FormBuilderInterface; | use Symfony\Component\Form\FormBuilderInterface; | ||||
use Symfony\Component\OptionsResolver\OptionsResolver; | use Symfony\Component\OptionsResolver\OptionsResolver; | ||||
use Symfony\Component\Translation\TranslatableMessage; | |||||
class ProfileFormType extends AbstractType | class ProfileFormType extends AbstractType | ||||
{ | { | ||||
protected $em ; | |||||
protected $em; | |||||
protected $translatorAdmin; | |||||
public function __construct(EntityManager $em) | |||||
public function __construct(EntityManager $em, TranslatorAdmin $translatorAdmin) | |||||
{ | { | ||||
$this->em = $em ; | |||||
$this->em = $em; | |||||
$this->translatorAdmin = $translatorAdmin; | |||||
} | } | ||||
public function buildForm(FormBuilderInterface $builder, array $options) | public function buildForm(FormBuilderInterface $builder, array $options) | ||||
{ | { | ||||
$entityName = $this->em->getEntityName(UserInterface::class); | |||||
$builder->add( | $builder->add( | ||||
'firstname', | 'firstname', | ||||
TextType::class, | |||||
array( | |||||
'label' => 'Prénom' | |||||
) | |||||
TextType::class | |||||
); | ); | ||||
$builder->add( | $builder->add( | ||||
'lastname', | 'lastname', | ||||
TextType::class, | |||||
array( | |||||
'label' => 'Nom' | |||||
) | |||||
TextType::class | |||||
); | ); | ||||
$builder->add( | $builder->add( | ||||
'email', | 'email', | ||||
EmailType::class, | |||||
array( | |||||
'label' => 'Email' | |||||
) | |||||
EmailType::class | |||||
); | ); | ||||
$builder->add( | |||||
'phone', | |||||
TextType::class, | |||||
array( | |||||
'label' => 'Téléphone' | |||||
) | |||||
); | |||||
if (property_exists($entityName, 'phone')) { | |||||
$builder->add( | |||||
'phone', | |||||
TextType::class | |||||
); | |||||
} | |||||
$builder->add( | $builder->add( | ||||
'submit', | 'submit', | ||||
SubmitType::class, | SubmitType::class, | ||||
array( | |||||
'label' => 'Sauvegarder' | |||||
) | |||||
[ | |||||
'label' => $this->translatorAdmin->transAction('save') | |||||
] | |||||
); | ); | ||||
} | } | ||||
import { Notification } from './js/notification.js'; | import { Notification } from './js/notification.js'; | ||||
global.Notification = Notification; | global.Notification = Notification; | ||||
Notification.init() ; | |||||
// Common | // Common | ||||
import './common.scss'; | import './common.scss'; |
/* Notifications */ | |||||
//Notification.init() ; | |||||
/* Tooltip */ | /* Tooltip */ | ||||
$('[data-toggle="tooltip"]').tooltip(); | $('[data-toggle="tooltip"]').tooltip(); | ||||
export class Notification { | export class Notification { | ||||
static setNotifications(notifications) { | |||||
static init() { | |||||
toastr.options.timeOut = 3000; | |||||
toastr.options.positionClass = 'toast-bottom-right'; | |||||
toastr.options.onHidden = function () { | |||||
if ($('#toast-container .toast').length == 1) { | |||||
$('#toast-close-all').remove(); | |||||
} | |||||
}; | |||||
} | |||||
static set(notifications) { | |||||
var currentNotifications = new Array(); | var currentNotifications = new Array(); | ||||
for (var type in notifications) { | for (var type in notifications) { | ||||
for (var key in notifications[type]) { | for (var key in notifications[type]) { | ||||
if (!currentNotifications.includes(notifications[type][key])) { | if (!currentNotifications.includes(notifications[type][key])) { | ||||
currentNotifications.push(notifications[type][key]); | currentNotifications.push(notifications[type][key]); | ||||
self.addNotification(type, notifications[type][key]); | |||||
self.add(type, notifications[type][key]); | |||||
} | } | ||||
} | } | ||||
} | } | ||||
} | } | ||||
static addNotification(type, text) { | |||||
toastr.options.timeOut = 3000; | |||||
toastr.options.onHidden = function () { | |||||
if ($('#toast-container .toast').length == 0) $('#toast-close-all').remove(); | |||||
}; | |||||
static add(type, text) { | |||||
toastr[type](text); | toastr[type](text); | ||||
if ($('#toast-close-all').length == 0) { | |||||
$('#toast-container').prepend('<button id="toast-close-all"><i class="fa fa-times"></i></button>'); | |||||
let $container = $('#toast-container') ; | |||||
let selectorButtonCloseAll = '#toast-close-all' ; | |||||
let countMessages = $container.find('.toast').length ; | |||||
if ($(selectorButtonCloseAll).length == 0 && countMessages > 2) { | |||||
$container.prepend('<button id="toast-close-all"><i class="fa fa-times"></i></button>'); | |||||
} | } | ||||
$('#toast-close-all').off('click'); | |||||
$('#toast-close-all').on('click', function () { | |||||
$(selectorButtonCloseAll).off('click').on('click', function () { | |||||
toastr.remove(); | toastr.remove(); | ||||
if ($('#toast-container .toast').length == 0) $('#toast-close-all').remove(); | |||||
if (countMessages == 0) { | |||||
$('#toast-close-all').remove(); | |||||
} | |||||
}); | }); | ||||
} | } | ||||
#toast-container { | #toast-container { | ||||
width: 350px; | |||||
width: 400px; | |||||
} | } | ||||
.toast { | |||||
float: right | |||||
#toast-container .toast { | |||||
float: right ; | |||||
width: 400px ; | |||||
opacity: 1 ; | |||||
box-shadow: none !important; | |||||
-moz-box-shadow: none !important; | |||||
-o-box-shadow: none !important; | |||||
-webkit-box-shadow: none !important; | |||||
&.success { | |||||
background-color: $success !important ; | |||||
} | |||||
&.danger, &.error { | |||||
background-color: $danger !important ; | |||||
} | |||||
&.info { | |||||
background-color: $info !important ; | |||||
} | |||||
&.warning { | |||||
background-color: $warning !important ; | |||||
} | |||||
} | } | ||||
#toast-container:before:hover { | #toast-container:before:hover { | ||||
#toast-close-all { | #toast-close-all { | ||||
border: 0; | border: 0; | ||||
position: absolute; | position: absolute; | ||||
bottom: 7px; | |||||
left: -15px; | |||||
pointer-events: auto; | pointer-events: auto; | ||||
z-index: 999999999999999999999; | |||||
z-index: 1000; | |||||
background: #BD362F; | background: #BD362F; | ||||
border-radius: 3px; | border-radius: 3px; | ||||
color: #fff; | color: #fff; | ||||
opacity: 0.8; | opacity: 0.8; | ||||
top: 2px; | |||||
width: 50px; | width: 50px; | ||||
height: 50px; | height: 50px; | ||||
font-size: 30px; | |||||
left: 0px; | |||||
font-size: 20px; | |||||
text-align: center; | text-align: center; | ||||
-webkit-text-shadow: 0 1px 0 #fff; | |||||
text-shadow: 0 1px 0 #fff; | |||||
-moz-box-shadow: 0 0 12px #999; | |||||
-webkit-box-shadow: 0 0 12px #999; | |||||
box-shadow: 0 0 12px #999; | |||||
//@include text-shadow(0 1px 0 #999) ; | |||||
border-radius: 50px ; | |||||
} | } | ||||
function initCollectionWidget() { | function initCollectionWidget() { | ||||
Tools.log('czefe'); | |||||
$('.field-collection[data-prototype]').each(function (i, collectionWidget) { | $('.field-collection[data-prototype]').each(function (i, collectionWidget) { | ||||
setCollectionWidgetSortable($(collectionWidget)); | setCollectionWidgetSortable($(collectionWidget)); | ||||
} | } | ||||
function reindexKeyCollectionWidget($collectionWidget) { | function reindexKeyCollectionWidget($collectionWidget) { | ||||
Tools.log('ncncnc'); | |||||
if ($collectionWidget.data('reindex-key')) { | if ($collectionWidget.data('reindex-key')) { | ||||
Tools.log('ncncnc'); | |||||
$collectionWidget.find('.field-collection-item').each(function (i, item) { | $collectionWidget.find('.field-collection-item').each(function (i, item) { | ||||
$(item).find('input,textarea').each(function (y, field) { | $(item).find('input,textarea').each(function (y, field) { | ||||
let $field = $(field); | let $field = $(field); |
let $field = $(this); | let $field = $(this); | ||||
$('#' + $field.data('id')).val(""); | $('#' + $field.data('id')).val(""); | ||||
$('#' + $field.data('id') + '_preview').prop('src',""); | $('#' + $field.data('id') + '_preview').prop('src',""); | ||||
$('#' + $field.data('id') + '_preview_text').html('Aucun fichier'); | |||||
}); | }); | ||||
$('.lc-filemanager-open').off('click'); | $('.lc-filemanager-open').off('click'); | ||||
$('.lc-filemanager-open').on('click', function (e) { | $('.lc-filemanager-open').on('click', function (e) { | ||||
var path = $(this).attr('data-path') | var path = $(this).attr('data-path') | ||||
$('#' + $field.data('id')).val(path); | $('#' + $field.data('id')).val(path); | ||||
$('#' + $field.data('id') + '_preview').prop('src',path); | $('#' + $field.data('id') + '_preview').prop('src',path); | ||||
$('#' + $field.data('id') + '_preview_text').html(path); | |||||
$('#lc-filemanager-modal').modal('hide'); | $('#lc-filemanager-modal').modal('hide'); | ||||
}); | }); | ||||
}); | }); |
let toggleRequest = $.ajax({type: "POST", url: toggleUrl, data: {}, dataType: 'json'}); | let toggleRequest = $.ajax({type: "POST", url: toggleUrl, data: {}, dataType: 'json'}); | ||||
toggleRequest.done(function (response) { | toggleRequest.done(function (response) { | ||||
Notification.addNotification('success', 'La propriété a bien été mise à jour.'); | |||||
Notification.add('success', 'La propriété a bien été mise à jour.'); | |||||
}); | }); | ||||
toggleRequest.fail(function () { | toggleRequest.fail(function () { | ||||
toggle.checked = oldValue; | toggle.checked = oldValue; | ||||
toggle.disabled = true; | toggle.disabled = true; | ||||
toggle.closest('.checkbox-switch').classList.add('disabled'); | toggle.closest('.checkbox-switch').classList.add('disabled'); | ||||
Notification.addNotification('error', 'Une erreur est survenue.'); | |||||
Notification.add('error', 'Une erreur est survenue.'); | |||||
}); | }); | ||||
}); | }); | ||||
} | } |
_liip_imagine: | |||||
resource: "@LiipImagineBundle/Resources/config/routing.yaml" | |||||
artgris_bundle_file_manager: | |||||
resource: "@ArtgrisFileManagerBundle/Controller" | |||||
type: annotation | |||||
prefix: /manager | |||||
sov_login: | sov_login: | ||||
path: /login | path: /login |
menu: | |||||
dashboard: Tableau de bord | |||||
page: Pages | |||||
user: Utilisateurs | |||||
user_index: Liste | |||||
account: Mon compte | |||||
account_profile: Informations personnelles | |||||
account_password: Mot de passe | |||||
title: | |||||
dashboard: Tableau de bord | |||||
index: '%label_plurial%' | |||||
sort: Ordonner "%label_plurial%" | |||||
new: Ajouter "%label%" | |||||
edit: Modifier "%label%" (#%id%) | |||||
detail: Voir "%label%" (#%id%) | |||||
account: | |||||
profile: Mes informations personnelles | |||||
change_password: Changer de mot de passe | |||||
action: | |||||
create: Créer | |||||
edit: Éditer | |||||
save: Sauvegarder | |||||
sort: Ordonner | |||||
delete: Supprimer | |||||
index_children: Afficher les enfants | |||||
index_parent: Retour au parent | |||||
back_index: Retour à la liste | |||||
save_and_return: Sauvegarder les modifications | |||||
save_and_continue: Sauvegarder et continuer l'édition | |||||
save_and_add_another: Créer et ajouter un nouvel élément | |||||
flash_message: | |||||
create: Le contenu "%name%" a été créé avec succès. | |||||
update: Le contenu "%name%" a été mis à jour avec succès. | |||||
delete: Le contenu "%name%" a été supprimé avec succès. | |||||
sort: Position modifiée | |||||
entity: | |||||
User: | |||||
label: Utilisateur | |||||
label_plurial: Utilisateurs | |||||
fields: | |||||
firstname: Prénom | |||||
lastname: Nom | |||||
Page: | |||||
label: Page | |||||
label_plurial: Pages | |||||
default: | |||||
fields: | |||||
title: Titre | |||||
position: Position | |||||
position_help: Position help | |||||
description: Description | |||||
description_help: Description help | |||||
file: Fichier | |||||
status: Statut | |||||
email: Email | |||||
metaTitle: Meta title | |||||
metaTitle_help: Affiché dans les résultats de recherche Google | |||||
metaDescription: Meta description | |||||
metaDescription_help: Affiché dans les résultats de recherche Google | |||||
oldUrls: Anciennes urls | |||||
devAlias: Alias | |||||
gallery: Galerie | |||||
panels: | |||||
general: Général | |||||
configuration: Configuration | |||||
gallery: Galerie | |||||
seo: Référencement | |||||
form: | |||||
account_profile: | |||||
message: | |||||
success: Votre profil a bien été modifié | |||||
account_password: | |||||
field: | |||||
current_password: Mot de passe actuel | |||||
new_password: Nouveau mot de passe | |||||
new_password_repeat: Nouveau mot de passe (confirmer) | |||||
message: | |||||
success: Votre mot de passe a bien été modifié | |||||
invalid_passwords: Les deux mots de passe ne correspondent pas. |
{# Gérés en Javascript dans layout.html.twig #} |
{# @var ea \EasyCorp\Bundle\EasyAdminBundle\Context\AdminContext #} | {# @var ea \EasyCorp\Bundle\EasyAdminBundle\Context\AdminContext #} | ||||
{% macro render_menu_item(item, is_sub_item = false) %} | {% macro render_menu_item(item, is_sub_item = false) %} | ||||
{% if item.isMenuSection %} | {% if item.isMenuSection %} | ||||
{% if item.icon is not empty %} | {% if item.icon is not empty %} | ||||
<i class="fa fa-{{ item.icon }}"></i> | <i class="fa fa-{{ item.icon }}"></i> | ||||
{% if item.icon is not empty %} | {% if item.icon is not empty %} | ||||
<i class="far fa-{{ item.icon }} nav-icon"></i> | <i class="far fa-{{ item.icon }} nav-icon"></i> | ||||
{% endif %} | {% endif %} | ||||
<p>{{ item.label|raw }}</p> | |||||
<p>{{ item.label|lc_trans_admin_menu }}</p> | |||||
{% if item.hasSubItems %}<i class="right fas fa-angle-left"></i>{% endif %} | {% if item.hasSubItems %}<i class="right fas fa-angle-left"></i>{% endif %} | ||||
</a> | </a> | ||||
{% endif %} | {% endif %} |
{% block configured_stylesheets %} | {% block configured_stylesheets %} | ||||
{{ parent() }} | {{ parent() }} | ||||
{% for css_asset in form.vars.ea_crud_form.assets.cssFiles %} | |||||
{% for css_asset in form.vars.ea_crud_form.assets.cssAssets %} | |||||
<link rel="stylesheet" href="{{ asset(css_asset) }}"> | <link rel="stylesheet" href="{{ asset(css_asset) }}"> | ||||
{% endfor %} | {% endfor %} | ||||
{% for webpack_encore_entry in form.vars.ea_crud_form.assets.webpackEncoreEntries %} | |||||
{% for webpack_encore_entry in form.vars.ea_crud_form.assets.webpackEncoreAssets %} | |||||
{{ ea_call_function_if_exists('encore_entry_link_tags', webpack_encore_entry) }} | {{ ea_call_function_if_exists('encore_entry_link_tags', webpack_encore_entry) }} | ||||
{% endfor %} | {% endfor %} | ||||
{% endblock %} | {% endblock %} | ||||
{% block configured_javascripts %} | {% block configured_javascripts %} | ||||
{{ parent() }} | {{ parent() }} | ||||
{% for js_asset in form.vars.ea_crud_form.assets.jsFiles %} | |||||
{% for js_asset in form.vars.ea_crud_form.assets.jsAssets %} | |||||
<script src="{{ asset(js_asset) }}"></script> | <script src="{{ asset(js_asset) }}"></script> | ||||
{% endfor %} | {% endfor %} | ||||
{% for webpack_encore_entry in form.vars.ea_crud_form.assets.webpackEncoreEntries %} | |||||
{% for webpack_encore_entry in form.vars.ea_crud_form.assets.webpackEncoreAssets %} | |||||
{{ ea_call_function_if_exists('encore_entry_script_tags', webpack_encore_entry) }} | {{ ea_call_function_if_exists('encore_entry_script_tags', webpack_encore_entry) }} | ||||
{% endfor %} | {% endfor %} | ||||
{% endblock %} | {% endblock %} |
{% for _locale in app_locales %} | {% for _locale in app_locales %} | ||||
<a class="{{ isIncludedInDropdown|default(false) ? 'dropdown-item' }} {{ action.cssClass }}" | <a class="{{ isIncludedInDropdown|default(false) ? 'dropdown-item' }} {{ action.cssClass }}" | ||||
href="{{ action.linkUrl }}&_locale={{ _locale }}" | href="{{ action.linkUrl }}&_locale={{ _locale }}" | ||||
{% for name, value in action.htmlAttributes %}{{ name }}="{{ value|e('html_attr') }}" {% endfor %}> | |||||
{%- if action.icon %}<i class="action-icon {{ action.icon }}"></i> {% endif -%} | |||||
{%- if action.label is not empty -%}{{ action.label }} {{ _locale }}{%- endif -%} | |||||
{% for name, value in action.htmlAttributes %}{{ name }}="{{ value|e('html_attr') }}" {% endfor %}> | |||||
{%- if action.icon %}<i class="action-icon {{ action.icon }}"></i> {% endif -%} | |||||
{%- if action.label is not empty -%}{{ action.label }} {%- endif -%} | |||||
{{ _locale }} | |||||
</a> | </a> | ||||
{% endfor %} | {% endfor %} | ||||
{% elseif 'button' == action.htmlElement %} | {% elseif 'button' == action.htmlElement %} | ||||
<button class="{{ action.cssClass }}" {% for name, value in action.htmlAttributes %}{{ name }}="{{ value|e('html_attr') }}" {% endfor %}> | <button class="{{ action.cssClass }}" {% for name, value in action.htmlAttributes %}{{ name }}="{{ value|e('html_attr') }}" {% endfor %}> | ||||
<span class="btn-label"> | |||||
<span class="btn-label"> | |||||
{%- if action.icon %}<i class="action-icon {{ action.icon }}"></i> {% endif -%} | {%- if action.icon %}<i class="action-icon {{ action.icon }}"></i> {% endif -%} | ||||
{%- if action.label is not empty -%}{{ action.label }}{%- endif -%} | |||||
{%- if action.label is not empty -%}{{ action.label }}{%- endif -%} | |||||
</span> | </span> | ||||
</button> | </button> | ||||
{% endif %} | {% endif %} |
{% block body_class 'ea-edit ea-edit-' ~ entity.name %} | {% block body_class 'ea-edit ea-edit-' ~ entity.name %} | ||||
{% block content_title %} | {% block content_title %} | ||||
{%- apply spaceless -%} | |||||
{{ ea.crud.customPageTitle is null | |||||
? (ea.crud.defaultPageTitle|trans(ea.i18n.translationParameters, 'EasyAdminBundle'))|raw | |||||
: ea.crud.customPageTitle|trans(ea.i18n.translationParameters)|raw }} | |||||
{%- endapply -%} | |||||
{{ 'edit'|lc_trans_admin_title(ea.getEntity().getFqcn(), {id: ea.getEntity().getInstance().getId()}) }} | |||||
{% endblock %} | {% endblock %} | ||||
{% block delete_form %} | {% block delete_form %} |
{# @var ea \EasyCorp\Bundle\EasyAdminBundle\Context\AdminContext #} | {# @var ea \EasyCorp\Bundle\EasyAdminBundle\Context\AdminContext #} | ||||
{% use '@EasyAdmin/crud/form_theme.html.twig' %} | {% use '@EasyAdmin/crud/form_theme.html.twig' %} | ||||
{% block form_row %} | |||||
{% set row_attr = row_attr|merge({ | |||||
class: row_attr.class|default('') ~ ' form-group' | |||||
}) %} | |||||
<div {% with { attr: row_attr } %}{{ block('attributes') }}{% endwith %}> | |||||
{{- form_label(form) -}} | |||||
<div class="form-widget"> | |||||
{% set has_prepend_html = ea.field.prepend_html|default(null) is not null %} | |||||
{% set has_append_html = ea.field.append_html|default(null) is not null %} | |||||
{% set has_input_groups = has_prepend_html or has_append_html %} | |||||
{% if has_input_groups %} | |||||
<div class="input-group">{% endif %} | |||||
{% if has_prepend_html %} | |||||
<div class="input-group-prepend"> | |||||
<span class="input-group-text">{{ ea.field.prepend_html|raw }}</span> | |||||
</div> | |||||
{% endif %} | |||||
{{ form_widget(form) }} | |||||
{% if has_append_html %} | |||||
<div class="input-group-append"> | |||||
<span class="input-group-text">{{ ea.field.append_html|raw }}</span> | |||||
</div> | |||||
{% endif %} | |||||
{% if has_input_groups %}</div>{% endif %} | |||||
{% set nullable_fields_fqcn = [ | |||||
'EasyCorp\Bundle\EasyAdminBundle\Field\DateTimeField', | |||||
'EasyCorp\Bundle\EasyAdminBundle\Field\DateField', | |||||
'EasyCorp\Bundle\EasyAdminBundle\Field\TimeField', | |||||
] %} | |||||
{% if form.vars.ea_crud_form.ea_field.fieldFqcn|default(false) in nullable_fields_fqcn and ea.field.nullable|default(false) %} | |||||
<div class="nullable-control"> | |||||
<label> | |||||
<input type="checkbox" {% if data is null %}checked="checked"{% endif %}> | |||||
{{ 'label.nullable_field'|trans({}, 'EasyAdminBundle') }} | |||||
</label> | |||||
</div> | |||||
{% endif %} | |||||
{% set help_message = name|lc_trans_admin_help(form.parent.vars.data) %} | |||||
{% if help_message != '' %} | |||||
<small class="form-help">{{ help_message }}</small> | |||||
{% endif %} | |||||
{{- form_errors(form) -}} | |||||
</div> | |||||
</div> | |||||
{% endblock form_row %} | |||||
{% block form_label -%} | |||||
{% if label is same as(false) -%} | |||||
<label>{# the empty <label> is needed to not break the form design #}</label> | |||||
{%- else -%} | |||||
{%- if compound is defined and compound -%} | |||||
{%- set element = 'legend' -%} | |||||
{%- set label_attr = label_attr|merge({class: (label_attr.class|default('') ~ ' col-form-label')|trim}) -%} | |||||
{%- else -%} | |||||
{%- set label_attr = label_attr|merge({for: id, class: (label_attr.class|default('') ~ ' form-control-label')|trim}) -%} | |||||
{%- endif -%} | |||||
{% if required -%} | |||||
{% set label_attr = label_attr|merge({class: (label_attr.class|default('') ~ ' required')|trim}) %} | |||||
{%- endif -%} | |||||
{% if label is empty -%} | |||||
{%- if label_format is not empty -%} | |||||
{% set label = label_format|replace({ | |||||
'%name%': name, | |||||
'%id%': id, | |||||
}) %} | |||||
{%- else -%} | |||||
{# {% set label = name|humanize %} #} | |||||
{%- endif -%} | |||||
{%- endif -%} | |||||
{# <{{ element|default('label') }}{% if label_attr %}{% with { attr: label_attr } %}{{ block('attributes') }}{% endwith %}{% endif %}>{{ (translation_domain is same as(false)) ? label : label|lower|lc_trans_admin_field(ea.getEntity().getFqcn()) }}</{{ element|default('label') }}> #} | |||||
<{{ element|default('label') }}{% if label_attr %}{% with { attr: label_attr } %}{{ block('attributes') }}{% endwith %}{% endif %}>{{ (label is not empty and '.' in label) ? label|trans({}, 'admin') : name|lc_trans_admin_field(form.parent.vars.data) }}</{{ element|default('label') }}> | |||||
{%- endif -%} | |||||
{%- endblock form_label %} | |||||
{% block gallery_manager_row %} | {% block gallery_manager_row %} | ||||
{{ block('collection_row') }} | {{ block('collection_row') }} | ||||
{% endblock gallery_manager_row %} | {% endblock gallery_manager_row %} | ||||
{{ block('collection_widget') }} | {{ block('collection_widget') }} | ||||
{% endblock gallery_manager_widget %} | {% endblock gallery_manager_widget %} | ||||
{% block collection_row %} | {% block collection_row %} | ||||
{% if prototype is defined and not prototype.rendered %} | {% if prototype is defined and not prototype.rendered %} | ||||
{% set row_attr = row_attr|merge({ 'data-prototype': form_row(prototype) }) %} | {% set row_attr = row_attr|merge({ 'data-prototype': form_row(prototype) }) %} | ||||
{% block file_manager_widget %} | {% block file_manager_widget %} | ||||
{% if form.vars.ea_crud_form.ea_field is not null %} | |||||
{% set managerDir = form.vars.ea_crud_form.ea_field.customOptions.get('managerDir') %} | |||||
{% set type = form.vars.ea_crud_form.ea_field.customOptions.get('type') %} | |||||
{% else %} | |||||
{% set managerDir = form.parent.vars.ea_crud_form.ea_field.customOptions.get('managerDir') %} | |||||
{% set type = form.parent.vars.ea_crud_form.ea_field.customOptions.get('type') %} | |||||
{% endif %} | |||||
<div class="lc-filemanager row"> | |||||
<div class="col-md-3 col-xs-12 form-group"> | |||||
<div class="lc-filemanager row"> | |||||
{% if type == 'image' %} | |||||
<div class="col-md-3 col-xs-12 form-group"> | |||||
<div class="lc-filemenager-preview card"> | <div class="lc-filemenager-preview card"> | ||||
<div class="no-image"> | <div class="no-image"> | ||||
<i class="fa fa-image"></i> | <i class="fa fa-image"></i> | ||||
</div> | </div> | ||||
<img src="{{ form.path.vars.value }}" id="{{ form.path.vars.id }}_preview" alt="" class="card-img-top"> | <img src="{{ form.path.vars.value }}" id="{{ form.path.vars.id }}_preview" alt="" class="card-img-top"> | ||||
</div> | </div> | ||||
</div> | |||||
</div> | |||||
{% else %} | |||||
<div class="callout callout-success"> | |||||
<h5><i class="fa fa-file-alt"></i> | |||||
<span id="{{ form.path.vars.id }}_preview_text">{{ form.path.vars.value }}</span> | |||||
</h5> | |||||
</div> | |||||
{% endif %} | |||||
<div class="col-12"> | <div class="col-12"> | ||||
<div class="input-group"> | <div class="input-group"> | ||||
<div class="input-group-prepend"> | <div class="input-group-prepend"> | ||||
{% endif %} | {% endif %} | ||||
<button type="button" class="btn btn-primary lc-filemanager-open" data-id="{{ form.path.vars.id }}" | <button type="button" class="btn btn-primary lc-filemanager-open" data-id="{{ form.path.vars.id }}" | ||||
data-toggle="tooltip" title="Sélectionner un fichier" | data-toggle="tooltip" title="Sélectionner un fichier" | ||||
data-target="{{ path('file_manager', {module:1, conf:'default'})|raw }}"> | |||||
data-target="{{ path('file_manager', {module:1, conf: managerDir})|raw }}"> | |||||
<i class="fa fa-folder-open"></i> | <i class="fa fa-folder-open"></i> | ||||
</button> | </button> | ||||
</div> | </div> | ||||
{{ form_rest(form) }} | {{ form_rest(form) }} | ||||
</div> | </div> | ||||
</div> | </div> | ||||
</div> | |||||
</div> | |||||
{% endif %} | |||||
{% endblock file_manager_widget %} | {% endblock file_manager_widget %} | ||||
{% block checkbox_radio_label -%} | {% block checkbox_radio_label -%} | ||||
{#- Do not display the label if widget is not defined in order to prevent double label rendering -#} | |||||
{#- Do not display the label if widget is not defined in order to prevent double label rendering -#} | |||||
{%- if widget is defined -%} | {%- if widget is defined -%} | ||||
{% set is_parent_custom = parent_label_class is defined and ('checkbox-custom' in parent_label_class or 'radio-custom' in parent_label_class or 'switch-custom' in parent_label_class) %} | {% set is_parent_custom = parent_label_class is defined and ('checkbox-custom' in parent_label_class or 'radio-custom' in parent_label_class or 'switch-custom' in parent_label_class) %} | ||||
{% set is_custom = label_attr.class is defined and ('checkbox-custom' in label_attr.class or 'radio-custom' in label_attr.class or 'switch-custom' in label_attr.class) %} | {% set is_custom = label_attr.class is defined and ('checkbox-custom' in label_attr.class or 'radio-custom' in label_attr.class or 'switch-custom' in label_attr.class) %} | ||||
{{ name|lc_trad(easyadmin['entity']['name'], 'field') }} | {{ name|lc_trad(easyadmin['entity']['name'], 'field') }} | ||||
{% else %} #} | {% else %} #} | ||||
{{- label is not same as(false) ? (translation_domain is same as(false) ? label : label|trans(label_translation_parameters, translation_domain))|raw -}} | {{- label is not same as(false) ? (translation_domain is same as(false) ? label : label|trans(label_translation_parameters, translation_domain))|raw -}} | ||||
{# {% endif %} #} | {# {% endif %} #} | ||||
{{- form_errors(form) -}} | {{- form_errors(form) -}} | ||||
</label> | </label> | ||||
{{ parent() }} | {{ parent() }} | ||||
{% if ea_crud_form.form_panels is defined %} | {% if ea_crud_form.form_panels is defined %} | ||||
<div class="card card-outline"> | <div class="card card-outline"> | ||||
<div class="card-header p-0 border-bottom-0"> | <div class="card-header p-0 border-bottom-0"> | ||||
<ul id="nav-params" class="nav nav-pills" role="navigation"> | <ul id="nav-params" class="nav nav-pills" role="navigation"> | ||||
{% for panel_name, panel_config in ea_crud_form.form_panels|filter(panel_config => not panel_config.form_tab or panel_config.form_tab == tab_name) %} | {% for panel_name, panel_config in ea_crud_form.form_panels|filter(panel_config => not panel_config.form_tab or panel_config.form_tab == tab_name) %} | ||||
{% set panel_has_header = panel_config.label|default(false) or panel_config.icon|default(false) %} | {% set panel_has_header = panel_config.label|default(false) or panel_config.icon|default(false) %} | ||||
<li class="nav-item"> | <li class="nav-item"> | ||||
<a href="#panel-{{ panel_name }} " class="nav-link {{ panel_name == 1 ? 'active' }}" data-toggle="tab" role="tab" | |||||
<a href="#panel-{{ panel_name }} " class="nav-link {{ panel_name == 1 ? 'active' }}" | |||||
data-toggle="tab" role="tab" | |||||
aria-controls="panel-{{ panel_name }}"> | aria-controls="panel-{{ panel_name }}"> | ||||
{{ panel_config.label|raw }} | |||||
<i class="fa fa-exclamation-circle invalid-form"></i> | |||||
{{ panel_config.label|lc_trans_admin_panel(ea.getEntity().getFqcn()) }} | |||||
<i class="fa fa-exclamation-circle invalid-form"></i> | |||||
</a> | </a> | ||||
</li> | </li> | ||||
{% endfor %} | {% endfor %} | ||||
{% if panel_config.icon|default(false) %} | {% if panel_config.icon|default(false) %} | ||||
<i class="{{ panel_config.icon }}"></i> | <i class="{{ panel_config.icon }}"></i> | ||||
{% endif %} | {% endif %} | ||||
{{ panel_config.label|raw }} | |||||
{{ panel_config.label|lc_trans_admin_panel(ea.getEntity().getFqcn()) }} | |||||
{% if collapsible %} | {% if collapsible %} | ||||
</a> | </a> |
{# @var entities \EasyCorp\Bundle\EasyAdminBundle\Collection\EntityDtoCollection #} | {# @var entities \EasyCorp\Bundle\EasyAdminBundle\Collection\EntityDtoCollection #} | ||||
{# @var paginator \EasyCorp\Bundle\EasyAdminBundle\Orm\EntityPaginator #} | {# @var paginator \EasyCorp\Bundle\EasyAdminBundle\Orm\EntityPaginator #} | ||||
{% extends ea.templatePath('layout') %} | {% extends ea.templatePath('layout') %} | ||||
{% trans_default_domain ea.i18n.translationDomain %} | {% trans_default_domain ea.i18n.translationDomain %} | ||||
{% block body_id entities|length > 0 ? 'ea-index-' ~ entities|first.name : '' %} | {% block body_id entities|length > 0 ? 'ea-index-' ~ entities|first.name : '' %} | ||||
{% block body_class 'index' ~ (entities|length > 0 ? ' index-' ~ entities|first.name : '') %} | {% block body_class 'index' ~ (entities|length > 0 ? ' index-' ~ entities|first.name : '') %} | ||||
{% block content_title %} | {% block content_title %} | ||||
{%- apply spaceless -%} | |||||
{% set default_title = ea.crud.defaultPageTitle('index')|trans(ea.i18n.translationParameters, 'EasyAdminBundle') %} | |||||
{{ ea.crud.customPageTitle is null ? default_title|raw : ea.crud.customPageTitle('index')|trans(ea.i18n.translationParameters)|raw }} | |||||
{%- endapply -%} | |||||
{{ 'index'|lc_trans_admin_title(ea.getEntity().getFqcn()) }} | |||||
{% endblock %} | {% endblock %} | ||||
{% block content_breadcrumb %} | {% block content_breadcrumb %} | ||||
{% endblock page_actions %} | {% endblock page_actions %} | ||||
{% block main %} | {% block main %} | ||||
{# sort can be multiple; let's consider the sorting field the first one #} | {# sort can be multiple; let's consider the sorting field the first one #} | ||||
{% set sort_field_name = app.request.get('sort')|keys|first %} | {% set sort_field_name = app.request.get('sort')|keys|first %} | ||||
{% set sort_order = app.request.get('sort')|first %} | {% set sort_order = app.request.get('sort')|first %} | ||||
class="fa fa-fw {{ column_icon }}"></i> | class="fa fa-fw {{ column_icon }}"></i> | ||||
</a> | </a> | ||||
{% else %} | {% else %} | ||||
<span>{{ field.label ? field.label|raw : field.getProperty|raw }}</span> | |||||
<span>{{ field.getProperty|lc_trans_admin_field(ea.getEntity().getFqcn()) }}</span> | |||||
{% endif %} | {% endif %} | ||||
</th> | </th> | ||||
{% endif %} | {% endif %} | ||||
{{ parent() }} | {{ parent() }} | ||||
<script type="text/javascript"> | <script type="text/javascript"> | ||||
$(function () { | $(function () { | ||||
/* $('.action-delete').on('click', function (e) { | /* $('.action-delete').on('click', function (e) { |
{% block body_class 'ea-new ea-new-' ~ entity.name %} | {% block body_class 'ea-new ea-new-' ~ entity.name %} | ||||
{% block content_title %} | {% block content_title %} | ||||
{%- apply spaceless -%} | |||||
{% set default_title = ea.crud.defaultPageTitle('new')|trans(ea.i18n.translationParameters, 'EasyAdminBundle') %} | |||||
{{ ea.crud.customPageTitle is null ? default_title|raw : ea.crud.customPageTitle('new')|trans(ea.i18n.translationParameters)|raw }} | |||||
{%- endapply -%} | |||||
{{ 'new'|lc_trans_admin_title(ea.getEntity().getFqcn()) }} | |||||
{% endblock %} | {% endblock %} | ||||
{% block body_javascript %} | {% block body_javascript %} | ||||
{{ parent() }} | {{ parent() }} | ||||
</li> | </li> | ||||
{% for page in paginator.pageRange %} | {% for page in paginator.pageRange %} | ||||
<li class="page-item {{ page == paginator.currentPage ? 'active' }} {{ page is null ? 'disabled' }}"> | |||||
{% if page is null %} | |||||
<span class="page-link">…</span> | |||||
{% else %} | |||||
<a class="page-link" href="{{ paginator.generateUrlForPage(page) }}">{{ page }}</a> | |||||
{% endif %} | |||||
</li> | |||||
{% if page != 0 %} | |||||
<li class="page-item {{ page == paginator.currentPage ? 'active' }} {{ page is null ? 'disabled' }}"> | |||||
{% if page is null %} | |||||
<span class="page-link">…</span> | |||||
{% else %} | |||||
<a class="page-link" href="{{ paginator.generateUrlForPage(page) }}">{{ page }}</a> | |||||
{% endif %} | |||||
</li> | |||||
{% endif %} | |||||
{% endfor %} | {% endfor %} | ||||
<li class="page-item {{ not paginator.hasNextPage ? 'disabled' }}"> | <li class="page-item {{ not paginator.hasNextPage ? 'disabled' }}"> |
{% block body_class 'index' ~ (entities|length > 0 ? ' index-' ~ entities|first.name : '') %} | {% block body_class 'index' ~ (entities|length > 0 ? ' index-' ~ entities|first.name : '') %} | ||||
{% block content_title %} | {% block content_title %} | ||||
Édition position | |||||
{{ 'sort'|lc_trans_admin_title(ea.getEntity().getFqcn()) }} | |||||
{% endblock %} | {% endblock %} | ||||
{% block content_breadcrumb %} | {% block content_breadcrumb %} | ||||
{{ include('@LcSov/adminlte/block/breadcrumb.html.twig') }} | {{ include('@LcSov/adminlte/block/breadcrumb.html.twig') }} | ||||
{% endblock content_breadcrumb %} | {% endblock content_breadcrumb %} |
{% extends '@LcSov/adminlte/layout.html.twig' %} | {% extends '@LcSov/adminlte/layout.html.twig' %} | ||||
{% block content_title 'SovBundle' %} | |||||
{% block content_title %} | |||||
{{ 'dashboard'|lc_trans_admin_title }} | |||||
{% endblock %} | |||||
{% block main %} | {% block main %} | ||||
Bien sur votre tableau de bord | |||||
Salut !!! | |||||
Tableau de bord par défaut. | |||||
{% endblock %} | {% endblock %} | ||||
<link rel="stylesheet" href="{{ asset(css_asset) }}"> | <link rel="stylesheet" href="{{ asset(css_asset) }}"> | ||||
{% endfor %} | {% endfor %} | ||||
{% for webpack_encore_entry in ea.assets.webpackEncoreEntries ?? [] %} | |||||
{% for webpack_encore_entry in ea.assets.webpackEncoreAssets ?? [] %} | |||||
{{ ea_call_function_if_exists('encore_entry_link_tags', webpack_encore_entry) }} | {{ ea_call_function_if_exists('encore_entry_link_tags', webpack_encore_entry) }} | ||||
{% endfor %} | {% endfor %} | ||||
{% endblock %} | {% endblock %} | ||||
{% block body %} | {% block body %} | ||||
<body id="{% block body_id %}{% endblock %}" class="sidebar-mini layout-fixed {% block body_class %}{% endblock %}"> | <body id="{% block body_id %}{% endblock %}" class="sidebar-mini layout-fixed {% block body_class %}{% endblock %}"> | ||||
{% block javascript_page_layout %} | {% block javascript_page_layout %} | ||||
<script> | <script> | ||||
document.body.classList.add( | document.body.classList.add( | ||||
<script src="{{ asset(js_asset) }}"></script> | <script src="{{ asset(js_asset) }}"></script> | ||||
{% endfor %} | {% endfor %} | ||||
{% for webpack_encore_entry in ea.assets.webpackEncoreEntries ?? [] %} | |||||
{{ ea_call_function_if_exists('encore_entry_script_tags', webpack_encore_entry) }} | |||||
{% for webpack_encore_entry in ea.assets.webpackEncoreAssets ?? [] %} | |||||
{{ ea_call_function_if_exists('encore_entry_script_tags', webpack_encore_entry, null, '_default', {'defer': false}) }} | |||||
{% endfor %} | {% endfor %} | ||||
{% endblock %} | {% endblock %} | ||||
{% include '@LcSov/adminlte/filemanager/file-manager-modal.html.twig' %} | {% include '@LcSov/adminlte/filemanager/file-manager-modal.html.twig' %} | ||||
{% if app.session is not null and app.session.started %} | |||||
{% set flash_messages = app.session.flashbag.all %} | |||||
{% if flash_messages|length > 0 %} | |||||
<script type="text/javascript"> | |||||
$(document).ready(function() { | |||||
{% for label, messages in flash_messages %} | |||||
{% for message in messages %} | |||||
Notification.add("{{ label }}", "{{ message|trans|raw|replace({'"': '\"'}) }}"); | |||||
{% endfor %} | |||||
{% endfor %} | |||||
}); | |||||
</script> | |||||
{% endif %} | |||||
{% endif %} | |||||
</body> | </body> | ||||
{% endblock body %} | {% endblock body %} | ||||
</html> | </html> |
{% extends '@LcSov/adminlte/layout.html.twig' %} | {% extends '@LcSov/adminlte/layout.html.twig' %} | ||||
{% block content_title %} | {% block content_title %} | ||||
Changer de mot de passe | |||||
{{ 'account.change_password'|lc_trans_admin_title }} | |||||
{% endblock %} | {% endblock %} | ||||
{% block main %} | {% block main %} |
{% extends '@LcSov/adminlte/layout.html.twig' %} | {% extends '@LcSov/adminlte/layout.html.twig' %} | ||||
{% block content_title %} | {% block content_title %} | ||||
Mes informations personnelles | |||||
{{ 'account.profile'|lc_trans_admin_title }} | |||||
{% endblock %} | {% endblock %} | ||||
{% block main %} | {% block main %} |
<?php | |||||
namespace Lc\SovBundle\Translation; | |||||
use EasyCorp\Bundle\EasyAdminBundle\Config\Crud; | |||||
use Symfony\Contracts\Translation\TranslatorInterface; | |||||
class TranslatorAdmin | |||||
{ | |||||
protected $translator; | |||||
const DOMAIN = 'admin'; | |||||
public function __construct(TranslatorInterface $translator) | |||||
{ | |||||
$this->translator = $translator; | |||||
} | |||||
public function transAction($action) | |||||
{ | |||||
return $this->trans('action.' . $action); | |||||
} | |||||
public function transMenu($menu) | |||||
{ | |||||
return $this->trans('menu.' . $menu); | |||||
} | |||||
public function transFlashMessage($name) | |||||
{ | |||||
return $this->trans('flash_message.' . $name); | |||||
} | |||||
public function transField($fieldName, $entityClass): string | |||||
{ | |||||
return $this->transEntityThenDefault( | |||||
$this->buildTransIdField($fieldName, $entityClass), | |||||
$this->buildTransIdField($fieldName, $entityClass, true) | |||||
); | |||||
} | |||||
public function transHelp($fieldName, $entityClass): string | |||||
{ | |||||
$fieldName = $fieldName . '_help'; | |||||
return $this->transEntityThenDefault( | |||||
$this->buildTransIdField($fieldName, $entityClass), | |||||
$this->buildTransIdField($fieldName, $entityClass, true), | |||||
true | |||||
); | |||||
} | |||||
public function transPanel($panelName, $entityClass): string | |||||
{ | |||||
return $this->transEntityThenDefault( | |||||
$this->buildTransIdPanel($panelName, $entityClass), | |||||
$this->buildTransIdPanel($panelName, $entityClass, true) | |||||
); | |||||
} | |||||
public function transTitle($pageName, $entityClass = null, $params = []) | |||||
{ | |||||
$entityName = $this->getEntityName($entityClass); | |||||
$paramsTranslation = []; | |||||
if ($entityName) { | |||||
$baseIdEntityLabel = 'entity.' . $entityName; | |||||
$paramsTranslation = [ | |||||
'%label%' => $this->trans($baseIdEntityLabel . '.label'), | |||||
'%label_plurial%' => $this->trans($baseIdEntityLabel . '.label_plurial'), | |||||
]; | |||||
} | |||||
if (isset($params['id'])) { | |||||
$paramsTranslation['%id%'] = $params['id']; | |||||
} | |||||
return $this->trans( | |||||
'title.' . $pageName, | |||||
$paramsTranslation | |||||
); | |||||
} | |||||
private function transEntityThenDefault($idTranslationEntity, $idTranslationDefault, $returnEmpty = false): string | |||||
{ | |||||
$translation = $this->trans($idTranslationEntity); | |||||
if ($translation == $idTranslationEntity) { | |||||
$translation = $this->trans($idTranslationDefault); | |||||
if ($translation == $idTranslationDefault) { | |||||
if ($returnEmpty) { | |||||
$translation = ''; | |||||
} else { | |||||
$translation = $idTranslationEntity; | |||||
} | |||||
} | |||||
} | |||||
return $translation; | |||||
} | |||||
private function buildTransIdField($fieldName, $entityClass, $default = false): string | |||||
{ | |||||
return $this->buildTransIdEntitySection($fieldName, $entityClass, 'fields', $default); | |||||
} | |||||
private function buildTransIdPanel($panelName, $entityClass, $default = false): string | |||||
{ | |||||
return $this->buildTransIdEntitySection($panelName, $entityClass, 'panels', $default); | |||||
} | |||||
private function buildTransIdEntitySection($name, $entityClass, $entitySection, $default): string | |||||
{ | |||||
if ($default) { | |||||
$entityName = 'default'; | |||||
} else { | |||||
$entityName = $this->getEntityName($entityClass); | |||||
} | |||||
return 'entity.' . $entityName . '.' . $entitySection . '.' . $name; | |||||
} | |||||
public function trans($id, $params = [], $domain = self::DOMAIN): string | |||||
{ | |||||
return $this->translator->trans($id, $params, $domain); | |||||
} | |||||
private function getEntityName($entityClass): string | |||||
{ | |||||
if (is_object($entityClass)) { | |||||
$entityClass = get_class($entityClass); | |||||
} | |||||
if (is_string($entityClass)) { | |||||
$entityNameExplode = explode('\\', $entityClass); | |||||
return $entityNameExplode[count($entityNameExplode) - 1]; | |||||
} | |||||
return 'default'; | |||||
} | |||||
} | |||||
?> |
namespace Lc\SovBundle\Twig; | namespace Lc\SovBundle\Twig; | ||||
use Doctrine\ORM\EntityManagerInterface; | use Doctrine\ORM\EntityManagerInterface; | ||||
use EasyCorp\Bundle\EasyAdminBundle\Config\Crud; | |||||
use Lc\SovBundle\Translation\TranslatorAdmin; | |||||
use Liip\ImagineBundle\Imagine\Cache\CacheManager; | use Liip\ImagineBundle\Imagine\Cache\CacheManager; | ||||
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface; | use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface; | ||||
use Symfony\Component\HttpFoundation\RequestStack; | use Symfony\Component\HttpFoundation\RequestStack; | ||||
use Symfony\Component\HttpKernel\KernelInterface; | use Symfony\Component\HttpKernel\KernelInterface; | ||||
use Symfony\Component\Routing\Generator\UrlGeneratorInterface; | use Symfony\Component\Routing\Generator\UrlGeneratorInterface; | ||||
use Symfony\Contracts\Translation\TranslatorInterface; | |||||
use Twig\Extension\AbstractExtension; | use Twig\Extension\AbstractExtension; | ||||
use Twig\TwigFilter; | use Twig\TwigFilter; | ||||
use Twig\TwigFunction; | use Twig\TwigFunction; | ||||
class TwigExtension extends AbstractExtension | class TwigExtension extends AbstractExtension | ||||
{ | { | ||||
protected $em; | |||||
protected $kernel; | |||||
protected $parameterBag; | |||||
protected $cacheManager; | |||||
protected $requestStack; | |||||
protected $router; | |||||
public function __construct(KernelInterface $kernel, ParameterBagInterface $parameterBag, CacheManager $cacheManager, EntityManagerInterface $entityManager, RequestStack $requestStack,UrlGeneratorInterface $router) | |||||
{ | |||||
$this->kernel = $kernel; | |||||
$this->parameterBag = $parameterBag; | |||||
$this->cacheManager = $cacheManager; | |||||
$this->em = $entityManager; | |||||
$this->requestStack = $requestStack; | |||||
$this->router = $router; | |||||
protected $em; | |||||
protected $kernel; | |||||
protected $parameterBag; | |||||
protected $cacheManager; | |||||
protected $requestStack; | |||||
protected $router; | |||||
protected $translator; | |||||
protected $translatorAdmin; | |||||
public function __construct( | |||||
KernelInterface $kernel, | |||||
ParameterBagInterface $parameterBag, | |||||
CacheManager $cacheManager, | |||||
EntityManagerInterface $entityManager, | |||||
RequestStack $requestStack, | |||||
UrlGeneratorInterface $router, | |||||
TranslatorInterface $translator, | |||||
TranslatorAdmin $translatorAdmin | |||||
) { | |||||
$this->kernel = $kernel; | |||||
$this->parameterBag = $parameterBag; | |||||
$this->cacheManager = $cacheManager; | |||||
$this->em = $entityManager; | |||||
$this->requestStack = $requestStack; | |||||
$this->router = $router; | |||||
$this->translator = $translator; | |||||
$this->translatorAdmin = $translatorAdmin; | |||||
} | |||||
public function getFunctions() | |||||
{ | |||||
return array( | |||||
new TwigFunction('lc_liip', [$this, 'lcLiip']), | |||||
new TwigFunction('homepage_route', [$this, 'homepageRoute']), | |||||
new TwigFunction('page_by_dev_alias', [$this, 'getPageByDevAlias']), | |||||
new TwigFunction('translated_urls', [$this, 'getTranslatedUrls']) | |||||
); | |||||
} | |||||
public function getFilters() | |||||
{ | |||||
return [ | |||||
new TwigFilter('lc_cache', [$this, 'lcCache']), | |||||
new TwigFilter('lc_trans_admin_field', [$this, 'lcTransAdminField']), | |||||
new TwigFilter('lc_trans_admin_help', [$this, 'lcTransAdminHelp']), | |||||
new TwigFilter('lc_trans_admin_panel', [$this, 'lcTransAdminPanel']), | |||||
new TwigFilter('lc_trans_admin_menu', [$this, 'lcTransAdminMenu']), | |||||
new TwigFilter('lc_trans_admin_title', [$this, 'lcTransAdminTitle']), | |||||
new TwigFilter('lc_trans_admin_action', [$this, 'lcTransAdminAction']), | |||||
]; | |||||
} | |||||
public function lcCache($file) | |||||
{ | |||||
$cacheTime = filemtime($this->kernel->getProjectDir() . '/public' . $file); | |||||
if ($cacheTime) { | |||||
return $file . '?c=' . $cacheTime; | |||||
} else { | |||||
return $file . "?c=0"; | |||||
} | } | ||||
public function getFunctions() | |||||
{ | |||||
return array( | |||||
new TwigFunction('lc_liip', [$this, 'lcLiip']), | |||||
new TwigFunction('homepage_route', [$this, 'homepageRoute']), | |||||
new TwigFunction('page_by_dev_alias', [$this, 'getPageByDevAlias']), | |||||
new TwigFunction('translated_urls', [$this, 'getTranslatedUrls']) | |||||
); | |||||
} | |||||
public function lcTransAdminField($fieldName, $entityClass) | |||||
{ | |||||
return $this->translatorAdmin->transField($fieldName, $entityClass) ; | |||||
} | |||||
public function lcTransAdminHelp($fieldName, $entityClass) | |||||
{ | |||||
return $this->translatorAdmin->transHelp($fieldName, $entityClass) ; | |||||
} | |||||
public function lcTransAdminPanel($panelName, $entityClass) | |||||
{ | |||||
return $this->translatorAdmin->transPanel($panelName, $entityClass) ; | |||||
} | |||||
public function lcTransAdminMenu($menuName) | |||||
{ | |||||
return $this->translatorAdmin->transMenu($menuName);; | |||||
} | |||||
public function lcTransAdminAction($actionName) | |||||
{ | |||||
return $this->translatorAdmin->transAction($actionName);; | |||||
} | |||||
public function lcTransAdminTitle($pageName, $entityClass = null, $params = []) | |||||
{ | |||||
return $this->translatorAdmin->transTitle($pageName, $entityClass, $params) ; | |||||
} | |||||
public function lcLiip($path, $thumb = 'tile', $default = 'default.jpg') | |||||
{ | |||||
if (substr($path, 0, 1) === '/') { | |||||
$path = substr($path, 1); | |||||
} | } | ||||
if ($path) { | |||||
$fileManagerFolder = substr($this->getFileManagerFolder(), 1); | |||||
public function getFilters() | |||||
{ | |||||
return [ | |||||
new TwigFilter('lc_cache', [$this, 'lcCache']), | |||||
]; | |||||
} | |||||
if (strpos($path, $fileManagerFolder) === false) { | |||||
$path = $fileManagerFolder . '/' . $path; | |||||
} | |||||
public function lcCache($file) | |||||
{ | |||||
$cacheTime = filemtime($this->kernel->getProjectDir() . '/public' . $file); | |||||
if ($cacheTime) { | |||||
return $file . '?c=' . $cacheTime; | |||||
} else { | |||||
return $file . "?c=0"; | |||||
} | |||||
if (file_exists($path)) { | |||||
return $this->cacheManager->getBrowserPath($path, $thumb); | |||||
} | |||||
} | } | ||||
public function lcLiip($path, $thumb = 'tile', $default = 'default.jpg') | |||||
{ | |||||
if (substr($path, 0, 1) === '/') $path = substr($path, 1); | |||||
if ($path) { | |||||
$fileManagerFolder = substr($this->getFileManagerFolder(), 1) ; | |||||
return $this->cacheManager->getBrowserPath($this->getFileManagerFolder() . '/' . $default, $thumb); | |||||
} | |||||
if (strpos($path, $fileManagerFolder) === false) { | |||||
$path = $fileManagerFolder . '/' . $path; | |||||
} | |||||
function getTranslatedUrls() | |||||
{ | |||||
$ret = array(); | |||||
$langs = $this->parameterBag->get('app.locales'); | |||||
$currentRoute = $this->requestStack->getCurrentRequest()->get('_route'); | |||||
if (file_exists($path)) { | |||||
return $this->cacheManager->getBrowserPath($path, $thumb); | |||||
} | |||||
} | |||||
$params = array_merge((array)$this->requestStack->getCurrentRequest()->get('_route_params'), $_GET); | |||||
return $this->cacheManager->getBrowserPath($this->getFileManagerFolder() . '/' . $default, $thumb); | |||||
if ($currentRoute) { | |||||
foreach ($langs as $lg) { | |||||
$ret[$lg] = $this->router->generate($currentRoute, array_merge($params, array('_locale' => $lg))); | |||||
} | |||||
} | } | ||||
function getTranslatedUrls() | |||||
{ | |||||
$ret = array(); | |||||
$langs = $this->parameterBag->get('app.locales'); | |||||
$currentRoute = $this->requestStack->getCurrentRequest()->get('_route'); | |||||
return $ret; | |||||
} | |||||
$params = array_merge((array)$this->requestStack->getCurrentRequest()->get('_route_params'), $_GET); | |||||
public function getFileManagerFolder() | |||||
{ | |||||
return $this->parameterBag->get('app.path_uploads'); | |||||
} | |||||
if ($currentRoute) { | |||||
foreach($langs as $lg) { | |||||
$ret[$lg] = $this->router->generate($currentRoute, array_merge($params, array('_locale'=>$lg))); | |||||
} | |||||
} | |||||
return $ret; | |||||
} | |||||
public function getFileManagerFolder() | |||||
{ | |||||
return $this->parameterBag->get('app.path_uploads'); | |||||
} | |||||
public function homepageRoute(){ | |||||
return $this->parameterBag->get('lc_sov.homepage_route'); | |||||
} | |||||
public function homepageRoute() | |||||
{ | |||||
return $this->parameterBag->get('lc_sov.homepage_route'); | |||||
} | |||||
} | } |