diff --git a/app/assets/stylesheets/budgets/groups_and_headings.scss b/app/assets/stylesheets/budgets/groups_and_headings.scss new file mode 100644 index 000000000..b3e532f1d --- /dev/null +++ b/app/assets/stylesheets/budgets/groups_and_headings.scss @@ -0,0 +1,67 @@ +.groups-and-headings { + $spacing: $line-height / 2; + + .headings-list { + display: flex; + flex-wrap: wrap; + list-style: none; + margin-left: -$spacing; + } + + .heading { + border: 2px solid $border; + border-radius: rem-calc(6); + box-shadow: 0 0 10px 0 rgba(0, 0, 0, 0.1); + margin-bottom: $line-height / 2; + margin-left: $spacing; + margin-top: $line-height / 4; + padding: $line-height / 2; + position: relative; + width: 100%; + + @include breakpoint(medium) { + width: calc(100% / 3 - #{$spacing}); + } + + @include breakpoint(large) { + width: calc(100% / 6 - #{$spacing}); + } + + &:focus-within { + outline: $outline-focus; + + a:focus { + outline: none; + } + } + + a { + font-weight: bold; + + &::after, + &::before { + bottom: 0; + content: ""; + left: 0; + position: absolute; + right: 0; + top: 0; + } + + &:hover { + text-decoration: none; + } + + &:hover::before { + background: $highlight; + z-index: -1; + } + } + + span { + display: block; + font-size: $small-font-size; + padding-top: $line-height / 2; + } + } +} diff --git a/app/assets/stylesheets/participation.scss b/app/assets/stylesheets/participation.scss index 764d4592c..579a8a08e 100644 --- a/app/assets/stylesheets/participation.scss +++ b/app/assets/stylesheets/participation.scss @@ -1222,36 +1222,6 @@ color: $brand; } -.groups-and-headings { - - .heading { - border: 1px solid $border; - border-radius: rem-calc(3); - display: inline-block; - margin-bottom: $line-height / 2; - - a { - display: block; - padding: $line-height / 2; - - &:hover { - background: $highlight; - text-decoration: none; - } - } - - .heading-name { - padding: $line-height / 2; - } - - span { - color: $text; - display: block; - font-size: $small-font-size; - } - } -} - .progress-votes { position: relative; diff --git a/app/components/budgets/budget_component.html.erb b/app/components/budgets/budget_component.html.erb new file mode 100644 index 000000000..30053714c --- /dev/null +++ b/app/components/budgets/budget_component.html.erb @@ -0,0 +1,32 @@ +
+ <%= link_to t("budgets.index.section_header.help"), "#section_help" %> +
++ <%= t("budgets.index.section_footer.title") %> +
+<%= t("budgets.index.section_footer.description") %>
++ <%= l investment.created_at.to_date %> + + <% if investment.author.hidden? || investment.author.erased? %> + • + + <% else %> + • + + <% if investment.author.official? %> + • + + <% end %> + <% end %> + + • + <%= investment.heading.name %> +
diff --git a/app/components/budgets/investments/info_component.rb b/app/components/budgets/investments/info_component.rb new file mode 100644 index 000000000..b491c4349 --- /dev/null +++ b/app/components/budgets/investments/info_component.rb @@ -0,0 +1,7 @@ +class Budgets::Investments::InfoComponent < ApplicationComponent + attr_reader :investment + + def initialize(investment) + @investment = investment + end +end diff --git a/app/controllers/budgets/ballot/lines_controller.rb b/app/controllers/budgets/ballot/lines_controller.rb index e9df6ab2c..c8c02d296 100644 --- a/app/controllers/budgets/ballot/lines_controller.rb +++ b/app/controllers/budgets/ballot/lines_controller.rb @@ -7,7 +7,6 @@ module Budgets before_action :load_tag_cloud before_action :load_categories before_action :load_investments - before_action :load_ballot_referer authorize_resource :budget authorize_resource :ballot @@ -67,10 +66,6 @@ module Budgets @categories = Tag.category.order(:name) end - def load_ballot_referer - @ballot_referer = session[:ballot_referer] - end - def load_map @investments ||= [] @investments_map_coordinates = MapLocation.where(investment: @investments).map(&:json_data) diff --git a/app/controllers/budgets/ballots_controller.rb b/app/controllers/budgets/ballots_controller.rb index 52b68c630..ecf0bb67e 100644 --- a/app/controllers/budgets/ballots_controller.rb +++ b/app/controllers/budgets/ballots_controller.rb @@ -4,7 +4,6 @@ module Budgets before_action :load_budget authorize_resource :budget before_action :load_ballot - after_action :store_referer, only: [:show] def show authorize! :show, @ballot @@ -22,9 +21,5 @@ module Budgets query = Budget::Ballot.where(user: current_user, budget: @budget) @ballot = @budget.balloting? ? query.first_or_create! : query.first_or_initialize end - - def store_referer - session[:ballot_referer] = request.referer - end end end diff --git a/app/controllers/budgets_controller.rb b/app/controllers/budgets_controller.rb index b7ee1da8a..fd5ecbbd5 100644 --- a/app/controllers/budgets_controller.rb +++ b/app/controllers/budgets_controller.rb @@ -1,13 +1,11 @@ class BudgetsController < ApplicationController include FeatureFlags include BudgetsHelper - include InvestmentFilters feature_flag :budgets before_action :load_budget, only: :show + before_action :load_current_budget, only: :index load_and_authorize_resource - before_action :set_default_investment_filter, only: :show - has_filters investment_filters, only: :show respond_to :html, :js @@ -17,7 +15,6 @@ class BudgetsController < ApplicationController def index @finished_budgets = @budgets.finished.order(created_at: :desc) - @budgets_coordinates = current_budget_map_locations end private @@ -25,4 +22,8 @@ class BudgetsController < ApplicationController def load_budget @budget = Budget.find_by_slug_or_id! params[:id] end + + def load_current_budget + @budget = current_budget + end end diff --git a/app/helpers/budgets_helper.rb b/app/helpers/budgets_helper.rb index fcf937fa0..6d5751302 100644 --- a/app/helpers/budgets_helper.rb +++ b/app/helpers/budgets_helper.rb @@ -5,13 +5,6 @@ module BudgetsHelper end end - def heading_name_and_price_html(heading, budget) - tag.div do - concat(heading.name + " ") - concat(tag.span(budget.formatted_heading_price(heading))) - end - end - def csv_params csv_params = params.clone.merge(format: :csv) csv_params = csv_params.to_unsafe_h.map { |k, v| [k.to_sym, v] }.to_h @@ -63,18 +56,6 @@ module BudgetsHelper budget.published? || current_user&.administrator? end - def current_budget_map_locations - return unless current_budget.present? - - if current_budget.publishing_prices_or_later? && current_budget.investments.selected.any? - investments = current_budget.investments.selected - else - investments = current_budget.investments - end - - MapLocation.where(investment_id: investments).map(&:json_data) - end - def display_calculate_winners_button?(budget) budget.balloting_or_later? end diff --git a/app/views/budgets/ballot/_ballot.html.erb b/app/views/budgets/ballot/_ballot.html.erb index c320a1652..8abf49a19 100644 --- a/app/views/budgets/ballot/_ballot.html.erb +++ b/app/views/budgets/ballot/_ballot.html.erb @@ -1,6 +1,6 @@- <%= link_to t("budgets.index.section_header.help"), "#section_help" %> -
-- <%= t("budgets.index.section_footer.title") %> -
-<%= t("budgets.index.section_footer.description") %>
-- <%= l investment.created_at.to_date %> + <%= render Budgets::Investments::InfoComponent.new(investment) %> - <% if investment.author.hidden? || investment.author.erased? %> - • - - <% else %> - • - - <% if investment.author.official? %> - • - - <% end %> - <% end %> - - • - <%= investment.heading.name %> -
- <%= link_to budget_path(@budget) do %>
+ <%= link_to budget_investments_path(@budget, heading_id: @heading) do %>
<%= t("budgets.results.investment_proyects") %>
<% end %>
- <%= link_to budget_path(@budget, filter: "unfeasible") do %>
+ <%= link_to budget_investments_path(@budget, heading_id: @heading, filter: "unfeasible") do %>
<%= t("budgets.results.unfeasible_investment_proyects") %>
<% end %>
- <%= link_to budget_path(@budget, filter: "unselected") do %>
+ <%= link_to budget_investments_path(@budget, heading_id: @heading, filter: "unselected") do %>
<%= t("budgets.results.not_selected_investment_proyects") %>
<% end %>
| <%= t("budgets.show.group") %> | - - - <% @budget.groups.each do |group| %> -
|---|
|
- <% if group.single_heading_group? %>
- <%= link_to group.name,
- budget_investments_path(@budget,
- heading_id: group.headings.first.id,
- filter: @current_filter),
- data: { turbolinks: false } %>
- <% else %>
- <%= link_to group.name,
- budget_group_path(@budget, group,
- filter: @current_filter) %>
- <% end %>
- - |
-