Ignore:
Timestamp:
02/24/12 16:09:22 (13 years ago)
Author:
hendrikvanantwerpen
Message:

[Client] MultipleChoiceWidget? for editing multiple choice questions
[Client] Move templates to separate directories.
[Client] Created QuestionWidget? to edit complete questions.
[Client] Fixed startup race condition where parsing was started before all classes were loaded.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • Dev/branches/rest-dojo-ui/client/rft/pages/questions.js

    r281 r288  
    11define(['dojo/_base/declare','dojo/_base/lang','dojo/_base/array','dojo/_base/event',
    2     'dojo/_base/Deferred','dojo/store/JsonRest','dijit/layout/ContentPane','dijit/TitlePane',
     2    'dojo/_base/Deferred','dojo/dom-construct','dojo/store/JsonRest','dijit/layout/ContentPane','dijit/TitlePane',
    33    'rft/ui/_Page','rft/ui/LineWithActionsWidget'],
    4     function(declare,lang,array,event,Deferred,JsonRest,ContentPane,TitlePane,_Page,LineWithActionsWidget) {
     4    function(declare,lang,array,event,Deferred,domConstruct,JsonRest,ContentPane,TitlePane,_Page,LineWithActionsWidget) {
    55        return declare('rft.pages.questions',[_Page],{
    66            constructor: function() {
     
    1313                    idProperty: 'uid'
    1414                });
    15                 this._refresh();
     15                this._refresh(true);
    1616            },
    17             _refresh: function() {
     17            _refresh: function(initial) {
    1818                Deferred.when( this._store.query() ).then(lang.hitch(this,function(results){
    1919                    array.forEach(results,lang.hitch(this,'_addQuestion'));
     20                    initial && this.accordion.selectChild(true);
    2021                }));
    2122            },
     
    5051                var category = q.category || 'Unsorted';
    5152                var widgets = this.accordion.getChildren();
    52                 var containerWidget;
    53                 var lastIndex = 'last';
     53                var containerWidget = null;
     54                var placeNode = this.accordion.domNode;
     55                var placePos = 'last';
    5456                array.some(widgets,lang.hitch(this,function(widget,idx) {
    5557                    if ( widget.title == category ) {
     
    5759                        return true;
    5860                    } else if ( widget.title > category  ) {
    59                         lastIndex = idx;
     61                        placeNode = widget.domNode;
     62                        placePos = "before";
    6063                        return true;
    6164                    }
     
    6770                    });
    6871                    containerWidget.startup();
    69                     this.accordion.addChild(containerWidget,lastIndex);
     72                    domConstruct.place(containerWidget.domNode,placeNode,placePos);
    7073                }
    7174                return containerWidget;
     
    8790            _editQuestion: function(question) {
    8891                this.questionForm.reset();
    89                 this.questionForm.set('value',question);
    9092                this.questionWidget.set('value',question);
    9193                this.questionDialog.show();
    9294            },
    9395            onSaveQuestion: function(evt) {
    94                 var value = this.questionForm.get('value');
    95                 var subvalue = this.questionWidget.get('value');
    96                 lang.mixin(value,subvalue);
     96                var value = this.questionWidget.get('value');
    9797                Deferred.when( this._store.put(value) )
    9898                .then(lang.hitch(this,function(){
Note: See TracChangeset for help on using the changeset viewer.