Commit 5dff3def authored by alexpott's avatar alexpott
Browse files

Issue #1968596 by dawehner, damiankloip | xjm: Fixed New displays are not ordered correctly.

parent 76f7b944
......@@ -216,7 +216,7 @@ public function addDisplay($plugin_id = 'page', $title = NULL, $id = NULL) {
'display_plugin' => $plugin_id,
'id' => $id,
'display_title' => $title,
'position' => NULL,
'position' => count($this->display),
'display_options' => array(),
);
......
......@@ -70,10 +70,29 @@ function testDisplayPlugin() {
'display_plugin' => 'display_test',
'id' => 'display_test_1',
'display_title' => 'Display test',
'position' => NULL,
'position' => 1,
);
$this->assertEqual($displays['display_test_1'], $options);
// Add another one to ensure that position is counted up.
$view->storage->addDisplay('display_test');
$displays = $view->storage->get('display');
$options = array(
'display_options' => array(),
'display_plugin' => 'display_test',
'id' => 'display_test_2',
'display_title' => 'Display test 2',
'position' => 2,
);
$this->assertEqual($displays['display_test_2'], $options);
// Move the second display before the first one in order to test custom
// sorting.
$displays['display_test_1']['position'] = 2;
$displays['display_test_2']['position'] = 1;
$view->storage->set('display', $displays);
$view->save();
$view->setDisplay('display_test_1');
$this->assertTrue($view->display_handler instanceof DisplayTestPlugin, 'The correct display handler instance is on the view object.');
......@@ -88,8 +107,8 @@ function testDisplayPlugin() {
// Change this option and check the title of out output.
$view->display_handler->overrideOption('test_option', 'Test option title');
$view->save();
$output = $view->preview();
$output = drupal_render($output);
......@@ -99,6 +118,10 @@ function testDisplayPlugin() {
// Test that the display category/summary is in the UI.
$this->drupalGet('admin/structure/views/view/test_view/edit/display_test_1');
$this->assertText('Display test settings');
// Ensure that the order is as expected.
$result = $this->xpath('//ul[@id="views-display-menu-tabs"]/li');
$this->assertEqual((string) $result[0]->a, 'Display test 2');
$this->assertEqual((string) $result[1]->a, 'Display test');
$this->clickLink('Test option title');
......
......@@ -109,6 +109,7 @@ public function getDisplayTabs(ViewUI $view) {
foreach ($displays as $id => $display) {
$tabs[$id] = array(
'#theme' => 'menu_local_task',
'#weight' => $display['position'],
'#link' => array(
'title' => $this->getDisplayLabel($view, $id),
'href' => 'admin/structure/views/view/' . $view->id() . '/edit/' . $id,
......
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