Changeset 375


Ignore:
Timestamp:
07/25/12 10:56:00 (13 years ago)
Author:
jkraaijeveld
Message:

Question editor now loads topic as well. Improved topic auto-completer with a new view which only sends the topic names from the database.

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

Legend:

Unmodified
Added
Removed
  • Dev/branches/rest-dojo-ui/client/config/docs.json

    r362 r375  
    7676                "map": "function(doc){ if ( doc.type === 'Question' ) { for (var i = 0; i < doc.categories.length; i++) { emit([doc.categories[i],doc.topic],1); } } }",
    7777                "reduce": "function(keys,values) { return sum(values); }"
     78            },
     79            "topics": {
     80                "map": "function(doc){ if ( doc.type === 'Question' ) { emit(doc.topic, 1); } }",
     81                "reduce":   "function(keys, values) { return null; }"
    7882            }
    7983        }
  • Dev/branches/rest-dojo-ui/client/rft/ui/QuestionEditorToolkit.js

    r374 r375  
    2020                        _categorySelect: null,
    2121                        _categoryStore: null,
     22                        _topicSelect: null,
     23                        _topicStore: null,
    2224                        _categories : null,
    2325
     
    5658                                this._categories = question.categories;
    5759                                this._setupListView();
    58                                 this._setupAutoComplete();
     60                                this._setupCategories();
     61                                this._setupTopic(question.topic);
    5962                        },
    6063                        onCategoryAdd: function() {
     
    8992                                this._list.startup();
    9093                        },
    91                         _setupAutoComplete: function() {
     94                        _setupCategories: function() {
    9295                                this._categoryStore = new dojo.store.Memory({data: [] });
    9396                                store.query("_design/default/_view/questions", {reduce:true, group:false, group_level:1})
    9497                                        .forPairs(lang.hitch(this, function(value, key) {
    95                                                 this._categoryStore.put({ category: key[0] });
     98                                                this._categoryStore.put({ id: key[0] });
    9699                                        }));
    97100                                this._categorySelect = new ComboBox( {
     
    99102                                        name: "categories",
    100103                                        store: this._categoryStore,
    101                                         searchAttr: "category"
     104                                        searchAttr: "id"
    102105                                }, "categoriesBox");
    103106
     107            },
     108            _setupTopic: function(topic) {
    104109                                this._topicStore = new dojo.store.Memory( {data: [] });
    105                                 store.query("_design/default/_view/questions", {reduce:true, group:true, group_level:2})
     110                                store.query("_design/default/_view/topics", {reduce:true, group:true})
    106111                                        .forPairs(lang.hitch(this, function(value, key) {
    107                                                 this._topicStore.put({ topic: key[1]});
     112                                                this._topicStore.put({ id: key });
    108113                                        }));
    109114                                this._topicSelect = new ComboBox( {
     
    111116                                        name: "topic",
    112117                                        store: this._topicStore,
    113                                         searchAttr: "topic"
     118                                        searchAttr: "id",
     119                                        value: topic
    114120                                }, "topicBox");
    115121            },
Note: See TracChangeset for help on using the changeset viewer.