Added param to filter challenges by guild when a challenge is first clicked from guild

This commit is contained in:
TheHollidayInn
2015-09-20 10:26:08 -05:00
parent 87f6af346a
commit 43c9683a8b
3 changed files with 9 additions and 2 deletions

View File

@@ -148,6 +148,7 @@ window.habitrpg = angular.module('habitrpg',
// Options > Social > Challenges
.state('options.social.challenges', {
url: "/challenges",
params: { groupIdFilter: null },
controller: 'ChallengesCtrl',
templateUrl: "partials/options.social.challenges.html"
})
@@ -156,7 +157,6 @@ window.habitrpg = angular.module('habitrpg',
templateUrl: 'partials/options.social.challenges.detail.html',
controller: ['$scope', 'Challenges', '$stateParams',
function($scope, Challenges, $stateParams){
$scope.obj = $scope.challenge = Challenges.Challenge.get({cid:$stateParams.cid}, function(){
$scope.challenge._locked = true;
});

View File

@@ -5,6 +5,8 @@ habitrpg.controller("ChallengesCtrl", ['$rootScope','$scope', 'Shared', 'User',
// challenge
$scope.cid = $state.params.cid;
$scope.groupIdFilter = $stateParams.groupIdFilter;
_getChallenges();
// FIXME $scope.challenges needs to be resolved first (see app.js)
@@ -381,6 +383,11 @@ habitrpg.controller("ChallengesCtrl", ['$rootScope','$scope', 'Shared', 'User',
_isMember: "either",
_isOwner: "either"
};
//If we game from a group, then override the filter to that group
if ($scope.groupIdFilter) {
$scope.search.group = {};
$scope.search.group[$scope.groupIdFilter] = true ;
}
});
}
};

View File

@@ -10,7 +10,7 @@
table.table.table-striped
tr(ng-repeat='challenge in group.challenges')
td
a(ui-sref='options.social.challenges.detail({cid:challenge._id})') {{challenge.name}}
a(ui-sref='options.social.challenges.detail({cid:challenge._id, groupIdFilter: group._id})') {{challenge.name}}
div(ng-if='group.challenges.length == 0')
p
|