Commit 6f4690d4 authored by catch's avatar catch

Issue #2598488 by NickWilde: Views Page display menu expanded option is not...

Issue #2598488 by NickWilde: Views Page display menu expanded option is not included and gets destroyed by cache-rebuild
parent d32bac92
...@@ -43,6 +43,9 @@ views.display.page: ...@@ -43,6 +43,9 @@ views.display.page:
context: context:
type: string type: string
label: 'Context' label: 'Context'
expanded:
type: boolean
label: 'Expanded'
tab_options: tab_options:
type: mapping type: mapping
label: 'Tab options' label: 'Tab options'
......
...@@ -127,6 +127,14 @@ public function getDescription() { ...@@ -127,6 +127,14 @@ public function getDescription() {
return $this->loadView()->display_handler->getOption('menu')['description']; return $this->loadView()->display_handler->getOption('menu')['description'];
} }
/**
* {@inheritdoc}
*/
public function isExpanded() {
return (bool) $this->loadView()->display_handler->getOption('menu')['expanded'];
}
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
......
...@@ -132,6 +132,7 @@ protected function defineOptions() { ...@@ -132,6 +132,7 @@ protected function defineOptions() {
'menu_name' => array('default' => 'main'), 'menu_name' => array('default' => 'main'),
'parent' => array('default' => ''), 'parent' => array('default' => ''),
'context' => array('default' => ''), 'context' => array('default' => ''),
'expanded' => array('default' => FALSE),
), ),
); );
$options['tab_options'] = array( $options['tab_options'] = array(
...@@ -239,7 +240,7 @@ public function buildOptionsForm(&$form, FormStateInterface $form_state) { ...@@ -239,7 +240,7 @@ public function buildOptionsForm(&$form, FormStateInterface $form_state) {
); );
$menu = $this->getOption('menu'); $menu = $this->getOption('menu');
if (empty($menu)) { if (empty($menu)) {
$menu = array('type' => 'none', 'title' => '', 'weight' => 0); $menu = array('type' => 'none', 'title' => '', 'weight' => 0, 'expanded' => FALSE);
} }
$form['menu']['type'] = array( $form['menu']['type'] = array(
'#prefix' => '<div class="views-left-30">', '#prefix' => '<div class="views-left-30">',
...@@ -293,6 +294,12 @@ public function buildOptionsForm(&$form, FormStateInterface $form_state) { ...@@ -293,6 +294,12 @@ public function buildOptionsForm(&$form, FormStateInterface $form_state) {
), ),
), ),
); );
$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. // Only display the parent selector if Menu UI module is enabled.
$menu_parent = $menu['menu_name'] . ':' . $menu['parent']; $menu_parent = $menu['menu_name'] . ':' . $menu['parent'];
......
...@@ -136,6 +136,8 @@ public function testMenuLinks() { ...@@ -136,6 +136,8 @@ public function testMenuLinks() {
$this->assertTrue(isset($tree['system.admin']->subtree['views_view:views.test_page_display_menu.page_4'])); $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; $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->getTitle(), 'Test child (with parent)');
$this->assertEqual($menu_link->isExpanded(), TRUE);
$this->assertEqual($menu_link->getDescription(), 'Sample description.');
} }
/** /**
......
...@@ -91,10 +91,11 @@ display: ...@@ -91,10 +91,11 @@ display:
type: normal type: normal
title: 'Test child (with parent)' title: 'Test child (with parent)'
parent: system.admin parent: system.admin
description: '' description: 'Sample description.'
menu_name: admin menu_name: admin
weight: 0 weight: 0
context: '0' context: '0'
expanded: true
defaults: defaults:
title: false title: false
display_plugin: page display_plugin: page
......
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