private function updatePagination()
 {
     $value = $this->inputOption->getValue();
     if (!$value || $this->paginationControl->getPageSize() == $value) {
         return;
     }
     $this->paginationControl->setPageSize($value);
 }
 protected function setViewData()
 {
     $view = $this->getView();
     if (!$view instanceof TemplateView) {
         return;
     }
     $defaults = ['containerAttributes' => ['data-role' => 'control-container', 'data-control' => 'filter'], 'inline' => true, 'label' => StaticStringy::humanize($this->field)];
     if ($this->valueOption !== null) {
         $defaults['name'] = $this->valueOption->getKey();
         $defaults['value'] = $this->valueOption->getValue();
     }
     $view->setDefaultData($defaults);
 }
 public function test()
 {
     // existing value in input + default
     $a = new InputOption('a', ['a' => 'A', 'e' => 'E'], 'default');
     self::assertEquals('a', $a->getKey());
     self::assertEquals('A', $a->getValue());
     self::assertEquals('A', $a->getInputValue());
     self::assertEquals('default', $a->getDefaultValue());
     self::assertEquals(true, $a->hasValue());
     // no value in input + default
     $b = new InputOption('b', ['a' => 'A', 'e' => 'E'], 'default');
     self::assertEquals('default', $b->getValue());
     self::assertEquals(null, $b->getInputValue());
     self::assertEquals('default', $b->getDefaultValue());
     self::assertEquals(true, $b->hasValue());
     // no value in input + no default
     $c = new InputOption('c', ['a' => 'A', 'e' => 'E']);
     self::assertEquals(false, $c->hasValue());
     // existing value in input + no default
     $e = new InputOption('e', ['a' => 'A', 'e' => 'E']);
     self::assertEquals(true, $e->hasValue());
     self::assertEquals(null, $e->getDefaultValue());
 }
Exemplo n.º 4
0
 public function getExportUrl()
 {
     return UriFunctions::modifyQuery(null, [$this->inputOption->getKey() => 1]);
 }
 /**
  * Returns current page number.
  *
  * @return int
  */
 public function getCurrentPage()
 {
     return (int) $this->pageInputOption->getValue();
 }
 private function validateInput()
 {
     return $this->fieldOption->hasValue() && array_key_exists($this->fieldOption->getValue(), $this->fields) && $this->directionOption->hasValue() && in_array($this->directionOption->getValue(), [SortOperation::ASC, SortOperation::DESC], true);
 }