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.

Location:
Dev/branches/rest-dojo-ui/client/rft/pages
Files:
2 edited

Legend:

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

    r281 r288  
    66    <div data-dojo-type="dijit.Dialog" title="Question" data-rft-attach-point="questionDialog">
    77        <form data-dojo-type="dijit.form.Form" data-rft-attach-point="questionForm" data-rft-attach-event="onSubmit:onSaveQuestion">
    8             <fieldset>
    9                 <input data-dojo-type="dijit.form.TextBox" name="uid" type="text" class="dijitHidden" />
    10                 <label for="code" class="loginLabel">Code</label>
    11                 <input data-dojo-type="dijit.form.TextBox" name="code" type="text" class="loginInput" />
    12                 <label for="question" class="loginLabel">Title</label>
    13                 <input data-dojo-type="dijit.form.TextBox" name="title" type="text" class="loginInput" />
    14                 <label for="question" class="loginLabel">Description</label>
    15                 <input data-dojo-type="dijit.form.Textarea" name="description" type="text" class="loginInput"/>
    16                 <label for="category" class="loginLabel">Category</label>
    17                 <input data-dojo-type="dijit.form.TextBox" name="category" type="text" class="loginInput" />
    18             </fieldset>
    19             <fieldset>
    20                 <div data-dojo-type="rft.ui.QuestionWidget" data-rft-attach-point="questionWidget" ></div>
    21             </fieldset>
     8            <div data-dojo-type="rft.ui.QuestionWidget" data-rft-attach-point="questionWidget"></div>
    229            <div style="float: right;">
    2310                <button type="button" data-dojo-type="dijit.form.Button" data-rft-attach-event="onClick:onCancelQuestion">Cancel</button>
  • 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.