Remove official level filter from advanced search

User testing has shown this filter isn't really useful and sometimes
makes users wonder what it's about. This is particularly true in CONSUL
installations which don't change the default values (most of them),
since users will see a filter with options like "Official position 1".
This commit is contained in:
Javi Martín
2021-08-24 22:30:49 +02:00
parent 30bbd844b5
commit 9f1f912d84
7 changed files with 199 additions and 336 deletions

View File

@@ -6,12 +6,12 @@
@include breakpoint(large) { @include breakpoint(large) {
.filter { .filter {
@include grid-column; @include grid-column;
width: 25%; width: 33%;
} }
.date-filters { .date-filters {
float: left; float: left;
width: 25%; width: 33%;
.filter { .filter {
width: 100%; width: 100%;
@@ -23,7 +23,7 @@
} }
.submit { .submit {
width: 25%; width: 33%;
} }
} }

View File

@@ -40,12 +40,6 @@
</div> </div>
</div> </div>
<div class="filter">
<label for="advanced_search_official_level"><%= t("shared.advanced_search.author_type") %></label>
<%= select_tag("advanced_search[official_level]", official_level_search_options,
include_blank: t("shared.advanced_search.author_type_blank")) %>
</div>
<% if sdg? %> <% if sdg? %>
<div class="filter"> <div class="filter">
<label for="advanced_search_goal"><%= t("shared.advanced_search.goal") %></label> <label for="advanced_search_goal"><%= t("shared.advanced_search.goal") %></label>

View File

@@ -7,11 +7,6 @@ class Shared::AdvancedSearchComponent < ApplicationComponent
params[:advanced_search] || {} params[:advanced_search] || {}
end end
def official_level_search_options
options_for_select((1..5).map { |i| [setting["official_level_#{i}_name"], i] },
advanced_search[:official_level])
end
def date_range_options def date_range_options
options_for_select([ options_for_select([
[t("shared.advanced_search.date_1"), 1], [t("shared.advanced_search.date_1"), 1],

View File

@@ -20,7 +20,7 @@ module Filterable
def allowed_filter?(filter, value) def allowed_filter?(filter, value)
return if value.blank? return if value.blank?
["official_level", "date_range", "goal", "target"].include?(filter) ["date_range", "goal", "target"].include?(filter)
end end
end end
end end

View File

@@ -673,8 +673,6 @@ en:
"no": "No" "no": "No"
search_results: "Search results" search_results: "Search results"
advanced_search: advanced_search:
author_type: "By author category"
author_type_blank: "Select a category"
date: "By date" date: "By date"
date_placeholder: "DD/MM/YYYY" date_placeholder: "DD/MM/YYYY"
date_range_blank: "Choose a date" date_range_blank: "Choose a date"

View File

@@ -673,8 +673,6 @@ es:
"no": "No" "no": "No"
search_results: "Resultados de la búsqueda" search_results: "Resultados de la búsqueda"
advanced_search: advanced_search:
author_type: "Por categoría de autor"
author_type_blank: "Elige una categoría"
date: "Por fecha" date: "Por fecha"
date_placeholder: "DD/MM/AAAA" date_placeholder: "DD/MM/AAAA"
date_range_blank: "Elige una fecha" date_range_blank: "Elige una fecha"

View File

@@ -64,127 +64,6 @@ describe "Advanced search" do
end end
end end
context "Search by author type" do
scenario "Public employee" do
Setting["official_level_1_name"] = "Official position 1"
ana = create :user, official_level: 1
john = create :user, official_level: 2
debate1 = create(:debate, author: ana)
debate2 = create(:debate, author: ana)
debate3 = create(:debate, author: john)
visit debates_path
click_button "Advanced search"
select "Official position 1", from: "advanced_search_official_level"
click_button "Filter"
expect(page).to have_content("There are 2 debates")
within("#debates") do
expect(page).to have_content(debate1.title)
expect(page).to have_content(debate2.title)
expect(page).not_to have_content(debate3.title)
end
end
scenario "Municipal Organization" do
Setting["official_level_2_name"] = "Official position 2"
ana = create :user, official_level: 2
john = create :user, official_level: 3
proposal1 = create(:proposal, author: ana)
proposal2 = create(:proposal, author: ana)
proposal3 = create(:proposal, author: john)
visit proposals_path
click_button "Advanced search"
select "Official position 2", from: "advanced_search_official_level"
click_button "Filter"
expect(page).to have_content("There are 2 citizen proposals")
within("#proposals") do
expect(page).to have_content(proposal1.title)
expect(page).to have_content(proposal2.title)
expect(page).not_to have_content(proposal3.title)
end
end
scenario "General director" do
Setting["official_level_3_name"] = "Official position 3"
ana = create :user, official_level: 3
john = create :user, official_level: 4
bdgt_invest1 = create(:budget_investment, heading: heading, author: ana)
bdgt_invest2 = create(:budget_investment, heading: heading, author: ana)
bdgt_invest3 = create(:budget_investment, heading: heading, author: john)
visit budget_investments_path(budget)
click_button "Advanced search"
select "Official position 3", from: "advanced_search_official_level"
click_button "Filter"
expect(page).to have_content("There are 2 investments")
within("#budget-investments") do
expect(page).to have_content(bdgt_invest1.title)
expect(page).to have_content(bdgt_invest2.title)
expect(page).not_to have_content(bdgt_invest3.title)
end
end
scenario "City councillor" do
Setting["official_level_4_name"] = "Official position 4"
ana = create :user, official_level: 4
john = create :user, official_level: 5
debate1 = create(:debate, author: ana)
debate2 = create(:debate, author: ana)
debate3 = create(:debate, author: john)
visit debates_path
click_button "Advanced search"
select "Official position 4", from: "advanced_search_official_level"
click_button "Filter"
expect(page).to have_content("There are 2 debates")
within("#debates") do
expect(page).to have_content(debate1.title)
expect(page).to have_content(debate2.title)
expect(page).not_to have_content(debate3.title)
end
end
scenario "Mayoress" do
Setting["official_level_5_name"] = "Official position 5"
ana = create :user, official_level: 5
john = create :user, official_level: 4
proposal1 = create(:proposal, author: ana)
proposal2 = create(:proposal, author: ana)
proposal3 = create(:proposal, author: john)
visit proposals_path
click_button "Advanced search"
select "Official position 5", from: "advanced_search_official_level"
click_button "Filter"
expect(page).to have_content("There are 2 citizen proposals")
within("#proposals") do
expect(page).to have_content(proposal1.title)
expect(page).to have_content(proposal2.title)
expect(page).not_to have_content(proposal3.title)
end
end
context "Search by date" do context "Search by date" do
context "Predefined date ranges" do context "Predefined date ranges" do
scenario "Last day" do scenario "Last day" do
@@ -315,19 +194,18 @@ describe "Advanced search" do
end end
scenario "Search by multiple filters" do scenario "Search by multiple filters" do
Setting["official_level_1_name"] = "Official position 1" Setting["feature.sdg"] = true
ana = create :user, official_level: 1 Setting["sdg.process.budgets"] = true
john = create :user, official_level: 1
create(:budget_investment, heading: heading, title: "Get Schwifty", author: ana, created_at: 1.minute.ago) create(:budget_investment, heading: heading, title: "Get Schwifty", sdg_goals: [SDG::Goal[7]], created_at: 1.minute.ago)
create(:budget_investment, heading: heading, title: "Hello Schwifty", author: john, created_at: 2.days.ago) create(:budget_investment, heading: heading, title: "Hello Schwifty", sdg_goals: [SDG::Goal[7]], created_at: 2.days.ago)
create(:budget_investment, heading: heading, title: "Save the forest") create(:budget_investment, heading: heading, title: "Save the forest")
visit budget_investments_path(budget) visit budget_investments_path(budget)
click_button "Advanced search" click_button "Advanced search"
fill_in "Write the text", with: "Schwifty" fill_in "Write the text", with: "Schwifty"
select "Official position 1", from: "advanced_search_official_level" select "7. Affordable and Clean Energy", from: "By SDG"
select "Last 24 hours", from: "js-advanced-search-date-min" select "Last 24 hours", from: "js-advanced-search-date-min"
click_button "Filter" click_button "Filter"
@@ -340,20 +218,21 @@ describe "Advanced search" do
end end
scenario "Maintain advanced search criteria" do scenario "Maintain advanced search criteria" do
Setting["official_level_1_name"] = "Official position 1" Setting["feature.sdg"] = true
Setting["sdg.process.debates"] = true
visit debates_path visit debates_path
click_button "Advanced search" click_button "Advanced search"
fill_in "Write the text", with: "Schwifty" fill_in "Write the text", with: "Schwifty"
select "Official position 1", from: "advanced_search_official_level" select "7. Affordable and Clean Energy", from: "By SDG"
select "Last 24 hours", from: "js-advanced-search-date-min" select "Last 24 hours", from: "js-advanced-search-date-min"
click_button "Filter" click_button "Filter"
within ".advanced-search-form" do within ".advanced-search-form" do
expect(page).to have_selector("input[name='search'][value='Schwifty']") expect(page).to have_selector("input[name='search'][value='Schwifty']")
expect(page).to have_select("advanced_search[official_level]", selected: "Official position 1") expect(page).to have_select("By SDG", selected: "7. Affordable and Clean Energy")
expect(page).to have_select("advanced_search[date_min]", selected: "Last 24 hours") expect(page).to have_select("advanced_search[date_min]", selected: "Last 24 hours")
end end
end end
@@ -449,5 +328,4 @@ describe "Advanced search" do
expect(page).to have_select "By target", selected: "13.1", disabled_options: [] expect(page).to have_select "By target", selected: "13.1", disabled_options: []
end end
end end
end
end end