Issue #1810812 by dawehner, damiankloip: Fixed Attachment is still using display on the view object.

8.0.x
catch 2013-01-07 11:17:57 +00:00
parent e7c0975c57
commit 455a299a4d
3 changed files with 126 additions and 5 deletions

View File

@ -91,8 +91,8 @@ class Attachment extends DisplayPluginBase {
}
elseif (count($displays) == 1) {
$display = array_shift($displays);
if (!empty($this->view->display[$display])) {
$attach_to = check_plain($this->view->display[$display]['display_title']);
if (!empty($this->view->storage->display[$display])) {
$attach_to = check_plain($this->view->storage->display[$display]['display_title']);
}
}
@ -194,7 +194,7 @@ class Attachment extends DisplayPluginBase {
case 'displays':
$form['#title'] .= t('Attach to');
$displays = array();
foreach ($this->view->display as $display_id => $display) {
foreach ($this->view->storage->get('display') as $display_id => $display) {
if (!empty($this->view->displayHandlers[$display_id]) && $this->view->displayHandlers[$display_id]->acceptAttachments()) {
$displays[$display_id] = $display['display_title'];
}
@ -246,8 +246,8 @@ class Attachment extends DisplayPluginBase {
$view->setArguments($args);
$view->setDisplay($this->display['id']);
if ($this->getOption('inherit_pager')) {
$view->display_handler->usesPager = $this->view->display[$display_id]->handler->usesPager();
$view->display_handler->setOption('pager', $this->view->display[$display_id]->handler->getOption('pager'));
$view->display_handler->usesPager = $this->view->displayHandlers[$display_id]->usesPager();
$view->display_handler->setOption('pager', $this->view->displayHandlers[$display_id]->getOption('pager'));
}
$attachment = $view->executeDisplay($this->display['id'], $args);

View File

@ -0,0 +1,53 @@
<?php
/**
* @file
* Contains \Drupal\views\Tests\UI\DisplayAttachmentTest.
*/
namespace Drupal\views\Tests\UI;
/**
* Tests the UI for the attachment display plugin.
*
* @see Drupal\views\Plugin\views\display\Attachment
*/
class DisplayAttachmentTest extends UITestBase {
/**
* Views used by this test.
*
* @var array
*/
public static $testViews = array('test_attachment_ui');
public static function getInfo() {
return array(
'name' => 'Display: Attachment',
'description' => 'Tests the UI for the attachment display plugin.',
'group' => 'Views UI',
);
}
/**
* Tests the attachment UI.
*/
public function testAttachmentUI() {
$this->drupalGet('admin/structure/views/view/test_attachment_ui/edit/attachment_1');
$this->assertText(t('Not defined'), 'The right text appears if there is no attachment selection yet.');
$this->drupalGet('admin/structure/views/nojs/display/test_attachment_ui/attachment_1/displays');
foreach (array('default', 'page-1') as $display_id) {
$this->assertNoFieldChecked("edit-displays-$display_id", format_string('Make sure the @display_id can be marked as attached', array('@display_id' => $display_id)));
}
// Save the attachments and test the value on the view.
$this->drupalPost(NULL, array('displays[default]' => 1, 'displays[page_1]' => 1), t('Apply'));
$this->drupalPost(NULL, array(), t('Save'));
$view = views_get_view('test_attachment_ui');
$view->initDisplay();
$this->assertEqual(array_keys($view->displayHandlers['attachment_1']->getOption('displays')), array('default', 'page_1'), 'The attached displays got saved as expected');
}
}

View File

@ -0,0 +1,68 @@
api_version: '3.0'
base_table: views_test_data
core: '8'
description: ''
disabled: '0'
display:
default:
display_options:
access:
type: perm
options:
perm: 'views_test_data test permission'
cache:
type: none
exposed_form:
type: basic
pager:
type: full
style:
type: default
row:
type: fields
fields:
id:
id: id
table: views_test_data
field: id
display_plugin: default
display_title: Master
id: default
position: '0'
attachment_1:
display_plugin: attachment
display_title: Attachment
id: attachment_1
position: '1'
page_1:
display_plugin: page
display_title: Page
display_options:
path: test_attachment_ui
id: page_1
position: '2'
feed_1:
display_plugin: feed
id: feed_1
display_title: Feed
position: ''
display_options:
pager:
type: some
style:
type: rss
row:
type: rss_fields
options:
title_field: id
link_field: id
description_field: id
creator_field: id
date_field: id
guid_field_options:
guid_field: id
guid_field_is_permalink: '0'
path: test_attachment_ui_feed
position: '3'
name: test_attachment_ui
tag: ''