diff --git a/app/assets/stylesheets/participation.scss b/app/assets/stylesheets/participation.scss index 5551017c3..a7cb5ca69 100644 --- a/app/assets/stylesheets/participation.scss +++ b/app/assets/stylesheets/participation.scss @@ -653,15 +653,16 @@ } } -.budget-investments-list { - .budget-investment { - .no-image { - background: $brand; - } +.budget-investments-list .budget-investment, +.proposals-list .proposal { + + .no-image { + background: $brand; } } -.budget-investments-list .budget-investment { +.budget-investments-list .budget-investment, +.proposals-list .proposal { @include breakpoint(small) { .no-image { diff --git a/app/helpers/images_helper.rb b/app/helpers/images_helper.rb index 47c7c0c47..324ae9e8e 100644 --- a/app/helpers/images_helper.rb +++ b/app/helpers/images_helper.rb @@ -1,5 +1,24 @@ module ImagesHelper + def image_absolute_url(image, version) + return "" unless image + if Paperclip::Attachment.default_options[:storage] == :filesystem + URI(request.url) + image.attachment.url(version) + else + investment.image_url(version) + end + end + + def image_note(image) + t "images.new.#{image.imageable.class.name.parameterize.underscore}.note", + title: image.imageable.title + end + + def image_first_recommendation(image) + t "images.#{image.imageable.class.name.parameterize.underscore}.recommendation_one_html", + title: image.imageable.title + end + def image_attachment_file_name(image) image.attachment_file_name end diff --git a/app/helpers/investments_helper.rb b/app/helpers/investments_helper.rb deleted file mode 100644 index e7a7112ce..000000000 --- a/app/helpers/investments_helper.rb +++ /dev/null @@ -1,23 +0,0 @@ -module InvestmentsHelper - - def investment_image_full_url(investment, version) - URI(request.url) + investment.image_url(version) - end - - def investment_image_advice_note(investment) - if investment.image.present? - t("budgets.investments.edit_image.edit_note", title: investment.title) - else - t("budgets.investments.edit_image.add_note", title: investment.title) - end - end - - def investment_image_button_text(investment) - investment.image.present? ? t("budgets.investments.show.edit_image") : t("budgets.investments.show.add_image") - end - - def errors_on_image(investment) - investment.errors[:attachment].join(', ') if investment.errors.key?(:attachment) - end - -end diff --git a/app/helpers/proposals_helper.rb b/app/helpers/proposals_helper.rb index 64936302e..51d056349 100644 --- a/app/helpers/proposals_helper.rb +++ b/app/helpers/proposals_helper.rb @@ -36,6 +36,10 @@ module ProposalsHelper can?(:create, document) && proposal.documents.size < Proposal.max_documents_allowed end + def can_destroy_image?(image, proposal) + proposal.image.present? && can?(:destroy, image) + end + def author_of_proposal?(proposal) author_of?(proposal, current_user) end diff --git a/app/views/budgets/investments/_investment_show.html.erb b/app/views/budgets/investments/_investment_show.html.erb index cf228658b..307398f2e 100644 --- a/app/views/budgets/investments/_investment_show.html.erb +++ b/app/views/budgets/investments/_investment_show.html.erb @@ -132,7 +132,7 @@ <%= render partial: 'shared/social_share', locals: { share_title: t("budgets.investments.show.share"), title: investment.title, - image_url: investment.image.present? ? investment_image_full_url(investment, :thumb) : '', + image_url: image_absolute_url(investment.image, :thumb), url: budget_investment_url(budget_id: investment.budget_id, id: investment.id) } %> diff --git a/app/views/images/new.html.erb b/app/views/images/new.html.erb index 003c6f6ca..a42df25ac 100644 --- a/app/views/images/new.html.erb +++ b/app/views/images/new.html.erb @@ -3,6 +3,7 @@
<%= back_link_to params[:from] %>

<%= t("images.new.title") %>

+

<%= image_note(@image) %>

<%= render "form", form_url: images_url %>
@@ -11,7 +12,7 @@

<%= t("images.recommendations_title") %>