Changeset 379
- Timestamp:
- 07/26/12 21:57:20 (13 years ago)
- Location:
- Dev/branches/rest-dojo-ui/client/rft
- Files:
-
- 4 edited
- 2 moved
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 }); -
Dev/branches/rest-dojo-ui/client/rft/run.js
r378 r379 8 8 'dojo/data/ObjectStore', 9 9 'dojo/store/JsonRest', 10 'dijit/Dialog', 10 11 'dijit/InlineEditBox', 11 12 'dijit/MenuBar', -
Dev/branches/rest-dojo-ui/client/rft/store.js
r363 r379 141 141 var dfd = new Deferred(); 142 142 var queryOpts = {}; 143 if ( query === undefined) {143 if ( !query ) { 144 144 query = '_all_docs'; 145 145 } -
Dev/branches/rest-dojo-ui/client/rft/ui/OrderedDndList.js
r378 r379 1 1 define([ 2 2 'dojo/_base/declare', 3 'dojo/_base/lang', 4 'dojo/dnd/Source', 5 'dojo/dom-construct', 6 'dijit/_Container', 7 'dijit/_TemplatedMixin', 3 8 'dijit/_WidgetBase', 4 'dijit/_TemplatedMixin',5 'dojo/_base/lang',6 'dojo/fx',7 'dojo/_base/fx',8 9 'dijit/_WidgetsInTemplateMixin', 9 'dijit/ _Container',10 'dijit/form/Button', 10 11 'rft/ui/LineWithActionsWidget', 11 'dojo/text!./templates/ SurveyListView.html'12 'dojo/text!./templates/OrderedDndList.html' 12 13 ],function( 13 14 declare, 15 lang, 16 Source, 17 domConstruct, 18 _Container, 19 _TemplatedMixin, 14 20 _WidgetBase, 15 _TemplatedMixin,16 lang,17 fx,18 baseFx,19 21 _WidgetsInTemplateMixin, 20 _Container,22 Button, 21 23 LineWithActionsWidget, 22 24 templateString 23 24 return declare('rft.ui. SurveyListView',[_WidgetBase,_TemplatedMixin,_WidgetsInTemplateMixin,_Container],{25 ){ 26 return declare('rft.ui.OrderedDndList',[_WidgetBase,_TemplatedMixin,_WidgetsInTemplateMixin,_Container],{ 25 27 templateString: templateString, 26 28 baseClass: 'rftSurveyListView', 29 type: 'text', 27 30 source: null, 28 region: 'center',29 31 30 32 postCreate: function() { … … 35 37 } 36 38 37 this.source = new dojo.dnd.Source(this.sourceNode, { 38 isSource: true, 39 accept: ["SurveyListViewItem"], 39 this.source = new Source(this.sourceNode, { 40 accept: [this.type], 40 41 horizontal: false, 41 withHandles: false,42 copyOnly: false,43 selfCopy: false,44 selfAccept: true,45 delay: 0,46 42 singular: true, 47 creator: lang.hitch(this, this. creatorMethod)43 creator: lang.hitch(this, this._createQuestionDndItem) 48 44 }); 49 45 50 new dijit.form.Button({46 new Button({ 51 47 label: "Move up", 52 48 showLabel: false, … … 55 51 'class': "trans", 56 52 onClick: lang.hitch(this, function() { 57 this. moveItem("up");53 this._moveSelectedItem("up"); 58 54 }) 59 55 }, this.btnListMoveUp); 60 56 61 new dijit.form.Button({57 new Button({ 62 58 label: "Move down", 63 59 showLabel: false, … … 66 62 'class': "trans", 67 63 onClick: lang.hitch(this, function() { 68 this. moveItem("down");64 this._moveSelectedItem("down"); 69 65 }) 70 66 }, this.btnListMoveDown); 71 67 }, 72 creatorMethod: function(item, hint) {68 _createQuestionDndItem: function(item, hint) { 73 69 var node; 74 70 75 71 if (hint == "avatar") { 76 node = document.createElement("div"); 77 node.className = "dragAvatar"; 78 node.innerHTML = item.title; 72 node = domConstruct.create("div",{ 73 'class': 'dragAvatar', 74 innerHTML: item.title 75 }); 79 76 } else { 80 77 var w = new LineWithActionsWidget({ … … 83 80 actions: { 84 81 "Remove" : { 82 // w not bound in hitch, because it's 83 // not initialized when hitch is called. 85 84 callback: lang.hitch(this, function(){ 86 this. removeItem(item,w);85 this._removeItem(w); 87 86 }), 88 87 properties: { … … 107 106 node = w.domNode; 108 107 } 109 var fullItem ={108 return { 110 109 node: node, 111 110 data: item, 112 type: " SurveyListViewItem"111 type: "question" 113 112 }; 114 return fullItem;115 113 }, 116 moveItem: function(dir) {114 _moveSelectedItem: function(dir) { 117 115 var node = this.source.getSelectedNodes()[0]; 118 116 if (node) { … … 142 140 this.source.insertNodes(false,[item], false, anchor); 143 141 } else { 144 this. source.insertNodes(false,[item]);142 this.appendItem(item); 145 143 } 146 144 }, 147 removeItem: function(item,widget){ 145 appendItem: function(item) { 146 this.source.insertNodes(false,[item]); 147 }, 148 getItems: function() { 149 return this.source.getAllNodes() 150 .map(function(node){ 151 return this.source.getItem(node.id).data; 152 },this); 153 }, 154 deleteItems: function() { 155 this.source.getAllNodes() 156 .forEach(function(node){ 157 node.destroy(); 158 }); 159 this.source.sync(); 160 }, 161 _removeItem: function(widget){ 148 162 widget.destroy(); 163 this.source.sync(); 149 164 } 150 165 }); 151 });166 });
Note: See TracChangeset
for help on using the changeset viewer.