Changeset 442 for Dev


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
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • Dev/trunk/client/qed/css/qed.css

    r441 r442  
    13541354  padding: 0 0 0 0;
    13551355}
    1356 /* line 19, /home/hendrik/gamelab/qed.svn/Dev/trunk/client/qed/css/widgets/Selector.less */
    1357 @media -sass-debug-info{filename{font-family:file\:\/\/\/home\/hendrik\/gamelab\/qed\.svn\/Dev\/trunk\/client\/qed\/css\/widgets\/Selector\.less}line{font-family:\0000319}}
     1356/* line 15, /home/hendrik/gamelab/qed.svn/Dev/trunk/client/qed/css/widgets/Selector.less */
     1357@media -sass-debug-info{filename{font-family:file\:\/\/\/home\/hendrik\/gamelab\/qed\.svn\/Dev\/trunk\/client\/qed\/css\/widgets\/Selector\.less}line{font-family:\0000315}}
     1358#rft.claro .rftSelector .rftLineWithActions.dojoDndItem.dojoDndItemAnchor {
     1359  background-color: #ffffff;
     1360}
     1361/* line 22, /home/hendrik/gamelab/qed.svn/Dev/trunk/client/qed/css/widgets/Selector.less */
     1362@media -sass-debug-info{filename{font-family:file\:\/\/\/home\/hendrik\/gamelab\/qed\.svn\/Dev\/trunk\/client\/qed\/css\/widgets\/Selector\.less}line{font-family:\0000322}}
    13581363#rft.claro .rftSelector .rftSelectorSelected .rftSelectorIndicator {
    13591364  margin: 0 0 0 0;
     
    13641369  background-color: #bedead;
    13651370}
    1366 /* line 26, /home/hendrik/gamelab/qed.svn/Dev/trunk/client/qed/css/widgets/Selector.less */
    1367 @media -sass-debug-info{filename{font-family:file\:\/\/\/home\/hendrik\/gamelab\/qed\.svn\/Dev\/trunk\/client\/qed\/css\/widgets\/Selector\.less}line{font-family:\0000326}}
     1371/* line 29, /home/hendrik/gamelab/qed.svn/Dev/trunk/client/qed/css/widgets/Selector.less */
     1372@media -sass-debug-info{filename{font-family:file\:\/\/\/home\/hendrik\/gamelab\/qed\.svn\/Dev\/trunk\/client\/qed\/css\/widgets\/Selector\.less}line{font-family:\0000329}}
    13681373#rft.claro .rftSelector .rftSelectorSelected .rftSelectorIndicator.conflict {
    13691374  background-color: #ff0000;
    13701375}
    1371 /* line 29, /home/hendrik/gamelab/qed.svn/Dev/trunk/client/qed/css/widgets/Selector.less */
    1372 @media -sass-debug-info{filename{font-family:file\:\/\/\/home\/hendrik\/gamelab\/qed\.svn\/Dev\/trunk\/client\/qed\/css\/widgets\/Selector\.less}line{font-family:\0000329}}
     1376/* line 32, /home/hendrik/gamelab/qed.svn/Dev/trunk/client/qed/css/widgets/Selector.less */
     1377@media -sass-debug-info{filename{font-family:file\:\/\/\/home\/hendrik\/gamelab\/qed\.svn\/Dev\/trunk\/client\/qed\/css\/widgets\/Selector\.less}line{font-family:\0000332}}
    13731378#rft.claro .rftSelector .rftSelectorSelected .rftSelectorIndicator.pending {
    13741379  background-color: #ff8000;
    13751380}
    1376 /* line 32, /home/hendrik/gamelab/qed.svn/Dev/trunk/client/qed/css/widgets/Selector.less */
    1377 @media -sass-debug-info{filename{font-family:file\:\/\/\/home\/hendrik\/gamelab\/qed\.svn\/Dev\/trunk\/client\/qed\/css\/widgets\/Selector\.less}line{font-family:\0000332}}
     1381/* line 35, /home/hendrik/gamelab/qed.svn/Dev/trunk/client/qed/css/widgets/Selector.less */
     1382@media -sass-debug-info{filename{font-family:file\:\/\/\/home\/hendrik\/gamelab\/qed\.svn\/Dev\/trunk\/client\/qed\/css\/widgets\/Selector\.less}line{font-family:\0000335}}
    13781383#rft.claro .rftSelector .rftSelectorSelected .rftSelectorIndicator.success {
    13791384  background-color: #00ff00;
    13801385}
    1381 /* line 41, /home/hendrik/gamelab/qed.svn/Dev/trunk/client/qed/css/widgets/Selector.less */
    1382 @media -sass-debug-info{filename{font-family:file\:\/\/\/home\/hendrik\/gamelab\/qed\.svn\/Dev\/trunk\/client\/qed\/css\/widgets\/Selector\.less}line{font-family:\0000341}}
     1386/* line 44, /home/hendrik/gamelab/qed.svn/Dev/trunk/client/qed/css/widgets/Selector.less */
     1387@media -sass-debug-info{filename{font-family:file\:\/\/\/home\/hendrik\/gamelab\/qed\.svn\/Dev\/trunk\/client\/qed\/css\/widgets\/Selector\.less}line{font-family:\0000344}}
    13831388#rft.claro .rftSelector .rftSelectorOptions .rftLineWithActions,
    13841389#rft.claro .rftSelector .rftSelectorSelected .rftLineWithActions {
     
    13861391  color: #111111;
    13871392}
    1388 /* line 50, /home/hendrik/gamelab/qed.svn/Dev/trunk/client/qed/css/widgets/Selector.less */
    1389 @media -sass-debug-info{filename{font-family:file\:\/\/\/home\/hendrik\/gamelab\/qed\.svn\/Dev\/trunk\/client\/qed\/css\/widgets\/Selector\.less}line{font-family:\0000350}}
     1393/* line 53, /home/hendrik/gamelab/qed.svn/Dev/trunk/client/qed/css/widgets/Selector.less */
     1394@media -sass-debug-info{filename{font-family:file\:\/\/\/home\/hendrik\/gamelab\/qed\.svn\/Dev\/trunk\/client\/qed\/css\/widgets\/Selector\.less}line{font-family:\0000353}}
    13901395#rft.claro .rftSelector .rftSelectorOptions .rftLineWithActions .rftInlineButton .rftIcon {
    13911396  width: 16px;
  • Dev/trunk/client/qed/css/widgets/Selector.less

    r432 r442  
    1313    .rftLineWithActions {
    1414        .noOffset;
     15        &.dojoDndItem.dojoDndItemAnchor {
     16            background-color: @text;
     17        }
    1518    }
    1619
  • 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>
  • Dev/trunk/client/qed/pages/question.js

    r441 r442  
    11define([
    2     'dojo/_base/declare',
    3     'dojo/_base/event',
    4     'dojo/_base/lang',
    5     'dojo/when',
    6     '../store',
    7     '../app/Content',
    8     '../app/Router',
    9     '../app/Page',
    10     '../model/classes/Question',
    11     '../model/widgets/QuestionEditorPreview',
    12     '../model/widgets/QuestionEditorToolkit',
    13     'dojo/text!./templates/question.html'
    14 ],function(declare, event, lang, when, store, Content, Router, Page, Question, QuestionEditorPreview, QuestionEditorToolkit, template){
    15     return declare([Page], {
     2    "../app/Content",
     3    "../app/Page",
     4    "../app/Router",
     5    "../model/classes/Question",
     6    "../model/widgets/QuestionEditorPreview",
     7    "../model/widgets/QuestionEditorToolkit",
     8    "../store",
     9    "../widgets/_ComplexValueMixin",
     10    "dojo/_base/declare",
     11    "dojo/_base/event",
     12    "dojo/_base/lang",
     13    "dojo/when",
     14    "dojo/text!./templates/question.html"
     15], function(Content, Page, Router, Question, QuestionEditorPreview, QuestionEditorToolkit, store, _ComplexValueMixin, declare, event, lang, when, template) {
     16    return declare([Page,_ComplexValueMixin], {
    1617        templateString: template,
    17         question: null,
    1818        _toolkit: null,
    1919        _preview: null,
     20        value: null,
    2021       
     22        buildRendering: function() {
     23            this.inherited(arguments);
     24
     25            this._toolkit = new QuestionEditorToolkit({
     26            },this.QuestionEditorToolkitNode);
     27            this._toolkit.on('submit',lang.hitch(this,"_onSave"));
     28            this._toolkit.startup();
     29
     30            this._preview = new QuestionEditorPreview({
     31                name: 'content',
     32                delay: 5,
     33                region: 'center'
     34            });
     35            this._preview.startup();
     36            this.addChild(this._preview);
     37        },
    2138        startup: function() {
    2239            if ( this._started ) { return; }
     
    2542                throw new Error("Error: no reference to object set!");
    2643            }
    27             this._setupEditor();
    2844            if (this.questionId === "new") {
    29                 this.question = Question.create();
    30                 this._refresh();
     45                this.set('value', Question.create());
    3146            } else {
    3247                when(store.get(this.questionId))
    33                 .then(lang.hitch(this, function(obj) {
    34                     this.question = obj;
    35                     this._refresh();
     48                .then(lang.hitch(this, function(value) {
     49                    this.set('value', value);
    3650                }));
    3751            }
    3852        },
    39         onLeave: function() {
     53        _setValueAttr: function(value) {
     54            this.value = value;
    4055            this.inherited(arguments);
     56            this.titleNode.innerHTML = Question.DisplayTitle.get(value);
    4157        },
    42         _refresh: function () {
    43             this.titleNode.innerHTML = Question.DisplayTitle.get(this.question);
    44             this._toolkit.set('value', this.question);
    45             this._preview.set('value', Question.Content.get(this.question));
     58        _getValueAttr: function() {
     59            var value = this.inherited(arguments);
     60            lang.mixin(this.value, value);
     61            return this.value;
    4662        },
    4763        _onSave: function(evt) {
    48             if ( this._preview.validate() ) {
    49                 lang.mixin(this.question, this._toolkit.get('value'));
    50                 Question.Content.set(this.question, this._preview.get('value'));
    51                 store.put(this.question)
     64            if ( this.validate() ) {
     65                var value = this.get('value');
     66                store.put(value)
    5267                .then(function() {
    5368                    Router.go('/questions');
     
    6277            Router.go('/questions');
    6378            return true;
    64         },
    65         _setupEditor: function() {
    66             this._toolkit = new QuestionEditorToolkit({
    67             },this.QuestionEditorToolkitNode);
    68             this._toolkit.on('submit',lang.hitch(this,"_onSave"));
    69             this._toolkit.startup();
    70 
    71             this._preview = new QuestionEditorPreview({
    72                 name: 'content',
    73                 delay: 5,
    74                 region: 'center'
    75             });
    76             this._preview.startup();
    77             this.addChild(this._preview);
    7879        }
    7980    });
  • Dev/trunk/client/qed/pages/session.js

    r441 r442  
    5151        onSave: function(evt) {
    5252            lang.mixin(this.session,this.propertiesForm.get('value'));
    53             this.session.accounts = array.map(this._accountList.get('value'),
    54                                               function(item){
    55                                                   return store.getIdentity(item);
     53            this.session.accounts = array.map(this._accountList.get('value'), function(item){
     54                return store.getIdentity(item);
    5655            });
    5756            store.put(this.session)
  • Dev/trunk/client/qed/widgets/ListWidget.js

    r441 r442  
    9090        _setValueAttr: function(value) {
    9191            this.clear();
    92             this.appendItems(value);
     92            this.appendItems(value || []);
     93        },
     94        _setDisabledAttr: function(value) {
     95            this._set("disabled", value);
     96            array.forEach(this.getChildren(), function(child){
     97                child.set("disabled", value);
     98            });
     99        },
     100        _setReadOnlyAttr: function(value) {
     101            this._set("readOnly", value);
     102            array.forEach(this.getChildren(), function(child){
     103                child.set("readOnly", value);
     104            });
     105        },
     106        focus: function() {
     107            var children = this.getChildren();
     108            if ( children.length > 0 ) {
     109                children[0].focus();
     110            }
    93111        },
    94112        appendItems: function(items) {
  • Dev/trunk/client/qed/widgets/TitleGroup.js

    r417 r442  
    1 require(['dojo/_base/declare','dojo/_base/query','dijit/registry','dojox/widget/TitleGroup'],
    2     function(declare,query,registry,TitleGroup){
    3         return declare([TitleGroup],{
    4             getChildren: function() {
    5                 return query("> .dijitTitlePane", this.domNode)
    6                 .map(function(node){
    7                     return registry.byNode(node);
    8                 });
    9             }
    10         });
     1define([
     2    "dijit/registry",
     3    "dojo/_base/declare",
     4    "dojo/_base/query",
     5    "dojox/widget/TitleGroup"
     6], function(registry, declare, query, TitleGroup) {
     7    return declare([TitleGroup],{
     8        getChildren: function() {
     9            return query("> .dijitTitlePane", this.domNode)
     10            .map(function(node){
     11                return registry.byNode(node);
     12            });
     13        }
    1114    });
     15});
Note: See TracChangeset for help on using the changeset viewer.