getodk / central-frontend

Vue.js based frontend for ODK Central

Home Page:https://docs.getodk.org/central-intro/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Dataset properties that are not valid OData identifiers are always empty in entities table

matthew-white opened this issue · comments

If the name of a dataset property is not a valid OData identifier, then a different name will be used for the property in the OData feed (via sanitizeOdataIdentifier() in Backend). In Frontend, the entities table uses the OData feed, but right now, if the name of a property differs from its OData identifier, the property's value is never shown. For example, I created a dataset with a property named circumference.cm, and the property is empty in the table: https://staging.getodk.cloud/#/projects/23/datasets/trees/entities. Yet if you access this entity using the REST API, you can see that its circumference.cm property is not empty: https://staging.getodk.cloud/v1/projects/23/datasets/trees/entities/c3e0d5f0-2af5-44bb-ad3f-26fb9f93288b. I think the issue is that we try to access property data using the name of the property, not its OData identifier:

<td v-for="property of properties" :key="property.id">
<span v-tooltip.text>{{ entity[property.name] }}</span>

This isn't an issue in the submissions table because Frontend specifies a query parameter of odata=true when it sends a request to the form fields endpoint. As a result, the endpoint returns OData identifiers for Frontend to use. I think we could have Backend do something similar for dataset properties, or we could import sanitizeOdataIdentifier() to Frontend and use it here.


Notes for the QA team

A name is a valid OData identifier if it:

  • Contains only alphanumeric characters and underscores.
  • Does not start with a number.

A dataset property name is not required to be a valid OData identifier. A property name:

  • Can contain letters, numbers, underscores, hyphens, and periods.
  • Cannot start with a number, hyphen, or period or with two underscores (__).

If the name of a property is not a valid OData identifier, the property's name will be changed in the OData feed. The entities table in the Central UI uses the OData feed under the hood, which is why there was this issue.

@sadiqkhoja, I think we still need to use the new odataName property in Frontend. Would you mind creating a PR for that? I'll work on adding that.

Tested with success!