1
0
mirror of https://github.com/flarum/core.git synced 2025-08-06 08:27:42 +02:00

Finish signup process, including state restoration

This commit is contained in:
Toby Zerner
2015-02-25 15:34:02 +10:30
parent 327719c5a3
commit 13a4ced63d
15 changed files with 62 additions and 29 deletions

View File

@@ -28,6 +28,7 @@ export default Ember.Controller.extend(ModalController, {
return user.save().then(function(user) {
controller.set('welcomeUser', user);
controller.set('loading', false);
controller.send('saveState');
}, function(reason) {
controller.set('loading', false);
});

View File

@@ -7,6 +7,13 @@ export default Ember.Route.extend(ApplicationRouteMixin, {
activate: function() {
if (!Ember.isEmpty(FLARUM_ALERT)) {
this.controllerFor('alerts').send('alert', AlertMessage.create(FLARUM_ALERT));
FLARUM_ALERT = null;
}
var restoreUrl = localStorage.getItem('restoreUrl');
if (restoreUrl && this.get('session.isAuthenticated')) {
this.transitionTo(restoreUrl);
localStorage.removeItem('restoreUrl');
}
},
@@ -42,6 +49,10 @@ export default Ember.Route.extend(ApplicationRouteMixin, {
sessionChanged: function() {
this.refresh();
},
saveState: function() {
localStorage.setItem('restoreUrl', this.router.get('url'));
}
}
});

View File

@@ -28,7 +28,7 @@
{{ui/loading-indicator classNameBindings=":modal-loading loading:active"}}
{{#if welcomeUser}}
<div {{bind-attr class=":signup-welcome :fade" style=welcomeStyle}}>
<div {{bind-attr class=":signup-welcome" style=welcomeStyle}}>
{{user-avatar welcomeUser}}
<h3>Welcome, {{welcomeUser.username}}!</h3>

View File

@@ -9,10 +9,10 @@ export default Ember.View.extend(ModalView, {
didInsertElement: function() {
},
welcomeUserDidChange: Ember.observer('welcomeUser', function() {
if (this.get('welcomeUser')) {
welcomeUserDidChange: Ember.observer('controller.welcomeUser', function() {
if (this.get('controller.welcomeUser')) {
Ember.run.scheduleOnce('afterRender', this, function() {
this.$('.signup-welcome').addClass('in');
this.$('.signup-welcome').hide().fadeIn();
});
}
})