From 43c9683a8b46d21ad2485258a1203cab9581bc4f Mon Sep 17 00:00:00 2001 From: TheHollidayInn Date: Sun, 20 Sep 2015 10:26:08 -0500 Subject: [PATCH] Added param to filter challenges by guild when a challenge is first clicked from guild --- website/public/js/app.js | 2 +- website/public/js/controllers/challengesCtrl.js | 7 +++++++ website/views/options/social/challenge-box.jade | 2 +- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/website/public/js/app.js b/website/public/js/app.js index d0caf41c2b..971863d153 100644 --- a/website/public/js/app.js +++ b/website/public/js/app.js @@ -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; }); diff --git a/website/public/js/controllers/challengesCtrl.js b/website/public/js/controllers/challengesCtrl.js index d60c15bd00..c540ff6be5 100644 --- a/website/public/js/controllers/challengesCtrl.js +++ b/website/public/js/controllers/challengesCtrl.js @@ -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 ; + } }); } }; diff --git a/website/views/options/social/challenge-box.jade b/website/views/options/social/challenge-box.jade index 25364798d0..8e5c6569c4 100644 --- a/website/views/options/social/challenge-box.jade +++ b/website/views/options/social/challenge-box.jade @@ -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 |