Skip to content

Commit

Permalink
Organization: paginate projects
Browse files Browse the repository at this point in the history
References #369
  • Loading branch information
ybakos committed Apr 29, 2024
1 parent 795cbe0 commit 20cf12a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
3 changes: 3 additions & 0 deletions app/controllers/organizations_controller.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
require 'hash'

class OrganizationsController < ApplicationController
include Pagy::Backend

before_action :authenticate_user!, except: [:show, :index]
before_action :require_admin, except: [:show, :index]
before_action :set_organization, only: %w[ show edit update destroy ]
Expand All @@ -23,6 +25,7 @@ def show
@structure_sum = @organization_projects.sum(:number_of_structures)
@project_total_length_km = @organization_projects.project_total_length_km
@project_total_length_mi = (@project_total_length_km* 0.6214).floor(1)
@pagy, @organization_projects = pagy(@organization_projects)
end

def new
Expand Down
7 changes: 7 additions & 0 deletions app/views/organizations/show.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,13 @@
.container.mt-5
%h2 Affiliated Projects
= render @organization_projects
.row.mb-5
.col.text-right
- if @pagy.prev
= link_to '&lsaquo; Previous page'.html_safe, @pagy.params.merge(page: @pagy.prev), class: 'btn btn-outline-primary', 'aria-label': 'previous'
.col
- if @pagy.next
= link_to 'Next page &rsaquo;'.html_safe, @pagy.params.merge(page: @pagy.next), class: 'btn btn-outline-primary', 'aria-label': 'next'
:javascript
var ctx = document.getElementById('myChart').getContext('2d');

Expand Down

0 comments on commit 20cf12a

Please sign in to comment.