[Git][noosfero/noosfero][master] 2 commits: custom-forms: paginate submissions

Gabriel Silva gitlab at mg.gitlab.com
Wed Jun 27 10:14:48 BRT 2018


Gabriel Silva pushed to branch master at Noosfero / noosfero


Commits:
e7f05d56 by Rodrigo Souto at 2018-06-26T03:48:19Z
custom-forms: paginate submissions

- - - - -
bf704684 by Gabriel Silva at 2018-06-27T13:14:44Z
Merge branch 'paginate-submissions-master' into 'master'

custom-forms: paginate submissions

See merge request noosfero/noosfero!1557
- - - - -


2 changed files:

- plugins/custom_forms/controllers/custom_forms_plugin_myprofile_controller.rb
- plugins/custom_forms/views/custom_forms_plugin_myprofile/submissions.html.erb


Changes:

=====================================
plugins/custom_forms/controllers/custom_forms_plugin_myprofile_controller.rb
=====================================
--- a/plugins/custom_forms/controllers/custom_forms_plugin_myprofile_controller.rb
+++ b/plugins/custom_forms/controllers/custom_forms_plugin_myprofile_controller.rb
@@ -85,7 +85,7 @@ class CustomFormsPluginMyprofileController < MyProfileController
   def submissions
     @form = CustomFormsPlugin::Form.find(params[:id])
     @sort_by = params[:sort_by] == 'author_name' ? 'author_name' : 'created_at'
-    @submissions = @form.submissions.order(@sort_by)
+    @submissions = @form.submissions.order(@sort_by).paginate(page: params[:npage], per_page: per_page)
 
     respond_to do |format|
       format.html
@@ -222,4 +222,8 @@ class CustomFormsPluginMyprofileController < MyProfileController
     forms.map{ |f| { id: f.id, name: f.name } }
   end
 
+  def per_page
+    20
+  end
+
 end


=====================================
plugins/custom_forms/views/custom_forms_plugin_myprofile/submissions.html.erb
=====================================
--- a/plugins/custom_forms/views/custom_forms_plugin_myprofile/submissions.html.erb
+++ b/plugins/custom_forms/views/custom_forms_plugin_myprofile/submissions.html.erb
@@ -37,7 +37,10 @@
       <% end %>
     </tbody>
   </table>
+
   <p>* <%= _('imported submissions') %></p>
+
+  <%= pagination_links(@submissions) %>
 <% end %>
 
 <%= button_bar do %>



View it on GitLab: https://gitlab.com/noosfero/noosfero/compare/b31737450c8cc36aa89554a2c7748846beb37975...bf70468407c57540adc94a2181e5ce9524719f21

-- 
View it on GitLab: https://gitlab.com/noosfero/noosfero/compare/b31737450c8cc36aa89554a2c7748846beb37975...bf70468407c57540adc94a2181e5ce9524719f21
You're receiving this email because of your account on gitlab.com.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listas.softwarelivre.org/pipermail/noosfero-dev/attachments/20180627/c680740f/attachment-0001.html>


More information about the Noosfero-dev mailing list