1 | define([ |
---|
2 | /*'dojo/_base/declare', |
---|
3 | 'dojo/_base/lang', |
---|
4 | 'dojo/date/stamp', |
---|
5 | '../store', |
---|
6 | '../app/Router', |
---|
7 | '../app/Page', |
---|
8 | '../widgets/ObjectBox', |
---|
9 | 'dojo/text!./templates/sessions.html'*/ |
---|
10 | ],function(declare,lang,dateStamp,store,Router,Page,ObjectBox,template){ |
---|
11 | /*return declare([Page],{ |
---|
12 | templateString: template, |
---|
13 | templateActions: null, |
---|
14 | sessionActions: null, |
---|
15 | startup: function() { |
---|
16 | if ( this._started ) { return; } |
---|
17 | this.inherited(arguments); |
---|
18 | this.templateActions = { |
---|
19 | "Edit": function(obj){ |
---|
20 | Router.go('/session/'+obj.get('id')); |
---|
21 | }, |
---|
22 | "Delete": lang.hitch(this,function(obj){ |
---|
23 | obj.remove() |
---|
24 | .then(lang.hitch(this,function(){ |
---|
25 | this._refresh(); |
---|
26 | })); |
---|
27 | }), |
---|
28 | "Publish": lang.hitch(this,this._publishSession) |
---|
29 | }; |
---|
30 | this.sessionActions = { |
---|
31 | "Facilitate": function(obj){ |
---|
32 | Router.go('run',{uid: obj.get('id')}); |
---|
33 | }, |
---|
34 | "Delete": lang.hitch(this,function(obj){ |
---|
35 | obj.remove() |
---|
36 | .then(lang.hitch(this,function(){ |
---|
37 | this._refresh(); |
---|
38 | })); |
---|
39 | }) |
---|
40 | }; |
---|
41 | this._refresh(); |
---|
42 | }, |
---|
43 | _refresh: function() { |
---|
44 | this.containerTemplates.set('content',''); |
---|
45 | this.containerSessions.set('content',''); |
---|
46 | this._refreshByType('SessionTemplate',this.containerTemplates.domNode,this.templateActions); |
---|
47 | this._refreshByType('SessionInstance',this.containerSessions.domNode,this.sessionActions); |
---|
48 | }, |
---|
49 | _refreshByType: function(type,container,actions) { |
---|
50 | // FIXME |
---|
51 | store.query("_design/default/_view/by_type",{key:type}) |
---|
52 | .forEach(lang.hitch(this,function(obj){ |
---|
53 | var widget = new ObjectBox({ |
---|
54 | actions: actions |
---|
55 | }).placeAt(container, "last"); |
---|
56 | widget.startup(); |
---|
57 | widget.set('value',obj); |
---|
58 | })); |
---|
59 | }, |
---|
60 | onAddSessionTemplate: function(){ |
---|
61 | Router.go('/session/new'); |
---|
62 | }, |
---|
63 | _publishSession: function(sessionTemplate) { |
---|
64 | // FIXME |
---|
65 | var session = lang.clone(sessionTemplate); |
---|
66 | delete session[store.idProperty]; |
---|
67 | delete session[store.revProperty]; |
---|
68 | session.type = "SessionInstance"; |
---|
69 | session.publicationDate = store.timestamp(); |
---|
70 | session.creator = "Igor Mayer"; |
---|
71 | store.add(session) |
---|
72 | .then(lang.hitch(this,function(){ |
---|
73 | this._refresh(); |
---|
74 | this.tabContainer.selectChild(this.sessionsTab); |
---|
75 | })); |
---|
76 | } |
---|
77 | });*/ |
---|
78 | }); |
---|