Set default ownership filter to either and fixed editing bug

This commit is contained in:
TheHollidayInn
2015-04-13 11:28:09 -05:00
parent 74ef8cd443
commit 71cc5f76fe
2 changed files with 15 additions and 11 deletions

View File

@@ -257,16 +257,20 @@ habitrpg.controller("ChallengesCtrl", ['$rootScope','$scope', 'Shared', 'User',
// TODO probably better to use $watch above, to avoid this being calculated on every digest cycle
$scope.filterChallenges = function(chal){
//Filter challenges that are owned by the user
if ($scope.search._isOwner == true) {
return (chal.leader._id == User.user.id);
} else if ($scope.search._isOwner == false) {
return (chal.leader._id != User.user.id);
}
if (!$scope.search) return true;
return (!$scope.search) ? true :
($scope.search.group[chal.group._id] &&
//Filter challenges that are owned by the user
if ($scope.search._isOwner == true) {
return (chal.leader._id == User.user.id);
} else if ($scope.search._isOwner == false) {
return (chal.leader._id != User.user.id);
} else {
return ($scope.search.group[chal.group._id] &&
(typeof $scope.search._isMember == 'undefined' || $scope.search._isMember == chal._isMember));
}
//By default we should return true to show all challenges
return true;
}
$scope.$watch('newChallenge.group', function(gid){