Пример #1
0
 private function createLinks($object, $classes = '')
 {
     return array_map(function (Link $link) use($object, $classes) {
         $action = $this->actions->getAction($link->actionId());
         $url = $this->baseUrl->appended($link->actionId())->withParameters(new Map($link->parameters($object)));
         $attributes = ['class' => $classes, 'href' => $url];
         if ($link->confirm() !== null) {
             $attributes['onclick'] = "return confirm('{$link->confirm()}');";
         }
         $description = $action->description();
         if (!is_null($description)) {
             $attributes['title'] = str_replace('"', "'", strip_tags($this->parser->shorten($description)));
         }
         return new Element('a', $attributes, [$action->caption()]);
     }, $this->links->getLinks($object));
 }
Пример #2
0
 /**
  * @param Url $base
  * @return array
  */
 private function assembleActions(Url $base)
 {
     $actions = [];
     foreach ($this->app->actions->getAllActions() as $id => $action) {
         $actions[] = ['caption' => $action->caption(), 'description' => $this->app->parser->shorten($action->description()), 'link' => ['href' => $base->appended($id)->toString()]];
     }
     return $actions;
 }
Пример #3
0
 public function handleScheduleBrick(ScheduleBrick $command)
 {
     if (!isset($this->goalOfTask[$command->getTask()])) {
         throw new \Exception("Task [{$command->getTask()}] does not exist.");
     }
     if ($command->getStart() < $this->now) {
         throw new \Exception('Cannot schedule brick in the past');
     }
     $brickId = $this->uid->generate('Brick');
     $events = [new BrickScheduled($brickId, $command->getTask(), $command->getDescription(), $command->getStart(), $command->getDuration())];
     if ($this->settings->calendarId) {
         $eventId = $this->calendar->insertEvent($this->settings->calendarId, $command->getDescription(), $command->getStart(), $command->getStart()->add($command->getDuration()), 'Show goal: ' . $this->base->appended('ShowGoalOfBrick')->withParameter('brick', $brickId) . "\n" . 'Mark as laid: ' . $this->base->appended('MarkBrickLaid')->withParameter('brick', $brickId));
         $events[] = new CalendarEventInserted($brickId, $this->settings->calendarId, $eventId);
     }
     return $events;
 }
Пример #4
0
 /**
  * @param ActionPanel $value
  * @return mixed
  */
 public function render($value)
 {
     $heading = $this->actions->getAction($value->getActionId())->caption();
     return (string) (new Panel($heading, $this->getContent($value)))->setMaxHeight($value->getMaxHeight())->setRightHeading([new Element('a', ['href' => $this->baseUrl->appended($value->getActionId())->withParameters(Map::toCollections($value->getParameters()))], [new Element('span', ['class' => 'glyphicon glyphicon-circle-arrow-right'])])])->render($this->renderers);
 }