mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-18 15:17:25 +01:00
bail out and alert user if prize is too high
This commit is contained in:
@@ -114,9 +114,13 @@ 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'));
|
||||||
|
|
||||||
var isNew = !challenge._id;
|
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){
|
challenge.$save(function(_challenge){
|
||||||
if (isNew) {
|
if (isNew) {
|
||||||
Notification.text(window.env.t('challengeCreated'));
|
Notification.text(window.env.t('challengeCreated'));
|
||||||
|
|||||||
Reference in New Issue
Block a user