Example #1
0
 /**
  * @return \Venne\System\Components\AdminGrid\AdminGrid
  */
 protected function createComponentTable()
 {
     $qb = $this->notificationSettingRepository->createQueryBuilder('a')->andWhere('a.user = :user')->setParameter('user', $this->presenter->user->identity->getId());
     $admin = $this->adminGridFactory->create($this->notificationSettingRepository);
     $table = $admin->getTable();
     $table->setTranslator($this->translator);
     $table->setModel(new Doctrine($qb));
     // columns
     $table->addColumnText('user', 'User')->getCellPrototype()->width = '15%';
     $table->addColumnText('type', 'Type')->setSortable()->setCustomRender(function (NotificationSetting $entity) {
         return $entity->type !== null ? $this->notificationManager->getType($entity->type->type)->getHumanName() : '';
     })->getCellPrototype()->width = '20%';
     $table->addColumnText('action', 'Action')->setCustomRender(function (NotificationSetting $entity) {
         return $entity->type !== null ? $entity->type->action : '';
     })->getCellPrototype()->width = '15%';
     $table->addColumnText('target', 'Target')->getCellPrototype()->width = '20%';
     $table->addColumnText('targetKey', 'Target key')->getCellPrototype()->width = '10%';
     $table->addColumnText('targetUser', 'Target user')->getCellPrototype()->width = '20%';
     // actions
     $event = $table->addActionEvent('edit', 'Edit');
     $event->getElementPrototype()->class[] = 'ajax';
     $form = $admin->addForm('notification', 'Notification setting', function (NotificationSetting $notificationSetting = null) {
         return $this->notificationSettingFormService->getFormFactory($notificationSetting !== null ? $notificationSetting->getId() : null);
     });
     $admin->connectFormWithAction($form, $event);
     // Toolbar
     $toolbar = $admin->getNavbar();
     $section = $toolbar->addSection('new', 'Create', 'file');
     $admin->connectFormWithNavbar($form, $section);
     $deleteEvent = $table->addActionEvent('delete', 'Delete');
     $deleteEvent->getElementPrototype()->class[] = 'ajax';
     $admin->connectActionAsDelete($deleteEvent);
     return $admin;
 }
Example #2
0
 /**
  * @return \Venne\System\Components\AdminGrid\AdminGrid
  */
 protected function createComponentTable()
 {
     $admin = $this->adminGridFactory->create($this->userRepository);
     $table = $admin->getTable();
     $table->setTranslator($this->translator);
     $table->addColumnText('email', 'E-mail')->setSortable()->getCellPrototype()->width = '100%';
     $table->getColumn('email')->setFilterText()->setSuggestion();
     $form = $admin->addForm('user', 'User', function (User $user = null) {
         return $this->getUserType()->getFormService()->getFormFactory($user ? $user->getId() : null);
     }, Form::TYPE_LARGE);
     $form->onSuccess[] = function () {
         $this->flashMessage('User has been saved.', 'success');
         $this->redrawControl('flashes');
     };
     $form->onError[] = function () {
         $this->flashMessage('Failed.', 'warning');
         $this->redrawControl('flashes');
     };
     $providerForm = $admin->addForm('loginProviders', 'Login providers', $this->providersForm, null, Form::TYPE_LARGE);
     $toolbar = $admin->getNavbar();
     $section = $toolbar->addSection('new', 'Create', 'user');
     $editAction = $table->addActionEvent('edit', 'Edit');
     $editAction->getElementPrototype()->class[] = 'ajax';
     $loginProviders = $table->addActionEvent('loginProviders', 'Login providers');
     $loginProviders->getElementPrototype()->class[] = 'ajax';
     $deleteAction = $table->addActionEvent('delete', 'Delete');
     $deleteAction->getElementPrototype()->class[] = 'ajax';
     $admin->connectFormWithAction($form, $editAction, $admin::MODE_PLACE);
     $admin->connectFormWithAction($providerForm, $loginProviders);
     $admin->connectActionAsDelete($deleteAction);
     foreach ($this->securityManager->getUserTypes() as $type => $value) {
         $admin->connectFormWithNavbar($form, $section->addSection(str_replace('\\', '_', $type), $value->getName()), $admin::MODE_PLACE);
     }
     return $admin;
 }
