Commit 15c6ef59 authored by webchick's avatar webchick

Issue #1829424 by damiankloip, dawehner: Added Allow area plugins to be disabled for displays.

parent dd60468d
......@@ -89,6 +89,13 @@ abstract class DisplayPluginBase extends PluginBase {
*/
protected $usesAttachments = FALSE;
/**
* Whether the display allows area plugins.
*
* @var bool
*/
protected $usesAreas = TRUE;
public function init(ViewExecutable $view, &$display, $options = NULL) {
$this->setOptionDefaults($this->options, $this->defineOptions());
$this->view = &$view;
......@@ -359,6 +366,16 @@ public function usesAttachments() {
return $this->usesAttachments;
}
/**
* Returns whether the display can use areas.
*
* @return bool
* TRUE if the display can use areas, or FALSE otherwise.
*/
public function usesAreas() {
return $this->usesAreas;
}
/**
* Allow displays to attach to other views.
*/
......
......@@ -128,7 +128,7 @@ public function testReorderDisplay() {
*/
public function testDefaultDisplay() {
$this->drupalGet('admin/structure/views/view/test_display');
$elements = $this->xpath('//*[@id="views-page-display-title"]');
$elements = $this->xpath('//*[@id="views-page-1-display-title"]');
$this->assertEqual(count($elements), 1, 'The page display is loaded as the default display.');
}
......@@ -182,4 +182,32 @@ public function testDisplayPluginsAlter() {
}
}
/**
* Tests display areas.
*/
public function testDisplayAreas() {
// Show the advanced column.
config('views.settings')->set('ui.show.advanced_column', TRUE)->save();
// Add a new data display to the view.
$view = views_get_view('test_display');
$view->storage->addDisplay('display_no_area_test');
$view->save();
$this->drupalGet('admin/structure/views/view/test_display/edit/display_no_area_test_1');
// Create a mapping of area type => class.
$areas = array(
'header' => 'header',
'footer' => 'footer',
'empty' => 'no-results-behavior',
);
// Assert that the expected text is found in each area category.
foreach ($areas as $type => $class) {
$element = $this->xpath('//div[contains(@class, :class)]/div', array(':class' => $class));
$this->assertEqual((string) $element[0], "The selected display type does not utilize $type plugins");
}
}
}
......@@ -75,12 +75,12 @@ display:
display_title: Master
id: default
position: '0'
page:
page_1:
display_options:
path: test-display
display_plugin: page
display_title: Page
id: page
id: page_1
position: '1'
human_name: ''
name: test_display
......
<?php
/**
* @file
* Definition of Drupal\views_test_data\Plugin\views\display\DisplayNoAreaTest.
*/
namespace Drupal\views_test_data\Plugin\views\display;
use Drupal\Core\Annotation\Plugin;
use Drupal\Core\Annotation\Translation;
/**
* Defines a Display test plugin with areas disabled.
*
* @Plugin(
* id = "display_no_area_test",
* title = @Translation("Display test no area"),
* theme = "views_view",
* contextual_links_locations = {"view"}
* )
*/
class DisplayNoAreaTest extends DisplayTest {
/**
* Whether the display allows area plugins.
*
* @var bool
* TRUE if the display can use areas, or FALSE otherwise.
*/
protected $usesAreas = FALSE;
}
......@@ -613,7 +613,7 @@ public function rebuildCurrentTab(ViewUI $view, &$output, $display_id) {
*/
public function renderDisplayTop(ViewUI $view) {
$display_id = $view->displayID;
$element['#theme'] = 'views_ui_container';
$element['#theme_wrappers'][] = 'views_ui_container';
$element['#attributes']['class'] = array('views-display-top', 'clearfix');
$element['#attributes']['id'] = array('views-display-top');
......@@ -836,7 +836,17 @@ public function getFormBucket(ViewUI $view, $type, $display) {
);
return $build;
}
case 'header':
case 'footer':
case 'empty':
if (!$view->get('executable')->displayHandlers[$display['id']]->usesAreas()) {
$build[$type][] = array(
'#markup' => t('The selected display type does not utilize @type plugins', array('@type' => $type)),
'#theme_wrappers' => array('views_ui_container'),
'#attributes' => array('class' => array('views-display-setting')),
);
return $build;
}
default:
$rearrange_url = "admin/structure/views/nojs/rearrange/{$view->get('name')}/{$display['id']}/$type";
$rearrange_text = t('Rearrange');
......
......@@ -12,7 +12,7 @@
*/
function theme_views_ui_container($variables) {
$element = $variables['element'];
return '<div' . new Attribute($element['#attributes']) . '>' . drupal_render_children($element) . '</div>';
return '<div' . new Attribute($element['#attributes']) . '>' . $element['#children'] . '</div>';
}
function template_preprocess_views_ui_display_tab_setting(&$variables) {
......
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