From cfd92cdc40a96649fa9e2be5263b05f4cc3d0a3b Mon Sep 17 00:00:00 2001 From: Peng DU Date: Tue, 20 Sep 2016 18:39:28 +0200 Subject: [PATCH] fix bug: code promotion change slot's price original --- app/assets/javascripts/controllers/trainings.coffee.erb | 1 + app/assets/javascripts/directives/coupon.coffee.erb | 6 ++++++ app/assets/templates/machines/reserve.html.erb | 2 +- app/assets/templates/shared/_coupon.html.erb | 4 ++-- app/assets/templates/trainings/reserve.html.erb | 2 +- 5 files changed, 11 insertions(+), 4 deletions(-) diff --git a/app/assets/javascripts/controllers/trainings.coffee.erb b/app/assets/javascripts/controllers/trainings.coffee.erb index 4f73efe9a..e7e955351 100644 --- a/app/assets/javascripts/controllers/trainings.coffee.erb +++ b/app/assets/javascripts/controllers/trainings.coffee.erb @@ -400,6 +400,7 @@ Application.Controllers.controller "ReserveTrainingController", ["$scope", "$sta if $scope.ctrl.member # reserve a training if this training will not be reserved and is not about to move and not is completed if !event.is_reserved && !$scope.slotToModify && !event.is_completed + $scope.coupon.applied = null if event != $scope.selectedTraining $scope.selectedTraining = event $scope.selectedTraining.offered = false diff --git a/app/assets/javascripts/directives/coupon.coffee.erb b/app/assets/javascripts/directives/coupon.coffee.erb index 531116100..2d1aa5812 100644 --- a/app/assets/javascripts/directives/coupon.coffee.erb +++ b/app/assets/javascripts/directives/coupon.coffee.erb @@ -5,6 +5,7 @@ Application.Directives.directive 'coupon', [ 'Coupon', 'growl', '_t', (Coupon, g show: '=' coupon: '=' userId: '@' + hasSelectSlot: '=' templateUrl: '<%= asset_path "shared/_coupon.html" %>' link: ($scope, element, attributes) -> @@ -18,6 +19,11 @@ Application.Directives.directive 'coupon', [ 'Coupon', 'growl', '_t', (Coupon, g # Binding for the code inputed $scope.couponCode = null + $scope.$watch 'hasSelectSlot', (newValue) -> + unless newValue + $scope.coupon = null + $scope.couponCode = null + $scope.code.input = false ## diff --git a/app/assets/templates/machines/reserve.html.erb b/app/assets/templates/machines/reserve.html.erb index f80ffb700..246df7ba5 100644 --- a/app/assets/templates/machines/reserve.html.erb +++ b/app/assets/templates/machines/reserve.html.erb @@ -78,7 +78,7 @@
{{ 'remove_this_slot' }}
- +
diff --git a/app/assets/templates/shared/_coupon.html.erb b/app/assets/templates/shared/_coupon.html.erb index d6661868b..7e00a29f5 100644 --- a/app/assets/templates/shared/_coupon.html.erb +++ b/app/assets/templates/shared/_coupon.html.erb @@ -1,5 +1,5 @@
- {{ 'i_have_a_coupon' }} + {{ 'i_have_a_coupon' }}
@@ -18,4 +18,4 @@
-
\ No newline at end of file + diff --git a/app/assets/templates/trainings/reserve.html.erb b/app/assets/templates/trainings/reserve.html.erb index 5f03078f4..34adf87e6 100644 --- a/app/assets/templates/trainings/reserve.html.erb +++ b/app/assets/templates/trainings/reserve.html.erb @@ -82,7 +82,7 @@ {{ 'remove_this_slot' }} - +