Example #1
0
 protected function createComponentGrid($name)
 {
     $grid = new Grid($this, $name);
     $grid->setModel($this->service->getGriditoModel());
     $grid->setItemsPerPage($this->service->count());
     $grid->addColumn("name", "Popis", array("renderer" => function ($node) {
         echo str_repeat(" ", $node->getLevel() * 4);
         echo Html::el("a")->href($node->getNode()->getUrl())->setText($node->getNode()->getName());
     }));
     $presenter = $this;
     $grid->addButton("add", "Přidat", array("icon" => "ui-icon-plusthick", "link" => function ($node) use($presenter) {
         return $presenter->link("add", $node->getId());
     }, "showText" => false));
     $grid->addButton("edit", "Upravit", array("icon" => "ui-icon-pencil", "link" => function ($node) use($presenter) {
         return $presenter->link("edit", $node->getId());
     }, "showText" => false));
     $grid->addButton("delete", "Smazat", array("icon" => "ui-icon-closethick", "handler" => function ($node) use($grid) {
         $node->delete();
         $grid->flashMessage("Položka menu byla smazána.");
     }, "confirmationQuestion" => function ($node) {
         return "Opravdu smazat položku " . $node->getNode()->getName() . "?";
     }, "visible" => function ($node) {
         return !$node->isRoot();
     }, "showText" => false, "ajax" => true));
     $grid->addButton("up", "Nahoru", array("icon" => "ui-icon-arrowthick-1-n", "handler" => function ($node) use($grid) {
         $node->moveAsPrevSiblingOf($node->getPrevSibling());
         $grid->flashMessage("Odkaz přesunut.");
     }, "visible" => function ($node) {
         return $node->getPrevSibling() !== null;
     }, "showText" => false, "ajax" => true));
     $grid->addButton("down", "Dolů", array("icon" => "ui-icon-arrowthick-1-s", "handler" => function ($node) use($grid) {
         $node->moveAsNextSiblingOf($node->getNextSibling());
         $grid->flashMessage("Odkaz přesunut.");
     }, "visible" => function ($node) {
         return $node->getNextSibling() !== null;
     }, "showText" => false, "ajax" => true));
 }
Example #2
0
 /**
  * @depends testUpdateNode
  */
 public function testDeleteNode(MenuItem $node)
 {
     $this->object->deleteNode($node);
     $tree = $this->object->fetchTree();
     $this->assertSame(array(), $tree->getChildren());
 }