From acebb07dddcf7768958ad0260723469b9e1a44d4 Mon Sep 17 00:00:00 2001 From: decabeza Date: Mon, 12 Mar 2018 17:06:50 +0100 Subject: [PATCH] Adds link to image and docs on admin budget investment info --- app/assets/stylesheets/admin.scss | 25 +++++++-- .../_written_by_author.html.erb | 54 ++++++++++++++----- app/views/documents/_documents.html.erb | 2 +- app/views/images/_image.html.erb | 2 +- config/locales/en/admin.yml | 6 +++ config/locales/es/admin.yml | 6 +++ .../features/admin/budget_investments_spec.rb | 29 ++++++++++ 7 files changed, 106 insertions(+), 18 deletions(-) diff --git a/app/assets/stylesheets/admin.scss b/app/assets/stylesheets/admin.scss index 45390aca4..b1037e47e 100644 --- a/app/assets/stylesheets/admin.scss +++ b/app/assets/stylesheets/admin.scss @@ -507,8 +507,7 @@ $sidebar-active: #f4fcd0; } .account-info, -.login-as, -.spending-proposal-info { +.login-as { background-color: #e7e7e7; border-radius: rem-calc(3); font-size: rem-calc(16); @@ -521,8 +520,26 @@ $sidebar-active: #f4fcd0; } } -.spending-proposal-info p { - margin-bottom: 0; +.extra-info { + background: #fafafa; + border-bottom-left-radius: rem-calc(6); + border-bottom-right-radius: rem-calc(6); + border-top: 2px solid #000; + font-size: $small-font-size; + padding: $line-height / 2; +} + +.admin-budget-investment-info { + background: $highlight-soft; + border: 2px solid $highlight; + border-radius: rem-calc(4); + margin-bottom: $line-height; + padding: $line-height / 2; + + p { + font-size: $small-font-size; + margin-bottom: 0; + } } .admin { diff --git a/app/views/admin/budget_investments/_written_by_author.html.erb b/app/views/admin/budget_investments/_written_by_author.html.erb index 8cf2eca57..2ce89e667 100644 --- a/app/views/admin/budget_investments/_written_by_author.html.erb +++ b/app/views/admin/budget_investments/_written_by_author.html.erb @@ -1,50 +1,53 @@ -
- <%= t "admin.budget_investments.show.info", budget_name: @budget.name, group_name: @investment.group.name, id: @investment.id %> +
+ <%= t "admin.budget_investments.show.info", + budget_name: @budget.name, + group_name: @investment.group.name, + id: @investment.id %>

<%= @investment.title %>

-
-
+
+

: <%= @investment.group.name %>"> - <%= t("admin.budget_investments.show.heading") %>: + <%= t("admin.budget_investments.show.heading") %>: <%= @investment.heading.name %>

- <%= t("admin.budget_investments.show.by") %>: + <%= t("admin.budget_investments.show.by") %>: <%= link_to @investment.author.name, admin_hidden_user_path(@investment.author) %>

- <%= t("admin.budget_investments.show.sent") %>: + <%= t("admin.budget_investments.show.sent") %>: <%= l @investment.created_at, format: :datetime %>

-
+

- <%= t("admin.budget_investments.show.compatibility.title") %>: + <%= t("admin.budget_investments.show.compatibility.title") %>: <%= t("admin.budget_investments.show.compatibility.#{@investment.incompatible?}") %>

- <%= t("admin.budget_investments.show.selection.title") %>: + <%= t("admin.budget_investments.show.selection.title") %>: <%= t("admin.budget_investments.show.selection.#{@investment.selected?}") %>

- <%= t("admin.budget_investments.show.winner.title") %>: + <%= t("admin.budget_investments.show.winner.title") %>: <%= t("admin.budget_investments.show.winner.#{@investment.winner?}") %>

@@ -52,11 +55,38 @@
<% if @investment.external_url.present? %> -

<%= text_with_links @investment.external_url %> 

+

+ <%= text_with_links @investment.external_url %>  +

<% end %> <%= safe_html_with_links @investment.description %> +

+ <%= t("admin.budget_investments.show.image") %>: + + <% if @investment.image.present? %> + <%= link_to t("admin.budget_investments.show.see_image"), + namespaced_budget_investment_path(@investment, {anchor: 'image'}), + target: "blank" %> + <% else %> + <%= t("admin.budget_investments.show.no_image") %> + <% end %> +

