Przeglądaj źródła

Correctif sort & groupBy repo

develop
Fab 3 lat temu
rodzic
commit
07ba123d9e
5 zmienionych plików z 27 dodań i 12 usunięć
  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 Wyświetl plik

@@ -104,8 +104,12 @@ abstract class AbstractAdminController extends EaAbstractCrudController

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')) {
$responseParameters->set('fields', $this->configureFields('index'));

@@ -292,7 +296,7 @@ abstract class AbstractAdminController extends EaAbstractCrudController
$url = $this->get(AdminUrlGenerator::class)
->setAction(Action::INDEX)
->generateUrl();
$this->addFlash('success', $this->translatorAdmin->transFlashMessage('sort'), array());
$this->addFlash('success', $this->get(TranslatorAdmin::class)->transFlashMessage('sort'), array());

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

+ 17
- 4
Repository/AbstractRepositoryQuery.php Wyświetl plik

@@ -105,16 +105,29 @@ abstract class AbstractRepositoryQuery implements RepositoryQueryInterface

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

} 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
{
if (substr($field, 0, 1) === '.') {
if (strpos($field, '.')!==false) {
return $this->addOrderBy($field, $sort);
} else {
return $this->addOrderBy('.' . $field, $sort);

+ 0
- 2
Repository/RepositoryQueryInterface.php Wyświetl plik

@@ -23,8 +23,6 @@ interface RepositoryQueryInterface

public function getRepository(): ServiceEntityRepository;

public function groupBy(string $field):self;

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

public function filterById(int $id):self;

+ 2
- 2
Resources/views/adminlte/crud/index.html.twig Wyświetl plik

@@ -87,8 +87,8 @@
dir="{{ ea.i18n.textDirection }}">
{% if field.isSortable %}
<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>
{% else %}
<span>{{ field.getProperty|sov_trans_admin_field(ea.getEntity().getFqcn()) }}</span>

+ 1
- 1
Resources/views/adminlte/crud/sort.html.twig Wyświetl plik

@@ -49,7 +49,7 @@

<div class="table-responsive">
<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>
{% block table_head %}
<tr>

Ładowanie…
Anuluj
Zapisz