- Timestamp:
- 12/16/12 20:07:35 (12 years ago)
- File:
-
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
Dev/branches/rest-dojo-ui/client/qed/pages/previewSurvey.js
r418 r420 2 2 'dojo/_base/array', 3 3 'dojo/_base/declare', 4 'dojo/_base/Deferred',5 'dojo/_base/event',6 4 'dojo/_base/lang', 5 'dojo/when', 7 6 '../store', 8 7 '../app/Page', 9 '../model/widgets/QuestionWidgetFactory', 10 'dojo/text!./templates/viewSurvey.html' 11 ],function(array,declare,Deferred,event,lang,store,Page,QuestionWidgetFactory,template){ 8 'dojo/text!./templates/previewSurvey.html' 9 ],function(array,declare,lang,when,store,Page,template){ 12 10 return declare([Page],{ 13 11 templateString: template, 14 survey: null,15 surveyId: "",16 options: null,17 constructor: function(){18 this._dataMap = {};19 this.options = this.options || {};20 },21 12 startup: function() { 22 13 if ( this._started ) { return; } 23 14 this.inherited(arguments); 24 25 26 15 if ( this.surveyId ) { 27 Deferred.when(store.get(this.surveyId))16 when(store.get(this.surveyId)) 28 17 .then(lang.hitch(this,function(survey){ 29 if ( !survey.published ) { 30 this.options.preview = true; 31 } 32 if ( this.options.preview ) { 33 this.buttonsPane.destroyRecursive(); 34 } 35 this.titleNode.innerHTML = survey.title + 36 (this.options.preview?' [preview]':''); 37 var f = new QuestionWidgetFactory(); 38 this.survey = survey; 39 store.query(null,{keys:this.survey.questions,include_docs:true}) 40 .forEach(function(question){ 41 array.forEach(question.content || [],function(item){ 42 var w = f.createViewWidget(item,{ 43 name: question.code+'.'+item.code 44 }); 45 if ( w !== null ) { 46 w.placeAt(this.questionsAnchor,'before'); 47 } 48 },this); 49 },this); 18 this.titleNode.innerHTML = survey.title; 19 this.surveyWidget.set('survey',survey); 50 20 })); 51 21 } else { 52 22 throw new Error("No valid uid or survey passed!"); 53 23 } 54 },55 _onSubmit: function(evt) {56 if ( this.options.preview ) { return; }57 var value = this.questionsForm.get('value');58 this.questionsPane.set('content','<pre>'+JSON.stringify(value)+'</pre>');59 event.stop(evt);60 return false;61 },62 _onCancel: function(evt) {63 if ( this.options.preview ) { return; }64 event.stop(evt);65 return false;66 24 } 67 25 });
Note: See TracChangeset
for help on using the changeset viewer.