Issue #2318435 by dawehner, Gábor Hojtsy: Fixed Views menu items disappears when editing menu.
							parent
							
								
									cdf77e49f8
								
							
						
					
					
						commit
						455428cb93
					
				| 
						 | 
					@ -669,7 +669,7 @@ display:
 | 
				
			||||||
        type: tab
 | 
					        type: tab
 | 
				
			||||||
        title: Files
 | 
					        title: Files
 | 
				
			||||||
        description: ''
 | 
					        description: ''
 | 
				
			||||||
        name: admin
 | 
					        menu_name: admin
 | 
				
			||||||
        weight: 0
 | 
					        weight: 0
 | 
				
			||||||
        context: ''
 | 
					        context: ''
 | 
				
			||||||
      display_description: ''
 | 
					      display_description: ''
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -549,14 +549,14 @@ display:
 | 
				
			||||||
        type: 'default tab'
 | 
					        type: 'default tab'
 | 
				
			||||||
        title: Content
 | 
					        title: Content
 | 
				
			||||||
        description: ''
 | 
					        description: ''
 | 
				
			||||||
        name: admin
 | 
					        menu_name: admin
 | 
				
			||||||
        weight: -10
 | 
					        weight: -10
 | 
				
			||||||
        context: ''
 | 
					        context: ''
 | 
				
			||||||
      tab_options:
 | 
					      tab_options:
 | 
				
			||||||
        type: normal
 | 
					        type: normal
 | 
				
			||||||
        title: Content
 | 
					        title: Content
 | 
				
			||||||
        description: 'Find and manage content'
 | 
					        description: 'Find and manage content'
 | 
				
			||||||
        name: admin
 | 
					        menu_name: admin
 | 
				
			||||||
        weight: -10
 | 
					        weight: -10
 | 
				
			||||||
      field_langcode: '***CURRENT_LANGUAGE***'
 | 
					      field_langcode: '***CURRENT_LANGUAGE***'
 | 
				
			||||||
      field_langcode_add_to_query: null
 | 
					      field_langcode_add_to_query: null
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -880,14 +880,14 @@ display:
 | 
				
			||||||
        type: 'default tab'
 | 
					        type: 'default tab'
 | 
				
			||||||
        title: List
 | 
					        title: List
 | 
				
			||||||
        description: 'Find and manage people interacting with your site.'
 | 
					        description: 'Find and manage people interacting with your site.'
 | 
				
			||||||
        name: admin
 | 
					        menu_name: admin
 | 
				
			||||||
        weight: -10
 | 
					        weight: -10
 | 
				
			||||||
        context: ''
 | 
					        context: ''
 | 
				
			||||||
      tab_options:
 | 
					      tab_options:
 | 
				
			||||||
        type: normal
 | 
					        type: normal
 | 
				
			||||||
        title: People
 | 
					        title: People
 | 
				
			||||||
        description: 'Manage user accounts, roles, and permissions.'
 | 
					        description: 'Manage user accounts, roles, and permissions.'
 | 
				
			||||||
        name: admin
 | 
					        menu_name: admin
 | 
				
			||||||
        weight: 0
 | 
					        weight: 0
 | 
				
			||||||
      defaults:
 | 
					      defaults:
 | 
				
			||||||
        show_admin_links: false
 | 
					        show_admin_links: false
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -34,7 +34,7 @@ views.display.page:
 | 
				
			||||||
        weight:
 | 
					        weight:
 | 
				
			||||||
          type: integer
 | 
					          type: integer
 | 
				
			||||||
          label: 'Weight'
 | 
					          label: 'Weight'
 | 
				
			||||||
        name:
 | 
					        menu_name:
 | 
				
			||||||
          type: string
 | 
					          type: string
 | 
				
			||||||
          label: 'Menu name'
 | 
					          label: 'Menu name'
 | 
				
			||||||
        context:
 | 
					        context:
 | 
				
			||||||
