Skip to content

Commit

Permalink
Merge pull request #161 from ukparliament/development
Browse files Browse the repository at this point in the history
Development merge
  • Loading branch information
j-corry authored Aug 21, 2024
2 parents 2933465 + 6e25e0e commit b27bef7
Show file tree
Hide file tree
Showing 3 changed files with 82 additions and 52 deletions.
4 changes: 4 additions & 0 deletions app/assets/stylesheets/search_results.css
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,10 @@
.search-control-panel-label {
align-content: center;
}

.search-control-panel-link {
align-content: center;
}
}

.flex-spacer {
Expand Down
5 changes: 3 additions & 2 deletions app/models/solr_search.rb
Original file line number Diff line number Diff line change
Expand Up @@ -145,9 +145,10 @@ def facet_hash
"type": "range",
"field": "date_dt",
"start": "1500-01-01T00:00:00Z",
"end": "2024-01-01T00:00:00Z",
"end": "#{Date.today.strftime("%Y-%m-%d")}T23:59:59Z",
"gap": "+1YEAR",
"mincount": 1
"mincount": 1,
"limit": 100
}
end

Expand Down
125 changes: 75 additions & 50 deletions app/views/search/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -95,13 +95,13 @@
</section>
<% end %>
<% else %>
<section class="facet">
<div>
<% unless @search_data.years.blank? %>
<section class="facet">
<div>
<strong>Year</strong>
</div>
<div class="facets">
<% unless @search_data.years.blank? %>
<div>
<strong>Year</strong>
</div>
<div class="facets">
<% @search_data.years[0..4].each do |year_data| %>
<div>
<%= link_to("#{year_data["val"].to_date.year} (#{year_data["count"]})", url_for(apply_filter_url(request.params, "year", year_data["val"].to_date.year)), class: "modifiable-link") %>
Expand All @@ -117,10 +117,10 @@
<% end %>
</details>
<% end %>
<% end %>
</div>
</div>
</div>
</section>
</section>
<% end %>
<% end %>
<% @search_data.facets.select { |h| ["legislature_ses", "session_t", "department_ses", "member_ses", "tablingMember_ses", "askingMember_ses", "leadMember_ses", "answeringMember_ses", "legislativeStage_ses", "legislationTitle_ses", "subject_ses"].include?(h.dig(:field_name)) }.each do |facet_field| %>
Expand All @@ -139,51 +139,76 @@
</div>
<div class="control-panel-row">
<label class="search-control-panel-label">
<span>Show detailed</span>
</label>
<label class="toggle">
<input hidden id="show-detailed" type="checkbox" <%= 'checked' if params[:show_detailed] == "true" %> data-action="change->detailed-results#toggle">
<span class="slider"></span>
<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 "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">-->
<!-- <span class="slider"></span>-->
<!-- </label>-->
<div class="flex-spacer"></div>
<label class="search-control-panel-label">
<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 "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 "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 "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| %>
<% unless request.params.dig(:filter).blank? %>
<% request.params.dig(:filter).keys.each do |filter_key| %>
<% request.params.dig(:filter, filter_key).each do |val| %>
<%= rf.hidden_field "filter[#{filter_key}]", value: val, multiple: true %>
<% end %>
<% end %>
<% end %>
<% unless request.params.dig(:query).blank? %>
<%= rf.hidden_field :query, value: request.params.dig(:query) %>
<% end %>
<% unless request.params.dig(:sort_by).blank? %>
<%= rf.hidden_field :sort_by, value: request.params.dig(:sort_by) %>
<% end %>
<%= rf.hidden_field :expanded_types, value: @search_data.expanded_types_string, class: 'hidden-existing-ids' %>
<%= rf.hidden_field :show_detailed, value: request.params.dig(:show_detailed), class: 'hidden-show-detailed' %>
<%= rf.select "results_per_page", options_for_select([["Show 10 results", 10], ["Show 20 results", 20], ["Show 50 results", 50], ["Show 100 results", 100]], selected: @search_data.results_per_page), {}, { onchange: "this.form.submit()", class: 'form-select' } %>
<% end %>
<%#= form_with url: request.url, method: :get, remote: true, id: 'results-per-page' do |rf| %>
<%# unless request.params.dig(:filter).blank? %>
<%# request.params.dig(:filter).keys.each do |filter_key| %>
<%# request.params.dig(:filter, filter_key).each do |val| %>
<%#= rf.hidden_field "filter[#{filter_key}]", value: val, multiple: true %>
<%# end %>
<%# end %>
<%# end %>
<%# unless request.params.dig(:query).blank? %>
<%#= rf.hidden_field :query, value: request.params.dig(:query) %>
<%# end %>
<%# unless request.params.dig(:sort_by).blank? %>
<%#= rf.hidden_field :sort_by, value: request.params.dig(:sort_by) %>
<%# end %>
<%#= rf.hidden_field :expanded_types, value: @search_data.expanded_types_string, class: 'hidden-existing-ids' %>
<%#= rf.hidden_field :show_detailed, value: request.params.dig(:show_detailed), class: 'hidden-show-detailed' %>
<%#= rf.select "results_per_page", options_for_select([["Show 10 results", 10], ["Show 20 results", 20], ["Show 50 results", 50], ["Show 100 results", 100]], selected: @search_data.results_per_page), {}, { onchange: "this.form.submit()", class: 'form-select' } %>
<%# end %>
<%= form_with url: request.url, method: :get, remote: true, id: 'sort-by' do |sf| %>
<% unless request.params.dig(:filter).blank? %>
<% request.params.dig(:filter).keys.each do |filter_key| %>
<% request.params.dig(:filter, filter_key).each do |val| %>
<%= sf.hidden_field "filter[#{filter_key}]", value: val, multiple: true %>
<% end %>
<% end %>
<% end %>
<% unless request.params.dig(:query).blank? %>
<%= sf.hidden_field :query, value: request.params.dig(:query) %>
<% end %>
<% unless request.params.dig(:results_per_page).blank? %>
<%= sf.hidden_field :results_per_page, value: request.params.dig(:results_per_page) %>
<% end %>
<%= sf.hidden_field :expanded_types, value: @search_data.expanded_types_string, class: 'hidden-existing-ids' %>
<%= sf.hidden_field :show_detailed, value: request.params.dig(:show_detailed), class: 'hidden-show-detailed' %>
<%= sf.select("sort_by", options_for_select([["Newest first", "date_desc"], ["Oldest first", "date_asc"]], selected: @search_data.sort), {}, { onchange: 'this.form.submit()', class: 'form-select' }) %>
<% end %>
<%#= form_with url: request.url, method: :get, remote: true, id: 'sort-by' do |sf| %>
<%# unless request.params.dig(:filter).blank? %>
<%# request.params.dig(:filter).keys.each do |filter_key| %>
<%# request.params.dig(:filter, filter_key).each do |val| %>
<%#= sf.hidden_field "filter[#{filter_key}]", value: val, multiple: true %>
<%# end %>
<%# end %>
<%# end %>
<%# unless request.params.dig(:query).blank? %>
<%#= sf.hidden_field :query, value: request.params.dig(:query) %>
<%# end %>
<%# unless request.params.dig(:results_per_page).blank? %>
<%#= sf.hidden_field :results_per_page, value: request.params.dig(:results_per_page) %>
<%# end %>
<%#= sf.hidden_field :expanded_types, value: @search_data.expanded_types_string, class: 'hidden-existing-ids' %>
<%#= sf.hidden_field :show_detailed, value: request.params.dig(:show_detailed), class: 'hidden-show-detailed' %>
<%#= sf.select("sort_by", options_for_select([["Newest first", "date_desc"], ["Oldest first", "date_asc"]], selected: @search_data.sort), {}, { onchange: 'this.form.submit()', class: 'form-select' }) %>
<%# end %>

</div>
</section>
Expand Down

0 comments on commit b27bef7

Please sign in to comment.