Skip to content
Snippets Groups Projects
Commit 5e7de2c6 authored by Mike Feranda's avatar Mike Feranda Committed by Mike Feranda
Browse files

Issue #3171640 by mferanda: Add twig and output variables from htmlformatter

parent 63b7765b
No related branches found
No related tags found
No related merge requests found
......@@ -47,8 +47,14 @@ function aggrid_help($route_name, RouteMatchInterface $route_match) {
*/
function aggrid_theme() {
return [
'aggrid' => [
'render element' => 'children',
'aggrid_table' => [
'variables' => [
'headers' => NULL,
'rowSettings' => NULL,
'rowSuppression' => NULL,
'rowData' => NULL,
'attributes' => []
],
],
];
}
......
......@@ -29,6 +29,13 @@ class HtmlFormatterType extends FormatterBase {
* @var boolean
*/
protected $suppComplimentary;
/**
* Complimentary suppression for aggrid item.
*
* @var array
*/
protected $rowSuppression;
/**
* {@inheritdoc}
......@@ -605,6 +612,11 @@ class HtmlFormatterType extends FormatterBase {
}
}
// If suppression, then apply to variable
if ($suppCell) {
$this->rowSuppression = $suppCell;
}
// Process actual suppressions
if (!$suppOverride) {
foreach($suppCell as $row => $value) {
......@@ -896,7 +908,9 @@ class HtmlFormatterType extends FormatterBase {
// Data rows.
$table_render .= $this->createAggridRowData($rowSettings, $headers, $rowData);
// Set the row suppression from after the actual rowData is run
$rowSuppression = $this->rowSuppression;
// Pinned Bottom Row Settings.
$pinnedBottomRowSettings[][][] = "";
$pinnedBottomRowSettings = $this->getRowSettings($aggridRowSettings, $headers, $pinnedBottomRowData, 'b-');
......@@ -906,10 +920,15 @@ class HtmlFormatterType extends FormatterBase {
// Close up the table.
$table_render .= '</tbody></table>';
$elements[$delta]['container'] = [
'#theme' => 'aggrid_table',
'#title' => $this->fieldDefinition->label(),
'#description' => $this->fieldDefinition->getDescription(),
'#headers' => $headers,
'#rowSettings' => $rowSettings,
'#rowSuppression' => $rowSuppression,
'#rowData' => $rowData,
'#suffix' => $table_render,
'#attached' => [
'library' => [
......@@ -917,8 +936,7 @@ class HtmlFormatterType extends FormatterBase {
],
],
];
/*
* Putting this code to the side for now. They're currently working on multiple headers
* for the '#type' => 'table'
......
{#
/**
* @file
* Theme for Plugin/Field/FieldFormatter/HtmlFormatterType.php
*
* Available variables:
* - headers: Header data
* - rowSettings: All settings for this aggrid item.
* - rowSuppression: All suppression information
* - rowData: Actual data from DB (json field)
*
*/
#}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment