1
0
mirror of https://github.com/LaCasemate/fab-manager.git synced 2025-02-20 14:54:15 +01:00

fix remove slot from cart

This commit is contained in:
Sylvain 2017-02-21 15:26:11 +01:00
parent fe6f85eb7c
commit 3837604dd6
3 changed files with 17 additions and 16 deletions

View File

@ -379,14 +379,14 @@ Application.Controllers.controller "ReserveMachineController", ["$scope", "$stat
$scope.selectedEvent.title = _t('i_reserve')
updateCalendar()
$scope.markSlotAsRemoved = ->
$scope.selectedEvent.backgroundColor = 'white'
$scope.selectedEvent.borderColor = FREE_SLOT_BORDER_COLOR
$scope.selectedEvent.title = ''
$scope.selectedEvent.isValid = false
$scope.selectedEvent.id = null
$scope.selectedEvent.is_reserved = false
$scope.selectedEvent.can_modify = false
$scope.markSlotAsRemoved = (slot) ->
slot.backgroundColor = 'white'
slot.borderColor = FREE_SLOT_BORDER_COLOR
slot.title = ''
slot.isValid = false
slot.id = null
slot.is_reserved = false
slot.can_modify = false
refetchCalendar()
$scope.markSlotAsModifying = ->

View File

@ -52,10 +52,10 @@ Application.Directives.directive 'cart', [ '$rootScope', '$uibModal', 'dialogs',
##
# Add the provided slot to the shopping cart (state transition from free to 'about to be reserved')
# and increment the total amount of the cart if needed.
# @param machineSlot {Object} fullCalendar event object
# @param slot {Object} fullCalendar event object
##
$scope.validMachineSlot = (machineSlot)->
machineSlot.isValid = true
$scope.validateSlot = (slot)->
slot.isValid = true
updateCartPrice()
@ -70,10 +70,11 @@ Application.Directives.directive 'cart', [ '$rootScope', '$uibModal', 'dialogs',
$scope.events.reserved.splice(index, 1)
# if is was the last slot, we remove any plan from the cart
if $scope.events.reserved.length == 0
$scope.selectedPlan = null
$scope.plansAreShown = false
$scope.selectedPlan = null
$scope.plan = null
$scope.modePlans = false
$scope.onSlotRemovedFromCart(machineSlot) if typeof $scope.onSlotRemovedFromCart == 'function'
updateCartPrice()
$scope.onSlotRemovedFromCart() if typeof $scope.onSlotRemovedFromCart == 'function'

View File

@ -30,10 +30,10 @@
</div>
</div>
<div>
<button class="btn btn-valid btn-warning btn-block text-u-c r-b" ng-click="validMachineSlot(machineSlot)" ng-if="!machineSlot.isValid" translate>{{ 'confirm_this_slot' }}</button>
<button class="btn btn-valid btn-warning btn-block text-u-c r-b" ng-click="validateSlot(machineSlot)" ng-if="!machineSlot.isValid" translate>{{ 'confirm_this_slot' }}</button>
</div>
<div class="clear"><a class="pull-right m-b-sm text-u-l ng-scope m-r-sm" href="#" ng-click="removeMachineSlot(machineSlot, $event)" ng-if="machineSlot.isValid" translate>{{ 'remove_this_slot' }}</a></div>
<div class="clear"><a class="pull-right m-b-sm text-u-l ng-scope m-r-sm" href="#" ng-click="removeMachineSlot(machineSlot, $index)" ng-if="machineSlot.isValid" translate>{{ 'remove_this_slot' }}</a></div>
</div>
<coupon show="machineSlotsValid() && (!modePlans || selectedPlan)" coupon="coupon.applied" total="totalNoCoupon" user-id="{{user.id}}"></coupon>