- Timestamp:
- 03/05/14 22:44:48 (11 years ago)
- Location:
- Dev/trunk/src/client/qed-client/model/classes
- Files:
-
- 1 edited
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
Dev/trunk/src/client/qed-client/model/classes
-
Property
svn:ignore
set to
### begin grunt-svn-ignore managed ignores
### edits will be overwritten when grunt svn-ignore is run
Question.js
Response.js
Survey.js
SurveyRun.js
### end grunt-svn-ignore managed ignores
-
Property
svn:ignore
set to
-
Dev/trunk/src/client/qed-client/model/classes/responses.js
r486 r487 1 define([],function(){ 2 var SurveyRun = { 3 create: function(){ 4 return { type:'Response' }; 1 define([ 2 "./_Class", 3 "./surveyRuns", 4 "dojo/Deferred", 5 "dojo/_base/declare", 6 "dojo/_base/json", 7 "dojo/_base/lang", 8 "dojo/_base/xhr", 9 "dojo/date/stamp" 10 ], function(_Class, surveyRuns, Deferred, declare, json, lang, xhr, stamp) { 11 12 var Responses = declare([_Class],{ 13 _collection: 'responses', 14 _type: 'Response', 15 create: function() { 16 var obj = { 17 type: this._type, 18 answers: {}, 19 surveyRunId: null 20 }; 21 return obj; 5 22 }, 6 SurveyRun: { 7 get: function(r) { 8 return r.surveyRunId || null; 9 }, 10 set: function(r,sr) { 11 r.surveyRunId = sr; 12 return r; 23 _deserialize: function(obj) { 24 if (obj._surveyRun) { 25 obj._surveyRun = surveyRuns._doDeserialize(obj._surveyRun); 13 26 } 27 if (obj.publicationDate) { 28 obj.publicationDate = stamp.fromISOString(obj.publicationDate); 29 } 30 }, 31 _serialize: function(obj) { 32 if (obj._surveyRun) { 33 obj._surveyRun = surveyRuns._doSerialize(obj._surveyRun); 34 } 35 if (obj.publicationDate) { 36 obj.publicationDate = stamp.toISOString(obj.publicationDate); 37 } 38 }, 39 getWithSecret: function(id,secret) { 40 var query = xhr.objectToQuery({secret:secret}); 41 return xhr('GET',{ 42 url: '/api/open/responses/' + id + '?' + query, 43 handleAs: 'json', 44 contentType: false 45 }).then(lang.hitch(this,'_doDeserialize'),function(err){ 46 return new Deferred().reject(json.fromJson(err.responseText)); 47 }); 48 }, 49 postWithSecret: function(response,secret) { 50 var query = xhr.objectToQuery({secret:secret}); 51 var body = json.toJson(this._doSerialize(response)); 52 return xhr('POST',{ 53 url: '/api/open/responses?' + query, 54 handleAs: 'json', 55 contentType: 'application/json', 56 rawBody: body 57 }).then(lang.hitch(this,'_doDeserialize'),function(err){ 58 return new Deferred().reject(json.fromJson(err.responseText)); 59 }); 60 }, 61 putWithSecret: function(response,secret) { 62 var query = xhr.objectToQuery({secret:secret}); 63 var body = json.toJson(this._doSerialize(response)); 64 return xhr('PUT',{ 65 url: '/api/open/responses/' + this.getId(response) + '?' + query, 66 handleAs: 'json', 67 contentType: 'application/json', 68 rawBody: body 69 }).then(lang.hitch(this,'_doDeserialize'),function(err){ 70 return new Deferred().reject(json.fromJson(err.responseText)); 71 }); 72 }, 73 removeWithSecret: function(response,secret) { 74 var query = xhr.objectToQuery({secret:secret}); 75 var rev = this.getRev(response); 76 var body = json.toJson(this._doSerialize(response)); 77 var headers = {}; 78 if ( rev ) { 79 headers['If-Match'] = '"'+rev+'"'; 80 } 81 return xhr('DELETE',{ 82 url: '/api/open/responses/' + this.getId(response) + '?' + query, 83 headers: headers, 84 handleAs: 'json', 85 contentType: 'application/json', 86 rawBody: body 87 }); 14 88 } 15 }; 16 return SurveyRun; 89 }); 90 91 return new Responses(); 92 17 93 });
Note: See TracChangeset
for help on using the changeset viewer.