protected function createComponentTable() { $repository = $this->getRepository(); $formFactory = $this->getFormFactory(); $adminControl = new AdminGrid($repository); // columns $table = $adminControl->getTable(); $table->addColumnText('email', 'Name')->setSortable()->getCellPrototype()->width = '100%'; $table->getColumn('email')->setFilterText()->setSuggestion(); $form = $adminControl->createForm($formFactory, 'Uživatel', NULL, \CmsModule\Components\Table\Form::TYPE_LARGE); $import = $adminControl->createForm($this->importFormFactory, 'Import'); // Toolbar $toolbar = $adminControl->getNavbar(); $toolbar->addSection('new', 'Create', 'file'); $adminControl->connectFormWithNavbar($form, $toolbar->getSection('new')); $toolbar->addSection('export', 'Export', 'floppy-save')->onClick[] = $this->exportClick; $toolbar->addSection('import', 'Import', 'floppy-open'); $adminControl->connectFormWithNavbar($import, $toolbar->getSection('import')); // actions $table->addAction('edit', 'Edit')->getElementPrototype()->class[] = 'ajax'; $adminControl->connectFormWithAction($form, $table->getAction('edit')); $table->addAction('delete', 'Delete')->getElementPrototype()->class[] = 'ajax'; $adminControl->connectActionAsDelete($table->getAction('delete')); return $adminControl; }
public function invoke() { $translator = $this->translator; $admin = new AdminGrid($this->invoiceRepository); $table = $admin->getTable(); $table->setTranslator($this->translator); $table->setDefaultSort(array('date' => 'DESC')); $table->addColumnText('identification', 'ID'); $table->addColumnText('revisionCounter', 'Revision'); $table->addColumnDate('date', 'Date'); $table->addColumnText('supplier', 'Supplier')->setCustomRender(function (InvoiceEntity $invoiceEntity) { return $invoiceEntity->getSupplier()->getAccount()->getPerson(); }); $table->addColumnText('customer', 'Customer')->setCustomRender(function (InvoiceEntity $invoiceEntity) { return $invoiceEntity->getCustomer(); }); $table->addColumnText('amount', 'Amount'); $table->addColumnText('state', 'State')->setCustomRender(function (InvoiceEntity $invoiceEntity) use($translator) { $states = InvoiceEntity::getStates(); return $translator->translate($states[$invoiceEntity->getState()]); }); $table->addAction('generate', 'Generate ID')->setCustomRender(function (InvoiceEntity $invoiceEntity, $element) { if ($invoiceEntity->getIdentification()) { $element->class[] = 'disabled'; } return $element; })->onClick[] = $this->generateClick; $table->addAction('generatePdf', 'Generate PDF')->onClick[] = $this->generatePdfClick; $table->addAction('downloadPdf', 'Download PDF')->setCustomRender(function (InvoiceEntity $invoiceEntity, $element) { if (!count($invoiceEntity->revisions)) { $element->class[] = 'disabled'; } return $element; })->onClick[] = $this->downloadPdfClick; $table->addAction('show', 'Preview')->onClick[] = $this->showClick; $table->addAction('pdf', 'PDF')->onClick[] = $this->pdfClick; $table->addAction('edit', 'Edit')->getElementPrototype()->class[] = 'ajax'; $form = $admin->createForm($this->invoiceFormFactory, 'Payment', NULL, \CmsModule\Components\Table\Form::TYPE_FULL); $admin->connectFormWithAction($form, $table->getAction('edit'), $admin::MODE_PLACE); // Toolbar $toolbar = $admin->getNavbar(); $toolbar->addSection('new', 'Create', 'file'); $admin->connectFormWithNavbar($form, $toolbar->getSection('new'), $admin::MODE_PLACE); $table->addAction('delete', 'Delete')->setCustomRender(function (InvoiceEntity $invoiceEntity, $element) { $element->class[] = 'ajax'; if ($invoiceEntity->getState() !== InvoiceEntity::STATE_NEW) { $element->class[] = 'disabled'; } return $element; }); $admin->connectActionAsDelete($table->getAction('delete')); return $admin; }
protected function createComponentTable() { $admin = new AdminGrid($this->dobrovolnikRepository); // columns $table = $admin->getTable(); $table->setModel(new Doctrine($this->dobrovolnikRepository->createQueryBuilder('a')->addSelect('r')->innerJoin('a.route', 'r')->andWhere('a.extendedPage = :page')->setParameter('page', $this->extendedPage->id), array('created' => 'r.created'))); $table->setDefaultSort(array('created' => 'DESC')); $table->addColumnText('surname', 'Surname')->setCustomRender(function (DobrovolnikEntity $entity) { $el = Html::el('a')->setText($entity->surname); $el->title = $entity->surname . ' ' . $entity->name . ' Město: ' . $entity->city . '' . ' Tel.: ' . $entity->phone . ' Email: ' . $entity->email; $el->href = 'mailto:' . $entity->email; $el->target = '_blank'; return $el; })->setSortable()->getCellPrototype()->width = '15%'; $table->getColumn('surname')->setFilterText()->setSuggestion(); $table->addColumnText('name', 'Name')->setSortable()->getCellPrototype()->width = '15%'; $table->getColumn('name')->setFilterText()->setSuggestion(); $items = array('homework' => array('HomeW' => 'Ze svého domova nebo po síti'), 'contactCampaign' => array('Campaign' => 'Při kontaktní kampani'), 'advertisingArea' => array('Plocha' => 'Nabídkou reklamních ploch'), 'distributionOfLeaflets' => array('Roznos' => 'Roznosem letáků do schránek'), 'distributionOfPosters' => array('Výlep' => 'Výlepem plakátů v okolních obcích'), 'blog' => array('Blog' => 'Mám web či blog, kde mohu nabídnout inzerci'), 'discussion' => array('Disc.' => 'Rád diskutuji s lidmi a komentuji aktuality'), 'adFacade' => array('Fasada' => 'Mám fasádu či plot na viditelném a frekventovaném místě'), 'adWindow' => array('Okno' => 'Vylepím si za okno plakát'), 'adShop' => array('Shop' => 'Vylepím si plakát do výlohy prodejny'), 'adCar' => array('Auto' => 'Nabízím k polepu auto (celé auto, zadní sklo nebo malá samolepka)'), 'provideCar' => array('Půjčit Auto' => 'Zapůjčit automobil'), 'providePub' => array('Pub' => 'Zapůjčit svou hospůdku pro konání besed s lídry či setkání příznivců'), 'provideAccommodation' => array('Azyl' => 'Poskytnout ubytování pro členy kontaktních týmů')); foreach ($items as $key => $item) { $el = Html::el('small')->setText(key($item)); $el->title = reset($item); $el->style = 'font-size: 60%'; $table->addColumnText($key, $el)->setSortable()->getCellPrototype()->width = '4%'; $table->getColumn($key)->setFilterText()->setSuggestion(); } $items = array('ownHelp' => array('Txt' => 'Jinou formou'), 'skills' => array('Txt' => 'Ovládám něco, co by mohlo straně pomoci'), 'otherwiseHelp' => array('Txt' => 'Pomohu jinak')); foreach ($items as $key => $item) { $el = Html::el('small')->setText(key($item)); $el->title = reset($item); $el->style = 'font-size: 60%'; $table->addColumnText($key, $el)->setCustomRender(function (DobrovolnikEntity $entity) use($key) { $el = Html::el('span')->setText($entity->{$key} ? 'T' : ''); $el->title = $entity->{$key}; return $el; })->setSortable()->getCellPrototype()->width = '4%'; $table->getColumn($key)->setFilterText()->setSuggestion(); } $_this = $this; $repository = $this->dobrovolnikRepository; $formFactory = $this->formFactory; $entity = $this->extendedPage; $form = $admin->createForm($formFactory, '', function () use($repository, $entity, $_this) { $entity = $repository->createNew(array($entity)); if ($_this->presenter->user->identity instanceof UserEntity) { $entity->route->author = $_this->presenter->user->identity; } return $entity; }, \CmsModule\Components\Table\Form::TYPE_FULL); $table->addAction('edit', 'Edit'); $admin->connectFormWithAction($form, $table->getAction('edit'), $admin::MODE_PLACE); return $admin; }
public function invoke() { $admin = new AdminGrid($this->paymentRepository); $table = $admin->getTable(); $table->setTranslator($this->translator); $table->setDefaultSort(array('date' => 'DESC')); $table->addColumnDate('date', 'Date'); $table->addColumnText('offset', 'Offset'); $table->addColumnText('amount', 'Amount'); $table->addColumnText('constantSymbol', 'CS'); $table->addColumnText('variableSymbol', 'VS'); $table->addColumnText('specificSymbol', 'SS'); $table->addColumnText('userIdentification', 'User identification'); $table->addAction('edit', 'Edit')->getElementPrototype()->class[] = 'ajax'; $form = $admin->createForm($this->paymentFormFactory, 'Payment', NULL, \CmsModule\Components\Table\Form::TYPE_FULL); $admin->connectFormWithAction($form, $table->getAction('edit'), $admin::MODE_PLACE); // Toolbar $toolbar = $admin->getNavbar(); $toolbar->addSection('new', 'Create', 'file'); $admin->connectFormWithNavbar($form, $toolbar->getSection('new'), $admin::MODE_PLACE); $toolbar->addSection('synchronize', 'Synchronize')->setIcon('refresh'); $toolbar->getSection('synchronize')->onClick[] = $this->synchronizeClick; $table->addAction('delete', 'Delete')->getElementPrototype()->class[] = 'ajax'; $admin->connectActionAsDelete($table->getAction('delete')); return $admin; }
/** * @return AdminGrid */ public function invoke() { $_this = $this; $adminGrid = new AdminGrid($this->pageRepository); $table = $adminGrid->getTable(); $table->setTranslator($this->presenter->context->translator->translator); $table->addColumnText('mainRoutefdsf', 'Name')->setSortable()->setFilterText()->setSuggestion(); $table->getColumn('name')->getCellPrototype()->width = '50%'; $table->addColumnText('mainRoute', 'URL')->setSortable()->setFilterText()->setSuggestion(); $table->getColumn('mainRoute')->getCellPrototype()->width = '25%'; $table->addColumnText('language', 'Language')->getCellPrototype()->width = '25%'; $adminGrid->onAttached[] = function (AdminGrid $table) use($_this) { $_this->onAttached($table); }; return $adminGrid; }
protected function createComponentTable() { $admin = new AdminGrid($this->routeRepository); // columns $table = $admin->getTable(); $table->setModel(new Doctrine($this->routeRepository->createQueryBuilder('a')->andWhere('a.page = :page')->setParameter('page', $this->extendedPage->page->id))); $table->setTranslator($this->presenter->context->translator->translator); $table->addColumnText('title', 'Title')->setSortable()->getCellPrototype()->width = '100%'; $table->getColumn('title')->setFilterText()->setSuggestion(); $table->addColumnText('url', 'Url')->setSortable()->getCellPrototype()->width = '100%'; $table->getColumn('url')->setFilterText()->setSuggestion(); // actions $table->addAction('edit', 'Edit')->getElementPrototype()->class[] = 'ajax'; $form = $admin->createForm($this->routeFormFactory, 'Route', NULL, \CmsModule\Components\Table\Form::TYPE_LARGE); $admin->connectFormWithAction($form, $table->getAction('edit')); return $admin; }
/** * @return AdminGrid */ public function invoke() { $_this = $this; $adminGrid = new AdminGrid($this->pageRepository); $table = $adminGrid->getTable(); $table->setModel(new Doctrine($this->pageRepository->createQueryBuilder('a')->addSelect('r')->innerJoin('a.mainRoute', 'r'), array('name' => 'r.name', 'created' => 'r.created', 'url' => 'r.url'))); $table->addColumnText('name', 'Name')->setCustomRender(function ($entity) { return $entity->mainRoute->name; })->setSortable()->setFilterText()->setSuggestion(); $table->getColumn('name')->getCellPrototype()->width = '50%'; $table->addColumnText('url', 'URL')->setCustomRender(function ($entity) { return $entity->mainRoute->url; })->setSortable()->setFilterText()->setSuggestion(); $table->getColumn('url')->getCellPrototype()->width = '25%'; $table->addColumnText('language', 'Language')->getCellPrototype()->width = '25%'; $adminGrid->onAttached[] = function (AdminGrid $table) use($_this) { $_this->onAttached($table); }; return $adminGrid; }
protected function createComponentTable() { $_this = $this; $admin = new AdminGrid(); $deploymentManager = $this->deploymentManager; // columns $table = $admin->getTable(); $table->setModel(new ArraySource($this->getBackups())); $table->setTranslator($this->translator); $table->addColumnText('name', 'Name')->setCustomRender(function ($items) use($_this) { return $items['name'] ?: $_this->translator->translate('untitled'); })->setSortable()->getCellPrototype()->width = '80%'; $table->addColumnDate('date', 'Date', 'd.m.Y - H:i:s')->setSortable()->getCellPrototype()->width = '20%'; // actions if ($this->isAuthorized('edit')) { // Toolbar $toolbar = $admin->getNavbar(); $toolbar->addSection('new', 'Create backup', 'file')->onClick[] = function () use($_this, $deploymentManager, $admin, $table) { $deploymentManager->createBackup($_this->getBackupName()); $admin->invalidateControl('table'); $_this->payload->url = $_this->link('this'); $table->setModel(new ArraySource($_this->getBackups())); }; $table->addAction('load', 'Load')->getElementPrototype()->class[] = 'ajax'; $table->getAction('load')->onClick[] = function ($button, $id) use($_this, $deploymentManager, $admin, $table) { $deploymentManager->loadBackup($id); $_this->redirect('this'); }; } if ($this->isAuthorized('remove')) { $table->addAction('delete', 'Delete')->getElementPrototype()->class[] = 'ajax'; $table->getAction('delete')->onClick[] = function ($button, $id) use($_this, $deploymentManager, $admin, $table) { $deploymentManager->removeBackup($id); $admin->invalidateControl('table'); $_this->payload->url = $_this->link('this'); $table->setModel(new ArraySource($_this->getBackups())); }; } return $admin; }
protected function createComponentTable() { $admin = new AdminGrid($this->roleRepository); // columns $table = $admin->getTable(); $table->setTranslator($this->translator); $table->addColumnText('name', 'Name')->setSortable()->getCellPrototype()->width = '40%'; $table->getColumn('name')->setFilterText()->setSuggestion(); $table->addColumnText('parent', 'Parent')->setSortable()->getCellPrototype()->width = '60%'; $table->getColumn('parent')->setCustomRender(function (RoleEntity $entity) { $entities = array(); $en = $entity; while ($en = $en->getParent()) { $entities[] = $en->getName(); } return implode(', ', $entities); }); // actions if ($this->isAuthorized('edit')) { $table->addAction('edit', 'Edit')->getElementPrototype()->class[] = 'ajax'; $table->addAction('permissions', 'Permissions')->getElementPrototype()->class[] = 'ajax'; $form = $admin->createForm($this->roleForm, 'Role'); $permissionsForm = $admin->createForm($this->permissionsForm, 'Permissions', NULL, Form::TYPE_LARGE); $admin->connectFormWithAction($form, $table->getAction('edit')); $admin->connectFormWithAction($permissionsForm, $table->getAction('permissions'), $admin::MODE_PLACE); // Toolbar $toolbar = $admin->getNavbar(); $toolbar->addSection('new', 'Create', 'file'); $admin->connectFormWithNavbar($form, $toolbar->getSection('new')); } if ($this->isAuthorized('remove')) { $table->addAction('delete', 'Delete')->getElementPrototype()->class[] = 'ajax'; $admin->connectActionAsDelete($table->getAction('delete')); } return $admin; }
public function invoke() { $admin = new AdminGrid($this->currencyRepository); $table = $admin->getTable(); $table->setTranslator($this->translator); $table->addColumnText('name', 'Name'); $table->addAction('edit', 'Edit')->getElementPrototype()->class[] = 'ajax'; $form = $admin->createForm($this->currencyFormFactory, 'Payment', NULL, \CmsModule\Components\Table\Form::TYPE_FULL); $admin->connectFormWithAction($form, $table->getAction('edit'), $admin::MODE_PLACE); // Toolbar $toolbar = $admin->getNavbar(); $toolbar->addSection('new', 'Create', 'file'); $admin->connectFormWithNavbar($form, $toolbar->getSection('new'), $admin::MODE_PLACE); $table->addAction('delete', 'Delete')->getElementPrototype()->class[] = 'ajax'; $admin->connectActionAsDelete($table->getAction('delete')); return $admin; }
public function invoke() { $admin = new AdminGrid($this->revisionRepository); $table = $admin->getTable(); $table->setTranslator($this->translator); $table->setDefaultSort(array('date' => 'DESC')); $table->addColumnText('revision', 'Revision'); $table->addColumnDate('date', 'Date'); $table->addAction('edit', 'Edit')->getElementPrototype()->class[] = 'ajax'; $form = $admin->createForm($this->revisionFormFactory, 'Revision'); $admin->connectFormWithAction($form, $table->getAction('edit')); // Toolbar $toolbar = $admin->getNavbar(); $toolbar->addSection('new', 'Create', 'file'); $admin->connectFormWithNavbar($form, $toolbar->getSection('new')); $table->addAction('delete', 'Delete'); $admin->connectActionAsDelete($table->getAction('delete')); return $admin; }
protected function createComponentTable() { $admin = new AdminGrid($this->typeRepository); // columns $table = $admin->getTable(); $table->setModel(new Doctrine($this->typeRepository->createQueryBuilder('a'))); $table->addColumnText('name', 'Name')->setSortable()->getCellPrototype()->width = '100%'; $table->getColumn('name')->setFilterText()->setSuggestion(); $table->addAction('edit', 'Edit')->getElementPrototype()->class[] = 'ajax'; $form = $admin->createForm($this->typeFormFactory, 'Type'); $admin->connectFormWithAction($form, $table->getAction('edit')); // Toolbar $toolbar = $admin->getNavbar(); $toolbar->addSection('new', 'Create', 'file'); $admin->connectFormWithNavbar($form, $toolbar->getSection('new')); $table->addAction('delete', 'Delete')->getElementPrototype()->class[] = 'ajax'; $admin->connectActionAsDelete($table->getAction('delete')); return $admin; }
protected function createComponentTable() { $admin = new AdminGrid($this->villageRepository); // columns $table = $admin->getTable(); $table->addColumnText('name', 'Name')->setSortable()->getCellPrototype()->width = '50%'; $table->getColumn('name')->setFilterText()->setSuggestion(); $table->addColumnText('latitude', 'Latitude'); $table->addColumnText('longitude', 'Longitude'); $formFactory = $this->formFactory; $form = $admin->createForm($formFactory, '', NULL, \CmsModule\Components\Table\Form::TYPE_FULL); $section = $admin->getNavbar()->addSection('new', 'New', 'item'); $table->addAction('edit', 'Edit'); $admin->connectFormWithAction($form, $table->getAction('edit'), $admin::MODE_PLACE); $admin->connectFormWithNavbar($form, $section, $admin::MODE_PLACE); return $admin; }
public function invoke() { $translator = $this->translator; $admin = new AdminGrid($this->personRepository); $table = $admin->getTable(); $table->setTranslator($this->translator); $table->addColumnText('name', 'Name')->getCellPrototype()->style[] = 'width: 70%;'; $table->addColumnText('type', 'Person')->setCustomRender(function (PersonEntity $personEntity) use($translator) { $types = PersonEntity::getTypes(); return $translator->translate($types[$personEntity->getType()]); })->getCellPrototype()->style[] = 'width: 30%;'; $table->addAction('edit', 'Edit')->getElementPrototype()->class[] = 'ajax'; $form = $admin->createForm($this->personFormFactory, 'Payment', NULL, \CmsModule\Components\Table\Form::TYPE_FULL); $admin->connectFormWithAction($form, $table->getAction('edit'), $admin::MODE_PLACE); // Toolbar $toolbar = $admin->getNavbar(); $toolbar->addSection('new', 'Create', 'file'); $admin->connectFormWithNavbar($form, $toolbar->getSection('new'), $admin::MODE_PLACE); $table->addAction('delete', 'Delete')->getElementPrototype()->class[] = 'ajax'; $admin->connectActionAsDelete($table->getAction('delete')); return $admin; }
public function invoke() { $admin = new AdminGrid($this->accountRepository); $table = $admin->getTable(); $table->setTranslator($this->translator); $table->addColumnText('name', 'Account number')->getCellPrototype()->width = '40%'; $table->addColumnText('bank', 'Bank')->setCustomRender(function (AccountEntity $account) { return (string) $account->bank; })->getCellPrototype()->width = '30%'; $table->addColumnText('person', 'Person')->setCustomRender(function (AccountEntity $account) { return $account->getPerson() ? $account->getPerson() : ''; })->getCellPrototype()->width = '30%'; $table->addAction('synchronize', 'Synchronize')->onClick[] = $this->synchronizeClick; $table->addAction('edit', 'Edit')->getElementPrototype()->class[] = 'ajax'; $form = $admin->createForm($this->accountFormFactory, 'Account', NULL, \CmsModule\Components\Table\Form::TYPE_FULL); $admin->connectFormWithAction($form, $table->getAction('edit'), $admin::MODE_PLACE); // Toolbar $toolbar = $admin->getNavbar(); $toolbar->addSection('new', 'Create', 'file'); $admin->connectFormWithNavbar($form, $toolbar->getSection('new'), $admin::MODE_PLACE); $table->addAction('delete', 'Delete')->getElementPrototype()->class[] = 'ajax'; $admin->connectActionAsDelete($table->getAction('delete')); return $admin; }
protected function createComponentTable() { $_this = $this; $repository = $this->languageRepository; $admin = new AdminGrid($this->languageRepository); // columns $table = $admin->getTable(); $table->setTranslator($this->translator); $table->addColumnText('name', 'Name')->setSortable()->getCellPrototype()->width = '50%'; $table->addColumnText('alias', 'Alias')->setSortable()->getCellPrototype()->width = '20%'; $table->addColumnText('short', 'Short')->setSortable()->getCellPrototype()->width = '30%'; // actions if ($this->isAuthorized('edit')) { $table->addAction('edit', 'Edit')->getElementPrototype()->class[] = 'ajax'; $form = $admin->createForm($this->form, 'Language', NULL, \CmsModule\Components\Table\Form::TYPE_LARGE); $admin->connectFormWithAction($form, $table->getAction('edit')); // Toolbar $toolbar = $admin->getNavbar(); $toolbar->addSection('new', 'Create', 'file'); $admin->connectFormWithNavbar($form, $toolbar->getSection('new')); $admin->onAttached[] = function (AdminGrid $admin) use($table, $_this, $repository) { if ($admin->formName && !$admin->id) { $admin['navbarForm']->onSuccess[] = function () use($_this, $repository) { if ($repository->createQueryBuilder('a')->select('count(a.id)')->getQuery()->getSingleScalarResult() <= 1) { $_this->redirect('this'); } }; } }; } if ($this->isAuthorized('remove')) { $table->addAction('delete', 'Delete')->getElementPrototype()->class[] = 'ajax'; $admin->connectActionAsDelete($table->getAction('delete')); $table->getAction('delete')->onClick[] = function () use($_this, $repository) { if ($repository->createQueryBuilder('a')->select('count(a.id)')->getQuery()->getSingleScalarResult() == 0) { $_this->redirect('this'); } }; } return $admin; }
protected function createComponentTable() { $repository = $this->getRepository(); $formFactory = $this->getFormFactory(); $adminControl = new AdminGrid($repository); // columns $table = $adminControl->getTable(); $table->setDefaultSort(array('created' => 'DESC')); $table->addColumnText('subject', 'Subject')->setCustomRender(function ($entity) { return $entity->newsletter->subject; })->getCellPrototype()->width = '100%'; $table->addColumnDate('created', 'Created'); $form = $adminControl->createForm($formFactory, 'Message', NULL, \CmsModule\Components\Table\Form::TYPE_LARGE); // actions $table->addAction('send', 'Send')->setConfirm(function () { return 'Really?'; })->onClick[] = $this->tableSend; $table->addAction('edit', 'Edit')->getElementPrototype()->class[] = 'ajax'; $adminControl->connectFormWithAction($form, $table->getAction('edit')); $table->addAction('delete', 'Delete')->getElementPrototype()->class[] = 'ajax'; $adminControl->connectActionAsDelete($table->getAction('delete')); return $adminControl; }
public function connectActionWithFloor(CallbackAction $action, AdminGrid $adminGrid, $name) { $this->floors[$name] = $adminGrid; $adminGrid->setParentFloor($this); $_this = $this; $action->onClick[] = function ($action, $id) use($_this, $name) { $_this->floorId = $id; $_this->floor = $name; $_this->handleFloor(); }; return $this; }
protected function createComponentTable() { $session = $this->session; $admin = new AdminGrid($this->loginRepository); // columns $table = $admin->getTable(); if ($this->user->identity instanceof UserEntity) { $table->setModel(new Doctrine($this->loginRepository->createQueryBuilder('a')->andWhere('a.user = :user')->setParameter('user', $this->user->identity))); } else { $table->setModel(new Doctrine($this->loginRepository->createQueryBuilder('a')->andWhere('a.user IS NULL'))); } $table->setTranslator($this->translator); $table->addColumnDate('current', 'Current')->setCustomRender(function (LoginEntity $entity) use($session) { $el = Html::el('span'); $el->class[] = 'glyphicon ' . ($session->id == $entity->getSessionId() ? 'glyphicon-ok' : 'glyphicon-remove'); return $el; })->getCellPrototype()->width = '10%'; $table->addColumnDate('created', 'Date')->setSortable()->getCellPrototype()->width = '40%'; $table->addColumnText('sessionId', 'Session ID')->getCellPrototype()->width = '50%'; // actions $table->addAction('delete', 'Delete')->setConfirm(function ($entity) { return "Really delete session '{$entity->sessionId}'?"; })->getElementPrototype()->class[] = 'ajax'; $admin->connectActionAsDelete($table->getAction('delete')); return $admin; }
protected function createComponentTable() { $repository = $this->entityManager->getRepository($this->type); $admin = new AdminGrid($repository); $table = $admin->getTable(); $table->setTranslator($this->translator); $table->setModel(new Doctrine($repository->createQueryBuilder('a')->addSelect('u')->innerJoin('a.user', 'u'), array('email' => 'u.email'))); // columns $table->addColumnText('email', 'E-mail')->setCustomRender(function ($entity) { return $entity->user->email; })->setSortable()->getCellPrototype()->width = '60%'; $table->getColumn('email')->setFilterText()->setSuggestion(); $table->addColumnText('roles', 'Roles')->getCellPrototype()->width = '40%'; $table->getColumn('roles')->setCustomRender(function ($entity) { return implode(", ", $entity->user->roles); }); // actions if ($this->isAuthorized('edit')) { $table->addAction('edit', 'Edit')->getElementPrototype()->class[] = 'ajax'; $table->addAction('loginProviders', 'Login providers')->getElementPrototype()->class[] = 'ajax'; $extendedPage = $this->extendedPage; $type = $this->type; $form = $admin->createForm($this->getUserType()->getFormFactory(), 'User', function () use($extendedPage, $type) { return new $type($extendedPage); }, Form::TYPE_LARGE); $socialForm = $admin->createForm($this->socialForm, 'Login providers', NULL, Form::TYPE_LARGE); $admin->connectFormWithAction($form, $table->getAction('edit'), $admin::MODE_PLACE); $admin->connectFormWithAction($socialForm, $table->getAction('loginProviders')); // Toolbar $toolbar = $admin->getNavbar(); $toolbar->addSection('new', 'Create', 'file'); $admin->connectFormWithNavbar($form, $toolbar->getSection('new'), $admin::MODE_PLACE); } if ($this->isAuthorized('remove')) { $table->addAction('delete', 'Delete')->getElementPrototype()->class[] = 'ajax'; $admin->connectActionAsDelete($table->getAction('delete')); } return $admin; }
/** * @return AdminGrid */ protected function createComponentTable() { $_this = $this; $admin = new AdminGrid($this->repository); // columns $table = $admin->getTable(); $table->setModel(new Doctrine($this->repository->createQueryBuilder('a')->addSelect('r')->innerJoin('a.route', 'r')->andWhere('a.extendedPage = :page')->setParameter('page', $this->extendedPage->id), array('name' => 'r.name', 'created' => 'r.created'))); $table->setDefaultSort(array('created' => 'DESC')); $table->addColumnText('name', 'Name')->setCustomRender(function ($entity) { return $entity->route->name; })->setSortable()->getCellPrototype()->width = '70%'; $table->getColumn('name')->setFilterText()->setSuggestion(); $table->addColumnDate('created', 'Created')->setCustomRender(function ($entity) { return $entity->route->created->format('Y-m-d H:i:s'); })->setSortable()->getCellPrototype()->width = '30%'; // actions $table->addAction('publish', 'Published')->setCustomRender(function ($entity, $element) { if ((bool) $entity->route->published) { $element->class[] = 'btn-primary'; } return $element; })->setCustomHref(function ($entity) use($_this) { return $_this->link('publish!', array($entity->id)); })->getElementPrototype()->class[] = 'ajax'; $table->addAction('preview', 'Preview')->setCustomHref(function ($entity) use($_this) { return $_this->link('preview!', array($entity->id)); }); $table->addAction('edit', 'Edit')->getElementPrototype()->class[] = 'ajax'; return $admin; }
protected function createComponentElementTable() { $admin = new AdminGrid($this->elementRepository); // columns $table = $admin->getTable(); $table->setTranslator($this->translator); $table->addColumnText('nameRaw', 'Name')->setSortable()->setFilterText()->setSuggestion(); $table->getColumn('nameRaw')->getCellPrototype()->width = '23%'; $table->addColumnText('mode', 'Mode')->setSortable()->setCustomRender(function ($entity) { $modes = ElementEntity::getModes(); return $modes[$entity->mode]; })->getCellPrototype()->width = '12%'; $table->addColumnText('langMode', 'Language mode')->setSortable()->setCustomRender(function ($entity) { $modes = ElementEntity::getLangModes(); return $modes[$entity->langMode]; })->getCellPrototype()->width = '12%'; $table->addColumnText('page', 'Page')->setSortable()->getCellPrototype()->width = '20%'; $table->addColumnText('route', 'Route')->setSortable()->getCellPrototype()->width = '20%'; $table->addColumnText('language', 'Language')->setSortable()->getCellPrototype()->width = '15%'; // filters $table->addFilterSelect('mode', 'Mode', array('' => '') + ElementEntity::getModes()); $table->addFilterSelect('langMode', 'Mode', array('' => '') + ElementEntity::getLangModes()); // actions if ($this->isAuthorized('edit')) { $table->addAction('edit', 'Edit')->getElementPrototype()->class[] = 'ajax'; $form = $admin->createForm($this->basicFormFactory, 'Element'); $admin->connectFormWithAction($form, $table->getAction('edit')); } if ($this->isAuthorized('remove')) { $table->addAction('delete', 'Delete')->getElementPrototype()->class[] = 'ajax'; $admin->connectActionAsDelete($table->getAction('delete')); } $admin->onRender[] = function (AdminGrid $admin) { $qb = $admin->getRepository()->createQueryBuilder('a'); if (!$admin->parentFloor->floorId) { $qb = $qb->andWhere('a.layout IS NULL'); } else { $qb = $qb->andWhere('a.layout = :id')->setParameter('id', $admin->getParentFloor()->floorId); } $admin->getTable()->setModel(new Doctrine($qb)); }; return $admin; }
protected function createComponentTable() { $admin = new AdminGrid($this->tagRepository); // columns $table = $admin->getTable(); $table->setTranslator($this->translator); $table->addColumnText('name', 'Name')->setSortable()->getCellPrototype()->width = '100%'; // actions if ($this->isAuthorized('edit')) { $table->addAction('edit', 'Edit')->getElementPrototype()->class[] = 'ajax'; $repository = $this->tagRepository; $form = $admin->createForm($this->formFactory, 'Tag', function () use($repository) { return $repository->createNew(); }, \CmsModule\Components\Table\Form::TYPE_LARGE); $admin->connectFormWithAction($form, $table->getAction('edit')); // Toolbar $toolbar = $admin->getNavbar(); $toolbar->addSection('new', 'Create', 'file'); $admin->connectFormWithNavbar($form, $toolbar->getSection('new')); } if ($this->isAuthorized('remove')) { $table->addAction('delete', 'Delete')->getElementPrototype()->class[] = 'ajax'; $admin->connectActionAsDelete($table->getAction('delete')); } return $admin; }