Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
project
drupal
Commits
64ad4081
Commit
64ad4081
authored
Feb 10, 2016
by
catch
Browse files
Issue
#2575245
by toniteof: Click-sorting broken in previews
parent
43ea3d9f
Changes
2
Hide whitespace changes
Inline
Side-by-side
core/modules/views/views.theme.inc
View file @
64ad4081
...
...
@@ -397,6 +397,12 @@ function template_preprocess_views_view_table(&$variables) {
// A boolean variable which stores whether the table has a responsive class.
$responsive
=
FALSE
;
// For the actual site we want to not render full URLs, because this would
// make pagers cacheable per URL, which is problematic in blocks, for example.
// For the actual live preview though the javascript relies on properly
// working URLs.
$route_name
=
!
empty
(
$view
->
live_preview
)
?
'<current>'
:
'<none>'
;
$query
=
tablesort_get_query_parameters
();
if
(
isset
(
$view
->
exposed_raw_input
))
{
$query
+=
$view
->
exposed_raw_input
;
...
...
@@ -438,9 +444,7 @@ function template_preprocess_views_view_table(&$variables) {
$link_options
=
array
(
'query'
=>
$query
,
);
// It is ok to specify no URL path here as we will always reload the
// current page.
$url
=
new
Url
(
'<none>'
,
[],
$link_options
);
$url
=
new
Url
(
$route_name
,
[],
$link_options
);
$variables
[
'header'
][
$field
][
'url'
]
=
$url
->
toString
();
$variables
[
'header'
][
$field
][
'content'
]
=
$label
;
$variables
[
'header'
][
$field
][
'title'
]
=
$title
;
...
...
core/modules/views_ui/src/Tests/PreviewTest.php
View file @
64ad4081
...
...
@@ -21,7 +21,7 @@ class PreviewTest extends UITestBase {
*
* @var array
*/
public
static
$testViews
=
array
(
'test_preview'
,
'test_preview_error'
,
'test_pager_full'
,
'test_mini_pager'
);
public
static
$testViews
=
array
(
'test_preview'
,
'test_preview_error'
,
'test_pager_full'
,
'test_mini_pager'
,
'test_click_sort'
);
/**
* Tests contextual links in the preview form.
...
...
@@ -270,6 +270,32 @@ public function testPreviewError() {
$this
->
assertText
(
'Unable to preview due to validation errors.'
,
'Preview error text found.'
);
}
/**
* Tests the link to sort in the preview form.
*/
public
function
testPreviewSortLink
()
{
// Get the preview.
$this
->
getPreviewAJAX
(
'test_click_sort'
,
'page_1'
,
0
);
// Test that the header label is present.
$elements
=
$this
->
xpath
(
'//th[contains(@class, :class)]/a'
,
array
(
':class'
=>
'views-field views-field-name'
));
$this
->
assertTrue
(
!
empty
(
$elements
),
'The header label is present.'
);
// Verify link.
$this
->
assertLinkByHref
(
'preview/page_1?_wrapper_format=drupal_ajax&order=name&sort=desc'
,
0
,
'The output URL is as expected.'
);
// Click link to sort.
$this
->
clickPreviewLinkAJAX
(
$elements
[
0
][
'href'
],
0
);
// Test that the header label is present.
$elements
=
$this
->
xpath
(
'//th[contains(@class, :class)]/a'
,
array
(
':class'
=>
'views-field views-field-name is-active'
));
$this
->
assertTrue
(
!
empty
(
$elements
),
'The header label is present.'
);
// Verify link.
$this
->
assertLinkByHref
(
'preview/page_1?_wrapper_format=drupal_ajax&order=name&sort=asc'
,
0
,
'The output URL is as expected.'
);
}
/**
* Get the preview form and force an AJAX preview update.
*
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment