Skip to content
This repository has been archived by the owner on Aug 30, 2021. It is now read-only.

fix(user): hide delete button for self #1535

Merged
merged 1 commit into from
Oct 1, 2016
Merged

fix(user): hide delete button for self #1535

merged 1 commit into from
Oct 1, 2016

Conversation

sujeethk
Copy link
Contributor

fix(user): hide delete button for self

Remove delete button for self

Fixes #1531

@coveralls
Copy link

coveralls commented Sep 30, 2016

Coverage Status

Coverage remained the same at 73.224% when pulling 16626bd94cae345aa5f9cff1c3e6e71865fe12b2 on sujeethk:fixes1531 into e3eafa6 on meanjs:master.

Copy link
Member

@mleanos mleanos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See my line comment.

@@ -8,7 +8,7 @@ <h1 ng-bind="vm.user.username"></h1>
<a class="btn btn-primary" ui-sref="admin.user-edit({userId: vm.user._id})">
<i class="glyphicon glyphicon-edit"></i>
</a>
<a class="btn btn-primary" ng-click="vm.remove()" ng-if="vm.user._id !== vm.authentication.user._id">
<a class="btn btn-primary" ng-click="vm.remove()" ng-if="vm.user.username !== vm.authentication.user.username">
Copy link
Member

@mleanos mleanos Sep 30, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using username here is OK. It always feels weird to me though, to compare using a field like this, vs the actual _id or some other more intentional field.

Instead of doing the comparison in the template, how about we create a flag that we manage in the controller using vm? Something like: vm.isCurrentUserSelf = isSelf(); in the controller. In this case, I feel better about using username.

By doing it this way, we can avoid the need to update the template if we ever change how we're determined what "self" means in this context.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or maybe a better name for the view-model field would be vm.isContextUserSelf or vm.isEditedUserSelf.. "isCurrentUserSelf" seems confusing.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mleanos did you mean client controller or server controller? reason I ask is the existing 'isCurrentUserOwner' is done on the server controller. I believe you mean client controller as you referred vm and I am ok with that approach. Just wanted to make sure you are ok if it is not consistent across

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep. I meant client-side. Just to keep the logic out of the view.

@sujeethk
Copy link
Contributor Author

sujeethk commented Oct 1, 2016

Updated per comments. Hoping coveralls doesn't drop.

Remove delete button for self

Fixes #1531
@coveralls
Copy link

coveralls commented Oct 1, 2016

Coverage Status

Coverage remained the same at 73.224% when pulling c3abe6d3728d134e0214c30d42da674909f87761 on sujeethk:fixes1531 into e3eafa6 on meanjs:master.

@coveralls
Copy link

coveralls commented Oct 1, 2016

Coverage Status

Coverage remained the same at 73.224% when pulling 9133d79 on sujeethk:fixes1531 into a7aebbd on meanjs:master.

Copy link
Member

@codydaig codydaig left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Member

@mleanos mleanos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thanks @sujeethk

@mleanos mleanos self-assigned this Oct 1, 2016
@mleanos mleanos added this to the 0.5.0 milestone Oct 1, 2016
@mleanos mleanos merged commit 0736a40 into meanjs:master Oct 1, 2016
@sujeethk sujeethk deleted the fixes1531 branch October 2, 2016 05:49
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Admin user able to delete self
4 participants