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:
context:
type: string
label: 'Context'
expanded:
type: boolean
label: 'Expanded'
tab_options:
type: mapping
label: 'Tab options'
......
......@@ -127,6 +127,14 @@ public function getDescription() {
return $this->loadView()->display_handler->getOption('menu')['description'];
}
/**
* {@inheritdoc}
*/
public function isExpanded() {
return (bool) $this->loadView()->display_handler->getOption('menu')['expanded'];
}
/**
* {@inheritdoc}
*/
......
......@@ -132,6 +132,7 @@ protected function defineOptions() {
'menu_name' => array('default' => 'main'),
'parent' => array('default' => ''),
'context' => array('default' => ''),
'expanded' => array('default' => FALSE),
),
);
$options['tab_options'] = array(
......@@ -239,7 +240,7 @@ public function buildOptionsForm(&$form, FormStateInterface $form_state) {
);
$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 @@ 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.
$menu_parent = $menu['menu_name'] . ':' . $menu['parent'];
......
......@@ -136,6 +136,8 @@ public function testMenuLinks() {
$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.');
}
/**
......
......@@ -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
......
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