Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
project
drupal
Commits
994f683e
Commit
994f683e
authored
Apr 22, 2015
by
Jess
Browse files
Issue
#2446783
by mpdonadio, dawehner, koence: Views preview not working without saving new display
parent
e11f8458
Changes
4
Hide whitespace changes
Inline
Side-by-side
core/modules/views/src/Form/ViewsForm.php
View file @
994f683e
...
...
@@ -14,6 +14,7 @@
use
Drupal\Core\Form\FormInterface
;
use
Drupal\Core\Form\FormStateInterface
;
use
Drupal\Core\Routing\UrlGeneratorInterface
;
use
Drupal\Core\Url
;
use
Drupal\views\ViewExecutable
;
use
Symfony\Component\DependencyInjection\ContainerInterface
;
use
Symfony\Component\HttpFoundation\RequestStack
;
...
...
core/modules/views/src/ViewExecutable.php
View file @
994f683e
...
...
@@ -21,6 +21,7 @@
use
Drupal\Component\Utility\Tags
;
use
Symfony\Component\HttpFoundation\Request
;
use
Symfony\Component\HttpFoundation\Response
;
use
Symfony\Component\Routing\Exception\RouteNotFoundException
;
/**
* Represents a view as a whole.
...
...
@@ -1763,6 +1764,17 @@ public function hasUrl($args = NULL, $display_id = NULL) {
return
FALSE
;
}
// Look up the route name to make sure it exists. The name may exist, but
// not be available yet in some instances when editing a view and doing
// a live preview.
$provider
=
\
Drupal
::
service
(
'router.route_provider'
);
try
{
$provider
->
getRouteByName
(
$display_handler
->
getRouteName
());
}
catch
(
RouteNotFoundException
$e
)
{
return
FALSE
;
}
return
TRUE
;
}
...
...
core/modules/views_ui/src/Tests/UnsavedPreviewTest.php
0 → 100644
View file @
994f683e
<?php
/**
* @file
* Contains of \Drupal\views_ui\Tests\UnsavedPreviewTest.
*/
namespace
Drupal\views_ui\Tests
;
use
Drupal\views\Tests\ViewTestBase
;
/**
* Tests covering Preview of unsaved Views.
*
* @group views_ui
*/
class
UnsavedPreviewTest
extends
ViewTestBase
{
/**
* Views used by this test.
*
* @var array
*/
public
static
$testViews
=
[
'content'
];
/**
* An admin user with the 'administer views' permission.
*
* @var \Drupal\user\UserInterface
*/
protected
$adminUser
;
/**
* {@inheritdoc}
*/
public
static
$modules
=
array
(
'node'
,
'views_ui'
);
/**
* Sets up a Drupal site for running functional and integration tests.
*/
protected
function
setUp
()
{
parent
::
setUp
(
FALSE
);
$this
->
adminUser
=
$this
->
drupalCreateUser
([
'administer views'
]);
$this
->
drupalLogin
(
$this
->
adminUser
);
}
/**
* Tests previews of unsaved new page displays.
*/
public
function
testUnsavedPageDisplayPreview
()
{
$this
->
drupalCreateContentType
([
'type'
=>
'page'
]);
for
(
$i
=
0
;
$i
<
5
;
$i
++
)
{
$this
->
drupalCreateNode
();
}
$this
->
drupalGet
(
'admin/structure/views/view/content'
);
$this
->
assertResponse
(
200
);
$this
->
drupalPostForm
(
NULL
,
[],
t
(
'Add Page'
));
$this
->
assertResponse
(
200
);
$this
->
drupalGet
(
'admin/structure/views/nojs/display/content/page_2/path'
);
$this
->
assertResponse
(
200
);
$this
->
drupalPostForm
(
NULL
,
[
'path'
=>
'foobarbaz'
],
t
(
'Apply'
));
$this
->
assertResponse
(
200
);
$this
->
drupalPostForm
(
NULL
,
[],
t
(
'Update preview'
));
$this
->
assertResponse
(
200
);
$this
->
assertText
(
t
(
'This display has no path'
));
$this
->
drupalGet
(
'admin/structure/views/view/content/edit/page_2'
);
$this
->
assertResponse
(
200
);
$this
->
drupalPostForm
(
NULL
,
[],
t
(
'Save'
));
$this
->
assertResponse
(
200
);
$this
->
drupalPostForm
(
NULL
,
[],
t
(
'Update preview'
));
$this
->
assertResponse
(
200
);
$this
->
assertLinkByHref
(
'foobarbaz'
);
}
}
core/modules/views_ui/src/ViewUI.php
View file @
994f683e
...
...
@@ -598,7 +598,7 @@ public function renderPreview($display_id, $args = array()) {
$executable
->
setArguments
(
$args
);
// Store the current view URL for later use:
if
(
$executable
->
display_handler
->
getOption
(
'path'
))
{
if
(
$executable
->
hasUrl
()
&&
$executable
->
display_handler
->
getOption
(
'path'
))
{
$path
=
$executable
->
getUrl
();
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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