mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-17 22:57:21 +01:00
Transition Challenge -> Edit to the Singleton challenge view, to address issues associated with #4814
This commit is contained in:
@@ -146,6 +146,16 @@ window.habitrpg = angular.module('habitrpg',
|
||||
});
|
||||
}]
|
||||
})
|
||||
.state('options.social.challenges.edit', {
|
||||
url: '/:cid/edit',
|
||||
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 = false;
|
||||
});
|
||||
}]
|
||||
})
|
||||
.state('options.social.challenges.detail.member', {
|
||||
url: '/:uid',
|
||||
templateUrl: 'partials/options.social.challenges.detail.member.html',
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
"use strict";
|
||||
|
||||
habitrpg.controller("ChallengesCtrl", ['$rootScope','$scope', 'Shared', 'User', 'Challenges', 'Notification', '$compile', 'Groups', '$state',
|
||||
function($rootScope, $scope, Shared, User, Challenges, Notification, $compile, Groups, $state) {
|
||||
habitrpg.controller("ChallengesCtrl", ['$rootScope','$scope', 'Shared', 'User', 'Challenges', 'Notification', '$compile', 'Groups', '$state', '$stateParams',
|
||||
function($rootScope, $scope, Shared, User, Challenges, Notification, $compile, Groups, $state, $stateParams) {
|
||||
|
||||
// Use presence of cid to determine whether to show a list or a single
|
||||
// challenge
|
||||
@@ -40,6 +40,13 @@ habitrpg.controller("ChallengesCtrl", ['$rootScope','$scope', 'Shared', 'User',
|
||||
// Challenge
|
||||
//------------------------------------------------------------
|
||||
|
||||
// Use this to force the top view to change, not just the nested view.
|
||||
$scope.edit = function(challenge) {
|
||||
$state.transitionTo('options.social.challenges.edit', {cid: challenge._id}, {
|
||||
reload: true, inherit: false, notify: true
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Create
|
||||
*/
|
||||
@@ -95,6 +102,7 @@ habitrpg.controller("ChallengesCtrl", ['$rootScope','$scope', 'Shared', 'User',
|
||||
// TODO figure out a more elegant way about this
|
||||
//challenge._editing = false;
|
||||
challenge._locked = true;
|
||||
getChallenges();
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
@@ -24,7 +24,7 @@ script(type='text/ng-template', id='partials/options.social.challenges.detail.ht
|
||||
// Edit button
|
||||
div(bindonce='challenge', ng-if='challenge.leader==user._id')
|
||||
div(ng-hide='challenge._locked==false')
|
||||
button.btn.btn-sm.btn-default(ng-click='challenge._locked = false')=env.t('edit')
|
||||
button.btn.btn-sm.btn-default(ng-click='edit(challenge)')=env.t('edit')
|
||||
button.btn.btn-sm.btn-warning(ng-click='close(challenge, $event)', tooltip=env.t('deleteOrSelect'))=env.t('endChallenge')
|
||||
|
||||
form(ng-show='challenge._locked==false')
|
||||
|
||||
Reference in New Issue
Block a user