stable

Clone or download

Read-only

fix: request #38295 Ensure that at least some backlog items are loaded when displaying the page

This is a stop-gap solution so we can be sure to have some content to display. Currently if the first page retrieved from the REST API is empty it is really hard to trigger the loading of the other items. Ideally we would rework the way the items are loaded in the PV2 app but this approach should be good enough for now as we are dealing with an edge case (and the current code as been good enough for a few years now). You might notice that attempting to load the initial items is done in a recursive way: * that should not be an issue, if we need to fetch a lot of pages it is very likely that something is wrong with the backend code * Angular promises are weird to deal with and this is the easiest way to do it * at least we will a crash relatively early if the backend code is wrong instead of getting into an infinite loop The easiest way to test this is to have a backlog with only a few "To be planned" items and to edit the REST endpoint code to simulate a first empty page, this can be done with ``` --- a/plugins/agiledashboard/include/AgileDashboard/REST/v1/ProjectBacklogResource.class.php +++ b/plugins/agiledashboard/include/AgileDashboard/REST/v1/ProjectBacklogResource.class.php @@ -166,12 +166,14 @@ class ProjectBacklogResource { $this->sendAllowHeaders(); + $offset -= $limit; + try { $top_milestone = $this->milestone_factory->getVirtualTopMilestone($user, $project); $paginated_backlog_items_representations = $this->paginated_backlog_item_representation_builder->getPaginatedBacklogItemsRepresentationsForTopMilestone($user, $top_milestone, $limit, $offset); - $this->sendPaginationHeaders($limit, $offset, $paginated_backlog_items_representations->getTotalSize()); + $this->sendPaginationHeaders($limit, $offset, $paginated_backlog_items_representations->getTotalSize()+$limit); return $paginated_backlog_items_representations->getBacklogItemsRepresentations(); } catch (\Planning_NoPlanningsException $e) { ``` Change-Id: Icdc954b03d4d292b2de57c5f95b9f3835bf6ceb4

Modified Files

Name
M plugins/agiledashboard/scripts/planning-v2/src/app/backlog/backlog-controller.js +11 −1 Go to diff View file
M plugins/agiledashboard/scripts/planning-v2/src/app/backlog/backlog-controller.test.js +3 −0 Go to diff View file