1
0
mirror of https://github.com/LaCasemate/fab-manager.git synced 2025-01-17 06:52:27 +01:00

split calendar & cart logic for machines

This commit is contained in:
Sylvain 2017-02-21 13:42:12 +01:00
parent afd1cb4ce7
commit 3db55019c9
4 changed files with 257 additions and 209 deletions

View File

@ -297,12 +297,6 @@ Application.Controllers.controller "ReserveMachineController", ["$scope", "$stat
## bind the machine availabilities with full-Calendar events
$scope.eventSources = []
## fullCalendar event. The last selected slot that the user want to book
$scope.slotToPlace = null
## fullCalendar event. An already booked slot that the user want to modify
$scope.slotToModify = null
## indicates the state of the current view : calendar or plans information
$scope.plansAreShown = false
@ -312,7 +306,10 @@ Application.Controllers.controller "ReserveMachineController", ["$scope", "$stat
$scope.planSelectionTime = null
## array of fullCalendar events. Slots where the user want to book
$scope.eventsReserved = []
$scope.events =
reserved: []
modifiable: null
placable: null
## total amount of the bill to pay
$scope.amountTotal = 0
@ -328,6 +325,8 @@ Application.Controllers.controller "ReserveMachineController", ["$scope", "$stat
$scope.selectedEvent = null
$scope.settings = settingsPromise
## is the user allowed to change the date of his booking
$scope.enableBookingMove = true
@ -375,69 +374,60 @@ Application.Controllers.controller "ReserveMachineController", ["$scope", "$stat
##
# Cancel the current booking modification, removing the previously booked slot from the selection
# @param e {Object} see https://docs.angularjs.org/guide/expression#-event-
##
$scope.removeSlotToModify = (e) ->
e.preventDefault()
if $scope.slotToPlace
$scope.slotToPlace.backgroundColor = 'white'
$scope.slotToPlace.title = ''
$scope.slotToPlace = null
$scope.slotToModify.title = if $scope.currentUser.role isnt 'admin' then _t('i_ve_reserved') else _t('not_available')
$scope.slotToModify.backgroundColor = 'white'
$scope.slotToModify = null
uiCalendarConfig.calendars.calendar.fullCalendar 'rerenderEvents'
$scope.markSlotAsAdded = ->
$scope.selectedEvent.backgroundColor = FREE_SLOT_BORDER_COLOR
$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
refetchCalendar()
$scope.markSlotAsModifying = ->
$scope.selectedEvent.backgroundColor = '#eee'
$scope.selectedEvent.title = _t('i_change')
updateCalendar()
$scope.changeModifyMachineSlot = ->
if $scope.events.placable
$scope.events.placable.backgroundColor = 'white'
$scope.events.placable.title = ''
if !$scope.events.placable or $scope.events.placable._id != $scope.selectedEvent._id
$scope.selectedEvent.backgroundColor = '#bbb'
$scope.selectedEvent.title = _t('i_shift')
updateCalendar()
##
# When modifying an already booked reservation, cancel the choice of the new slot
# @param e {Object} see https://docs.angularjs.org/guide/expression#-event-
##
$scope.removeSlotToPlace = (e)->
e.preventDefault()
$scope.slotToPlace.backgroundColor = 'white'
$scope.slotToPlace.title = ''
$scope.slotToPlace = null
uiCalendarConfig.calendars.calendar.fullCalendar 'rerenderEvents'
##
# When modifying an already booked reservation, confirm the modification.
##
# When modifying an already booked reservation, callback when the modification was successfully done.
##
$scope.modifyMachineSlot = ->
Slot.update {id: $scope.slotToModify.id},
slot:
start_at: $scope.slotToPlace.start
end_at: $scope.slotToPlace.end
availability_id: $scope.slotToPlace.availability_id
, -> # success
$scope.modifiedSlots =
newReservedSlot: $scope.slotToPlace
oldReservedSlot: $scope.slotToModify
$scope.slotToPlace.title = if $scope.currentUser.role isnt 'admin' then _t('i_ve_reserved') else _t('not_available')
$scope.slotToPlace.backgroundColor = 'white'
$scope.slotToPlace.borderColor = $scope.slotToModify.borderColor
$scope.slotToPlace.id = $scope.slotToModify.id
$scope.slotToPlace.is_reserved = true
$scope.slotToPlace.can_modify = true
$scope.slotToPlace = null
$scope.modifiedSlots =
newReservedSlot: $scope.events.placable
oldReservedSlot: $scope.events.modifiable
$scope.events.placable.title = if $scope.currentUser.role isnt 'admin' then _t('i_ve_reserved') else _t('not_available')
$scope.events.placable.backgroundColor = 'white'
$scope.events.placable.borderColor = $scope.events.modifiable.borderColor
$scope.events.placable.id = $scope.events.modifiable.id
$scope.events.placable.is_reserved = true
$scope.events.placable.can_modify = true
$scope.events.placable = null
$scope.slotToModify.backgroundColor = 'white'
$scope.slotToModify.title = ''
$scope.slotToModify.borderColor = FREE_SLOT_BORDER_COLOR
$scope.slotToModify.id = null
$scope.slotToModify.is_reserved = false
$scope.slotToModify.can_modify = false
$scope.slotToModify = null
$scope.events.modifiable.backgroundColor = 'white'
$scope.events.modifiable.title = ''
$scope.events.modifiable.borderColor = FREE_SLOT_BORDER_COLOR
$scope.events.modifiable.id = null
$scope.events.modifiable.is_reserved = false
$scope.events.modifiable.can_modify = false
$scope.events.modifiable = null
uiCalendarConfig.calendars.calendar.fullCalendar 'rerenderEvents'
, (err) -> # failure
growl.error(_t('unable_to_change_the_reservation'))
console.error(err)
updateCalendar()
@ -445,14 +435,13 @@ Application.Controllers.controller "ReserveMachineController", ["$scope", "$stat
# Cancel the current booking modification, reseting the whole process
##
$scope.cancelModifyMachineSlot = ->
$scope.slotToPlace.backgroundColor = 'white'
$scope.slotToPlace.title = ''
$scope.slotToPlace = null
$scope.slotToModify.title = if $scope.currentUser.role isnt 'admin' then _t('i_ve_reserved') else _t('not_available')
$scope.slotToModify.backgroundColor = 'white'
$scope.slotToModify = null
if $scope.events.placable
$scope.events.placable.backgroundColor = 'white'
$scope.events.placable.title = ''
$scope.events.modifiable.title = if $scope.currentUser.role isnt 'admin' then _t('i_ve_reserved') else _t('not_available')
$scope.events.modifiable.backgroundColor = 'white'
uiCalendarConfig.calendars.calendar.fullCalendar 'rerenderEvents'
updateCalendar()
@ -503,29 +492,17 @@ Application.Controllers.controller "ReserveMachineController", ["$scope", "$stat
##
# Checks if $scope.slotToModify and $scope.slotToPlace have tag incompatibilities
# Checks if $scope.events.modifiable and $scope.events.placable have tag incompatibilities
# @returns {boolean} true in case of incompatibility
##
$scope.tagMissmatch = ->
for tag in $scope.slotToModify.tags
if tag.id not in $scope.slotToPlace.tag_ids
for tag in $scope.events.modifiable.tags
if tag.id not in $scope.events.placable.tag_ids
return true
false
$scope.updateCalendar = ->
uiCalendarConfig.calendars.calendar.fullCalendar 'rerenderEvents'
$scope.refetchCalendar = ->
$timeout ->
uiCalendarConfig.calendars.calendar.fullCalendar 'refetchEvents'
uiCalendarConfig.calendars.calendar.fullCalendar 'rerenderEvents'
##
# Once the reservation is booked (payment process successfully completed), change the event style
# in fullCalendar, update the user's subscription and free-credits if needed
@ -554,8 +531,7 @@ Application.Controllers.controller "ReserveMachineController", ["$scope", "$stat
Auth._currentUser.subscribed_plan = angular.copy($scope.selectedPlan)
$scope.plansAreShown = false
uiCalendarConfig.calendars.calendar.fullCalendar 'refetchEvents'
uiCalendarConfig.calendars.calendar.fullCalendar 'rerenderEvents'
refetchCalendar()
@ -618,6 +594,16 @@ Application.Controllers.controller "ReserveMachineController", ["$scope", "$stat
slot.user = user
updateCalendar = ->
uiCalendarConfig.calendars.calendar.fullCalendar 'rerenderEvents'
refetchCalendar = ->
$timeout ->
uiCalendarConfig.calendars.calendar.fullCalendar 'refetchEvents'
uiCalendarConfig.calendars.calendar.fullCalendar 'rerenderEvents'
## !!! MUST BE CALLED AT THE END of the controller
initialize()

View File

@ -10,39 +10,36 @@ UNAVAILABLE_SLOT_BORDER_COLOR = '<%= AvailabilityHelper::MACHINE_IS_RESERVED_BY_
BOOKED_SLOT_BORDER_COLOR = '<%= AvailabilityHelper::IS_RESERVED_BY_CURRENT_USER %>'
Application.Directives.directive 'cart', [ '$rootScope', '$uibModal', 'dialogs', 'growl', 'Auth', 'Price', 'Wallet', 'CustomAsset', 'helpers', '_t'
, ($rootScope, $uibModal, dialogs, growl, Auth, Price, Wallet, CustomAsset, helpers, _t) ->
Application.Directives.directive 'cart', [ '$rootScope', '$uibModal', 'dialogs', 'growl', 'Auth', 'Price', 'Wallet', 'CustomAsset', 'Slot', 'helpers', '_t'
, ($rootScope, $uibModal, dialogs, growl, Auth, Price, Wallet, CustomAsset, Slot, helpers, _t) ->
{
restrict: 'E'
scope:
slot: '='
slotSelectionTime: '='
eventsReserved: '='
onUpdate: '='
onOutdated: '='
events: '='
onSlotAddedToCart: '='
onSlotRemovedFromCart: '='
onSlotStartToModify: '='
onSlotModifyDestination: '='
onSlotModifySuccess: '='
onSlotModifyCancel: '='
onSlotModifyUnselect: '='
onSlotCancelSuccess: '='
user: '='
modePlans: '='
plan: '='
planSelectionTime: '='
afterPayment: '='
settings: '='
templateUrl: '<%= asset_path "shared/_cart.html" %>'
link: ($scope, element, attributes) ->
## fullCalendar event. An already booked slot that the user want to modify
$scope.slotToModify = null
## fullCalendar event. The last selected slot that the user want to book
$scope.slotToPlace = null
$scope.paidMachineSlots = null
## will store the user's plan if he choosed to buy one
$scope.selectedPlan = null
$scope.modifiedSlots = null
$scope.canceledSlot = null
## total amount of the bill to pay
$scope.amountTotal = 0
@ -53,6 +50,18 @@ Application.Directives.directive 'cart', [ '$rootScope', '$uibModal', 'dialogs',
$scope.coupon =
applied: null
## Global config: is the user authorized to change his bookings slots?
$scope.enableBookingMove = ($scope.settings.booking_move_enable == "true")
## Global config: delay in hours before a booking while changing the booking slot is forbidden
$scope.moveBookingDelay = parseInt($scope.settings.booking_move_delay)
## Global config: is the user authorized to cancel his bookings?
$scope.enableBookingCancel = ($scope.settings.booking_cancel_enable == "true")
## Global config: delay in hours before a booking while the cancellation is forbidden
$scope.cancelBookingDelay = parseInt($scope.settings.booking_cancel_delay)
##
@ -70,29 +79,16 @@ Application.Directives.directive 'cart', [ '$rootScope', '$uibModal', 'dialogs',
# Remove the provided slot from the shopping cart (state transition from 'about to be reserved' to free)
# and decrement the total amount of the cart if needed.
# @param machineSlot {Object} fullCalendar event object
# @param e {Object} see https://docs.angularjs.org/guide/expression#-event-
# @param index {number} index of the slot in the reservation array
##
$scope.removeMachineSlot = (machineSlot, e)->
e.preventDefault() if e
machineSlot.backgroundColor = 'white'
machineSlot.borderColor = FREE_SLOT_BORDER_COLOR
machineSlot.title = ''
machineSlot.isValid = false
if machineSlot.machine.is_reduced_amount
angular.forEach $scope.user.machine_credits, (credit)->
if credit.machine_id = machineSlot.machine.id
credit.hours_used--
machineSlot.machine.is_reduced_amount = false
index = $scope.eventsReserved.indexOf(machineSlot)
$scope.eventsReserved.splice(index, 1)
if $scope.eventsReserved.length == 0
if $scope.plansAreShown
$scope.removeMachineSlot = (machineSlot, index)->
$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.plansAreShown = false
updateCartPrice()
$scope.onOutdated() if typeof $scope.onOutdated == 'function'
$scope.onSlotRemovedFromCart() if typeof $scope.onSlotRemovedFromCart == 'function'
@ -102,7 +98,7 @@ Application.Directives.directive 'cart', [ '$rootScope', '$uibModal', 'dialogs',
##
$scope.machineSlotsValid = ->
isValid = true
angular.forEach $scope.eventsReserved, (m)->
angular.forEach $scope.events.reserved, (m)->
isValid = false if !m.isValid
isValid
@ -120,7 +116,7 @@ Application.Directives.directive 'cart', [ '$rootScope', '$uibModal', 'dialogs',
$scope.payMachine = ->
# first, we check that a user was selected
if Object.keys($scope.user).length > 0
reservation = mkReservation($scope.user, $scope.eventsReserved, $scope.selectedPlan)
reservation = mkReservation($scope.user, $scope.events.reserved, $scope.selectedPlan)
Wallet.getWalletByUser {user_id: $scope.user.id}, (wallet) ->
amountToPay = helpers.getAmountToPay($scope.amountTotal, wallet.amount)
@ -134,6 +130,56 @@ Application.Directives.directive 'cart', [ '$rootScope', '$uibModal', 'dialogs',
growl.error(_t('please_select_a_member_first'))
##
# When modifying an already booked reservation, confirm the modification.
##
$scope.modifyMachineSlot = ->
Slot.update {id: $scope.events.modifiable.id},
slot:
start_at: $scope.events.placable.start
end_at: $scope.events.placable.end
availability_id: $scope.events.placable.availability_id
, -> # success
$scope.onSlotModifySuccess() if typeof $scope.onSlotModifySuccess == 'function'
, (err) -> # failure
growl.error(_t('unable_to_change_the_reservation'))
console.error(err)
##
# Cancel the current booking modification, reseting the whole process
##
$scope.cancelModifyMachineSlot = ->
$scope.onSlotModifyCancel() if typeof $scope.onSlotModifyCancel == 'function'
$scope.events.placable = null
$scope.events.modifiable = null
##
# When modifying an already booked reservation, cancel the choice of the new slot
# @param e {Object} see https://docs.angularjs.org/guide/expression#-event-
##
$scope.removeSlotToPlace = (e)->
e.preventDefault()
$scope.onSlotModifyUnselect() if typeof $scope.onSlotModifyUnselect == 'function'
$scope.events.placable = null
##
# Cancel the current booking modification, removing the previously booked slot from the selection
# @param e {Object} see https://docs.angularjs.org/guide/expression#-event-
##
$scope.removeSlotToModify = (e) ->
e.preventDefault()
if $scope.events.placable
$scope.events.placable.backgroundColor = 'white'
$scope.events.placable.title = ''
$scope.events.placable = null
$scope.events.modifiable.title = if $scope.currentUser.role isnt 'admin' then _t('i_ve_reserved') else _t('not_available')
$scope.events.modifiable.backgroundColor = 'white'
$scope.events.modifiable = null
uiCalendarConfig.calendars.calendar.fullCalendar 'rerenderEvents'
### PRIVATE SCOPE ###
@ -162,66 +208,61 @@ Application.Directives.directive 'cart', [ '$rootScope', '$uibModal', 'dialogs',
# Callback triggered when the selected slot changed
##
slotSelectionChanged = ->
if !$scope.slot.is_reserved && !$scope.slotToModify
index = $scope.eventsReserved.indexOf($scope.slot)
if index == -1
$scope.slot.backgroundColor = FREE_SLOT_BORDER_COLOR
$scope.slot.title = _t('i_reserve')
$scope.eventsReserved.push $scope.slot
else
$scope.removeMachineSlot($scope.slot)
$scope.paidMachineSlots = null
$scope.selectedPlan = null
$scope.modifiedSlots = null
else if !$scope.slot.is_reserved && $scope.slotToModify
if $scope.slotToPlace
$scope.slotToPlace.backgroundColor = 'white'
$scope.slotToPlace.title = ''
$scope.slotToPlace = $scope.slot
$scope.slot.backgroundColor = '#bbb'
$scope.slot.title = _t('i_shift')
else if $scope.slot.is_reserved and (slotCanBeModified($scope.slot) or slotCanBeCanceled($scope.slot)) and !$scope.slotToModify and $scope.eventsReserved.length == 0
$scope.slot.movable = slotCanBeModified($scope.slot)
$scope.slot.cancelable = slotCanBeCanceled($scope.slot)
dialogs.confirm
templateUrl: '<%= asset_path "shared/confirm_modify_slot_modal.html" %>'
resolve:
object: -> $scope.slot
, (type) ->
if type == 'move'
$scope.modifiedSlots = null
$scope.slotToModify = $scope.slot
$scope.slot.backgroundColor = '#eee'
$scope.slot.title = _t('i_change')
$scope.onUpdate() if typeof $scope.onUpdate == 'function'
else if type == 'cancel'
dialogs.confirm
resolve:
object: ->
title: _t('confirmation_required')
msg: _t('do_you_really_want_to_cancel_this_reservation')
, -> # cancel confirmed
Slot.cancel {id: $scope.slot.id}, -> # successfully canceled
growl.success _t('reservation_was_cancelled_successfully')
$scope.canceledSlot = $scope.slot
$scope.canceledSlot.backgroundColor = 'white'
$scope.canceledSlot.title = ''
$scope.canceledSlot.borderColor = FREE_SLOT_BORDER_COLOR
$scope.canceledSlot.id = null
$scope.canceledSlot.is_reserved = false
$scope.canceledSlot.can_modify = false
$scope.canceledSlot = null
$scope.onUpdate() if typeof $scope.onUpdate == 'function'
, -> # error while canceling
growl.error _t('cancellation_failed')
, ->
$scope.paidMachineSlots = null
$scope.selectedPlan = null
$scope.modifiedSlots = null
$scope.onUpdate() if typeof $scope.onUpdate == 'function'
updateCartPrice()
if $scope.slot
if !$scope.slot.is_reserved && !$scope.events.modifiable
# slot is not reserved and we are not currently modifying a slot
# -> can be added to cart or removed if already present
index = $scope.events.reserved.indexOf($scope.slot)
if index == -1
# slot is not in the cart, so we add it
$scope.events.reserved.push $scope.slot
$scope.onSlotAddedToCart() if typeof $scope.onSlotAddedToCart == 'function'
else
# slot is in the cart, remove it
$scope.removeMachineSlot($scope.slot, index)
# finally, we update the prices
updateCartPrice()
else if !$scope.slot.is_reserved && $scope.events.modifiable
# slot is not reserved but we are currently modifying a slot
# -> we request the calender to change the rendering
$scope.onSlotModifyUnselect() if typeof $scope.onSlotModifyUnselect == 'function'
# -> then, we re-affect the destination slot
if !$scope.events.placable or $scope.events.placable._id != $scope.slot._id
$scope.events.placable = $scope.slot
else
$scope.events.placable = null
else if $scope.slot.is_reserved and $scope.events.modifiable and $scope.slot.is_reserved._id == $scope.events.modifiable._id
# slot is reserved and currently modified
# -> we cancel the modification
$scope.cancelModifyMachineSlot()
else if $scope.slot.is_reserved and (slotCanBeModified($scope.slot) or slotCanBeCanceled($scope.slot)) and !$scope.events.modifiable and $scope.events.reserved.length == 0
# slot is reserved and is ok to be modified or cancelled
# but we are not currently running a modification or having any slots in the cart
# -> first the affect the modification/cancellation rights attributes to the current slot
$scope.slot.movable = slotCanBeModified($scope.slot)
$scope.slot.cancelable = slotCanBeCanceled($scope.slot)
# -> then, we open a dialog to ask to the user to choose an action
dialogs.confirm
templateUrl: '<%= asset_path "shared/confirm_modify_slot_modal.html" %>'
resolve:
object: -> $scope.slot
, (type) ->
# the user has choosen an action, so we proceed
if type == 'move'
$scope.onSlotStartToModify() if typeof $scope.onSlotStartToModify == 'function'
$scope.events.modifiable = $scope.slot
else if type == 'cancel'
dialogs.confirm
resolve:
object: ->
title: _t('confirmation_required')
msg: _t('do_you_really_want_to_cancel_this_reservation')
, -> # cancel confirmed
Slot.cancel {id: $scope.slot.id}, -> # successfully canceled
growl.success _t('reservation_was_cancelled_successfully')
$scope.onSlotCancelSuccess() if typeof $scope.onSlotCancelSuccess == 'function'
, -> # error while canceling
growl.error _t('cancellation_failed')
@ -233,14 +274,29 @@ Application.Directives.directive 'cart', [ '$rootScope', '$uibModal', 'dialogs',
return true if $rootScope.currentUser.role is 'admin'
slotStart = moment(slot.start)
now = moment()
if slot.can_modify and $scope.enableBookingMove and slotStart.diff(now, "hours") >= $scope.moveBookingDelay #FIXME
if slot.can_modify and $scope.enableBookingMove and slotStart.diff(now, "hours") >= $scope.moveBookingDelay
return true
else
return false
##
##
# Determines if the provided booked slot is able to be canceled by the user.
# @param slot {Object} fullCalendar event object
##
slotCanBeCanceled = (slot) ->
return true if $rootScope.currentUser.role is 'admin'
slotStart = moment(slot.start)
now = moment()
if slot.can_modify and $scope.enableBookingCancel and slotStart.diff(now, "hours") >= $scope.cancelBookingDelay
return true
else
return false
##
# Callback triggered when the selected slot changed
##
planSelectionChanged = ->
@ -261,7 +317,7 @@ Application.Directives.directive 'cart', [ '$rootScope', '$uibModal', 'dialogs',
##
updateCartPrice = ->
if Object.keys($scope.user).length > 0
r = mkReservation($scope.user, $scope.eventsReserved, $scope.selectedPlan)
r = mkReservation($scope.user, $scope.events.reserved, $scope.selectedPlan)
Price.compute mkRequestParams(r, $scope.coupon.applied), (res) ->
$scope.amountTotal = res.price
$scope.totalNoCoupon = res.price_without_coupon
@ -273,7 +329,7 @@ Application.Directives.directive 'cart', [ '$rootScope', '$uibModal', 'dialogs',
setSlotsDetails = (details) ->
angular.forEach $scope.eventsReserved, (slot) ->
angular.forEach $scope.events.reserved, (slot) ->
angular.forEach details.slots, (s) ->
if moment(s.start_at).isSame(slot.start)
slot.promo = s.promo

View File

@ -29,7 +29,7 @@
<select-member></select-member>
</div>
<div class="widget panel b-a m m-t-lg" ng-show="!ctrl.member && currentUser.role == 'admin' && eventsReserved.length == 0 && (!paidMachineSlots || paidMachineSlots.length == 0) && !slotToModify && !modifiedSlots">
<div class="widget panel b-a m m-t-lg" ng-show="!ctrl.member && currentUser.role == 'admin' && eventsReserved.length == 0 && (!paidMachineSlots || paidMachineSlots.length == 0) && !events.modifiable && !modifiedSlots">
<div class="panel-heading b-b small">
<h3 translate>{{ 'summary' }}</h3>
</div>
@ -42,14 +42,20 @@
<cart slot="selectedEvent"
slot-selection-time="selectionTime"
events-reserved="eventsReserved"
on-update="updateCalendar"
on-outdated="refetchCalendar"
events="events"
on-slot-added-to-cart="markSlotAsAdded"
on-slot-removed-from-cart="markSlotAsRemoved"
on-slot-start-to-modify="markSlotAsModifying"
on-slot-modify-success="modifyMachineSlot"
on-slot-modify-cancel="cancelModifyMachineSlot"
on-slot-modify-unselect="changeModifyMachineSlot"
on-slot-cancel-success="markSlotAsRemoved"
user="ctrl.member"
mode-plans="plansAreShown"
plan="selectedPlan"
plan-selection-time="planSelectionTime"
after-payment="afterPayment"></cart>
after-payment="afterPayment"
settings="settings"></cart>
<uib-alert type="warning m">
<p class="text-sm">

View File

@ -1,18 +1,18 @@
<div class="widget panel b-a m m-t-lg" ng-if="user && !slotToModify && !modifiedSlots">
<div class="widget panel b-a m m-t-lg" ng-if="user && !events.modifiable && !modifiedSlots">
<div class="panel-heading b-b small">
<h3 translate>{{ 'summary' }}</h3>
</div>
<div class="widget-content no-bg auto wrapper" ng-show="eventsReserved.length == 0 && (!paidMachineSlots || paidMachineSlots.length == 0)">
<div class="widget-content no-bg auto wrapper" ng-show="events.reserved.length == 0 && (!paidMachineSlots || paidMachineSlots.length == 0)">
<p class="font-felt fleche-left text-lg"><%= image_tag("fleche-left.png", class: 'fleche-left visible-lg') %>
{{ 'select_one_or_more_slots_in_the_calendar' | translate }}</p>
</div>
<div class="widget-content no-bg auto wrapper" ng-if="eventsReserved.length > 0">
<div class="widget-content no-bg auto wrapper" ng-if="events.reserved.length > 0">
<div class="font-sbold m-b-sm " translate>{{ 'you_ve_just_selected_the_slot' }}</div>
<div class="panel panel-default bg-light" ng-repeat="machineSlot in eventsReserved">
<div class="panel panel-default bg-light" ng-repeat="machineSlot in events.reserved">
<div class="panel-body">
<div class="font-sbold text-u-c">{{ 'datetime_to_time' | translate:{START_DATETIME:(machineSlot.start | amDateFormat:'LLLL'), END_TIME:(machineSlot.end | amDateFormat:'LT') } }}</div>
<div class="text-base">{{ 'cost_of_a_machine_hour' | translate }} <span ng-class="{'text-blue': !machineSlot.promo, 'red': machineSlot.promo}">{{machineSlot.price | currency}}</span></div>
@ -58,7 +58,7 @@
</div>
<div class="panel-footer no-padder" ng-if="eventsReserved.length > 0">
<div class="panel-footer no-padder" ng-if="events.reserved.length > 0">
<button class="btn btn-valid btn-info btn-block p-l btn-lg text-u-c r-b text-base" ng-click="payMachine()" ng-if="machineSlotsValid() && (!modePlans || selectedPlan)">{{ 'confirm_and_pay' | translate }} {{amountTotal | currency}}</button>
</div>
@ -88,18 +88,18 @@
</div>
<div class="widget panel b-a m m-t-lg" ng-if="slotToModify || modifiedSlots">
<div class="widget panel b-a m m-t-lg" ng-if="events.modifiable || modifiedSlots">
<div class="panel-heading b-b small">
<h3 translate>{{ 'summary' }}</h3>
</div>
<div class="widget-content no-bg auto wrapper" ng-if="slotToModify">
<div class="widget-content no-bg auto wrapper" ng-if="events.modifiable">
<div class="font-sbold m-b-sm " translate>{{ 'i_want_to_change_the_following_reservation' }}</div>
<div class="panel panel-warning bg-yellow">
<div class="panel-body">
<div class="font-sbold text-u-c">{{ 'datetime_to_time' | translate:{START_DATETIME:(slotToModify.start | amDateFormat:'LLLL'), END_TIME:(slotToModify.end | amDateFormat:'LT') } }}</div>
<div class="font-sbold text-u-c">{{ 'datetime_to_time' | translate:{START_DATETIME:(events.modifiable.start | amDateFormat:'LLLL'), END_TIME:(events.modifiable.end | amDateFormat:'LT') } }}</div>
</div>
<div class="clear"><a class="pull-right m-b-sm text-u-l ng-scope m-r-sm" href="#" ng-click="removeSlotToModify($event)" translate>{{ 'cancel_my_modification' }}</a></div>
<div class="clear"><a class="pull-right m-b-sm text-u-l ng-scope m-r-sm" href="#" ng-click="cancelModifyMachineSlot($event)" translate>{{ 'cancel_my_modification' }}</a></div>
</div>
<div class="widget-content no-bg">
@ -107,24 +107,24 @@
{{ 'select_a_new_slot_in_the_calendar' | translate }}</p>
</div>
<div class="panel panel-info bg-info text-white" ng-if="slotToPlace">
<div class="panel panel-info bg-info text-white" ng-if="events.placable">
<div class="panel-body">
<div class="font-sbold text-u-c">{{ 'datetime_to_time' | translate:{START_DATETIME:(slotToPlace.start | amDateFormat:'LLLL'), END_TIME:(slotToPlace.end | amDateFormat:'LT') } }}</div>
<div class="font-sbold text-u-c">{{ 'datetime_to_time' | translate:{START_DATETIME:(events.placable.start | amDateFormat:'LLLL'), END_TIME:(events.placable.end | amDateFormat:'LT') } }}</div>
</div>
<div class="clear"><a class="pull-right m-b-sm text-u-l ng-scope m-r-sm" href="#" ng-click="removeSlotToPlace($event)" translate>{{ 'cancel_my_selection' }}</a></div>
</div>
<div ng-if="slotToPlace && slotToModify.tags.length > 0 && slotToPlace.tags.length > 0" ng-class="{'panel panel-danger bg-red': tagMissmatch()}">
<div ng-if="events.placable && events.modifiable.tags.length > 0 && events.placable.tags.length > 0" ng-class="{'panel panel-danger bg-red': tagMissmatch()}">
<div class="panel-body">
<div id="fromTags">
{{ 'tags_of_the_original_slot' | translate }}<br/>
<span ng-repeat="tag in slotToModify.tags">
<span ng-repeat="tag in events.modifiable.tags">
<span class='label label-success text-white' title="{{tag.name}}">{{tag.name}}</span>
</span>
</div><br/>
<div id="toTags">
{{ 'tags_of_the_destination_slot' | translate }}<br/>
<span ng-repeat="tag in slotToPlace.tags">
<span ng-repeat="tag in events.placable.tags">
<span class='label label-success text-white' title="{{tag.name}}">{{tag.name}}</span>
</span>
</div>
@ -133,7 +133,7 @@
</div>
<div class="panel-footer no-padder" ng-if="slotToModify && slotToPlace">
<div class="panel-footer no-padder" ng-if="events.modifiable && events.placable">
<button class="btn btn-invalid btn-default btn-block p-l btn-lg text-u-c r-n text-base" ng-click="cancelModifyMachineSlot()" translate>{{ 'cancel' }}</button>
<div>
<button class="btn btn-valid btn-info btn-block p-l btn-lg text-u-c r-b text-base" ng-click="modifyMachineSlot()" translate>{{ 'confirm_my_modification' }}</button>