Transition Challenge -> Edit to the Singleton challenge view, to address issues associated with #4814

This commit is contained in:
Kevin Gisi
2015-03-28 05:01:44 -04:00
parent 6fb95ec27b
commit da81241ebe
3 changed files with 21 additions and 3 deletions

View File

@@ -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', { .state('options.social.challenges.detail.member', {
url: '/:uid', url: '/:uid',
templateUrl: 'partials/options.social.challenges.detail.member.html', templateUrl: 'partials/options.social.challenges.detail.member.html',

View File

@@ -1,7 +1,7 @@
"use strict"; "use strict";
habitrpg.controller("ChallengesCtrl", ['$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) { 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 // Use presence of cid to determine whether to show a list or a single
// challenge // challenge
@@ -40,6 +40,13 @@ habitrpg.controller("ChallengesCtrl", ['$rootScope','$scope', 'Shared', 'User',
// Challenge // 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 * Create
*/ */
@@ -95,6 +102,7 @@ habitrpg.controller("ChallengesCtrl", ['$rootScope','$scope', 'Shared', 'User',
// TODO figure out a more elegant way about this // TODO figure out a more elegant way about this
//challenge._editing = false; //challenge._editing = false;
challenge._locked = true; challenge._locked = true;
getChallenges();
} }
}); });
}; };

View File

@@ -24,7 +24,7 @@ script(type='text/ng-template', id='partials/options.social.challenges.detail.ht
// Edit button // Edit button
div(bindonce='challenge', ng-if='challenge.leader==user._id') div(bindonce='challenge', ng-if='challenge.leader==user._id')
div(ng-hide='challenge._locked==false') 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') button.btn.btn-sm.btn-warning(ng-click='close(challenge, $event)', tooltip=env.t('deleteOrSelect'))=env.t('endChallenge')
form(ng-show='challenge._locked==false') form(ng-show='challenge._locked==false')