Ignore:
Timestamp:
03/12/14 15:16:54 (11 years ago)
Author:
hendrikvanantwerpen
Message:
  • Factored out general object mapping and iteration.
  • Split widgets for multiplechoice and singlechoice.
  • Restored readOnly/disabled setting for QuestionEditorPreviewItem? on innerWidget (since view innerWidget is not a form anymore, we cannot just set it on that, we iterate over all form children now).
File:
1 edited

Legend:

Unmodified
Added
Removed
  • Dev/trunk/src/client/qed-client/model/classes/responses.js

    r509 r510  
    11define([
     2    "../../lib/object",
    23    "./_Class",
    34    "./surveyRuns",
     
    78    "dojo/_base/lang",
    89    "dojo/_base/xhr"
    9 ], function(_Class, surveyRuns, Deferred, declare, json, lang, xhr) {
     10], function(objectFuns, _Class, surveyRuns, Deferred, declare, json, lang, xhr) {
    1011
    1112    var Responses = declare([_Class],{
     
    2930        },
    3031        _serialize: function(obj) {
     32            this._convertCheckAndRadio(obj.answers);
    3133            if (obj._surveyRun) {
    3234                obj._surveyRun = surveyRuns._doSerialize(obj._surveyRun);
     
    8486                return result;
    8587            },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);
    86104        }
    87105    });
Note: See TracChangeset for help on using the changeset viewer.