Beispiel #1
0
 public function createHiddenInput($data = [], $referenceSettings = [])
 {
     /** @var Mesour\Icon\IIcon $icon */
     $className = $this->getIconClass();
     $icon = new $className();
     $referenceData = [];
     foreach ($this->source->getDataStructure()->getTableStructures() as $tableStructure) {
         $source = $this->getSource()->getReferencedSource($tableStructure->getName());
         if ($source->getTotalCount() <= self::$maxCheckboxCount) {
             $referenceData[$tableStructure->getName()] = $source->fetchFullData($this->getDateFormat());
         }
     }
     $hidden = $this->getHiddenPrototype();
     $attributes = ['data-mesour-data' => Nette\Utils\Json::encode($data), 'value' => Nette\Utils\Json::encode($this->getValues()), 'data-references' => Nette\Utils\Json::encode(array_merge([self::PREDEFINED_KEY => $this->predefinedData], $referenceData)), 'data-mesour-date' => $this->getDateFormat(), 'data-icon-prefix' => $icon->getPrefix(), 'data-icons' => Nette\Utils\Json::encode(self::$icons), 'data-mesour-js-date' => Mesour\Components\Utils\Helpers::convertDateToJsFormat($this->getDateFormat())];
     $hidden->addAttributes($attributes);
     return $hidden;
 }
Beispiel #2
0
 protected static function matchCounts(IFilterSource $source, $filteredCount, $fullCount, $rawClassType)
 {
     static $lastRowsDescription = 'Output from fetchLastRawRows after %s';
     $users = $source->fetchAll();
     if (count($users) > 0) {
         Assert::type(ArrayHash::class, reset($users));
     }
     Assert::count($filteredCount, $users, 'Output from fetchAll');
     $lastRows = $source->fetchLastRawRows();
     if (count($lastRows) > 0) {
         Assert::type($rawClassType, reset($lastRows));
     }
     Assert::count($filteredCount, $lastRows, sprintf($lastRowsDescription, 'fetchAll'));
     $fullData = $source->fetchFullData();
     if (count($fullData) > 0) {
         Assert::type(ArrayHash::class, reset($fullData));
     }
     Assert::count($fullCount, $fullData, 'Output from fetchFullData');
     $lastRows = $source->fetchLastRawRows();
     if (count($lastRows) > 0) {
         Assert::type($rawClassType, reset($lastRows));
     }
     Assert::count($fullCount, $lastRows, sprintf($lastRowsDescription, 'fetchFullData'));
 }