Explorar el Código

[Administration] Utilisateurs > liste : configuration du nombre d'utilisateurs affichés par page

feature/souke
Guillaume Bourgeois hace 1 año
padre
commit
10383c4b6a
Se han modificado 5 ficheros con 19 adiciones y 7 borrados
  1. +2
    -3
      backend/controllers/ProducerController.php
  2. +2
    -1
      backend/views/user/index.php
  3. +5
    -0
      common/components/PageSizer.php
  4. +5
    -3
      common/logic/Producer/Producer/Service/ProducerPageSizer.php
  5. +5
    -0
      common/logic/Producer/Producer/Wrapper/ProducerContainer.php

+ 2
- 3
backend/controllers/ProducerController.php Ver fichero

@@ -174,14 +174,13 @@ class ProducerController extends BackendController

public function actionPagesize()
{
$producerManager = $this->getProducerManager();
$producerCurrent = $this->getProducerCurrent();
$request = Yii::$app->request;

$entity = $request->post('entity');
$pageSize = $request->post('pagesize');

$producerManager->updatePagesize($producerCurrent, $entity, $pageSize);
$this->getProducerContainer()->getProducerPageSizer()
->updatePagesize($producerCurrent, $entity, $pageSize);

$referer = strtok(Yii::$app->request->referrer, "?");
return $this->redirect($referer);

+ 2
- 1
backend/views/user/index.php Ver fichero

@@ -68,7 +68,8 @@ $this->render('_menu', [
<?= GridView::widget([
'dataProvider' => $dataProvider,
'filterModel' => $searchModel,
'summary' => $producerManager->getPageSizeSummary($producer, 'user', 'Utilisateurs'),
'summary' => $this->getProducerContainer()->getProducerPageSizer()
->getPageSizeSummary($producer, 'user', 'Utilisateurs'),
'columns' => [
[
'attribute' => 'username',

+ 5
- 0
common/components/PageSizer.php Ver fichero

@@ -31,4 +31,9 @@ class PageSizer
return $pageSizeOptionsArray;
}

public function isPageSizeExist(int $pageSize): bool
{
return in_array($pageSize, self::$pageSizeOptions);
}

}

+ 5
- 3
common/logic/Producer/Producer/Service/ProducerPageSizer.php Ver fichero

@@ -10,9 +10,11 @@ class ProducerPageSizer extends AbstractUtils
{
protected ProducerSolver $producerSolver;
protected ProducerBuilder $producerBuilder;
protected PageSizer $pageSizer;

public function loadDependencies(): void
{
$this->pageSizer = \Yii::$app->pageSizer;
$this->producerSolver = $this->loadService(ProducerSolver::class);
$this->producerBuilder = $this->loadService(ProducerBuilder::class);
}
@@ -28,16 +30,16 @@ class ProducerPageSizer extends AbstractUtils
return $this->producerSolver->getConfig($pageSizeConfig, $producer) ?: PageSizer::DEFAULT_PAGE_SIZE ;
}

public function getPageSizeSummary(Producer $producer, string $entity, string $labelEntity)
public function getPageSizeSummary(Producer $producer, string $entity, string $labelEntity): string
{
return \Yii::$app->pageSizer->getForm($entity, $labelEntity, $this->getPageSize($producer, $entity));
return $this->pageSizer->getForm($entity, $labelEntity, $this->getPageSize($producer, $entity));
}

public function updatePagesize(Producer $producer, string $entity, int $pageSize)
{
$field = $this->getPageSizeConfigName($entity);

if(isset($producer->$field)) {
if(isset($producer->$field) && $this->pageSizer->isPageSizeExist($pageSize)) {
$producer->$field = $pageSize;
$this->producerBuilder->update($producer);
}

+ 5
- 0
common/logic/Producer/Producer/Wrapper/ProducerContainer.php Ver fichero

@@ -50,4 +50,9 @@ class ProducerContainer extends AbstractContainer
{
return ProducerUtils::getInstance();
}

public function getProducerPageSizer(): ProducerPageSizer
{
return ProducerPageSizer::getInstance();
}
}

Cargando…
Cancelar
Guardar