Remove unused JavaScript view in investments admin
This code isn't used since commitc9f31b8e1. Since we no longer depend on the content of the `#investments` element being in a separate partial, we're also moving this element to the partial itself and adding an HTML class to it, like we usually do. We're also removing the code that loads all the investments in the `toggle_selection` action, which wasn't needed since commit3278b3572, when we stopped rendering all the investments in this action.
This commit is contained in:
@@ -6,19 +6,18 @@ class Admin::BudgetInvestmentsController < Admin::BaseController
|
|||||||
feature_flag :budgets
|
feature_flag :budgets
|
||||||
|
|
||||||
has_orders %w[oldest], only: [:show, :edit]
|
has_orders %w[oldest], only: [:show, :edit]
|
||||||
has_filters %w[all], only: [:index, :toggle_selection]
|
has_filters %w[all], only: :index
|
||||||
|
|
||||||
before_action :load_budget
|
before_action :load_budget
|
||||||
before_action :load_investment, only: [:show, :edit, :update, :toggle_selection]
|
before_action :load_investment, only: [:show, :edit, :update, :toggle_selection]
|
||||||
before_action :load_ballot, only: [:show, :index]
|
before_action :load_ballot, only: [:show, :index]
|
||||||
before_action :parse_valuation_filters
|
before_action :parse_valuation_filters
|
||||||
before_action :load_investments, only: [:index, :toggle_selection]
|
before_action :load_investments, only: :index
|
||||||
|
|
||||||
def index
|
def index
|
||||||
load_tags
|
load_tags
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.html
|
format.html
|
||||||
format.js
|
|
||||||
format.csv do
|
format.csv do
|
||||||
send_data Budget::Investment::Exporter.new(@investments).to_csv,
|
send_data Budget::Investment::Exporter.new(@investments).to_csv,
|
||||||
filename: "budget_investments.csv"
|
filename: "budget_investments.csv"
|
||||||
@@ -65,7 +64,6 @@ class Admin::BudgetInvestmentsController < Admin::BaseController
|
|||||||
authorize! :toggle_selection, @investment
|
authorize! :toggle_selection, @investment
|
||||||
@investment.toggle :selected
|
@investment.toggle :selected
|
||||||
@investment.save!
|
@investment.save!
|
||||||
load_investments
|
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|||||||
@@ -1,62 +1,64 @@
|
|||||||
<%= link_to t("admin.budget_investments.index.download_current_selection"),
|
<div id="investments" class="admin-budget-investments">
|
||||||
admin_budget_budget_investments_path(csv_params),
|
<%= link_to t("admin.budget_investments.index.download_current_selection"),
|
||||||
class: "float-right small clear" %>
|
admin_budget_budget_investments_path(csv_params),
|
||||||
|
class: "float-right small clear" %>
|
||||||
|
|
||||||
<% if params[:advanced_filters].include?("winners") %>
|
<% if params[:advanced_filters].include?("winners") %>
|
||||||
<%= render Admin::Budgets::CalculateWinnersButtonComponent.new(@budget, from_investments: true) %>
|
<%= render Admin::Budgets::CalculateWinnersButtonComponent.new(@budget, from_investments: true) %>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
<% if @investments.any? %>
|
<% if @investments.any? %>
|
||||||
<h3 class="inline-block"><%= page_entries_info @investments %></h3>
|
<h3 class="inline-block"><%= page_entries_info @investments %></h3>
|
||||||
<%= render "admin/shared/columns_selector",
|
<%= render "admin/shared/columns_selector",
|
||||||
cookie: "investments-columns",
|
cookie: "investments-columns",
|
||||||
default: %w[id title supports admin valuator geozone feasibility price valuation_finished visible_to_valuators selected incompatible] %>
|
default: %w[id title supports admin valuator geozone feasibility price valuation_finished visible_to_valuators selected incompatible] %>
|
||||||
<br>
|
<br>
|
||||||
|
|
||||||
<%= render "filters_description", i18n_namespace: "admin.budget_investments.index" %>
|
<%= render "filters_description", i18n_namespace: "admin.budget_investments.index" %>
|
||||||
|
|
||||||
<table class="table-for-mobile column-selectable">
|
<table class="table-for-mobile column-selectable">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th><%= link_to_investments_sorted_by :id %></th>
|
<th><%= link_to_investments_sorted_by :id %></th>
|
||||||
<th data-field="title"><%= link_to_investments_sorted_by :title %></th>
|
<th data-field="title"><%= link_to_investments_sorted_by :title %></th>
|
||||||
<th data-field="supports"><%= link_to_investments_sorted_by :supports %></th>
|
<th data-field="supports"><%= link_to_investments_sorted_by :supports %></th>
|
||||||
<th data-field="admin"><%= t("admin.budget_investments.index.list.admin") %></th>
|
<th data-field="admin"><%= t("admin.budget_investments.index.list.admin") %></th>
|
||||||
<th data-field="author">
|
<th data-field="author">
|
||||||
<%= t("admin.budget_investments.index.list.author") %>
|
<%= t("admin.budget_investments.index.list.author") %>
|
||||||
</th>
|
</th>
|
||||||
<th data-field="valuator">
|
<th data-field="valuator">
|
||||||
<%= t("admin.budget_investments.index.list.valuation_group") %> /
|
<%= t("admin.budget_investments.index.list.valuation_group") %> /
|
||||||
<%= t("admin.budget_investments.index.list.valuator") %>
|
<%= t("admin.budget_investments.index.list.valuator") %>
|
||||||
</th>
|
</th>
|
||||||
<th data-field="geozone"><%= t("admin.budget_investments.index.list.geozone") %></th>
|
<th data-field="geozone"><%= t("admin.budget_investments.index.list.geozone") %></th>
|
||||||
<th data-field="feasibility"><%= t("admin.budget_investments.index.list.feasibility") %></th>
|
<th data-field="feasibility"><%= t("admin.budget_investments.index.list.feasibility") %></th>
|
||||||
<% if @budget.show_money? %>
|
<% if @budget.show_money? %>
|
||||||
<th data-field="price"><%= t("admin.budget_investments.index.list.price") %></th>
|
<th data-field="price"><%= t("admin.budget_investments.index.list.price") %></th>
|
||||||
|
<% end %>
|
||||||
|
<th data-field="valuation_finished">
|
||||||
|
<%= t("admin.budget_investments.index.list.valuation_finished") %>
|
||||||
|
</th>
|
||||||
|
<th data-field="visible_to_valuators">
|
||||||
|
<%= t("admin.budget_investments.index.list.visible_to_valuators") %>
|
||||||
|
</th>
|
||||||
|
<th data-field="selected"><%= t("admin.budget_investments.index.list.selected") %></th>
|
||||||
|
<% if params[:advanced_filters]&.include?("selected") %>
|
||||||
|
<th data-field="incompatible"><%= t("admin.budget_investments.index.list.incompatible") %></th>
|
||||||
|
<% end %>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
|
||||||
|
<tbody>
|
||||||
|
<% @investments.each do |investment| %>
|
||||||
|
<%= render Admin::BudgetInvestments::RowComponent.new(investment) %>
|
||||||
<% end %>
|
<% end %>
|
||||||
<th data-field="valuation_finished">
|
</tbody>
|
||||||
<%= t("admin.budget_investments.index.list.valuation_finished") %>
|
</table>
|
||||||
</th>
|
|
||||||
<th data-field="visible_to_valuators">
|
|
||||||
<%= t("admin.budget_investments.index.list.visible_to_valuators") %>
|
|
||||||
</th>
|
|
||||||
<th data-field="selected"><%= t("admin.budget_investments.index.list.selected") %></th>
|
|
||||||
<% if params[:advanced_filters]&.include?("selected") %>
|
|
||||||
<th data-field="incompatible"><%= t("admin.budget_investments.index.list.incompatible") %></th>
|
|
||||||
<% end %>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
|
|
||||||
<tbody>
|
<%= paginate @investments %>
|
||||||
<% @investments.each do |investment| %>
|
<% else %>
|
||||||
<%= render Admin::BudgetInvestments::RowComponent.new(investment) %>
|
<div class="callout primary clear">
|
||||||
<% end %>
|
<%= t("admin.budget_investments.index.no_budget_investments") %>
|
||||||
</tbody>
|
</div>
|
||||||
</table>
|
<% end %>
|
||||||
|
</div>
|
||||||
<%= paginate @investments %>
|
|
||||||
<% else %>
|
|
||||||
<div class="callout primary clear">
|
|
||||||
<%= t("admin.budget_investments.index.no_budget_investments") %>
|
|
||||||
</div>
|
|
||||||
<% end %>
|
|
||||||
|
|||||||
@@ -12,6 +12,4 @@
|
|||||||
|
|
||||||
<%= render "/shared/filter_subnav", i18n_namespace: "admin.budget_investments.index" %>
|
<%= render "/shared/filter_subnav", i18n_namespace: "admin.budget_investments.index" %>
|
||||||
|
|
||||||
<div id="investments">
|
<%= render "investments" %>
|
||||||
<%= render "investments" %>
|
|
||||||
</div>
|
|
||||||
|
|||||||
@@ -1 +0,0 @@
|
|||||||
$("#investments").html("<%= j render("admin/budget_investments/investments") %>");
|
|
||||||
Reference in New Issue
Block a user