source: Dev/trunk/src/client/qed-client/model/widgets/TabbedQuestionBrowser.js @ 501

Last change on this file since 501 was 501, checked in by hendrikvanantwerpen, 11 years ago
File size: 1.6 KB
Line 
1define([
2    "../../widgets/TabbedBrowser",
3    "../classes/categories",
4    "../classes/questions",
5    "../classes/topics",
6    "dojo/_base/array",
7    "dojo/_base/declare",
8    "dojo/_base/lang"
9], function(TabbedBrowser, categories, questions, topics, array, declare, lang) {
10    return declare([TabbedBrowser],{
11        tabPosition: 'left-h',
12        include: null,
13        dndType: "question",
14        getCategories: function(){
15            var opts = {};
16            if ( this.include ) { opts[this.include] = true; }
17            return categories.query(opts);
18        },
19        getCategoryName: function(category){ return category.name; },
20        getCategoryCount: function(category){ return category.count; },
21        getTopics: function(category) {
22            var opts = {category:category.name};
23            if ( this.include ) { opts[this.include] = true; }
24            return topics.query(opts);
25        },
26        getTopicName: function(topic){ return topic.name; },
27        getTopicCount: function(topic){ return topic.count; },
28        getItems: function(category,topic) {
29            var opts = {category:category.name,topic:topic.name};
30            if ( this.include ) { opts[this.include] = true; }
31            return questions.query(opts);
32        },
33        getItemName: function(item) {
34            var title = '['+item.code+']'+item.title;
35            if ( !this.include ) {
36                title += (item.publicationDate ?' (published on '+item.publicationDate+')':' (unpublished)');
37            }
38            return title;
39        },
40        areItemsEqual: function(i1,i2) {
41            return questions.getId(i1) === questions.getId(i2);
42        }
43    });
44});
Note: See TracBrowser for help on using the repository browser.