Changeset 410 for Dev/branches/rest-dojo-ui/client/rft/pages
- Timestamp:
- 09/07/12 16:59:14 (13 years ago)
- Location:
- Dev/branches/rest-dojo-ui/client/rft/pages
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
Dev/branches/rest-dojo-ui/client/rft/pages/index.js
r407 r410 1 1 define([ 2 2 'dojo/_base/declare', 3 '../app/ Controller',3 '../app/Router', 4 4 '../app/Page', 5 5 'dojo/text!./index.html' 6 ],function(declare, Controller,Page,template){6 ],function(declare,Router,Page,template){ 7 7 return declare([Page],{ 8 8 templateString: template, … … 11 11 if ( this._started ) { return; } 12 12 this.inherited(arguments); 13 this.btnContentCreate.on("click",function(){ Controller.go("/sessions"); });14 this.btnContentFacilitate.on("click",function(){ Controller.go("/run"); });15 this.btnSurveys.on("click",function(){ Controller.go("/surveys"); });16 this.btnQuestions.on("click",function(){ Controller.go("/questions"); });17 this.btnApplications.on("click",function(){ Controller.go("/applications"); });18 this.btnDashboards.on("click",function(){ Controller.go("/dashboards"); });19 this.btnResults.on("click",function(){ Controller.go("/results"); });13 this.btnContentCreate.on("click",function(){ Router.go("/sessions"); }); 14 this.btnContentFacilitate.on("click",function(){ Router.go("/run"); }); 15 this.btnSurveys.on("click",function(){ Router.go("/surveys"); }); 16 this.btnQuestions.on("click",function(){ Router.go("/questions"); }); 17 this.btnApplications.on("click",function(){ Router.go("/applications"); }); 18 this.btnDashboards.on("click",function(){ Router.go("/dashboards"); }); 19 this.btnResults.on("click",function(){ Router.go("/results"); }); 20 20 } 21 21 }); -
Dev/branches/rest-dojo-ui/client/rft/pages/question.js
r407 r410 5 5 'dojo/_base/lang', 6 6 '../store', 7 '../app/Controller', 7 '../app/Content', 8 '../app/Router', 8 9 '../app/Page', 9 10 '../ui/QuestionEditorPreview', 10 11 '../ui/QuestionEditorToolkit', 11 12 'dojo/text!./question.html' 12 ],function(declare, Deferred, event, lang, store, Cont roller, Page, QuestionEditorPreview, QuestionEditorToolkit, template){13 ],function(declare, Deferred, event, lang, store, Content, Router, Page, QuestionEditorPreview, QuestionEditorToolkit, template){ 13 14 return declare([Page], { 14 15 templateString: template, … … 43 44 store.put(this.question) 44 45 .then(function() { 45 Controller.go('/questions'); 46 Router.go('/questions'); 47 },function(err){ 48 Content.notify(err.reason,'error'); 46 49 }); 47 50 evt && event.stop( evt ); … … 49 52 }, 50 53 _onDiscard: function() { 51 Controller.go('/questions');54 Router.go('/questions'); 52 55 return true; 53 56 }, -
Dev/branches/rest-dojo-ui/client/rft/pages/questions.js
r407 r410 4 4 'dojo/_base/event', 5 5 'dojo/_base/lang', 6 '../app/Controller',7 6 '../store', 7 '../app/Content', 8 '../app/Router', 8 9 '../app/Page', 9 10 '../ui/TabbedQuestionBrowser', 10 11 'dojo/text!./questions.html' 11 ],function(declare,Deferred,event,lang, Controller,store,Page,TabbedQuestionBrowser,template) {12 ],function(declare,Deferred,event,lang,store,Content,Router,Page,TabbedQuestionBrowser,template) { 12 13 return declare([Page],{ 13 14 templateString: template, … … 19 20 'class': 'blue', 20 21 itemActions: { 21 'Edit': {22 Edit: { 22 23 callback: lang.hitch(this,"onEditQuestion"), 23 icon: 'Edit', 24 description: 'Edit question' 24 icon: 'Edit', 25 description: 'Edit question' 26 }, 27 Publish: { 28 callback: lang.hitch(this,"onPublishQuestion"), 29 icon: 'Publish', 30 description: 'Publish question' 25 31 } 26 32 } 27 33 },this.questionBrowser); 28 34 this.questionBrowser.startup(); 29 },30 _refresh: function() {31 Deferred.when(store.query('_design/default/_view/by_type',{key: 'Question'}))32 .then(lang.hitch(this,function(items){33 this._list.setItems(items);34 }));35 35 }, 36 36 onNewQuestion: function() { … … 41 41 }, 42 42 onEditQuestion: function(question) { 43 Controller.go("/question/"+question._id); 43 Router.go("/question/"+question._id); 44 }, 45 onPublishQuestion: function(question) { 46 question.publicationDate = store.timestamp(); 47 store.put(question) 48 .then(function(){ 49 Content.notify("Question puplished."); 50 },function(err){ 51 Content.notify(err.reason,'error'); 52 }); 44 53 } 45 54 }); -
Dev/branches/rest-dojo-ui/client/rft/pages/session.js
r407 r410 2 2 'dojo/_base/array', 3 3 'dojo/_base/declare', 4 'dojo/_base/Deferred', 5 'dojo/_base/event', 4 6 'dojo/_base/lang', 5 'dojo/_base/event', 6 'dojo/_base/Deferred', 7 '../app/Controller', 7 '../search', 8 8 '../store', 9 '../elastic/ElasticSearchFilteringSelect',10 '../elastic/ElasticReadStore',11 9 '../app/Page', 10 '../app/Router', 11 '../ui/ThresholdFilteringSelect', 12 12 '../ui/lists/AccountListView', 13 13 'dojo/text!./session.html' 14 ],function(array,declare, lang,event,Deferred,ElasticSearchFilteringSelect,ElasticReadStore,store,Page,Controller,AccountListView,template){14 ],function(array,declare,Deferred,event,lang,search,store,Page,Router,ThresholdFilteringSelect,AccountListView,template){ 15 15 return declare([Page],{ 16 16 templateString: template, … … 48 48 store.put(this.session) 49 49 .then(function(){ 50 Controller.go('/sessions');50 Router.go('/sessions'); 51 51 }); 52 52 event.stop(evt); … … 56 56 this.propertiesForm.reset(); 57 57 event.stop(evt); 58 Controller.go('/sessions');58 Router.go('/sessions'); 59 59 return false; 60 60 }, … … 70 70 }, 71 71 _setupAutoComplete: function() { 72 var accountStore = new ElasticReadStore({ 73 url: "http://localhost:9200/rft/_search", 74 requestMethod: "POST" 75 }); 76 this._select = new ElasticSearchFilteringSelect({ 77 store: accountStore, 72 this._select = new ThresholdFilteringSelect({ 73 store: search, 78 74 autoComplete: false, 79 75 required: false, -
Dev/branches/rest-dojo-ui/client/rft/pages/sessions.js
r407 r410 4 4 'dojo/date/stamp', 5 5 '../store', 6 '../app/ Controller',6 '../app/Router', 7 7 '../app/Page', 8 8 '../ui/ObjectBox', 9 9 'dojo/text!./sessions.html' 10 ],function(declare,lang,dateStamp,store, Controller,Page,ObjectBox,template){10 ],function(declare,lang,dateStamp,store,Router,Page,ObjectBox,template){ 11 11 return declare([Page],{ 12 12 templateString: template, … … 18 18 this.templateActions = { 19 19 "Edit": function(obj){ 20 Controller.go('/session/'+store.getIdentity(obj));20 Router.go('/session/'+store.getIdentity(obj)); 21 21 }, 22 22 "Delete": lang.hitch(this,function(obj){ … … 30 30 this.sessionActions = { 31 31 "Facilitate": function(obj){ 32 Controller.go('run',{uid:store.getIdentity(obj)});32 Router.go('run',{uid:store.getIdentity(obj)}); 33 33 }, 34 34 "Delete": lang.hitch(this,function(obj){ … … 62 62 }) 63 63 .then(lang.hitch(this,function(obj){ 64 Controller.go('/session/'+store.getIdentity(obj));64 Router.go('/session/'+store.getIdentity(obj)); 65 65 })); 66 66 }, … … 70 70 delete session[store.revProperty]; 71 71 session.type = "SessionInstance"; 72 session.publi shedDate = dateStamp.toISOString(new Date(),{zulu: true});72 session.publicationDate = store.timestamp(); 73 73 session.creator = "Igor Mayer"; 74 74 store.add(session) -
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 }); -
Dev/branches/rest-dojo-ui/client/rft/pages/surveys.html
r407 r410 1 1 <div> 2 <div data-dojo-type="dijit/layout/ContentPane" data-dojo-props="region: 'center'"> 3 <button data-dojo-type="dijit/form/Button" class="blue" data-dojo-props="disabled: true, baseClass: 'rftBlockButton', iconClass: 'rftIcon rftIconEdit'" data-dojo-attach-point="btnEdit">Edit</button> 4 <button data-dojo-type="dijit/form/Button" class="blue" data-dojo-props="baseClass: 'rftBlockButton', iconClass: 'rftIcon rftIconPlus'" data-dojo-attach-point="btnNew">New</button> 5 <div data-dojo-type="dojox/grid/DataGrid" data-dojo-props="autoWidth:true,autoHeight:true,structure:[{name:'Title',field:'title'}]" data-dojo-attach-point="grid"></div> 2 3 <div data-dojo-type="dijit/layout/ContentPane" data-dojo-props="region:'top'"> 4 <h2> 5 <span class="rftIcon rftIconSurvey"></span> 6 <span class="headerText">Surveys</span> 7 </h2> 6 8 </div> 9 10 <div data-dojo-attach-point="tabContainer" data-dojo-type="dijit/layout/TabContainer" class="blue" data-dojo-props="tabPosition:'left-h',region:'center'"> 11 12 <div data-dojo-type="dijit/layout/BorderContainer" title="Drafts" data-dojo-attach-point="draftsTab"> 13 <div data-dojo-type="dijit/layout/ContentPane" data-dojo-props="region: 'center'" data-dojo-attach-point="draftsContainer"> 14 </div> 15 <div data-dojo-type="dijit/layout/ContentPane" data-dojo-props="region: 'bottom'" style="height: 40px;"> 16 <button data-dojo-type="dijit/form/Button" class="blue" data-dojo-props="baseClass: 'rftBlockButton', iconClass: 'rftIcon rftIconNew'" data-dojo-attach-event="onClick:_onNewSurvey">New survey</button> 17 </div> 18 </div> 19 20 <div data-dojo-type="dijit/layout/BorderContainer" title="Published" data-dojo-attach-point="publishedTab"> 21 <div data-dojo-type="dijit/layout/ContentPane" data-dojo-props="region: 'center'" data-dojo-attach-point="publishedContainer"> 22 </div> 23 <div data-dojo-type="dijit/layout/ContentPane" data-dojo-props="region: 'bottom'" style="height: 40px;"> 24 </div> 25 </div> 26 27 <div data-dojo-type="dijit/layout/BorderContainer" title="Runs" data-dojo-attach-point="runsTab"> 28 <div data-dojo-type="dijit/layout/ContentPane" data-dojo-props="region: 'center'" data-dojo-attach-point="runsContainer"> 29 </div> 30 <div data-dojo-type="dijit/layout/ContentPane" data-dojo-props="region: 'bottom'" style="height: 40px;"> 31 </div> 32 </div> 33 </div> 34 7 35 </div> -
Dev/branches/rest-dojo-ui/client/rft/pages/surveys.js
r407 r410 1 1 define([ 2 'dojo/_base/array', 2 3 'dojo/_base/declare', 3 4 'dojo/_base/lang', 4 'dojo/_base/Deferred', 5 'dojo/data/ObjectStore', 6 '../auth', 5 'dojo/when', 7 6 '../store', 8 '../app/Cont roller',7 '../app/Content', 9 8 '../app/Page', 9 '../app/Router', 10 '../ui/LineWithActionsWidget', 10 11 'dojo/text!./surveys.html' 11 ],function( declare,lang,Deferred,ObjectStore,auth,store,Controller,Page,template){12 ],function(array,declare,lang,when,store,Content,Page,Router,LineWithActionsWidget,template){ 12 13 return declare([Page],{ 13 14 templateString: template, 14 selectedObject: null,15 15 startup: function() { 16 16 if ( this._started ) { return; } 17 17 this.inherited(arguments); 18 this.grid.setStore( 19 ObjectStore({objectStore: store}), 20 "_design/default/_view/by_type",{key:'Survey'}); 21 22 this.grid.on('rowclick',lang.hitch(this,function(evt){ 23 this.selectedObject = evt.grid.getItem(evt.rowIndex); 24 this.btnEdit.set('disabled',!this.selectedObject); 18 this.refresh(); 19 }, 20 _onNewSurvey: function(){ 21 when( store.add({type:'Survey'}) ) 22 .then(function(survey) { 23 Router.go('/survey/'+store.getIdentity(survey)); 24 }); 25 }, 26 _onPublishSurvey:function(survey){ 27 var self = this; 28 survey.publicationDate = store.timestamp(); 29 store.put(survey).then(function(){ 30 self.refreshDrafts(); 31 self.refreshPublished(); 32 },function(err){ 33 Content.notify(err.reason,'error'); 34 }); 35 }, 36 _onDeleteSurvey:function(survey){ 37 var self = this; 38 store.remove(store.getIdentity(survey),store.getRevision(survey)) 39 .then(function(){ 40 self.refreshDrafts(); 41 },function(err){ 42 Content.notify(err.reason,'error'); 43 }); 44 }, 45 _onEditSurvey:function(survey){ 46 Router.go('/survey/'+store.getIdentity(survey)); 47 }, 48 _onPreviewSurvey:function(survey){ 49 Router.go('/viewSurvey/'+store.getIdentity(survey),{preview:true}); 50 }, 51 _onRunSurvey:function(survey){ 52 53 }, 54 refresh: function() { 55 this.refreshDrafts(); 56 this.refreshPublished(); 57 this.refreshRuns(); 58 }, 59 refreshDrafts: function() { 60 this.draftsContainer.set('content',''); 61 when(store.query("_design/surveys/_view/drafts") 62 ,lang.hitch(this,function(surveys){ 63 this.draftsTab.set('title','Drafts ('+surveys.length+')'); 64 array.forEach(surveys,function(survey){ 65 var w = new LineWithActionsWidget({ 66 title: survey.title || '(unnamed)', 67 actions: [{ 68 callback: lang.hitch(this,'_onPublishSurvey',survey), 69 properties: { 70 label: 'Publish', 71 tooltip: 'Publish survey', 72 icon: 'Publish' 73 } 74 },{ 75 callback: lang.hitch(this,'_onPreviewSurvey',survey), 76 properties: { 77 label: 'Preview', 78 tooltip: 'Preview survey', 79 icon: 'Preview' 80 } 81 },{ 82 callback: lang.hitch(this,'_onDeleteSurvey',survey), 83 properties: { 84 label: 'Delete', 85 tooltip: 'Delete survey', 86 icon: 'Delete' 87 } 88 },{ 89 callback: lang.hitch(this,'_onEditSurvey',survey), 90 properties: { 91 label: 'Edit', 92 tooltip: 'Edit survey', 93 icon: 'Edit' 94 } 95 }] 96 }); 97 this.draftsContainer.addChild(w); 98 },this); 25 99 })); 26 27 this.grid.on('rowdblclick',lang.hitch(this,function(evt){ 28 var obj = evt.grid.getItem(evt.rowIndex); 29 Controller.go('/survey/'+store.getIdentity(obj)); 100 }, 101 refreshPublished: function() { 102 this.publishedContainer.set('content',''); 103 when(store.query("_design/surveys/_view/published") 104 ,lang.hitch(this,function(surveys){ 105 this.publishedTab.set('title','Published ('+surveys.length+')'); 106 array.forEach(surveys,function(survey){ 107 var w = new LineWithActionsWidget({ 108 title: survey.title, 109 actions:[{ 110 callback: lang.hitch(this,'_onPreviewSurvey',survey), 111 properties: { 112 label: 'Preview', 113 tooltip: 'Preview survey', 114 icon: 'Preview' 115 } 116 },{ 117 callback: lang.hitch(this,'_onRunSurvey',survey), 118 properties: { 119 label: 'Run', 120 tooltip: 'Run survey', 121 icon: 'Run' 122 } 123 }] 124 }); 125 this.publishedContainer.addChild(w); 126 },this); 30 127 })); 31 32 this.btnNew.on('click',lang.hitch(this,function(){ 33 Deferred.when( store.add({type:'Survey',creator:auth.getUser()}) ) 34 .then(function(obj) { 35 Controller.go('/survey/'+store.getIdentity(obj)); 36 }); 37 })); 38 39 this.btnEdit.on('click',lang.hitch(this,function(){ 40 if ( this.selectedObject ) { 41 Controller.go('/survey/'+store.getIdentity(this.selectedObject)); 42 } 43 128 }, 129 refreshRuns: function() { 130 this.runsContainer.set('content',''); 131 when(store.query("_design/default/_view/by_type",{key:'SurveyRun'}) 132 ,lang.hitch(this,function(surveyRuns){ 133 this.runsTab.set('title','Runs ('+surveyRuns.length+')'); 134 array.forEach(surveyRuns,function(surveyRun){ 135 var w = new LineWithActionsWidget({ 136 title: survey.title, 137 actions:[{ 138 callback: lang.hitch(this,'_onCloseRun',surveyRun), 139 properties: { 140 label: 'Close', 141 tooltip: 'Close survey', 142 icon: 'Close' 143 } 144 }] 145 }); 146 this.runsContainer.addChild(w); 147 },this); 44 148 })); 45 149 } -
Dev/branches/rest-dojo-ui/client/rft/pages/viewSurvey.html
r407 r410 16 16 </div> 17 17 18 <div data-dojo- type="dijit/layout/ContentPane" data-dojo-props="region:'bottom'">18 <div data-dojo-attach-point="buttonsPane" data-dojo-type="dijit/layout/ContentPane" data-dojo-props="region:'bottom'"> 19 19 <button data-dojo-type="dijit/form/Button" 20 20 type="submit" -
Dev/branches/rest-dojo-ui/client/rft/pages/viewSurvey.js
r407 r410 13 13 templateString: template, 14 14 survey: null, 15 surveyId: "", 16 options: null, 15 17 constructor: function(){ 16 18 this._dataMap = {}; 19 this.options = this.options || {}; 17 20 }, 18 21 startup: function() { 19 22 if ( this._started ) { return; } 20 23 this.inherited(arguments); 24 25 21 26 if ( this.surveyId ) { 22 27 Deferred.when(store.get(this.surveyId)) 23 .then(lang.hitch(this,function(obj){ 28 .then(lang.hitch(this,function(survey){ 29 if ( !survey.published ) { 30 this.options.preview = true; 31 } 32 if ( this.options.preview ) { 33 this.buttonsPane.destroyRecursive(); 34 } 35 this.titleNode.innerHTML = survey.title + 36 (this.options.preview?' [preview]':''); 24 37 var f = new ContentWidgetFactory(); 25 this.survey = obj;38 this.survey = survey; 26 39 store.query(null,{keys:this.survey.questions,include_docs:true}) 27 40 .forEach(function(question){ … … 37 50 })); 38 51 } else { 39 throw "No valid uid or survey passed!";52 throw new Error("No valid uid or survey passed!"); 40 53 } 41 54 }, 42 55 _onSubmit: function(evt) { 56 if ( this.options.preview ) { return; } 43 57 var value = this.questionsForm.get('value'); 44 58 this.questionsPane.set('content','<pre>'+JSON.stringify(value)+'</pre>'); … … 47 61 }, 48 62 _onCancel: function(evt) { 63 if ( this.options.preview ) { return; } 49 64 event.stop(evt); 50 65 return false;
Note: See TracChangeset
for help on using the changeset viewer.