Last change
on this file was
494,
checked in by hendrikvanantwerpen, 11 years ago
|
- Removed all Coffeescript from codebase (build process is still there).
- Nicer message on failed login.
- Own all event subscriptions from widgets.
- Update objects in _ObjectPage with invalid info too, or our refresh
will overwrite what user did.
|
File size:
1.2 KB
|
Rev | Line | |
---|
[494] | 1 | define([ |
---|
| 2 | "../session", |
---|
| 3 | "./LoginDialogWrapper", |
---|
| 4 | "dijit/MenuBarItem", |
---|
| 5 | "dojo/_base/declare", |
---|
| 6 | "dojo/_base/event", |
---|
| 7 | "dojo/_base/lang", |
---|
| 8 | "dojo/on" |
---|
| 9 | ], function(session, LoginDialogWrapper, MenuBarItem, declare, event, lang, on) { |
---|
| 10 | return declare([MenuBarItem], { |
---|
| 11 | info: null, |
---|
| 12 | postCreate: function() { |
---|
| 13 | return this.set('label', "Login"); |
---|
| 14 | }, |
---|
| 15 | startup: function() { |
---|
| 16 | if (this._started) { return; } |
---|
| 17 | this.inherited(arguments); |
---|
| 18 | this._update(session.get()); |
---|
| 19 | this.own(on(session, 'change', lang.hitch(this,function(info) { |
---|
| 20 | return this._update(info); |
---|
| 21 | }))); |
---|
| 22 | }, |
---|
| 23 | _update: function(info) { |
---|
| 24 | this.info = info; |
---|
| 25 | if (info) { |
---|
| 26 | return this.set('label', "Logout, " + info.username); |
---|
| 27 | } else { |
---|
| 28 | return this.set('label', "Login"); |
---|
| 29 | } |
---|
| 30 | }, |
---|
| 31 | onClick: function(evt) { |
---|
| 32 | if (this.info) { |
---|
| 33 | session.logout(); |
---|
| 34 | } else { |
---|
| 35 | LoginDialogWrapper.show(); |
---|
| 36 | } |
---|
| 37 | if (evt) { event.stop(evt); } |
---|
| 38 | return false; |
---|
| 39 | } |
---|
| 40 | }); |
---|
| 41 | }); |
---|
Note: See
TracBrowser
for help on using the repository browser.