| 
						 | 
					@ -56,7 +56,7 @@ views.display.page:
 | 
				
			||||||
        weight:
 | 
					        weight:
 | 
				
			||||||
          type: integer
 | 
					          type: integer
 | 
				
			||||||
          label: 'Weight'
 | 
					          label: 'Weight'
 | 
				
			||||||
        name:
 | 
					        menu_name:
 | 
				
			||||||
          type: string
 | 
					          type: string
 | 
				
			||||||
          label: 'Menu name'
 | 
					          label: 'Menu name'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -132,14 +132,16 @@ class ViewsMenuLink extends MenuLinkBase implements ContainerFactoryPluginInterf
 | 
				
			||||||
   */
 | 
					   */
 | 
				
			||||||
  public function updateLink(array $new_definition_values, $persist) {
 | 
					  public function updateLink(array $new_definition_values, $persist) {
 | 
				
			||||||
    $overrides = array_intersect_key($new_definition_values, $this->overrideAllowed);
 | 
					    $overrides = array_intersect_key($new_definition_values, $this->overrideAllowed);
 | 
				
			||||||
 | 
					    // Update the definition.
 | 
				
			||||||
 | 
					    $this->pluginDefinition = $overrides + $this->pluginDefinition;
 | 
				
			||||||
    if ($persist) {
 | 
					    if ($persist) {
 | 
				
			||||||
      $view = $this->loadView();
 | 
					      $view = $this->loadView();
 | 
				
			||||||
      $display = &$view->storage->getDisplay($view->current_display);
 | 
					      $display = &$view->storage->getDisplay($view->current_display);
 | 
				
			||||||
      // Just save the title to the original view.
 | 
					      // Just save the title to the original view.
 | 
				
			||||||
      $changed = FALSE;
 | 
					      $changed = FALSE;
 | 
				
			||||||
      foreach (array('title' => 'title', 'weight' => 'weight', 'menu' => 'name', 'description' => 'description') as $definition_key => $views_key) {
 | 
					      foreach ($new_definition_values as $key => $new_definition_value) {
 | 
				
			||||||
        if ($display['display_options']['menu'][$views_key] != $new_definition_values[$definition_key]) {
 | 
					        if (isset($display['display_options']['menu'][$key]) && $display['display_options']['menu'][$key] != $new_definition_values[$key]) {
 | 
				
			||||||
          $display['display_options']['menu'][$views_key] = $new_definition_values[$definition_key];
 | 
					          $display['display_options']['menu'][$key] = $new_definition_values[$key];
 | 
				
			||||||
          $changed = TRUE;
 | 
					          $changed = TRUE;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
| 
						 | 
					@ -149,8 +151,6 @@ class ViewsMenuLink extends MenuLinkBase implements ContainerFactoryPluginInterf
 | 
				
			||||||
        $view->storage->save();
 | 
					        $view->storage->save();
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    // Update the definition.
 | 
					 | 
				
			||||||
    $this->pluginDefinition = $overrides + $this->pluginDefinition;
 | 
					 | 
				
			||||||
    return $this->pluginDefinition;
 | 
					    return $this->pluginDefinition;
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -50,7 +50,7 @@ class Page extends PathPluginBase {
 | 
				
			||||||
        'title' => array('default' => '', 'translatable' => FALSE),
 | 
					        'title' => array('default' => '', 'translatable' => FALSE),
 | 
				
			||||||
        'description' => array('default' => '', 'translatable' => FALSE),
 | 
					        'description' => array('default' => '', 'translatable' => FALSE),
 | 
				
			||||||
        'weight' => array('default' => 0),
 | 
					        'weight' => array('default' => 0),
 | 
				
			||||||
        'name' => array('default' => 'navigation'),
 | 
					        'menu_name' => array('default' => 'navigation'),
 | 
				
			||||||
        'context' => array('default' => ''),
 | 
					        'context' => array('default' => ''),
 | 
				
			||||||
      ),
 | 
					      ),
 | 
				
			||||||
    );
 | 
					    );
 | 
				
			||||||
| 
						 | 
					@ -61,7 +61,7 @@ class Page extends PathPluginBase {
 | 
				
			||||||
        'title' => array('default' => '', 'translatable' => FALSE),
 | 
					        'title' => array('default' => '', 'translatable' => FALSE),
 | 
				
			||||||
        'description' => array('default' => '', 'translatable' => FALSE),
 | 
					        'description' => array('default' => '', 'translatable' => FALSE),
 | 
				
			||||||
        'weight' => array('default' => 0),
 | 
					        'weight' => array('default' => 0),
 | 
				
			||||||
        'name' => array('default' => 'navigation'),
 | 
					        'menu_name' => array('default' => 'navigation'),
 | 
				
			||||||
      ),
 | 
					      ),
 | 
				
			||||||
    );
 | 
					    );
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -219,11 +219,11 @@ class Page extends PathPluginBase {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        // Only display the menu selector if Menu UI module is enabled.
 | 
					        // Only display the menu selector if Menu UI module is enabled.
 | 
				
			||||||
        if (\Drupal::moduleHandler()->moduleExists('menu_ui')) {
 | 
					        if (\Drupal::moduleHandler()->moduleExists('menu_ui')) {
 | 
				
			||||||
          $form['menu']['name'] = array(
 | 
					          $form['menu']['menu_name'] = array(
 | 
				
			||||||
            '#title' => t('Menu'),
 | 
					            '#title' => t('Menu'),
 | 
				
			||||||
            '#type' => 'select',
 | 
					            '#type' => 'select',
 | 
				
			||||||
            '#options' => menu_ui_get_menus(),
 | 
					            '#options' => menu_ui_get_menus(),
 | 
				
			||||||
            '#default_value' => $menu['name'],
 | 
					            '#default_value' => $menu['menu_name'],
 | 
				
			||||||
            '#states' => array(
 | 
					            '#states' => array(
 | 
				
			||||||
              'visible' => array(
 | 
					              'visible' => array(
 | 
				
			||||||
                array(
 | 
					                array(
 | 
				
			||||||
| 
						 | 
					@ -237,9 +237,9 @@ class Page extends PathPluginBase {
 | 
				
			||||||
          );
 | 
					          );
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        else {
 | 
					        else {
 | 
				
			||||||
          $form['menu']['name'] = array(
 | 
					          $form['menu']['menu_name'] = array(
 | 
				
			||||||
            '#type' => 'value',
 | 
					            '#type' => 'value',
 | 
				
			||||||
            '#value' => $menu['name'],
 | 
					            '#value' => $menu['menu_name'],
 | 
				
			||||||
          );
 | 
					          );
 | 
				
			||||||
          $form['menu']['markup'] = array(
 | 
					          $form['menu']['markup'] = array(
 | 
				
			||||||
            '#markup' => t('Menu selection requires the activation of Menu UI module.'),
 | 
					            '#markup' => t('Menu selection requires the activation of Menu UI module.'),
 | 
				
			||||||
| 
						 | 
					@ -350,9 +350,9 @@ class Page extends PathPluginBase {
 | 
				
			||||||
          );
 | 
					          );
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        else {
 | 
					        else {
 | 
				
			||||||
          $form['tab_options']['name'] = array(
 | 
					          $form['tab_options']['menu_name'] = array(
 | 
				
			||||||
            '#type' => 'value',
 | 
					            '#type' => 'value',
 | 
				
			||||||
            '#value' => $tab_options['name'],
 | 
					            '#value' => $tab_options['menu_name'],
 | 
				
			||||||
          );
 | 
					          );
 | 
				
			||||||
          $form['tab_options']['markup'] = array(
 | 
					          $form['tab_options']['markup'] = array(
 | 
				
			||||||
            '#markup' => t('Menu selection requires the activation of Menu UI module.'),
 | 
					            '#markup' => t('Menu selection requires the activation of Menu UI module.'),
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -314,7 +314,7 @@ abstract class PathPluginBase extends DisplayPluginBase implements DisplayRouter
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        // Insert item into the proper menu.
 | 
					        // Insert item into the proper menu.
 | 
				
			||||||
        $links[$menu_link_id]['menu_name'] = $menu['name'];
 | 
					        $links[$menu_link_id]['menu_name'] = $menu['menu_name'];
 | 
				
			||||||
        // Keep track of where we came from.
 | 
					        // Keep track of where we came from.
 | 
				
			||||||
        $links[$menu_link_id]['metadata'] = array(
 | 
					        $links[$menu_link_id]['metadata'] = array(
 | 
				
			||||||
          'view_id' => $view_id,
 | 
					          'view_id' => $view_id,
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1018,7 +1018,7 @@ abstract class WizardPluginBase extends PluginBase implements WizardInterface {
 | 
				
			||||||
    if (!empty($page['link'])) {
 | 
					    if (!empty($page['link'])) {
 | 
				
			||||||
      $display_options['menu']['type'] = 'normal';
 | 
					      $display_options['menu']['type'] = 'normal';
 | 
				
			||||||
      $display_options['menu']['title'] = $page['link_properties']['title'];
 | 
					      $display_options['menu']['title'] = $page['link_properties']['title'];
 | 
				
			||||||
      $display_options['menu']['name'] = $page['link_properties']['menu_name'];
 | 
					      $display_options['menu']['menu_name'] = $page['link_properties']['menu_name'];
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    return $display_options;
 | 
					    return $display_options;
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -21,6 +21,13 @@ class DisplayPageWebTest extends PluginTestBase {
 | 
				
			||||||
   */
 | 
					   */
 | 
				
			||||||
  public static $testViews = array('test_page_display_arguments', 'test_page_display_menu');
 | 
					  public static $testViews = array('test_page_display_arguments', 'test_page_display_menu');
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  /**
 | 
				
			||||||
 | 
					   * Modules to enable.
 | 
				
			||||||
 | 
					   *
 | 
				
			||||||
 | 
					   * @var array
 | 
				
			||||||
 | 
					   */
 | 
				
			||||||
 | 
					  public static $modules = ['menu_ui', 'block'];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  protected function setUp() {
 | 
					  protected function setUp() {
 | 
				
			||||||
    parent::setUp();
 | 
					    parent::setUp();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -73,6 +80,7 @@ class DisplayPageWebTest extends PluginTestBase {
 | 
				
			||||||
   * Tests menu settings of page displays.
 | 
					   * Tests menu settings of page displays.
 | 
				
			||||||
   */
 | 
					   */
 | 
				
			||||||
  public function testPageDisplayMenu() {
 | 
					  public function testPageDisplayMenu() {
 | 
				
			||||||
 | 
					    // Check local tasks.
 | 
				
			||||||
    $this->drupalGet('test_page_display_menu');
 | 
					    $this->drupalGet('test_page_display_menu');
 | 
				
			||||||
    $this->assertResponse(200);
 | 
					    $this->assertResponse(200);
 | 
				
			||||||
    $element = $this->xpath('//ul[contains(@class, :ul_class)]//a[contains(@class, :a_class)]', array(
 | 
					    $element = $this->xpath('//ul[contains(@class, :ul_class)]//a[contains(@class, :a_class)]', array(
 | 
				
			||||||
| 
						 | 
					@ -93,6 +101,24 @@ class DisplayPageWebTest extends PluginTestBase {
 | 
				
			||||||
    ));
 | 
					    ));
 | 
				
			||||||
    $this->assertEqual((string) $element[0], t('Test local tab'));
 | 
					    $this->assertEqual((string) $element[0], t('Test local tab'));
 | 
				
			||||||
    $this->assertTitle(t('Test local page | Drupal'));
 | 
					    $this->assertTitle(t('Test local page | Drupal'));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    // Check an ordinary menu link.
 | 
				
			||||||
 | 
					    $admin_user = $this->drupalCreateUser(['administer menu']);
 | 
				
			||||||
 | 
					    $this->drupalLogin($admin_user);
 | 
				
			||||||
 | 
					    $this->drupalPlaceBlock('system_menu_block:tools');
 | 
				
			||||||
 | 
					    $this->drupalGet('<front>');
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    $menu_link = $this->cssSelect('div.block-menu ul.menu a');
 | 
				
			||||||
 | 
					    $this->assertEqual((string) $menu_link[0], 'Test menu link');
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    // Update the menu link.
 | 
				
			||||||
 | 
					    $this->drupalPostForm("admin/structure/menu/link/views_view:views.test_page_display_menu.page_3/edit", [
 | 
				
			||||||
 | 
					      'title' => 'New title',
 | 
				
			||||||
 | 
					    ], t('Save'));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    $this->drupalGet('<front>');
 | 
				
			||||||
 | 
					    $menu_link = $this->cssSelect('div.block-menu ul.menu a');
 | 
				
			||||||
 | 
					    $this->assertEqual((string) $menu_link[0], 'New title');
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -30,14 +30,14 @@ display:
 | 
				
			||||||
        type: 'default tab'
 | 
					        type: 'default tab'
 | 
				
			||||||
        title: 'Test default tab'
 | 
					        title: 'Test default tab'
 | 
				
			||||||
        description: ''
 | 
					        description: ''
 | 
				
			||||||
        name: tools
 | 
					        menu_name: tools
 | 
				
			||||||
        weight: '-10'
 | 
					        weight: '-10'
 | 
				
			||||||
        context: '0'
 | 
					        context: '0'
 | 
				
			||||||
      tab_options:
 | 
					      tab_options:
 | 
				
			||||||
        type: normal
 | 
					        type: normal
 | 
				
			||||||
        title: 'Test parent path'
 | 
					        title: 'Test parent path'
 | 
				
			||||||
        description: ''
 | 
					        description: ''
 | 
				
			||||||
        name: tools
 | 
					        menu_name: tools
 | 
				
			||||||
        weight: '0'
 | 
					        weight: '0'
 | 
				
			||||||
      defaults:
 | 
					      defaults:
 | 
				
			||||||
        title: '0'
 | 
					        title: '0'
 | 
				
			||||||
| 
						 | 
					@ -53,7 +53,7 @@ display:
 | 
				
			||||||
        type: tab
 | 
					        type: tab
 | 
				
			||||||
        title: 'Test local tab'
 | 
					        title: 'Test local tab'
 | 
				
			||||||
        description: ''
 | 
					        description: ''
 | 
				
			||||||
        name: tools
 | 
					        menu_name: tools
 | 
				
			||||||
        weight: '0'
 | 
					        weight: '0'
 | 
				
			||||||
        context: '0'
 | 
					        context: '0'
 | 
				
			||||||
      defaults:
 | 
					      defaults:
 | 
				
			||||||
| 
						 | 
					@ -62,6 +62,23 @@ display:
 | 
				
			||||||
    display_title: Page
 | 
					    display_title: Page
 | 
				
			||||||
    id: page_2
 | 
					    id: page_2
 | 
				
			||||||
    position: 0
 | 
					    position: 0
 | 
				
			||||||
 | 
					  page_3:
 | 
				
			||||||
 | 
					    display_options:
 | 
				
			||||||
 | 
					      path: test_page_display_menu_link
 | 
				
			||||||
 | 
					      title: 'Test menu link'
 | 
				
			||||||
 | 
					      menu:
 | 
				
			||||||
 | 
					        type: normal
 | 
				
			||||||
 | 
					        title: 'Test menu link'
 | 
				
			||||||
 | 
					        description: ''
 | 
				
			||||||
 | 
					        menu_name: tools
 | 
				
			||||||
 | 
					        weight: '0'
 | 
				
			||||||
 | 
					        context: '0'
 | 
				
			||||||
 | 
					      defaults:
 | 
				
			||||||
 | 
					        title: '0'
 | 
				
			||||||
 | 
					    display_plugin: page
 | 
				
			||||||
 | 
					    display_title: Page
 | 
				
			||||||
 | 
					    id: page_3
 | 
				
			||||||
 | 
					    position: 0
 | 
				
			||||||
label: 'Test page menu'
 | 
					label: 'Test page menu'
 | 
				
			||||||
id: test_page_display_menu
 | 
					id: test_page_display_menu
 | 
				
			||||||
tag: ''
 | 
					tag: ''
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue