1 | define([ |
---|
2 | 'dojo/_base/declare', |
---|
3 | 'dojo/_base/Deferred', |
---|
4 | 'dojo/_base/event', |
---|
5 | 'dojo/_base/lang', |
---|
6 | 'rft/content', |
---|
7 | 'rft/store', |
---|
8 | 'rft/ui/_Page', |
---|
9 | 'rft/ui/TabbedQuestionBrowser' |
---|
10 | ],function(declare,Deferred,event,lang,content,store,_Page,TabbedQuestionBrowser) { |
---|
11 | return declare('rft.pages.questions',[_Page],{ |
---|
12 | constructor: function() { |
---|
13 | this.inherited(arguments); |
---|
14 | }, |
---|
15 | onVisit: function() { |
---|
16 | this.questionBrowser = new TabbedQuestionBrowser({ |
---|
17 | region: 'center', |
---|
18 | 'class': 'blue', |
---|
19 | itemActions: { |
---|
20 | 'Edit': { |
---|
21 | callback: lang.hitch(this,"onEditQuestion"), |
---|
22 | icon: 'Edit', |
---|
23 | description: 'Edit question' |
---|
24 | } |
---|
25 | } |
---|
26 | },this.questionBrowser); |
---|
27 | this.questionBrowser.startup(); |
---|
28 | }, |
---|
29 | _refresh: function() { |
---|
30 | Deferred.when(store.query('_design/default/_view/by_type',{key: 'Question'})) |
---|
31 | .then(lang.hitch(this,function(items){ |
---|
32 | this._list.setItems(items); |
---|
33 | })); |
---|
34 | }, |
---|
35 | onNewQuestion: function() { |
---|
36 | Deferred.when(store.add({type:'Question'})) |
---|
37 | .then(lang.hitch(this,function(question){ |
---|
38 | this.onEditQuestion(question); |
---|
39 | })); |
---|
40 | }, |
---|
41 | onEditQuestion: function(question) { |
---|
42 | content.goTo("question", {uid: question._id}); |
---|
43 | } |
---|
44 | }); |
---|
45 | }); |
---|