getodk / build

ODK Build is a drag-and-drop form designer for ODK XForms. Thousands of users around the world depend on it for their data collection campaigns. Contribute and make the world a better place! ✨📝✨
https://build.getodk.org/
Other
110 stars 82 forks source link

Exported XML should keep form id static and increase version #236

Closed florianm closed 3 years ago

florianm commented 3 years ago

As a form maintainer, I author forms in ODK Build and publish updated form versions to ODK Central. As an ODK advocate within my organisation, I train and support colleagues (not all are technically minded) along this low-code path from form design to form deployment. Having a GUI form builder is a big UX win over XLSForms.

Creating an updated draft version for an existing form in ODK Central requires the updated form definition to have the same id but also allows to set a new version.

ODK Build exports each XML with a form id build_FORM_TITLE_HASH and no version, e.g.:

<data id="build_Turtle-Tagging_1606567443">

This requires manual editing of each exported XML before it can be used as a new draft version for an existing form. This step is error-prone and an avoidable complication for form maintainers.

Would it be feasible to change ODK Build's export to XML to export the sanitized FORM_TITLE as form id, and export the current form id as version instead?

<data id="Turtle-Tagging" version="build_Turtle-Tagging_1606567443">
florianm commented 3 years ago

Thinking out loud:

            attrs: {
              'id': 'build_' + $.sanitizeString($('.header h1').text()) +
                    '_' + Math.round((new Date()).getTime() / 1000)
            },

could be

            attrs: {
              'id': $.sanitizeString($('.header h1').text()),
              'version': 'build_' + $.sanitizeString($('.header h1').text()) +
                    '_' + Math.round((new Date()).getTime() / 1000)
            },

Talking points:

lognaturel commented 3 years ago

Thanks, @florianm! Version should be compatible with Aggregate. That means it needs to be an incrementing integer with a max of 10 digits. I think Math.round((new Date()).getTime() / 1000) on its own would probably work.

florianm commented 3 years ago

Cheers, yep happy to do so. Just pushed and passed checks.

florianm commented 3 years ago

While I haven't gotten the test suite to run yet, I ran Build locally, exported a form to XML and saw that the XML contains the data id and version as intended. I haven't checked for possible adverse side effects of this change.