Issue #2598488 by NickWilde: Views Page display menu expanded option is not included and gets destroyed by cache-rebuild

8.0.x
Nathaniel Catchpole 2015-11-02 13:56:05 +00:00
parent d32bac926a
commit 6f4690d40d
5 changed files with 23 additions and 2 deletions

View File

@ -43,6 +43,9 @@ views.display.page:
context:
type: string
label: 'Context'
expanded:
type: boolean
label: 'Expanded'
tab_options:
type: mapping
label: 'Tab options'

View File

@ -127,6 +127,14 @@ class ViewsMenuLink extends MenuLinkBase implements ContainerFactoryPluginInterf
return $this->loadView()->display_handler->getOption('menu')['description'];
}
/**
* {@inheritdoc}
*/
public function isExpanded() {
return (bool) $this->loadView()->display_handler->getOption('menu')['expanded'];
}
/**
* {@inheritdoc}
*/

View File

@ -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'];

View File

@ -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.');
}
/**

View File

@ -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