]> git.openstreetmap.org Git - rails.git/commitdiff
Diary entries #index: Migrate to bootstrap pagination
authorTobias Jordans <t@tobiasjordans.de>
Wed, 30 Dec 2020 13:20:13 +0000 (14:20 +0100)
committerTobias Jordans <t@tobiasjordans.de>
Wed, 30 Dec 2020 13:20:13 +0000 (14:20 +0100)
Use https://getbootstrap.com/docs/4.5/components/pagination/ for the pagination.

I tried using link_to_if but this does not work well in this case since multiple changes need to happen for the disabled state.

app/views/diary_entries/index.html.erb

index 96c052da69fd940ff16c7e7f374017fbde99ed6c..28cb69b24b3aa916aa53792fac8e031f3e96695e 100644 (file)
 
   <%= render @entries %>
 
-  <div class="pagination">
-    <% if @entries.size < @page_size -%>
-      <%= t(".older_entries") %>
-    <% else -%>
-      <%= link_to t(".older_entries"), @params.merge(:page => @page + 1) %>
-    <% end -%>
-
-    |
-
-    <% if @page > 1 -%>
-      <%= link_to t(".newer_entries"), @params.merge(:page => @page - 1) %>
-    <% else -%>
-      <%= t(".newer_entries") %>
-    <% end -%>
-  </div>
+  <nav>
+    <ul class='pagination'>
+      <% if @entries.size >= @page_size -%>
+        <li class='page-item'>
+          <%= link_to t('.older_entries'), @params.merge(:page => @page + 1), :class => 'page-link' %>
+        </li>
+      <% else -%>
+        <li class='page-item disabled'>
+          <%= link_to t('.older_entries'), '#', :class => 'page-link', :tabindex => '-1', :'aria-disabled' => true %>
+        </li>
+      <% end -%>
+
+      <% if @page > 1 -%>
+        <li class='page-item'>
+          <%= link_to_if @page > 1, t(".newer_entries"), @params.merge(:page => @page - 1), :class => 'page-link' %>
+        </li>
+      <% else -%>
+        <li class='page-item disabled'>
+          <%= link_to t('.newer_entries'), '#', :class => 'page-link', :tabindex => '-1', :'aria-disabled' => true %>
+        </li>
+      <% end -%>
+    </ul>
+  </nav>
 <% end %>
 
 <% unless params[:friends] or params[:nearby] -%>