From 8d5f53e1e7036ca1bf87f188b55c5893098e069f Mon Sep 17 00:00:00 2001 From: lalo Date: Thu, 4 Apr 2019 15:01:54 +0200 Subject: [PATCH 1/2] Refactor budget investment show page extracting code to partial --- .../investments/_investment_detail.erb | 73 ++++++++++++++++++ .../investments/_investment_show.html.erb | 74 +------------------ 2 files changed, 74 insertions(+), 73 deletions(-) create mode 100644 app/views/budgets/investments/_investment_detail.erb diff --git a/app/views/budgets/investments/_investment_detail.erb b/app/views/budgets/investments/_investment_detail.erb new file mode 100644 index 000000000..15c0f3c75 --- /dev/null +++ b/app/views/budgets/investments/_investment_detail.erb @@ -0,0 +1,73 @@ +

<%= investment.title %>

+
+ <%= render "/shared/author_info", resource: investment %> + +  •  + <%= l investment.created_at.to_date %> +  •  + <%= investment.heading.name %> +  •  + + <%= render "budgets/investments/flag_actions", investment: investment %> + +
+ +
+ +<%= render_image(investment.image, :large, true) if investment.image.present? %> + +

+ <%= t("budgets.investments.show.code_html", code: investment.id) %> +

+ +<%= safe_html_with_links investment.description.html_safe %> + +<% if feature?(:map) && map_location_available?(@investment.map_location) %> +
+ <%= render_map(investment.map_location, "budget_investment", false, nil) %> +
+<% end %> + +<% if investment.location.present? %> +

+ <%= t("budgets.investments.show.location_html", location: investment.location) %> +

+<% end %> + +<% if investment.organization_name.present? %> +

+ <%= t("budgets.investments.show.organization_name_html", name: investment.organization_name) %> +

+<% end %> + +<% if feature?(:allow_attached_documents) %> + <%= render "documents/documents", + documents: investment.documents, + max_documents_allowed: Budget::Investment.max_documents_allowed %> +<% end %> + +<%= render "shared/tags", taggable: investment %> + +<% if investment.external_url.present? %> + +<% end %> + +<% if investment.should_show_unfeasibility_explanation? %> +

<%= t("budgets.investments.show.unfeasibility_explanation") %>

+

<%= investment.unfeasibility_explanation %>

+<% end %> + +<% if investment.should_show_price_explanation? %> +

+ <%= t("budgets.investments.show.price_explanation") %> +

+

<%= investment.price_explanation %>

+<% end %> + +<%= render "relationable/related_content", relationable: investment %> + +
+ <%= render "budgets/investments/actions", investment: investment %> +
diff --git a/app/views/budgets/investments/_investment_show.html.erb b/app/views/budgets/investments/_investment_show.html.erb index ecc2645bc..529699001 100644 --- a/app/views/budgets/investments/_investment_show.html.erb +++ b/app/views/budgets/investments/_investment_show.html.erb @@ -18,79 +18,7 @@
<%= back_link_to budget_investments_path(investment.budget, heading_id: investment.heading) %> -

<%= investment.title %>

-
- <%= render "/shared/author_info", resource: investment %> - -  •  - <%= l investment.created_at.to_date %> -  •  - <%= investment.heading.name %> -  •  - - <%= render "budgets/investments/flag_actions", investment: @investment %> - -
- -
- - <%= render_image(investment.image, :large, true) if investment.image.present? %> - -

- <%= t("budgets.investments.show.code_html", code: investment.id) %> -

- - <%= safe_html_with_links investment.description.html_safe %> - - <% if feature?(:map) && map_location_available?(@investment.map_location) %> -
- <%= render_map(@investment.map_location, "budget_investment", false, nil) %> -
- <% end %> - - <% if investment.location.present? %> -

- <%= t("budgets.investments.show.location_html", location: investment.location) %> -

- <% end %> - - <% if investment.organization_name.present? %> -

- <%= t("budgets.investments.show.organization_name_html", name: investment.organization_name) %> -

- <% end %> - - <% if feature?(:allow_attached_documents) %> - <%= render "documents/documents", - documents: investment.documents, - max_documents_allowed: Budget::Investment.max_documents_allowed %> - <% end %> - - <%= render "shared/tags", taggable: investment %> - - <% if investment.external_url.present? %> - - <% end %> - - <% if investment.should_show_unfeasibility_explanation? %> -

<%= t("budgets.investments.show.unfeasibility_explanation") %>

-

<%= investment.unfeasibility_explanation %>

- <% end %> - - <% if investment.should_show_price_explanation? %> -

- <%= t("budgets.investments.show.price_explanation") %> -

-

<%= investment.price_explanation %>

- <% end %> - - <%= render "relationable/related_content", relationable: @investment %> - -
- <%= render "budgets/investments/actions", investment: @investment %> -
+ <%= render partial: "/budgets/investments/investment_detail", locals: {investment: investment} %>