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:
kholliday
2015-03-10 22:15:24 -05:00
parent 3830a39804
commit 8a121a5dc3
3 changed files with 12 additions and 4 deletions

View File

@@ -46,5 +46,6 @@
"removeTasks": "Remove Tasks", "removeTasks": "Remove Tasks",
"keepTasks": "Keep Tasks", "keepTasks": "Keep Tasks",
"closeCha": "Close challenge and...", "closeCha": "Close challenge and...",
"leaveCha": "Leave challenge and..." "leaveCha": "Leave challenge and...",
"challengeNotEnoughGems": "You do not have enough gems to post this challenge."
} }

View File

@@ -45,6 +45,7 @@ habitrpg.controller("ChallengesCtrl", ['$rootScope','$scope', 'Shared', 'User',
*/ */
$scope.save = function(challenge) { $scope.save = function(challenge) {
if (!challenge.group) return alert(window.env.t('selectGroup')); if (!challenge.group) return alert(window.env.t('selectGroup'));
if (!$scope.enoughGems) return alert(window.env.t('challengeNotEnoughGems'));
var isNew = !challenge._id; var isNew = !challenge._id;
challenge.$save(function(_challenge){ challenge.$save(function(_challenge){
if (isNew) { if (isNew) {
@@ -218,7 +219,11 @@ habitrpg.controller("ChallengesCtrl", ['$rootScope','$scope', 'Shared', 'User',
if (!gid) return; if (!gid) return;
var group = _.find($scope.groups, {_id:gid}); 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); $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; $scope.enoughGems = true;
if (gid == 'habitrpg') {
$scope.newChallenge.prize = 1;
if ( $scope.maxPrize <= 0 ) $scope.enoughGems = false;
}
}) })
$scope.selectAll = function(){ $scope.selectAll = function(){

View File

@@ -116,9 +116,11 @@ script(type='text/ng-template', id='partials/options.social.challenges.html')
//- what's going on here? //- what's going on here?
br br
br br
div.alert.alert-warning(ng-hide="enoughGems")
=env.t('challengeNotEnoughGems')
.form-group .form-group
input.form-control(type='number', min="{{newChallenge.group=='habitrpg' ? 1 : 0}}", max="{{maxPrize}}", ng-model='newChallenge.prize', placeholder=env.t('prize')) 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 span.input-suffix.Pet_Currency_Gem1x.inline-gems
|&nbsp; |&nbsp;
span.hint.vertical-20(popover=env.t('prizePop'), popover-trigger='mouseenter', popover-placement='right') span.hint.vertical-20(popover=env.t('prizePop'), popover-trigger='mouseenter', popover-placement='right')