bail out and alert user if prize is too high

This commit is contained in:
Blade Barringer
2015-07-24 10:35:03 -05:00
parent 7c4486e001
commit 5cd42e85c7

View File

@@ -114,9 +114,13 @@ habitrpg.controller("ChallengesCtrl", ['$rootScope','$scope', 'Shared', 'User',
*/
$scope.save = function(challenge) {
if (!challenge.group) return alert(window.env.t('selectGroup'));
var isNew = !challenge._id;
$scope.hasEnoughGems(challenge.group);
if (!$scope.enoughGems && isNew ) return alert(window.env.t('challengeNotEnoughGems'));
if(isNew && challenge.prize > $scope.maxPrize) {
return alert(window.env.t('challengeNotEnoughGems'));
}
challenge.$save(function(_challenge){
if (isNew) {
Notification.text(window.env.t('challengeCreated'));