|
|
@@ -63,14 +63,14 @@ abstract class AbstractAdminController extends EaAbstractCrudController |
|
|
|
public static function getSubscribedServices() |
|
|
|
{ |
|
|
|
return array_merge( |
|
|
|
parent::getSubscribedServices(), |
|
|
|
[ |
|
|
|
'session' => SessionInterface::class, |
|
|
|
'request' => RequestStack::class, |
|
|
|
'em' => EntityManagerInterface::class, |
|
|
|
'translator_admin' => TranslatorAdmin::class, |
|
|
|
'filter_manager' => FilterManager::class, |
|
|
|
] |
|
|
|
parent::getSubscribedServices(), |
|
|
|
[ |
|
|
|
'session' => SessionInterface::class, |
|
|
|
'request' => RequestStack::class, |
|
|
|
'em' => EntityManagerInterface::class, |
|
|
|
'translator_admin' => TranslatorAdmin::class, |
|
|
|
'filter_manager' => FilterManager::class, |
|
|
|
] |
|
|
|
); |
|
|
|
} |
|
|
|
|
|
|
@@ -113,9 +113,9 @@ abstract class AbstractAdminController extends EaAbstractCrudController |
|
|
|
if ($entity !== null) { |
|
|
|
if ($entity->getParent() !== null) { |
|
|
|
$url = $adminUrlGenerator |
|
|
|
->setController($context->getCrud()->getControllerFqcn()) |
|
|
|
->set('entityId', $entity->getParent()->getId()) |
|
|
|
->generateUrl(); |
|
|
|
->setController($context->getCrud()->getControllerFqcn()) |
|
|
|
->set('entityId', $entity->getParent()->getId()) |
|
|
|
->generateUrl(); |
|
|
|
$action->setLinkUrl($url); |
|
|
|
} |
|
|
|
} else { |
|
|
@@ -127,10 +127,10 @@ abstract class AbstractAdminController extends EaAbstractCrudController |
|
|
|
$entityId = $context->getRequest()->get('entityId'); |
|
|
|
if ($entityId != null) { |
|
|
|
$url = $adminUrlGenerator |
|
|
|
->setController($context->getCrud()->getControllerFqcn()) |
|
|
|
->setAction($action->getName()) |
|
|
|
->set('entityId', $entityId) |
|
|
|
->generateUrl(); |
|
|
|
->setController($context->getCrud()->getControllerFqcn()) |
|
|
|
->setAction($action->getName()) |
|
|
|
->set('entityId', $entityId) |
|
|
|
->generateUrl(); |
|
|
|
$action->setLinkUrl($url); |
|
|
|
} |
|
|
|
} |
|
|
@@ -155,14 +155,14 @@ abstract class AbstractAdminController extends EaAbstractCrudController |
|
|
|
{ |
|
|
|
$entityClass = $this->getEntityFqcn(); |
|
|
|
$paramListMaxResults = 'listMaxResults'; |
|
|
|
$paramSessionListMaxResults = $entityClass.'-'.$paramListMaxResults; |
|
|
|
$paramSessionListMaxResults = $entityClass . '-' . $paramListMaxResults; |
|
|
|
$requestListMaxResults = $this->get('request')->getCurrentRequest()->get($paramListMaxResults); |
|
|
|
|
|
|
|
if ($requestListMaxResults) { |
|
|
|
$this->get('session')->set($paramSessionListMaxResults, $requestListMaxResults); |
|
|
|
} |
|
|
|
$maxResults = $this->get('session')->get($paramSessionListMaxResults) ? $this->get('session')->get( |
|
|
|
$paramSessionListMaxResults |
|
|
|
$paramSessionListMaxResults |
|
|
|
) : 30; |
|
|
|
|
|
|
|
$crud->setPaginatorPageSize($maxResults); |
|
|
@@ -172,17 +172,17 @@ abstract class AbstractAdminController extends EaAbstractCrudController |
|
|
|
{ |
|
|
|
if ($this->isInstanceOf(SeoInterface::class)) { |
|
|
|
return [ |
|
|
|
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' |
|
|
|
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(), |
|
|
|
CollectionField::new('oldUrls') |
|
|
|
->setFormTypeOption('entry_type', TextType::class)->setLabel( |
|
|
|
'Anciennes urls du document' |
|
|
|
)->hideOnIndex(), |
|
|
|
]; |
|
|
|
} else { |
|
|
|
return null; |
|
|
@@ -193,13 +193,12 @@ abstract class AbstractAdminController extends EaAbstractCrudController |
|
|
|
{ |
|
|
|
if ($this->isInstanceOf(DevAliasInterface::class)) { |
|
|
|
return [ |
|
|
|
FormField::addPanel('configuration')->setTemplateName('crud/field/generic'), |
|
|
|
TextField::new('devAlias')->hideOnIndex(), |
|
|
|
FormField::addPanel('configuration')->setTemplateName('crud/field/generic'), |
|
|
|
TextField::new('devAlias')->hideOnIndex(), |
|
|
|
]; |
|
|
|
}else{ |
|
|
|
} else { |
|
|
|
return null; |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
public function sort(AdminContext $context) |
|
|
@@ -217,9 +216,9 @@ abstract class AbstractAdminController extends EaAbstractCrudController |
|
|
|
|
|
|
|
$fields = FieldCollection::new($this->configureFields(Crud::PAGE_INDEX)); |
|
|
|
$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); |
|
|
|
$paginator = $this->get(PaginatorFactory::class)->create($queryBuilder); |
|
|
@@ -228,16 +227,16 @@ abstract class AbstractAdminController extends EaAbstractCrudController |
|
|
|
$this->get(EntityFactory::class)->processFieldsForAll($entities, $fields); |
|
|
|
|
|
|
|
$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()); |
|
|
|
$repository = $entityManager->getRepository($this->getEntityFqcn()); |
|
|
@@ -264,26 +263,26 @@ abstract class AbstractAdminController extends EaAbstractCrudController |
|
|
|
} |
|
|
|
|
|
|
|
$url = $this->get(AdminUrlGenerator::class) |
|
|
|
->setAction(Action::INDEX) |
|
|
|
->generateUrl(); |
|
|
|
->setAction(Action::INDEX) |
|
|
|
->generateUrl(); |
|
|
|
$this->addFlash('success', $this->translatorAdmin->transFlashMessage('sort'), array()); |
|
|
|
|
|
|
|
return $this->redirect($url); |
|
|
|
} |
|
|
|
|
|
|
|
$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')); |
|
|
|
$event = new AfterCrudActionEvent($context, $responseParameters); |
|
|
@@ -296,16 +295,16 @@ abstract class AbstractAdminController extends EaAbstractCrudController |
|
|
|
} |
|
|
|
|
|
|
|
public function createIndexQueryBuilder( |
|
|
|
SearchDto $searchDto, |
|
|
|
EntityDto $entityDto, |
|
|
|
FieldCollection $fields, |
|
|
|
FilterCollection $filters |
|
|
|
SearchDto $searchDto, |
|
|
|
EntityDto $entityDto, |
|
|
|
FieldCollection $fields, |
|
|
|
FilterCollection $filters |
|
|
|
): QueryBuilder { |
|
|
|
$queryBuilder = parent::createIndexQueryBuilder( |
|
|
|
$searchDto, |
|
|
|
$entityDto, |
|
|
|
$fields, |
|
|
|
$filters |
|
|
|
$searchDto, |
|
|
|
$entityDto, |
|
|
|
$fields, |
|
|
|
$filters |
|
|
|
); |
|
|
|
|
|
|
|
//TOdo utiliser les repositoryQuery ? |
|
|
@@ -320,14 +319,14 @@ abstract class AbstractAdminController extends EaAbstractCrudController |
|
|
|
} |
|
|
|
|
|
|
|
$this->filtersForm = $this->createForm( |
|
|
|
FiltersFormType::class, |
|
|
|
null, |
|
|
|
array( |
|
|
|
'fields' => $fields, |
|
|
|
'entity_dto' => $entityDto, |
|
|
|
'entity_class' => $this->getEntityFqcn(), |
|
|
|
'entity_name' => $entityDto->getName(), |
|
|
|
) |
|
|
|
FiltersFormType::class, |
|
|
|
null, |
|
|
|
array( |
|
|
|
'fields' => $fields, |
|
|
|
'entity_dto' => $entityDto, |
|
|
|
'entity_class' => $this->getEntityFqcn(), |
|
|
|
'entity_name' => $entityDto->getName(), |
|
|
|
) |
|
|
|
); |
|
|
|
|
|
|
|
$filterManager = $this->get('filter_manager'); |
|
|
@@ -343,10 +342,10 @@ abstract class AbstractAdminController extends EaAbstractCrudController |
|
|
|
} |
|
|
|
|
|
|
|
public function createSortQueryBuilder( |
|
|
|
SearchDto $searchDto, |
|
|
|
EntityDto $entityDto, |
|
|
|
FieldCollection $fields, |
|
|
|
FilterCollection $filters |
|
|
|
SearchDto $searchDto, |
|
|
|
EntityDto $entityDto, |
|
|
|
FieldCollection $fields, |
|
|
|
FilterCollection $filters |
|
|
|
): QueryBuilder { |
|
|
|
$queryBuilder = $this->createIndexQueryBuilder($searchDto, $entityDto, $fields, $filters); |
|
|
|
|
|
|
@@ -375,7 +374,7 @@ abstract class AbstractAdminController extends EaAbstractCrudController |
|
|
|
$context = $this->get(AdminContextProvider::class)->getContext(); |
|
|
|
|
|
|
|
return $context->getCrudControllers()->findCrudFqcnByEntityFqcn( |
|
|
|
$this->get('em')->getEntityName($interface) |
|
|
|
$this->get('em')->getEntityName($interface) |
|
|
|
); |
|
|
|
} |
|
|
|
|
|
|
@@ -411,66 +410,66 @@ abstract class AbstractAdminController extends EaAbstractCrudController |
|
|
|
public function buildIndexActions(Actions $actions): void |
|
|
|
{ |
|
|
|
$this->actionUpdate( |
|
|
|
$actions, |
|
|
|
Crud::PAGE_INDEX, |
|
|
|
Action::NEW, |
|
|
|
[ |
|
|
|
'icon' => 'plus', |
|
|
|
'label' => $this->get('translator_admin')->transAction('create'), |
|
|
|
'add_class' => 'btn-sm', |
|
|
|
] |
|
|
|
$actions, |
|
|
|
Crud::PAGE_INDEX, |
|
|
|
Action::NEW, |
|
|
|
[ |
|
|
|
'icon' => 'plus', |
|
|
|
'label' => $this->get('translator_admin')->transAction('create'), |
|
|
|
'add_class' => 'btn-sm', |
|
|
|
] |
|
|
|
); |
|
|
|
|
|
|
|
$this->actionUpdate( |
|
|
|
$actions, |
|
|
|
Crud::PAGE_INDEX, |
|
|
|
Action::EDIT, |
|
|
|
[ |
|
|
|
'class' => 'btn btn-sm btn-primary', |
|
|
|
'icon' => 'edit', |
|
|
|
'label' => false, |
|
|
|
'html_attributes' => array( |
|
|
|
'data-toggle' => 'tooltip', |
|
|
|
'title' => $this->get('translator_admin')->transAction('edit'), |
|
|
|
), |
|
|
|
] |
|
|
|
$actions, |
|
|
|
Crud::PAGE_INDEX, |
|
|
|
Action::EDIT, |
|
|
|
[ |
|
|
|
'class' => 'btn btn-sm btn-primary', |
|
|
|
'icon' => 'edit', |
|
|
|
'label' => false, |
|
|
|
'html_attributes' => array( |
|
|
|
'data-toggle' => 'tooltip', |
|
|
|
'title' => $this->get('translator_admin')->transAction('edit'), |
|
|
|
), |
|
|
|
] |
|
|
|
); |
|
|
|
|
|
|
|
$this->actionUpdate( |
|
|
|
$actions, |
|
|
|
Crud::PAGE_INDEX, |
|
|
|
Action::DETAIL, |
|
|
|
[ |
|
|
|
'icon' => 'eye', |
|
|
|
'add_class' => 'btn btn-sm btn-success', |
|
|
|
'label' => false, |
|
|
|
'html_attributes' => array( |
|
|
|
'data-toggle' => 'tooltip', |
|
|
|
'title' => $this->get('translator_admin')->transAction('detail'), |
|
|
|
), |
|
|
|
] |
|
|
|
$actions, |
|
|
|
Crud::PAGE_INDEX, |
|
|
|
Action::DETAIL, |
|
|
|
[ |
|
|
|
'icon' => 'eye', |
|
|
|
'add_class' => 'btn btn-sm btn-success', |
|
|
|
'label' => false, |
|
|
|
'html_attributes' => array( |
|
|
|
'data-toggle' => 'tooltip', |
|
|
|
'title' => $this->get('translator_admin')->transAction('detail'), |
|
|
|
), |
|
|
|
] |
|
|
|
); |
|
|
|
|
|
|
|
$this->actionUpdate( |
|
|
|
$actions, |
|
|
|
Crud::PAGE_INDEX, |
|
|
|
Action::DELETE, |
|
|
|
[ |
|
|
|
'icon' => 'trash', |
|
|
|
'dropdown' => true, |
|
|
|
'label' => $this->get('translator_admin')->transAction('delete'), |
|
|
|
] |
|
|
|
$actions, |
|
|
|
Crud::PAGE_INDEX, |
|
|
|
Action::DELETE, |
|
|
|
[ |
|
|
|
'icon' => 'trash', |
|
|
|
'dropdown' => true, |
|
|
|
'label' => $this->get('translator_admin')->transAction('delete'), |
|
|
|
] |
|
|
|
); |
|
|
|
|
|
|
|
$this->actionUpdate( |
|
|
|
$actions, |
|
|
|
Crud::PAGE_INDEX, |
|
|
|
Action::BATCH_DELETE, |
|
|
|
[ |
|
|
|
'class' => 'btn btn-sm btn-danger', |
|
|
|
'icon' => 'trash', |
|
|
|
'label' => $this->get('translator_admin')->transAction('delete'), |
|
|
|
] |
|
|
|
$actions, |
|
|
|
Crud::PAGE_INDEX, |
|
|
|
Action::BATCH_DELETE, |
|
|
|
[ |
|
|
|
'class' => 'btn btn-sm btn-danger', |
|
|
|
'icon' => 'trash', |
|
|
|
'label' => $this->get('translator_admin')->transAction('delete'), |
|
|
|
] |
|
|
|
); |
|
|
|
} |
|
|
|
|
|
|
@@ -482,47 +481,47 @@ abstract class AbstractAdminController extends EaAbstractCrudController |
|
|
|
|
|
|
|
|
|
|
|
$this->actionUpdate( |
|
|
|
$actions, |
|
|
|
Crud::PAGE_EDIT, |
|
|
|
Action::SAVE_AND_RETURN, |
|
|
|
[ |
|
|
|
'add_class' => 'float-right', |
|
|
|
'icon' => 'check', |
|
|
|
'label' => $this->get('translator_admin')->transAction('save_and_return'), |
|
|
|
] |
|
|
|
$actions, |
|
|
|
Crud::PAGE_EDIT, |
|
|
|
Action::SAVE_AND_RETURN, |
|
|
|
[ |
|
|
|
'add_class' => 'float-right', |
|
|
|
'icon' => 'check', |
|
|
|
'label' => $this->get('translator_admin')->transAction('save_and_return'), |
|
|
|
] |
|
|
|
); |
|
|
|
|
|
|
|
$this->actionUpdate( |
|
|
|
$actions, |
|
|
|
Crud::PAGE_EDIT, |
|
|
|
Action::INDEX, |
|
|
|
[ |
|
|
|
'icon' => 'chevron-left', |
|
|
|
'class' => 'btn btn-link', |
|
|
|
'label' => $this->get('translator_admin')->transAction('back_index'), |
|
|
|
] |
|
|
|
$actions, |
|
|
|
Crud::PAGE_EDIT, |
|
|
|
Action::INDEX, |
|
|
|
[ |
|
|
|
'icon' => 'chevron-left', |
|
|
|
'class' => 'btn btn-link', |
|
|
|
'label' => $this->get('translator_admin')->transAction('back_index'), |
|
|
|
] |
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
$this->actionUpdate( |
|
|
|
$actions, |
|
|
|
Crud::PAGE_EDIT, |
|
|
|
Action::SAVE_AND_CONTINUE, |
|
|
|
[ |
|
|
|
'class' => 'btn btn-info float-right', |
|
|
|
'label' => $this->get('translator_admin')->transAction('save_and_continue'), |
|
|
|
] |
|
|
|
$actions, |
|
|
|
Crud::PAGE_EDIT, |
|
|
|
Action::SAVE_AND_CONTINUE, |
|
|
|
[ |
|
|
|
'class' => 'btn btn-info float-right', |
|
|
|
'label' => $this->get('translator_admin')->transAction('save_and_continue'), |
|
|
|
] |
|
|
|
); |
|
|
|
|
|
|
|
$this->actionUpdate( |
|
|
|
$actions, |
|
|
|
Crud::PAGE_EDIT, |
|
|
|
Action::DELETE, |
|
|
|
[ |
|
|
|
'icon' => 'trash', |
|
|
|
'class' => 'btn btn-outline-danger action-delete', |
|
|
|
'label' => $this->get('translator_admin')->transAction('delete'), |
|
|
|
] |
|
|
|
$actions, |
|
|
|
Crud::PAGE_EDIT, |
|
|
|
Action::DELETE, |
|
|
|
[ |
|
|
|
'icon' => 'trash', |
|
|
|
'class' => 'btn btn-outline-danger action-delete', |
|
|
|
'label' => $this->get('translator_admin')->transAction('delete'), |
|
|
|
] |
|
|
|
); |
|
|
|
} |
|
|
|
|
|
|
@@ -535,35 +534,35 @@ abstract class AbstractAdminController extends EaAbstractCrudController |
|
|
|
$actions->add(Crud::PAGE_NEW, Action::INDEX); |
|
|
|
|
|
|
|
$this->actionUpdate( |
|
|
|
$actions, |
|
|
|
Crud::PAGE_EDIT, |
|
|
|
Action::SAVE_AND_RETURN, |
|
|
|
[ |
|
|
|
'add_class' => 'float-right', |
|
|
|
'icon' => 'check', |
|
|
|
'label' => $this->get('translator_admin')->transAction('save_and_return'), |
|
|
|
] |
|
|
|
$actions, |
|
|
|
Crud::PAGE_EDIT, |
|
|
|
Action::SAVE_AND_RETURN, |
|
|
|
[ |
|
|
|
'add_class' => 'float-right', |
|
|
|
'icon' => 'check', |
|
|
|
'label' => $this->get('translator_admin')->transAction('save_and_return'), |
|
|
|
] |
|
|
|
); |
|
|
|
|
|
|
|
$this->actionUpdate( |
|
|
|
$actions, |
|
|
|
Crud::PAGE_EDIT, |
|
|
|
Action::INDEX, |
|
|
|
[ |
|
|
|
'icon' => 'chevron-left', |
|
|
|
'class' => 'btn btn-link', |
|
|
|
'label' => $this->get('translator_admin')->transAction('back_index'), |
|
|
|
] |
|
|
|
$actions, |
|
|
|
Crud::PAGE_EDIT, |
|
|
|
Action::INDEX, |
|
|
|
[ |
|
|
|
'icon' => 'chevron-left', |
|
|
|
'class' => 'btn btn-link', |
|
|
|
'label' => $this->get('translator_admin')->transAction('back_index'), |
|
|
|
] |
|
|
|
); |
|
|
|
|
|
|
|
$this->actionUpdate( |
|
|
|
$actions, |
|
|
|
Crud::PAGE_EDIT, |
|
|
|
Action::SAVE_AND_ADD_ANOTHER, |
|
|
|
[ |
|
|
|
'class' => 'btn btn-info float-right', |
|
|
|
'label' => $this->get('translator_admin')->transAction('save_and_add_another'), |
|
|
|
] |
|
|
|
$actions, |
|
|
|
Crud::PAGE_EDIT, |
|
|
|
Action::SAVE_AND_ADD_ANOTHER, |
|
|
|
[ |
|
|
|
'class' => 'btn btn-info float-right', |
|
|
|
'label' => $this->get('translator_admin')->transAction('save_and_add_another'), |
|
|
|
] |
|
|
|
); |
|
|
|
} |
|
|
|
|
|
|
@@ -571,13 +570,13 @@ abstract class AbstractAdminController extends EaAbstractCrudController |
|
|
|
{ |
|
|
|
if ($this->isInstanceOf(TranslatableInterface::class)) { |
|
|
|
$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; |
|
|
|
} |
|
|
|
); |
|
|
|
} |
|
|
|
} |
|
|
@@ -586,9 +585,9 @@ abstract class AbstractAdminController extends EaAbstractCrudController |
|
|
|
{ |
|
|
|
if ($this->isInstanceOf(SortableInterface::class)) { |
|
|
|
$sortAction = Action::new('sort', $this->get('translator_admin')->transAction('sort'), 'fa fa-sort') |
|
|
|
->linkToCrudAction('sort') |
|
|
|
->setCssClass('btn btn-sm btn-success') |
|
|
|
->createAsGlobalAction(); |
|
|
|
->linkToCrudAction('sort') |
|
|
|
->setCssClass('btn btn-sm btn-success') |
|
|
|
->createAsGlobalAction(); |
|
|
|
|
|
|
|
$actions->add(Crud::PAGE_INDEX, $sortAction); |
|
|
|
} |
|
|
@@ -599,24 +598,24 @@ abstract class AbstractAdminController extends EaAbstractCrudController |
|
|
|
{ |
|
|
|
if ($this->isInstanceOf(TreeInterface::class)) { |
|
|
|
$indexChildAction = Action::new( |
|
|
|
'index_children', |
|
|
|
$this->get('translator_admin')->transAction('index_children'), |
|
|
|
'fa fa-list' |
|
|
|
'index_children', |
|
|
|
$this->get('translator_admin')->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'); |
|
|
|
->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->get('translator_admin')->transAction('index_parent'), |
|
|
|
'fa fa-chevron-left' |
|
|
|
'index_parent', |
|
|
|
$this->get('translator_admin')->transAction('index_parent'), |
|
|
|
'fa fa-chevron-left' |
|
|
|
) |
|
|
|
->linkToCrudAction(Action::INDEX) |
|
|
|
->setCssClass('btn btn-sm btn-info') |
|
|
|
->createAsGlobalAction(); |
|
|
|
->linkToCrudAction(Action::INDEX) |
|
|
|
->setCssClass('btn btn-sm btn-info') |
|
|
|
->createAsGlobalAction(); |
|
|
|
|
|
|
|
$actions->add(Crud::PAGE_INDEX, $backParentAction); |
|
|
|
$actions->add(Crud::PAGE_INDEX, $indexChildAction); |
|
|
@@ -627,35 +626,35 @@ abstract class AbstractAdminController extends EaAbstractCrudController |
|
|
|
{ |
|
|
|
if ($actions->getAsDto('actions')->getAction($crudActionName, $actionName)) { |
|
|
|
$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']); |
|
|
|
} |
|
|
|
$crudActionName, |
|
|
|
$actionName, |
|
|
|
function (Action $action) use ($button) { |
|
|
|
if (isset($button['add_class'])) { |
|
|
|
$action->addCssClass($button['add_class']); |
|
|
|
} |
|
|
|
|
|
|
|
if (isset($button['icon'])) { |
|
|
|
$action->setIcon('fa fa-'.$button['icon']); |
|
|
|
} |
|
|
|
if (isset($button['class'])) { |
|
|
|
$action->setCssClass($button['class']); |
|
|
|
} |
|
|
|
|
|
|
|
if (isset($button['label'])) { |
|
|
|
$action->setLabel($button['label']); |
|
|
|
} |
|
|
|
if (isset($button['icon'])) { |
|
|
|
$action->setIcon('fa fa-' . $button['icon']); |
|
|
|
} |
|
|
|
|
|
|
|
if (isset($button['dropdown']) && $button['dropdown']) { |
|
|
|
$action->addCssClass('in-dropdown'); |
|
|
|
} |
|
|
|
if (isset($button['label'])) { |
|
|
|
$action->setLabel($button['label']); |
|
|
|
} |
|
|
|
|
|
|
|
if (isset($button['html_attributes']) && $button['html_attributes']) { |
|
|
|
$action->setHtmlAttributes($button['html_attributes']); |
|
|
|
} |
|
|
|
if (isset($button['dropdown']) && $button['dropdown']) { |
|
|
|
$action->addCssClass('in-dropdown'); |
|
|
|
} |
|
|
|
|
|
|
|
return $action; |
|
|
|
if (isset($button['html_attributes']) && $button['html_attributes']) { |
|
|
|
$action->setHtmlAttributes($button['html_attributes']); |
|
|
|
} |
|
|
|
|
|
|
|
return $action; |
|
|
|
} |
|
|
|
); |
|
|
|
} |
|
|
|
} |
|
|
@@ -663,22 +662,22 @@ abstract class AbstractAdminController extends EaAbstractCrudController |
|
|
|
public function autocompleteFilter(AdminContext $context): JsonResponse |
|
|
|
{ |
|
|
|
$queryBuilder = $this->createIndexQueryBuilder( |
|
|
|
$context->getSearch(), |
|
|
|
$context->getEntity(), |
|
|
|
FieldCollection::new([]), |
|
|
|
FilterCollection::new() |
|
|
|
$context->getSearch(), |
|
|
|
$context->getEntity(), |
|
|
|
FieldCollection::new([]), |
|
|
|
FilterCollection::new() |
|
|
|
); |
|
|
|
$autocompleteContext = $context->getRequest()->get(AssociationField::PARAM_AUTOCOMPLETE_CONTEXT); |
|
|
|
|
|
|
|
/** @var CrudControllerInterface $controller */ |
|
|
|
$controller = $this->get(ControllerFactory::class)->getCrudControllerInstance( |
|
|
|
$autocompleteContext[EA::CRUD_CONTROLLER_FQCN], |
|
|
|
Action::INDEX, |
|
|
|
$context->getRequest() |
|
|
|
$autocompleteContext[EA::CRUD_CONTROLLER_FQCN], |
|
|
|
Action::INDEX, |
|
|
|
$context->getRequest() |
|
|
|
); |
|
|
|
/** @var FieldDto $field */ |
|
|
|
$field = FieldCollection::new( |
|
|
|
$controller->configureFields($autocompleteContext['originatingPage']) |
|
|
|
$controller->configureFields($autocompleteContext['originatingPage']) |
|
|
|
)->getByProperty($autocompleteContext['propertyName']); |
|
|
|
|
|
|
|
$filterManager = $this->get('filter_manager'); |
|
|
@@ -687,7 +686,7 @@ abstract class AbstractAdminController extends EaAbstractCrudController |
|
|
|
if ($filterManager->isRelationField($field->getProperty())) { |
|
|
|
$queryBuilder->select($autocompleteContext['propertyName']); |
|
|
|
} else { |
|
|
|
$queryBuilder->select('entity.'.$autocompleteContext['propertyName']); |
|
|
|
$queryBuilder->select('entity.' . $autocompleteContext['propertyName']); |
|
|
|
} |
|
|
|
|
|
|
|
$responses = array(); |