2015-05-18 12:43:00 +01:00
|
|
|
import Ember from 'ember';
|
2015-05-12 08:10:41 -06:00
|
|
|
|
2015-06-18 11:59:08 +01:00
|
|
|
var TeamUserView = Ember.View.extend({
|
|
|
|
tagName: 'section',
|
|
|
|
classNames: ['gh-view'],
|
2014-07-29 18:11:02 -06:00
|
|
|
currentUser: Ember.computed.alias('controller.session.user'),
|
2014-10-24 21:09:50 +00:00
|
|
|
|
2014-07-29 18:11:02 -06:00
|
|
|
isNotOwnProfile: Ember.computed('controller.user.id', 'currentUser.id', function () {
|
|
|
|
return this.get('controller.user.id') !== this.get('currentUser.id');
|
|
|
|
}),
|
2014-10-24 21:09:50 +00:00
|
|
|
|
2014-08-12 18:06:34 -06:00
|
|
|
isNotOwnersProfile: Ember.computed.not('controller.user.isOwner'),
|
2014-10-24 21:09:50 +00:00
|
|
|
|
2014-07-29 18:11:02 -06:00
|
|
|
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-10-24 21:09:50 +00:00
|
|
|
|
2014-08-12 18:06:34 -06:00
|
|
|
rolesDropdownIsVisible: Ember.computed.and('isNotOwnProfile', 'canAssignRoles', 'isNotOwnersProfile'),
|
2014-07-31 00:23:42 -07:00
|
|
|
|
|
|
|
deleteUserActionIsVisible: Ember.computed('currentUser', 'canAssignRoles', 'controller.user', function () {
|
|
|
|
if ((this.get('canAssignRoles') && this.get('isNotOwnProfile') && !this.get('controller.user.isOwner')) ||
|
2014-11-18 11:37:35 +00:00
|
|
|
(this.get('currentUser.isEditor') && (this.get('isNotOwnProfile') ||
|
2014-07-31 00:23:42 -07:00
|
|
|
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
|
|
|
});
|
|
|
|
|
2015-06-18 11:59:08 +01:00
|
|
|
export default TeamUserView;
|