add pagination to templates/users/submissions
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
|
||||
class ApplicationController < ActionController::Base
|
||||
include ActiveStorage::SetCurrent
|
||||
include Pagy::Backend
|
||||
|
||||
before_action :maybe_redirect_to_setup, unless: :signed_in?
|
||||
before_action :authenticate_user!, unless: :devise_controller?
|
||||
|
||||
@@ -6,6 +6,6 @@ class DashboardController < ApplicationController
|
||||
def index
|
||||
return render 'pages/landing' unless signed_in?
|
||||
|
||||
@templates = current_account.templates.active
|
||||
@pagy, @templates = pagy(current_account.templates.active, items: 12)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -4,7 +4,7 @@ class SubmissionsController < ApplicationController
|
||||
before_action :load_template, only: %i[index new create]
|
||||
|
||||
def index
|
||||
@submissions = @template.submissions.active
|
||||
@pagy, @submissions = pagy(@template.submissions.active)
|
||||
end
|
||||
|
||||
def show
|
||||
|
||||
@@ -4,7 +4,7 @@ class UsersController < ApplicationController
|
||||
before_action :load_user, only: %i[edit update destroy]
|
||||
|
||||
def index
|
||||
@users = current_account.users.active.order(id: :desc)
|
||||
@pagy, @users = pagy(current_account.users.active.order(id: :desc))
|
||||
end
|
||||
|
||||
def new
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
<%= render 'shared/pagination', pagy: @pagy %>
|
||||
<% else %>
|
||||
<div class="card bg-base-200 h-96 mb-2">
|
||||
<div class="card-body text-center">
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
<% 'input-error' %>
|
||||
<span class="label-text-alt text-red-400">
|
||||
<span class="label-text-alt text-red-400 mt-1">
|
||||
<%= message %>
|
||||
</span>
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
<% link = pagy_link_proc(@pagy) %>
|
||||
<% if @pagy.pages > 1 %>
|
||||
<div class="flex my-6 items-center justify-center md:justify-end">
|
||||
<div class="join">
|
||||
<% if @pagy.prev %>
|
||||
<%== link.call(@pagy.prev, "«", 'class="join-item btn btn-sm"') %>
|
||||
<% else %>
|
||||
<span class="join-item btn btn-sm btn-disabled !bg-base-200">«</span>
|
||||
<% end %>
|
||||
<span class="join-item btn btn-sm uppercase">
|
||||
Page <%= @pagy.page %>
|
||||
</span>
|
||||
<% if @pagy.next %>
|
||||
<%== link.call(@pagy.next, "»", 'class="join-item btn btn-sm"') %>
|
||||
<% else %>
|
||||
<span class="join-item btn btn-sm btn-disabled !bg-base-200">»</span>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
<% end %>
|
||||
@@ -62,39 +62,41 @@
|
||||
<td>
|
||||
<% submission.submitters.each do |submitter| %>
|
||||
<%= submitter.email %>
|
||||
</br>
|
||||
<% end %>
|
||||
</td>
|
||||
<td>
|
||||
<% submission.submitters.each do |submitter| %>
|
||||
<div>
|
||||
<span class="badge badge-info badge-outline">
|
||||
<%= submitter.status %>
|
||||
</span>
|
||||
</div>
|
||||
<% end %>
|
||||
</td>
|
||||
<td>
|
||||
<% submission.submitters.each do |submitter| %>
|
||||
<% share_link_input_id = "share-link-input_#{submitter.id}" %>
|
||||
<div class="join ">
|
||||
<input id="<%= share_link_input_id %>" autocomplete="off" type="text" class="input input-xs input-bordered join-item" value="<%= submit_form_url(slug: submitter.slug) %>" disabled>
|
||||
<clipboard-copy class="btn btn-xs btn-neutral btn-square join-item text-white font-bold swap swap-active" for="<%= share_link_input_id %>">
|
||||
<%= svg_icon('clipboard', class: 'w-3 h-3 swap-on text-white') %>
|
||||
<%= svg_icon('clipboard_copy', class: 'w-3 h-3 swap-off text-white') %>
|
||||
</clipboard-copy>
|
||||
</div>
|
||||
<br/>
|
||||
<% end %>
|
||||
</td>
|
||||
<td class="flex items-center space-x-2 justify-end">
|
||||
<%= link_to 'View', submission_path(submission), title: 'View', class: 'btn btn-outline btn-xs' %>
|
||||
<%= button_to 'Remove', submission_path(submission), class: 'btn btn-outline btn-error btn-xs', title: 'Delete', method: :delete, data: { turbo_confirm: 'Are you sure?' } %>
|
||||
</td>
|
||||
</tr>
|
||||
<% end %>
|
||||
</tbody>
|
||||
</table>
|
||||
<br>
|
||||
<% end %>
|
||||
</td>
|
||||
<td>
|
||||
<% submission.submitters.each do |submitter| %>
|
||||
<div>
|
||||
<span class="badge badge-info badge-outline">
|
||||
<%= submitter.status %>
|
||||
</span>
|
||||
</div>
|
||||
<% end %>
|
||||
</td>
|
||||
<td>
|
||||
<% submission.submitters.each do |submitter| %>
|
||||
<% share_link_input_id = "share-link-input_#{submitter.id}" %>
|
||||
<div class="join ">
|
||||
<input id="<%= share_link_input_id %>" autocomplete="off" type="text" class="input input-xs input-bordered join-item" value="<%= submit_form_url(slug: submitter.slug) %>" disabled>
|
||||
<clipboard-copy class="btn btn-xs btn-neutral btn-square join-item text-white font-bold swap swap-active" for="<%= share_link_input_id %>">
|
||||
<%= svg_icon('clipboard', class: 'w-3 h-3 swap-on text-white') %>
|
||||
<%= svg_icon('clipboard_copy', class: 'w-3 h-3 swap-off text-white') %>
|
||||
</clipboard-copy>
|
||||
</div>
|
||||
<br>
|
||||
<% end %>
|
||||
</td>
|
||||
<td class="flex items-center space-x-2 justify-end">
|
||||
<%= link_to 'View', submission_path(submission), title: 'View', class: 'btn btn-outline btn-xs' %>
|
||||
<%= button_to 'Remove', submission_path(submission), class: 'btn btn-outline btn-error btn-xs', title: 'Delete', method: :delete, data: { turbo_confirm: 'Are you sure?' } %>
|
||||
</td>
|
||||
</tr>
|
||||
<% end %>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<%= render 'shared/pagination', pagy: @pagy %>
|
||||
<% else %>
|
||||
<%= render 'shared/no_data_banner' %>
|
||||
<% end %>
|
||||
|
||||
@@ -58,5 +58,6 @@
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<%= render 'shared/pagination', pagy: @pagy %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
Pagy::DEFAULT[:items] = 10
|
||||
Pagy::DEFAULT.freeze
|
||||
|
||||
ActiveSupport.on_load(:action_view) do
|
||||
include Pagy::Frontend
|
||||
end
|
||||
Reference in New Issue
Block a user