-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
WIP: Add ga4-index data attrs in Ruby vs JS
We're now able to provide the index from the facet partials thus avoiding the need for the code in GOVUK.analyticsGa4.Ga4FinderTracker.setFilterIndexes(). However, I've left the code to trigger the "ga4-filter-indexes-added" event for now to reduce the scope of this change. The plan is that the whole of setFilterIndexes() will become redundant in a subsequent commit. Note that the index is 0-indexed vs 1-indexed since the former is how the Rails indexing was working. This means we currently have to add 1 in the facet partials when setting the ga4-index.index_section value. It might make more sense to change the index in FacetsIterator to be 1-indexed and change OptionSelectFacet#closed_by_default? to work with this. TODO: I'm not completely convinced that the Facet#has_ga4_section? method belongs in the model.
- Loading branch information
1 parent
51ef791
commit 69e149b
Showing
10 changed files
with
36 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
class FacetsIterator | ||
delegate :select, :any?, to: :@facets | ||
|
||
def initialize(facets) | ||
@facets = facets | ||
@facets_with_ga4_section = @facets.select(&:has_ga4_section?) | ||
end | ||
|
||
def each_with_index_and_count | ||
@facets.each do |facet| | ||
yield facet, @facets_with_ga4_section.index(facet), @facets_with_ga4_section.count | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -59,6 +59,10 @@ def ga4_section | |
nil | ||
end | ||
|
||
def has_ga4_section? | ||
!ga4_section.nil? | ||
end | ||
|
||
private | ||
|
||
def and_word_connectors | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters