Commit b3312d05 authored by alexpott's avatar alexpott

Issue #2412805 by mondrake: View preview does not attach assets provided by plugins

parent 03f372f3
...@@ -213,6 +213,9 @@ public function testPreviewAdditionalInfo() { ...@@ -213,6 +213,9 @@ public function testPreviewAdditionalInfo() {
// @see views_ui_test.module // @see views_ui_test.module
$elements = $this->xpath('//div[@id="views-live-preview"]/div[contains(@class, views-query-info)]//td[text()=:text]', array(':text' => t('Test row count'))); $elements = $this->xpath('//div[@id="views-live-preview"]/div[contains(@class, views-query-info)]//td[text()=:text]', array(':text' => t('Test row count')));
$this->assertEqual(count($elements), 1, 'Views Query Preview Info area altered.'); $this->assertEqual(count($elements), 1, 'Views Query Preview Info area altered.');
// Check that additional assets are attached.
$this->assertTrue(strpos($this->getDrupalSettings()['ajaxPageState']['libraries'], 'views_ui_test/views_ui_test.test') !== FALSE, 'Attached library found.');
$this->assertRaw('css/views_ui_test.test.css', 'Attached CSS asset found.');
} }
/** /**
......
...@@ -68,7 +68,7 @@ public function form(array $form, FormStateInterface $form_state) { ...@@ -68,7 +68,7 @@ public function form(array $form, FormStateInterface $form_state) {
'#weight' => 110, '#weight' => 110,
'#theme_wrappers' => array('container'), '#theme_wrappers' => array('container'),
'#attributes' => array('id' => 'views-live-preview'), '#attributes' => array('id' => 'views-live-preview'),
'#markup' => $view->renderPreview($this->displayID, $args), 'preview' => $view->renderPreview($this->displayID, $args),
); );
} }
$uri = $view->urlInfo('preview-form'); $uri = $view->urlInfo('preview-form');
......
...@@ -577,7 +577,6 @@ public function renderPreview($display_id, $args = array()) { ...@@ -577,7 +577,6 @@ public function renderPreview($display_id, $args = array()) {
$combined = $show_query && $show_stats; $combined = $show_query && $show_stats;
$rows = array('query' => array(), 'statistics' => array()); $rows = array('query' => array(), 'statistics' => array());
$output = '';
$errors = $this->executable->validate(); $errors = $this->executable->validate();
$this->executable->destroy(); $this->executable->destroy();
...@@ -599,7 +598,9 @@ public function renderPreview($display_id, $args = array()) { ...@@ -599,7 +598,9 @@ public function renderPreview($display_id, $args = array()) {
$this->executable->setExposedInput($exposed_input); $this->executable->setExposedInput($exposed_input);
if (!$this->executable->setDisplay($display_id)) { if (!$this->executable->setDisplay($display_id)) {
return t('Invalid display id @display', array('@display' => $display_id)); return [
'#markup' => t('Invalid display id @display', array('@display' => $display_id)),
];
} }
$this->executable->setArguments($args); $this->executable->setArguments($args);
...@@ -644,7 +645,6 @@ public function renderPreview($display_id, $args = array()) { ...@@ -644,7 +645,6 @@ public function renderPreview($display_id, $args = array()) {
// Execute/get the view preview. // Execute/get the view preview.
$preview = $this->executable->preview($display_id, $args); $preview = $this->executable->preview($display_id, $args);
$preview = drupal_render($preview);
if ($show_additional_queries) { if ($show_additional_queries) {
$this->endQueryCapture(); $this->endQueryCapture();
...@@ -769,10 +769,16 @@ public function renderPreview($display_id, $args = array()) { ...@@ -769,10 +769,16 @@ public function renderPreview($display_id, $args = array()) {
} }
if ($show_location === 'above' || $show_stats === 'above') { if ($show_location === 'above' || $show_stats === 'above') {
$output .= drupal_render($table) . $preview; $output = [
'table' => $table,
'preview' => $preview,
];
} }
elseif ($show_location === 'below' || $show_stats === 'below') { elseif ($show_location === 'below' || $show_stats === 'below') {
$output .= $preview . drupal_render($table); $output = [
'preview' => $preview,
'table' => $table,
];
} }
// Ensure that we just remove an additional request we pushed earlier. // Ensure that we just remove an additional request we pushed earlier.
......
/**
* @file
* Just a placeholder file for the test.
*/
views_ui_test.test:
css:
component:
css/views_ui_test.test.css: {}
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
* Add a row count row to the live preview area. * Add a row count row to the live preview area.
*/ */
function views_ui_test_views_preview_info_alter(&$rows, $view) { function views_ui_test_views_preview_info_alter(&$rows, $view) {
$rows['query'][] = array( $data = ['#markup' => t('Test row count')];
t('Test row count'), count($view->result), $data['#attached']['library'][] = 'views_ui_test/views_ui_test.test';
); $rows['query'][] = [['data' => $data], count($view->result)];
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment