source: Dev/branches/rest-dojo-ui/client/rft/pages/session.js @ 364

Last change on this file since 364 was 364, checked in by jkraaijeveld, 13 years ago

Since lists where common, created a ListView? base class with basic functionality. For the session editor, created a AccountListView? which only has the created method declared and derives everything else from ListView?.

File size: 1.9 KB
Line 
1define(['dojo/_base/declare',
2        'dojo/_base/lang',
3        'dojo/_base/event',
4        'dojo/_base/Deferred',
5        'rft/store',
6        'rft/ui/_Page',
7        'rft/content',
8    'rft/ui/AccountListView'
9    ],
10        function(declare,lang,event,Deferred,store,_Page,content,AccountListView){
11                return declare('rft.pages.session',[_Page],{
12                        session: null,
13                        listView: null,
14                        onVisit: function() {
15                                if ( this.pageArgs.uid ) {
16                                        Deferred.when(store.get(this.pageArgs.uid))
17                                        .then(lang.hitch(this,function(obj){
18                                                this.session = obj;
19                        this._refresh();
20                                        }));
21                    this._setupListView();
22                                } else {
23                                        throw "No valid uid or session passed!";
24                                }
25                        },
26                        onLeave: function() {
27                                this.inherited(arguments);
28                        },
29            _refresh: function() {
30                this.titleNode.innerHTML = this.session.title || '';
31                this.propertiesForm.set('value',this.session);
32            },
33            onInvite: function() {
34                this._addAccount({ title : this.emailBox.get('value') });
35                this.emailBox.set('value', "");
36            },
37            onSave: function(evt) {
38                lang.mixin(this.session,this.propertiesForm.get('value'));
39                store.put(this.session)
40                .then(function(){
41                    content.goTo('sessions');
42                });
43                event.stop(evt);
44                return false;
45            },
46            onDiscard: function(evt) {
47                this.propertiesForm.reset();
48                event.stop(evt);
49                content.goTo('sessions');
50                return false;
51            },
52            _addAccount: function(item) {
53                this.listView.insertItem(item);
54            },
55            _setupListView: function() {
56                this.listView = new AccountListView( {
57                    controller: this
58                }).placeAt(this.listViewNode);
59                this.listView.startup();
60            }
61
62                });
63});
64
Note: See TracBrowser for help on using the repository browser.