source: Dev/trunk/client/qed/pages/questions.js @ 441

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

Make dragging questions optional.

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