Remove investment filters in groups

The interface was a bit confusing, since after clicking on "See
unfeasible investments" (or similar), we were on a page where no
investments were shown.

Besides, since commit 7e3dd47d5, the group page is only linked from the
"my ballot" page, through a link inviting the user to vote in that
group, and it's only possible to vote selected investments (which is the
default filter during the final voting phase).

The only reason we had these links here was these links weren't present
in the investments page. But they're present there since commit
04605d5d5, so we don't need them in the group page anymore.
This commit is contained in:
Javi Martín
2021-09-16 01:47:00 +02:00
parent 28a7aea1c0
commit 756a16f67a
10 changed files with 13 additions and 148 deletions

View File

@@ -1,6 +1,5 @@
module Budgets
class GroupsController < ApplicationController
include InvestmentFilters
include FeatureFlags
feature_flag :budgets
@@ -9,9 +8,6 @@ module Budgets
authorize_resource :budget
authorize_resource :group, class: "Budget::Group"
before_action :set_default_investment_filter, only: :show
has_filters investment_filters, only: [:show]
def show
end

View File

@@ -8,7 +8,6 @@ module Budgets
include DocumentAttributes
include MapLocationAttributes
include Translatable
include InvestmentFilters
PER_PAGE = 10
@@ -33,8 +32,7 @@ module Budgets
has_orders %w[most_voted newest oldest], only: :show
has_orders ->(c) { c.instance_variable_get(:@budget).investments_orders }, only: :index
has_filters investment_filters, only: [:index, :show, :suggest]
has_filters ->(c) { c.instance_variable_get(:@budget).investments_filters }, only: [:index, :show, :suggest]
invisible_captcha only: [:create, :update], honeypot: :subtitle, scope: :budget_investment
@@ -170,6 +168,14 @@ module Budgets
end
end
def set_default_investment_filter
if @budget&.finished?
params[:filter] ||= "winners"
elsif @budget&.publishing_prices_or_later?
params[:filter] ||= "selected"
end
end
def load_map
@map_location = MapLocation.load_from_heading(@heading)
end

View File

@@ -1,21 +0,0 @@
module InvestmentFilters
extend ActiveSupport::Concern
class_methods do
def investment_filters
->(controller) { controller.investment_filters }
end
end
def set_default_investment_filter
if @budget&.finished?
params[:filter] ||= "winners"
elsif @budget&.publishing_prices_or_later?
params[:filter] ||= "selected"
end
end
def investment_filters
@budget.investments_filters
end
end

View File

@@ -16,9 +16,7 @@ module BudgetsHelper
end
def css_for_ballot_heading(heading)
return "" if current_ballot.blank? || @current_filter == "unfeasible"
current_ballot.has_lines_in_heading?(heading) ? "is-active" : ""
current_ballot&.has_lines_in_heading?(heading) ? "is-active" : ""
end
def current_ballot

View File

@@ -1,27 +1,9 @@
<% content_for :canonical do %>
<%= render "shared/canonical", href: budget_group_url(filter: @current_filter) %>
<% end %>
<main class="budget-group-show">
<header>
<%= back_link_to budget_path(@budget) %>
<h1><%= t("budgets.groups.show.title") %></h1>
</header>
<% if @current_filter == "unfeasible" %>
<div class="row margin-top">
<div class="small-12 column">
<h3><%= t("budgets.groups.show.unfeasible_title") %></h3>
</div>
</div>
<% elsif @current_filter == "unselected" %>
<div class="row margin-top">
<div class="small-12 column">
<h3><%= t("budgets.groups.show.unselected_title") %></h3>
</div>
</div>
<% end %>
<div class="row margin">
<div id="headings" class="small-12 medium-7 column select-district">
<div class="row">
@@ -30,9 +12,8 @@
<% slice.each do |heading| %>
<span id="<%= dom_id(heading) %>"
class="<%= css_for_ballot_heading(heading) %>">
<%= link_to heading.name,
budget_investments_path(heading_id: heading.id,
filter: @current_filter) %><br>
<%= link_to heading.name, budget_investments_path(heading_id: heading.id) %>
<br>
</span>
<% end %>
</div>
@@ -44,28 +25,4 @@
<%= image_tag(image_path_for("map.jpg")) %>
</div>
</div>
<% if @budget.balloting_or_later? %>
<% unless @current_filter == "unfeasible" %>
<div class="row">
<div class="small-12 column">
<small>
<%= link_to t("budgets.groups.show.unfeasible"),
budget_group_path(@budget, @group, filter: "unfeasible") %>
</small>
</div>
</div>
<% end %>
<% unless @current_filter == "unselected" %>
<div class="row">
<div class="small-12 column">
<small>
<%= link_to t("budgets.groups.show.unselected"),
budget_group_path(@budget, @group, filter: "unselected") %>
</small>
</div>
</div>
<% end %>
<% end %>
</main>

