Issue #1837982 by tim.plunkett, dawehner: Fixed Contextual links within the Views UI preview are broken.
parent
838a9e573c
commit
c34cdb0246
|
@ -27,6 +27,19 @@ class PreviewTest extends UITestBase {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests contextual links in the preview form.
|
||||||
|
*/
|
||||||
|
protected function testPreviewContextual() {
|
||||||
|
module_enable(array('contextual'));
|
||||||
|
$this->drupalGet('admin/structure/views/view/test_preview/edit');
|
||||||
|
$this->assertResponse(200);
|
||||||
|
$this->drupalPost(NULL, $edit = array(), t('Update preview'));
|
||||||
|
|
||||||
|
$elements = $this->xpath('//div[@id="views-live-preview"]//ul[contains(@class, :ul-class)]/li[contains(@class, :li-class)]', array(':ul-class' => 'contextual-links', ':li-class' => 'filter-add'));
|
||||||
|
$this->assertEqual(count($elements), 1, 'The contextual link to add a new field is shown.');
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests arguments in the preview form.
|
* Tests arguments in the preview form.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -394,7 +394,7 @@ function views_ui_clone_title(ViewUI $view) {
|
||||||
*/
|
*/
|
||||||
function views_ui_preprocess_views_view(&$vars) {
|
function views_ui_preprocess_views_view(&$vars) {
|
||||||
$view = $vars['view'];
|
$view = $vars['view'];
|
||||||
if (!empty($view->views_ui_context) && module_exists('contextual')) {
|
if (!empty($view->live_preview) && module_exists('contextual')) {
|
||||||
$view->hide_admin_links = TRUE;
|
$view->hide_admin_links = TRUE;
|
||||||
foreach (array('title', 'header', 'exposed', 'rows', 'pager', 'more', 'footer', 'empty', 'attachment_after', 'attachment_before') as $section) {
|
foreach (array('title', 'header', 'exposed', 'rows', 'pager', 'more', 'footer', 'empty', 'attachment_after', 'attachment_before') as $section) {
|
||||||
if (!empty($vars[$section])) {
|
if (!empty($vars[$section])) {
|
||||||
|
@ -422,9 +422,9 @@ function views_ui_preprocess_views_view(&$vars) {
|
||||||
* @param $title
|
* @param $title
|
||||||
* Add a bolded title of this section.
|
* Add a bolded title of this section.
|
||||||
*/
|
*/
|
||||||
function views_ui_view_preview_section_handler_links(ViewUI $view, $type, $title = FALSE) {
|
function views_ui_view_preview_section_handler_links(ViewExecutable $view, $type, $title = FALSE) {
|
||||||
$display = $view->executable->display_handler->display;
|
$display = $view->display_handler->display;
|
||||||
$handlers = $view->executable->display_handler->getHandlers($type);
|
$handlers = $view->display_handler->getHandlers($type);
|
||||||
$links = array();
|
$links = array();
|
||||||
|
|
||||||
$types = ViewExecutable::viewsHandlerTypes();
|
$types = ViewExecutable::viewsHandlerTypes();
|
||||||
|
@ -438,13 +438,13 @@ function views_ui_view_preview_section_handler_links(ViewUI $view, $type, $title
|
||||||
$field_name = $handler->adminLabel(TRUE);
|
$field_name = $handler->adminLabel(TRUE);
|
||||||
$links[$type . '-edit-' . $id] = array(
|
$links[$type . '-edit-' . $id] = array(
|
||||||
'title' => t('Edit @section', array('@section' => $field_name)),
|
'title' => t('Edit @section', array('@section' => $field_name)),
|
||||||
'href' => "admin/structure/views/nojs/config-item/{$view->get('name')}/{$display['id']}/$type/$id",
|
'href' => "admin/structure/views/nojs/config-item/{$view->storage->get('name')}/{$display['id']}/$type/$id",
|
||||||
'attributes' => array('class' => array('views-ajax-link')),
|
'attributes' => array('class' => array('views-ajax-link')),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
$links[$type . '-add'] = array(
|
$links[$type . '-add'] = array(
|
||||||
'title' => t('Add new'),
|
'title' => t('Add new'),
|
||||||
'href' => "admin/structure/views/nojs/add-item/{$view->get('name')}/{$display['id']}/$type",
|
'href' => "admin/structure/views/nojs/add-item/{$view->storage->get('name')}/{$display['id']}/$type",
|
||||||
'attributes' => array('class' => array('views-ajax-link')),
|
'attributes' => array('class' => array('views-ajax-link')),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -454,12 +454,12 @@ function views_ui_view_preview_section_handler_links(ViewUI $view, $type, $title
|
||||||
/**
|
/**
|
||||||
* Returns a link to editing a certain display setting.
|
* Returns a link to editing a certain display setting.
|
||||||
*/
|
*/
|
||||||
function views_ui_view_preview_section_display_category_links(ViewUI $view, $type, $title) {
|
function views_ui_view_preview_section_display_category_links(ViewExecutable $view, $type, $title) {
|
||||||
$display = $view->display_handler->display;
|
$display = $view->display_handler->display;
|
||||||
$links = array(
|
$links = array(
|
||||||
$type . '-edit' => array(
|
$type . '-edit' => array(
|
||||||
'title' => t('Edit @section', array('@section' => $title)),
|
'title' => t('Edit @section', array('@section' => $title)),
|
||||||
'href' => "admin/structure/views/nojs/display/{$view->get('name')}/{$display['id']}/$type",
|
'href' => "admin/structure/views/nojs/display/{$view->storage->get('name')}/{$display['id']}/$type",
|
||||||
'attributes' => array('class' => array('views-ajax-link')),
|
'attributes' => array('class' => array('views-ajax-link')),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
@ -470,8 +470,8 @@ function views_ui_view_preview_section_display_category_links(ViewUI $view, $typ
|
||||||
/**
|
/**
|
||||||
* Returns all contextual links for the main content part of the view.
|
* Returns all contextual links for the main content part of the view.
|
||||||
*/
|
*/
|
||||||
function views_ui_view_preview_section_rows_links(ViewUI $view) {
|
function views_ui_view_preview_section_rows_links(ViewExecutable $view) {
|
||||||
$display = $view->executable->display_handler->display;
|
$display = $view->display_handler->display;
|
||||||
$links = array();
|
$links = array();
|
||||||
$links = array_merge($links, views_ui_view_preview_section_handler_links($view, 'filter', TRUE));
|
$links = array_merge($links, views_ui_view_preview_section_handler_links($view, 'filter', TRUE));
|
||||||
$links = array_merge($links, views_ui_view_preview_section_handler_links($view, 'field', TRUE));
|
$links = array_merge($links, views_ui_view_preview_section_handler_links($view, 'field', TRUE));
|
||||||
|
|
|
@ -503,7 +503,7 @@ function template_preprocess_views_ui_view_preview_section(&$vars) {
|
||||||
'#links' => $links,
|
'#links' => $links,
|
||||||
'#attributes' => array('class' => array('contextual-links')),
|
'#attributes' => array('class' => array('contextual-links')),
|
||||||
'#attached' => array(
|
'#attached' => array(
|
||||||
'library' => array(array('contextual', 'contextual-links')),
|
'library' => array(array('contextual', 'drupal.contextual-links')),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
$vars['links'] = drupal_render($build);
|
$vars['links'] = drupal_render($build);
|
||||||
|
|
Loading…
Reference in New Issue