getodk / central-frontend

Vue.js based frontend for ODK Central
https://docs.getodk.org/central-intro/
Apache License 2.0
32 stars 57 forks source link

Show "Link Entity List" button after publishing new entity list #921

Closed matthew-white closed 8 months ago

matthew-white commented 9 months ago

Closes #916. I think the issue is that the datasets resource needs to be cleared/reset after the form draft is published. That's because publishing a draft can have the effect of publishing a new entity list. In FormDraftStatus, the afterPublish() method re-requests, resets, or updates many resources, but it doesn't do so for datasets. That means that if FormAttachmentList requested datasets before the draft was published, it won't do so again after the draft is published (unless the page is refreshed or the user navigates away from the form).

What has been done to verify that this works as intended?

I wrote two new tests about this scenario (under "linking after publishing new dataset"). The first test involves publishing the project's first entity list, and it passed without any changes. The second test involves publishing a second entity list for the project, and it only passed after I updated afterPublish().

Why is this the best possible solution? Were any other approaches considered?

While looking at this issue, it didn't always feel clear when or where resources were re-requested, reset, or updated. There's probably room for improvement there (though I don't have any specific ideas at the moment). However, given that afterPublish() is already modifying a lot of resources, I think it makes sense that it should also reset datasets.

Before submitting this PR, please make sure you have: