setTemplateFile() public méthode

Sets file name of custom template.
public setTemplateFile ( string $file ) : Grid
$file string
Résultat Grid
 protected function createComponentInterpretList($name)
 {
     $grid = new Grid($this, $name);
     $grid->setModel($this->interpreti->findAll());
     $grid->addColumnText("nazev", "Interpret")->setCustomRender(function ($item) {
         return !$item->interpret_id ? Html::el('b')->setText($item->nazev) : $item->nazev;
     })->setSortable()->setFilterText()->setSuggestion();
     $grid->addColumnText("alias", "Alias pro")->setColumn(function ($item) {
         return isset($item->interpret->nazev) ? $item->interpret->nazev : null;
     });
     $grid->addFilterCheck('interpret_id', 'Jen aliasy');
     $grid->addColumnText("desc", "Popis")->setCustomRender(function ($item) {
         return Strings::truncate($item->desc, 256);
     });
     $grid->addActionHref('edit', 'Editovat', 'editor')->setIcon('pencil');
     $grid->addActionHref('delete', 'Smazat', 'delete!')->setIcon('trash')->setConfirm('Opravdu chcete smazat tohoto interpreta?');
     //Set face for grid
     $gridTemplate = __DIR__ . "/../templates/components/Grid.latte";
     if (file_exists($gridTemplate)) {
         $grid->setTemplateFile($gridTemplate);
     }
     return $grid;
 }
Exemple #2
0
 protected function createComponentSongList($name)
 {
     $grid = new Grido\Grid($this, $name);
     $grid->setModel($this->songy);
     $grid->addColumnDate("datum", "Datum", "d.m.y")->setSortable();
     $grid->addColumnText("interpret_name", "Interpret")->setCustomRender(function ($item) {
         $template = $this->createTemplate();
         $template->setFile(__DIR__ . "/../templates/components/Grid/interpret.latte");
         $template->song = $item;
         return $template;
     })->setSortable()->setFilterText()->setSuggestion();
     $grid->addColumnText("name", "Song")->setCustomRender(function ($item) {
         $template = $this->createTemplate();
         $template->setFile(__DIR__ . "/../templates/components/Grid/song.latte");
         $template->song = $item;
         return $template;
     })->setSortable()->setFilterText()->setSuggestion();
     $filter = array('' => 'Všechny');
     $filter = \Nette\Utils\Arrays::mergeTree($filter, $this->zanry->getList());
     $grid->addColumnText("zanr_id", "Žánr")->setCustomRender(function ($item) {
         return $item->zanr ? $item->zanr->name : null;
     })->setFilterSelect($filter);
     $grid->addColumnText("zadatel", "Přidal(a)")->setCustomRender(function ($item) {
         $template = $this->createTemplate();
         $template->setFile(__DIR__ . "/../templates/components/Grid/zadatel.latte");
         $template->song = $item;
         return $template;
     })->setSortable()->setFilterText()->setSuggestion();
     $statuses = array('' => 'Všechny', 'approved' => 'Zařazené', 'rejected' => 'Vyřazené', 'waiting' => 'Čekající');
     $grid->addColumnText("status", "Status")->setCustomRender(function ($item) {
         $status = $item->status;
         $revizor = $item->revisor ? $item->ref("user", "revisor")->username : "******";
         switch ($status) {
             case "approved":
                 return Html::el("span", array("class" => "label label-success", "title" => "Schválil(a) " . $revizor))->setText("Zařazen");
             case "waiting":
                 return Html::el("span", array("class" => "label label-warning", "title" => "Čeká ve frontě ke schválení"))->setText("Čeká");
             case "rejected":
                 return Html::el("span", array("class" => "label label-danger", "title" => "Zamítl(a) " . $revizor))->setText("Vyřazen");
             default:
                 return Html::el("i")->setText("Neznámý");
         }
     })->setSortable()->setFilterSelect($statuses);
     $grid->addColumnText("vzkaz", "Vzkaz DJovi")->setCustomRender(function ($item) {
         $elm = Html::el("span");
         if ($item->private_vzkaz) {
             if (!$this->user->isAllowed("privateMsg", "view") && $this->user->id != $item->user_id) {
                 $elm->addAttributes(array("class" => "msg-hidden", "title" => "Tento vzkaz je určen pouze pro DJe"));
                 $elm->setText("Soukromý vzkaz");
                 return $elm;
             }
             $elm->addAttributes(array("class" => "msg-private", "title" => "Tento vzkaz je určen pouze pro DJe"));
             $elm->setText($item->vzkaz);
         } else {
             return $item->vzkaz;
         }
         return $elm;
     });
     $myLikes = $this->songList->getMyLikes($this->user);
     $grid->addColumnText("likes", "")->setCustomRender(function ($item) use($myLikes) {
         $likes = count($item->related('song_likes'));
         $isLiked = isset($myLikes[$item->id]) ?: false;
         $el = Html::el('a')->addAttributes(['class' => 'like' . ($isLiked ? ' liked' : '')]);
         $el->add(Html::el('i')->addAttributes(['class' => 'glyphicon glyphicon-heart']));
         $el->add(Html::el()->setText(' ' . $likes));
         $el->href($this->link('like!', ['id' => $item->id]));
         return $el;
     });
     if ($this->user->isAllowed("song", "approve")) {
         $grid->addActionHref("approve", "")->setIcon("ok")->setElementPrototype(Html::el("a", array("class" => "btn btn-success", "data-toggle" => "modal", "data-target" => ".modal")));
     }
     if ($this->user->isAllowed("song", "reject")) {
         $grid->addActionHref("reject", "")->setIcon("remove")->setElementPrototype(Html::el("a", array("class" => "btn btn-danger", "data-toggle" => "modal", "data-target" => ".modal")));
     }
     if ($this->user->isAllowed("song", "play")) {
         $grid->addActionHref("play", "")->setDisable(function ($item) {
             if ($item->link) {
                 return false;
             }
             return true;
         })->setIcon("play")->setElementPrototype(Html::el("a", array("class" => "btn btn-info", "data-toggle" => "modal", "data-target" => ".modal")));
     }
     if ($this->user->isAllowed("song", "edit")) {
         $grid->addActionHref("edit", "", "admin:song:editor")->setIcon("pencil")->setElementPrototype(Html::el("a", array("class" => "btn btn-default", "target" => "_blank")));
     }
     $grid->setFilterRenderType(\Grido\Components\Filters\Filter::RENDER_OUTER);
     $grid->setDefaultSort(array("datum" => "DESC"));
     //Set face for grid
     $gridTemplate = __DIR__ . "/../templates/components/Grid.latte";
     if (file_exists($gridTemplate)) {
         $grid->setTemplateFile($gridTemplate);
     }
     return $grid;
 }
