diff --git a/app/assets/stylesheets/participation.scss b/app/assets/stylesheets/participation.scss index 4bc64f9a5..5469f2658 100644 --- a/app/assets/stylesheets/participation.scss +++ b/app/assets/stylesheets/participation.scss @@ -760,6 +760,10 @@ &.past-budgets { min-height: 0; + + .button ~ .button { + margin-left: $line-height / 2; + } } } @@ -1691,9 +1695,10 @@ img { height: $line-height * 9; + min-width: 100%; + max-width: none; transition-duration: 0.3s; transition-property: transform; - width: 100%; } &:hover { diff --git a/app/controllers/budgets/executions_controller.rb b/app/controllers/budgets/executions_controller.rb index e33f43dcd..b321c4377 100644 --- a/app/controllers/budgets/executions_controller.rb +++ b/app/controllers/budgets/executions_controller.rb @@ -13,7 +13,7 @@ module Budgets .joins(:milestones).includes(:milestones) .select { |i| i.milestones.published.with_status .order_by_publication_date.last - .status_id == params[:status].to_i } + .try(:status_id) == params[:status].to_i } .uniq .group_by(&:heading) else diff --git a/app/helpers/budget_executions_helper.rb b/app/helpers/budget_executions_helper.rb index fd8376987..d77867052 100644 --- a/app/helpers/budget_executions_helper.rb +++ b/app/helpers/budget_executions_helper.rb @@ -6,4 +6,9 @@ module BudgetExecutionsHelper .last.status_id == status rescue false }.count end + def first_milestone_with_image(investment) + investment.milestones.order_by_publication_date + .select{ |milestone| milestone.image.present? }.last + end + end diff --git a/app/models/budget/investment/milestone.rb b/app/models/budget/investment/milestone.rb index 562be54b8..f59705ede 100644 --- a/app/models/budget/investment/milestone.rb +++ b/app/models/budget/investment/milestone.rb @@ -17,7 +17,7 @@ class Budget validates :publication_date, presence: true validate :description_or_status_present? - scope :order_by_publication_date, -> { order(publication_date: :asc) } + scope :order_by_publication_date, -> { order(publication_date: :asc, created_at: :asc) } scope :published, -> { where("publication_date <= ?", Date.current) } scope :with_status, -> { where("status_id IS NOT NULL") } diff --git a/app/views/budgets/executions/_image.html.erb b/app/views/budgets/executions/_image.html.erb new file mode 100644 index 000000000..639761875 --- /dev/null +++ b/app/views/budgets/executions/_image.html.erb @@ -0,0 +1,9 @@ +<% milestone = first_milestone_with_image(investment) %> + +<% if milestone&.image.present? %> + <%= image_tag milestone.image_url(:large), alt: milestone.image.title %> +<% elsif investment.image.present? %> + <%= image_tag investment.image_url(:large), alt: investment.image.title %> +<% else %> + <%= image_tag "budget_execution_no_image.jpg", alt: investment.title %> +<% end %> diff --git a/app/views/budgets/executions/_investments.html.erb b/app/views/budgets/executions/_investments.html.erb index b329e1a7b..e9ddd48fb 100644 --- a/app/views/budgets/executions/_investments.html.erb +++ b/app/views/budgets/executions/_investments.html.erb @@ -7,15 +7,7 @@