define([ 'dojo/_base/declare', 'dojo/_base/Deferred', 'dojo/_base/event', 'dojo/_base/lang', '../store', '../app/Content', '../app/Router', '../app/Page', '../model/widgets/TabbedQuestionBrowser', 'dojo/text!./templates/questions.html' ],function(declare,Deferred,event,lang,store,Content,Router,Page,TabbedQuestionBrowser,template) { return declare([Page],{ templateString: template, startup: function() { if ( this._started ) { return; } this.inherited(arguments); this.questionBrowser = new TabbedQuestionBrowser({ region: 'center', 'class': 'orange', dndType: null, itemActions: { Delete: { callback: lang.hitch(this,"onDeleteQuestion"), icon: 'Delete', description: 'Delete question' }, Edit: { callback: lang.hitch(this,"onEditQuestion"), icon: 'Edit', description: 'Edit question' }, Publish: { callback: lang.hitch(this,"onPublishQuestion"), icon: 'Publish', description: 'Publish question' } } },this.questionBrowser); this.questionBrowser.startup(); }, onNewQuestion: function() { Router.go("/question/new"); }, onDeleteQuestion: function(question) { store.remove(store.getIdentity(question),store.getRevision(question)) .then(function(){ Content.notify("Question deleted."); },function(err){ Content.notify(err,'error'); }); }, onEditQuestion: function(question) { Router.go("/question/"+question._id); }, onPublishQuestion: function(question) { question.publicationDate = store.timestamp(); store.put(question) .then(function(){ Content.notify("Question published."); },function(err){ Content.notify(err,'error'); }); } }); });