|
|
@@ -116,9 +116,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 { |
|
|
@@ -130,10 +130,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); |
|
|
|
} |
|
|
|
} |
|
|
@@ -151,8 +151,7 @@ abstract class AbstractAdminController extends EaAbstractCrudController |
|
|
|
|
|
|
|
if ($this->isInstanceOf(SortableInterface::class)) { |
|
|
|
$crud->setDefaultSort(['position' => 'ASC']); |
|
|
|
} |
|
|
|
else { |
|
|
|
} else { |
|
|
|
$crud->setDefaultSort(['id' => 'DESC']); |
|
|
|
} |
|
|
|
|
|
|
@@ -170,7 +169,7 @@ abstract class AbstractAdminController extends EaAbstractCrudController |
|
|
|
$this->get('session')->set($paramSessionListMaxResults, $requestListMaxResults); |
|
|
|
} |
|
|
|
$maxResults = $this->get('session')->get($paramSessionListMaxResults) ? $this->get('session')->get( |
|
|
|
$paramSessionListMaxResults |
|
|
|
$paramSessionListMaxResults |
|
|
|
) : 30; |
|
|
|
|
|
|
|
$crud->setPaginatorPageSize($maxResults); |
|
|
@@ -180,17 +179,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; |
|
|
@@ -201,8 +200,8 @@ 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 { |
|
|
|
return null; |
|
|
@@ -224,9 +223,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); |
|
|
@@ -235,16 +234,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()); |
|
|
@@ -271,26 +270,26 @@ abstract class AbstractAdminController extends EaAbstractCrudController |
|
|
|
} |
|
|
|
|
|
|
|
$url = $this->get(AdminUrlGenerator::class) |
|
|
|
->setAction(ActionDefinition::INDEX) |
|
|
|
->generateUrl(); |
|
|
|
->setAction(ActionDefinition::INDEX) |
|
|
|
->generateUrl(); |
|
|
|
$this->addFlashTranslator('success', 'sorted'); |
|
|
|
|
|
|
|
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); |
|
|
@@ -303,14 +302,14 @@ abstract class AbstractAdminController extends EaAbstractCrudController |
|
|
|
} |
|
|
|
|
|
|
|
public function duplicate( |
|
|
|
AdminContext $context, |
|
|
|
EntityComponent $entityComponent, |
|
|
|
TranslatorAdmin $translatorAdmin, |
|
|
|
EntityManagerInterface $em |
|
|
|
AdminContext $context, |
|
|
|
EntityComponent $entityComponent, |
|
|
|
TranslatorAdmin $translatorAdmin, |
|
|
|
EntityManagerInterface $em |
|
|
|
) { |
|
|
|
if (!$this->isGranted( |
|
|
|
Permission::EA_EXECUTE_ACTION, |
|
|
|
['action' => "duplicate", 'entity' => $context->getEntity()] |
|
|
|
Permission::EA_EXECUTE_ACTION, |
|
|
|
['action' => "duplicate", 'entity' => $context->getEntity()] |
|
|
|
)) { |
|
|
|
throw new ForbiddenActionException($context); |
|
|
|
} |
|
|
@@ -324,9 +323,9 @@ abstract class AbstractAdminController extends EaAbstractCrudController |
|
|
|
$em->flush(); |
|
|
|
|
|
|
|
$url = $this->get(AdminUrlGenerator::class) |
|
|
|
->setAction(ActionDefinition::EDIT) |
|
|
|
->setEntityId($newEntity->getId()) |
|
|
|
->generateUrl(); |
|
|
|
->setAction(ActionDefinition::EDIT) |
|
|
|
->setEntityId($newEntity->getId()) |
|
|
|
->generateUrl(); |
|
|
|
|
|
|
|
$this->addFlashTranslator('success', 'duplicated'); |
|
|
|
|
|
|
@@ -338,9 +337,14 @@ abstract class AbstractAdminController extends EaAbstractCrudController |
|
|
|
EntityDto $entityDto, |
|
|
|
FieldCollection $fields, |
|
|
|
FilterCollection $filters |
|
|
|
): RepositoryQueryInterface |
|
|
|
{ |
|
|
|
$repositoryQuery = $this->get(EntityRepository::class)->createRepositoryQuery($this->getRepositoryQuery(), $searchDto, $entityDto, $fields, $filters); |
|
|
|
): RepositoryQueryInterface { |
|
|
|
$repositoryQuery = $this->get(EntityRepository::class)->createRepositoryQuery( |
|
|
|
$this->getRepositoryQuery(), |
|
|
|
$searchDto, |
|
|
|
$entityDto, |
|
|
|
$fields, |
|
|
|
$filters |
|
|
|
); |
|
|
|
|
|
|
|
// TODO : déplacer dans EntotyRepository |
|
|
|
if ($this->isInstanceOf(TreeInterface::class)) { |
|
|
@@ -370,22 +374,21 @@ abstract class AbstractAdminController extends EaAbstractCrudController |
|
|
|
return $repositoryQuery; |
|
|
|
} |
|
|
|
|
|
|
|
public function createIndexQueryBuilder( |
|
|
|
SearchDto $searchDto, |
|
|
|
EntityDto $entityDto, |
|
|
|
FieldCollection $fields, |
|
|
|
FilterCollection $filters |
|
|
|
): QueryBuilder { |
|
|
|
|
|
|
|
$repositoryQuery = $this->createIndexRepositoryQuery($searchDto, $entityDto, $fields, $filters); |
|
|
|
return $repositoryQuery->getQueryBuilder(); |
|
|
|
public function createIndexQueryBuilder( |
|
|
|
SearchDto $searchDto, |
|
|
|
EntityDto $entityDto, |
|
|
|
FieldCollection $fields, |
|
|
|
FilterCollection $filters |
|
|
|
): QueryBuilder { |
|
|
|
$repositoryQuery = $this->createIndexRepositoryQuery($searchDto, $entityDto, $fields, $filters); |
|
|
|
return $repositoryQuery->getQueryBuilder(); |
|
|
|
} |
|
|
|
|
|
|
|
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); |
|
|
|
|
|
|
@@ -409,7 +412,7 @@ abstract class AbstractAdminController extends EaAbstractCrudController |
|
|
|
$context = $this->get(AdminContextProvider::class)->getContext(); |
|
|
|
|
|
|
|
return $context->getCrudControllers()->findCrudFqcnByEntityFqcn( |
|
|
|
$this->get(EntityManagerInterface::class)->getEntityName($interface) |
|
|
|
$this->get(EntityManagerInterface::class)->getEntityName($interface) |
|
|
|
); |
|
|
|
} |
|
|
|
|
|
|
@@ -432,7 +435,6 @@ abstract class AbstractAdminController extends EaAbstractCrudController |
|
|
|
$entityManager->delete($entityInstance); |
|
|
|
$entityManager->flush(); |
|
|
|
$this->get(FlashBagTranslator::class)->add('success', 'deleted', $this->getTranslationEntityName()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
public function configureActions(Actions $actions): Actions |
|
|
@@ -454,13 +456,13 @@ abstract class AbstractAdminController extends EaAbstractCrudController |
|
|
|
public function getDuplicateAction(): Action |
|
|
|
{ |
|
|
|
$duplicateAction = Action::new( |
|
|
|
ActionDefinition::DUPLICATE, |
|
|
|
$this->get(TranslatorAdmin::class)->transAction(ActionDefinition::DUPLICATE), |
|
|
|
'fa fa-fw fa-copy' |
|
|
|
ActionDefinition::DUPLICATE, |
|
|
|
$this->get(TranslatorAdmin::class)->transAction(ActionDefinition::DUPLICATE), |
|
|
|
'fa fa-fw fa-copy' |
|
|
|
) |
|
|
|
->linkToCrudAction(ActionDefinition::DUPLICATE) |
|
|
|
->setLabel($this->get(TranslatorAdmin::class)->transAction(ActionDefinition::DUPLICATE)) |
|
|
|
->setCssClass('in-dropdown text-info action-confirm'); |
|
|
|
->linkToCrudAction(ActionDefinition::DUPLICATE) |
|
|
|
->setLabel($this->get(TranslatorAdmin::class)->transAction(ActionDefinition::DUPLICATE)) |
|
|
|
->setCssClass('in-dropdown text-info action-confirm'); |
|
|
|
|
|
|
|
return $duplicateAction; |
|
|
|
} |
|
|
@@ -470,67 +472,67 @@ abstract class AbstractAdminController extends EaAbstractCrudController |
|
|
|
$actions->add(Crud::PAGE_INDEX, $this->getDuplicateAction()); |
|
|
|
|
|
|
|
$this->actionUpdate( |
|
|
|
$actions, |
|
|
|
Crud::PAGE_INDEX, |
|
|
|
ActionDefinition::NEW, |
|
|
|
[ |
|
|
|
'icon' => 'plus', |
|
|
|
'label' => $this->get(TranslatorAdmin::class)->transAction('create'), |
|
|
|
'add_class' => 'btn-sm', |
|
|
|
] |
|
|
|
$actions, |
|
|
|
Crud::PAGE_INDEX, |
|
|
|
ActionDefinition::NEW, |
|
|
|
[ |
|
|
|
'icon' => 'plus', |
|
|
|
'label' => $this->get(TranslatorAdmin::class)->transAction('create'), |
|
|
|
'add_class' => 'btn-sm', |
|
|
|
] |
|
|
|
); |
|
|
|
|
|
|
|
$this->actionUpdate( |
|
|
|
$actions, |
|
|
|
Crud::PAGE_INDEX, |
|
|
|
ActionDefinition::EDIT, |
|
|
|
[ |
|
|
|
'class' => 'btn btn-sm btn-primary', |
|
|
|
'icon' => 'edit', |
|
|
|
'label' => false, |
|
|
|
'html_attributes' => array( |
|
|
|
'data-toggle' => 'tooltip', |
|
|
|
'title' => $this->get(TranslatorAdmin::class)->transAction('edit'), |
|
|
|
), |
|
|
|
] |
|
|
|
$actions, |
|
|
|
Crud::PAGE_INDEX, |
|
|
|
ActionDefinition::EDIT, |
|
|
|
[ |
|
|
|
'class' => 'btn btn-sm btn-primary', |
|
|
|
'icon' => 'edit', |
|
|
|
'label' => false, |
|
|
|
'html_attributes' => array( |
|
|
|
'data-toggle' => 'tooltip', |
|
|
|
'title' => $this->get(TranslatorAdmin::class)->transAction('edit'), |
|
|
|
), |
|
|
|
] |
|
|
|
); |
|
|
|
|
|
|
|
$this->actionUpdate( |
|
|
|
$actions, |
|
|
|
Crud::PAGE_INDEX, |
|
|
|
ActionDefinition::DETAIL, |
|
|
|
[ |
|
|
|
'icon' => 'eye', |
|
|
|
'add_class' => 'btn btn-sm btn-success', |
|
|
|
'label' => false, |
|
|
|
'html_attributes' => array( |
|
|
|
'data-toggle' => 'tooltip', |
|
|
|
'title' => $this->get(TranslatorAdmin::class)->transAction('detail'), |
|
|
|
), |
|
|
|
] |
|
|
|
$actions, |
|
|
|
Crud::PAGE_INDEX, |
|
|
|
ActionDefinition::DETAIL, |
|
|
|
[ |
|
|
|
'icon' => 'eye', |
|
|
|
'add_class' => 'btn btn-sm btn-success', |
|
|
|
'label' => false, |
|
|
|
'html_attributes' => array( |
|
|
|
'data-toggle' => 'tooltip', |
|
|
|
'title' => $this->get(TranslatorAdmin::class)->transAction('detail'), |
|
|
|
), |
|
|
|
] |
|
|
|
); |
|
|
|
|
|
|
|
$this->actionUpdate( |
|
|
|
$actions, |
|
|
|
Crud::PAGE_INDEX, |
|
|
|
ActionDefinition::DELETE, |
|
|
|
[ |
|
|
|
'icon' => 'trash', |
|
|
|
'dropdown' => true, |
|
|
|
'label' => $this->get(TranslatorAdmin::class)->transAction('delete'), |
|
|
|
'class' => 'dropdown-item text-danger in-dropdown action-delete', |
|
|
|
] |
|
|
|
$actions, |
|
|
|
Crud::PAGE_INDEX, |
|
|
|
ActionDefinition::DELETE, |
|
|
|
[ |
|
|
|
'icon' => 'trash', |
|
|
|
'dropdown' => true, |
|
|
|
'label' => $this->get(TranslatorAdmin::class)->transAction('delete'), |
|
|
|
'class' => 'dropdown-item text-danger in-dropdown action-delete', |
|
|
|
] |
|
|
|
); |
|
|
|
|
|
|
|
$this->actionUpdate( |
|
|
|
$actions, |
|
|
|
Crud::PAGE_INDEX, |
|
|
|
ActionDefinition::BATCH_DELETE, |
|
|
|
[ |
|
|
|
'class' => 'btn btn-sm btn-danger', |
|
|
|
'icon' => 'trash', |
|
|
|
'label' => $this->get(TranslatorAdmin::class)->transAction('delete'), |
|
|
|
] |
|
|
|
$actions, |
|
|
|
Crud::PAGE_INDEX, |
|
|
|
ActionDefinition::BATCH_DELETE, |
|
|
|
[ |
|
|
|
'class' => 'btn btn-sm btn-danger', |
|
|
|
'icon' => 'trash', |
|
|
|
'label' => $this->get(TranslatorAdmin::class)->transAction('delete'), |
|
|
|
] |
|
|
|
); |
|
|
|
} |
|
|
|
|
|
|
@@ -542,47 +544,47 @@ abstract class AbstractAdminController extends EaAbstractCrudController |
|
|
|
|
|
|
|
|
|
|
|
$this->actionUpdate( |
|
|
|
$actions, |
|
|
|
Crud::PAGE_EDIT, |
|
|
|
ActionDefinition::SAVE_AND_RETURN, |
|
|
|
[ |
|
|
|
'add_class' => 'float-right ', |
|
|
|
'icon' => 'check', |
|
|
|
'label' => $this->get(TranslatorAdmin::class)->transAction('save_and_return'), |
|
|
|
] |
|
|
|
$actions, |
|
|
|
Crud::PAGE_EDIT, |
|
|
|
ActionDefinition::SAVE_AND_RETURN, |
|
|
|
[ |
|
|
|
'add_class' => 'float-right ', |
|
|
|
'icon' => 'check', |
|
|
|
'label' => $this->get(TranslatorAdmin::class)->transAction('save_and_return'), |
|
|
|
] |
|
|
|
); |
|
|
|
|
|
|
|
$this->actionUpdate( |
|
|
|
$actions, |
|
|
|
Crud::PAGE_EDIT, |
|
|
|
ActionDefinition::INDEX, |
|
|
|
[ |
|
|
|
'icon' => 'chevron-left', |
|
|
|
'class' => 'btn btn-link', |
|
|
|
'label' => $this->get(TranslatorAdmin::class)->transAction('back_index'), |
|
|
|
] |
|
|
|
$actions, |
|
|
|
Crud::PAGE_EDIT, |
|
|
|
ActionDefinition::INDEX, |
|
|
|
[ |
|
|
|
'icon' => 'chevron-left', |
|
|
|
'class' => 'btn btn-link', |
|
|
|
'label' => $this->get(TranslatorAdmin::class)->transAction('back_index'), |
|
|
|
] |
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
$this->actionUpdate( |
|
|
|
$actions, |
|
|
|
Crud::PAGE_EDIT, |
|
|
|
ActionDefinition::SAVE_AND_CONTINUE, |
|
|
|
[ |
|
|
|
'class' => 'btn btn-info float-right action-save-continue', |
|
|
|
'label' => $this->get(TranslatorAdmin::class)->transAction('save_and_continue'), |
|
|
|
] |
|
|
|
$actions, |
|
|
|
Crud::PAGE_EDIT, |
|
|
|
ActionDefinition::SAVE_AND_CONTINUE, |
|
|
|
[ |
|
|
|
'class' => 'btn btn-info float-right action-save-continue', |
|
|
|
'label' => $this->get(TranslatorAdmin::class)->transAction('save_and_continue'), |
|
|
|
] |
|
|
|
); |
|
|
|
|
|
|
|
$this->actionUpdate( |
|
|
|
$actions, |
|
|
|
Crud::PAGE_EDIT, |
|
|
|
ActionDefinition::DELETE, |
|
|
|
[ |
|
|
|
'icon' => 'trash', |
|
|
|
'class' => 'btn btn-outline-danger action-delete', |
|
|
|
'label' => $this->get(TranslatorAdmin::class)->transAction('delete'), |
|
|
|
] |
|
|
|
$actions, |
|
|
|
Crud::PAGE_EDIT, |
|
|
|
ActionDefinition::DELETE, |
|
|
|
[ |
|
|
|
'icon' => 'trash', |
|
|
|
'class' => 'btn btn-outline-danger action-delete', |
|
|
|
'label' => $this->get(TranslatorAdmin::class)->transAction('delete'), |
|
|
|
] |
|
|
|
); |
|
|
|
} |
|
|
|
|
|
|
@@ -595,35 +597,35 @@ abstract class AbstractAdminController extends EaAbstractCrudController |
|
|
|
$actions->add(Crud::PAGE_NEW, ActionDefinition::INDEX); |
|
|
|
|
|
|
|
$this->actionUpdate( |
|
|
|
$actions, |
|
|
|
Crud::PAGE_EDIT, |
|
|
|
ActionDefinition::SAVE_AND_RETURN, |
|
|
|
[ |
|
|
|
'add_class' => 'float-right', |
|
|
|
'icon' => 'check', |
|
|
|
'label' => $this->get(TranslatorAdmin::class)->transAction('save_and_return'), |
|
|
|
] |
|
|
|
$actions, |
|
|
|
Crud::PAGE_EDIT, |
|
|
|
ActionDefinition::SAVE_AND_RETURN, |
|
|
|
[ |
|
|
|
'add_class' => 'float-right', |
|
|
|
'icon' => 'check', |
|
|
|
'label' => $this->get(TranslatorAdmin::class)->transAction('save_and_return'), |
|
|
|
] |
|
|
|
); |
|
|
|
|
|
|
|
$this->actionUpdate( |
|
|
|
$actions, |
|
|
|
Crud::PAGE_EDIT, |
|
|
|
ActionDefinition::INDEX, |
|
|
|
[ |
|
|
|
'icon' => 'chevron-left', |
|
|
|
'class' => 'btn btn-link', |
|
|
|
'label' => $this->get(TranslatorAdmin::class)->transAction('back_index'), |
|
|
|
] |
|
|
|
$actions, |
|
|
|
Crud::PAGE_EDIT, |
|
|
|
ActionDefinition::INDEX, |
|
|
|
[ |
|
|
|
'icon' => 'chevron-left', |
|
|
|
'class' => 'btn btn-link', |
|
|
|
'label' => $this->get(TranslatorAdmin::class)->transAction('back_index'), |
|
|
|
] |
|
|
|
); |
|
|
|
|
|
|
|
$this->actionUpdate( |
|
|
|
$actions, |
|
|
|
Crud::PAGE_EDIT, |
|
|
|
ActionDefinition::SAVE_AND_ADD_ANOTHER, |
|
|
|
[ |
|
|
|
'class' => 'btn btn-info float-right', |
|
|
|
'label' => $this->get(TranslatorAdmin::class)->transAction('save_and_add_another'), |
|
|
|
] |
|
|
|
$actions, |
|
|
|
Crud::PAGE_EDIT, |
|
|
|
ActionDefinition::SAVE_AND_ADD_ANOTHER, |
|
|
|
[ |
|
|
|
'class' => 'btn btn-info float-right', |
|
|
|
'label' => $this->get(TranslatorAdmin::class)->transAction('save_and_add_another'), |
|
|
|
] |
|
|
|
); |
|
|
|
} |
|
|
|
|
|
|
@@ -631,13 +633,13 @@ abstract class AbstractAdminController extends EaAbstractCrudController |
|
|
|
{ |
|
|
|
if ($this->isInstanceOf(TranslatableInterface::class)) { |
|
|
|
$actions->update( |
|
|
|
Crud::PAGE_INDEX, |
|
|
|
ActionDefinition::EDIT, |
|
|
|
function (Action $action) { |
|
|
|
$action->setTemplatePath('@LcSov/adminlte/crud/action/translatable.html.twig'); |
|
|
|
Crud::PAGE_INDEX, |
|
|
|
ActionDefinition::EDIT, |
|
|
|
function (Action $action) { |
|
|
|
$action->setTemplatePath('@LcSov/adminlte/crud/action/translatable.html.twig'); |
|
|
|
|
|
|
|
return $action; |
|
|
|
} |
|
|
|
return $action; |
|
|
|
} |
|
|
|
); |
|
|
|
} |
|
|
|
} |
|
|
@@ -645,10 +647,14 @@ abstract class AbstractAdminController extends EaAbstractCrudController |
|
|
|
public function handleSortableEntityActions(Actions $actions): void |
|
|
|
{ |
|
|
|
if ($this->isInstanceOf(SortableInterface::class)) { |
|
|
|
$sortAction = Action::new(ActionDefinition::SORT, $this->get(TranslatorAdmin::class)->transAction(ActionDefinition::SORT), 'fa fa-sort') |
|
|
|
->linkToCrudAction(ActionDefinition::SORT) |
|
|
|
->setCssClass('btn btn-sm btn-success') |
|
|
|
->createAsGlobalAction(); |
|
|
|
$sortAction = Action::new( |
|
|
|
ActionDefinition::SORT, |
|
|
|
$this->get(TranslatorAdmin::class)->transAction(ActionDefinition::SORT), |
|
|
|
'fa fa-sort' |
|
|
|
) |
|
|
|
->linkToCrudAction(ActionDefinition::SORT) |
|
|
|
->setCssClass('btn btn-sm btn-success') |
|
|
|
->createAsGlobalAction(); |
|
|
|
|
|
|
|
$actions->add(Crud::PAGE_INDEX, $sortAction); |
|
|
|
} |
|
|
@@ -659,24 +665,24 @@ abstract class AbstractAdminController extends EaAbstractCrudController |
|
|
|
{ |
|
|
|
if ($this->isInstanceOf(TreeInterface::class)) { |
|
|
|
$indexChildAction = Action::new( |
|
|
|
ActionDefinition::INDEX_CHILDREN, |
|
|
|
$this->get(TranslatorAdmin::class)->transAction(ActionDefinition::INDEX_CHILDREN), |
|
|
|
'fa fa-list' |
|
|
|
ActionDefinition::INDEX_CHILDREN, |
|
|
|
$this->get(TranslatorAdmin::class)->transAction(ActionDefinition::INDEX_CHILDREN), |
|
|
|
'fa fa-list' |
|
|
|
) |
|
|
|
->linkToCrudAction(ActionDefinition::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(ActionDefinition::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( |
|
|
|
ActionDefinition::INDEX_PARENT, |
|
|
|
$this->get(TranslatorAdmin::class)->transAction(ActionDefinition::INDEX_PARENT), |
|
|
|
'fa fa-chevron-left' |
|
|
|
ActionDefinition::INDEX_PARENT, |
|
|
|
$this->get(TranslatorAdmin::class)->transAction(ActionDefinition::INDEX_PARENT), |
|
|
|
'fa fa-chevron-left' |
|
|
|
) |
|
|
|
->linkToCrudAction(ActionDefinition::INDEX) |
|
|
|
->setCssClass('btn btn-sm btn-info') |
|
|
|
->createAsGlobalAction(); |
|
|
|
->linkToCrudAction(ActionDefinition::INDEX) |
|
|
|
->setCssClass('btn btn-sm btn-info') |
|
|
|
->createAsGlobalAction(); |
|
|
|
|
|
|
|
$actions->add(Crud::PAGE_INDEX, $backParentAction); |
|
|
|
$actions->add(Crud::PAGE_INDEX, $indexChildAction); |
|
|
@@ -687,35 +693,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; |
|
|
|
} |
|
|
|
); |
|
|
|
} |
|
|
|
} |
|
|
@@ -723,22 +729,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], |
|
|
|
ActionDefinition::INDEX, |
|
|
|
$context->getRequest() |
|
|
|
$autocompleteContext[EA::CRUD_CONTROLLER_FQCN], |
|
|
|
ActionDefinition::INDEX, |
|
|
|
$context->getRequest() |
|
|
|
); |
|
|
|
/** @var FieldDto $field */ |
|
|
|
$field = FieldCollection::new( |
|
|
|
$controller->configureFields($autocompleteContext['originatingPage']) |
|
|
|
$controller->configureFields($autocompleteContext['originatingPage']) |
|
|
|
)->getByProperty($autocompleteContext['propertyName']); |
|
|
|
|
|
|
|
$filterManager = $this->get(FilterManager::class); |
|
|
@@ -763,15 +769,15 @@ abstract class AbstractAdminController extends EaAbstractCrudController |
|
|
|
{ |
|
|
|
if ($dataInOption) { |
|
|
|
$data = $entity; |
|
|
|
}else{ |
|
|
|
} else { |
|
|
|
$data = null; |
|
|
|
} |
|
|
|
|
|
|
|
$options['action'] = $this->get(AdminUrlGenerator::class) |
|
|
|
->setAction($action) |
|
|
|
->setController($controller) |
|
|
|
->setEntityId($entity->getId()) |
|
|
|
->generateUrl(); |
|
|
|
->setAction($action) |
|
|
|
->setController($controller) |
|
|
|
->setEntityId($entity->getId()) |
|
|
|
->generateUrl(); |
|
|
|
|
|
|
|
return $this->createForm($class, $data, $options); |
|
|
|
} |