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

Commit

Permalink
fix(user): hide delete button for self (#1535)
Browse files Browse the repository at this point in the history
Remove delete button for self

Fixes #1531
  • Loading branch information
sujeethk authored and mleanos committed Oct 1, 2016
1 parent ae8d2b3 commit 0736a40
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
vm.user = user;
vm.remove = remove;
vm.update = update;
vm.isContextUserSelf = isContextUserSelf;

function remove(user) {
if ($window.confirm('Are you sure you want to delete this user?')) {
Expand Down Expand Up @@ -46,5 +47,9 @@
vm.error = errorResponse.data.message;
});
}

function isContextUserSelf() {
return vm.user.username === vm.authentication.user.username;
}
}
}());
Original file line number Diff line number Diff line change
Expand Up @@ -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.isContextUserSelf()">
<i class="glyphicon glyphicon-trash"></i>
</a>
</div>
Expand Down

0 comments on commit 0736a40

Please sign in to comment.