Skip to content

Instantly share code, notes, and snippets.

@knownasilya
Last active December 28, 2015 01:09
Show Gist options
  • Save knownasilya/7417898 to your computer and use it in GitHub Desktop.
Save knownasilya/7417898 to your computer and use it in GitHub Desktop.
state manager
serviceStateManager: Ember.StateManager.extend({
enableLogging: true,
initialState: function () {
var accountType = this.get('auth.user.accountType'),
result = 'notProvider';
if (accountType === 'isp') {
result = 'isProvider';
}
return result;
}.property(),
states: {
isProvider: Ember.State.create({
enter: function (sm) {
this.setProperties({
isServiceDetailsVisible: false,
isDesiredServiceVisible: false
});
}
}),
notProvider: Ember.State.create({
enter: function (sm) {
var hasService = this.get('haveService');
// Assertion failed: Could not find state for path: "noService"
hasService ? sm.transitionTo('hasService') : sm.transitionTo('noService');
},
states: {
hasService: Ember.State.create({
enter: function (sm) {
var happy = this.get('happyWithService');
happy ? sm.transitionTo('happy') : sm.transitionTo('unhappy');
},
states: {
unhappy: Ember.State.create(),
happy: Ember.State.create()
}
}),
noService: Ember.State.create({
enter: function (sm) {
this.setProperties({
isCurrentServiceVisible: false,
isDesiredServiceVisible: true
});
}
})
}
})
}
}).create(),
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment