Skip to content

Commit

Permalink
Merge pull request #3553 from alphagov/monica-tweaks
Browse files Browse the repository at this point in the history
All content finder: Minor design/content tweaks
  • Loading branch information
csutter authored Nov 7, 2024
2 parents 9008461 + 8895329 commit 754f44f
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 26 deletions.
2 changes: 1 addition & 1 deletion app/assets/stylesheets/components/_filter-panel.scss
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
}

&::before {
margin: 0 govuk-spacing(3) govuk-spacing(1) 0;
margin: 0 govuk-spacing(2) govuk-spacing(1) 0;
}
}

Expand Down
2 changes: 1 addition & 1 deletion app/models/date_facet.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def applied_filters
present_values.map do |type, date|
preposition = preposition_mappings[type]
{
name: "#{name} #{preposition}",
name: "#{short_name} #{preposition}",
label: date.date.strftime("%e %B %Y"),
query_params: { key => { type => date.original_input } },
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
} do %>
<%= date_input(
"#{date_facet.key}[from]",
date_facet.name,
date_facet.short_name,
date_facet.parsed_from_date&.to_hash,
hint: "For example, 28 2 #{Date.current.year - 2}",
error_message: date_facet.error_message_from(@search_query),
Expand All @@ -15,7 +15,7 @@
<%= date_input(
"#{date_facet.key}[to]",
date_facet.name,
date_facet.short_name,
date_facet.parsed_to_date&.to_hash,
hint: "For example, 13 12 #{Date.current.year - 1}",
error_message: date_facet.error_message_to(@search_query),
Expand Down
4 changes: 2 additions & 2 deletions features/all_content_finder.feature
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ Feature: All content finder ("site search")
And I open the "Type" filter section
And I check the "Services" option
And I check the "Research and statistics" option
And I open the "Updated" filter section
And I open the "Date" filter section
And I enter "1989" for "Year" under "Updated after"
And I enter "1989" for "Year" under "Updated before"
And I enter "12" for "Month" under "Updated before"
Expand Down Expand Up @@ -66,7 +66,7 @@ Feature: All content finder ("site search")
Scenario: Entering an incorrect date
When I search all content for "chandeliers flickering"
And I open the filter panel
And I open the "Updated" filter section
And I open the "Date" filter section
And I enter "-1" for "Year" under "Updated before"
And I apply the filters
Then the filter panel is open by default
Expand Down
30 changes: 15 additions & 15 deletions features/fixtures/all_content.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,15 @@
"default_documents_per_page": 10,
"document_noun": "result",
"facets": [
{
"display_as_result_metadata": true,
"filterable": true,
"key": "public_timestamp",
"name": "Date",
"preposition": "Updated",
"short_name": "Updated",
"type": "date"
},
{
"display_as_result_metadata": false,
"filter_key": "all_part_of_taxonomy_tree",
Expand Down Expand Up @@ -87,15 +96,6 @@
"show_option_select_filter": false,
"type": "hidden_clearable"
},
{
"display_as_result_metadata": true,
"filterable": true,
"key": "public_timestamp",
"name": "Updated",
"preposition": "Updated",
"short_name": "Updated",
"type": "date"
},
{
"allowed_values": [],
"display_as_result_metadata": false,
Expand Down Expand Up @@ -141,30 +141,30 @@
"available_translations": [
{
"api_path": "/api/content/search/all",
"api_url": "https://www.integration.publishing.service.gov.uk/api/content/search/all",
"api_url": "https://www.gov.uk/api/content/search/all",
"base_path": "/search/all",
"content_id": "dd395436-9b40-41f3-8157-740a453ac972",
"document_type": "finder",
"links": {},
"locale": "en",
"public_updated_at": "2024-09-20T09:17:24Z",
"public_updated_at": "2024-10-24T11:19:57Z",
"schema_name": "finder",
"title": "Search",
"web_url": "https://www.integration.publishing.service.gov.uk/search/all",
"web_url": "https://www.gov.uk/search/all",
"withdrawn": false
}
]
},
"locale": "en",
"phase": "live",
"public_updated_at": "2024-09-20T10:17:24+01:00",
"public_updated_at": "2024-10-24T12:19:57+01:00",
"publishing_app": "search-api",
"publishing_request_id": "21-1726823845.044-10.1.34.217-616",
"publishing_request_id": "21-1729768797.580-10.13.32.238-615",
"publishing_scheduled_at": null,
"rendering_app": "finder-frontend",
"scheduled_publishing_delay_seconds": null,
"schema_name": "finder",
"title": "Search",
"updated_at": "2024-09-20T10:17:25+01:00",
"updated_at": "2024-10-24T12:19:57+01:00",
"withdrawn_notice": {}
}
4 changes: 2 additions & 2 deletions features/step_definitions/all_content_finder_steps.rb
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@
expect(page).to have_selector("h2", text: "Sort by")
expect(page).to have_selector("h2", text: "Filter by Topic")
expect(page).to have_selector("h2", text: "Filter by Type")
expect(page).to have_selector("h2", text: "Filter by Updated")
expect(page).to have_selector("h2", text: "Filter by Date")

# These are hidden clearable filters and should not have a section
expect(page).not_to have_selector("h2", text: "Filter by Organisation")
Expand All @@ -106,7 +106,7 @@
within(".app-c-filter-panel") do
expect(page).to have_selector("summary", text: "Filter by Topic 2 selected", normalize_ws: true)
expect(page).to have_selector("summary", text: "Filter by Type 2 selected", normalize_ws: true)
expect(page).to have_selector("summary", text: "Filter by Updated 2 selected", normalize_ws: true)
expect(page).to have_selector("summary", text: "Filter by Date 2 selected", normalize_ws: true)
end
end

Expand Down
7 changes: 4 additions & 3 deletions spec/models/date_facet_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
{
"type" => "date",
"name" => "Occurred",
"short_name" => "Happened",
"key" => "date_of_occurrence",
"preposition" => "occurred",
}
Expand Down Expand Up @@ -67,7 +68,7 @@

it "returns the expected applied filters" do
expect(subject.applied_filters).to eql([{
name: "Occurred after",
name: "Happened after",
label: "22 September 1988",
query_params: { "date_of_occurrence" => { from: "22/09/1988" } },
}])
Expand All @@ -85,12 +86,12 @@
it "returns the expected applied filters" do
expect(subject.applied_filters).to eql([
{
name: "Occurred after",
name: "Happened after",
label: "22 September 1988",
query_params: { "date_of_occurrence" => { from: "22/09/1988" } },
},
{
name: "Occurred before",
name: "Happened before",
label: "22 September 2014",
query_params: { "date_of_occurrence" => { to: "22/09/2014" } },
},
Expand Down

0 comments on commit 754f44f

Please sign in to comment.