瀏覽代碼

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

feature/souke
Guillaume Bourgeois 1 年之前
父節點
當前提交
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();
}
}

Loading…
取消
儲存