diff --git a/app/components/tabbed_pagination_component.rb b/app/components/tabbed_pagination_component.rb new file mode 100644 index 00000000..0ac54d4a --- /dev/null +++ b/app/components/tabbed_pagination_component.rb @@ -0,0 +1,38 @@ +# frozen_string_literal: true + +class TabbedPaginationComponent < GovukComponent::PaginationComponent + def initialize(fragment: nil, **kwargs) + self.fragment = fragment + super(**kwargs) + end + + private + + attr_accessor :fragment + + def build_items + pagy.series.map { |i| with_item(number: i, href: pagy_url_for(pagy, i, fragment:), from_pagy: true) } + end + + def build_next + return unless pagy&.next + + kwargs = { + href: pagy_url_for(pagy, pagy.next, fragment:), + text: @next_text, + } + + with_next_page(**kwargs.compact) + end + + def build_previous + return unless pagy&.prev + + kwargs = { + href: pagy_url_for(pagy, pagy.prev, fragment:), + text: @previous_text, + } + + with_previous_page(**kwargs.compact) + end +end diff --git a/app/controllers/check_records/bulk_searches_controller.rb b/app/controllers/check_records/bulk_searches_controller.rb index 01c776cf..0398352e 100644 --- a/app/controllers/check_records/bulk_searches_controller.rb +++ b/app/controllers/check_records/bulk_searches_controller.rb @@ -44,7 +44,11 @@ def show QualificationsApi::Teacher.new(teacher['api_data']) end @not_found = data['not_found'].map {|record| Hashie::Mash.new(record) } - @pagy, @results = pagy_array(@results) + @pagy, @results = pagy_array(@results, limit: 10) + @pagy_not_found, @not_found = + pagy_array(@not_found, limit: 10, page_param: :page_not_found, anchor_string: '#records-not-found') + + @bulk_search_response.update!(expires_at: 30.minutes.from_now) end private diff --git a/app/views/check_records/bulk_searches/new.html.erb b/app/views/check_records/bulk_searches/new.html.erb index 5d35a94e..e94dfd9a 100644 --- a/app/views/check_records/bulk_searches/new.html.erb +++ b/app/views/check_records/bulk_searches/new.html.erb @@ -25,7 +25,7 @@ must be in DD/MM/YYYY format.
- You can add a maximum of 20 people. + You can add a maximum of 100 people.
+ We found <%= pluralize(@total, 'teacher record') %> out of the <%= pluralize(@results.count + @not_found.count, 'entry') %> you uploaded. +
<%= govuk_tabs do |tabs| if @results.any? tabs.with_tab(label: "Records found", id: "records-found") do %> diff --git a/app/views/check_records/search/_not_found.html.erb b/app/views/check_records/search/_not_found.html.erb index 07abfebd..cf496553 100644 --- a/app/views/check_records/search/_not_found.html.erb +++ b/app/views/check_records/search/_not_found.html.erb @@ -1,6 +1,7 @@