Allow printing investments from any budget in the management interface
This commit is contained in:
@@ -7,13 +7,17 @@
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr id="<%= dom_id(budget) %>">
|
||||
<td><%= budget.name %></td>
|
||||
<td><%= budget.current_phase.name %></td>
|
||||
<td align="right">
|
||||
<%= link_to t("management.budgets.print_investments"),
|
||||
print_management_budget_investments_path(budget) %>
|
||||
</td>
|
||||
</tr>
|
||||
<% budgets.each do |budget| %>
|
||||
<tr id="<%= dom_id(budget) %>">
|
||||
<td><%= budget.name %></td>
|
||||
<td><%= budget.current_phase.name %></td>
|
||||
<td align="right">
|
||||
<%= link_to t("management.budgets.print_investments"),
|
||||
print_management_budget_investments_path(budget) %>
|
||||
</td>
|
||||
</tr>
|
||||
<% end %>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<%= paginate budgets %>
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
class Management::Budgets::PrintInvestments::TableComponent < ApplicationComponent
|
||||
attr_reader :budget
|
||||
attr_reader :budgets
|
||||
delegate :paginate, to: :helpers
|
||||
|
||||
def initialize(budget)
|
||||
@budget = budget
|
||||
def initialize(budgets)
|
||||
@budgets = budgets
|
||||
end
|
||||
end
|
||||
|
||||
@@ -49,10 +49,6 @@ class Management::BaseController < ActionController::Base
|
||||
I18n.with_locale(session[:locale], &action)
|
||||
end
|
||||
|
||||
def current_budget
|
||||
Budget.current
|
||||
end
|
||||
|
||||
def clear_password
|
||||
session[:new_password] = nil
|
||||
end
|
||||
|
||||
@@ -19,7 +19,7 @@ class Management::BudgetsController < Management::BaseController
|
||||
end
|
||||
|
||||
def print_investments
|
||||
@budget = current_budget
|
||||
@budgets = Budget.published.order(created_at: :desc).page(params[:page])
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
@@ -1,3 +1,9 @@
|
||||
<h2><%= t("management.budgets.print_investments") %></h2>
|
||||
|
||||
<%= render Management::Budgets::PrintInvestments::TableComponent.new(@budget) %>
|
||||
<% if @budgets.any? %>
|
||||
<%= render Management::Budgets::PrintInvestments::TableComponent.new(@budgets) %>
|
||||
<% else %>
|
||||
<div class="callout primary">
|
||||
<%= t("management.budgets.no_budgets") %>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
Reference in New Issue
Block a user