kanbanworkflowstimelinescrumrubyroadmapproject-planningproject-managementopenprojectangularissue-trackerifcgantt-chartganttbug-trackerboardsbcf
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
39 lines
1.0 KiB
39 lines
1.0 KiB
12 years ago
|
#-- copyright
|
||
|
# OpenProject is a project management system.
|
||
|
#
|
||
|
# Copyright (C) 2012-2013 the OpenProject Team
|
||
|
#
|
||
|
# This program is free software; you can redistribute it and/or
|
||
|
# modify it under the terms of the GNU General Public License version 3.
|
||
|
#
|
||
|
# See doc/COPYRIGHT.rdoc for more details.
|
||
|
#++
|
||
|
|
||
12 years ago
|
# This module includes some boilerplate code for pagination using scopes.
|
||
|
# #search_scope has to be overridden by the model itself and MUST return an
|
||
|
# actual scope (i.e. scope in Rails3 or named_scope in Rails2) or its corresponding hash.
|
||
|
|
||
12 years ago
|
module Pagination::Model
|
||
12 years ago
|
|
||
|
def self.included(base)
|
||
|
base.extend self
|
||
|
end
|
||
|
|
||
|
def self.extended(base)
|
||
|
base.instance_eval do
|
||
|
unloadable
|
||
|
|
||
|
def paginate_scope!(scope, options = {})
|
||
|
limit = options.fetch(:page_limit) || 10
|
||
|
page = options.fetch(:page) || 1
|
||
12 years ago
|
|
||
|
scope.paginate({ :per_page => limit, :page => page })
|
||
12 years ago
|
end
|
||
|
|
||
|
def search_scope(query)
|
||
|
raise NotImplementedError, "Override in subclass #{self.name}"
|
||
|
end
|
||
|
end
|
||
|
end
|
||
|
end
|