Changeset 410 for Dev/branches/rest-dojo-ui/client/rft/pages/survey.js
- Timestamp:
- 09/07/12 16:59:14 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
Dev/branches/rest-dojo-ui/client/rft/pages/survey.js
r407 r410 5 5 'dojo/_base/event', 6 6 'dojo/_base/lang', 7 '../app/ Controller',7 '../app/Router', 8 8 '../store', 9 9 '../app/Page', … … 11 11 '../ui/TabbedQuestionBrowser', 12 12 'dojo/text!./survey.html' 13 ],function(array,declare,Deferred,event,lang, Controller,store,Page,13 ],function(array,declare,Deferred,event,lang,Router,store,Page, 14 14 QuestionListView,TabbedQuestionBrowser,template){ 15 15 return declare([Page],{ … … 27 27 this._setupQuestionBrowser(); 28 28 this._setupListView(); 29 Deferred.when(store.get(this.surveyId)) 30 .then(lang.hitch(this,function(obj){ 31 this.survey = obj; 32 store.query(null,{keys:this.survey.questions,include_docs:true}) 33 .forEach(lang.hitch(this.questionList,'appendItem')); 34 this.refresh(); 35 })); 29 this._setupSurvey(); 36 30 } else { 37 31 throw "No valid uid or survey passed!"; … … 42 36 region: 'center', 43 37 'class': 'blue', 38 include: 'published', 44 39 selectedActions: { 45 40 "Include": { … … 59 54 this.questionBrowser.startup(); 60 55 }, 61 _includeQuestion: function(question) {62 this.questionList.insertItem(question);63 },64 56 _setupListView: function() { 65 57 this.questionList = new QuestionListView({ … … 67 59 },this.surveyListViewNode); 68 60 this.questionList.startup(); 61 }, 62 _setupSurvey: function() { 63 Deferred.when(store.get(this.surveyId)) 64 .then(lang.hitch(this,function(survey){ 65 this.survey = survey; 66 store.query(null,{keys:this.survey.questions || [], include_docs: true}) 67 .forEach(lang.hitch(this.questionList,'appendItem')); 68 this.refresh(); 69 })); 70 }, 71 _includeQuestion: function(question) { 72 this.questionList.insertItem(question); 69 73 }, 70 74 refresh: function() { … … 94 98 store.put(this.survey) 95 99 .then(function() { 96 Controller.go('/surveys');100 Router.go('/surveys'); 97 101 }); 98 102 event.stop(evt); … … 100 104 }, 101 105 _onDiscard: function(evt) { 106 Router.go('/surveys'); 102 107 }, 103 108 _onShowPreview: function() { 104 Controller.go('/viewSurvey/'+store.getIdentity(this.survey)); 109 Router.go('/viewSurvey/'+store.getIdentity(this.survey),{ 110 preview: true 111 }); 105 112 } 106 113 });
Note: See TracChangeset
for help on using the changeset viewer.