Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
drupal
Manage
Activity
Members
Labels
Plan
Wiki
Custom issue tracker
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
project
drupal
Commits
85277153
Commit
85277153
authored
1 year ago
by
Jordan Graham
Committed by
Simeon Kesmev
1 year ago
Browse files
Options
Downloads
Patches
Plain Diff
3032353: Patched views per
https://www.drupal.org/node/3032353
.
parent
a0bf9683
No related branches found
No related tags found
1 merge request
!6106
3032353
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
core/modules/views/js/ajax_view.js
+6
-0
6 additions, 0 deletions
core/modules/views/js/ajax_view.js
core/modules/views/src/Controller/ViewAjaxController.php
+34
-15
34 additions, 15 deletions
core/modules/views/src/Controller/ViewAjaxController.php
with
40 additions
and
15 deletions
core/modules/views/js/ajax_view.js
+
6
−
0
View file @
85277153
...
...
@@ -140,6 +140,12 @@
Drupal
.
views
.
ajaxView
.
prototype
.
attachExposedFormAjax
=
function
()
{
const
that
=
this
;
this
.
exposedFormAjax
=
[];
// Add exposed_form_display option to the request.
if
(
that
.
element_settings
.
submit
)
{
that
.
element_settings
.
submit
.
exposed_form_display
=
1
;
}
// Exclude the reset buttons so no AJAX behaviors are bound. Many things
// break during the form reset phase if using AJAX.
$
(
...
...
This diff is collapsed.
Click to expand it.
core/modules/views/src/Controller/ViewAjaxController.php
+
34
−
15
View file @
85277153
...
...
@@ -3,22 +3,24 @@
namespace
Drupal\views\Controller
;
use
Drupal\Component\Utility\Html
;
use
Drupal\Component\Utility\UrlHelper
;
use
Drupal\Core\Ajax\PrependCommand
;
use
Drupal\Core\Ajax\ReplaceCommand
;
use
Drupal\Core\DependencyInjection\ContainerInjectionInterface
;
use
Drupal\Core\Entity\EntityStorageInterface
;
use
Drupal\Core\EventSubscriber\AjaxResponseSubscriber
;
use
Drupal\Core\EventSubscriber\MainContentViewSubscriber
;
use
Drupal\Core\Form\FormBuilderInterface
;
use
Drupal\Core\Path\CurrentPathStack
;
use
Drupal\Core\Render\RendererInterface
;
use
Drupal\Core\Routing\RedirectDestinationInterface
;
use
Drupal\Core\Render\RenderContext
;
use
Drupal\Core\Ajax\ScrollTopCommand
;
use
Drupal\Core\Path\CurrentPathStack
;
use
Drupal\Component\Utility\UrlHelper
;
use
Drupal\views\Ajax\ViewAjaxResponse
;
use
Drupal\views\ViewExecutableFactory
;
use
Symfony\Component\DependencyInjection\ContainerInterface
;
use
Drupal\Core\Render\RendererInterface
;
use
Drupal\Core\Form\FormBuilderInterface
;
use
Drupal\Core\Render\BubbleableMetadata
;
use
Symfony\Component\HttpFoundation\Request
;
use
Drupal\Core\Entity\EntityStorageInterface
;
use
Drupal\Core\Routing\RedirectDestinationInterface
;
use
Drupal\Core\EventSubscriber\AjaxResponseSubscriber
;
use
Drupal\Core\EventSubscriber\MainContentViewSubscriber
;
use
Symfony\Component\DependencyInjection\ContainerInterface
;
use
Drupal\Core\DependencyInjection\ContainerInjectionInterface
;
use
Symfony\Component\HttpKernel\Exception\NotFoundHttpException
;
use
Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException
;
...
...
@@ -127,6 +129,7 @@ public function ajaxView(Request $request) {
$dom_id
=
isset
(
$dom_id
)
?
preg_replace
(
'/[^a-zA-Z0-9_-]+/'
,
'-'
,
$dom_id
)
:
NULL
;
$pager_element
=
$request
->
get
(
'pager_element'
);
$pager_element
=
isset
(
$pager_element
)
?
intval
(
$pager_element
)
:
NULL
;
$exposed_form_display
=
$request
->
request
->
get
(
'exposed_form_display'
);
$response
=
new
ViewAjaxResponse
();
...
...
@@ -142,6 +145,7 @@ public function ajaxView(Request $request) {
'view_dom_id'
,
'pager_element'
,
'view_base_path'
,
'exposed_form_display'
,
AjaxResponseSubscriber
::
AJAX_REQUEST_PARAMETER
,
FormBuilderInterface
::
AJAX_FORM_REQUEST
,
MainContentViewSubscriber
::
WRAPPER_FORMAT
,
...
...
@@ -195,15 +199,30 @@ public function ajaxView(Request $request) {
$response
->
addCommand
(
new
ReplaceCommand
(
".js-view-dom-id-
$dom_id
"
,
$preview
));
$response
->
addCommand
(
new
PrependCommand
(
".js-view-dom-id-
$dom_id
"
,
[
'#type'
=>
'status_messages'
]));
// Views with ajax enabled aren't refreshing filters placed in blocks.
// Only <div> containing view is refreshed. ReplaceCommand is fixing
// that for view, if it uses ajax and exposed forms in block.
if
(
$exposed_form_display
&&
$view
->
display_handler
->
usesExposed
()
&&
$view
->
display_handler
->
getOption
(
'exposed_block'
))
{
$view_id
=
preg_replace
(
'/[^a-zA-Z0-9-]+/'
,
'-'
,
$name
.
'-'
.
$display_id
);
$context
=
new
RenderContext
();
$exposed_form
=
$this
->
renderer
->
executeInRenderContext
(
$context
,
function
()
use
(
$view
)
{
return
$view
->
display_handler
->
viewExposedFormBlocks
();
});
if
(
!
$context
->
isEmpty
())
{
$bubbleable_metadata
=
$context
->
pop
();
BubbleableMetadata
::
createFromRenderArray
(
$exposed_form
)
->
merge
(
$bubbleable_metadata
)
->
applyTo
(
$exposed_form
);
}
$response
->
addCommand
(
new
ReplaceCommand
(
"#views-exposed-form-"
.
$view_id
,
$this
->
renderer
->
render
(
$exposed_form
)));
}
return
$response
;
}
else
{
}
else
{
throw
new
AccessDeniedHttpException
();
}
}
else
{
}
else
{
throw
new
NotFoundHttpException
();
}
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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!
Save comment
Cancel
Please
register
or
sign in
to comment