Example #3
0
 /**
  * @return \Venne\System\Components\AdminGrid\AdminGrid
  */
 protected function createComponentTable()
 {
     $admin = $this->adminGridFactory->create($this->jobRepository);
     $table = $admin->getTable();
     $table->addColumnText('type', 'Type')->getCellPrototype()->width = '35%';
     $table->addColumnText('state', 'State')->getCellPrototype()->width = '15%';
     $table->addColumnText('priority', 'Priority')->getCellPrototype()->width = '10%';
     $table->addColumnDate('date', 'Date')->getCellPrototype()->width = '15%';
     $table->addColumnDate('dateInterval', 'Interval')->getCellPrototype()->width = '15%';
     $table->addColumnDate('round', 'Round')->getCellPrototype()->width = '10%';
     // actions
     $table->addActionEvent('run', 'Run')->onClick[] = function ($id) {
         $job = $this->jobRepository->find($id);
         try {
             $this->jobManager->scheduleJob($job, JobManager::PRIORITY_REALTIME);
             $this->flashMessage($this->getTranslator()->translate('Job has been done.'), 'success');
         } catch (JobFailedException $e) {
             $this->flashMessage($this->getTranslator()->translate('Job failed.'), 'warning');
         }
         $this->redirect('this');
     };
     $table->addActionEvent('edit', 'Edit')->getElementPrototype()->class[] = 'ajax';
     $form = $admin->addForm('job', 'Job', function (Job $job = null) {
         return $this->jobFormService->getFormFactory($job !== null ? $job->getId() : null);
     });
     $admin->connectFormWithAction($form, $table->getAction('edit'));
     $table->addActionEvent('delete', 'Delete')->getElementPrototype()->class[] = 'ajax';
     $admin->connectActionAsDelete($table->getAction('delete'));
     return $admin;
 }
Example #4
0
 /**
  * @return \Venne\System\Components\AdminGrid\AdminGrid
  */
 public function create()
 {
     $admin = $this->adminGridFactory->create($this->invitationRepository);
     $qb = $this->invitationRepository->createQueryBuilder('a')->andWhere('a.author = :author')->setParameter('author', $this->netteUser->identity->getId());
     $table = $admin->getTable();
     $table->setModel(new Doctrine($qb));
     $table->setTranslator($this->translator);
     $table->addColumnText('email', 'E-mail')->setSortable()->getCellPrototype()->width = '60%';
     $table->getColumn('email')->setFilterText()->setSuggestion();
     $table->addColumnText('type', 'Type')->setCustomRender(function (Invitation $invitationEntity) {
         return $invitationEntity->registration->getName();
     })->getCellPrototype()->width = '40%';
     $form = $admin->addForm('invitation', 'Invitation', function (Invitation $invitation = null) {
         return $this->invitationFormService->getFormFactory($invitation !== null ? $invitation->getId() : null);
     });
     $toolbar = $admin->getNavbar();
     $newSection = $toolbar->addSection('new', 'Create', 'file');
     $editAction = $table->addActionEvent('edit', 'Edit');
     $editAction->getElementPrototype()->class[] = 'ajax';
     $deleteAction = $table->addActionEvent('delete', 'Delete');
     $deleteAction->getElementPrototype()->class[] = 'ajax';
     $admin->connectFormWithNavbar($form, $newSection);
     $admin->connectFormWithAction($form, $editAction);
     $admin->connectActionAsDelete($deleteAction);
     return $admin;
 }
