Closed svenvandescheur closed 1 month ago
Replacing order_by("in_exception_list")
, with .order_by("in_exception_list", "pk")
seems to to the trick when no custom ordering is active, however with custom ordering the order_by is overridden and the match between zaken and destructionlist items can't be made on the same position on a page.
Destruction list edit page doesn't show the correct active selection, possibly due to mismatch between
/api/v1/destruction-list-items/
and/api/v1/zaken/
endpoint.Reproducible test case:
https://openarchiefbeheer.test.maykin.opengem.nl/
: create a new destruction list, add all the items from the first page, and the first item of the second page.Technical notes:
The view is constructed sing primarily two data sources:
/api/v1/destruction-list-items/
providing the items currently on the list./api/v1/zaken/
providing all selectable zaken.In edit mode the second endpoint is used to populate the datagrid, however the first endpoint is used to check whether zaken should be selected, every
Zaak
on the current page is matched to a in memory page containing all the selectedDestructionListItem
's zaken. If both the zaken are truthy (set) and theuuid
orurl
matches, the zaak is selected.For example:
The database has 5 items:
Zaak-1
Zaak-2
Zaak-3
Zaak-4
Zaak-5
A destruction list has 3 selected items:
Zaak-1
Zaak-2
Zaak-3
Given that the page size is
2
(instead of 100 on the actual application):Zaak-1
andZaak-2
, the first page of the de destruction list items should have both items on te same position, therefore theuuid
s and orurl
s match and the items should be selected. The second (zaak) page should showZaak-3
andZaak-4
, the first position of the destruction list items should match so it's selected, the second item (Zaak-4
) should remains unselected.Hypothesis
The above implementation assumes that both the endpoints are in sync and have the same
Zaak
en on identical positions on the same page. If any of the filtering/ordering is off, the selection may be incomplete.