Skip to content

Commit

Permalink
Merge pull request #162 from ukparliament/development
Browse files Browse the repository at this point in the history
Development merge
  • Loading branch information
j-corry committed Aug 22, 2024
2 parents b27bef7 + 1cecfc6 commit f664ff1
Show file tree
Hide file tree
Showing 6 changed files with 367 additions and 277 deletions.
8 changes: 7 additions & 1 deletion app/models/search_data.rb
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,10 @@ def show_detailed
search.dig(:search_parameters, :show_detailed)
end

def show_detailed?
show_detailed == "true" ? true : false
end

def expanded_types
return unless search

Expand Down Expand Up @@ -115,7 +119,9 @@ def toggled_facets
def sort
return unless search

search.dig(:search_parameters, 'sort_by')
from_params = search.dig(:search_parameters, 'sort_by')

from_params.blank? ? 'date_desc' : from_params
end

def start
Expand Down
16 changes: 8 additions & 8 deletions app/views/search/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -142,9 +142,9 @@
<span>Show detailed:</span>
</label>
<div class="search-control-panel-link">
<%= link_to "On", search_url(query: @search_data.query, filter: @search_data.filter, sort_by: @search_data.sort, results_per_page: @search_data.results_per_page, page: @search_data.current_page, expanded_types: @search_data.expanded_types, show_detailed: true), class: "#{'selected' if @search_data.show_detailed} modifiable-link" %>
<%= link_to_unless @search_data.show_detailed?, "On", search_url(query: @search_data.query, filter: @search_data.filter, sort_by: @search_data.sort, results_per_page: @search_data.results_per_page, page: @search_data.current_page, expanded_types: @search_data.expanded_types, show_detailed: true), class: "#{'selected' if @search_data.show_detailed} modifiable-link" %>
|
<%= link_to "Off", search_url(query: @search_data.query, filter: @search_data.filter, sort_by: @search_data.sort, results_per_page: @search_data.results_per_page, page: @search_data.current_page, expanded_types: @search_data.expanded_types, show_detailed: false), class: "#{'selected' if @search_data.show_detailed} modifiable-link" %>
<%= link_to_if @search_data.show_detailed?, "Off", search_url(query: @search_data.query, filter: @search_data.filter, sort_by: @search_data.sort, results_per_page: @search_data.results_per_page, page: @search_data.current_page, expanded_types: @search_data.expanded_types, show_detailed: false), class: "#{'selected' if @search_data.show_detailed} modifiable-link" %>
</div>
<!-- <label class="toggle">-->
<!-- <input hidden id="show-detailed" type="checkbox" <%#= 'checked' if params[:show_detailed] == "true" %> data-action="change->detailed-results#toggle">-->
Expand All @@ -155,21 +155,21 @@
<span>Results:</span>
</label>
<div class="search-control-panel-link">
<%= link_to "10", search_url(query: @search_data.query, filter: @search_data.filter, sort_by: @search_data.sort, results_per_page: 10, page: @search_data.current_page, expanded_types: @search_data.expanded_types, show_detailed: @search_data.show_detailed), class: "#{'selected' if @search_data.show_detailed} modifiable-link" %>
<%= link_to_unless @search_data.results_per_page == 10, "10", search_url(query: @search_data.query, filter: @search_data.filter, sort_by: @search_data.sort, results_per_page: 10, page: @search_data.current_page, expanded_types: @search_data.expanded_types, show_detailed: @search_data.show_detailed), class: "#{'selected' if @search_data.show_detailed} modifiable-link" %>
|
<%= link_to "20", search_url(query: @search_data.query, filter: @search_data.filter, sort_by: @search_data.sort, results_per_page: 20, page: @search_data.current_page, expanded_types: @search_data.expanded_types, show_detailed: @search_data.show_detailed), class: "#{'selected' if @search_data.show_detailed} modifiable-link" %>
<%= link_to_unless @search_data.results_per_page == 20, "20", search_url(query: @search_data.query, filter: @search_data.filter, sort_by: @search_data.sort, results_per_page: 20, page: @search_data.current_page, expanded_types: @search_data.expanded_types, show_detailed: @search_data.show_detailed), class: "#{'selected' if @search_data.show_detailed} modifiable-link" %>
|
<%= link_to "50", search_url(query: @search_data.query, filter: @search_data.filter, sort_by: @search_data.sort, results_per_page: 50, page: @search_data.current_page, expanded_types: @search_data.expanded_types, show_detailed: @search_data.show_detailed), class: "#{'selected' if @search_data.show_detailed} modifiable-link" %>
<%= link_to_unless @search_data.results_per_page == 50, "50", search_url(query: @search_data.query, filter: @search_data.filter, sort_by: @search_data.sort, results_per_page: 50, page: @search_data.current_page, expanded_types: @search_data.expanded_types, show_detailed: @search_data.show_detailed), class: "#{'selected' if @search_data.show_detailed} modifiable-link" %>
|
<%= link_to "100", search_url(query: @search_data.query, filter: @search_data.filter, sort_by: @search_data.sort, results_per_page: 100, page: @search_data.current_page, expanded_types: @search_data.expanded_types, show_detailed: @search_data.show_detailed), class: "#{'selected' if @search_data.show_detailed} modifiable-link" %>
<%= link_to_unless @search_data.results_per_page == 100, "100", search_url(query: @search_data.query, filter: @search_data.filter, sort_by: @search_data.sort, results_per_page: 100, page: @search_data.current_page, expanded_types: @search_data.expanded_types, show_detailed: @search_data.show_detailed), class: "#{'selected' if @search_data.show_detailed} modifiable-link" %>
</div>
<label class="search-control-panel-label">
<span>Sort by:</span>
</label>
<div class="search-control-panel-link">
<%= link_to "Newest first", search_url(query: @search_data.query, filter: @search_data.filter, sort_by: 'date_desc', results_per_page: @search_data.results_per_page, page: @search_data.current_page, expanded_types: @search_data.expanded_types, show_detailed: @search_data.show_detailed), class: "#{'selected' if @search_data.show_detailed} modifiable-link" %>
<%= link_to_unless @search_data.sort == "date_desc", "Newest first", search_url(query: @search_data.query, filter: @search_data.filter, sort_by: 'date_desc', results_per_page: @search_data.results_per_page, page: @search_data.current_page, expanded_types: @search_data.expanded_types, show_detailed: @search_data.show_detailed), class: "#{'selected' if @search_data.show_detailed} modifiable-link" %>
|
<%= link_to "Oldest first", search_url(query: @search_data.query, filter: @search_data.filter, sort_by: 'date_asc', results_per_page: @search_data.results_per_page, page: @search_data.current_page, expanded_types: @search_data.expanded_types, show_detailed: @search_data.show_detailed), class: "#{'selected' if @search_data.show_detailed} modifiable-link" %>
<%= link_to_unless @search_data.sort == "date_asc", "Oldest first", search_url(query: @search_data.query, filter: @search_data.filter, sort_by: 'date_asc', results_per_page: @search_data.results_per_page, page: @search_data.current_page, expanded_types: @search_data.expanded_types, show_detailed: @search_data.show_detailed), class: "#{'selected' if @search_data.show_detailed} modifiable-link" %>
</div>

