Commit e5d92017 authored by webchick's avatar webchick

Issue #2160389 by damiankloip: [regression] Link display form and summary needs fixing.

parent 2069bf0c
......@@ -1298,10 +1298,20 @@ public function optionsSummary(&$categories, &$options) {
}
if ($this->usesLinkDisplay()) {
$display_id = $this->getLinkDisplay();
$displays = $this->view->storage->get('display');
$link_display = empty($displays[$display_id]) ? t('None') : check_plain($displays[$display_id]['display_title']);
$link_display = $this->getOption('link_display') == 'custom_url' ? t('Custom URL') : $link_display;
$link_display_option = $this->getOption('link_display');
$link_display = $this->t('None');
if ($link_display_option == 'custom_url') {
$link_display = $this->t('Custom URL');
}
elseif (!empty($link_display_option)) {
$display_id = $this->getLinkDisplay();
$displays = $this->view->storage->get('display');
if (!empty($displays[$display_id])) {
$link_display = String::checkPlain($displays[$display_id]['display_title']);
}
}
$options['link_display'] = array(
'category' => 'pager',
'title' => t('Link display'),
......@@ -1708,21 +1718,20 @@ public function buildOptionsForm(&$form, &$form_state) {
break;
case 'link_display':
$form['#title'] .= t('Which display to use for path');
$options = array(FALSE => $this->t('None'), 'custom_url' => $this->t('Custom URL'));
foreach ($this->view->storage->get('display') as $display_id => $display) {
if ($this->view->displayHandlers->get($display_id)->hasPath()) {
$options[$display_id] = $display['display_title'];
}
}
$options['custom_url'] = t('Custom URL');
if (count($options)) {
$form['link_display'] = array(
'#title' => t('Custom URL'),
'#type' => 'radios',
'#options' => $options,
'#description' => t("Which display to use to get this display's path for things like summary links, rss feed links, more links, etc."),
'#default_value' => $this->getOption('link_display'),
);
}
$form['link_display'] = array(
'#type' => 'radios',
'#options' => $options,
'#description' => t("Which display to use to get this display's path for things like summary links, rss feed links, more links, etc."),
'#default_value' => $this->getOption('link_display'),
);
$options = array();
$count = 0; // This lets us prepare the key as we want it printed.
......
......@@ -265,6 +265,16 @@ public function testLinkDisplay() {
// Test setting the link display in the UI form.
$path = 'admin/structure/views/view/test_display/edit/block_1';
$link_display_path = 'admin/structure/views/nojs/display/test_display/block_1/link_display';
// Test the link text displays 'None' and not 'Block 1'
$this->drupalGet($path);
$result = $this->xpath("//a[contains(@href, :path)]", array(':path' => $link_display_path));
$this->assertEqual($result[0], t('None'), 'Make sure that the link option summary shows "None" by default.');
$this->drupalGet($link_display_path);
$this->assertFieldChecked('edit-link-display-0');
// Test the default radio option on the link display form.
$this->drupalPostForm($link_display_path, array('link_display' => 'page_1'), t('Apply'));
// The form redirects to the master display.
$this->drupalGet($path);
......@@ -272,7 +282,6 @@ public function testLinkDisplay() {
$result = $this->xpath("//a[contains(@href, :path)]", array(':path' => $link_display_path));
$this->assertEqual($result[0], 'Page', 'Make sure that the link option summary shows the right linked display.');
$link_display_path = 'admin/structure/views/nojs/display/test_display/block_1/link_display';
$this->drupalPostForm($link_display_path, array('link_display' => 'custom_url', 'link_url' => 'a-custom-url'), t('Apply'));
// The form redirects to the master display.
$this->drupalGet($path);
......
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