Make investment filters easier to understand

So now:

* In the first few phases, no filters are shown (just like before)
* During the valuation phase, we show "Active" and "Unfeasible"
* During the final voting, we show "Active" (which now refers to the
  selected investments), "Not selected for the final voting" and
  "Unfeasible"
* When the budget is finished, we show "Winners", "Not selected for the
  final voting" and "Unfeasible"

Now each investment is shown in one (and only one) of the filters
(except when the budget is finished; in this case we don't show selected
investments which didn't win), and we remove the confusing "Not
unfeasible" filter by only showing it during the valuation phase (before
filters are selected) and renaming it to "Active". We also rearrange the
filters so the default one for each phase is shown first.

The idea of using the "Active" text for investments which can be
selected during the selection phase and voted during the final voting is
experimental. Right now, for simplicity, since we assume filters will
always use the same text, we're removing the "Active" filter when the
budget is finished, since having both "Winners" and "Active" filters
would be confusing.
This commit is contained in:
Javi Martín
2021-11-13 14:46:16 +01:00
parent 64892cf3ea
commit e612705463
6 changed files with 46 additions and 45 deletions

View File

@@ -198,10 +198,12 @@ class Budget < ApplicationRecord
def investments_filters
[
(%w[not_unfeasible feasible unfeasible] if valuating_or_later?),
(%w[selected unselected] if publishing_prices_or_later?),
("winners" if finished?)
].compact.flatten
("winners" if finished?),
("selected" if publishing_prices_or_later? && !finished?),
("unselected" if publishing_prices_or_later?),
("not_unfeasible" if valuating?),
("unfeasible" if valuating_or_later?)
].compact
end
def email_selected

View File

@@ -117,11 +117,10 @@ en:
not_logged_in: "To create a new budget investment you must %{sign_in} or %{sign_up}."
filter: "Filtering projects by"
filters:
feasible: "Feasible"
not_unfeasible: "Feasible or with undecided feasibility"
selected: "Selected"
not_unfeasible: "Active"
selected: "Active"
unfeasible: "Unfeasible"
unselected: "Unselected"
unselected: "Not selected for the final voting"
winners: "Winners"
orders:
random: random

View File

@@ -117,11 +117,10 @@ es:
not_logged_in: "Para crear un nuevo proyecto de gasto debes %{sign_in} o %{sign_up}."
filter: "Filtrando proyectos"
filters:
feasible: "Viables"
not_unfeasible: "Viables o con viabilidad por decidir"
selected: "Seleccionados"
not_unfeasible: "Activos"
selected: "Activos"
unfeasible: "Inviables"
unselected: "No seleccionados"
unselected: "No seleccionados para votación"
winners: "Ganadores"
orders:
random: Aleatorios

View File

@@ -2,6 +2,7 @@ require "rails_helper"
describe Budgets::Investments::FiltersComponent do
let(:budget) { create(:budget) }
before { allow(controller).to receive(:valid_filters) { budget.investments_filters } }
around do |example|
with_request_url(Rails.application.routes.url_helpers.budget_investments_path(budget)) do
@@ -12,7 +13,6 @@ describe Budgets::Investments::FiltersComponent do
it "is not displayed before valuation" do
%w[informing accepting reviewing selecting].each do |phase|
budget.update!(phase: phase)
allow(controller).to receive(:valid_filters).and_return(budget.investments_filters)
render_inline Budgets::Investments::FiltersComponent.new
@@ -20,14 +20,35 @@ describe Budgets::Investments::FiltersComponent do
end
end
it "is displayed during and after valuation" do
Budget::Phase::kind_or_later("valuating").each do |phase|
budget.update!(phase: phase)
allow(controller).to receive(:valid_filters).and_return(budget.investments_filters)
it "shows the active and unfeasible investments during the valuation phase" do
budget.update!(phase: "valuating")
render_inline Budgets::Investments::FiltersComponent.new
expect(page).to have_content "Filtering projects by"
end
expect(page).to have_link count: 2
expect(page).to have_link "Active"
expect(page).to have_link "Unfeasible"
end
it "shows the active, unselected and unfeasible filters during the final voting" do
budget.update!(phase: "balloting")
render_inline Budgets::Investments::FiltersComponent.new
expect(page).to have_link count: 3
expect(page).to have_link "Active"
expect(page).to have_link "Not selected for the final voting"
expect(page).to have_link "Unfeasible"
end
it "shows the winners, unselected and unfeasible investments when the budget is finished" do
budget.update!(phase: "finished")
render_inline Budgets::Investments::FiltersComponent.new
expect(page).to have_link count: 3
expect(page).to have_link "Winners"
expect(page).to have_link "Not selected for the final voting"
expect(page).to have_link "Unfeasible"
end
end

View File

@@ -297,21 +297,21 @@ describe Budget do
it "returns feasibility filters during valuation" do
budget.phase = "valuating"
expect(budget.investments_filters).to eq(%w[not_unfeasible feasible unfeasible])
expect(budget.investments_filters).to eq(%w[not_unfeasible unfeasible])
end
it "returns feasibility and selection filters during the final voting phases" do
%w[publishing_prices balloting reviewing_ballots].each do |phase|
budget.phase = phase
expect(budget.investments_filters).to eq(%w[not_unfeasible feasible unfeasible selected unselected])
expect(budget.investments_filters).to eq(%w[selected unselected unfeasible])
end
end
it "returns all filters after the budget has finished" do
it "returns winners, unfeasible and unselected when the budget has finished" do
budget.phase = "finished"
expect(budget.investments_filters).to eq(%w[not_unfeasible feasible unfeasible selected unselected winners])
expect(budget.investments_filters).to eq(%w[winners unselected unfeasible])
end
end

View File

@@ -144,42 +144,22 @@ describe "Budget Investments" do
expect(page).to have_content "FILTERING PROJECTS BY"
click_link "Feasible"
expect(page).to have_css ".budget-investment", count: 1
expect(page).to have_content "Feasible investment"
click_link "Unfeasible"
expect(page).to have_content "Unfeasible investment"
expect(page).to have_css ".budget-investment", count: 1
click_link "Unselected"
click_link "Not selected for the final voting"
expect(page).to have_css ".budget-investment", count: 3
expect(page).to have_content "Unselected investment"
expect(page).to have_content "Unclassified investment"
expect(page).to have_content "Feasible investment"
click_link "Selected"
expect(page).to have_css ".budget-investment", count: 2
expect(page).to have_content "Selected investment"
expect(page).to have_content "Winner investment"
click_link "Winners"
expect(page).to have_css ".budget-investment", count: 1
expect(page).to have_content "Winner investment"
click_link "Feasible or with undecided feasibility"
expect(page).to have_css ".budget-investment", count: 5
expect(page).to have_content "Selected investment"
expect(page).to have_content "Unselected investment"
expect(page).to have_content "Feasible investment"
expect(page).to have_content "Unclassified investment"
expect(page).to have_content "Winner investment"
end
context("Search") do