Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
facets-3052574
Manage
Activity
Members
Labels
Plan
Custom issue tracker
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
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
Issue forks
facets-3052574
Commits
7357a430
Commit
7357a430
authored
1 year ago
by
Ted Cooper
Browse files
Options
Downloads
Patches
Plain Diff
Fix indenting. Minor CS.
parent
9a9e6a99
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
js/facets-views-ajax.js
+2
-3
2 additions, 3 deletions
js/facets-views-ajax.js
src/Controller/FacetBlockAjaxController.php
+1
-1
1 addition, 1 deletion
src/Controller/FacetBlockAjaxController.php
src/Plugin/Block/FacetBlock.php
+53
-50
53 additions, 50 deletions
src/Plugin/Block/FacetBlock.php
with
56 additions
and
54 deletions
js/facets-views-ajax.js
+
2
−
3
View file @
7357a430
...
@@ -3,7 +3,6 @@
...
@@ -3,7 +3,6 @@
* Facets views AJAX handling.
* Facets views AJAX handling.
*/
*/
(
function
(
$
,
Drupal
,
once
)
{
(
function
(
$
,
Drupal
,
once
)
{
'
use strict
'
;
'
use strict
'
;
...
@@ -39,7 +38,7 @@
...
@@ -39,7 +38,7 @@
return
;
return
;
}
}
// Update view on range slider stop event
// Update view on range slider stop event
.
if
(
typeof
settings
.
facets
!==
"
undefined
"
&&
settings
.
facets
.
sliders
&&
settings
.
facets
.
sliders
[
facetId
])
{
if
(
typeof
settings
.
facets
!==
"
undefined
"
&&
settings
.
facets
.
sliders
&&
settings
.
facets
.
sliders
[
facetId
])
{
settings
.
facets
.
sliders
[
facetId
].
stop
=
function
(
e
,
ui
)
{
settings
.
facets
.
sliders
[
facetId
].
stop
=
function
(
e
,
ui
)
{
const
sliderSettings
=
settings
.
facets
.
sliders
[
facetId
];
const
sliderSettings
=
settings
.
facets
.
sliders
[
facetId
];
...
@@ -73,7 +72,7 @@
...
@@ -73,7 +72,7 @@
for
(
let
paramName
in
newQueryParams
)
{
for
(
let
paramName
in
newQueryParams
)
{
if
(
paramName
.
substr
(
0
,
1
)
===
'
f
'
)
{
if
(
paramName
.
substr
(
0
,
1
)
===
'
f
'
)
{
value
=
newQueryParams
[
paramName
];
value
=
newQueryParams
[
paramName
];
//
r
eplace
//
R
eplace
.
facetKey
=
value
.
substr
(
0
,
value
.
indexOf
(
'
:
'
));
facetKey
=
value
.
substr
(
0
,
value
.
indexOf
(
'
:
'
));
if
(
typeof
facetPositions
[
facetKey
]
!==
'
undefined
'
)
{
if
(
typeof
facetPositions
[
facetKey
]
!==
'
undefined
'
)
{
paramKey
=
'
f[
'
+
facetPositions
[
facetKey
]
+
'
]
'
;
paramKey
=
'
f[
'
+
facetPositions
[
facetKey
]
+
'
]
'
;
...
...
This diff is collapsed.
Click to expand it.
src/Controller/FacetBlockAjaxController.php
+
1
−
1
View file @
7357a430
...
@@ -155,7 +155,7 @@ class FacetBlockAjaxController extends ControllerBase {
...
@@ -155,7 +155,7 @@ class FacetBlockAjaxController extends ControllerBase {
$container
=
\Drupal
::
getContainer
();
$container
=
\Drupal
::
getContainer
();
$container
->
set
(
'request_stack'
,
$request_stack
);
$container
->
set
(
'request_stack'
,
$request_stack
);
foreach
(
$facets_blocks
as
$block_selector
=>
$block_id
)
{
foreach
(
$facets_blocks
as
$block_selector
=>
$block_id
)
{
// Facet block render array.
// Facet block render array.
$block_view
=
NULL
;
$block_view
=
NULL
;
// Re prepare from css standarts.
// Re prepare from css standarts.
...
...
This diff is collapsed.
Click to expand it.
src/Plugin/Block/FacetBlock.php
+
53
−
50
View file @
7357a430
...
@@ -2,14 +2,14 @@
...
@@ -2,14 +2,14 @@
namespace
Drupal\facets\Plugin\Block
;
namespace
Drupal\facets\Plugin\Block
;
use
Drupal\Component\Utility\Html
;
use
Drupal\Core\Access\AccessResult
;
use
Drupal\Core\Access\AccessResult
;
use
Drupal\Core\Block\BlockBase
;
use
Drupal\Core\Block\BlockBase
;
use
Drupal\Component\Utility\Html
;
use
Drupal\Core\Cache\Cache
;
use
Drupal\Core\Cache\Cache
;
use
Drupal\Core\Cache\CacheableMetadata
;
use
Drupal\Core\Cache\CacheableMetadata
;
use
Drupal\Core\Entity\EntityStorageInterface
;
use
Drupal\Core\Entity\EntityStorageInterface
;
use
Drupal\Core\Plugin\ContainerFactoryPluginInterface
;
use
Drupal\Core\Form\FormStateInterface
;
use
Drupal\Core\Form\FormStateInterface
;
use
Drupal\Core\Plugin\ContainerFactoryPluginInterface
;
use
Drupal\Core\Session\AccountInterface
;
use
Drupal\Core\Session\AccountInterface
;
use
Drupal\facets\FacetInterface
;
use
Drupal\facets\FacetInterface
;
use
Drupal\facets\FacetManager\DefaultFacetManager
;
use
Drupal\facets\FacetManager\DefaultFacetManager
;
...
@@ -40,6 +40,8 @@ class FacetBlock extends BlockBase implements ContainerFactoryPluginInterface {
...
@@ -40,6 +40,8 @@ class FacetBlock extends BlockBase implements ContainerFactoryPluginInterface {
protected
$facetStorage
;
protected
$facetStorage
;
/**
/**
* The facet entity.
*
* @var \Drupal\facets\FacetInterface
* @var \Drupal\facets\FacetInterface
*/
*/
protected
$facet
;
protected
$facet
;
...
@@ -93,56 +95,57 @@ class FacetBlock extends BlockBase implements ContainerFactoryPluginInterface {
...
@@ -93,56 +95,57 @@ class FacetBlock extends BlockBase implements ContainerFactoryPluginInterface {
// Let the facet_manager build the facets.
// Let the facet_manager build the facets.
$facet_build
=
$this
->
facetManager
->
build
(
$facet
);
$facet_build
=
$this
->
facetManager
->
build
(
$facet
);
if
(
$facet_build
)
{
if
(
$facet_build
)
{
CacheableMetadata
::
createFromObject
(
$this
)
->
applyTo
(
$build
);
CacheableMetadata
::
createFromObject
(
$this
)
->
applyTo
(
$build
);
// Add extra elements from facet source, for example, ajax scripts.
// Add extra elements from facet source, for example, ajax scripts.
// @see Drupal\facets\Plugin\facets\facet_source\SearchApiDisplay
// @see Drupal\facets\Plugin\facets\facet_source\SearchApiDisplay
/** @var \Drupal\facets\FacetSource\FacetSourcePluginInterface $facet_source */
/** @var \Drupal\facets\FacetSource\FacetSourcePluginInterface $facet_source */
$facet_source
=
$facet
->
getFacetSource
();
$facet_source
=
$facet
->
getFacetSource
();
$facet_build
+=
$facet_source
->
buildFacet
();
$facet_build
+=
$facet_source
->
buildFacet
();
$build
=
[
$build
=
[
'#type'
=>
'container'
,
'#type'
=>
'container'
,
'#contextual_links'
=>
[
'#contextual_links'
=>
[
'facets_facet'
=>
[
'facets_facet'
=>
[
'route_parameters'
=>
[
'facets_facet'
=>
$facet
->
id
()],
'route_parameters'
=>
[
'facets_facet'
=>
$facet
->
id
()],
],
],
],
],
'#attributes'
=>
[
'#attributes'
=>
[
'class'
=>
[
'block-facet__wrapper'
],
'class'
=>
[
'block-facet__wrapper'
],
],
],
$facet_build
,
0
=>
$facet_build
,
];
];
// Add css classes.
// Add css classes.
if
(
!
empty
(
$facet_build
[
0
][
'#attributes'
][
'class'
]))
{
if
(
!
empty
(
$facet_build
[
0
][
'#attributes'
][
'class'
]))
{
$css_classes
=
$facet_build
[
0
][
'#attributes'
][
'class'
];
$css_classes
=
$facet_build
[
0
][
'#attributes'
][
'class'
];
// Active/inactive css classes.
// Active/inactive css classes.
if
(
in_array
(
'facet-active'
,
$css_classes
))
{
if
(
in_array
(
'facet-active'
,
$css_classes
))
{
$build
[
'#attributes'
][
'class'
][]
=
'facet-active'
;
$build
[
'#attributes'
][
'class'
][]
=
'facet-active'
;
}
else
{
$build
[
'#attributes'
][
'class'
][]
=
'facet-inactive'
;
}
// Whether it is necessary to add hide css class.
if
(
in_array
(
'facet-hidden'
,
$css_classes
))
{
$build
[
'#attributes'
][
'class'
][]
=
'hidden'
;
}
}
}
else
{
// Add classes needed for ajax.
$build
[
'#attributes'
][
'class'
][]
=
'facet-inactive'
;
if
(
!
empty
(
$facet_build
[
'#use_ajax'
]))
{
$build
[
'#attributes'
][
'class'
][]
=
'block-facets-ajax'
;
$block_id
=
str_replace
(
':'
,
'--'
,
$this
->
pluginId
);
$block_id
=
Html
::
cleanCssIdentifier
(
$block_id
);
$build
[
'#attributes'
][
'class'
][]
=
'js-facet-block-id-'
.
$block_id
;
$build
[
'#attributes'
][
'id'
]
=
Html
::
getUniqueId
(
$block_id
);
}
}
// Whether it is necessary to add hide css class.
// To render correctly in different situations.
if
(
in_array
(
'facet-hidden'
,
$css_classes
))
{
$build
=
[
$build
[
'#attributes'
][
'class'
][]
=
'hidden'
;
'facet_block'
=>
$build
,
}
];
}
// Add classes needed for ajax.
if
(
!
empty
(
$facet_build
[
'#use_ajax'
]))
{
$build
[
'#attributes'
][
'class'
][]
=
'block-facets-ajax'
;
$block_id
=
str_replace
(
':'
,
'--'
,
$this
->
pluginId
);
$block_id
=
Html
::
cleanCssIdentifier
(
$block_id
);
$build
[
'#attributes'
][
'class'
][]
=
'js-facet-block-id-'
.
$block_id
;
$build
[
'#attributes'
][
'id'
]
=
Html
::
getUniqueId
(
$block_id
);
}
// To render correctly in different situations.
$build
=
[
'facet_block'
=>
$build
,
];
}
}
return
$build
;
return
$build
;
}
}
...
...
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