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

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

Improve SurveyRun? form and drop Fieldsets as widgets.

  • Improved console message on Page change fail.
  • Renamed some widgets, dropped having Fieldset widgets.
  • Put constraint that survey run start date cannot be before end date.
  • Link to survey from survey summary,
File size: 1.3 KB
Line 
1define([
2    "../../widgets/_ComplexValueWidget",
3    "../classes/Survey",
4    "./questions/Factory",
5    "dojo/_base/array",
6    "dojo/_base/declare",
7    "dojo/dom-construct",
8    "dojo/text!./templates/SurveyRenderWidget.html"
9], function(_ComplexValueWidget, Survey, QuestionWidgetFactory, array, declare, 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(Survey.Questions.get(this.survey),function(question){
25                array.forEach(question.content || [],function(item,index){
26                    // The dot causes values to be grouped in an object!
27                    item.code = question.code.toString()+'.'+index.toString();
28                    var w = f.createViewWidget(item);
29                    if ( w !== null ) {
30                        w.placeAt(this.domNode);
31                    }
32                },this);
33            },this);
34        }
35    });
36});
Note: See TracBrowser for help on using the repository browser.