Exemple #3
0
 /**
  * Twitter Bootstrap theme.
  * @return \Grido\Customization
  */
 public function useTemplateBootstrap()
 {
     $this->grid->setTemplateFile($this->getTemplateFiles()[self::TEMPLATE_BOOTSTRAP]);
     return $this;
 }
Exemple #4
0
 protected function createComponentSongList($name)
 {
     $grid = new Grid($this, $name);
     $grid->setModel($this->songy->findAll());
     $grid->addColumnDate("datum", "Datum", "d.m.y")->setSortable()->setFilterDateRange();
     $grid->addColumnText("interpret_name", "Interpret")->setCustomRender(function ($item) {
         return $item->interpret_name . ($item->interpret ? " " . Html::el('i')->addAttributes(['class' => 'fa fa-ticket', 'title' => 'Asociován s ' . $item->interpret->nazev]) : null);
     })->setSortable()->setFilterText()->setSuggestion();
     $grid->addColumnText("name", "Song")->setSortable()->setFilterText()->setSuggestion();
     $filter = array('' => 'Všechny');
     $filter = \Nette\Utils\Arrays::mergeTree($filter, $this->zanry->getList());
     $grid->addColumnText("zanr_id", "Žánr")->setCustomRender(function ($item) {
         return $item->zanr ? $item->zanr->name : null;
     })->setFilterSelect($filter);
     $grid->addColumnText("zadatel", "Přidal(a)")->setSortable()->setFilterText()->setSuggestion();
     $statuses = array('' => 'Všechny', 'approved' => 'Zařazené', 'rejected' => 'Vyřazené', 'waiting' => 'Čekající');
     $grid->addColumnText("status", "Status")->setCustomRender(function ($item) {
         $status = $item->status;
         $revizor = $item->revisor ? $item->ref("user", "revisor")->username : "******";
         switch ($status) {
             case "approved":
                 return Html::el("span", array("class" => "label label-success", "title" => "Schválil(a) " . $revizor))->setText("Zařazen");
             case "waiting":
                 return Html::el("span", array("class" => "label label-warning", "title" => "Čeká ve frontě ke schválení"))->setText("Čeká");
             case "rejected":
                 return Html::el("span", array("class" => "label label-danger", "title" => "Zamítl(a) " . $revizor))->setText("Vyřazen");
             default:
                 return Html::el("i")->setText("Neznámý");
         }
     })->setSortable()->setFilterSelect($statuses);
     $grid->addColumnText("pecka", "Pecka")->setReplacement(array(0 => '', 1 => Html::el('i')->addAttributes(['class' => 'fa fa-check'])))->setFilterCheck()->setCondition(" = 1");
     $grid->addColumnText("instro", "Instro")->setReplacement(array(0 => '', 1 => Html::el('i')->addAttributes(['class' => 'fa fa-check'])))->setFilterCheck()->setCondition(" = 1");
     $grid->addColumnText("remix", "Remix")->setReplacement(array(0 => '', 1 => Html::el('i')->addAttributes(['class' => 'fa fa-check'])))->setFilterCheck()->setCondition(" = 1");
     $grid->addColumnNumber("likes", Html::el('i')->addAttributes(['class' => 'fa fa-heart']))->setCustomRender(function ($item) {
         return $item->related("song_likes")->count();
     });
     $grid->addActionHref("editor", "Editovat")->setIcon("pencil");
     $grid->addActionHref('delete', 'Smazat', 'deleteSong!')->setIcon('trash')->setConfirm('Opravdu chcete smazat tento song?');
     $grid->setFilterRenderType(Filter::RENDER_OUTER);
     $grid->setDefaultSort(array("datum" => "DESC"));
     //Set face for grid
     $gridTemplate = __DIR__ . "/../templates/components/Grid.latte";
     if (file_exists($gridTemplate)) {
         $grid->setTemplateFile($gridTemplate);
     }
     return $grid;
 }