2014-07-29 18:11:02 -06:00
|
|
|
var SettingsUserView = Ember.View.extend({
|
|
|
|
currentUser: Ember.computed.alias('controller.session.user'),
|
|
|
|
|
|
|
|
isNotOwnProfile: Ember.computed('controller.user.id', 'currentUser.id', function () {
|
|
|
|
return this.get('controller.user.id') !== this.get('currentUser.id');
|
|
|
|
}),
|
|
|
|
|
|
|
|
canAssignRoles: Ember.computed.or('currentUser.isAdmin', 'currentUser.isOwner'),
|
2014-08-01 13:03:26 -07:00
|
|
|
|
2014-08-02 07:02:50 -07:00
|
|
|
canMakeOwner: Ember.computed.and('currentUser.isOwner', 'isNotOwnProfile', 'controller.user.isAdmin'),
|
2014-07-29 18:11:02 -06:00
|
|
|
|
2014-07-31 00:23:42 -07:00
|
|
|
rolesDropdownIsVisible: Ember.computed.and('isNotOwnProfile', 'canAssignRoles'),
|
|
|
|
|
|
|
|
deleteUserActionIsVisible: Ember.computed('currentUser', 'canAssignRoles', 'controller.user', function () {
|
|
|
|
if ((this.get('canAssignRoles') && this.get('isNotOwnProfile') && !this.get('controller.user.isOwner')) ||
|
|
|
|
(this.get('currentUser.isEditor') && (!this.get('isNotOwnProfile') ||
|
|
|
|
this.get('controller.user.isAuthor')))) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}),
|
|
|
|
|
2014-08-01 13:03:26 -07:00
|
|
|
userActionsAreVisible: Ember.computed.or('deleteUserActionIsVisible', 'canMakeOwner')
|
2014-07-31 00:23:42 -07:00
|
|
|
|
2014-07-29 18:11:02 -06:00
|
|
|
});
|
|
|
|
|
|
|
|
export default SettingsUserView;
|