Changeset 407 for Dev/branches/rest-dojo-ui/client/rft/pages/survey.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/survey.js
r402 r407 5 5 'dojo/_base/event', 6 6 'dojo/_base/lang', 7 '../ content',7 '../app/Controller', 8 8 '../store', 9 '../ ui/_Page',9 '../app/Page', 10 10 '../ui/lists/QuestionListView', 11 '../ui/TabbedQuestionBrowser' 12 ], 13 function(array,declare,Deferred,event,lang,content,store,_Page, 14 QuestionListView,TabbedQuestionBrowser){ 15 return declare('rft.pages.survey',[_Page],{ 16 survey: null, 17 questionList: null, 18 _dataMap: null, 19 constructor: function(){ 20 this._dataMap = {}; 21 }, 22 onVisit: function() { 23 if ( this.pageArgs.uid ) { 24 this._setupQuestionBrowser(); 25 this._setupListView(); 26 Deferred.when(store.get(this.pageArgs.uid)) 27 .then(lang.hitch(this,function(obj){ 28 this.survey = obj; 29 store.query(null,{keys:this.survey.questions,include_docs:true}) 30 .forEach(lang.hitch(this.questionList,'appendItem')); 31 this.refresh(); 32 })); 33 } else { 34 throw "No valid uid or survey passed!"; 11 '../ui/TabbedQuestionBrowser', 12 'dojo/text!./survey.html' 13 ],function(array,declare,Deferred,event,lang,Controller,store,Page, 14 QuestionListView,TabbedQuestionBrowser,template){ 15 return declare([Page],{ 16 templateString: template, 17 survey: null, 18 questionList: null, 19 _dataMap: null, 20 constructor: function(){ 21 this._dataMap = {}; 22 }, 23 startup: function() { 24 if ( this._started ) { return; } 25 this.inherited(arguments); 26 if ( this.surveyId ) { 27 this._setupQuestionBrowser(); 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 })); 36 } else { 37 throw "No valid uid or survey passed!"; 38 } 39 }, 40 _setupQuestionBrowser: function() { 41 this.questionBrowser = new TabbedQuestionBrowser({ 42 region: 'center', 43 'class': 'blue', 44 selectedActions: { 45 "Include": { 46 callback: lang.hitch(this,this._includeQuestion), 47 icon: "Accept", 48 description: "Include in survey" 49 } 50 }, 51 itemActions: { 52 "Info": { 53 callback: function(item){ item.description && alert(item.description); }, 54 icon: "Inspect", 55 description: "Show item description" 56 } 35 57 } 36 }, 37 _setupQuestionBrowser: function() { 38 this.questionBrowser = new TabbedQuestionBrowser({ 39 region: 'center', 40 'class': 'blue', 41 selectedActions: { 42 "Include": { 43 callback: lang.hitch(this,this._includeQuestion), 44 icon: "Accept", 45 description: "Include in survey" 46 } 47 }, 48 itemActions: { 49 "Info": { 50 callback: function(item){ item.description && alert(item.description); }, 51 icon: "Inspect", 52 description: "Show item description" 53 } 54 } 55 },this.questionBrowser); 56 this.questionBrowser.startup(); 57 }, 58 _includeQuestion: function(question) { 59 this.questionList.insertItem(question); 60 }, 61 _setupListView: function() { 62 this.questionList = new QuestionListView({ 63 region: 'center' 64 },this.surveyListViewNode); 65 this.questionList.startup(); 66 }, 67 refresh: function() { 68 this.titleNode.innerHTML = this.survey.title || "(set title in properties)"; 69 this.propertiesForm.set('value',this.survey); 70 }, 71 _onShowProperties: function(evt) { 72 this.propertiesDialog.show(); 73 }, 74 _onPropertiesOk: function(evt) { 75 this.propertiesDialog.hide(); 76 lang.mixin(this.survey, this.propertiesForm.get('value')); 77 this.refresh(); 78 event.stop(evt); 79 return false; 80 }, 81 _onPropertiesCancel: function(evt) { 82 this.propertiesDialog.hide(); 83 this.propertiesForm.set('value',this.survey); 84 event.stop(evt); 85 return false; 86 }, 87 _onSave: function(evt) { 88 this.survey.questions = array.map(this.questionList.getItems(),function(item){ 89 return store.getIdentity(item); 90 }); 91 store.put(this.survey) 92 .then(function() { 93 content.goTo('surveys'); 94 }); 95 event.stop(evt); 96 return false; 97 }, 98 _onDiscard: function(evt) { 99 }, 100 _onShowPreview: function() { 101 content.goTo('viewSurvey', {uid: store.getIdentity(this.survey)}); 102 } 103 }); 58 },this.questionBrowser); 59 this.questionBrowser.startup(); 60 }, 61 _includeQuestion: function(question) { 62 this.questionList.insertItem(question); 63 }, 64 _setupListView: function() { 65 this.questionList = new QuestionListView({ 66 region: 'center' 67 },this.surveyListViewNode); 68 this.questionList.startup(); 69 }, 70 refresh: function() { 71 this.titleNode.innerHTML = this.survey.title || "(set title in properties)"; 72 this.propertiesForm.set('value',this.survey); 73 }, 74 _onShowProperties: function(evt) { 75 this.propertiesDialog.show(); 76 }, 77 _onPropertiesOk: function(evt) { 78 this.propertiesDialog.hide(); 79 lang.mixin(this.survey, this.propertiesForm.get('value')); 80 this.refresh(); 81 event.stop(evt); 82 return false; 83 }, 84 _onPropertiesCancel: function(evt) { 85 this.propertiesDialog.hide(); 86 this.propertiesForm.set('value',this.survey); 87 event.stop(evt); 88 return false; 89 }, 90 _onSave: function(evt) { 91 this.survey.questions = array.map(this.questionList.getItems(),function(item){ 92 return store.getIdentity(item); 93 }); 94 store.put(this.survey) 95 .then(function() { 96 Controller.go('/surveys'); 97 }); 98 event.stop(evt); 99 return false; 100 }, 101 _onDiscard: function(evt) { 102 }, 103 _onShowPreview: function() { 104 Controller.go('/viewSurvey/'+store.getIdentity(this.survey)); 105 } 106 }); 104 107 }); 105 108
Note: See TracChangeset
for help on using the changeset viewer.