Closed florianm closed 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:
$.sanitizeString($('.header h1').text())
be refactored into its own function and covered by by unit tests?'id': odkmaker.data.getTitle().replace(/[^A-Za-z0-9]/g, ''),
does not generate a trailing "-" if the form title ends in special characters.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.
Cheers, yep happy to do so. Just pushed and passed checks.
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.
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 newversion
.ODK Build exports each XML with a form id
build_FORM_TITLE_HASH
and no version, e.g.: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?