Changeset 461 for Dev/trunk/src/client/qed-client/pages
- Timestamp:
- 06/10/13 01:07:16 (12 years ago)
- Location:
- Dev/trunk/src/client/qed-client/pages
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
Dev/trunk/src/client/qed-client/pages/response.js
r443 r461 1 1 define([ 2 "../app/Content", 2 3 "../app/Page", 3 4 "../lib/async", … … 13 14 "require", 14 15 "dojo/text!./templates/response.html" 15 ], function( Page, async, Response, Survey, SurveyRun, store, declare, event, lang, all, when, require, template) {16 ], function(Content, Page, async, Response, Survey, SurveyRun, store, declare, event, lang, all, when, require, template) { 16 17 return declare([Page],{ 17 18 contextRequire: require, … … 24 25 if ( this._started ) { return; } 25 26 this.inherited(arguments); 26 this._disable Buttons();27 this._disableSubmit(); 27 28 var surveyRunId = this.surveyRunId; 28 29 var responseId = this.options && this.options.id; 29 30 if ( surveyRunId && responseId ) { 30 31 this._loadSurveyAndResponse(surveyRunId,responseId) 31 .then(lang.hitch(this,"_enableButtons")); 32 .then(lang.hitch(this, function() { 33 if ( this.response.publicationDate ) { 34 this._showInfo("<div>You already submitted your survey and cannot change it anymore. You can still view your answers here.</div>"); 35 this._disableSubmit(); 36 } else { 37 this._enableSubmit(); 38 } 39 }), function() { 40 this._showInfo("<div>The url seems to be incorrect, no survey found.</div>"); 41 }); 32 42 } else { 33 43 throw new Error("No valid uid or survey passed!"); … … 43 53 } 44 54 this.titleNode.innerHTML = Survey.DisplayTitle.get(surveyRun.survey); 45 this.surveyWidget.set('survey', surveyRun.survey);46 this. responseForm.set('value',this.response.answers || {});55 this.surveyWidget.set('survey', surveyRun.survey); 56 this.surveyWidget.set('value', this.response.answers || {}); 47 57 })); 48 58 }, 49 _enable Buttons: function() {59 _enableSubmit: function() { 50 60 this.submitButton.set('disabled',false); 51 61 this.continueButton.set('disabled',false); 62 this.surveyWidget.set('disabled', false); 52 63 }, 53 _disable Buttons: function() {64 _disableSubmit: function() { 54 65 this.submitButton.set('disabled',true); 55 66 this.continueButton.set('disabled',true); 67 this.surveyWidget.set('disabled', true); 68 }, 69 _showInfo: function(html) { 70 this.infoNode.innerHTML = html; 56 71 }, 57 72 _getAnswersAndSaveResponse: function() { 58 this.response.answers = this.responseForm.get('value'); 59 console.log(this.response); 60 return store.put(this.response); 73 var answers = this.surveyWidget.get('value'); 74 this.response.answers = answers; 75 return store.put(this.response).then(function(){ 76 Content.notify("Your response is saved."); 77 }, function(err){ 78 Content.notify(err,'error'); 79 }); 61 80 }, 62 81 _onSubmit: function(e) { 63 82 this.response.publicationDate = store.timestamp(); 64 this._getAnswersAndSaveResponse(); 65 this.content.domNode.innerHTML = "<div>Thanks for filling in the survey.</div>"; 83 this._getAnswersAndSaveResponse() 84 .then(function(){ 85 this._showInfo("<div>Thanks for filling in the survey. You cannot edit your answers anymore.</div>"); 86 this._disableSubmit(); 87 }); 66 88 if ( e ) { event.stop(e); } 67 89 return false; 68 90 }, 69 91 _onContinueLater: function(e) { 70 this._getAnswersAndSaveResponse(); 71 this.content.domNode.innerHTML = "<div>To continue with this survey later, just save the URL in the location bar and revisit it later. Your answers will still be there.</div>"; 92 this._getAnswersAndSaveResponse() 93 .then(lang.hitch(this,function(){ 94 this._showInfo("<div>To continue with this survey later, just save the URL in the location bar and revisit it later. Your answers will still be there.</div>"); 95 })); 72 96 if ( e ) { event.stop(e); } 73 97 return false; -
Dev/trunk/src/client/qed-client/pages/templates/response.html
r457 r461 6 6 <span class="headerText" data-dojo-attach-point="titleNode">Survey</span> 7 7 </h2> 8 <div data-dojo-attach-point="infoNode"></div> 8 9 </div> 9 10 10 11 <div data-dojo-type="dijit/layout/ContentPane" data-dojo-props="region:'center'" data-dojo-attach-point="content"> 11 <form data-dojo-type="dijit/form/Form" data-dojo-attach-point="responseForm" 12 data-dojo-attach-event="onSubmit:_ignoreEvent" style="overflow: auto"> 13 <div data-dojo-type="../model/widgets/SurveyRenderWidget" data-dojo-attach-point="surveyWidget"></div> 14 </form> 12 <div name="answers" data-dojo-type="../model/widgets/SurveyRenderWidget" data-dojo-attach-point="surveyWidget"></div> 15 13 </div> 16 14
Note: See TracChangeset
for help on using the changeset viewer.