Skip to content

Commit

Permalink
Merge pull request #143 from odk-x/demo
Browse files Browse the repository at this point in the history
release 2.1.7
  • Loading branch information
jbeorse authored Dec 29, 2020
2 parents 8460672 + 4dfafd3 commit 7abf14b
Show file tree
Hide file tree
Showing 9 changed files with 115 additions and 83 deletions.
10 changes: 5 additions & 5 deletions app/config/tables/eonasdan/definition.csv
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
_element_key,_element_name,_element_type,_list_child_element_keys
example0,example0,date,[]
example1,example1,dateTime,[]
example2,example2,date,[]
example3,example3,time,[]
_element_key,_element_name,_element_type,_list_child_element_keys
example0,example0,date_no_time,[]
example1,example1,dateTime,[]
example2,example2,date,[]
example3,example3,time,[]
Binary file modified app/config/tables/eonasdan/forms/eonasdan/eonasdan.xlsx
Binary file not shown.
10 changes: 5 additions & 5 deletions app/config/tables/eonasdan/forms/eonasdan/formDef.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"xlsx": {
"survey": [
{
"type": "birthdate",
"type": "birth_date",
"name": "example0",
"display": {
"prompt": {
Expand Down Expand Up @@ -170,7 +170,7 @@
}
],
"type": "string",
"elementType": "date",
"elementType": "date_no_time",
"elementKey": "example0"
},
"example1": {
Expand Down Expand Up @@ -218,7 +218,7 @@
"reachable_sections": {},
"prompts": [
{
"type": "birthdate",
"type": "birth_date",
"name": "example0",
"display": {
"prompt": {
Expand All @@ -228,7 +228,7 @@
"_row_num": 2,
"__rowNum__": 1,
"_token_type": "prompt",
"_type": "birthdate",
"_type": "birth_date",
"_branch_label_enclosing_screen": "survey/_screen2",
"promptIdx": 0
},
Expand Down Expand Up @@ -538,7 +538,7 @@
}
],
"type": "string",
"elementType": "date",
"elementType": "date_no_time",
"elementKey": "example0",
"elementName": "example0",
"elementSet": "data",
Expand Down
10 changes: 5 additions & 5 deletions app/config/tables/eonasdan/properties.csv
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
_partition,_aspect,_key,_type,_value
FormType,default,FormType.formType,string,SURVEY
SurveyUtil,default,SurveyUtil.formId,string,eonasdan
Table,default,defaultViewType,string,SPREADSHEET
Table,default,displayName,object,"{""text"":""DateTime Picker""}"
_partition,_aspect,_key,_type,_value
FormType,default,FormType.formType,string,SURVEY
SurveyUtil,default,SurveyUtil.formId,string,eonasdan
Table,default,defaultViewType,string,SPREADSHEET
Table,default,displayName,object,"{""text"":""DateTime Picker""}"
4 changes: 3 additions & 1 deletion app/system/survey/js/databaseUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -552,7 +552,9 @@ return {
} else if ( jsonType.type === 'number' ) {
return Number(value);
} else if ( jsonType.type === 'string' ) {
if ( jsonType.elementType === 'date' ||
if ( jsonType.elementType === 'date_no_time' ) {
return moment(value);
} else if ( jsonType.elementType === 'date' ||
jsonType.elementType === 'dateTime' ) {
// convert from a nanosecond-extended iso8601-style UTC date yyyy-mm-ddTHH:MM:SS.sssssssss
// this does not preserve the nanosecond field...
Expand Down
104 changes: 72 additions & 32 deletions app/system/survey/js/prompts.js
Original file line number Diff line number Diff line change
Expand Up @@ -1945,16 +1945,10 @@ promptTypes.decimal = promptTypes.input_type.extend({
}
}
});
promptTypes.datetime = promptTypes.input_type.extend({
type: "datetime",
templatePath: "templates/datetimepicker.handlebars",
// TODO: Use a template?
promptTypes.base_date = promptTypes.input_type.extend({
type: "base_date",
usePicker: true,
insideAfterRender: false,
timeFormat: "MM/DD/YYYY h:mm A",
timeTemplate: "YYYY / MM / DD HH : mm",
showDate: true,
showTime: true,
dtp: null,
events: {
"swipeleft input": "stopPropagation",
Expand Down Expand Up @@ -2032,16 +2026,7 @@ promptTypes.datetime = promptTypes.input_type.extend({
odkCommon.log('D',"prompts." + that.type + ".modification px: " + that.promptIdx);
if ( !that.insideAfterRender ) {
var formattedDateValue = that.$('input').combodate('getValue', null);
var value = null;
if (formattedDateValue !== null && formattedDateValue !== undefined && !(_.isEmpty(formattedDateValue))) {
if (that.type === "time") {
var newDate = new Date();
formattedDateValue.year(newDate.getUTCFullYear());
formattedDateValue.month(newDate.getUTCMonth());
formattedDateValue.date(newDate.getUTCDate());
}
value = new Date(formattedDateValue);
}
var value = that.formatDBVal(formattedDateValue);

//
// we are using a date pop-up. If an earlier action fails, we should not
Expand Down Expand Up @@ -2125,15 +2110,49 @@ promptTypes.datetime = promptTypes.input_type.extend({
return null;
}
});
promptTypes.datetime = promptTypes.base_date.extend({
type: "datetime",
templatePath: "templates/datetimepicker.handlebars",
timeFormat: "YYYY/MM/DD h:mm A",
timeTemplate: "YYYY / MM / DD HH : mm",
showDate: true,
showTime: true,
formatDBVal: function(formattedDateValue) {
var that = this;
var outputValue = null;
if (formattedDateValue !== null && formattedDateValue !== undefined && !(_.isEmpty(formattedDateValue))) {
if (that.type === "time") {
var newDate = new Date();
formattedDateValue.year(newDate.getUTCFullYear());
formattedDateValue.month(newDate.getUTCMonth());
formattedDateValue.date(newDate.getUTCDate());
}
outputValue = new Date(formattedDateValue);
}
return outputValue;
}
});
promptTypes.date = promptTypes.datetime.extend({
type: "date",
showTime: false,
timeFormat: "MM/DD/YYYY",
timeFormat: "YYYY/MM/DD",
timeTemplate: "YYYY / MM / DD"
});

promptTypes.time = promptTypes.datetime.extend({
type: "time",
showDate: false,
timeFormat: "h:mm A",
timeTemplate: "HH : mm",
sameValue: function(ref, value) {
// these are milliseconds relative to Jan 1 1970...
var ref_tod = (ref.valueOf() % 86400000);
var value_tod = (value.valueOf() % 86400000);
return (ref_tod === value_tod);
}
});
promptTypes.birthdate = promptTypes.date.extend({
type: "birthdate",
// TODO: REMOVE THIS. IT HAS BEEN DEPRACATED IN FAVOR OF BIRTH_DATE
type: "birth_date",
afterRender: function() {
var that = this;
if(that.usePicker){
Expand All @@ -2152,18 +2171,39 @@ promptTypes.birthdate = promptTypes.date.extend({
}
},
});
promptTypes.date_no_time = promptTypes.base_date.extend({
type: "date_no_time",
showTime: false,
timeFormat: "YYYY/MM/DD",
timeTemplate: "YYYY / MM / DD",
dbDateFormat: "YYYY-MM-DD",
formatDBVal: function(formattedDateValue) {
var outputValue = null;
if (formattedDateValue !== null && formattedDateValue !== undefined && !(_.isEmpty(formattedDateValue))) {
outputValue = formattedDateValue.format(this.dbDateFormat);
}
return outputValue;
},
})
promptTypes.birth_date = promptTypes.date_no_time.extend({
type: "birth_date",
afterRender: function() {
var that = this;
if(that.usePicker){
that.insideAfterRender = true;

promptTypes.time = promptTypes.datetime.extend({
type: "time",
showDate: false,
timeFormat: "h:mm A",
timeTemplate: "HH : mm",
sameValue: function(ref, value) {
// these are milliseconds relative to Jan 1 1970...
var ref_tod = (ref.valueOf() % 86400000);
var value_tod = (value.valueOf() % 86400000);
return (ref_tod === value_tod);
}
if (that.dtp !== null && that.dtp !== undefined) {
that.dtp.destroy();
}

that.$('input').combodate({format: this.timeFormat, template: this.timeTemplate, maxYear: new Date().getFullYear(), hideCurrentMonth: true, hideCurrentDay: true });

var inputElement = that.$('input');
that.dtp = inputElement.data('DateTimePicker');

that.insideAfterRender = false;
}
},
});
/**
* Media is an abstract object used as a base for image/audio/video
Expand Down
4 changes: 2 additions & 2 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,12 @@
}
//]]>
</script>
<title>OpenDataKit Development Environment Homepage</title>
<title>ODK-X Development Environment Homepage</title>
</head>

<body class="absolute">
<noscript>This page requires javascript and a Chrome or WebKit browser</noscript>
<div class="topversion">ODK 2.1.6</div>
<div class="topversion">ODK 2.1.7</div>
<ul class="tabs">
<li>
<button onclick="switchTab(event, 'tab1')" class="tab-link active">Preview</a>
Expand Down
44 changes: 12 additions & 32 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 11 additions & 1 deletion xlsxconverter/XLSXConverter2.js
Original file line number Diff line number Diff line change
Expand Up @@ -426,9 +426,19 @@ var XLSXConverter = {};
// odk time stamp -- UTC timestamp string with 00:00:00.000 time.
"type": "string",
"elementType": "date"
},
"date_no_time": {
// odk date with no time or timezone information
"type": "string",
"elementType": "date_no_time"
},
"birth_date": {
// odk date with no time or timezone information
"type": "string",
"elementType": "date_no_time"
},
"birthdate": {
// odk time stamp -- UTC timestamp string with 00:00:00.000 time.
// TODO: REMOVE THIS. IT IS DEPRACATED IN FAVOR OF birth_date
"type": "string",
"elementType": "date"
},
Expand Down

0 comments on commit 7abf14b

Please sign in to comment.