source: Dev/trunk/src/qed-client/pages/questions.js @ 443

Last change on this file since 443 was 443, checked in by hendrikvanantwerpen, 12 years ago

Reorganized for Node --- the SVN gods hate us all!

Lost all historical info on moved files, because SVN is a f *.

Also we have Node now, serving both the static content and forwarding
database requests.

File size: 2.3 KB
Line 
1define([
2    'dojo/_base/declare',
3    'dojo/_base/Deferred',
4    'dojo/_base/event',
5    'dojo/_base/lang',
6    '../store',
7    '../app/Content',
8    '../app/Router',
9    '../app/Page',
10    '../model/widgets/TabbedQuestionBrowser',
11    'dojo/text!./templates/questions.html'
12],function(declare,Deferred,event,lang,store,Content,Router,Page,TabbedQuestionBrowser,template) {
13    return declare([Page],{
14        templateString: template,
15        startup: function() {
16            if ( this._started ) { return; }
17            this.inherited(arguments);
18            this.questionBrowser = new TabbedQuestionBrowser({
19                region: 'center',
20                'class': 'orange',
21                dndType: null,
22                itemActions: {
23                    Delete: {
24                        callback: lang.hitch(this,"onDeleteQuestion"),
25                        icon: 'Delete',
26                        description: 'Delete question'
27                    },
28                    Edit: {
29                        callback: lang.hitch(this,"onEditQuestion"),
30                        icon: 'Edit',
31                        description: 'Edit question'
32                    },
33                    Publish: {
34                        callback: lang.hitch(this,"onPublishQuestion"),
35                        icon: 'Publish',
36                        description: 'Publish question'
37                    }
38                }
39            },this.questionBrowser);
40            this.questionBrowser.startup();
41        },
42        onNewQuestion: function() {
43            Router.go("/question/new");
44        },
45        onDeleteQuestion: function(question) {
46            store.remove(store.getIdentity(question),store.getRevision(question))
47            .then(function(){
48                Content.notify("Question deleted.");
49            },function(err){
50                Content.notify(err,'error');
51            });
52        },
53        onEditQuestion: function(question) {
54            Router.go("/question/"+question._id);
55        },
56        onPublishQuestion: function(question) {
57            question.publicationDate = store.timestamp();
58            store.put(question)
59            .then(function(){
60                Content.notify("Question published.");
61            },function(err){
62                Content.notify(err,'error');
63            });
64        }
65    });
66});
Note: See TracBrowser for help on using the repository browser.