- Timestamp:
- 10/16/13 16:05:39 (12 years ago)
- Location:
- Dev/trunk/src
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
Dev/trunk/src/client/qed-client/pages/response.js
r477 r478 63 63 this.submitButton.set('disabled',false); 64 64 this.continueButton.set('disabled',false); 65 this.cancelButton.set('disabled',false); 65 66 this.surveyWidget.set('disabled', false); 66 67 }, … … 68 69 this.submitButton.set('disabled',true); 69 70 this.continueButton.set('disabled',true); 71 this.cancelButton.set('disabled',true); 70 72 this.surveyWidget.set('disabled', true); 71 73 }, … … 80 82 data:json.toJson(this.response), 81 83 headers:{"Content-Type": "application/json"} 82 }).then(function(){ 84 }).then(lang.hitch(this,function(res){ 85 this.response._rev = res.rev; 83 86 Content.notify("Your response is saved."); 84 } , function(err){87 }), function(err){ 85 88 Content.notify(err,'error'); 86 89 }); … … 104 107 return false; 105 108 }, 109 _onCancel: function(e) { 110 this._disableSubmit(); 111 this.surveyWidget.destroy(); 112 request('/api/responses/'+store.getIdentity(this.response)+'?rev='+store.getRevision(this.response),{ 113 method: 'DELETE', 114 handleAs:'json', 115 data:json.toJson(this.response), 116 headers:{"Content-Type": "application/json"} 117 }).then(lang.hitch(this,function(res){ 118 this._showInfo("<div>Your response has been deleted, no answers have been saved.</div>"); 119 Content.notify("Your response is deleted."); 120 }), function(err){ 121 Content.notify(err,'error'); 122 }); 123 if ( e ) { event.stop(e); } 124 return false; 125 }, 106 126 _ignoreEvent: function(e) { 107 127 if ( e ) { event.stop(e); } -
Dev/trunk/src/client/qed-client/pages/templates/response.html
r463 r478 29 29 data-dojo-attach-point="continueButton" 30 30 data-dojo-attach-event="onClick:_onContinueLater"> 31 Continue later</button> 31 Save & Continue later</button> 32 <button data-dojo-type="dijit/form/Button" 33 type="button" 34 data-dojo-attach-point="cancelButton" 35 data-dojo-attach-event="onClick:_onCancel"> 36 Cancel & Delete</button> 32 37 </div> 33 38 -
Dev/trunk/src/client/qed-client/store.js
r468 r478 10 10 11 11 var couchStore = new CouchStore({ 12 target: ' api/data/',12 target: '/data/', 13 13 request: request /*, 14 14 validate: function(object) { -
Dev/trunk/src/server/app.js
r477 r478 48 48 49 49 // cookies and session 50 app.use('/api',express.bodyParser());51 50 app.use(express.cookieParser()); 52 51 app.use(express.session({ secret: "quasi experimental design" })); 52 app.use('/api',express.bodyParser()); 53 53 54 54 // passport … … 77 77 }); 78 78 79 // data is proxied to couch 80 app.use('/data', ensureAuthenticated); 81 app.use('/data', proxy(settings.couchDbURL)); 79 82 80 83 // post to this url to login … … 99 102 }); 100 103 101 // expose everything needed to fill in responses102 // FIXME : this needs more security, now you can guess ids103 // and get actual survey and response data!104 app.get(105 '/live',106 function(req,res){107 res.redirect('/response.html#!/55704d6a84194c2d7ba9bec93c000e75');108 });109 104 app.get( 110 105 '/api/surveyRuns/:id', … … 155 150 }); 156 151 }); 152 app.delete( 153 '/api/responses/:id', 154 function(req,res){ 155 var id = req.params.id; 156 var rev = req.query.rev; 157 couch.delete(id,rev).then(function(result){ 158 res.send(200, result); 159 }, function(error){ 160 res.send(500, error); 161 }); 162 }); 157 163 158 // data is proxied to couch159 app.use('/api/data', ensureAuthenticated);160 app.use('/api/data', proxy(settings.couchDbURL));161 162 164 // generate CSV download of responses 163 165 app.get( … … 224 226 } 225 227 226 function writeObjectsToCSVStream(objects, stream ) {228 function writeObjectsToCSVStream(objects, stream, prelude) { 227 229 var keys = _.chain(objects) 228 230 .map(_.keys) … … 235 237 }); 236 238 var writer = new CSV.CsvWriter(stream); 239 if ( prelude ) { 240 _.forEach(prelude, function(val,key){ 241 writer.writeRecord([key,val]); 242 }); 243 } 237 244 writer.writeRecord(keys); 238 245 _.forEach(objects, function(obj){ -
Dev/trunk/src/server/util/couch.coffee
r477 r478 15 15 url = "#{@url}/#{id}" 16 16 couchRequest 'PUT', url, doc 17 delete: (id, rev) -> 18 url = "#{@url}/#{id}?rev=#{rev}" 19 couchRequest 'DELETE', url 17 20 18 21 normalizeURL = (url) ->
Note: See TracChangeset
for help on using the changeset viewer.