diff --git a/.fabmanager-version b/.fabmanager-version index 26f8b8bcd..62e64205b 100644 --- a/.fabmanager-version +++ b/.fabmanager-version @@ -1 +1 @@ -2.4.5 \ No newline at end of file +2.4.6 \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index d256af89b..ed68f9cc0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ # Changelog Fab Manager +## v2.4.6 2016 Novembre 30 + +- Change display of message about coupon application status +- Fix a bug: compute price API return error 500 if reservable_id is not provided + ## v2.4.5 2016 November 29 - Ability to create coupons with cash amounts (previously only percentages were allowed) diff --git a/app/assets/javascripts/directives/coupon.coffee.erb b/app/assets/javascripts/directives/coupon.coffee.erb index 4392297bf..4b42558f8 100644 --- a/app/assets/javascripts/directives/coupon.coffee.erb +++ b/app/assets/javascripts/directives/coupon.coffee.erb @@ -1,4 +1,4 @@ -Application.Directives.directive 'coupon', [ '$rootScope', 'Coupon', 'growl', '_t', ($rootScope, Coupon, growl, _t) -> +Application.Directives.directive 'coupon', [ '$rootScope', 'Coupon', '_t', ($rootScope, Coupon, _t) -> { restrict: 'E' scope: @@ -19,6 +19,9 @@ Application.Directives.directive 'coupon', [ '$rootScope', 'Coupon', 'growl', '_ # Binding for the code inputed (see the attached template) $scope.couponCode = null + # Code validation messages + $scope.messages = [] + # Re-compute if the code can be applied when the total of the cart changes $scope.$watch 'total', (newValue, oldValue) -> if newValue and newValue != oldValue and $scope.couponCode @@ -28,6 +31,7 @@ Application.Directives.directive 'coupon', [ '$rootScope', 'Coupon', 'growl', '_ # Callback to validate the code ## $scope.validateCode = -> + $scope.messages = [] if $scope.couponCode == '' $scope.status = 'pending' $scope.coupon = null @@ -36,13 +40,19 @@ Application.Directives.directive 'coupon', [ '$rootScope', 'Coupon', 'growl', '_ $scope.status = 'valid' $scope.coupon = res if res.type == 'percent_off' - growl.success(_t('the_coupon_has_been_applied_you_get_PERCENT_discount', {PERCENT: res.percent_off})) + $scope.messages.push(type: 'success', message: _t('the_coupon_has_been_applied_you_get_PERCENT_discount', {PERCENT: res.percent_off})) else - growl.success(_t('the_coupon_has_been_applied_you_get_AMOUNT_CURRENCY', {AMOUNT: res.amount_off, CURRENCY: $rootScope.currencySymbol})) + $scope.messages.push(type: 'success', message: _t('the_coupon_has_been_applied_you_get_AMOUNT_CURRENCY', {AMOUNT: res.amount_off, CURRENCY: $rootScope.currencySymbol})) , (err) -> $scope.status = 'invalid' $scope.coupon = null - growl.error(_t('unable_to_apply_the_coupon_because_'+err.data.status)) + $scope.messages.push(type: 'danger', message: _t('unable_to_apply_the_coupon_because_'+err.data.status)) + + ## + # Callback to remove the message at provided index from the displayed list + ## + $scope.closeMessage = (index) -> + $scope.messages.splice(index, 1); } ] diff --git a/app/assets/templates/shared/_coupon.html.erb b/app/assets/templates/shared/_coupon.html.erb index 7e00a29f5..bc4552ece 100644 --- a/app/assets/templates/shared/_coupon.html.erb +++ b/app/assets/templates/shared/_coupon.html.erb @@ -3,7 +3,7 @@
-
+
+ + {{msg.message}}
diff --git a/app/controllers/api/prices_controller.rb b/app/controllers/api/prices_controller.rb index 2c9dacd10..19acd769e 100644 --- a/app/controllers/api/prices_controller.rb +++ b/app/controllers/api/prices_controller.rb @@ -41,7 +41,7 @@ class API::PricesController < API::ApiController _user = User.find(_price_params[:user_id]) # reservable if _price_params[:reservable_id].nil? - @amount = {elements: nil, total: 0} + @amount = {elements: nil, total: 0, before_coupon: 0} else _reservable = _price_params[:reservable_type].constantize.find(_price_params[:reservable_id]) @amount = Price.compute(current_user.is_admin?, _user, _reservable, _price_params[:slots_attributes], _price_params[:plan_id], _price_params[:nb_reserve_places], _price_params[:tickets_attributes], coupon_params[:coupon_code])