View File

@@ -43,10 +43,6 @@ en:
groups:
show:
title: Select a heading
unfeasible_title: Unfeasible investments
unfeasible: See unfeasible investments
unselected_title: Investments not selected for balloting phase
unselected: See investments not selected for balloting phase
phase:
drafting: Draft (Not visible to the public)
informing: Information

View File

@@ -43,10 +43,6 @@ es:
groups:
show:
title: Selecciona una partida
unfeasible_title: Proyectos de gasto inviables
unfeasible: Ver proyectos inviables
unselected_title: Proyectos no seleccionados para la votación final
unselected: Ver los proyectos no seleccionados para la votación final
phase:
drafting: Borrador (No visible para el público)
informing: Información

View File

@@ -328,42 +328,6 @@ describe "Budgets" do
let!(:budget) { create(:budget, :selecting) }
let!(:group) { create(:budget_group, budget: budget) }
describe "Links to unfeasible and selected" do
scenario "are not seen before balloting" do
visit budget_group_path(budget, group)
expect(page).not_to have_link "See unfeasible investments"
expect(page).not_to have_link "See investments not selected for balloting phase"
end
scenario "are not seen publishing prices" do
budget.update!(phase: :publishing_prices)
visit budget_group_path(budget, group)
expect(page).not_to have_link "See unfeasible investments"
expect(page).not_to have_link "See investments not selected for balloting phase"
end
scenario "are seen balloting" do
budget.update!(phase: :balloting)
visit budget_group_path(budget, group)
expect(page).to have_link "See unfeasible investments"
expect(page).to have_link "See investments not selected for balloting phase"
end
scenario "are seen on finished budgets" do
budget.update!(phase: :finished)
visit budget_group_path(budget, group)
expect(page).to have_link "See unfeasible investments"
expect(page).to have_link "See investments not selected for balloting phase"
end
end
scenario "Take into account headings with the same name from a different budget" do
group1 = create(:budget_group, budget: budget, name: "New York")
heading1 = create(:budget_heading, group: group1, name: "Brooklyn")

View File

@@ -26,25 +26,6 @@ describe "Budget Groups" do
expect(first_heading.name).to appear_before(last_heading.name)
end
scenario "Links to investment filters" do
create(:budget_heading, group: group, name: "Southwest")
budget.update!(phase: "finished")
visit budget_group_path(budget, group)
click_link "See unfeasible investments"
expect(page).to have_css "h3", exact_text: "Unfeasible investments"
expect(page).to have_link "Southwest"
expect(page).not_to have_link "See unfeasible investments"
click_link "See investments not selected for balloting phase"
expect(page).to have_css "h3", exact_text: "Investments not selected for balloting phase"
expect(page).to have_link "Southwest"
expect(page).not_to have_link "See investments not selected for balloting phase unfeasible investments"
end
scenario "Back link" do
visit budget_group_path(budget, group)

View File

@@ -1458,7 +1458,7 @@ describe "Budget Investments" do
end
end
scenario "Highlight voted heading except with unfeasible filter" do
scenario "Highlight voted heading" do
budget.update!(phase: "balloting")
user = create(:user, :level_two)
@@ -1476,14 +1476,6 @@ describe "Budget Investments" do
expect(page).to have_css("#budget_heading_#{heading_1.id}.is-active")
expect(page).to have_css("#budget_heading_#{heading_2.id}")
click_link "See unfeasible investments"
within("#headings") do
expect(page).to have_css("#budget_heading_#{heading_1.id}")
expect(page).to have_css("#budget_heading_#{heading_2.id}")
expect(page).not_to have_css(".is-active")
end
end
scenario "Ballot is visible" do