diff options
author | Jan Provaznik <jprovaznik@gitlab.com> | 2018-01-29 16:22:58 +0100 |
---|---|---|
committer | Jan Provaznik <jprovaznik@gitlab.com> | 2018-01-29 18:17:17 +0100 |
commit | 71f36786ba9b902aabc88679404b095f474e2ba0 (patch) | |
tree | d31d6816f7e4aa9ab42e24445384e14a4e854c81 /app | |
parent | 501d81c523b2cf53128e62ea2d7c4dff6681928d (diff) | |
download | gitlab-ce-jprovazn-pagination.tar.gz |
Make pagination optional for issuablesjprovazn-pagination
On epics roadmap page we list all epics in the given time frame
without pagination (at least for the first iteration), in this
case it would be nice to use the existing issuables index logic
except pagination (see MR gitlab-ee!4281). For this reason this
patch allows to easily disable pagination.
Related gitlab-ee!4281
Diffstat (limited to 'app')
-rw-r--r-- | app/controllers/concerns/issuable_collections.rb | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/app/controllers/concerns/issuable_collections.rb b/app/controllers/concerns/issuable_collections.rb index b25e753a5ad..2fa0f98e344 100644 --- a/app/controllers/concerns/issuable_collections.rb +++ b/app/controllers/concerns/issuable_collections.rb @@ -12,11 +12,9 @@ module IssuableCollections # rubocop:disable Gitlab/ModuleWithInstanceVariables def set_issuables_index - @issuables = issuables_collection - @issuables = @issuables.page(params[:page]) - @issuable_meta_data = issuable_meta_data(@issuables, collection_type) - @total_pages = issuable_page_count + @issuables = issuables_collection + set_pagination return if redirect_out_of_range(@total_pages) if params[:label_name].present? @@ -35,14 +33,26 @@ module IssuableCollections @users.push(author) if author end end + + def set_pagination + return if pagination_disabled? + + @issuables = @issuables.page(params[:page]) + @issuable_meta_data = issuable_meta_data(@issuables, collection_type) + @total_pages = issuable_page_count + end # rubocop:enable Gitlab/ModuleWithInstanceVariables + def pagination_disabled? + false + end + def issuables_collection finder.execute.preload(preload_for_collection) end def redirect_out_of_range(total_pages) - return false if total_pages.zero? + return false if total_pages.nil? || total_pages.zero? out_of_range = @issuables.current_page > total_pages # rubocop:disable Gitlab/ModuleWithInstanceVariables |