aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBruno Perles2015-11-12 16:18:21 +0100
committerBruno Perles2015-11-13 11:17:06 +0100
commit6e6b503de53632dbc1ffad418e4a31491a7b15a8 (patch)
treec392f85bd2dc2a6b67a2e44ac31e320012bac3d4
parentfb245dbf939ce497a8a7355bc994f78164b4204b (diff)
downloadchouette-core-6e6b503de53632dbc1ffad418e4a31491a7b15a8.tar.bz2
#40549 - Fix pagination on huge lines
-rw-r--r--app/controllers/imports_controller.rb4
-rw-r--r--app/views/imports/show.html.erb2
-rw-r--r--app/views/shared/_ie_report.html.erb4
-rw-r--r--app/views/shared/_ie_report_line.html.erb12
4 files changed, 16 insertions, 6 deletions
diff --git a/app/controllers/imports_controller.rb b/app/controllers/imports_controller.rb
index bc5aae465..44f0307a0 100644
--- a/app/controllers/imports_controller.rb
+++ b/app/controllers/imports_controller.rb
@@ -96,6 +96,10 @@ class ImportsController < ChouetteController
def resource
@import ||= import_service.find( params[:id] )
+ @line_items = @import.report.line_items
+ if @line_items.size > 500
+ @line_items = @line_items.paginate(page: params[:page], per_page: 20)
+ end
end
def collection
diff --git a/app/views/imports/show.html.erb b/app/views/imports/show.html.erb
index 21e06d964..926445f93 100644
--- a/app/views/imports/show.html.erb
+++ b/app/views/imports/show.html.erb
@@ -19,7 +19,7 @@
<%= link_to font_awesome_classic_tag("fa-file-#{@import.filename_extension}-o") + t("imports.show.imported_file"), imported_file_referential_import_path(@referential, @import.id) if @import.file_path? %>
<%= link_to font_awesome_classic_tag("fa-external-link") + t("imports.show.compliance_check"), compliance_check_referential_import_path(@referential, @import.id) if @import.compliance_check? %>
</div>
- <%= render(partial: "shared/ie_report.html", locals: {job: @import}) %>
+ <%= render(partial: 'shared/ie_report', locals: {job: @import, line_items: @line_items}) %>
</div>
<% content_for :sidebar do %>
diff --git a/app/views/shared/_ie_report.html.erb b/app/views/shared/_ie_report.html.erb
index f4f6fa043..11a49879b 100644
--- a/app/views/shared/_ie_report.html.erb
+++ b/app/views/shared/_ie_report.html.erb
@@ -15,13 +15,13 @@
<div class="tab-content">
<div role="tabpanel" class="tab-pane active" id="ie_tab_line">
- <%= render partial: 'shared/ie_report_line', locals: { job: job, type: (defined?(type) ? type : :default) } %>
+ <%= render partial: 'shared/ie_report_line', locals: { job: job, line_items: line_items, type: (defined?(type) ? type : :default) } %>
</div>
<div role="tabpanel" class="tab-pane" id="ie_tab_file">
<%= render partial: 'shared/ie_report_file', locals: { job: job } %>
</div>
</div>
<% else %>
- <%= render partial: 'shared/ie_report_line', locals: { job: job, type: (defined?(type) ? type : :default) } %>
+ <%= render partial: 'shared/ie_report_line', locals: { job: job, line_items: line_items, type: (defined?(type) ? type : :default) } %>
<% end %>
</div>
diff --git a/app/views/shared/_ie_report_line.html.erb b/app/views/shared/_ie_report_line.html.erb
index 8c635baa8..a8399f2d2 100644
--- a/app/views/shared/_ie_report_line.html.erb
+++ b/app/views/shared/_ie_report_line.html.erb
@@ -25,7 +25,7 @@
</div>
</form>
</p>
- <table id="table-line" class="table table-hover table-striped data-table toggle-circle toggle-medium" data-filter="#filter-line" data-page-size="20">
+ <table class="table table-hover table-striped data-table toggle-circle toggle-medium" data-filter="#filter-line"<% unless line_items.respond_to?(:total_pages) %> id="table-line" data-page-size="20"<% end %>>
<thead>
<tr>
<th><%= t(".table.line.state") %></th>
@@ -41,7 +41,7 @@
</tr>
</thead>
<tbody>
- <% job.report.line_items.each_with_index do |line_item, index| %>
+ <% line_items.each_with_index do |line_item, index| %>
<tr>
<td data-value="<%=line_item.status%>"><%= line_item.status ? font_awesome_classic_tag("fa-check") : font_awesome_classic_tag("fa-times") %></td>
<td><%= line_item.name %></td>
@@ -58,7 +58,13 @@
</tbody>
<tfoot>
<tr>
- <td colspan="5"><ul class="pagination pagination-centered"></ul></td>
+ <td colspan="10">
+ <% if line_items.respond_to?(:total_pages) %>
+ <%= will_paginate line_items, renderer: BootstrapPagination::Rails %>
+ <% else %>
+ <ul class="pagination pagination-centered"></ul>
+ <% end %>
+ </td>
</tr>
</tfoot>
</table>