Skip to content

Commit b23ebfd

Browse files
committed
Merge branch 'dev' for release 2.4.6
2 parents 920270e + 3fad06c commit b23ebfd

File tree

5 files changed

+24
-7
lines changed

5 files changed

+24
-7
lines changed

.fabmanager-version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
2.4.5
1+
2.4.6

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# Changelog Fab Manager
22

3+
## v2.4.6 2016 Novembre 30
4+
5+
- Change display of message about coupon application status
6+
- Fix a bug: compute price API return error 500 if reservable_id is not provided
7+
38
## v2.4.5 2016 November 29
49

510
- Ability to create coupons with cash amounts (previously only percentages were allowed)

app/assets/javascripts/directives/coupon.coffee.erb

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Application.Directives.directive 'coupon', [ '$rootScope', 'Coupon', 'growl', '_t', ($rootScope, Coupon, growl, _t) ->
1+
Application.Directives.directive 'coupon', [ '$rootScope', 'Coupon', '_t', ($rootScope, Coupon, _t) ->
22
{
33
restrict: 'E'
44
scope:
@@ -19,6 +19,9 @@ Application.Directives.directive 'coupon', [ '$rootScope', 'Coupon', 'growl', '_
1919
# Binding for the code inputed (see the attached template)
2020
$scope.couponCode = null
2121

22+
# Code validation messages
23+
$scope.messages = []
24+
2225
# Re-compute if the code can be applied when the total of the cart changes
2326
$scope.$watch 'total', (newValue, oldValue) ->
2427
if newValue and newValue != oldValue and $scope.couponCode
@@ -28,6 +31,7 @@ Application.Directives.directive 'coupon', [ '$rootScope', 'Coupon', 'growl', '_
2831
# Callback to validate the code
2932
##
3033
$scope.validateCode = ->
34+
$scope.messages = []
3135
if $scope.couponCode == ''
3236
$scope.status = 'pending'
3337
$scope.coupon = null
@@ -36,13 +40,19 @@ Application.Directives.directive 'coupon', [ '$rootScope', 'Coupon', 'growl', '_
3640
$scope.status = 'valid'
3741
$scope.coupon = res
3842
if res.type == 'percent_off'
39-
growl.success(_t('the_coupon_has_been_applied_you_get_PERCENT_discount', {PERCENT: res.percent_off}))
43+
$scope.messages.push(type: 'success', message: _t('the_coupon_has_been_applied_you_get_PERCENT_discount', {PERCENT: res.percent_off}))
4044
else
41-
growl.success(_t('the_coupon_has_been_applied_you_get_AMOUNT_CURRENCY', {AMOUNT: res.amount_off, CURRENCY: $rootScope.currencySymbol}))
45+
$scope.messages.push(type: 'success', message: _t('the_coupon_has_been_applied_you_get_AMOUNT_CURRENCY', {AMOUNT: res.amount_off, CURRENCY: $rootScope.currencySymbol}))
4246
, (err) ->
4347
$scope.status = 'invalid'
4448
$scope.coupon = null
45-
growl.error(_t('unable_to_apply_the_coupon_because_'+err.data.status))
49+
$scope.messages.push(type: 'danger', message: _t('unable_to_apply_the_coupon_because_'+err.data.status))
50+
51+
##
52+
# Callback to remove the message at provided index from the displayed list
53+
##
54+
$scope.closeMessage = (index) ->
55+
$scope.messages.splice(index, 1);
4656
}
4757
]
4858

app/assets/templates/shared/_coupon.html.erb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
<div ng-show="code.input">
55
<label for="coupon_code" translate>{{ 'code_' }}</label>
6-
<div class="input-group">
6+
<div class="input-group m-b">
77
<input type="text"
88
class="form-control"
99
name="coupon_code"
@@ -17,5 +17,7 @@
1717
<i class="fa fa-check" ng-show="status == 'valid'"></i>
1818
</span>
1919
</div>
20+
21+
<uib-alert ng-repeat="msg in messages" type="{{msg.type}}" close="closeMessage($index)">{{msg.message}}</uib-alert>
2022
</div>
2123
</div>

app/controllers/api/prices_controller.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ def compute
4141
_user = User.find(_price_params[:user_id])
4242
# reservable
4343
if _price_params[:reservable_id].nil?
44-
@amount = {elements: nil, total: 0}
44+
@amount = {elements: nil, total: 0, before_coupon: 0}
4545
else
4646
_reservable = _price_params[:reservable_type].constantize.find(_price_params[:reservable_id])
4747
@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])

0 commit comments

Comments
 (0)