Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
facets
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
facets
Merge requests
!113
Draft: Issue
#3052574
: Facets with AJAX not working in most of situations
Code
Review changes
Check out branch
Download
Patches
Plain diff
Open
Draft: Issue
#3052574
: Facets with AJAX not working in most of situations
issue/facets-3052574:3052574-facets-with-ajax-2
into
2.0.x
Overview
1
Commits
18
Pipelines
0
Changes
8
Open
eduardo morales alberti
requested to merge
issue/facets-3052574:3052574-facets-with-ajax-2
into
2.0.x
2 years ago
Overview
1
Commits
18
Pipelines
0
Changes
8
Expand
Closes
#3052574
0
0
Merge request reports
Viewing commit
706db6b9
Prev
Next
Show latest version
8 files
+
39
−
118
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Files
8
Search (e.g. *.vue) (Ctrl+P)
706db6b9
Use data attributes for dom selection
· 706db6b9
Ide Braakman
authored
2 years ago
js/facets-views-ajax.js
+
8
−
47
Options
@@ -94,15 +94,11 @@
updateFacetsView
(
href
,
current_dom_id
,
view_path
);
};
}
else
if
(
facetId
==
'
facets_summary_ajax_summary
'
||
facetId
==
'
facets_summary_ajax_summary_count
'
)
{
if
(
updateFacetsSummaryBlock
())
{
$
(
once
(
facetId
,
'
[data-drupal-facets-summary-id=
'
+
facetSettings
.
facets_summary_id
+
'
] ul li
'
)).
click
(
function
(
e
)
{
e
.
preventDefault
();
var
facetLink
=
$
(
this
).
find
(
'
a
'
);
updateFacetsView
(
facetLink
.
attr
(
'
href
'
),
current_dom_id
,
view_path
);
});
}
else
if
(
facetSettings
.
hasOwnProperty
(
'
facets_summary_id
'
))
{
$
(
once
(
facetId
,
'
[data-facets-plugin-id="facets_summary_block:
'
+
facetId
+
'
"]
'
)).
on
(
'
click
'
,
'
a
'
,
function
(
e
)
{
e
.
preventDefault
();
updateFacetsView
(
$
(
this
).
attr
(
'
href
'
),
current_dom_id
,
view_path
);
});
}
// Update view on facet item click.
else
{
@@ -203,51 +199,16 @@
}
};
// Update facets summary block.
if
(
updateFacetsSummaryBlock
())
{
facet_settings
.
submit
.
update_summary_block
=
true
;
facet_settings
.
submit
.
facet_summary_plugin_ids
=
{};
let
summary_selector
=
'
[data-drupal-facets-summary-id=
'
+
settings
.
facets_views_ajax
.
facets_summary_ajax_summary
.
facets_summary_id
+
'
]
'
;
if
(
settings
.
facets_views_ajax
.
facets_summary_ajax_summary_count
!==
undefined
)
{
summary_selector
+=
'
, [data-drupal-facets-summary-id=
'
+
settings
.
facets_views_ajax
.
facets_summary_ajax_summary_count
.
facets_summary_id
+
'
]
'
;
}
$
(
summary_selector
).
each
(
function
(
index
,
summaryWrapper
)
{
let
summaryPluginId
=
$
(
summaryWrapper
).
attr
(
'
data-drupal-facets-summary-plugin-id
'
);
let
summaryPluginIdWrapper
=
$
(
summaryWrapper
).
attr
(
'
id
'
);
facet_settings
.
submit
.
facet_summary_plugin_ids
[
summaryPluginIdWrapper
]
=
summaryPluginId
;
});
}
Drupal
.
ajax
(
facet_settings
).
execute
();
};
// Helper function to determine if we should update the summary block.
// Returns true or false.
var
updateFacetsSummaryBlock
=
function
()
{
var
settings
=
drupalSettings
;
var
update_summary
=
false
;
if
(
settings
.
facets_views_ajax
.
facets_summary_ajax_summary
||
settings
.
facets_views_ajax
.
facets_summary_ajax_summary_count
)
{
update_summary
=
true
;
}
return
update_summary
;
};
// Helper function, return facet blocks.
var
facetsBlocks
=
function
()
{
// Get all ajax facets blocks from the current page.
var
facets_blocks
=
{}
;
var
facets_blocks
=
[]
;
$
(
'
.block-facets-ajax
'
).
each
(
function
(
index
)
{
var
block_id_start
=
'
js-facet-block-id-
'
;
var
block_id
=
$
.
map
(
$
(
this
).
attr
(
'
class
'
).
split
(
'
'
),
function
(
v
,
i
)
{
if
(
v
.
indexOf
(
block_id_start
)
>
-
1
)
{
return
v
.
slice
(
block_id_start
.
length
,
v
.
length
);
}
}).
join
();
var
block_selector
=
$
(
this
).
attr
(
'
id
'
);
facets_blocks
[
block_selector
]
=
block_id
;
$
(
'
[data-facets-plugin-id]
'
).
each
(
function
()
{
facets_blocks
.
push
(
$
(
this
).
attr
(
'
data-facets-plugin-id
'
));
});
return
facets_blocks
;
Loading