From 85191aa4cecfae933680d65af8831c727cda316c Mon Sep 17 00:00:00 2001 From: Nicolas Pennec Date: Wed, 4 Sep 2024 13:30:37 +0200 Subject: [PATCH] [list] fix UI refresh when an entity list is paginated --- src/store/modules/assets.js | 6 +++++- src/store/modules/edits.js | 6 +++++- src/store/modules/shots.js | 6 +++++- tests/unit/store/assets.spec.js | 6 ++++-- 4 files changed, 19 insertions(+), 5 deletions(-) diff --git a/src/store/modules/assets.js b/src/store/modules/assets.js index 21e975de41..5bb8552622 100644 --- a/src/store/modules/assets.js +++ b/src/store/modules/assets.js @@ -240,7 +240,11 @@ const helpers = { result = sortAssetResult(result, sorting, taskTypeMap, taskMap) cache.result = result - const displayedAssets = result.slice(0, PAGE_SIZE) + const limit = + state.displayedAssets.length > PAGE_SIZE + ? state.displayedAssets.length + : PAGE_SIZE + const displayedAssets = result.slice(0, limit) const maxX = displayedAssets.length const maxY = state.nbValidationColumns diff --git a/src/store/modules/edits.js b/src/store/modules/edits.js index a7a7359335..02ed08e865 100644 --- a/src/store/modules/edits.js +++ b/src/store/modules/edits.js @@ -214,7 +214,11 @@ const helpers = { result = sortEditResult(result, sorting, taskTypeMap, taskMap) cache.result = result - const displayedEdits = result.slice(0, PAGE_SIZE) + const limit = + state.displayedEdits.length > PAGE_SIZE + ? state.displayedEdits.length + : PAGE_SIZE + const displayedEdits = result.slice(0, limit) const maxX = displayedEdits.length const maxY = state.nbValidationColumns diff --git a/src/store/modules/shots.js b/src/store/modules/shots.js index 7fdd9c5b88..436b6b45cb 100644 --- a/src/store/modules/shots.js +++ b/src/store/modules/shots.js @@ -230,7 +230,11 @@ const helpers = { result = sortShotResult(result, sorting, taskTypeMap, taskMap) cache.result = result - const displayedShots = result.slice(0, PAGE_SIZE) + const limit = + state.displayedShots.length > PAGE_SIZE + ? state.displayedShots.length + : PAGE_SIZE + const displayedShots = result.slice(0, limit) const maxX = displayedShots.length const maxY = state.nbValidationColumns diff --git a/tests/unit/store/assets.spec.js b/tests/unit/store/assets.spec.js index f8e69fb026..348a2dadd8 100644 --- a/tests/unit/store/assets.spec.js +++ b/tests/unit/store/assets.spec.js @@ -1498,7 +1498,8 @@ describe('Assets store', () => { test('SET_ASSET_SEARCH', () => { const state = { - assetSorting: { 123: 123 } + assetSorting: { 123: 123 }, + displayedAssets: [] } const payload = { sorting: 123, @@ -1864,7 +1865,8 @@ describe('Assets store', () => { test('CHANGE_ASSET_SORT', () => { const state = { assetSorting: { 123: 123 }, - assetSearchText: 'search' + assetSearchText: 'search', + displayedAssets: [] } const payload = { sorting: { 123: 124 },