private function populateDashboard(DashboardModel $dashboard, ObjectManager $manager)
 {
     $user = $this->getAdminUser($manager);
     $widgetConfiguration = ['ticket_timeline' => [0, 0], 'time_of_response_widget' => [1, 0], 'tickets_by_channels_widget' => [0, 1], 'tickets_by_branches_widget' => [1, 2], 'tickets_by_priority_widget' => [0, 2]];
     foreach ($widgetConfiguration as $name => $position) {
         $widget = new Widget();
         $widget->setDashboard($dashboard->getEntity());
         $widget->setLayoutPosition($position);
         $widget->setName($name);
         $state = new WidgetState();
         $state->setWidget($widget);
         $state->setOwner($user);
         $state->setExpanded(true);
         $manager->persist($widget);
         $manager->persist($state);
     }
 }
Esempio n. 2
0
 /**
  * @param DashboardModel $dashboardModel
  * @return mixed
  */
 protected function update(DashboardModel $dashboardModel)
 {
     $form = $this->createForm($this->container->get('oro_dashboard.form.type.edit'), $dashboardModel->getEntity(), array('create_new' => !$dashboardModel->getId()));
     $request = $this->getRequest();
     if ($request->isMethod('POST')) {
         if ($form->submit($request)->isValid()) {
             $this->getDashboardManager()->save($dashboardModel, true);
             $this->get('session')->getFlashBag()->add('success', $this->get('translator')->trans('oro.dashboard.saved_message'));
             return $this->get('oro_ui.router')->redirectAfterSave(array('route' => 'oro_dashboard_update', 'parameters' => array('id' => $dashboardModel->getId(), '_enableContentProviders' => 'mainMenu')), array('route' => 'oro_dashboard_view', 'parameters' => array('id' => $dashboardModel->getId(), 'change_dashboard' => true, '_enableContentProviders' => 'mainMenu')));
         }
     }
     return array('entity' => $dashboardModel, 'form' => $form->createView());
 }
Esempio n. 3
0
 public function testGetTemplate()
 {
     $this->assertEquals(DashboardModel::DEFAULT_TEMPLATE, $this->dashboardModel->getTemplate());
 }
Esempio n. 4
0
 /**
  * Copy widgets from source entity to dashboard model
  *
  * @param DashboardModel $target
  * @param Dashboard      $source
  */
 protected function copyWidgets(DashboardModel $target, Dashboard $source)
 {
     foreach ($source->getWidgets() as $sourceWidget) {
         $widgetModel = $this->copyWidgetModel($sourceWidget);
         $this->save($widgetModel, false);
         $target->addWidget($widgetModel);
     }
 }