- Timestamp:
- 03/12/14 15:16:54 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
Dev/trunk/src/client/qed-client/model/classes/responses.js
r509 r510 1 1 define([ 2 "../../lib/object", 2 3 "./_Class", 3 4 "./surveyRuns", … … 7 8 "dojo/_base/lang", 8 9 "dojo/_base/xhr" 9 ], function( _Class, surveyRuns, Deferred, declare, json, lang, xhr) {10 ], function(objectFuns, _Class, surveyRuns, Deferred, declare, json, lang, xhr) { 10 11 11 12 var Responses = declare([_Class],{ … … 29 30 }, 30 31 _serialize: function(obj) { 32 this._convertCheckAndRadio(obj.answers); 31 33 if (obj._surveyRun) { 32 34 obj._surveyRun = surveyRuns._doSerialize(obj._surveyRun); … … 84 86 return result; 85 87 },lang.hitch(this,'_deserializeError')); 88 }, 89 _convertCheckAndRadio: function(answers) { 90 // When we encounter an array, we assume it's really a 91 // checkbox value. 92 objectFuns.forEach(answers,function(v,prop){ 93 if ( lang.isArray(v) ) { 94 switch (v.length) { 95 case 0: 96 case 1: 97 answers[prop] = v[0]; 98 break; 99 default: 100 throw new Error("Responses cannot exist of array values."); 101 } 102 } 103 },this); 86 104 } 87 105 });
Note: See TracChangeset
for help on using the changeset viewer.