Show PDFs from newest to oldest in PDF import modal
Until this is merged, the import modal for PDF documents in the Quiz Editor shows documents from oldest to newest. When having a lot of PDF documents, this means there is a need to scroll down to the newest document to find it. This was found confusing by Marieke, so an effort was made to change this behaviour.
In correspondence with #47 (closed), the PDF import modal now shows the PDF files from newest to oldest. More specifically, it sorts the PDFs descending on ID. This has been implemented in two-fold:
- The back-end now has a method
getAllPdfs()
as part of thePdfDetailsDao
which selects all PDFs sorted by ID (descending). ThePdfResource
does now returngetAllPdfs()
instead of the default DAO functionfindAll()
. This means that the back-end returns now a sorted list for aGET
on the/pdfs
endpoint. - The front-end upload function for new PDF puts newly uploaded PDF files in the front of the list instead of appending them to the end of the list, to keep the list sorted according to the new requirements when new PDFs are uploaded.
It should be noted that we could also have created a new endpoint for returning sorted PDFs, but since the GET
on the PDF endpoint never did any promises on the sorting, none of our implementation would break because of the changed order. The endpoint still returns all PDFs, as before.