Changeset 421 for Dev/branches/rest-dojo-ui/client/qed/pages/surveyRun.js
- Timestamp:
- 12/27/12 17:46:05 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
Dev/branches/rest-dojo-ui/client/qed/pages/surveyRun.js
r420 r421 10 10 '../app/Page', 11 11 '../model/classes/SurveyRun', 12 '../widgets/LineWithActionsWidget', 12 13 'dojo/text!./templates/surveyRun.html' 13 ],function(declare,event,lang,when,Content,Router,func,store,Page,SurveyRun, template){14 ],function(declare,event,lang,when,Content,Router,func,store,Page,SurveyRun,LineWithActionsWidget,template){ 14 15 return declare([Page],{ 15 16 templateString: template, … … 21 22 if ( this.surveyRunId ) { 22 23 this._loadSurveyRun(); 24 this._loadResponses(); 23 25 } else { 24 26 throw "No valid uid or survey passed!"; … … 29 31 .then(lang.hitch(this,function(surveyRun){ 30 32 this.surveyRun = surveyRun; 31 this.refresh ();33 this.refreshSurveyRun(); 32 34 })); 33 35 }, 34 refresh : function() {36 refreshSurveyRun: function() { 35 37 this.titleNode.innerHTML = SurveyRun.DisplayTitle.get(this.surveyRun); 36 38 this.surveyNode.set('value',SurveyRun.Survey.get(this.surveyRun)); … … 38 40 this._onPropChange(); 39 41 }, 42 _loadResponses: function() { 43 when(store.query("_design/responses/_view/by_surveyrun",{key:this.surveyRunId})) 44 .forEach(lang.hitch(this,function(response){ 45 var actions = { 46 view: { 47 callback: function(){}, 48 properties: { 49 title: "View response" 50 } 51 } 52 }; 53 if ( !response.publicationDate ) { 54 actions.remove = { 55 callback: function(){}, 56 properties: { 57 title: "Remove response" 58 } 59 }; 60 } 61 var w = new LineWithActionsWidget({ 62 actions: actions 63 }); 64 var responseId = store.getIdentity(response); 65 w.set('title',this._link(this._getResponseURL(this.surveyRunId,responseId),responseId)); 66 w.placeAt(this.responsesNode); 67 })); 68 }, 40 69 _onPropChange: function(e) { 41 70 var surveyRun = this.propertiesForm.get('value'); 42 71 if ( surveyRun.mode === "open" ) { 43 var url = 'response.html#!/'+store.getIdentity(this.surveyRun); 44 this.runURLNode.innerHTML = '<a target="_black" href="'+url+'">'+url+'</a>'; 72 this.runURLNode.innerHTML = this._link(this._getGeneralURL(store.getIdentity(this.surveyRun))); 45 73 } else { 46 74 this.runURLNode.innerHTML = "No general URL. Add individual respondents below."; 47 75 } 76 }, 77 _getGeneralURL: function(surveyRunId) { 78 return 'response.html#!/'+surveyRunId; 79 }, 80 _getResponseURL: function(surveyRunId,responseId) { 81 return 'response.html#!/'+surveyRunId+'!id='+responseId; 82 }, 83 _link: function(url,label) { 84 return '<a target="_black" href="'+url+'">'+(label || url)+'</a>'; 48 85 }, 49 86 _onSave: function(evt) {
Note: See TracChangeset
for help on using the changeset viewer.