Changeset 487 for Dev/trunk/src/client/qed-client/pages/surveys.js
- Timestamp:
- 03/05/14 22:44:48 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
Dev/trunk/src/client/qed-client/pages/surveys.js
r443 r487 1 1 define([ 2 'dojo/_base/array', 3 'dojo/_base/declare', 4 'dojo/_base/lang', 5 'dojo/when', 6 '../store', 7 '../app/Content', 8 '../app/Page', 9 '../app/Router', 10 '../model/classes/Survey', 11 '../model/classes/SurveyRun', 12 '../widgets/LineWithActionsWidget', 13 'dojo/text!./templates/surveys.html' 14 ],function(array,declare,lang,when,store,Content,Page,Router,Survey,SurveyRun,LineWithActionsWidget,template){ 2 "../app/Content", 3 "../app/Page", 4 "../app/Router", 5 "../model/classes/surveys", 6 "../model/classes/surveyRuns", 7 "../widgets/LineWithActionsWidget", 8 "dojo/_base/array", 9 "dojo/_base/declare", 10 "dojo/_base/lang", 11 "dojo/when", 12 "dojo/text!./templates/surveys.html" 13 ], function(Content, Page, Router, surveys, surveyRuns, LineWithActionsWidget, array, declare, lang, when, template) { 15 14 return declare([Page],{ 16 15 templateString: template, … … 25 24 _onPublishSurvey:function(survey){ 26 25 var self = this; 27 survey.publicationDate = store.timestamp(); 28 store.put(survey).then(function(){ 26 survey.publicationDate = new Date(); 27 surveys.save(survey) 28 .then(function(){ 29 29 self.refreshDrafts(); 30 30 self.refreshPublished(); … … 35 35 _onDeleteSurvey:function(survey){ 36 36 var self = this; 37 s tore.remove(store.getIdentity(survey),store.getRevision(survey))37 surveys.remove(survey) 38 38 .then(function(){ 39 39 self.refreshDrafts(); … … 43 43 }, 44 44 _onEditSurvey:function(survey){ 45 Router.go('/survey/'+s tore.getIdentity(survey));45 Router.go('/survey/'+survey._id); 46 46 }, 47 47 _onPreviewSurvey:function(survey){ 48 Router.go('/previewSurvey/'+s tore.getIdentity(survey));48 Router.go('/previewSurvey/'+survey._id); 49 49 }, 50 50 _onRunSurvey:function(survey){ 51 var surveyRun = SurveyRun.create();52 SurveyRun.Survey.set(surveyRun,survey);53 s tore.put(surveyRun)51 var surveyRun = surveyRuns.create(); 52 surveyRun.survey = survey; 53 surveyRuns.save(surveyRun) 54 54 .then(lang.hitch(this,function(surveyRun){ 55 55 this._onRunDetails(surveyRun); … … 59 59 }, 60 60 _onRunDetails: function(surveyRun) { 61 Router.go('/surveyRun/'+s tore.getIdentity(surveyRun));61 Router.go('/surveyRun/'+surveyRun._id); 62 62 }, 63 63 refresh: function() { … … 68 68 refreshDrafts: function() { 69 69 this.draftsContainer.set('content',''); 70 when(store.query("_design/surveys/_view/drafts"), 71 lang.hitch(this,function(surveys) { 70 when(surveys.query({drafts:true}), lang.hitch(this,function(surveys) { 72 71 this.draftsTab.set('title','Drafts ('+surveys.length+')'); 73 72 array.forEach(surveys,function(survey){ 74 73 var w = new LineWithActionsWidget({ 75 title: Survey.DisplayTitle.get(survey)|| '(unnamed)',74 title: survey.title || '(unnamed)', 76 75 actions: [{ 77 76 callback: lang.hitch(this,'_onPublishSurvey',survey), … … 110 109 refreshPublished: function() { 111 110 this.publishedContainer.set('content',''); 112 when(store.query("_design/surveys/_view/published"), 113 lang.hitch(this, function(surveys) { 111 when(surveys.query({published:true}), lang.hitch(this, function(surveys) { 114 112 this.publishedTab.set('title','Published ('+surveys.length+')'); 115 113 array.forEach(surveys,function(survey){ 116 114 var w = new LineWithActionsWidget({ 117 title: Survey.DisplayTitle.get(survey),115 title: survey.title || "", 118 116 actions:[{ 119 117 callback: lang.hitch(this,'_onPreviewSurvey',survey), … … 138 136 refreshRuns: function() { 139 137 this.runsContainer.set('content',''); 140 when(store.query("_design/default/_view/by_type",{key:'SurveyRun'}), 141 lang.hitch(this,function(surveyRuns){ 138 when(surveyRuns.query(), lang.hitch(this,function(surveyRuns){ 142 139 this.runsTab.set('title','Runs ('+surveyRuns.length+')'); 143 140 array.forEach(surveyRuns,function(surveyRun){ 144 141 var w = new LineWithActionsWidget({ 145 title: SurveyRun.DisplayTitle.get(surveyRun),142 title: surveyRun.title || "", 146 143 actions:[{ 147 144 callback: lang.hitch(this,'_onRunDetails',surveyRun),
Note: See TracChangeset
for help on using the changeset viewer.