-
Bug
-
Resolution: Fixed
-
High
-
None
-
None
Although the 'delete' button is not clickable for a deleted entity, manually entering a `…/delete` route works.
After re-deleting the entity, the name is no longer showing (the mechanism is to fetch the last know alias from the previous revision; in this case it'll be empty).
Instead, there should be a check when hitting the /delete endpoint for the loaded entity's `dataId: if it's null (and hence a 'deleted' entity), throw an error (400 Bad Request? 409 Conflict ? )
In more detail:
Each entity type (author, work, edition, edition group, publisher, series) defines a "/delete" endpoint which we need to modify. Here's where you find them.
The following modifications will need to be done for the /delete route of each entity, so modifying 6 files in total.
We will need to check if the entity has already been deleted. We do that by checking if has a `dataId` attribute.
When the delete route is called, the entity has already been automatically loaded into res.locals in a previous step, so we'll do:
if(!res.locals.entity.dataId) {...
If that condition is true, we want to return an error page to the user.
We do this by calling the "next" function with our ConflictError object (this already exists but will need to be imported) like it is done here for example and with a nice user-friendly message along the lines of "This entity has already been deleted".