diff --git a/.php-cs-fixer.dist.php b/.php-cs-fixer.dist.php index 58a3b2e835..97a57e9e77 100644 --- a/.php-cs-fixer.dist.php +++ b/.php-cs-fixer.dist.php @@ -53,13 +53,6 @@ // fn => without curly brackets is less readable, // also prevent bounding of unwanted variables for GC 'use_arrow_functions' => false, - - // TODO remove once 3.17.1 is released - // https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/pull/6979 - // https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/pull/7011 - // fixes were merged - 'phpdoc_types' => ['groups' => ['simple', 'meta']], - 'phpdoc_var_without_name' => false, ]) ->setFinder($finder) ->setCacheFile(sys_get_temp_dir() . '/php-cs-fixer.' . md5(__DIR__) . '.cache'); diff --git a/demos/collection/grid.php b/demos/collection/grid.php index c305220ae1..f5a4a6e073 100644 --- a/demos/collection/grid.php +++ b/demos/collection/grid.php @@ -79,4 +79,4 @@ )); // Setting ipp with an array will add an ItemPerPageSelector to paginator. -$grid->setIpp([10, 25, 50, 100]); +$grid->setIpp([10, 100, 1000]); diff --git a/src/Behat/Context.php b/src/Behat/Context.php index 60b7c35898..01b8b6670c 100644 --- a/src/Behat/Context.php +++ b/src/Behat/Context.php @@ -231,6 +231,13 @@ function ($matches) { $selector ); + // add NBSP support for normalize-space() xpath function + $xpath = preg_replace( + '~(?container->stickyGet('ipp'); if ($ipp) { diff --git a/src/ItemsPerPageSelector.php b/src/ItemsPerPageSelector.php index c7afce8bf6..da70f841cd 100644 --- a/src/ItemsPerPageSelector.php +++ b/src/ItemsPerPageSelector.php @@ -4,6 +4,7 @@ namespace Atk4\Ui; +use Atk4\Data\Field; use Atk4\Ui\Js\JsExpression; /** @@ -16,14 +17,9 @@ class ItemsPerPageSelector extends View public $ui = 'selection compact dropdown'; /** @var list Default page length menu items. */ - public $pageLengthItems = [10, 25, 50, 100]; + public $pageLengthItems = [10, 100, 1000]; - /** - * Default button label. - * - [ipp] will be replace by the number of pages selected. - * - * @var string - */ + /** @var string */ public $label = 'Items per page:'; /** @var int The current number of item per page. */ @@ -32,6 +28,11 @@ class ItemsPerPageSelector extends View /** @var Callback|null The callback function. */ public $cb; + private function formatInteger(int $value): string + { + return $this->getApp()->uiPersistence->typecastSaveField(new Field(['type' => 'integer']), $value); + } + protected function init(): void { parent::init(); @@ -45,7 +46,7 @@ protected function init(): void if (!$this->currentIpp) { $this->currentIpp = $this->pageLengthItems[0]; } - $this->set((string) $this->currentIpp); + $this->set($this->formatInteger($this->currentIpp)); } /** @@ -59,8 +60,7 @@ public function onPageLengthSelect(\Closure $fx): void { $this->cb->set(function () use ($fx) { $ipp = isset($_GET['ipp']) ? (int) $_GET['ipp'] : null; - // $this->pageLength->set(preg_replace("/\[ipp\]/", $ipp, $this->label)); - $this->set($ipp); // @phpstan-ignore-line TODO https://github.com/atk4/ui/issues/2016 + $this->set($this->formatInteger($ipp)); $reload = $fx($ipp); if ($reload) { $this->getApp()->terminateJson($reload); @@ -71,8 +71,8 @@ public function onPageLengthSelect(\Closure $fx): void protected function renderView(): void { $menuItems = []; - foreach ($this->pageLengthItems as $key => $item) { - $menuItems[] = ['name' => $item, 'value' => $item]; + foreach ($this->pageLengthItems as $item) { + $menuItems[] = ['name' => $this->formatInteger($item), 'value' => $item]; } $function = new JsExpression('function (value, text, item) { diff --git a/tests-behat/grid.feature b/tests-behat/grid.feature index f5a8cbd70a..fd73c8f667 100644 --- a/tests-behat/grid.feature +++ b/tests-behat/grid.feature @@ -61,3 +61,18 @@ Feature: Grid When I click using selector "//th.sortable[//div[text()='Name']]" Then I should see "Andorra" Then I should not see "Zambia" + + Scenario: IPP selector + Then I should see "Andorra" + Then I should not see "China" + Then I should not see "Zambia" + When I click using selector "//div.ui.dropdown.compact" + When I click using selector "//div.ui.dropdown.compact//div.item[text()='100']" + Then I should see "Andorra" + Then I should see "China" + Then I should not see "Zambia" + When I click using selector "//div.ui.dropdown.compact" + When I click using selector "//div.ui.dropdown.compact//div.item[text()[normalize-space()='1 000']]" + Then I should see "Andorra" + Then I should see "China" + Then I should see "Zambia"