+ +

+ <%= t("admin.budget_investments.show.documents") %>: + + <% if @investment.documents.present? %> + <%= link_to t("admin.budget_investments.show.see_documents", + count: @investment.documents.count), + namespaced_budget_investment_path(@investment, {anchor: 'documents'}), + target: "blank" %> + <% else %> + <%= t("admin.budget_investments.show.no_documents") %> + <% end %> +

+

<%= t("admin.budget_investments.show.user_tags") %>: <%= @investment.tag_list.sort.join(', ') %> diff --git a/app/views/documents/_documents.html.erb b/app/views/documents/_documents.html.erb index 5963127df..44e116cdd 100644 --- a/app/views/documents/_documents.html.erb +++ b/app/views/documents/_documents.html.erb @@ -1,4 +1,4 @@ -

+

<%= t("documents.title") %> (<%= documents.count %>)

<% if documents.any? %> diff --git a/app/views/images/_image.html.erb b/app/views/images/_image.html.erb index 1f2494c01..edcf07187 100644 --- a/app/views/images/_image.html.erb +++ b/app/views/images/_image.html.erb @@ -1,4 +1,4 @@ -
+
<%= image_tag image.attachment.url(version), class: image_class(image), diff --git a/config/locales/en/admin.yml b/config/locales/en/admin.yml index 2058b917d..5cacb2a13 100644 --- a/config/locales/en/admin.yml +++ b/config/locales/en/admin.yml @@ -214,6 +214,12 @@ en: title: Winner "true": "Yes" "false": "No" + image: "Image" + see_image: "See image" + no_image: "Without image" + documents: "Documents" + see_documents: "See documents (%{count})" + no_documents: "Without documents" edit: classification: Classification compatibility: Compatibility diff --git a/config/locales/es/admin.yml b/config/locales/es/admin.yml index 399eda7bb..a63c714ab 100644 --- a/config/locales/es/admin.yml +++ b/config/locales/es/admin.yml @@ -213,6 +213,12 @@ es: title: Ganadora "true": "Si" "false": "No" + image: "Imagen" + see_image: "Ver imagen" + no_image: "Sin imagen" + documents: "Documentos" + see_documents: "Ver documentos (%{count})" + no_documents: "Sin documentos" edit: classification: Clasificación compatibility: Compatibilidad diff --git a/spec/features/admin/budget_investments_spec.rb b/spec/features/admin/budget_investments_spec.rb index b9ce3bb1e..2764bb7bb 100644 --- a/spec/features/admin/budget_investments_spec.rb +++ b/spec/features/admin/budget_investments_spec.rb @@ -443,6 +443,8 @@ feature 'Admin budget investments' do expect(page).to have_content(budget_investment.description) expect(page).to have_content(budget_investment.author.name) expect(page).to have_content(budget_investment.heading.name) + expect(page).to have_content('Without image') + expect(page).to have_content('Without documents') expect(page).to have_content('1234') expect(page).to have_content('1000') expect(page).to have_content('Unfeasible') @@ -456,6 +458,33 @@ feature 'Admin budget investments' do expect(page).to have_button "Publish comment" end + scenario 'Show image and documents on investment details' do + budget_investment = create(:budget_investment, + price: 1234, + price_first_year: 1000, + feasibility: "unfeasible", + unfeasibility_explanation: 'It is impossible', + administrator: administrator) + create(:image, imageable: budget_investment) + document = create(:document, documentable: budget_investment) + + visit admin_budget_budget_investments_path(budget_investment.budget) + + click_link budget_investment.title + + expect(page).to have_content(budget_investment.title) + expect(page).to have_content(budget_investment.description) + expect(page).to have_content(budget_investment.author.name) + expect(page).to have_content(budget_investment.heading.name) + expect(page).to have_content('See image') + expect(page).to have_content('See documents (1)') + expect(page).to have_content('1234') + expect(page).to have_content('1000') + expect(page).to have_content('Unfeasible') + expect(page).to have_content('It is impossible') + expect(page).to have_content('Ana (ana@admins.org)') + end + scenario "If budget is finished, investment cannot be edited or valuation comments created" do # Only milestones can be managed