Changeset 407 for Dev/branches/rest-dojo-ui/client/rft/pages/viewSurvey.js
- Timestamp:
- 09/05/12 14:41:13 (13 years ago)
- Location:
- Dev/branches/rest-dojo-ui
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
Dev/branches/rest-dojo-ui
- Property svn:ignore
-
old new 1 1 nbproject 2 2 .project 3 release
-
- Property svn:ignore
-
Dev/branches/rest-dojo-ui/client
- Property svn:externals
-
old new 1 dojotoolkit http://svn.dojotoolkit.org/src/tags/release-1.8.0 1 dojo http://svn.dojotoolkit.org/src/tags/release-1.8.0/dojo 2 dijit http://svn.dojotoolkit.org/src/tags/release-1.8.0/dijit 3 dojox http://svn.dojotoolkit.org/src/tags/release-1.8.0/dojox 4 util http://svn.dojotoolkit.org/src/tags/release-1.8.0/util
-
- Property svn:externals
-
Dev/branches/rest-dojo-ui/client/rft/pages/viewSurvey.js
r406 r407 6 6 'dojo/_base/lang', 7 7 '../store', 8 '../ui/_Page', 9 '../ui/content/ContentWidgetFactory' 10 ], 11 function(array,declare,Deferred,event,lang,store,_Page,ContentWidgetFactory){ 12 return declare('rft.pages.viewSurvey',[_Page],{ 13 survey: null, 14 constructor: function(){ 15 this._dataMap = {}; 16 }, 17 onVisit: function() { 18 if ( this.pageArgs.uid ) { 19 Deferred.when(store.get(this.pageArgs.uid)) 20 .then(lang.hitch(this,function(obj){ 21 var f = new ContentWidgetFactory(); 22 this.survey = obj; 23 store.query(null,{keys:this.survey.questions,include_docs:true}) 24 .forEach(function(question){ 25 array.forEach(question.content || [],function(item){ 26 var w = f.createViewWidget(item,{ 27 name: question.code+'.'+item.code 28 }); 29 if ( w !== null ) { 30 w.placeAt(this.questionsAnchor,'before'); 31 } 32 },this); 8 '../app/Page', 9 '../ui/content/ContentWidgetFactory', 10 'dojo/text!./viewSurvey.html' 11 ],function(array,declare,Deferred,event,lang,store,Page,ContentWidgetFactory,template){ 12 return declare([Page],{ 13 templateString: template, 14 survey: null, 15 constructor: function(){ 16 this._dataMap = {}; 17 }, 18 startup: function() { 19 if ( this._started ) { return; } 20 this.inherited(arguments); 21 if ( this.surveyId ) { 22 Deferred.when(store.get(this.surveyId)) 23 .then(lang.hitch(this,function(obj){ 24 var f = new ContentWidgetFactory(); 25 this.survey = obj; 26 store.query(null,{keys:this.survey.questions,include_docs:true}) 27 .forEach(function(question){ 28 array.forEach(question.content || [],function(item){ 29 var w = f.createViewWidget(item,{ 30 name: question.code+'.'+item.code 31 }); 32 if ( w !== null ) { 33 w.placeAt(this.questionsAnchor,'before'); 34 } 33 35 },this); 34 })); 35 } else { 36 throw "No valid uid or survey passed!"; 37 } 38 }, 39 _onSubmit: function(evt) { 40 var value = this.questionsForm.get('value'); 41 this.questionsPane.set('content','<pre>'+JSON.stringify(value)+'</pre>'); 42 event.stop(evt); 43 return false; 44 }, 45 _onCancel: function(evt) { 46 event.stop(evt); 47 return false; 36 },this); 37 })); 38 } else { 39 throw "No valid uid or survey passed!"; 48 40 } 49 }); 41 }, 42 _onSubmit: function(evt) { 43 var value = this.questionsForm.get('value'); 44 this.questionsPane.set('content','<pre>'+JSON.stringify(value)+'</pre>'); 45 event.stop(evt); 46 return false; 47 }, 48 _onCancel: function(evt) { 49 event.stop(evt); 50 return false; 51 } 52 }); 50 53 }); 51
Note: See TracChangeset
for help on using the changeset viewer.