Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Admin budget investment info #2539

Merged
merged 1 commit into from
Mar 27, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 21 additions & 4 deletions app/assets/stylesheets/admin.scss
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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 {
Expand Down
54 changes: 42 additions & 12 deletions app/views/admin/budget_investments/_written_by_author.html.erb
Original file line number Diff line number Diff line change
@@ -1,62 +1,92 @@
<div class="callout primary float-right">
<%= t "admin.budget_investments.show.info", budget_name: @budget.name, group_name: @investment.group.name, id: @investment.id %>
<div class="extra-info float-right">
<%= t "admin.budget_investments.show.info",
budget_name: @budget.name,
group_name: @investment.group.name,
id: @investment.id %>
</div>

<br>
<h1 class="inline-block"><%= @investment.title %></h1>

<div class="row small-collapse spending-proposal-info">
<div class="row">
<div class="admin-budget-investment-info">
<div class="row expanded">
<div class="small-12 medium-4 column">
<p title="<%= t("admin.budget_investments.show.group") %>: <%= @investment.group.name %>">
<strong><%= t("admin.budget_investments.show.heading") %>:</strong>
<strong><%= t("admin.budget_investments.show.heading") %></strong>:
<%= @investment.heading.name %>
</p>
</div>

<div class="small-12 medium-4 column">
<p>
<strong><%= t("admin.budget_investments.show.by") %>:</strong>
<strong><%= t("admin.budget_investments.show.by") %></strong>:
<%= link_to @investment.author.name, admin_hidden_user_path(@investment.author) %>
</p>
</div>

<div class="small-12 medium-4 column">
<p>
<strong><%= t("admin.budget_investments.show.sent") %>:</strong>
<strong><%= t("admin.budget_investments.show.sent") %></strong>:
<%= l @investment.created_at, format: :datetime %>
</p>
</div>
</div>

<div class="row">
<div class="row expanded">
<div class="small-12 medium-4 column">
<p>
<strong><%= t("admin.budget_investments.show.compatibility.title") %>:</strong>
<strong><%= t("admin.budget_investments.show.compatibility.title") %></strong>:
<%= t("admin.budget_investments.show.compatibility.#{@investment.incompatible?}") %>
</p>
</div>
<div class="small-12 medium-4 column">
<p>
<strong><%= t("admin.budget_investments.show.selection.title") %>:</strong>
<strong><%= t("admin.budget_investments.show.selection.title") %></strong>:
<%= t("admin.budget_investments.show.selection.#{@investment.selected?}") %>
</p>
</div>
<div class="small-12 medium-4 column">
<p>
<strong><%= t("admin.budget_investments.show.winner.title") %>:</strong>
<strong><%= t("admin.budget_investments.show.winner.title") %></strong>:
<%= t("admin.budget_investments.show.winner.#{@investment.winner?}") %>
</p>
</div>
</div>
</div>

<% if @investment.external_url.present? %>
<p><%= text_with_links @investment.external_url %>&nbsp;<span class="icon-external small"></span></p>
<p>
<%= text_with_links @investment.external_url %>&nbsp;<span class="icon-external small"></span>
</p>
<% end %>

<%= safe_html_with_links @investment.description %>

<p>
<strong><%= t("admin.budget_investments.show.image") %></strong>:

<% 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 %>
</p>

<p>
<strong><%= t("admin.budget_investments.show.documents") %></strong>:

<% 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 %>
</p>

<p id="user-tags">
<strong><%= t("admin.budget_investments.show.user_tags") %>: </strong>
<%= @investment.tag_list.sort.join(', ') %>
Expand Down
2 changes: 1 addition & 1 deletion app/views/documents/_documents.html.erb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<div class="documents">
<div id="documents" class="documents">
<h2><%= t("documents.title") %>&nbsp;<span>(<%= documents.count %>)</span></h2>

<% if documents.any? %>
Expand Down
2 changes: 1 addition & 1 deletion app/views/images/_image.html.erb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<div class="small-12 column text-center image-preview">
<div id="image" class="small-12 column text-center image-preview">
<figure>
<%= image_tag image.attachment.url(version),
class: image_class(image),
Expand Down
6 changes: 6 additions & 0 deletions config/locales/en/admin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 6 additions & 0 deletions config/locales/es/admin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
29 changes: 29 additions & 0 deletions spec/features/admin/budget_investments_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -443,6 +443,8 @@
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')
Expand All @@ -456,6 +458,33 @@
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

Expand Down