Skip to content
Snippets Groups Projects
Commit e5d92017 authored by Angie Byron's avatar Angie Byron
Browse files

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

parent 2069bf0c
No related branches found
No related tags found
No related merge requests found
...@@ -1298,10 +1298,20 @@ public function optionsSummary(&$categories, &$options) { ...@@ -1298,10 +1298,20 @@ public function optionsSummary(&$categories, &$options) {
} }
if ($this->usesLinkDisplay()) { if ($this->usesLinkDisplay()) {
$display_id = $this->getLinkDisplay(); $link_display_option = $this->getOption('link_display');
$displays = $this->view->storage->get('display'); $link_display = $this->t('None');
$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; 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( $options['link_display'] = array(
'category' => 'pager', 'category' => 'pager',
'title' => t('Link display'), 'title' => t('Link display'),
...@@ -1708,21 +1718,20 @@ public function buildOptionsForm(&$form, &$form_state) { ...@@ -1708,21 +1718,20 @@ public function buildOptionsForm(&$form, &$form_state) {
break; break;
case 'link_display': case 'link_display':
$form['#title'] .= t('Which display to use for path'); $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) { foreach ($this->view->storage->get('display') as $display_id => $display) {
if ($this->view->displayHandlers->get($display_id)->hasPath()) { if ($this->view->displayHandlers->get($display_id)->hasPath()) {
$options[$display_id] = $display['display_title']; $options[$display_id] = $display['display_title'];
} }
} }
$options['custom_url'] = t('Custom URL');
if (count($options)) { $form['link_display'] = array(
$form['link_display'] = array( '#type' => 'radios',
'#title' => t('Custom URL'), '#options' => $options,
'#type' => 'radios', '#description' => t("Which display to use to get this display's path for things like summary links, rss feed links, more links, etc."),
'#options' => $options, '#default_value' => $this->getOption('link_display'),
'#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(); $options = array();
$count = 0; // This lets us prepare the key as we want it printed. $count = 0; // This lets us prepare the key as we want it printed.
......
...@@ -265,6 +265,16 @@ public function testLinkDisplay() { ...@@ -265,6 +265,16 @@ public function testLinkDisplay() {
// Test setting the link display in the UI form. // Test setting the link display in the UI form.
$path = 'admin/structure/views/view/test_display/edit/block_1'; $path = 'admin/structure/views/view/test_display/edit/block_1';
$link_display_path = 'admin/structure/views/nojs/display/test_display/block_1/link_display'; $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')); $this->drupalPostForm($link_display_path, array('link_display' => 'page_1'), t('Apply'));
// The form redirects to the master display. // The form redirects to the master display.
$this->drupalGet($path); $this->drupalGet($path);
...@@ -272,7 +282,6 @@ public function testLinkDisplay() { ...@@ -272,7 +282,6 @@ public function testLinkDisplay() {
$result = $this->xpath("//a[contains(@href, :path)]", array(':path' => $link_display_path)); $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.'); $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')); $this->drupalPostForm($link_display_path, array('link_display' => 'custom_url', 'link_url' => 'a-custom-url'), t('Apply'));
// The form redirects to the master display. // The form redirects to the master display.
$this->drupalGet($path); $this->drupalGet($path);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment