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 commit7e3dd47d5, 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 commit04605d5d5, so we don't need them in the group page anymore.
This commit is contained in:
@@ -1,6 +1,5 @@
|
|||||||
module Budgets
|
module Budgets
|
||||||
class GroupsController < ApplicationController
|
class GroupsController < ApplicationController
|
||||||
include InvestmentFilters
|
|
||||||
include FeatureFlags
|
include FeatureFlags
|
||||||
feature_flag :budgets
|
feature_flag :budgets
|
||||||
|
|
||||||
@@ -9,9 +8,6 @@ module Budgets
|
|||||||
authorize_resource :budget
|
authorize_resource :budget
|
||||||
authorize_resource :group, class: "Budget::Group"
|
authorize_resource :group, class: "Budget::Group"
|
||||||
|
|
||||||
before_action :set_default_investment_filter, only: :show
|
|
||||||
has_filters investment_filters, only: [:show]
|
|
||||||
|
|
||||||
def show
|
def show
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -8,7 +8,6 @@ module Budgets
|
|||||||
include DocumentAttributes
|
include DocumentAttributes
|
||||||
include MapLocationAttributes
|
include MapLocationAttributes
|
||||||
include Translatable
|
include Translatable
|
||||||
include InvestmentFilters
|
|
||||||
|
|
||||||
PER_PAGE = 10
|
PER_PAGE = 10
|
||||||
|
|
||||||
@@ -33,8 +32,7 @@ module Budgets
|
|||||||
|
|
||||||
has_orders %w[most_voted newest oldest], only: :show
|
has_orders %w[most_voted newest oldest], only: :show
|
||||||
has_orders ->(c) { c.instance_variable_get(:@budget).investments_orders }, only: :index
|
has_orders ->(c) { c.instance_variable_get(:@budget).investments_orders }, only: :index
|
||||||
|
has_filters ->(c) { c.instance_variable_get(:@budget).investments_filters }, only: [:index, :show, :suggest]
|
||||||
has_filters investment_filters, only: [:index, :show, :suggest]
|
|
||||||
|
|
||||||
invisible_captcha only: [:create, :update], honeypot: :subtitle, scope: :budget_investment
|
invisible_captcha only: [:create, :update], honeypot: :subtitle, scope: :budget_investment
|
||||||
|
|
||||||
@@ -170,6 +168,14 @@ module Budgets
|
|||||||
end
|
end
|
||||||
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
|
def load_map
|
||||||
@map_location = MapLocation.load_from_heading(@heading)
|
@map_location = MapLocation.load_from_heading(@heading)
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -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
|
|
||||||
@@ -16,9 +16,7 @@ module BudgetsHelper
|
|||||||
end
|
end
|
||||||
|
|
||||||
def css_for_ballot_heading(heading)
|
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
|
end
|
||||||
|
|
||||||
def current_ballot
|
def current_ballot
|
||||||
|
|||||||
@@ -1,27 +1,9 @@
|
|||||||
<% content_for :canonical do %>
|
|
||||||
<%= render "shared/canonical", href: budget_group_url(filter: @current_filter) %>
|
|
||||||
<% end %>
|
|
||||||
|
|
||||||
<main class="budget-group-show">
|
<main class="budget-group-show">
|
||||||
<header>
|
<header>
|
||||||
<%= back_link_to budget_path(@budget) %>
|
<%= back_link_to budget_path(@budget) %>
|
||||||
<h1><%= t("budgets.groups.show.title") %></h1>
|
<h1><%= t("budgets.groups.show.title") %></h1>
|
||||||
</header>
|
</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 class="row margin">
|
||||||
<div id="headings" class="small-12 medium-7 column select-district">
|
<div id="headings" class="small-12 medium-7 column select-district">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
@@ -30,9 +12,8 @@
|
|||||||
<% slice.each do |heading| %>
|
<% slice.each do |heading| %>
|
||||||
<span id="<%= dom_id(heading) %>"
|
<span id="<%= dom_id(heading) %>"
|
||||||
class="<%= css_for_ballot_heading(heading) %>">
|
class="<%= css_for_ballot_heading(heading) %>">
|
||||||
<%= link_to heading.name,
|
<%= link_to heading.name, budget_investments_path(heading_id: heading.id) %>
|
||||||
budget_investments_path(heading_id: heading.id,
|
<br>
|
||||||
filter: @current_filter) %><br>
|
|
||||||
</span>
|
</span>
|
||||||
<% end %>
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
@@ -44,28 +25,4 @@
|
|||||||
<%= image_tag(image_path_for("map.jpg")) %>
|
<%= image_tag(image_path_for("map.jpg")) %>
|
||||||
</div>
|
</div>
|
||||||
</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>
|
</main>
|
||||||
|
|||||||
@@ -43,10 +43,6 @@ en:
|
|||||||
groups:
|
groups:
|
||||||
show:
|
show:
|
||||||
title: Select a heading
|
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:
|
phase:
|
||||||
drafting: Draft (Not visible to the public)
|
drafting: Draft (Not visible to the public)
|
||||||
informing: Information
|
informing: Information
|
||||||
|
|||||||
@@ -43,10 +43,6 @@ es:
|
|||||||
groups:
|
groups:
|
||||||
show:
|
show:
|
||||||
title: Selecciona una partida
|
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:
|
phase:
|
||||||
drafting: Borrador (No visible para el público)
|
drafting: Borrador (No visible para el público)
|
||||||
informing: Información
|
informing: Información
|
||||||
|
|||||||
@@ -328,42 +328,6 @@ describe "Budgets" do
|
|||||||
let!(:budget) { create(:budget, :selecting) }
|
let!(:budget) { create(:budget, :selecting) }
|
||||||
let!(:group) { create(:budget_group, budget: budget) }
|
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
|
scenario "Take into account headings with the same name from a different budget" do
|
||||||
group1 = create(:budget_group, budget: budget, name: "New York")
|
group1 = create(:budget_group, budget: budget, name: "New York")
|
||||||
heading1 = create(:budget_heading, group: group1, name: "Brooklyn")
|
heading1 = create(:budget_heading, group: group1, name: "Brooklyn")
|
||||||
|
|||||||
@@ -26,25 +26,6 @@ describe "Budget Groups" do
|
|||||||
expect(first_heading.name).to appear_before(last_heading.name)
|
expect(first_heading.name).to appear_before(last_heading.name)
|
||||||
end
|
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
|
scenario "Back link" do
|
||||||
visit budget_group_path(budget, group)
|
visit budget_group_path(budget, group)
|
||||||
|
|
||||||
|
|||||||
@@ -1458,7 +1458,7 @@ describe "Budget Investments" do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
scenario "Highlight voted heading except with unfeasible filter" do
|
scenario "Highlight voted heading" do
|
||||||
budget.update!(phase: "balloting")
|
budget.update!(phase: "balloting")
|
||||||
user = create(:user, :level_two)
|
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_1.id}.is-active")
|
||||||
expect(page).to have_css("#budget_heading_#{heading_2.id}")
|
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
|
end
|
||||||
|
|
||||||
scenario "Ballot is visible" do
|
scenario "Ballot is visible" do
|
||||||
|
|||||||
Reference in New Issue
Block a user