Changeset 477 for Dev/trunk/src/client/qed-client/pages/response.js
- Timestamp:
- 08/06/13 01:48:17 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
Dev/trunk/src/client/qed-client/pages/response.js
r461 r477 9 9 "dojo/_base/declare", 10 10 "dojo/_base/event", 11 "dojo/_base/json", 11 12 "dojo/_base/lang", 12 13 "dojo/promise/all", 14 "dojo/request", 13 15 "dojo/when", 14 16 "require", 15 17 "dojo/text!./templates/response.html" 16 ], function(Content, Page, async, Response, Survey, SurveyRun, store, declare, event, lang, all, when, require, template) {18 ], function(Content, Page, async, Response, Survey, SurveyRun, store, declare, event, json, lang, all, request, when, require, template) { 17 19 return declare([Page],{ 18 20 contextRequire: require, … … 37 39 this._enableSubmit(); 38 40 } 39 }), function() {41 }), lang.hitch(this,function() { 40 42 this._showInfo("<div>The url seems to be incorrect, no survey found.</div>"); 41 }) ;43 })); 42 44 } else { 43 45 throw new Error("No valid uid or survey passed!"); … … 45 47 }, 46 48 _loadSurveyAndResponse: function(surveyRunId,responseId){ 47 return all([store.get(surveyRunId),store.get(responseId)]) 49 return all([request.get('/api/surveyRuns/'+surveyRunId,{handleAs:'json'}), 50 request.get('/api/responses/'+responseId,{handleAs:'json'})]) 48 51 .then(lang.hitch(this,function(surveyAndResponse){ 49 52 var surveyRun = surveyAndResponse[0]; … … 73 76 var answers = this.surveyWidget.get('value'); 74 77 this.response.answers = answers; 75 return store.put(this.response).then(function(){ 78 return request.put('/api/responses/'+store.getIdentity(this.response),{ 79 handleAs:'json', 80 data:json.toJson(this.response), 81 headers:{"Content-Type": "application/json"} 82 }).then(function(){ 76 83 Content.notify("Your response is saved."); 77 84 }, function(err){ … … 82 89 this.response.publicationDate = store.timestamp(); 83 90 this._getAnswersAndSaveResponse() 84 .then( function(){91 .then(lang.hitch(this,function(){ 85 92 this._showInfo("<div>Thanks for filling in the survey. You cannot edit your answers anymore.</div>"); 86 93 this._disableSubmit(); 87 }) ;94 })); 88 95 if ( e ) { event.stop(e); } 89 96 return false;
Note: See TracChangeset
for help on using the changeset viewer.