getodk / central

ODK Central is a server that is easy to use, very fast, and stuffed with features that make data collection easier. Contribute and make the world a better place! ✨🗄✨
https://docs.getodk.org/central-intro/
Apache License 2.0
121 stars 145 forks source link

Uploading a spreadsheet with entities with an added property without refreshing page with Import Data from File modal #633

Open dbemke opened 2 months ago

dbemke commented 2 months ago

Problem description

If I try to upload a spreadsheet adding entities with a new property which was added at the time when the Import Data from File modal was opened I can see information that I’m trying to upload a file with a property that doesn’t exist. If I reopen the modal the data stay the same. Refreshing the entities page "adds” the new property. In the screenshot below: the property "age" was added to the dataset and is present in properties of the dataset.

addedProp

URL of the page

https://test.getodk.cloud/

Steps to reproduce the problem

  1. Open 2 tabs with the same project containing a form with entities.
  2. In the first tab go to Entities page to Data tab.
  3. Click "Upload” and "Download a data template”.
  4. In the second tab upload new version of the form with entities (dataset from step 2) with a new property added.
  5. Publish the form so that the new property is added to the dataset.
  6. Open the file with the downloaded template and add a column with a new property and save the file.
  7. Go to the first tab and click "choose one” and upload the file made from the template.

Expected behavior

I'm not sure what should be the expected behavior - updating the list of properties when a file with entities is uploaded/information to refresh the page.

Central version shown in version.txt

https://test.getodk.cloud/ versions: 645a8061b8df3644584cefc036d751c6115fcbec (v2023.5.1-3-g645a806) +5c93766eb558c113a6389f7d035d3bde3fe2261f client (v2023.5.0-47-g5c93766e) +85a0e3cbcec39c000d29002a9e9bce3150115ac2 server (v2023.5.0-35-g85a0e3cb)

dbemke commented 2 months ago

Another similar example: when I delete an entity in a different tab while the Import Data from file modal is opened or I don't refresh the entities page, the Import Data from file modal won't show the change in entities after reopening. The user needs to refresh the entities page. In this case the user isn't blocked by anything just doesn't see the latest changes

matthew-white commented 2 months ago

Sorry I missed this one, @dbemke!

If I try to upload a spreadsheet adding entities with a new property which was added at the time when the Import Data from File modal was opened I can see information that I’m trying to upload a file with a property that doesn’t exist.

I'm not sure what should be the expected behavior

What you're describing is the expected behavior currently, though I'm also not sure that it's the ideal behavior. This happens because the UI is the one that checks the CSV header, not the backend. The UI compares the CSV header to the properties it knows about, but you're right that if a different tab/browser/device adds a new property, the first tab won't know about it. That will cause the tab not to show the new property in the tables and to reject a CSV file with the new property (and conversely, to accept a CSV file without it).

Adding a new property won't be common, and nothing very bad should happen if a tab doesn't know about the latest properties, so my instinct is that the current behavior is OK. That said, I wanted to connect this issue to two others: one about refreshing stale data that was retrieved a while ago (getodk/central-frontend#204) and one about sharing changes across tabs (getodk/central#646).

when I delete an entity in a different tab while the Import Data from file modal is opened or I don't refresh the entities page, the Import Data from file modal won't show the change in entities after reopening.

This one is more surprising to me, actually. If you open the modal, then delete an entity in another tab, then close the modal and reopen it, you should see that:

Is that what you're seeing?

One way to think about it is that the table in the modal is different from the table on the page. Even if the table on the page hasn't been refreshed, the table in the modal should still be up-to-date as of when the modal was opened.

dbemke commented 2 months ago

The total number of rows has updated The deleted entity is not shown

Is that what you're seeing?

Hmm.. Yes now it seems to work as expected so either I made a mistake or there was some extra factor. I'll try to test it a bit more after the regression testing.