source: Dev/trunk/client/qed/model/widgets/SurveyWidget.js @ 428

Last change on this file since 428 was 427, checked in by hendrikvanantwerpen, 12 years ago

Display content elements on their own line.
Use className iso 'class' in node creation.
Added required version field to package.json.

File size: 1.4 KB
Line 
1define([
2    'dojo/_base/array',
3    'dojo/_base/declare',
4    'dijit/_Container',
5    'dijit/_WidgetBase',
6    'dijit/_TemplatedMixin',
7    'dijit/_WidgetsInTemplateMixin',
8    '../classes/Survey',
9    '../widgets/QuestionWidgetFactory',
10    'dojo/text!./templates/SurveyWidget.html'
11],function(array,declare,_Container,_WidgetBase,_TemplatedMixin,_WidgetsInTemplateMixin,Survey,QuestionWidgetFactory,template){
12    return declare([_WidgetBase,_TemplatedMixin,_WidgetsInTemplateMixin,_Container],{
13        templateString: template,
14        survey: null,
15        startup: function() {
16            if ( this._started ) { return; }
17            this.inherited(arguments);
18            if ( this.survey ) {
19                this._setSurveyAttr(this.survey);
20            }
21        },
22        _setSurveyAttr: function(survey) {
23            this.domNode.innerHTML = "";
24            this.survey = survey;
25            var f = new QuestionWidgetFactory();
26            array.forEach(Survey.Questions.get(this.survey),function(question){
27                array.forEach(question.content || [],function(item,index){
28                    // The dot causes values to be grouped in an object!
29                    item.code = question.code.toString()+'.'+index.toString();
30                    var w = f.createViewWidget(item);
31                    if ( w !== null ) {
32                        w.placeAt(this.domNode);
33                    }
34                },this);
35            },this);
36        }
37    });
38});
Note: See TracBrowser for help on using the repository browser.