private function addCalbacks() { $this->rowAction->addManipulateRender(function ($action, $row) { if ($row->getField('foo') == 0) { return null; } return $action; }); $this->rowAction->addManipulateRender(function ($action, $row) { if ($row->getField('bar') == 0) { return null; } return $action; }); }
/** * List all website config * * @throws AccessDeniedException If authenticate user is not allowed to access to this resource (minimum ROLE_ADMIN) * @return \Symfony\Component\HttpFoundation\Response */ public function listAction() { if (false === $this->get('security.authorization_checker')->isGranted('ROLE_ADMIN')) { throw new AccessDeniedException(); } // Set Datagrid source $source = new Entity($this->get('asf_website.config.manager')->getClassName()); $tableAlias = $source->getTableAlias(); $source->manipulateQuery(function ($query) use($tableAlias) { $query instanceof QueryBuilder; if (count($query->getDQLPart('orderBy')) == 0) { $query->orderBy($tableAlias . '.name', 'ASC'); } }); // Get Grid instance $grid = $this->get('grid'); $grid instanceof Grid; // Attach the source to the grid $grid->setSource($source); $grid->setId('asf_website_config_list'); // Columns configuration $grid->hideColumns(array('id')); $grid->getColumn('name')->setTitle($this->get('translator')->trans('Config name', array(), 'asf_website'))->setDefaultOperator('like')->setOperatorsVisible(false); $editAction = new RowAction('btn_edit', 'asf_website_config_edit'); $editAction->setRouteParameters(array('id')); $grid->addRowAction($editAction); $deleteAction = new RowAction('btn_delete', 'asf_website_config_delete', true); $deleteAction->setRouteParameters(array('id'))->setConfirmMessage($this->get('translator')->trans('Do you want to delete this config?', array(), 'asf_website')); $grid->addRowAction($deleteAction); $grid->setNoDataMessage($this->get('translator')->trans('No config was found.', array(), 'asf_website')); return $grid->getGridResponse('ASFWebsiteBundle:Config:list.html.twig'); }
/** * @return Response */ public function indexAction() { $source = new Entity('OpiferCmsBundle:Cron'); $editAction = new RowAction('edit', 'opifer_cms_cronjob_edit'); $editAction->setRouteParameters(['id']); $deleteAction = new RowAction('delete', 'opifer_cms_cronjob_delete'); $deleteAction->setRouteParameters(['id']); $grid = $this->get('grid'); $grid->setId('cronjobs')->setSource($source)->addRowAction($editAction)->addRowAction($deleteAction); $grid->getColumn('state')->manipulateRenderCell(function ($value, $row, $router) { switch ($value) { case Cron::STATE_RUNNING: $label = 'info'; break; case Cron::STATE_FINISHED: $label = 'success'; break; case Cron::STATE_TERMINATED: case Cron::STATE_CANCELED: case Cron::STATE_FAILED: $label = 'danger'; break; default: $label = 'default'; break; } return '<span class="label label-' . $label . '">' . $value . '</span>'; }); $grid->getColumn('state')->setSafe(false); return $grid->getGridResponse('OpiferCmsBundle:Backend/Cronjob:index.html.twig'); }
public function indexAction() { $data = array(); $source = new Entity('OjsJournalBundle:Publisher', 'application'); $tableAlias = $source->getTableAlias(); $source->manipulateQuery(function (QueryBuilder $query) use($tableAlias) { $query->andWhere($tableAlias . ".status = :status")->setParameter('status', 0); return $query; }); $grid = $this->get('grid')->setSource($source); $gridAction = $this->get('grid_action'); $grid->getColumn('status')->manipulateRenderCell(function ($value) { return $this->get('translator')->trans(Publisher::$statuses[$value]); }); $rowAction = array(); $saveAction = new RowAction('<i class="fa fa-save"></i>', 'ojs_admin_application_publisher_save'); $saveAction->setRouteParameters(['id']); $saveAction->setAttributes(['class' => 'btn btn-primary btn-xs', 'title' => $this->get('translator')->trans('institute.merge_as_new_institute')]); $rowAction[] = $saveAction; $rowAction[] = $gridAction->showAction('ojs_admin_application_publisher_show', 'id'); $rowAction[] = $gridAction->editAction('ojs_admin_application_publisher_edit', 'id'); $rowAction[] = $gridAction->deleteAction('ojs_admin_application_publisher_delete', 'id'); $actionColumn = new ActionsColumn("actions", 'actions'); $actionColumn->setRowActions($rowAction); $grid->addColumn($actionColumn); $data['grid'] = $grid; return $grid->getGridResponse('OjsAdminBundle:AdminApplication:publisher.html.twig', $data); }
/** * Lists all Issue entities. * * @param Request $request * @return Response */ public function indexAction(Request $request) { $journal = $this->get('ojs.journal_service')->getSelectedJournal(); $eventDispatcher = $this->get('event_dispatcher'); if (!$this->isGranted('VIEW', $journal, 'issues')) { throw new AccessDeniedException("You not authorized for this page!"); } $source = new Entity('OjsJournalBundle:Issue'); $grid = $this->get('grid')->setSource($source); $gridAction = $this->get('grid_action'); $actionColumn = new ActionsColumn("actions", 'actions'); $rowAction[] = $gridAction->showAction('ojs_journal_issue_show', ['id', 'journalId' => $journal->getId()]); $articleAction = new RowAction('<i class="fa fa-file-text"></i>', 'ojs_journal_issue_view'); $articleAction->setRouteParameters(['journalId' => $journal->getId(), 'id']); $articleAction->setAttributes(['class' => 'btn btn-success btn-xs ', 'data-toggle' => 'tooltip', 'title' => $this->get('translator')->trans("Articles")]); $rowAction[] = $articleAction; $lastIssueAction = new RowAction('<i class="fa fa-cog"></i>', 'ojs_journal_issue_make_last'); $lastIssueAction->setRouteParameters(['journalId' => $journal->getId(), 'id']); $lastIssueAction->setAttributes(['class' => 'btn btn-success btn-xs ', 'data-toggle' => 'tooltip', 'title' => $this->get('translator')->trans("make.last.issue")]); $rowAction[] = $lastIssueAction; if ($this->isGranted('EDIT', $journal, 'issues')) { $rowAction[] = $gridAction->editAction('ojs_journal_issue_edit', ['id', 'journalId' => $journal->getId()]); } if ($this->isGranted('DELETE', $journal, 'issues')) { $rowAction[] = $gridAction->deleteAction('ojs_journal_issue_delete', ['id', 'journalId' => $journal->getId()]); } $rowAction[] = $gridAction->filesAction('ojs_journal_issue_file_index', ['journalId' => $journal->getId(), 'id']); $actionColumn->setRowActions($rowAction); $grid->addColumn($actionColumn); $listEvent = new ListEvent(); $listEvent->setGrid($grid); $eventDispatcher->dispatch(IssueEvents::LISTED, $listEvent); $grid = $listEvent->getGrid(); return $grid->getGridResponse('OjsJournalBundle:Issue:index.html.twig'); }
/** * Index view of content by type * * @param int $type * @return Response */ public function typeAction($type) { $contentType = $this->get('opifer.content.content_type_manager')->getRepository()->find($type); if (!$contentType) { throw $this->createNotFoundException(sprintf('Content Type with ID %d could not be found.', $type)); } $queryBuilder = $this->get('opifer.content.content_manager')->getRepository()->createQueryBuilder('c')->select('c', 'vs', 'v', 'a')->leftJoin('c.valueSet', 'vs')->leftJoin('vs.values', 'v')->leftJoin('v.attribute', 'a'); $source = new Entity($this->getParameter('opifer_content.content_class')); $source->initQueryBuilder($queryBuilder); $tableAlias = $source->getTableAlias(); $source->manipulateQuery(function ($query) use($tableAlias, $contentType) { $query->andWhere($tableAlias . '.contentType = :contentType')->setParameter('contentType', $contentType); }); $designAction = new RowAction('button.design', 'opifer_content_contenteditor_design'); $designAction->setRouteParameters(['id', 'owner' => 'content']); $designAction->setRouteParametersMapping(['id' => 'ownerId']); $detailsAction = new RowAction('button.details', 'opifer_content_content_edit'); $detailsAction->setRouteParameters(['id']); //$deleteAction = new RowAction('button.delete', 'opifer_content_content_delete'); //$deleteAction->setRouteParameters(['id']); /* @var $grid \APY\DataGridBundle\Grid\Grid */ $grid = $this->get('grid'); $grid->setId('content')->setSource($source)->addRowAction($detailsAction)->addRowAction($designAction); //->addRowAction($deleteAction) foreach ($contentType->getSchema()->getAttributes() as $attribute) { $name = $attribute->getName(); $column = new AttributeColumn(['id' => $name, 'field' => 'valueSet.values.value', 'title' => $attribute->getDisplayName(), 'visible' => false, 'attribute' => $name, 'source' => true]); $column->manipulateRenderCell(function ($value, $row, $router) use($name) { $value = $row->getEntity()->getAttributes()[$name]; return $value; }); $grid->addColumn($column); } return $grid->getGridResponse($this->getParameter('opifer_content.content_type_view'), ['content_type' => $contentType, 'grid' => $grid]); }
/** * List all brands. * * @throws AccessDeniedException If authenticate user is not allowed to access to this resource (minimum ROLE_ADMIN) * * @return \Symfony\Component\HttpFoundation\Response */ public function listAction() { $this->get('event_dispatcher')->dispatch(ProductEvents::LIST_BRANDS, new Event()); // Set Datagrid source $source = new Entity($this->getParameter('asf_product.brand.entity')); $tableAlias = $source->getTableAlias(); $source->manipulateQuery(function ($query) use($tableAlias) { $query instanceof QueryBuilder; if (count($query->getDQLPart('orderBy')) == 0) { $query->orderBy($tableAlias . '.name', 'ASC'); } }); // Get Grid instance $grid = $this->get('grid'); $grid instanceof Grid; // Attach the source to the grid $grid->setSource($source); $grid->setId('asf_brands_list'); // Columns configuration $editAction = new RowAction('btn_edit', 'asf_product_brand_edit'); $editAction->setRouteParameters(array('id')); $grid->addRowAction($editAction); $deleteAction = new RowAction('btn_delete', 'asf_product_brand_delete', true); $deleteAction->setRouteParameters(array('id'))->setConfirmMessage($this->get('translator')->trans('asf.product.msg.delete.confirm', array('%name%' => $this->get('translator')->trans('asf.product.default_value.this_brand')))); $grid->addRowAction($deleteAction); $grid->setNoDataMessage($this->get('translator')->trans('asf.product.msg.list.no_brand')); return $grid->getGridResponse('ASFProductBundle:Brand:list.html.twig'); }
public function indexAction(Request $request) { $data = array(); $source = new Entity('OjsJournalBundle:Journal'); $source->manipulateRow(function (Row $row) use($request) { /* @var Journal $entity */ $entity = $row->getEntity(); $entity->setDefaultLocale($request->getDefaultLocale()); if (!is_null($entity)) { $row->setField('title', $entity->getTitle()); } return $row; }); $alias = $source->getTableAlias(); $source->manipulateQuery(function (QueryBuilder $query) use($alias) { $query->andWhere($alias . '.status = :status')->setParameter('status', JournalStatuses::STATUS_PREPARING); return $query; }); $grid = $this->get('grid')->setSource($source); $gridAction = $this->get('grid_action'); $saveAction = new RowAction('<i class="fa fa-save"></i>', 'ojs_admin_application_journal_save'); $saveAction->setRouteParameters(['id']); $saveAction->setAttributes(['class' => 'btn btn-primary btn-xs', 'title' => $this->get('translator')->trans('journal.merge_as_new_journal')]); $rowAction = array(); $rowAction[] = $saveAction; $rowAction[] = $gridAction->editAction('ojs_admin_application_journal_edit', 'id'); $rowAction[] = $gridAction->showAction('ojs_admin_application_journal_show', 'id'); $rowAction[] = $gridAction->deleteAction('ojs_admin_application_journal_delete', 'id'); $actionColumn = new ActionsColumn("actions", 'actions'); $actionColumn->setRowActions($rowAction); $grid->addColumn($actionColumn); $data['grid'] = $grid; return $grid->getGridResponse('OjsAdminBundle:AdminApplication:journal.html.twig', $data); }
/** * Lists all Issue entities. * * @param Request $request * @return Response */ public function indexAction(Request $request) { $journal = $this->get('ojs.journal_service')->getSelectedJournal(); if (!$this->isGranted('VIEW', $journal, 'issues')) { throw new AccessDeniedException("You are not authorized for view this journal's issues!"); } $source = new Entity('OjsJournalBundle:Issue'); $source->addHint(Query::HINT_CUSTOM_OUTPUT_WALKER, 'Gedmo\\Translatable\\Query\\TreeWalker\\TranslationWalker'); $ta = $source->getTableAlias(); $source->manipulateQuery(function (QueryBuilder $query) use($ta, $journal) { $query->andWhere($ta . '.journalId = :journal_id')->setParameter('journal_id', $journal->getId()); }); $grid = $this->get('grid')->setSource($source); $gridAction = $this->get('grid_action'); $actionColumn = new ActionsColumn("actions", 'actions'); $rowAction[] = $gridAction->showAction('ojs_journal_issue_show', ['id', 'journalId' => $journal->getId()]); $articleAction = new RowAction('<i class="fa fa-file-text"></i>', 'ojs_journal_issue_view'); $articleAction->setRouteParameters(['journalId' => $journal->getId(), 'id']); $articleAction->setAttributes(['class' => 'btn btn-success btn-xs ', 'data-toggle' => 'tooltip', 'title' => $this->get('translator')->trans("Articles")]); $rowAction[] = $articleAction; if ($this->isGranted('EDIT', $journal, 'issues')) { $rowAction[] = $gridAction->editAction('ojs_journal_issue_edit', ['id', 'journalId' => $journal->getId()]); } if ($this->isGranted('DELETE', $journal, 'issues')) { $rowAction[] = $gridAction->deleteAction('ojs_journal_issue_delete', ['id', 'journalId' => $journal->getId()]); } $actionColumn->setRowActions($rowAction); $grid->addColumn($actionColumn); $data = []; $data['grid'] = $grid; return $grid->getGridResponse('OjsJournalBundle:Issue:index.html.twig', $data); }
/** * @return Response */ public function indexAction() { $source = new Entity('OpiferMailingListBundle:MailingList'); $editAction = new RowAction('button.view', 'opifer_mailing_list_mailing_list_view'); $editAction->setRouteParameters(['id']); /* @var $grid \APY\DataGridBundle\Grid\Grid */ $grid = $this->get('grid'); $grid->setId('property')->setSource($source)->addRowAction($editAction); return $grid->getGridResponse('OpiferMailingListBundle:MailingList:index.html.twig'); }
/** * @return Response */ public function indexAction() { $source = new Entity('OpiferCmsBundle:Site'); $editAction = new RowAction('edit', 'opifer_cms_site_edit'); $editAction->setRouteParameters(['id']); $deleteAction = new RowAction('delete', 'opifer_cms_site_delete'); $deleteAction->setRouteParameters(['id']); $grid = $this->get('grid'); $grid->setId('sites')->setSource($source)->addRowAction($editAction)->addRowAction($deleteAction); return $grid->getGridResponse('OpiferCmsBundle:Backend/Site:index.html.twig'); }
/** * {@inheritdoc} */ public function indexAction() { $source = new Entity($this->getParameter('opifer_content.content_type_class')); $editAction = new RowAction('button.edit', 'opifer_content_contenttype_edit'); $editAction->setRouteParameters(['id']); $deleteAction = new RowAction('button.delete', 'opifer_content_contenttype_delete'); $deleteAction->setRouteParameters(['id']); /* @var $grid \APY\DataGridBundle\Grid\Grid */ $grid = $this->get('grid'); $grid->setId('content_types')->setSource($source)->addRowAction($editAction)->addRowAction($deleteAction); return $grid->getGridResponse('OpiferCmsBundle:Backend/ContentType:index.html.twig'); }
/** * @return Response */ public function indexAction() { $source = new Entity($this->get('opifer.review.review_manager')->getClass()); $editAction = new RowAction('button.edit', 'opifer_review_review_edit'); $editAction->setRouteParameters(['id']); $deleteAction = new RowAction('button.delete', 'opifer_review_review_delete'); $deleteAction->setRouteParameters(['id']); /* @var $grid \APY\DataGridBundle\Grid\Grid */ $grid = $this->get('grid'); $grid->setId('reviews')->setSource($source)->addRowAction($editAction)->addRowAction($deleteAction); return $grid->getGridResponse('OpiferCmsBundle:Backend/Review:index.html.twig'); }
/** * @Route("/") */ public function indexAction(Request $request) { $source = new Entity('ChamiloCourseBundle:CTool'); $course = $this->getCourse(); /* @var $grid \APY\DataGridBundle\Grid\Grid */ $grid = $this->get('grid'); $grid->setSource($source); //$grid->setLimits(5); /*$deleteMassAction = new MassAction( 'Delete', 'chamilo.controller.notebook:deleteMassAction', true, array('course' => $request->get('course')) ); $grid->addMassAction($deleteMassAction);*/ $myRowAction = new RowAction('View', 'chamilo_notebook_show', false, '_self', array('class' => 'btn btn-default')); $myRowAction->setRouteParameters(array('course' => $course, 'id')); $grid->addRowAction($myRowAction); /*$myRowAction = new RowAction( 'Edit', 'chamilo_notebook_edit', false, '_self', array('class' => 'btn btn-info') ); $myRowAction->setRouteParameters(array('course' => $course, 'id')); */ //$grid->addRowAction($myRowAction); /* $myRowAction = new RowAction( 'Delete', 'chamilo_notebook_delete', false, '_self', array('class' => 'btn btn-danger', 'form_delete' => true) ); $myRowAction->setRouteParameters(array('course' => $course, 'id')); $grid->addRowAction($myRowAction); */ /*$grid->addExport( new CSVExport( 'CSV Export', 'export', array('course' => $course) ) ); $grid->addExport( new ExcelExport( 'Excel Export', 'export', array('course' => $course) ) );*/ return $grid->getGridResponse('ChamiloNotebookBundle:Notebook:index.html.twig'); }
/** * The user index. * * @return Response */ public function indexAction() { $source = new Entity($this->container->getParameter('opifer_cms.user.class')); $editAction = new RowAction('edit', 'opifer_cms_user_edit'); $editAction->setRouteParameters(['id']); //$deleteAction = new RowAction('delete', 'opifer_cms_user_delete'); //$deleteAction->setRouteParameters(['id']); $grid = $this->get('grid'); $grid->setId('users')->setSource($source)->addRowAction($editAction); //->addRowAction($deleteAction); return $grid->getGridResponse('OpiferCmsBundle:Backend/User:index.html.twig'); }
/** * @return Response */ public function indexAction() { $source = new Entity('OpiferMailingListBundle:MailingList'); $editAction = new RowAction('button.edit', 'opifer_mailing_list_mailing_list_edit'); $editAction->setRouteParameters(['id']); $deleteAction = new RowAction('button.delete', 'opifer_mailing_list_mailing_list_delete', true, '_self'); $deleteAction->setConfirmMessage('Confirm deleting this entry?'); $deleteAction->setRouteParameters(['id']); /* @var $grid \APY\DataGridBundle\Grid\Grid */ $grid = $this->get('grid'); $grid->setId('property')->setSource($source)->addRowAction($editAction)->addRowAction($deleteAction); return $grid->getGridResponse('OpiferMailingListBundle:MailingList:index.html.twig'); }
/** * @return Response */ public function indexAction() { $source = new Entity('OpiferContentBundle:Template'); $editAction = new RowAction('button.edit', 'opifer_cms_template_edit'); $editAction->setRouteParameters(['id']); $deleteAction = new RowAction('button.delete', 'opifer_cms_template_delete'); $deleteAction->setRouteParameters(['id']); $designAction = new RowAction('button.design', 'opifer_content_contenteditor_design'); $designAction->setRouteParameters(['type' => 'template', 'id']); $grid = $this->get('grid'); /* @var $grid \APY\DataGridBundle\Grid\Grid */ $grid->setId('templates')->setSource($source)->addRowAction($editAction)->addRowAction($deleteAction)->addRowAction($designAction); return $grid->getGridResponse('OpiferCmsBundle:Backend/Template:index.html.twig'); }
/** * @Route("/") */ public function indexAction(Request $request) { $source = new Entity('ChamiloNotebookBundle:CNotebook'); $course = $this->getCourse(); /* @var $grid \APY\DataGridBundle\Grid\Grid */ $grid = $this->get('grid'); /*$tableAlias = $source->getTableAlias(); $source->manipulateQuery(function (QueryBuilder $query) use ($tableAlias, $course) { $query->andWhere($tableAlias . '.cId = '.$course->getId()); //$query->resetDQLPart('orderBy'); } );*/ /** @var NotebookRepository $repository */ $repository = $this->getRepository(); $resources = $repository->getResourceByCourse($course); $source->setData($resources); $grid->setSource($source); //$grid->hideFilters(); $grid->setLimits(5); //$grid->isReadyForRedirect(); //$grid->setMaxResults(1); //$grid->setLimits(2); /*$grid->getColumn('id')->manipulateRenderCell( function ($value, $row, $router) use ($course) { //$router = $this->get('router'); return $router->generate( 'chamilo_notebook_show', array('id' => $row->getField('id'), 'course' => $course) ); } );*/ if ($this->isGranted(ResourceNodeVoter::ROLE_CURRENT_COURSE_TEACHER)) { $deleteMassAction = new MassAction('Delete', 'chamilo.controller.notebook:deleteMassAction', true, array('course' => $request->get('course'))); $grid->addMassAction($deleteMassAction); } $myRowAction = new RowAction($this->trans('View'), 'chamilo_notebook_show', false, '_self', array('class' => 'btn btn-default')); $myRowAction->setRouteParameters(array('course' => $course, 'id')); $grid->addRowAction($myRowAction); if ($this->isGranted(ResourceNodeVoter::ROLE_CURRENT_COURSE_TEACHER)) { $myRowAction = new RowAction($this->trans('Edit'), 'chamilo_notebook_edit', false, '_self', array('class' => 'btn btn-info')); $myRowAction->setRouteParameters(array('course' => $course, 'id')); $grid->addRowAction($myRowAction); $myRowAction = new RowAction($this->trans('Delete'), 'chamilo_notebook_delete', false, '_self', array('class' => 'btn btn-danger', 'form_delete' => true)); $myRowAction->setRouteParameters(array('course' => $course, 'id')); $grid->addRowAction($myRowAction); } $grid->addExport(new CSVExport($this->trans('CSV Export'), 'export', array('course' => $course))); $grid->addExport(new ExcelExport($this->trans('Excel Export'), 'export', array('course' => $course))); return $grid->getGridResponse('ChamiloNotebookBundle:Notebook:index.html.twig'); }
/** * List all identities * * @return Symfony\Component\HttpFoundation\Response */ public function listAction() { if ($this->getParameter('asf_contact.secure_controller') !== false && false === $this->get('security.authorization_checker')->isGranted($this->getParameter('asf_contact.secure_controller'))) { throw new AccessDeniedException('You don\'t have permission to access this resource.'); } // Initialize variables $view_options = array(); $identityManager = $this->get('asf_contact.identity.manager'); // Set Datagrid source $source = new Entity($identityManager->getClassName()); $tableAlias = $source->getTableAlias(); $source->manipulateQuery(function ($query) use($tableAlias) { $query instanceof QueryBuilder; if (count($query->getDQLPart('orderBy')) == 0) { $query->orderBy($tableAlias . '.name', 'ASC'); } }); // Get Grid instance $grid = $this->get('grid'); $grid instanceof Grid; // Attach the source to the grid $grid->setSource($source); $grid->setId('asf_contact_identity'); // Columns configuration $grid->hideColumns(array('id', 'updatedAt', 'createdAt')); $nameColumn = $grid->getColumn('name'); $nameColumn->setTitle($this->get('translator')->trans('Name', array(), 'asf_contact'))->setDefaultOperator('like')->setOperatorsVisible(false); $emailColumn = $grid->getColumn('emailCanonical'); $emailColumn->setTitle($this->get('translator')->trans('E-mail', array(), 'asf_contact'))->setDefaultOperator('like')->setOperatorsVisible(false); $stateColumn = $grid->getColumn('state'); $stateColumn->setTitle($this->get('translator')->trans('State', array(), 'asf_contact'))->setSize(100)->setFilterType('select')->setDefaultOperator('like')->setOperatorsVisible(false)->setSelectFrom('values')->setValues(array(IdentityModel::STATE_ENABLED => $this->get('translator')->trans('Activated', array(), 'asf_contact'), IdentityModel::STATE_DISABLED => $this->get('translator')->trans('Deactivated', array(), 'asf_contact'))); $editAction = new RowAction('btn_edit', 'asf_contact_identity_edit'); $editAction->setRouteParameters(array('id')); $grid->addRowAction($editAction); $deleteAction = new RowAction('btn_delete', 'asf_contact_identity_delete', true); $deleteAction->setRouteParameters(array('id'))->setConfirmMessage($this->get('translator')->trans('Do you want to delete this identity ?', array(), 'asf_contact')); $grid->addRowAction($deleteAction); $typeColumn = $grid->getColumn('type'); $typeColumn->setTitle($this->get('translator')->trans('Type', array(), 'asf_contact'))->setFilterType('select')->setDefaultOperator('eq')->setOperatorsVisible(false)->setSelectFrom('values')->setValues(array(IdentityModel::TYPE_PERSON => $this->get('translator')->trans('Person', array(), 'asf_contact'), IdentityModel::TYPE_ORGANIZATION => $this->get('translator')->trans('Organization', array(), 'asf_contact')))->manipulateRenderCell(function ($value, $row, $router) { if ($value == IdentityModel::TYPE_PERSON) { return $this->get('translator')->trans('Person', array(), 'asf_contact'); } elseif ($value == IdentityModel::TYPE_ORGANIZATION) { return $this->get('translator')->trans('Organization', array(), 'asf_contact'); } }); $grid->setNoDataMessage($this->get('translator')->trans('No contact in the address book.', array(), 'asf_contact')); // Display grid return $grid->getGridResponse('ASFContactBundle:Identity:list.html.twig', $view_options); }
public function listAction() { $source = new Entity('OpiferCmsBundle:Post'); $formColumn = new TextColumn(['id' => 'posts', 'title' => 'Form', 'source' => false, 'filterable' => false, 'sortable' => false, 'safe' => false]); $formColumn->manipulateRenderCell(function ($value, $row, $router) { return '<a href="' . $this->generateUrl('opifer_form_form_edit', ['id' => $row->getEntity()->getForm()->getId()]) . '">' . $row->getEntity()->getForm()->getName() . '</a>'; }); $viewAction = new RowAction('view', 'opifer_form_post_view'); $viewAction->setRouteParameters(['id']); $deleteAction = new RowAction('delete', 'opifer_form_post_delete'); $deleteAction->setRouteParameters(['id']); $grid = $this->get('grid'); $grid->setId('posts')->setSource($source)->addColumn($formColumn, 2)->addRowAction($viewAction)->addRowAction($deleteAction); return $grid->getGridResponse('OpiferCmsBundle:Backend/Post:list.html.twig'); }
/** * @return Response */ public function indexAction() { $source = new Entity($this->get('opifer.form.form_manager')->getClass()); $postsColumn = new TextColumn(['id' => 'posts', 'title' => 'Posts', 'source' => false, 'filterable' => false, 'sortable' => false, 'safe' => false]); $postsColumn->manipulateRenderCell(function ($value, $row, $router) { return '<a href="' . $this->generateUrl('opifer_form_post_index', ['formId' => $row->getEntity()->getId()]) . '">' . count($row->getEntity()->getPosts()) . ' posts</a>'; }); $editAction = new RowAction('button.edit', 'opifer_form_form_edit'); $editAction->setRouteParameters(['id']); $deleteAction = new RowAction('button.delete', 'opifer_form_form_delete'); $deleteAction->setRouteParameters(['id']); /* @var $grid \APY\DataGridBundle\Grid\Grid */ $grid = $this->get('grid'); $grid->setId('forms')->setSource($source)->addColumn($postsColumn)->addRowAction($editAction)->addRowAction($deleteAction); return $grid->getGridResponse('OpiferCmsBundle:Backend/Form:index.html.twig'); }
public function lister_utilisateurAction() { if (false === $this->get('security.authorization_checker')->isGranted('ROLE_ADMIN') && false === $this->get('security.authorization_checker')->isGranted('ROLE_SUPER_ADMIN')) { throw new AccessDeniedException(); } // Creates a simple grid based on your entity (ORM) $source = new Entity('ROUtilisateurBundle:Utilisateur'); // Get a Grid instance $grid = $this->get('grid'); //Récupération du repository utilisateur $utilisateurRepository = $this->getDoctrine()->getManager()->getRepository('ROUtilisateurBundle:Utilisateur'); //Dire au dataGrid que la source sera différente du paramétrage onnataion de l'entité modéle $utilisateurQueryBuilder = $utilisateurRepository->loadUserForGrid(); $source->initQueryBuilder($utilisateurQueryBuilder); //Création de la colonne avec les roles concaténé $rolesColumn = new TextColumn(array('id' => 'concatNomRole', 'title' => 'Rôles', 'filterable' => false, 'sortable' => false)); $grid->addColumn($rolesColumn); // Attach the source to the grid $grid->setSource($source); //Création de la possiblité d'exporter le listing au format CSV $grid->addExport(new CSVExport('CSV Export', 'Export utilisateur CSV')); $grid->addExport(new ExcelExport('XLS Export', 'Export utilisateur XLS')); //Message a afficher si la valeur de l'attribut est vide $grid->setNoDataMessage(' - '); //Message a afficher si le listing ne contient aucune ligne $grid->setNoResultMessage('Aucun resultat trouvé'); //GESTION DES ACTION DE LA COLONNE DE DROITE //Ajout de l'action d'ajout utilisateur $rowDetailAction = new RowAction('', 'ro_utilisateur_detail', false, '_self', array('class' => 'btn btn-primary'), array('class' => 'glyphicon glyphicon-eye-open', 'title' => 'Détail utilisateur')); $grid->addRowAction($rowDetailAction); //Ajout de l'action de modification utilisateur $rowUpdateAction = new RowAction('', 'ro_utilisateur_edit', false, '_self', array('class' => 'btn btn-success'), array('class' => 'glyphicon glyphicon-edit glyphicon-white', 'title' => 'Modifier utilisateur')); $grid->addRowAction($rowUpdateAction); //Ajout de l'action de suppression utilisateur $rowDeleteAction = new RowAction('', 'ro_utilisateur_delete', true, '_self', array('class' => 'btn btn-danger'), array('class' => 'glyphicon glyphicon-trash glyphicon-white', 'title' => 'Supprimer utilisateur')); //Message de confirmation de suppression $rowDeleteAction->setConfirmMessage('Etes vous sur de vouloir supprimer cet utilisateur ?'); $grid->addRowAction($rowDeleteAction); //GESTION DES MASS ACTION //Mass action,traitement sur plusieur ligne en les cochant,ici on crée un bouton de suppresssion $grid->addMassAction(new DeleteMassAction()); // Return the response of the grid to the template return $grid->getGridResponse('ROUtilisateurBundle:utilisateur:lister_utilisateur.html.twig'); }
/** * List all categories. * * @throws AccessDeniedException If authenticate user is not allowed to access to this resource (minimum ROLE_ADMIN) * * @return \Symfony\Component\HttpFoundation\Response */ public function listAction() { $this->get('event_dispatcher')->dispatch(ProductEvents::LIST_CATEGORIES, new Event()); // Set Datagrid source $source = new Entity($this->getParameter('asf_product.category.entity')); $tableAlias = $source->getTableAlias(); $user = $this->getUser(); $source->manipulateQuery(function ($query) use($tableAlias, $user) { $query instanceof QueryBuilder; $states = array(CategoryModel::STATE_DRAFT, CategoryModel::STATE_WAITING, CategoryModel::STATE_PUBLISHED); if (in_array(UserRole::ROLE_SUPERADMIN, $user->getRoles())) { $states[] = CategoryModel::STATE_DELETED; } $query->add('where', $query->expr()->in($tableAlias . '.state', $states)); if (count($query->getDQLPart('orderBy')) == 0) { $query->orderBy($tableAlias . '.name', 'ASC'); } }); // Get Grid instance $grid = $this->get('grid'); $grid instanceof Grid; // Attach the source to the grid $grid->setSource($source); $grid->setId('asf_categories_list'); $source->manipulateRow(function ($row) { if (CategoryModel::STATE_DELETED === $row->getField('state')) { $row->setClass('danger'); } elseif (CategoryModel::STATE_WAITING === $row->getField('state')) { $row->setClass('info'); } elseif (CategoryModel::STATE_DRAFT === $row->getField('state')) { $row->setClass('warning'); } return $row; }); // Columns configuration $editAction = new RowAction('btn_edit', 'asf_product_category_edit'); $editAction->setRouteParameters(array('id')); $grid->addRowAction($editAction); $deleteAction = new RowAction('btn_delete', 'asf_product_category_delete', true); $deleteAction->setRouteParameters(array('id'))->setConfirmMessage($this->get('translator')->trans('asf.product.msg.delete.confirm', array('%name%' => $this->get('translator')->trans('asf.product.default_value.this_category')))); $grid->addRowAction($deleteAction); $grid->setNoDataMessage($this->get('translator')->trans('asf.product.msg.list.no_category', array(), 'asf_product')); return $grid->getGridResponse('ASFProductBundle:Category:list.html.twig'); }
/** * @Route("/") */ public function indexAction() { $breadCrumb = $this->get('chamilo_core.block.breadcrumb'); $breadCrumb->addChild($this->trans('Introduction')); // Creates a simple grid based on your entity (ORM) $source = new Entity('ChamiloCourseBundle:CToolIntro'); // Get a Grid instance $grid = $this->get('grid'); // Attach the source to the grid $grid->setSource($source); $rowUpdateAction = new RowAction($this->trans('Update'), 'chamilo_course_ctoolintro_update', false, '_self', ['class' => 'btn'], null); $rowUpdateAction->setRouteParameters(['iid', 'course' => $this->getCourse()->getCode()]); $rowAction = new RowAction($this->trans('Delete'), 'chamilo_course_ctoolintro_delete', true, '_self', ['class' => 'btn'], null); $rowAction->setRouteParameters(['iid', 'course' => $this->getCourse()->getCode()]); $grid->addRowAction($rowUpdateAction); $grid->addRowAction($rowAction); // Return the response of the grid to the template return $grid->getGridResponse('ChamiloCourseBundle:CToolIntro:grid.html.twig'); }
/** * @return Response */ public function indexAction() { $source = new Entity('OpiferCmsBundle:Template'); $editAction = new RowAction('edit', 'opifer_cms_template_edit'); $editAction->setRouteParameters(['id']); $deleteAction = new RowAction('delete', 'opifer_cms_template_delete'); $deleteAction->setRouteParameters(['id']); $attributesColumn = new TextColumn(['id' => 'attributes', 'Attributes', 'source' => false, 'filterable' => false, 'sortable' => false, 'safe' => false]); $attributesColumn->manipulateRenderCell(function ($value, $row, $router) { $html = ''; foreach ($row->getEntity()->getAttributes() as $attribute) { $html .= '<span class="label label-primary" style="display:inline-block">' . $attribute->getDisplayName() . '</span>'; } return $html; }); $grid = $this->get('grid'); $grid->setId('templates')->setSource($source)->addColumn($attributesColumn)->addRowAction($editAction)->addRowAction($deleteAction); return $grid->getGridResponse('OpiferCmsBundle:Backend/Template:index.html.twig'); }
/** * Index * * @param Request $request * * @return Response */ public function indexAction(Request $request) { // Creates simple grid based on your entity (ORM) $source = new Entity('OpiferContentBundle:Template'); $grid = $this->get('grid'); $rowAction = new RowAction('link.edit', 'opifer_content_template_index'); $rowAction->setRouteParameters(['id']); $editorAction = new RowAction('link.editor', 'opifer_content_template_editor'); $editorAction->setRouteParameters(['id']); $deleteAction = new RowAction('link.delete', 'opifer.crud.delete', true, '_self', array('class' => 'grid_delete_action text-danger')); $deleteAction->setRouteParameters(['slug' => 'templates', 'id'])->setRouteParametersMapping(['id' => 'id'])->manipulateRender(function ($action, $row) { $action->setConfirmMessage('Delete template' . $row->getField('name') . '?'); return $action; }); $massDeleteAction = new DeleteMassAction(); $massDeleteAction->setTitle('link.delete'); $grid->setId('templates')->setSource($source)->setPersistence(true)->setDefaultOrder('id', 'desc')->addRowAction($rowAction)->addRowAction($deleteAction)->addRowAction($editorAction)->addMassAction($massDeleteAction)->setVisibleColumns(['id', 'name', 'displayName']); $grid->isReadyForRedirect(); return $grid->getGridResponse('OpiferContentBundle:Template:index.html.twig', ['title' => 'title.templates']); }
/** * {@inheritdoc} */ public function sharedAction() { $this->getDoctrine()->getManager()->getFilters()->disable('draft'); $source = new Entity('OpiferContentBundle:Block'); $tableAlias = $source->getTableAlias(); $source->manipulateQuery(function ($query) use($tableAlias) { $query->andWhere("{$tableAlias}.shared = 1")->andWhere("{$tableAlias}.content IS NULL")->andWhere("{$tableAlias}.template IS NULL"); }); // // $idColumn = new NumberColumn(array('id' => 'id', 'field' => 'id', 'title' => 'label.id')); // $nameColumn = new TextColumn(array('id' => 'name', 'field' => 'sharedName', 'title' => 'label.name')); // $displayNameColumn = new TextColumn(array('id' => 'display_name', 'field' => 'sharedDisplayName', 'title' => 'label.display_name')); $editAction = new RowAction('button.edit', 'opifer_content_block_shared_edit'); $editAction->setRouteParameters(['id']); $deleteAction = new RowAction('button.delete', 'opifer_content_block_delete'); $deleteAction->setRouteParameters(['id']); /* @var $grid \APY\DataGridBundle\Grid\Grid */ $grid = $this->get('grid'); $grid->setId('blocks')->setSource($source)->setVisibleColumns(['id', 'sharedName', 'sharedDisplayName'])->addRowAction($editAction)->addRowAction($deleteAction); return $grid->getGridResponse('OpiferCmsBundle:Backend/Block:shared.html.twig'); }
/** * Lists all User entities. * @return Response */ public function indexAction() { if (!$this->isGranted('VIEW', new User())) { throw new AccessDeniedException("You are not authorized for this page!"); } $source = new Entity("OjsUserBundle:User"); $grid = $this->get('grid'); $gridAction = $this->get('grid_action'); $grid->setSource($source); $passwordAction = new RowAction('<i class="fa fa-key"></i>', 'ojs_admin_user_password'); $passwordAction->setRouteParameters('id'); $passwordAction->setAttributes(['class' => 'btn btn-info btn-xs', 'data-toggle' => 'tooltip', 'title' => $this->get('translator')->trans('title.password_change')]); $actionColumn = new ActionsColumn("actions", 'actions'); $rowAction[] = $gridAction->showAction('ojs_admin_user_show', 'id'); $rowAction[] = $gridAction->editAction('ojs_admin_user_edit', 'id'); $rowAction[] = $passwordAction; $rowAction[] = $gridAction->userBanAction(); $rowAction[] = $gridAction->deleteAction('ojs_admin_user_delete', 'id'); $actionColumn->setRowActions($rowAction); $grid->addColumn($actionColumn); return $grid->getGridResponse('OjsAdminBundle:AdminUser:index.html.twig', ['grid' => $grid]); }
/** * @Route("/") */ public function indexAction(Request $request) { $source = new Entity('ChamiloNotebookBundle:CNotebook'); $course = $this->getCourse(); /* @var $grid \APY\DataGridBundle\Grid\Grid */ $grid = $this->get('grid'); /** @var NotebookRepository $repository */ $repository = $this->getRepository(); $resources = $repository->getResourceByCourse($course); $source->setData($resources); $grid->setSource($source); //$grid->hideFilters(); $grid->setLimits(5); //$grid->isReadyForRedirect(); // Delete Mass if ($this->isGranted(ResourceNodeVoter::ROLE_CURRENT_COURSE_TEACHER)) { $deleteMassAction = new MassAction('Delete', 'chamilo_notebook.controller.notebook:deleteMassAction', true, array('course' => $request->get('course'))); $grid->addMassAction($deleteMassAction); } // Show $myRowAction = new RowAction($this->trans('View'), 'chamilo_notebook_show', false, '_self', array('class' => 'btn btn-default')); $myRowAction->setRouteParameters(array('course' => $course, 'id')); $grid->addRowAction($myRowAction); if ($this->isGranted(ResourceNodeVoter::ROLE_CURRENT_COURSE_TEACHER)) { // Edit $myRowAction = new RowAction($this->trans('Edit'), 'chamilo_notebook_edit', false, '_self', array('class' => 'btn btn-info')); $myRowAction->setRouteParameters(array('course' => $course, 'id')); $grid->addRowAction($myRowAction); // Delete $myRowAction = new RowAction($this->trans('Delete'), 'chamilo_notebook_delete', false, '_self', array('class' => 'btn btn-danger', 'form_delete' => true)); $myRowAction->setRouteParameters(array('course' => $course, 'id')); $grid->addRowAction($myRowAction); } // Exports $grid->addExport(new CSVExport($this->trans('CSV Export'), 'export', array('course' => $course))); $grid->addExport(new ExcelExport($this->trans('Excel Export'), 'export', array('course' => $course))); return $grid->getGridResponse('ChamiloNotebookBundle:Notebook:index.html.twig'); }
/** * Lists all Issue entities. * * @param Request $request * @return Response */ public function indexAction(Request $request) { $journal = $this->get('ojs.journal_service')->getSelectedJournal(); if (!$this->isGranted('VIEW', $journal, 'issues')) { throw new AccessDeniedException("You not authorized for this page!"); } $source = new Entity('OjsJournalBundle:Issue'); $source->manipulateRow(function (Row $row) use($request) { /** @var Issue $entity */ $entity = $row->getEntity(); $entity->setDefaultLocale($request->getDefaultLocale()); if (!is_null($entity)) { $row->setField('title', $entity->getTitle()); $row->setField('description', $entity->getDescription()); } return $row; }); $grid = $this->get('grid')->setSource($source); $gridAction = $this->get('grid_action'); $actionColumn = new ActionsColumn("actions", 'actions'); $rowAction[] = $gridAction->showAction('ojs_journal_issue_show', ['id', 'journalId' => $journal->getId()]); $articleAction = new RowAction('<i class="fa fa-file-text"></i>', 'ojs_journal_issue_view'); $articleAction->setRouteParameters(['journalId' => $journal->getId(), 'id']); $articleAction->setAttributes(['class' => 'btn btn-success btn-xs ', 'data-toggle' => 'tooltip', 'title' => $this->get('translator')->trans("Articles")]); $rowAction[] = $articleAction; if ($this->isGranted('EDIT', $journal, 'issues')) { $rowAction[] = $gridAction->editAction('ojs_journal_issue_edit', ['id', 'journalId' => $journal->getId()]); } if ($this->isGranted('DELETE', $journal, 'issues')) { $rowAction[] = $gridAction->deleteAction('ojs_journal_issue_delete', ['id', 'journalId' => $journal->getId()]); } $actionColumn->setRowActions($rowAction); $grid->addColumn($actionColumn); $data = []; $data['grid'] = $grid; return $grid->getGridResponse('OjsJournalBundle:Issue:index.html.twig', $data); }