source: Dev/trunk/src/client/qed-client/model/widgets/SurveyRenderWidget.js @ 512

Last change on this file since 512 was 511, checked in by hendrikvanantwerpen, 11 years ago
  • Added open item options to singe and multiple choice.
  • Question view widgets are forms again, because we needed the control.
  • Multiple and singel choice share their widgets.
  • QuestionEditorPreview? now has items that were already there close, but opens newly dropped items.
  • PreviewItems? will save modified value even when we change to view before the widget loses its focus (which causes a change event).
File size: 1.8 KB
Line 
1define([
2    "../../widgets/_ComplexValueWidget",
3    "./questions/Factory",
4    "dojo/_base/array",
5    "dojo/_base/declare",
6    "dojo/_base/lang",
7    "dojo/dom-construct",
8    "dojo/text!./templates/SurveyRenderWidget.html"
9], function(_ComplexValueWidget, QuestionWidgetFactory, array, declare, lang, domConstruct, template) {
10    return declare([_ComplexValueWidget],{
11        templateString: template,
12        survey: null,
13        startup: function() {
14            if ( this._started ) { return; }
15            this.inherited(arguments);
16            if ( this.survey ) {
17                this._setSurveyAttr(this.survey);
18            }
19        },
20        _setSurveyAttr: function(survey) {
21            domConstruct.empty(this.domNode);
22            this.survey = survey;
23            var f = new QuestionWidgetFactory();
24            array.forEach(this.survey.questions,function(question){
25                array.forEach(question.content || [], function(item){
26                    item.code = question.code;
27                    var w = f.createViewWidget(item);
28                    if ( w !== null ) {
29                        w.placeAt(this.domNode);
30                        w.startup();
31                    }
32                },this);
33            },this);
34        },
35        _getValueAttr: function() {
36            var newValue = {};
37            array.forEach(this._getDescendantFormWidgets(),function(widget){
38                lang.mixin(newValue,widget.get('value'));
39            },this);
40            this.value = newValue;
41            return this.value;
42        },
43        _setValueAttr: function(value) {
44            array.forEach(this._getDescendantFormWidgets(),function(widget){
45                widget.set('value',value);
46            },this);
47            this.value = value;
48        }
49    });
50});
Note: See TracBrowser for help on using the repository browser.