<%#= form_with url: request.url, method: :get, remote: true, id: 'results-per-page' do |rf| %>
Expand Down
2 changes: 1 addition & 1 deletion coverage/.last_run.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"result": {
"line": 82.96
"line": 83.05
}
}
43 changes: 25 additions & 18 deletions coverage/.resultset.json
Original file line number Diff line number Diff line change
Expand Up @@ -2795,33 +2795,37 @@
null,
null,
1,
5,
29,
null,
5,
29,
null,
null,
1,
0,
48,
null,
0,
48,
null,
null,
1,
6,
null,
6,
null,
6,
1,
24,
null,
6,
24,
null,
24,
null,
24,
0,
null,
null,
6,
24,
null,
null,
1,
6,
0,
null,
0,
null,
Expand All @@ -2841,9 +2845,11 @@
null,
null,
1,
5,
26,
null,
5,
26,
null,
26,
null,
null,
1,
Expand All @@ -2857,19 +2863,19 @@
null,
null,
1,
5,
26,
null,
5,
5,
26,
26,
null,
null,
1,
3,
null,
null,
1,
3,
3,
27,
27,
null,
null,
1,
Expand Down Expand Up @@ -2966,7 +2972,7 @@
null,
null,
1,
2,
26,
null,
null,
1,
Expand Down Expand Up @@ -3363,6 +3369,7 @@
null,
null,
null,
null,
0,
null,
null,
Expand Down Expand Up @@ -3652,6 +3659,6 @@
]
}
},
"timestamp": 1724223355
"timestamp": 1724317741
}
}
Loading

0 comments on commit f664ff1

Please sign in to comment.