Skip to content

Commit

Permalink
all/feature getodk#154: add instance name form property; adjust outpu…
Browse files Browse the repository at this point in the history
…t XML.

* also add orx: namespace prefix to meta/instanceID while we’re in this
  code. not sure what the penalty for noncompliance is but we may as
  well comply.
* progress toward getodk#154, but still two more properties to implement.
  • Loading branch information
issa-tseng committed Jul 7, 2017
1 parent 3cc330c commit 29e222e
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 8 deletions.
22 changes: 14 additions & 8 deletions public/javascripts/data.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ var dataNS = odkmaker.namespace.load('odkmaker.data');
version: odkmaker.data.currentVersion,
activeLanguages: odkmaker.i18n.activeLanguageData(),
optionsPresets: odkmaker.options.presets,
htitle: htitle
htitle: htitle,
instanceName: $('#formProperties_instanceName').val()
}
};
};
Expand Down Expand Up @@ -106,6 +107,7 @@ var dataNS = odkmaker.namespace.load('odkmaker.data');

$('h1').text(formObj.title);
$('#formProperties_title').val(formObj.metadata.htitle)
$('#formProperties_instanceName').val(formObj.metadata.instanceName);
odkmaker.i18n.setActiveLanguages(formObj.metadata.activeLanguages);
odkmaker.options.presets = formObj.metadata.optionsPresets;
loadMany($('.workspace'), formObj.controls);
Expand Down Expand Up @@ -568,16 +570,18 @@ var dataNS = odkmaker.namespace.load('odkmaker.data');
// TODO: user-config of instanceHead

// Per OpenRosa spec, instanceID should be in /data/meta
var meta = {
name: 'orx:meta',
children: [ { name: 'orx:instanceID' } ]
};

var instanceHead = {
name: 'data',
attrs: {
'id': 'build_' + $.sanitizeString($('.header h1').text()) +
'_' + Math.round((new Date()).getTime() / 1000)
},
children: [{
name: 'meta',
children: [ { name: 'instanceID' } ]
}],
children: [ meta ],
context: {}
};

Expand All @@ -603,9 +607,9 @@ var dataNS = odkmaker.namespace.load('odkmaker.data');
attrs: {
'xmlns': 'http://www.w3.org/2002/xforms',
'xmlns:h': 'http://www.w3.org/1999/xhtml',
'xmlns:ev': 'http://www.w3.org/2001/xml-events',
'xmlns:xsd': 'http://www.w3.org/2001/XMLSchema',
'xmlns:jr': 'http://openrosa.org/javarosa'
'xmlns:jr': 'http://openrosa.org/javarosa',
'xmlns:orx': 'http://openrosa.org/xforms'
},
children: [
{ name: 'h:head',
Expand Down Expand Up @@ -634,14 +638,16 @@ var dataNS = odkmaker.namespace.load('odkmaker.data');
var instanceID = {
name: 'bind',
attrs: {
'nodeset': '/data/meta/instanceID',
'nodeset': '/data/orx:meta/orx:instanceID',
'type' : 'string',
'readonly' : 'true()',
'calculate' : 'concat(\'uuid:\', uuid())'
}
}
model.children.push(instanceID);

if (!$.isBlank(internal.metadata.instanceName))
meta.children.push({ name: 'instanceName', children: [ internal.metadata.instanceName ], _noWhitespace: true })

_.each(internal.controls, function(control)
{
Expand Down
5 changes: 5 additions & 0 deletions public/stylesheets/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -1385,6 +1385,11 @@ body > .control.last .controlFlowArrow,
margin-left: 10em;
width: calc(100% - 10em);
}
.formPropertiesDialog p
{
font-size: 1.1em;
padding-left: 10em;
}

.errorMessage p
{
Expand Down
4 changes: 4 additions & 0 deletions server/views/index.erb
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,10 @@

<label for="formProperties_title">Title on Device</label>
<input type="text" id="formProperties_title" name="title" />

<label for="formProperties_instanceName">Instance Name</label>
<input type="text" id="formProperties_instanceName" name="instanceName" />
<p>You can use calculated expressions to name submissions based on submission data. <a target="_blank" href="https://opendatakit.org/help/form-design/examples/">More Information</a>.</p>
</form>
</div>
<div class="modalButtonContainer">
Expand Down

0 comments on commit 29e222e

Please sign in to comment.