Ghost/ghost/admin/app/routes/team/user.js
Kevin Ansfield e74e2e039e Update code to match eslint rules
no issue
- switch `jscs` and `jshint` inline config to `eslint` config
- fix eslint errors, predominantly in tests where the config now the main app config more closely
2016-11-14 13:26:00 +00:00

58 lines
1.6 KiB
JavaScript

/* eslint-disable camelcase */
import AuthenticatedRoute from 'ghost-admin/routes/authenticated';
import CurrentUserSettings from 'ghost-admin/mixins/current-user-settings';
import styleBody from 'ghost-admin/mixins/style-body';
export default AuthenticatedRoute.extend(styleBody, CurrentUserSettings, {
titleToken: 'Team - User',
classNames: ['team-view-user'],
model(params) {
return this.store.queryRecord('user', {slug: params.user_slug, include: 'count.posts'});
},
serialize(model) {
return {user_slug: model.get('slug')};
},
afterModel(user) {
this._super(...arguments);
return this.get('session.user').then((currentUser) => {
let isOwnProfile = user.get('id') === currentUser.get('id');
let isAuthor = currentUser.get('isAuthor');
let isEditor = currentUser.get('isEditor');
if (isAuthor && !isOwnProfile) {
this.transitionTo('team.user', currentUser);
} else if (isEditor && !isOwnProfile && !user.get('isAuthor')) {
this.transitionTo('team');
}
});
},
deactivate() {
let model = this.modelFor('team.user');
// we want to revert any unsaved changes on exit
if (model && model.get('hasDirtyAttributes')) {
model.rollbackAttributes();
}
model.get('errors').clear();
this._super(...arguments);
},
actions: {
didTransition() {
this.modelFor('team.user').get('errors').clear();
},
save() {
this.get('controller.save').perform();
}
}
});