Ignore:
Timestamp:
05/02/13 13:13:13 (12 years ago)
Author:
hendrikvanantwerpen
Message:

Enable validation on all fields of question.

Location:
Dev/trunk/client/qed/model/widgets
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • Dev/trunk/client/qed/model/widgets/QuestionEditorPreviewItem.js

    r441 r442  
    5555            return !this._editing || this.innerWidget.validate();
    5656        },
     57        focus: function() {
     58            if ( this._editing ) {
     59                this.innerWidget.focus();
     60            }
     61        },
    5762        showView: function() {
    5863            if ( this._editing ) {
     
    7479                this.showEdit();
    7580            }
    76             evt && event.stop(evt);
     81            if ( evt ) { event.stop(evt); }
    7782            return false;
    7883        },
     
    141146                }
    142147            }
    143             evt && event.stop(evt);
     148            if ( evt ) { event.stop(evt); }
    144149            return false;
    145150        }
  • Dev/trunk/client/qed/model/widgets/QuestionEditorToolkit.js

    r441 r442  
    2020
    2121        templateString: template,
    22         _list: null,
     22        _categoryList: null,
    2323        _categorySelect: null,
    2424        _categoryStore: null,
     
    6565        },
    6666
    67         postCreate: function(){
     67        buildRendering: function() {
    6868            this.inherited(arguments);
     69
     70            this._categoryList = new CategoryListView({
     71                name: "categories"
     72            }).placeAt(this.categoryListNode);
     73
     74            this._categoryStore = new Memory({data: [] });
     75            this._categorySelect = new ComboBox( {
     76                store: this._categoryStore,
     77                searchAttr: "id"
     78            }, this.categoryBoxNode);
     79
     80            this._topicStore = new Memory( {data: [] });
     81            this._topicSelect = new ComboBox({
     82                name: "topic",
     83                store: this._topicStore,
     84                searchAttr: "id"
     85            }, this.topicBoxNode);
     86
    6987            var creator = lang.hitch(this,"_creator");
    7088            this.contentSource = new Source(this.ToolkitContentSourceNode, {
     
    85103            this.inputsSource.insertNodes(false, this._inputsItems);
    86104        },
    87         _setValueAttr: function(question) {
    88             this._setupListView();
    89             this._setupCategories();
    90             this._setupTopic(question.topic);
    91             this.propertiesForm.set('value', question);
    92             this._list.set('value', question.categories);
     105        startup: function() {
     106            if ( this._started ) { return; }
     107            this.inherited(arguments);
     108
     109            store.query("_design/questions/_view/all", {reduce:true, group:false, group_level:1})
     110            .forPairs(lang.hitch(this, function(value, key) {
     111                this._categoryStore.put({ id: key[0] });
     112            }));
     113
     114            store.query("_design/questions/_view/all_topics", {reduce:true, group:true})
     115            .forPairs(lang.hitch(this, function(value, key) {
     116                this._topicStore.put({ id: key });
     117            }));
    93118        },
    94         _getValueAttr: function() {
    95             var value = this.propertiesForm.get('value');
    96             value.categories = this._list.get('value');
    97             return value;
    98         },
    99         onCategoryAdd: function() {
    100             this._addCategory(this._categorySelect.get('displayedValue'));
     119        _onCategoryAdd: function() {
     120            this._categoryList.appendItem(this._categorySelect.get('displayedValue'));
    101121            this._categorySelect.reset();
    102122        },
     
    122142                type: ["questionContent"]
    123143            };
    124         },
    125         _setupListView: function() {
    126             this._list = new CategoryListView({
    127             }).placeAt(this.listNode);
    128             this._list.startup();               
    129         },
    130         _setupCategories: function() {
    131             this._categoryStore = new Memory({data: [] });
    132             store.query("_design/questions/_view/all", {reduce:true, group:false, group_level:1})
    133             .forPairs(lang.hitch(this, function(value, key) {
    134                 this._categoryStore.put({ id: key[0] });
    135             }));
    136             this._categorySelect = new ComboBox( {
    137                 name: "categories",
    138                 store: this._categoryStore,
    139                 searchAttr: "id"
    140             }, this.categoriesBoxNode);
    141         },
    142         _setupTopic: function(topic) {
    143             this._topicStore = new Memory( {data: [] });
    144             store.query("_design/questions/_view/all_topics", {reduce:true, group:true})
    145             .forPairs(lang.hitch(this, function(value, key) {
    146                 this._topicStore.put({ id: key });
    147             }));
    148             this._topicSelect = new ComboBox( {
    149                 name: "topic",
    150                 store: this._topicStore,
    151                 searchAttr: "id",
    152                 value: topic
    153             }, this.topicBoxNode);
    154         },
    155         _addCategory: function(item) {
    156             this._list.appendItem(item);
    157144        }
    158145
  • Dev/trunk/client/qed/model/widgets/templates/QuestionEditorToolkit.html

    r431 r442  
    11<div>
    2         <div data-dojo-type="dojox/widget/TitleGroup">
     2        <div data-dojo-type="qed/widgets/TitleGroup">
    33                <div data-dojo-type="dijit/TitlePane" class="orange" data-dojo-props="open:true" title="Properties" data-dojo-props="iconClass:'rftIcon rftIconProperties'">
    4             <div data-dojo-type="dijit/form/Form" data-dojo-attach-point="propertiesForm">
    5                                 <fieldset class="align">
    6                                         <label>Title:</label><input data-dojo-type="dijit/form/TextBox" name="title"/>
    7                                         <label>Code:</label><input data-dojo-type="dijit/form/TextBox" name= "code"/>
    8                                         <label>Categories:</label>
    9                                         <div data-dojo-attach-point="listNode" class="rftLineListView"></div>
    10                                         <div data-dojo-attach-point="categoriesBoxNode"></div>
    11                                         <button class="inheritBgColor" data-dojo-type="dijit/form/Button" data-dojo-attach-event="onClick:onCategoryAdd" data-dojo-props="baseClass:'rftBlockButton', iconClass: 'rftIcon rftIconPlus'">Add</button><br/>
    12                                         <label>Topic:</label>
    13                                         <div data-dojo-attach-point="topicBoxNode"></div>
    14                                         <label>Description:</label><textarea data-dojo-type="dijit/form/Textarea" name="description"></textarea>
    15                                 </fieldset>
    16                         </div>
     4            <fieldset class="align">
     5                <label>Title:</label><input data-dojo-type="dijit/form/ValidationTextBox" required="required" name="title"/>
     6                <label>Code:</label><input data-dojo-type="dijit/form/ValidationTextBox" required="required" name="code"/>
     7                <label>Categories:</label>
     8                <div data-dojo-attach-point="categoryListNode" class="rftLineListView"></div>
     9                <div data-dojo-attach-point="categoryBoxNode"></div>
     10                <button class="inheritBgColor" data-dojo-type="dijit/form/Button" data-dojo-attach-event="onClick:_onCategoryAdd" data-dojo-props="baseClass:'rftBlockButton', iconClass: 'rftIcon rftIconPlus'">Add</button><br/>
     11                <label>Topic:</label>
     12                <div data-dojo-attach-point="topicBoxNode"></div>
     13                <label>Description:</label><textarea data-dojo-type="dijit/form/Textarea" name="description"></textarea>
     14            </fieldset>
    1715                </div>
    1816
    1917                <div data-dojo-type="dijit/TitlePane" title="Content" data-dojo-props="iconClass:'rftIcon rftIconPlus', open:false">
    20                         <div data-dojo-attach-point="ToolkitContentSourceNode">
    21                                
    22                         </div>
     18                        <div data-dojo-attach-point="ToolkitContentSourceNode"></div>
    2319                </div>
    2420
    2521                <div data-dojo-type="dijit/TitlePane" title="Inputs" data-dojo-props="iconClass:'rftIcon rftIconInput', open:false">
    26                         <div data-dojo-attach-point="ToolkitInputsSourceNode">
    27                                
    28                         </div>
     22                        <div data-dojo-attach-point="ToolkitInputsSourceNode"></div>
    2923                </div>
    3024        </div>
Note: See TracChangeset for help on using the changeset viewer.