1 | define([ |
---|
2 | /*'dojo/_base/array', |
---|
3 | 'dojo/_base/declare', |
---|
4 | 'dojo/_base/event', |
---|
5 | 'dojo/_base/lang', |
---|
6 | 'dojo/when', |
---|
7 | '../search', |
---|
8 | '../store', |
---|
9 | '../app/Page', |
---|
10 | '../app/Router', |
---|
11 | '../widgets/ThresholdFilteringSelect', |
---|
12 | '../model/classes/SessionTemplate', |
---|
13 | '../model/widgets/AccountListView', |
---|
14 | 'dojo/text!./templates/session.html'*/ |
---|
15 | ],function(array,declare,event,lang,when,search,store,Page,Router,ThresholdFilteringSelect,SessionTemplate,AccountListView,template){ |
---|
16 | /*return declare([Page],{ |
---|
17 | templateString: template, |
---|
18 | session: null, |
---|
19 | _accountList: null, |
---|
20 | _select: null, |
---|
21 | startup: function() { |
---|
22 | if ( this._started ) { return; } |
---|
23 | this.inherited(arguments); |
---|
24 | if ( this.sessionId ) { |
---|
25 | this._loadSession(); |
---|
26 | this._setupAutoComplete(); |
---|
27 | } else { |
---|
28 | throw "No valid uid or session passed!"; |
---|
29 | } |
---|
30 | }, |
---|
31 | _loadSession: function() { |
---|
32 | if ( this.sessionId === "new" ) { |
---|
33 | this.session = SessionTemplate.create(); |
---|
34 | } else { |
---|
35 | when(store.get(this.sessionId)) |
---|
36 | .then(lang.hitch(this,function(obj){ |
---|
37 | this.session = obj; |
---|
38 | this._setupAccountList(); |
---|
39 | this._refresh(); |
---|
40 | })); |
---|
41 | } |
---|
42 | }, |
---|
43 | _refresh: function() { |
---|
44 | this.titleNode.innerHTML = SessionTemplate.DisplayTitle.get(this.session); |
---|
45 | this.propertiesForm.set('value',this.session); |
---|
46 | }, |
---|
47 | onInvite: function() { |
---|
48 | this._addAccount(this._select.item.i); |
---|
49 | this._select.reset(); |
---|
50 | }, |
---|
51 | onSave: function(evt) { |
---|
52 | lang.mixin(this.session,this.propertiesForm.get('value')); |
---|
53 | this.session.accounts = array.map(this._accountList.get('value'), function(item){ |
---|
54 | return store.getIdentity(item); |
---|
55 | }); |
---|
56 | store.put(this.session) |
---|
57 | .then(function(){ |
---|
58 | Router.go('/sessions'); |
---|
59 | }); |
---|
60 | event.stop(evt); |
---|
61 | return false; |
---|
62 | }, |
---|
63 | onDiscard: function(evt) { |
---|
64 | this.propertiesForm.reset(); |
---|
65 | event.stop(evt); |
---|
66 | Router.go('/sessions'); |
---|
67 | return false; |
---|
68 | }, |
---|
69 | _addAccount: function(item) { |
---|
70 | this._accountList.insertItem(item); |
---|
71 | }, |
---|
72 | _setupAccountList: function() { |
---|
73 | this._accountList = new AccountListView({ |
---|
74 | value: this.session.accounts |
---|
75 | }).placeAt(this.accountListNode); |
---|
76 | this._accountList.startup(); |
---|
77 | }, |
---|
78 | _setupAutoComplete: function() { |
---|
79 | this._select = new ThresholdFilteringSelect({ |
---|
80 | store: search, |
---|
81 | autoComplete: false, |
---|
82 | required: false, |
---|
83 | labelType: "text", |
---|
84 | placeHolder: "Enter email address here...", |
---|
85 | pageSize: 10, |
---|
86 | hasDownArrow: false, |
---|
87 | style: "width: 400", |
---|
88 | searchAttr: "title" |
---|
89 | }, this.accountSelector); |
---|
90 | this._select.startup(); |
---|
91 | } |
---|
92 | |
---|
93 | |
---|
94 | });*/ |
---|
95 | }); |
---|
96 | |
---|