Changeset 379 for Dev/branches/rest-dojo-ui/client/rft/pages
- Timestamp:
- 07/26/12 21:57:20 (13 years ago)
- Location:
- Dev/branches/rest-dojo-ui/client/rft/pages
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
Dev/branches/rest-dojo-ui/client/rft/pages/survey.html
r370 r379 5 5 <h2> 6 6 <span class="rftIcon rftIconSurvey"></span> 7 <span class="headerText" data- dojo-attach-point="header">Survey A [editing]</span>7 <span class="headerText" data-rft-attach-point="titleNode">Survey Editor</span> 8 8 </h2> 9 9 </div> … … 18 18 19 19 <div data-dojo-type="dijit.layout.ContentPane" data-dojo-props="region: 'bottom'"> 20 <button data-rft-attach-point="btnProperties" data-dojo-type="dijit.form.Button" data-rft-attach-event="onClick:onProperties" data-dojo-props="baseClass: 'rftLargeButton', iconClass: 'rftIcon rftIconProperties'">Properties</button> 21 <button data-rft-attach-point="btnSave" data-dojo-type="dijit.form.Button" data-rft-attach-event="onClick:onSave" data-dojo-props="baseClass: 'rftLargeButton', iconClass: 'rftIcon rftIconAccept'">Save Changes</button> 22 <button data-rft-attach-point="btnDiscard" data-dojo-type="dijit.form.Button" data-dojo-props="baseClass: 'rftLargeButton', iconClass: 'rftIcon rftIconCancel'">Discard changes</button> 23 <button data-rft-attach-point="btnPreview" data-dojo-type="dijit.form.Button" data-dojo-props="baseClass: 'rftLargeButton', iconClass: 'rftIcon rftIconPreview'">Preview</button> 20 <button data-dojo-type="dijit.form.Button" 21 data-rft-attach-event="onClick:_onShowProperties" 22 data-dojo-props="baseClass: 'rftLargeButton', iconClass: 'rftIcon rftIconProperties'"> 23 Properties</button> 24 <button data-dojo-type="dijit.form.Button" 25 data-rft-attach-event="onClick:_onSave" 26 data-dojo-props="baseClass: 'rftLargeButton', iconClass: 'rftIcon rftIconAccept'"> 27 Save Changes</button> 28 <button data-dojo-type="dijit.form.Button" 29 data-rft-attach-event="onClick:_onDiscard" 30 data-dojo-props="baseClass: 'rftLargeButton', iconClass: 'rftIcon rftIconCancel'"> 31 Discard changes</button> 32 <button data-dojo-type="dijit.form.Button" 33 data-rft-attach-event="onClick:_onShowPreview" 34 data-dojo-props="baseClass: 'rftLargeButton', iconClass: 'rftIcon rftIconPreview'"> 35 Preview</button> 24 36 </div> 25 37 </div> 26 38 </div> 39 40 <div data-dojo-type="dijit.Dialog" 41 title="Survey properties" 42 data-rft-attach-point="propertiesDialog" 43 data-rft-attach-event="onSubmit:_onPropertiesOk"> 44 45 <form data-dojo-type="dijit.form.Form" 46 data-rft-attach-point="propertiesForm"> 47 <label for="title">Title</label> 48 <input data-dojo-type="dijit.form.TextBox" name="title"/> 49 </form> 50 51 <div> 52 <button data-dojo-type="dijit.form.Button" 53 type="submit" 54 data-rft-attach-event="onClick:_onPropertiesOk"> 55 OK</button> 56 <button data-dojo-type="dijit.form.Button" 57 type="button" 58 data-rft-attach-event="onClick:_onPropertiesCancel"> 59 Cancel</button> 60 </div> 61 </div> 62 27 63 </div> -
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.