mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-18 15:17:25 +01:00
Reimplemented single challenge view code from #3319
This commit is contained in:
@@ -13,7 +13,7 @@ ul.challenge-accordion-header-specs
|
||||
color: white;
|
||||
margin-right: 5px;
|
||||
|
||||
#create-challenge-btn
|
||||
#back-to-challenges, #create-challenge-btn
|
||||
margin-bottom: 10px
|
||||
|
||||
#challenges-filters h3
|
||||
|
||||
@@ -3,8 +3,18 @@
|
||||
habitrpg.controller("ChallengesCtrl", ['$rootScope','$scope', 'Shared', 'User', 'Challenges', 'Notification', '$compile', 'Groups', '$state',
|
||||
function($rootScope, $scope, Shared, User, Challenges, Notification, $compile, Groups, $state) {
|
||||
|
||||
// FIXME $scope.challenges needs to be resolved first (see app.js)
|
||||
$scope.groups = Groups.Group.query({type:'party,guilds,tavern'});
|
||||
// Use presence of cid to determine whether to show a list or a single
|
||||
// challenge
|
||||
$scope.cid = $state.params.cid;
|
||||
|
||||
// Fetch single challenge if a cid is present; fetch multiple challenges
|
||||
// otherwise
|
||||
var getChallenges = function() {
|
||||
if ($scope.cid) {
|
||||
Challenges.Challenge.get({cid: $scope.cid}, function(challenge) {
|
||||
$scope.challenges = [challenge];
|
||||
});
|
||||
} else {
|
||||
Challenges.Challenge.query(function(challenges){
|
||||
$scope.challenges = challenges;
|
||||
$scope.groupsFilter = _.uniq(_.pluck(challenges, 'group'), function(g){return g._id});
|
||||
@@ -12,6 +22,15 @@ habitrpg.controller("ChallengesCtrl", ['$rootScope','$scope', 'Shared', 'User',
|
||||
group: _.transform($scope.groups, function(m,g){m[g._id]=true;})
|
||||
};
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
getChallenges();
|
||||
|
||||
// FIXME $scope.challenges needs to be resolved first (see app.js)
|
||||
$scope.groups = Groups.Group.query({type:'party,guilds,tavern'});
|
||||
|
||||
|
||||
// we should fix this, that's pretty brittle
|
||||
|
||||
// override score() for tasks listed in challenges-editing pages, so that nothing happens
|
||||
@@ -178,7 +197,7 @@ habitrpg.controller("ChallengesCtrl", ['$rootScope','$scope', 'Shared', 'User',
|
||||
|
||||
$scope.join = function(challenge){
|
||||
challenge.$join(function(){
|
||||
$scope.challenges = Challenges.Challenge.query();
|
||||
getChallenges()
|
||||
User.log({});
|
||||
});
|
||||
|
||||
@@ -189,7 +208,7 @@ habitrpg.controller("ChallengesCtrl", ['$rootScope','$scope', 'Shared', 'User',
|
||||
$scope.selectedChal = undefined;
|
||||
} else {
|
||||
$scope.selectedChal.$leave({keep:keep}, function(){
|
||||
$scope.challenges = Challenges.Challenge.query();
|
||||
getChallenges()
|
||||
User.log({});
|
||||
});
|
||||
}
|
||||
|
||||
@@ -67,7 +67,7 @@ script(type='text/ng-template', id='partials/options.social.challenges.html')
|
||||
.container-fluid
|
||||
.row
|
||||
.col-md-2
|
||||
.well#challenges-filters
|
||||
.well#challenges-filters(ng-hide="cid")
|
||||
h3=env.t('filter') + ':'
|
||||
h4=env.t('groups')
|
||||
ul.list-unstyled
|
||||
@@ -92,6 +92,8 @@ script(type='text/ng-template', id='partials/options.social.challenges.html')
|
||||
input(type='radio', name='search-participation-radio', ng-click='search._isMember = undefined', checked='checked')
|
||||
=env.t('either')
|
||||
.col-md-10
|
||||
a.btn.btn-info#back-to-challenges(ng-show="cid", ui-sref='options.social.challenges', ui-sref-opts='{reload: true}')
|
||||
| Back to all challenges
|
||||
// Creation form
|
||||
button.btn.btn-success#create-challenge-btn(ng-click='create()', ng-hide='newChallenge')=env.t('createChallenge')
|
||||
.create-challenge-from.well(ng-if='newChallenge')
|
||||
@@ -163,7 +165,7 @@ script(type='text/ng-template', id='partials/options.social.challenges.html')
|
||||
a.btn.btn-sm.btn-success(ng-hide='challenge._isMember', ng-click='join(challenge)')
|
||||
span.glyphicon.glyphicon-ok
|
||||
=env.t('join')
|
||||
a.accordion-toggle(ng-click='toggle(challenge._id)') {{challenge.name}}
|
||||
a.accordion-toggle(id="{{challenge._id}}" ng-click='toggle(challenge._id)') {{challenge.name}}
|
||||
.panel-body(ng-class='{collapse: !$stateParams.cid == challenge._id}')
|
||||
.accordion-inner(ng-if='$stateParams.cid == challenge._id')
|
||||
div(ui-view)
|
||||
|
||||
@@ -104,7 +104,7 @@ script(type='text/ng-template', id='partials/options.social.html')
|
||||
a(ui-sref='options.social.guilds.public')
|
||||
=env.t('guilds')
|
||||
li(ng-class="{ active: $state.includes('options.social.challenges') }")
|
||||
a(ui-sref='options.social.challenges')
|
||||
a(ui-sref='options.social.challenges', ui-sref-opts='{reload: true}')
|
||||
=env.t('challenges')
|
||||
li(ng-class="{ active: $state.includes('options.social.hall') }")
|
||||
a(ui-sref='options.social.hall.heroes')
|
||||
|
||||
Reference in New Issue
Block a user