Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
iperdomo committed Oct 31, 2013
2 parents 4970a3e + 2a1479f commit 9c0a44e
Show file tree
Hide file tree
Showing 12 changed files with 104 additions and 23 deletions.
3 changes: 3 additions & 0 deletions Dashboard/app/js/lib/models/models.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,9 @@ FLOW.Question = FLOW.BaseModel.extend({
allowSign: DS.attr('boolean', {
defaultValue: false
}),
geoLocked: DS.attr('boolean', {
defaultValue: false
}),
collapseable: DS.attr('boolean', {
defaultValue: false
}),
Expand Down
40 changes: 20 additions & 20 deletions Dashboard/app/js/lib/views/reports/export-reports-views.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,57 +126,56 @@ FLOW.ExportReportsAppletView = FLOW.View.extend({
showComprehensiveDialog: false,
showRawDataImportApplet: false,
showGoogleEarthButton: false,
selectedSurvey:null,

didInsertElement: function () {
FLOW.selectedControl.set('selectedSurvey', null);
FLOW.uploader.registerEvents();
},

selectedSurvey: function () {
return FLOW.selectedControl.selectedSurvey.get('keyId');
}.property(),

showRawDataReport: function () {
if (!this.get('selectedSurvey')) {
var sId = this.get('selectedSurvey');
if (!sId) {
this.showWarning();
return;
}
FLOW.ReportLoader.load('RAW_DATA', this.selectedSurvey.get('id'));
FLOW.ReportLoader.load('RAW_DATA', sId);
},

showRawTextFileExport: function () {
if (!this.get('selectedSurvey')) {
var sId = this.get('selectedSurvey');
if (!sId) {
this.showWarning();
return;
}
FLOW.ReportLoader.load('RAW_DATA_TEXT', this.selectedSurvey.get('id'));
FLOW.ReportLoader.load('RAW_DATA_TEXT', sId);
},

showComprehensiveReport: function () {
var opts = {};
var opts = {}, sId = this.get('selectedSurvey');
this.set('showComprehensiveDialog', false);

opts.performRollup = '' + FLOW.editControl.summaryPerGeoArea;
opts.nocharts = '' + FLOW.editControl.omitCharts;

FLOW.ReportLoader.load('GRAPHICAL_SURVEY_SUMMARY', this.selectedSurvey.get('id'), opts);
},

showGoogleEarthFile: function () {
if (!this.get('selectedSurvey')) {
this.showWarning();
return;
}
this.renderApplet('showGoogleEarthFileApplet', true);
FLOW.ReportLoader.load('GRAPHICAL_SURVEY_SUMMARY', sId, opts);
},

showSurveyForm: function () {
if (!this.get('selectedSurvey')) {
var sId = this.get('selectedSurvey');
if (!sId) {
this.showWarning();
return;
}
FLOW.ReportLoader.load('SURVEY_FORM', this.selectedSurvey.get('id'));
FLOW.ReportLoader.load('SURVEY_FORM', sId);
},

importFile: function () {
var file;
if (!this.get('selectedSurvey')) {
var file, sId = this.get('selectedSurvey');
if (!sId) {
this.showImportWarning(Ember.String.loc('_import_select_survey'));
return;
}
Expand All @@ -193,7 +192,8 @@ FLOW.ExportReportsAppletView = FLOW.View.extend({
},

showComprehensiveOptions: function () {
if (!this.get('selectedSurvey')) {
var sId = this.get('selectedSurvey');
if (!sId) {
this.showWarning();
return;
}
Expand Down
16 changes: 15 additions & 1 deletion Dashboard/app/js/lib/views/surveys/question-view.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ FLOW.QuestionView = FLOW.View.extend({
allowDecimal: null,
allowMultipleFlag: null,
allowOtherFlag: null,
geoLocked: null,
dependentFlag: false,
dependentQuestion: null,
optionList: null,
Expand Down Expand Up @@ -79,11 +80,19 @@ FLOW.QuestionView = FLOW.View.extend({
}
}.property('this.type').cacheable(),

amGeoType: function () {
if (this.type) {
return this.type.get('value') == 'GEO';
} else {
return false;
}
}.property('this.type').cacheable(),

amNoOptionsType: function () {
var val;
if (!Ember.none(this.type)) {
val = this.type.get('value');
return val == 'GEO' || val == 'FREE_TEXT' || val == 'PHOTO' || val == 'VIDEO' || val == 'BARCODE';
return val == 'FREE_TEXT' || val == 'PHOTO' || val == 'VIDEO' || val == 'BARCODE';
}
}.property('this.type').cacheable(),

Expand Down Expand Up @@ -113,6 +122,7 @@ FLOW.QuestionView = FLOW.View.extend({
this.set('allowDecimal', FLOW.selectedControl.selectedQuestion.get('allowDecimal'));
this.set('allowMultipleFlag', FLOW.selectedControl.selectedQuestion.get('allowMultipleFlag'));
this.set('allowOtherFlag', FLOW.selectedControl.selectedQuestion.get('allowOtherFlag'));
this.set('geoLocked', FLOW.selectedControl.selectedQuestion.get('geoLocked'));
this.set('includeInMap', FLOW.selectedControl.selectedQuestion.get('includeInMap'));
this.set('dependentFlag', FLOW.selectedControl.selectedQuestion.get('dependentFlag'));
this.set('optionList', FLOW.selectedControl.selectedQuestion.get('questionOptionList'));
Expand Down Expand Up @@ -219,6 +229,9 @@ FLOW.QuestionView = FLOW.View.extend({
this.set('allowSign', false);
this.set('allowDecimal', false);
}
if (this.type.get('value') !== 'GEO') {
this.set('geoLocked', false);
}
path = FLOW.selectedControl.selectedSurveyGroup.get('code') + "/" + FLOW.selectedControl.selectedSurvey.get('name') + "/" + FLOW.selectedControl.selectedQuestionGroup.get('code');
FLOW.selectedControl.selectedQuestion.set('text', this.get('text'));
FLOW.selectedControl.selectedQuestion.set('tip', this.get('tip'));
Expand All @@ -234,6 +247,7 @@ FLOW.QuestionView = FLOW.View.extend({
FLOW.selectedControl.selectedQuestion.set('allowDecimal', this.get('allowDecimal'));
FLOW.selectedControl.selectedQuestion.set('allowMultipleFlag', this.get('allowMultipleFlag'));
FLOW.selectedControl.selectedQuestion.set('allowOtherFlag', this.get('allowOtherFlag'));
FLOW.selectedControl.selectedQuestion.set('geoLocked', this.get('geoLocked'));
FLOW.selectedControl.selectedQuestion.set('includeInMap', this.get('includeInMap'));

dependentQuestionAnswer = "";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

{{view Ember.Select
contentBinding="FLOW.surveyControl.arrangedContent"
selectionBinding="view.selectedSurvey"
selectionBinding="FLOW.selectedControl.selectedSurvey"
optionLabelPath="content.code"
optionValuePath="content.keyId"
prompt=""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

{{view Ember.Select
contentBinding="FLOW.surveyControl.arrangedContent"
selectionBinding="view.selectedSurvey"
selectionBinding="FLOW.selectedControl.selectedSurvey"
optionLabelPath="content.code"
optionValuePath="content.keyId"
prompt=""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@
<label class="minValNumb">{{t _min_val}}: {{view Ember.TextField valueBinding="view.minVal" size=10 }}</label>
<label class="maxValNumb">{{t _max_val}}: {{view Ember.TextField valueBinding="view.maxVal" size=10 }}</label>
{{/if}}
{{#if view.amGeoType}}
<h1 class="answerNbr">{{t _geo_details}}: </h1>
<label class="labelcheckbox"> {{view Ember.Checkbox checkedBinding="view.geoLocked"}}{{t _disable_manual_geo_edit}} </label>
{{/if}}

{{#if view.amNoOptionsType}}
<p class="noOptions">
Expand Down
9 changes: 9 additions & 0 deletions GAE/src/com/gallatinsystems/survey/domain/Question.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ public enum Type {
private Boolean allowMultipleFlag = null;
private Boolean allowOtherFlag = null;
private Boolean collapseable = false;
private Boolean geoLocked = null;
private Boolean immutable = false;
private Long dependentQuestionId;
private String dependentQuestionAnswer;
Expand Down Expand Up @@ -323,4 +324,12 @@ public void setImmutable(Boolean immutable) {
public Boolean getImmutable() {
return immutable;
}

public Boolean getGeoLocked() {
return geoLocked;
}

public void setGeoLocked(Boolean geoLocked) {
this.geoLocked = geoLocked;
}
}
2 changes: 2 additions & 0 deletions GAE/src/locale/en.properties
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ Device\ id = Device id
Devices = Devices
Devices\ list = Devices list
Disable\ devices = Disable devices
Disable\ manual\ editing\ of\ geo\ values\ on\ device = Disable manual editing of geo values on device
Do\ not\ navigate\ away\ from\ this\ page\ while\ the\ upload\ is\ in\ progress = Do not navigate away from this page while the upload is in progress
Documentation\ and\ user\ guides = Documentation and user guides
Drop\ files\ here\ to\ upload\ or = Drop files here to upload or
Expand Down Expand Up @@ -126,6 +127,7 @@ Free\ Text = Free Text
Generate\ Summary\ Sheets\ for\ each\ Geographic\ Area = Generate Summary Sheets for each Geographic Area
Generates\ a\ printable\ survey\ form\ in\ excel\ that\ can\ be\ used\ to\ conduct\ a\ paper-based\ survey.\ must\ be\ saved\ as\ an\ .xls\ or\ .xlsx = Generates a printable survey form in excel that can be used to conduct a paper-based survey. must be saved as an .xls or .xlsx
Geolocation = Geolocation
Geolocation\ settings = Geolocation settings
Go\ back\ to\ assignment\ list = Go back to assignment list
Go\ back\ to\ survey\ overview = Go back to survey overview
Google\ Earth\ file = Google Earth file
Expand Down
2 changes: 2 additions & 0 deletions GAE/src/locale/ui-strings.properties
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ _device_id = Device id
_devices = Devices
_devices_list = Devices list
_disable_devices = Disable devices
_disable_manual_geo_edit = Disable manual editing of geo values on device
_do_not_navigate_away = Do not navigate away from this page while the upload is in progress
_documentation_and_user_guides = Documentation and user guides
_drop_files = Drop files here to upload or
Expand Down Expand Up @@ -125,6 +126,7 @@ _find = Find
_free_text = Free Text
_gelocation = Geolocation
_generate_summary_per_geo_area = Generate Summary Sheets for each Geographic Area
_geo_details = Geolocation settings
_go_back_to_assignment_list = Go back to assignment list
_go_back_to_survey_overview = Go back to survey overview
_google_earth_applet_text_ = Exports a Google Earth file that shows the location and survey data for every surveyed point in your dashboard. can be opened in Google Earth, and must be saved as a .kmz file
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ public class QuestionDto extends BaseDto implements NamedObject {
private List<Long> questionOptions = null;
private Boolean mandatoryFlag = null;
private Boolean dependentFlag = null;
private Boolean geoLocked = null;
private Long dependentQuestionId;
private String dependentQuestionAnswer;
private Long metricId;
Expand Down Expand Up @@ -369,4 +370,12 @@ public Long getSourceId() {
public void setSourceId(Long sourceId) {
this.sourceId = sourceId;
}

public Boolean getGeoLocked() {
return geoLocked;
}

public void setGeoLocked(Boolean geoLocked) {
this.geoLocked = geoLocked;
}
}
34 changes: 34 additions & 0 deletions GAE/src/org/waterforpeople/mapping/app/web/RawDataRestServlet.java
Original file line number Diff line number Diff line change
Expand Up @@ -80,12 +80,46 @@ protected RestResponse handleRequest(RestRequest req) throws Exception {
.getAction())) {
List<QuestionAnswerStoreDto> dtoList = new ArrayList<QuestionAnswerStoreDto>();
boolean isNew = false;

if (importReq.getSurveyInstanceId() == null
&& importReq.getSurveyId() != null) {
// if the instanceID is null, we need to create one
createInstance(importReq);
isNew = true;
}

if (importReq.getSurveyInstanceId() != null
&& importReq.getSurveyId() != null) {

SurveyInstance si = new SurveyInstanceDAO().getByKey(importReq
.getSurveyInstanceId());

if (si == null) {
MessageDao mDao = new MessageDao();
Message message = new Message();

message.setObjectId(importReq.getSurveyInstanceId());
message.setActionAbout("importData");
message.setShortMessage("Survey instance id ["
+ importReq.getSurveyInstanceId()
+ "] doesn't exist");
mDao.save(message);
return null;
}

if (!si.getSurveyId().equals(importReq.getSurveyId())) {
MessageDao mDao = new MessageDao();
Message message = new Message();

message.setObjectId(importReq.getSurveyInstanceId());
message.setActionAbout("importData");
message.setShortMessage("Wrong survey selected when importing instance id ["
+ importReq.getSurveyInstanceId() + "]");
mDao.save(message);
return null;
}
}

for (Map.Entry<Long, String[]> item : importReq
.getQuestionAnswerMap().entrySet()) {
QuestionAnswerStoreDto qasDto = new QuestionAnswerStoreDto();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -592,6 +592,10 @@ private String marshallQuestion(Question q) {
qXML.setType(FREE_QUESTION_TYPE);
} else if (q.getType().equals(Question.Type.GEO)) {
qXML.setType(GEO_QUESTION_TYPE);
// add locked flag if the geoLocked field is true in the question
if (q.getGeoLocked() != null && q.getGeoLocked()){
qXML.setLocked(q.getGeoLocked().toString());
}
} else if (q.getType().equals(Question.Type.NUMBER)) {
qXML.setType(FREE_QUESTION_TYPE);
if (!hasValidation) {
Expand Down

0 comments on commit 9c0a44e

Please sign in to comment.