Changeset 531 for Dev/trunk/src/client/qed-client/pages/surveys.js
- Timestamp:
- 03/27/14 14:44:36 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
Dev/trunk/src/client/qed-client/pages/surveys.js
r529 r531 18 18 this.draftsTab.set('title','Drafts (<span class="qedLoading"></span>)'); 19 19 this.publishedTab.set('title','Published (<span class="qedLoading"></span>)'); 20 this.runsTab.set('title','Runs (<span class="qedLoading"></span>)');21 20 this.refresh(); 22 21 }, … … 56 55 _onRunSurvey:function(survey){ 57 56 var surveyRun = surveyRuns.create(); 58 surveyRun.title = 'Run of "' + survey.title + '" of '+(new Date().toString()); 57 surveyRun.title = 'Run of "'+survey.title+'" of '+ 58 (new Date().toString()); 59 59 surveyRun.survey = survey; 60 60 surveyRuns.save(surveyRun) 61 61 .then(lang.hitch(this,function(surveyRun){ 62 this._onRunDetails(surveyRun); 63 }),lang.hitch(this,function(err){ 64 this.notify(err.error,'error'); 65 })); 66 }, 67 _onRunDetails: function(surveyRun) { 68 Router.go(surveyRuns.getObjectPath(surveyRun)); 69 }, 70 _onRunDelete: function(surveyRun) { 71 if ( !confirm("Are you sure you want to delete this survey run?") ) { 72 return; 73 } 74 surveyRuns.remove(surveyRun) 75 .then(lang.hitch(this,function(){ 76 this.notify("SurveyRun successfully deleted."); 77 this.refreshRuns(); 62 Router.go(surveyRuns.getObjectPath( 63 surveyRuns.getId(surveyRun))); 78 64 }),lang.hitch(this,function(err){ 79 65 this.notify(err.error,'error'); … … 83 69 this.refreshDrafts(); 84 70 this.refreshPublished(); 85 this.refreshRuns();86 71 }, 87 72 refreshDrafts: function() { 88 this.draftsContainer.set('content',' ');73 this.draftsContainer.set('content','Loading draft surveys <span class="qedLoading"></span>'); 89 74 when(surveys.query({drafts:true}), lang.hitch(this,function(surveys) { 90 75 this.draftsTab.set('title','Drafts ('+surveys.length+')'); 76 this.draftsContainer.set('content',''); 91 77 array.forEach(surveys,function(survey){ 92 78 var w = new LineWithActionsWidget({ … … 127 113 }, 128 114 refreshPublished: function() { 129 this.publishedContainer.set('content',' ');115 this.publishedContainer.set('content','Loading published surveys <span class="qedLoading"></span>'); 130 116 when(surveys.query({published:true}), lang.hitch(this, function(surveys) { 117 this.publishedContainer.set('content',''); 131 118 this.publishedTab.set('title','Published ('+surveys.length+')'); 132 119 array.forEach(surveys,function(survey){ … … 152 139 },this); 153 140 })); 154 },155 refreshRuns: function() {156 this.runsContainer.set('content','');157 when(surveyRuns.query(), lang.hitch(this,function(surveyRuns){158 this.runsTab.set('title','Runs ('+surveyRuns.length+')');159 array.forEach(surveyRuns,function(surveyRun){160 var w = new LineWithActionsWidget({161 title: surveyRun.title || "",162 actions:[{163 callback: lang.hitch(this,'_onRunDetails',surveyRun),164 properties: {165 label: 'Details',166 tooltip: 'Show details for this run',167 icon: 'Edit'168 }169 },{170 callback: lang.hitch(this,'_onRunDelete',surveyRun),171 properties: {172 label: 'Delete',173 tooltip: 'Delete this run',174 icon: 'Delete'175 }176 }]177 });178 this.runsContainer.addChild(w);179 },this);180 }));181 141 } 182 142 });
Note: See TracChangeset
for help on using the changeset viewer.