Browse Source

Pagination on dashboard

Maarten van den Berg 7 years ago
parent
commit
fa0e28a614

+ 11 - 0
app/assets/stylesheets/application.scss

@@ -88,3 +88,14 @@ table.collapse.in {
88 88
 [aria-expanded="false"] > .sv-show-collapsed {
89 89
   display: inline;
90 90
 }
91
+
92
+/* Fix ridiculous margins with pagination */
93
+.sv-nomargins > nav.pagination {
94
+  margin-top: 0;
95
+  margin-bottom: 0;
96
+}
97
+
98
+.sv-nomargins > nav.pagination > ul.pagination {
99
+  margin-top: 0;
100
+  margin-bottom: 0;
101
+}

+ 3 - 0
app/controllers/dashboard_controller.rb

@@ -7,9 +7,12 @@ class DashboardController < ApplicationController
7 7
       .joins(:activity)
8 8
       .where('activities.start >= ?', DateTime.now)
9 9
       .order('activities.start ASC')
10
+      .paginate(page: params[:upage], per_page: 10)
10 11
     @user_organized = @upcoming
11 12
       .where(is_organizer: true)
13
+      .limit(3)
12 14
     @need_response = @upcoming
13 15
       .where(attending: nil)
16
+      .paginate(page: params[:nrpage], per_page: 5)
14 17
   end
15 18
 end

+ 4 - 0
app/views/dashboard/home.html.haml

@@ -36,6 +36,8 @@
36 36
                       = e.location
37 37
                     %td
38 38
                       = render partial: "activities/presence_buttons", locals: {activity: e, person: current_person, state: p.attending}
39
+          .panel-footer.text-center.sv-nomargins
40
+            = will_paginate @need_response, param_name: 'nrpage', renderer: WillPaginate::ActionView::Bootstrap4LinkRenderer, class: 'pagination-sm pagination'
39 41
   .row
40 42
     .col-md-6
41 43
       .panel.panel-default
@@ -86,3 +88,5 @@
86 88
                     = render partial: "activities/presence_buttons", locals: {activity: e, person: current_person, state: p.attending}
87 89
                   %td
88 90
                     = editable p, :notes, url: presence_group_activity_path(e.group, e, person_id: current_person.id), title: t('activities.participant.notes'), value: p.notes, emptytext: t('activities.participant.add_notes')
91
+        .panel-footer.text-center.sv-nomargins
92
+          = will_paginate(@upcoming, param_name: 'upage', renderer: WillPaginate::ActionView::Bootstrap4LinkRenderer, class: 'pagination-sm pagination')

+ 18 - 0
config/locales/nl_willpaginate.yml

@@ -0,0 +1,18 @@
1
+nl:
2
+  will_paginate:
3
+    previous_label: "&#8592;"
4
+    next_label: "&#8594;"
5
+    page_gap: "&hellip;"
6
+
7
+    page_entries_info:
8
+      single_page:
9
+        zero:  "Geen %{model} gevonden"
10
+        one:   "Er is 1 %{model}"
11
+        other: "Dit zijn alle %{count} %{model}"
12
+      single_page_html:
13
+        zero:  "Geen %{model} gevonden"
14
+        one:   "Er is <b>1</b> %{model}"
15
+        other: "Dit zijn <b>alle&nbsp;%{count}</b> %{model}"
16
+
17
+      multi_page: "%{model} %{from} - %{to} van %{count}"
18
+      multi_page_html: "%{model} <b>%{from}&nbsp;-&nbsp;%{to}</b> van <b>%{count}</b>"