Browse Source

Correctif sort & groupBy repo

develop
Fab 3 years ago
parent
commit
07ba123d9e
5 changed files with 27 additions and 12 deletions
  1. +7
    -3
      Controller/AbstractAdminController.php
  2. +17
    -4
      Repository/AbstractRepositoryQuery.php
  3. +0
    -2
      Repository/RepositoryQueryInterface.php
  4. +2
    -2
      Resources/views/adminlte/crud/index.html.twig
  5. +1
    -1
      Resources/views/adminlte/crud/sort.html.twig

+ 7
- 3
Controller/AbstractAdminController.php View File



public function configureResponseParameters(KeyValueStore $responseParameters): KeyValueStore public function configureResponseParameters(KeyValueStore $responseParameters): KeyValueStore
{ {
$this->overrideGlobalActions($responseParameters->get('global_actions'));
$this->overrideEntitiesActions($responseParameters->get('entities'));
if($responseParameters->get('global_actions')){
$this->overrideGlobalActions($responseParameters->get('global_actions'));
}
if($responseParameters->get('entities')){
$this->overrideEntitiesActions($responseParameters->get('entities'));
}
if (Crud::PAGE_INDEX === $responseParameters->get('pageName')) { if (Crud::PAGE_INDEX === $responseParameters->get('pageName')) {
$responseParameters->set('fields', $this->configureFields('index')); $responseParameters->set('fields', $this->configureFields('index'));


$url = $this->get(AdminUrlGenerator::class) $url = $this->get(AdminUrlGenerator::class)
->setAction(Action::INDEX) ->setAction(Action::INDEX)
->generateUrl(); ->generateUrl();
$this->addFlash('success', $this->translatorAdmin->transFlashMessage('sort'), array());
$this->addFlash('success', $this->get(TranslatorAdmin::class)->transFlashMessage('sort'), array());


return $this->redirect($url); return $this->redirect($url);
} }

+ 17
- 4
Repository/AbstractRepositoryQuery.php View File



public function groupBy(string $field): self public function groupBy(string $field): self
{ {
if (substr($field, 0, 1) === '.') {
return $this->groupBy($field) ;
if (strpos($field, '.')!==false) {
$this->addGroupBy($field) ;

} else { } else {
return $this->groupBy('.'.$field) ;
$this->addGroupBy('.'.$field) ;
} }
return $this;
} }
/*
public function addGroupBy(string $field): self
{
if (strpos($field, '.')!==false) {
$this->query->addGroupBy($field) ;

} else {
$this->query->addGroupBy('.'.$field) ;
}
return $this;
}*/


public function orderBy(string $field, string $sort = 'ASC'): self public function orderBy(string $field, string $sort = 'ASC'): self
{ {
if (substr($field, 0, 1) === '.') {
if (strpos($field, '.')!==false) {
return $this->addOrderBy($field, $sort); return $this->addOrderBy($field, $sort);
} else { } else {
return $this->addOrderBy('.' . $field, $sort); return $this->addOrderBy('.' . $field, $sort);

+ 0
- 2
Repository/RepositoryQueryInterface.php View File



public function getRepository(): ServiceEntityRepository; public function getRepository(): ServiceEntityRepository;


public function groupBy(string $field):self;

public function orderBy(string $field, string $sort = 'ASC'):self; public function orderBy(string $field, string $sort = 'ASC'):self;


public function filterById(int $id):self; public function filterById(int $id):self;

+ 2
- 2
Resources/views/adminlte/crud/index.html.twig View File

dir="{{ ea.i18n.textDirection }}"> dir="{{ ea.i18n.textDirection }}">
{% if field.isSortable %} {% if field.isSortable %}
<a href="{{ ea_url({ page: 1, sort: { (field.property): next_sort_direction } }).includeReferrer() }}"> <a href="{{ ea_url({ page: 1, sort: { (field.property): next_sort_direction } }).includeReferrer() }}">
{{ field.label ? field.label|raw : field.getProperty|raw }} <i
class="fa fa-fw {{ column_icon }}"></i>
{{ field.getProperty|sov_trans_admin_field(ea.getEntity().getFqcn()) }}
<i class="fa fa-fw {{ column_icon }}"></i>
</a> </a>
{% else %} {% else %}
<span>{{ field.getProperty|sov_trans_admin_field(ea.getEntity().getFqcn()) }}</span> <span>{{ field.getProperty|sov_trans_admin_field(ea.getEntity().getFqcn()) }}</span>

+ 1
- 1
Resources/views/adminlte/crud/sort.html.twig View File



<div class="table-responsive"> <div class="table-responsive">
<table class="table table-bordered table-hover table-striped sov-sortable" <table class="table table-bordered table-hover table-striped sov-sortable"
data-parent-position="{{ entity is defined and entity is not null ? entity.position : '' }}">
data-parent-position="{{ ea.entity is defined and ea.entity.instance is not null ? ea.entity.instance.position : '' }}">
<thead> <thead>
{% block table_head %} {% block table_head %}
<tr> <tr>

Loading…
Cancel
Save