summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNathaniel Catchpole2015-11-02 13:56:05 +0000
committerNathaniel Catchpole2015-11-02 13:56:05 +0000
commit6f4690d40da6eca654482c45b0001f641dde768d (patch)
treedad11f773922f02d97d02cea738894dd67448d4c
parentd32bac926ae09d6bf06a3f02cc6a0e3722726392 (diff)
Issue #2598488 by NickWilde: Views Page display menu expanded option is not included and gets destroyed by cache-rebuild
-rw-r--r--core/modules/views/config/schema/views.display.schema.yml3
-rw-r--r--core/modules/views/src/Plugin/Menu/ViewsMenuLink.php8
-rw-r--r--core/modules/views/src/Plugin/views/display/Page.php9
-rw-r--r--core/modules/views/src/Tests/Plugin/DisplayPageTest.php2
-rw-r--r--core/modules/views/tests/modules/views_test_config/test_views/views.view.test_page_display_menu.yml3
5 files changed, 23 insertions, 2 deletions
diff --git a/core/modules/views/config/schema/views.display.schema.yml b/core/modules/views/config/schema/views.display.schema.yml
index 16b0d1d..511b0b9 100644
--- a/core/modules/views/config/schema/views.display.schema.yml
+++ b/core/modules/views/config/schema/views.display.schema.yml
@@ -43,6 +43,9 @@ views.display.page:
context:
type: string
label: 'Context'
+ expanded:
+ type: boolean
+ label: 'Expanded'
tab_options:
type: mapping
label: 'Tab options'
diff --git a/core/modules/views/src/Plugin/Menu/ViewsMenuLink.php b/core/modules/views/src/Plugin/Menu/ViewsMenuLink.php
index 85c2350..f307cee 100644
--- a/core/modules/views/src/Plugin/Menu/ViewsMenuLink.php
+++ b/core/modules/views/src/Plugin/Menu/ViewsMenuLink.php
@@ -130,6 +130,14 @@ class ViewsMenuLink extends MenuLinkBase implements ContainerFactoryPluginInterf
/**
* {@inheritdoc}
*/
+ public function isExpanded() {
+ return (bool) $this->loadView()->display_handler->getOption('menu')['expanded'];
+ }
+
+
+ /**
+ * {@inheritdoc}
+ */
public function updateLink(array $new_definition_values, $persist) {
$overrides = array_intersect_key($new_definition_values, $this->overrideAllowed);
// Update the definition.
diff --git a/core/modules/views/src/Plugin/views/display/Page.php b/core/modules/views/src/Plugin/views/display/Page.php
index 77f1b77..c23b26e 100644
--- a/core/modules/views/src/Plugin/views/display/Page.php
+++ b/core/modules/views/src/Plugin/views/display/Page.php
@@ -132,6 +132,7 @@ class Page extends PathPluginBase {
'menu_name' => array('default' => 'main'),
'parent' => array('default' => ''),
'context' => array('default' => ''),
+ 'expanded' => array('default' => FALSE),
),
);
$options['tab_options'] = array(
@@ -239,7 +240,7 @@ class Page extends PathPluginBase {
);
$menu = $this->getOption('menu');
if (empty($menu)) {
- $menu = array('type' => 'none', 'title' => '', 'weight' => 0);
+ $menu = array('type' => 'none', 'title' => '', 'weight' => 0, 'expanded' => FALSE);
}
$form['menu']['type'] = array(
'#prefix' => '<div class="views-left-30">',
@@ -293,6 +294,12 @@ class Page extends PathPluginBase {
),
),
);
+ $form['menu']['expanded'] = [
+ '#title' => $this->t('Show as expanded'),
+ '#type' => 'checkbox',
+ '#default_value' => !empty($menu['expanded']),
+ '#description' => $this->t('If selected and this menu link has children, the menu will always appear expanded. '),
+ ];
// Only display the parent selector if Menu UI module is enabled.
$menu_parent = $menu['menu_name'] . ':' . $menu['parent'];
diff --git a/core/modules/views/src/Tests/Plugin/DisplayPageTest.php b/core/modules/views/src/Tests/Plugin/DisplayPageTest.php
index 5ce2d3f..7c7593d 100644
--- a/core/modules/views/src/Tests/Plugin/DisplayPageTest.php
+++ b/core/modules/views/src/Tests/Plugin/DisplayPageTest.php
@@ -136,6 +136,8 @@ class DisplayPageTest extends ViewKernelTestBase {
$this->assertTrue(isset($tree['system.admin']->subtree['views_view:views.test_page_display_menu.page_4']));
$menu_link = $tree['system.admin']->subtree['views_view:views.test_page_display_menu.page_4']->link;
$this->assertEqual($menu_link->getTitle(), 'Test child (with parent)');
+ $this->assertEqual($menu_link->isExpanded(), TRUE);
+ $this->assertEqual($menu_link->getDescription(), 'Sample description.');
}
/**
diff --git a/core/modules/views/tests/modules/views_test_config/test_views/views.view.test_page_display_menu.yml b/core/modules/views/tests/modules/views_test_config/test_views/views.view.test_page_display_menu.yml
index 814ad4e..a1eb3b5 100644
--- a/core/modules/views/tests/modules/views_test_config/test_views/views.view.test_page_display_menu.yml
+++ b/core/modules/views/tests/modules/views_test_config/test_views/views.view.test_page_display_menu.yml
@@ -91,10 +91,11 @@ display:
type: normal
title: 'Test child (with parent)'
parent: system.admin
- description: ''
+ description: 'Sample description.'
menu_name: admin
weight: 0
context: '0'
+ expanded: true
defaults:
title: false
display_plugin: page