Example #5
0
 /**
  * @return \Venne\System\Components\AdminGrid\AdminGrid
  */
 public function create()
 {
     $admin = $this->adminGridFactory->create($this->roleRepository);
     $table = $admin->getTable();
     $table->setTranslator($this->translator);
     $name = $table->addColumnText('name', 'Name');
     $name->setSortable()->getCellPrototype()->width = '40%';
     $name->setFilterText()->setSuggestion();
     $table->addColumnText('parent', 'Parent')->setSortable()->setCustomRender(function (Role $entity) {
         $entities = array();
         $en = $entity;
         while ($en = $en->getParent()) {
             $entities[] = $en->getName();
         }
         return implode(', ', $entities);
     })->getCellPrototype()->width = '60%';
     $form = $admin->addForm('role', 'Role', function (Role $role = null) {
         return $this->roleFormService->getFormFactory($role ? $role->getId() : null);
     });
     $toolbar = $admin->getNavbar();
     $newSection = $toolbar->addSection('new', 'Create', 'file');
     $editAction = $table->addActionEvent('edit', 'Edit');
     $editAction->getElementPrototype()->class[] = 'ajax';
     $permissionAction = $table->addActionEvent('permissions', 'Permissions');
     $permissionAction->getElementPrototype()->class[] = 'ajax';
     $deleteAction = $table->addActionEvent('delete', 'Delete');
     $deleteAction->getElementPrototype()->class[] = 'ajax';
     $admin->connectFormWithNavbar($form, $newSection);
     $admin->connectFormWithAction($form, $editAction);
     $admin->connectActionAsDelete($deleteAction);
     return $admin;
 }
Example #6
0
 /**
  * @return \Venne\System\Components\AdminGrid\AdminGrid
  */
 public function create()
 {
     $admin = $this->adminGridFactory->create($this->registrationRepository);
     $table = $admin->getTable();
     $table->setTranslator($this->translator);
     $table->addColumnText('name', 'Name')->setSortable()->getCellPrototype()->width = '100%';
     $table->getColumn('name')->setFilterText()->setSuggestion();
     $form = $admin->addForm('registration', 'Registration', function (Registration $registration = null) {
         return $this->registrationFormService->getFormFactory($registration !== null ? $registration->getId() : null);
     });
     $toolbar = $admin->getNavbar();
     $newSection = $toolbar->addSection('new', 'Create', 'file');
     $editAction = $table->addActionEvent('edit', 'Edit');
     $editAction->getElementPrototype()->class[] = 'ajax';
     $deleteAction = $table->addActionEvent('delete', 'Delete');
     $deleteAction->getElementPrototype()->class[] = 'ajax';
     $admin->connectFormWithNavbar($form, $newSection);
     $admin->connectFormWithAction($form, $editAction);
     $admin->connectActionAsDelete($deleteAction);
     return $admin;
 }
Example #7
0
 /**
  * @return \Venne\System\Components\AdminGrid\AdminGrid
  */
 protected function createTable()
 {
     $admin = $this->adminGridFactory->create($this->fileRepository);
     $admin->onRender[] = function (AdminGrid $admin) {
         $admin->getTable()->setTemplateFile(__DIR__ . '/Grido.latte');
     };
     $admin->onError[] = function (AdminGrid $admin, \Exception $e) {
         $this->onError($this, $e);
     };
     $table = $admin->getTable();
     $table->addColumnText('name', 'Name');
     $table->setDefaultPerPage(99999999999);
     return $admin;
 }
Example #8
0
 /**
  * @return \Venne\System\Components\AdminGrid\AdminGrid
  */
 protected function createComponentTable()
 {
     $session = $this->session;
     $admin = $this->adminGridFactory->create($this->loginRepository);
     $table = $admin->getTable();
     if ($this->user->identity instanceof User) {
         $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 (Login $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%';
     $deleteAction = $table->addActionEvent('delete', 'Delete');
     $deleteAction->getElementPrototype()->class[] = 'ajax';
     $admin->connectActionAsDelete($deleteAction);
     return $admin;
 }