Added hide and error message when a user tries to create a challenge for HabitRPG group and they have no gems

This commit is contained in:
TheHollidayInn
2015-04-06 10:06:59 -05:00
committed by Blade Barringer
parent 63a8bf63cb
commit fce622ddc7
4 changed files with 23 additions and 2 deletions

View File

@@ -55,5 +55,6 @@
"challengedEitherOwnedFilter": "Either",
"backToChallenges": "Back to all challenges",
"prizeValue": "<%= gemcount %>&nbsp;<%= gemicon %> Prize",
"clone": "Clone"
"clone": "Clone",
"challengeNotEnoughGems": "You do not have enough gems to post this challenge."
}

File diff suppressed because one or more lines are too long

View File

@@ -38,6 +38,9 @@ habitrpg.controller("ChallengesCtrl", ['$rootScope','$scope', 'Shared', 'User',
// override score() for tasks listed in challenges-editing pages, so that nothing happens
$scope.score = function(){}
//This is used to ensure the user has enough gems to create a challenge
$scope.enoughGems = true;
//------------------------------------------------------------
// Challenge
//------------------------------------------------------------
@@ -130,6 +133,7 @@ habitrpg.controller("ChallengesCtrl", ['$rootScope','$scope', 'Shared', 'User',
$scope.save = function(challenge) {
if (!challenge.group) return alert(window.env.t('selectGroup'));
var isNew = !challenge._id;
if (!$scope.enoughGems && isNew ) return alert(window.env.t('challengeNotEnoughGems'));
challenge.$save(function(_challenge){
if (isNew) {
Notification.text(window.env.t('challengeCreated'));
@@ -303,7 +307,10 @@ habitrpg.controller("ChallengesCtrl", ['$rootScope','$scope', 'Shared', 'User',
if (!gid) return;
var group = _.find($scope.groups, {_id:gid});
$scope.maxPrize = User.user.balance*4 + ((group && group.balance && group.leader==User.user._id) ? group.balance*4 : 0);
if (gid == 'habitrpg') $scope.newChallenge.prize = 1;
if (gid == 'habitrpg') {
$scope.newChallenge.prize = 1;
if ( $scope.maxPrize <= 0 ) $scope.enoughGems = false;
}
})
$scope.selectAll = function(){

View File

@@ -139,6 +139,17 @@ script(type='text/ng-template', id='partials/options.social.challenges.html')
.Pet_Currency_Gem1x
input.form-control(type='number', min="{{newChallenge.group=='habitrpg' ? 1 : 0}}", max="{{maxPrize}}", ng-model='newChallenge.prize', placeholder=env.t('prize'))
a.hint(popover="{{newChallenge.group=='habitrpg' ? env.t('prizePopTavern') : env.t('prizePop')}}", popover-trigger='mouseenter', popover-placement='right')
//- what's going on here?
br
br
div.alert.alert-warning(ng-hide="enoughGems")
=env.t('challengeNotEnoughGems')
.form-group
input.form-control(type='number', min="{{newChallenge.group=='habitrpg' ? 1 : 0}}", max="{{enoughGems ? maxPrize : null}}", ng-model='newChallenge.prize', placeholder=env.t('prize'), ng-show="enoughGems")
span.input-suffix.Pet_Currency_Gem1x.inline-gems
|&nbsp;
span.hint.vertical-20(popover=env.t('prizePop'), popover-trigger='mouseenter', popover-placement='right')
=env.t('moreInfo')
.pull-right(ng-show='newChallenge.group=="habitrpg"')
!=env.t('publicChallenges')