Changeset 379 for Dev/branches/rest-dojo-ui/client/rft/pages/survey.js
- Timestamp:
- 07/26/12 21:57:20 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
Dev/branches/rest-dojo-ui/client/rft/pages/survey.js
r370 r379 1 1 define([ 2 'dojo/_base/array', 2 3 'dojo/_base/declare', 3 4 'dojo/_base/Deferred', … … 7 8 'rft/store', 8 9 'rft/ui/_Page', 9 'rft/ui/ SurveyListView',10 'rft/ui/OrderedDndList', 10 11 'rft/ui/TabbedQuestionBrowser' 11 12 ], 12 function(declare,Deferred,event,lang,content,store,_Page,SurveyListView,TabbedQuestionBrowser){ 13 function(array,declare,Deferred,event,lang,content,store,_Page, 14 OrderedDndList,TabbedQuestionBrowser){ 13 15 return declare('rft.pages.survey',[_Page],{ 14 object: null,15 listView: null,16 survey: null, 17 questionList: null, 16 18 _dataMap: null, 17 19 constructor: function(){ … … 20 22 onVisit: function() { 21 23 if ( this.pageArgs.uid ) { 24 this._setupQuestionBrowser(); 25 this._setupListView(); 22 26 Deferred.when(store.get(this.pageArgs.uid)) 23 27 .then(lang.hitch(this,function(obj){ 24 this. object= obj;25 return Deferred.when( obj.creator && store.dereference(obj.creator));28 this.survey = obj; 29 this.refresh(); 26 30 })); 27 this._setupQuestionBrowser();28 this._setupListView();29 31 } else { 30 32 throw "No valid uid or survey passed!"; 31 33 } 32 },33 onProperties: function(evt) {34 35 },36 onSave: function(evt) {37 // lang.mixin(this.object, this.propertiesForm.get('value'));38 store.put(this.object)39 .then(function() {40 content.goTo('surveys');41 });42 event.stop(evt);43 return false;44 },45 _goToPreview: function() {46 content.goTo('surveyAdvanced', {uid: this.object._id});47 34 }, 48 35 _setupQuestionBrowser: function() { … … 52 39 selectedActions: { 53 40 "Include": { 54 callback: lang.hitch(this,this. includeQuestion),41 callback: lang.hitch(this,this._includeQuestion), 55 42 icon: "Accept", 56 43 description: "Include in survey" … … 67 54 this.questionBrowser.startup(); 68 55 }, 69 /* ListView code */ 70 includeQuestion: function(question) { 71 var item = this.listView.insertItem(question); 56 _includeQuestion: function(question) { 57 this.questionList.insertItem(question); 72 58 }, 73 59 _setupListView: function() { 74 this.listView = new SurveyListView({ 75 controller: this 60 this.questionList = new OrderedDndList({ 61 type: 'question', 62 region: 'center' 76 63 }).placeAt(this.surveyListViewNode); 77 this.listView.startup(); 64 this.questionList.startup(); 65 }, 66 refresh: function() { 67 this.titleNode.innerHTML = this.survey.title || "(set title in properties)"; 68 this.propertiesForm.set('value',this.survey); 69 store.query(null,{keys:this.survey.questions,include_docs:true}) 70 .forEach(lang.hitch(this.questionList,'appendItem')); 71 }, 72 _onShowProperties: function(evt) { 73 this.propertiesDialog.show(); 74 }, 75 _onPropertiesOk: function(evt) { 76 this.propertiesDialog.hide(); 77 lang.mixin(this.survey, this.propertiesForm.get('value')); 78 this.refresh(); 79 event.stop(evt); 80 return false; 81 }, 82 _onPropertiesCancel: function(evt) { 83 this.propertiesDialog.hide(); 84 this.propertiesForm.set('value',this.survey); 85 event.stop(evt); 86 return false; 87 }, 88 _onSave: function(evt) { 89 this.survey.questions = array.map(this.questionList.getItems(),function(item){ 90 return store.getIdentity(item); 91 }); 92 store.put(this.survey) 93 .then(function() { 94 content.goTo('surveys'); 95 }); 96 event.stop(evt); 97 return false; 98 }, 99 _onDiscard: function(evt) { 100 }, 101 _onShowPreview: function() { 102 content.goTo('surveyAdvanced', {uid: store.getIdentity(this.survey)}); 78 103 } 79 104 });
Note: See TracChangeset
for help on using the changeset viewer.