Fixes #5696: Overviews - On deletion of the 51th element it will show no entries

Co-authored-by: Benjamin Scharf <bs@zammad.com>
Co-authored-by: Rolf Schmidt <rs@zammad.com>
This commit is contained in:
Benjamin Scharf
2025-07-08 16:16:25 +02:00
parent 889b065825
commit 003bb1e927
2 changed files with 33 additions and 0 deletions

View File

@@ -120,6 +120,11 @@ class App.ControllerGenericIndex extends App.Controller
App[@genericObject][method](
(collection, data) =>
maxPage = Math.max(1, Math.ceil(data.total_count / @pageData.pagerPerPage))
if @pageData.pagerSelected && @pageData.pagerSelected > maxPage
@pageData.pagerSelected = maxPage
return @navigate "#{@pageData.pagerBaseUrl}#{@pageData.pagerSelected}/#{encodeURIComponent(@searchQuery)}"
@pageData.pagerTotalCount = data.total_count
if data.total_count > @pageData.pagerPerPage || @searchQuery
@dndCallback = undefined

View File

@@ -413,4 +413,32 @@ RSpec.describe 'Manage > Overviews', type: :system do
include_examples 'showing the error message if roles are empty'
end
end
describe 'Overviews: On deletion of the 51th element it will show no entries #5696', authenticated_as: :authenticate, searchindex: true do
def authenticate
Overview.destroy_all
create_list(:overview, 51)
searchindex_model_reload([Overview])
true
end
it 'redirects to the previous page' do
visit '/#manage/overviews'
first('.table-overview a', text: '2').click
expect(page).to have_current_path(%r{/#manage/overviews/2/}, url: true)
expect(page).to have_css('.table-overview tbody tr.item', count: 1)
# Delete the single item on the second page
find('.table-overview tbody .js-action').click
find('[data-table-action="delete"]').click
find('.modal-dialog .js-submit').click
expect(page).to have_current_path(%r{/#manage/overviews/1/}, url: true)
expect(page).to have_css('.table-overview tbody tr.item', count: 50)
end
end
end