Ignore:
Timestamp:
04/29/13 19:35:10 (12 years ago)
Author:
hendrikvanantwerpen
Message:

Big cleanup of the question content.

  • Replaced old list implementations with a new one that behaves like a form widget.
  • All question content is now in separate widgets, not in the factory itself.
  • Added form and widget validation for question editing.
File:
1 edited

Legend:

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

    r428 r441  
    2525        _topicSelect: null,
    2626        _topicStore: null,
    27         _categories : null,
    2827
    2928        _contentItems: [
     
    3736            { type: "StringInput" },
    3837            { type: "TextInput" },
    39             { type: "IntegerInput" },
     38            { type: "NumberInput" },
    4039            { type: "ScaleInput" },
    4140            { type: "MultipleChoiceInput" }
     
    4948            "StringInput": "Text line",
    5049            "TextInput": "Free text",
    51             "IntegerInput": "Integer number",
     50            "NumberInput": "Number",
    5251            "ScaleInput": "Scale",
    5352            "MultipleChoiceInput": "Multiple choice"
     
    6160            "StringInput": "Text",
    6261            "TextInput": "Text",
    63             "IntegerInput": "Integer",
     62            "NumberInput": "Number",
    6463            "ScaleInput": "Scale",
    6564            "MultipleChoiceInput": "MultipleChoice"
     
    8786        },
    8887        _setValueAttr: function(question) {
    89             this.propertiesForm.set('value', question);
    90             this._categories = question.categories || [];
    9188            this._setupListView();
    9289            this._setupCategories();
    9390            this._setupTopic(question.topic);
     91            this.propertiesForm.set('value', question);
     92            this._list.set('value', question.categories);
    9493        },
    9594        _getValueAttr: function() {
    9695            var value = this.propertiesForm.get('value');
    97             value.categories = this._categories;
     96            value.categories = this._list.get('value');
    9897            return value;
    9998        },
     
    125124        },
    126125        _setupListView: function() {
    127             this._list = new CategoryListView( {
    128                 removeCallback: lang.hitch(this, this._removeCategory)
     126            this._list = new CategoryListView({
    129127            }).placeAt(this.listNode);
    130128            this._list.startup();               
    131             for (var category in this._categories) {
    132                 this._list.appendItem(this._categories[category]);
    133             }   
    134129        },
    135130        _setupCategories: function() {
     
    144139                searchAttr: "id"
    145140            }, this.categoriesBoxNode);
    146             this._supportingWidgets.push(this._categorySelect);
    147 
    148141        },
    149142        _setupTopic: function(topic) {
     
    159152                value: topic
    160153            }, this.topicBoxNode);
    161             this._supportingWidgets.push(this._topicSelect);
    162154        },
    163155        _addCategory: function(item) {
    164             this._categories.push(item);
    165156            this._list.appendItem(item);
    166         },
    167         _removeCategory: function(item) {
    168             this._categories.splice(this._categories.indexOf(item), 1);
    169157        }
    170158
Note: See TracChangeset for help on using the changeset viewer.