Просмотр исходного кода

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

feature/souke
Guillaume Bourgeois 1 год назад
Родитель
Сommit
10383c4b6a
5 измененных файлов: 19 добавлений и 7 удалений
  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 Просмотреть файл

@@ -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 Просмотреть файл

@@ -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 Просмотреть файл

@@ -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 Просмотреть файл

@@ -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 Просмотреть файл

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

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

Загрузка…
Отмена
Сохранить