Commit 455a299a authored by catch's avatar catch
Browse files

Issue #1810812 by dawehner, damiankloip: Fixed Attachment is still using...

Issue #1810812 by dawehner, damiankloip: Fixed Attachment is still using display on the view object.
parent e7c0975c
......@@ -91,8 +91,8 @@ public function optionsSummary(&$categories, &$options) {
}
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 @@ public function buildOptionsForm(&$form, &$form_state) {
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 @@ public function attachTo(ViewExecutable $view, $display_id) {
$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);
......
<?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');
}
}
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: ''
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