mirror of
https://github.com/sudoxnym/habitica.git
synced 2026-07-26 13:22:38 +00:00
bail out and alert user if prize is too high
This commit is contained in:
parent
7c4486e001
commit
5cd42e85c7
1 changed files with 6 additions and 2 deletions
|
|
@ -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'));
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue