1 | define([ |
---|
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 && !item.publicationDate ) { |
---|
36 | title += ' (*)'; |
---|
37 | } |
---|
38 | return title; |
---|
39 | }, |
---|
40 | areItemsEqual: function(i1,i2) { |
---|
41 | return questions.getId(i1) === questions.getId(i2); |
---|
42 | } |
---|
43 | }); |
---|
44 | }); |
---|