diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb
index a3cb0242..7500acdb 100644
--- a/app/controllers/application_controller.rb
+++ b/app/controllers/application_controller.rb
@@ -55,6 +55,14 @@ class ApplicationController < ActionController::Base
request.session[:impersonated_user_id] = user.uuid
end
+ def pagy_auto(collection, **keyword_args)
+ if current_ability.can?(:manage, :countless)
+ pagy_countless(collection, **keyword_args)
+ else
+ pagy(collection, **keyword_args)
+ end
+ end
+
private
def with_locale(&)
diff --git a/app/controllers/submissions_archived_controller.rb b/app/controllers/submissions_archived_controller.rb
index f71638c7..3ad5d936 100644
--- a/app/controllers/submissions_archived_controller.rb
+++ b/app/controllers/submissions_archived_controller.rb
@@ -18,6 +18,6 @@ class SubmissionsArchivedController < ApplicationController
@submissions.order(id: :desc)
end
- @pagy, @submissions = pagy(@submissions.preload(submitters: :start_form_submission_events))
+ @pagy, @submissions = pagy_auto(@submissions.preload(submitters: :start_form_submission_events))
end
end
diff --git a/app/controllers/submissions_dashboard_controller.rb b/app/controllers/submissions_dashboard_controller.rb
index 3386edd8..55fb6ae0 100644
--- a/app/controllers/submissions_dashboard_controller.rb
+++ b/app/controllers/submissions_dashboard_controller.rb
@@ -19,6 +19,6 @@ class SubmissionsDashboardController < ApplicationController
@submissions.order(id: :desc)
end
- @pagy, @submissions = pagy(@submissions.preload(submitters: :start_form_submission_events))
+ @pagy, @submissions = pagy_auto(@submissions.preload(submitters: :start_form_submission_events))
end
end
diff --git a/app/controllers/template_folders_controller.rb b/app/controllers/template_folders_controller.rb
index e5cb2bbf..c22f2fed 100644
--- a/app/controllers/template_folders_controller.rb
+++ b/app/controllers/template_folders_controller.rb
@@ -9,7 +9,7 @@ class TemplateFoldersController < ApplicationController
@templates = Templates.search(@templates, params[:q])
@templates = Templates::Order.call(@templates, current_user, cookies.permanent[:dashboard_templates_order])
- @pagy, @templates = pagy(@templates, limit: 12)
+ @pagy, @templates = pagy_auto(@templates, limit: 12)
end
def edit; end
diff --git a/app/controllers/templates_archived_controller.rb b/app/controllers/templates_archived_controller.rb
index f75e83a1..f52e5af7 100644
--- a/app/controllers/templates_archived_controller.rb
+++ b/app/controllers/templates_archived_controller.rb
@@ -7,6 +7,6 @@ class TemplatesArchivedController < ApplicationController
@templates = @templates.where.not(archived_at: nil).preload(:author, :folder, :template_accesses).order(id: :desc)
@templates = Templates.search(@templates, params[:q])
- @pagy, @templates = pagy(@templates, limit: 12)
+ @pagy, @templates = pagy_auto(@templates, limit: 12)
end
end
diff --git a/app/controllers/templates_archived_submissions_controller.rb b/app/controllers/templates_archived_submissions_controller.rb
index bf023677..9c9da083 100644
--- a/app/controllers/templates_archived_submissions_controller.rb
+++ b/app/controllers/templates_archived_submissions_controller.rb
@@ -15,7 +15,7 @@ class TemplatesArchivedSubmissionsController < ApplicationController
@submissions.order(id: :desc)
end
- @pagy, @submissions = pagy(@submissions.preload(submitters: :start_form_submission_events))
+ @pagy, @submissions = pagy_auto(@submissions.preload(submitters: :start_form_submission_events))
rescue ActiveRecord::RecordNotFound
redirect_to root_path
end
diff --git a/app/controllers/templates_controller.rb b/app/controllers/templates_controller.rb
index 6eb91ed8..b3d0ccec 100644
--- a/app/controllers/templates_controller.rb
+++ b/app/controllers/templates_controller.rb
@@ -21,7 +21,7 @@ class TemplatesController < ApplicationController
submissions.order(id: :desc)
end
- @pagy, @submissions = pagy(submissions.preload(:template_accesses, submitters: :start_form_submission_events))
+ @pagy, @submissions = pagy_auto(submissions.preload(:template_accesses, submitters: :start_form_submission_events))
rescue ActiveRecord::RecordNotFound
redirect_to root_path
end
diff --git a/app/controllers/templates_dashboard_controller.rb b/app/controllers/templates_dashboard_controller.rb
index 319b0297..b4806fbc 100644
--- a/app/controllers/templates_dashboard_controller.rb
+++ b/app/controllers/templates_dashboard_controller.rb
@@ -17,7 +17,7 @@ class TemplatesDashboardController < ApplicationController
@pagy, @template_folders = pagy(
@template_folders,
- items: FOLDERS_PER_PAGE,
+ limit: FOLDERS_PER_PAGE,
page: @template_folders.count > SHOW_TEMPLATES_FOLDERS_THRESHOLD ? params[:page] : 1
)
@@ -35,7 +35,7 @@ class TemplatesDashboardController < ApplicationController
(@template_folders.size < 7 ? 9 : 6)
end
- @pagy, @templates = pagy(@templates, limit:)
+ @pagy, @templates = pagy_auto(@templates, limit:)
end
end
diff --git a/app/views/submissions_archived/index.html.erb b/app/views/submissions_archived/index.html.erb
index 8a5216c1..cad51398 100644
--- a/app/views/submissions_archived/index.html.erb
+++ b/app/views/submissions_archived/index.html.erb
@@ -21,7 +21,7 @@
<%= render 'submissions_filters/filter_button', filter_params: %>
-<% if @pagy.count > 0 %>
+<% if @pagy.count.nil? || @pagy.count > 0 %>
<%= render partial: 'templates/submission', collection: @submissions, locals: { with_template: true, archived: true } %>
diff --git a/app/views/submissions_dashboard/index.html.erb b/app/views/submissions_dashboard/index.html.erb
index e09732ff..2ba16b18 100644
--- a/app/views/submissions_dashboard/index.html.erb
+++ b/app/views/submissions_dashboard/index.html.erb
@@ -1,5 +1,5 @@
<% filter_params = params.permit(Submissions::Filter::ALLOWED_PARAMS).compact_blank %>
-<% is_show_tabs = @pagy.count >= 5 || params[:status].present? || filter_params.present? %>
+<% is_show_tabs = (@pagy.count.nil? || @pagy.count >= 5) || params[:status].present? || filter_params.present? %>
<% if Docuseal.demo? %><%= render 'shared/demo_alert' %><% end %>
<% end %>
-<% if @pagy.count > 0 %>
+<% if @pagy.count.nil? || @pagy.count > 0 %>
<%= render partial: 'templates/submission', collection: @submissions, locals: { with_template: true } %>
<% end %>
-<% if params[:q].blank? && params[:status].blank? && filter_params.blank? && @pagy.count < 5 %>
+<% if params[:q].blank? && params[:status].blank? && filter_params.blank? && @pagy.count.present? && @pagy.count < 5 %>
<%= render 'templates/dropzone' %>
<% end %>
<% if @submissions.present? || (params[:q].blank? && filter_params.blank?) %>
diff --git a/app/views/template_folders/show.html.erb b/app/views/template_folders/show.html.erb
index e99a5888..3d7387a5 100644
--- a/app/views/template_folders/show.html.erb
+++ b/app/views/template_folders/show.html.erb
@@ -39,13 +39,13 @@
<% end %>
- <% if @pagy.count > 0 %>
+ <% if @pagy.count.nil? || @pagy.count > 0 %>
<%= render partial: 'templates/template', collection: @templates %>
<% templates_order_select_html = capture do %>
<% if params[:q].blank? && @pagy.pages > 1 %>
- <%= render('shared/templates_order_select', with_recently_used: @pagy.count < 10_000) %>
+ <%= render('shared/templates_order_select', with_recently_used: @pagy.count.present? && @pagy.count < 10_000) %>
<% end %>
<% end %>
<%= render 'shared/pagination', pagy: @pagy, items_name: 'templates', right_additional_html: templates_order_select_html %>
diff --git a/app/views/templates/show.html.erb b/app/views/templates/show.html.erb
index 083feab6..a7de5760 100644
--- a/app/views/templates/show.html.erb
+++ b/app/views/templates/show.html.erb
@@ -1,7 +1,7 @@
<%= render 'title', template: @template %>
<% filter_params = params.permit(Submissions::Filter::ALLOWED_PARAMS).compact_blank %>
<% is_show_tabs = @pagy.pages > 1 || params[:q].present? || params[:status].present? || filter_params.present? %>
-<% if !@pagy.count.zero? || params[:q].present? || params[:status].present? || filter_params.present? %>
+<% if @pagy.count.nil? || !@pagy.count.zero? || params[:q].present? || params[:status].present? || filter_params.present? %>
@@ -35,27 +35,33 @@
<%= svg_icon('list', class: 'w-5 h-5') %>
<%= t('all') %>
-
- <%= params[:status].blank? && filter_params.blank? ? @pagy.count : @base_submissions.unscope(:group, :order).select(:id).distinct.count %>
-
+ <% unless can?(:manage, :countless) %>
+
+ <%= params[:status].blank? && filter_params.blank? ? @pagy.count : @base_submissions.unscope(:group, :order).select(:id).distinct.count %>
+
+ <% end %>
<%= svg_icon('clock', class: 'w-5 h-5') %>
<%= t('pending') %>
-
- <%= params[:status] == 'pending' && filter_params.blank? ? @pagy.count : @base_submissions.pending.unscope(:group, :order).select(:id).distinct.count %>
-
+ <% unless can?(:manage, :countless) %>
+
+ <%= params[:status] == 'pending' && filter_params.blank? ? @pagy.count : @base_submissions.pending.unscope(:group, :order).select(:id).distinct.count %>
+
+ <% end %>
<%= svg_icon('circle_check', class: 'w-5 h-5') %>
<%= t('completed') %>
-
- <%= params[:status] == 'completed' && filter_params.blank? ? @pagy.count : @base_submissions.completed.unscope(:group, :order).select(:id).distinct.count %>
-
+ <% unless can?(:manage, :countless) %>
+
+ <%= params[:status] == 'completed' && filter_params.blank? ? @pagy.count : @base_submissions.completed.unscope(:group, :order).select(:id).distinct.count %>
+
+ <% end %>
diff --git a/app/views/templates_archived/index.html.erb b/app/views/templates_archived/index.html.erb
index c90ef0fb..f126f10b 100644
--- a/app/views/templates_archived/index.html.erb
+++ b/app/views/templates_archived/index.html.erb
@@ -12,7 +12,7 @@
<%= render 'shared/search_input', placeholder: "#{t('search')}..." %>
<% end %>
-<% if @pagy.count > 0 %>
+<% if @pagy.count.nil? || @pagy.count > 0 %>
<%= render partial: 'templates/template', collection: @templates %>
diff --git a/app/views/templates_archived_submissions/index.html.erb b/app/views/templates_archived_submissions/index.html.erb
index eac39e1e..0536d8a9 100644
--- a/app/views/templates_archived_submissions/index.html.erb
+++ b/app/views/templates_archived_submissions/index.html.erb
@@ -29,7 +29,7 @@
<% end %>
-<% if @pagy.count > 0 %>
+<% if @pagy.count.nil? || @pagy.count > 0 %>
<%= render partial: 'templates/submission', collection: @submissions, locals: { template: @template, archived: true } %>
diff --git a/app/views/templates_dashboard/index.html.erb b/app/views/templates_dashboard/index.html.erb
index bcd85b01..99f4d80e 100644
--- a/app/views/templates_dashboard/index.html.erb
+++ b/app/views/templates_dashboard/index.html.erb
@@ -12,7 +12,7 @@
<%= render 'templates/dashboard_dropzone', style: 'height: 114px' %>
<% end %>
- <% if has_archived || @pagy.count > 0 || @template_folders.present? %>
+ <% if has_archived || @pagy.count.nil? || @pagy.count > 0 || @template_folders.present? %>
<%= render 'dashboard/toggle_view', selected: 'templates' %>
@@ -45,7 +45,7 @@
<% end %>
<% templates_order_select_html = capture do %>
<% if params[:q].blank? && @pagy.pages > 1 %>
- <%= render('shared/templates_order_select', with_recently_used: @pagy.count < 10_000) %>
+ <%= render('shared/templates_order_select', with_recently_used: @pagy.count.present? && @pagy.count < 10_000) %>
<% end %>
<% end %>
<% if @template_folders.present? %>
@@ -84,9 +84,9 @@
<% if show_dropzone %>
<%= render 'templates/dropzone' %>
<% end %>
-<% if @templates.present? || params[:q].blank? %>
+<% if @templates.present? || @template_folders.present? || params[:q].blank? %>
<% if @pagy.pages > 1 %>
- <%= render 'shared/pagination', pagy: @pagy, items_name: 'templates', left_additional_html: view_archived_html, right_additional_html: templates_order_select_html %>
+ <%= render 'shared/pagination', pagy: @pagy, items_name: @templates.present? ? 'templates' : 'template_folders', left_additional_html: view_archived_html, right_additional_html: templates_order_select_html %>
<% else %>
<%= view_archived_html %>
diff --git a/config/initializers/pagy.rb b/config/initializers/pagy.rb
index dc79235a..45c364e8 100644
--- a/config/initializers/pagy.rb
+++ b/config/initializers/pagy.rb
@@ -1,5 +1,7 @@
# frozen_string_literal: true
+require 'pagy/extras/countless'
+
Pagy::DEFAULT[:limit] = 10
Pagy::DEFAULT.freeze
diff --git a/config/locales/i18n.yml b/config/locales/i18n.yml
index bd5ef1be..1d4ae3d8 100644
--- a/config/locales/i18n.yml
+++ b/config/locales/i18n.yml
@@ -836,6 +836,9 @@ en: &en
templates:
range_with_total: "%{from}-%{to} of %{count} templates"
range_without_total: "%{from}-%{to} templates"
+ template_folders:
+ range_with_total: "%{from}-%{to} of %{count} folders"
+ range_without_total: "%{from}-%{to} folders"
users:
range_with_total: "%{from}-%{to} of %{count} users"
range_without_total: "%{from}-%{to} users"
@@ -1661,6 +1664,9 @@ es: &es
templates:
range_with_total: "%{from}-%{to} de %{count} plantillas"
range_without_total: "%{from}-%{to} plantillas"
+ template_folders:
+ range_with_total: "%{from}-%{to} de %{count} carpetas"
+ range_without_total: "%{from}-%{to} carpetas"
users:
range_with_total: "%{from}-%{to} de %{count} usuarios"
range_without_total: "%{from}-%{to} usuarios"
@@ -2484,6 +2490,9 @@ it: &it
templates:
range_with_total: "%{from}-%{to} di %{count} modelli"
range_without_total: "%{from}-%{to} modelli"
+ template_folders:
+ range_with_total: "%{from}-%{to} di %{count} cartelle"
+ range_without_total: "%{from}-%{to} cartelle"
users:
range_with_total: "%{from}-%{to} di %{count} utenti"
range_without_total: "%{from}-%{to} utenti"
@@ -3310,6 +3319,9 @@ fr: &fr
templates:
range_with_total: "%{from} à %{to} sur %{count} modèles"
range_without_total: "%{from} à %{to} modèles"
+ template_folders:
+ range_with_total: "%{from} à %{to} sur %{count} dossiers"
+ range_without_total: "%{from} à %{to} dossiers"
users:
range_with_total: "%{from} à %{to} sur %{count} utilisateurs"
range_without_total: "%{from} à %{to} utilisateurs"
@@ -4136,6 +4148,9 @@ pt: &pt
templates:
range_with_total: "%{from}-%{to} de %{count} modelos"
range_without_total: "%{from}-%{to} modelos"
+ template_folders:
+ range_with_total: "%{from}-%{to} de %{count} pastas"
+ range_without_total: "%{from}-%{to} pastas"
users:
range_with_total: "%{from}-%{to} de %{count} usuários"
range_without_total: "%{from}-%{to} usuários"
@@ -4961,6 +4976,9 @@ de: &de
templates:
range_with_total: "%{from}-%{to} von %{count} Vorlagen"
range_without_total: "%{from}-%{to} Vorlagen"
+ template_folders:
+ range_with_total: "%{from}-%{to} von %{count} Ordnern"
+ range_without_total: "%{from}-%{to} Ordner"
users:
range_with_total: "%{from}-%{to} von %{count} Benutzern"
range_without_total: "%{from}-%{to} Benutzer"