You are here

public function MaestroEngineProcessDetails::render in Maestro 8.2

Same name and namespace in other branches
  1. 3.x src/Plugin/views/field/MaestroEngineProcessDetails.php \Drupal\maestro\Plugin\views\field\MaestroEngineProcessDetails::render()

Renders the field.

Parameters

\Drupal\views\ResultRow $values: The values retrieved from a single row of a view's query result.

Return value

string|\Drupal\Component\Render\MarkupInterface The rendered output. If the output is safe it will be wrapped in an object that implements MarkupInterface. If it is empty or unsafe it will be a string.

Overrides FieldPluginBase::render

File

src/Plugin/views/field/MaestroEngineProcessDetails.php, line 50

Class

MaestroEngineProcessDetails
Field handler to show process details and attached views.

Namespace

Drupal\maestro\Plugin\views\field

Code

public function render(ResultRow $values) {
  $item = $values->_entity;
  $rows = [];
  $links = [];

  // We need the process ID no matter what we're viewing.
  $processID = 0;
  if ($item
    ->getEntityTypeId() == 'maestro_production_assignments') {
    $queueRecord = MaestroEngine::getQueueEntryById($item->queue_id
      ->getString());
    $processID = $queueRecord->process_id
      ->getString();
  }
  elseif ($item
    ->getEntityTypeId() == 'maestro_queue') {
    $processID = $item->process_id
      ->getString();
  }
  elseif ($item
    ->getEntityTypeId() == 'maestro_process') {
    $processID = $item->process_id
      ->getString();
  }
  $build = [];
  $build['details'][$processID]['expand'] = [
    '#prefix' => '<div class="maestro-process-details-expand-wrapper maestro-expand-wrapper maestro-status-toggle-' . $processID . '">',
    '#suffix' => '</div>',
    '#attributes' => [
      'class' => [
        'maestro-timeline-status',
        'maestro-status-toggle',
      ],
      'title' => $this
        ->t('Open Details'),
    ],
    '#type' => 'link',
    '#id' => 'maestro-id-ajax-' . $processID,
    '#url' => Url::fromRoute('maestro.process_details_ajax_open', [
      'processID' => $processID,
    ]),
    '#title' => $this
      ->t('Open Details'),
    '#ajax' => [
      'progress' => [
        'type' => 'throbber',
        'message' => NULL,
      ],
    ],
  ];

  // Css for the status bar.
  $build['#attached']['library'][] = 'maestro/maestro-engine-css';
  $build['#attached']['library'][] = 'maestro_taskconsole/maestro_taskconsole_css';
  return $build;
}