1
0
mirror of https://github.com/LaCasemate/fab-manager.git synced 2025-03-21 12:29:03 +01:00

fix summary after event moved

This commit is contained in:
Sylvain 2017-02-22 10:28:14 +01:00
parent 7a21a907a8
commit c4824f99ba
4 changed files with 29 additions and 27 deletions

View File

@ -311,6 +311,7 @@ Application.Controllers.controller "ReserveMachineController", ["$scope", "$stat
modifiable: null
placable: null
paid: []
moved: null
## total amount of the bill to pay
$scope.amountTotal = 0
@ -427,16 +428,12 @@ Application.Controllers.controller "ReserveMachineController", ["$scope", "$stat
# When modifying an already booked reservation, callback when the modification was successfully done.
##
$scope.modifyMachineSlot = ->
$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.events.modifiable.backgroundColor = 'white'
$scope.events.modifiable.title = ''
@ -444,7 +441,6 @@ Application.Controllers.controller "ReserveMachineController", ["$scope", "$stat
$scope.events.modifiable.id = null
$scope.events.modifiable.is_reserved = false
$scope.events.modifiable.can_modify = false
$scope.events.modifiable = null
updateCalendar()

View File

@ -99,7 +99,13 @@ Application.Directives.directive 'cart', [ '$rootScope', '$uibModal', 'dialogs',
# Switch the user's view from the reservation agenda to the plan subscription
##
$scope.showPlans = ->
$scope.modePlans = true
# first, we ensure that a user was selected (admin) or logged (member)
if Object.keys($scope.user).length > 0
$scope.modePlans = true
else
# otherwise we alert, this error musn't occur when the current user hasn't the admin role
growl.error(_t('cart.please_select_a_member_first'))
##
# Validates the shopping chart and redirect the user to the payment step
@ -131,7 +137,15 @@ Application.Directives.directive 'cart', [ '$rootScope', '$uibModal', 'dialogs',
end_at: $scope.events.placable.end
availability_id: $scope.events.placable.availability_id
, -> # success
# -> run the callback
$scope.onSlotModifySuccess() if typeof $scope.onSlotModifySuccess == 'function'
# -> set the events as successfully moved (to display a summary)
$scope.events.moved =
newSlot: $scope.events.placable
oldSlot: $scope.events.modifiable
# -> reset the 'moving' status
$scope.events.placable = null
$scope.events.modifiable = null
, (err) -> # failure
growl.error(_t('cart.unable_to_change_the_reservation'))
console.error(err)
@ -140,8 +154,10 @@ Application.Directives.directive 'cart', [ '$rootScope', '$uibModal', 'dialogs',
##
# Cancel the current booking modification, reseting the whole process
# @param event {Object} see https://docs.angularjs.org/guide/expression#-event-
##
$scope.cancelModifySlot = ->
$scope.cancelModifySlot = (event) ->
event.preventDefault() if event
$scope.onSlotModifyCancel() if typeof $scope.onSlotModifyCancel == 'function'
$scope.events.placable = null
$scope.events.modifiable = null
@ -222,6 +238,7 @@ Application.Directives.directive 'cart', [ '$rootScope', '$uibModal', 'dialogs',
# in every cases, because a new reservation has started
# we reset the array of settled events, the selected plan and the coupon
$scope.events.paid = []
$scope.events.moved = null
$scope.selectedPlan = null
$scope.coupon.applied = null
# finally, we update the prices

View File

@ -29,17 +29,6 @@
<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) && !events.modifiable && !modifiedSlots">
<div class="panel-heading b-b small">
<h3 translate>{{ 'summary' }}</h3>
</div>
<div class="widget-content no-bg auto wrapper">
<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>
<cart slot="selectedEvent"
slot-selection-time="selectionTime"
events="events"

View File

@ -1,10 +1,10 @@
<div class="widget panel b-a m m-t-lg" ng-if="user && !events.modifiable && !modifiedSlots">
<div class="widget panel b-a m m-t-lg" ng-if="user && !events.modifiable && !events.moved">
<div class="panel-heading b-b small">
<h3 translate>{{ 'cart.summary' }}</h3>
</div>
<div class="widget-content no-bg auto wrapper" ng-show="events.reserved.length == 0 && (!events.paid || events.paid.length == 0)">
<p class="font-felt fleche-left text-lg"><%= image_tag("fleche-left.png", class: 'fleche-left visible-lg') %>
<p class="font-felt fleche-left text-lg"><%= image_tag('fleche-left.png', class: 'fleche-left visible-lg') %>
{{ 'cart.select_one_or_more_slots_in_the_calendar' | translate }}</p>
</div>
@ -38,7 +38,7 @@
<coupon show="isSlotsValid() && (!modePlans || selectedPlan)" coupon="coupon.applied" total="totalNoCoupon" user-id="{{user.id}}"></coupon>
<span ng-hide="fablabWithoutPlans">
<div ng-hide="fablabWithoutPlans">
<div ng-if="isSlotsValid() && !user.subscribed_plan" ng-show="!modePlans">
<p class="font-sbold text-base l-h-2x" translate>{{ 'cart.to_benefit_from_attractive_prices' }}</p>
<div><button class="btn btn-warning-full rounded btn-block text-xs" ng-click="showPlans()" translate>{{ 'cart.view_our_subscriptions' }}</button></div>
@ -54,7 +54,7 @@
</div>
</div>
</div>
</span>
</div>
</div>
@ -88,7 +88,7 @@
</div>
<div class="widget panel b-a m m-t-lg" ng-if="events.modifiable || modifiedSlots">
<div class="widget panel b-a m m-t-lg" ng-if="events.modifiable || events.moved">
<div class="panel-heading b-b small">
<h3 translate>{{ 'cart.summary' }}</h3>
</div>
@ -103,7 +103,7 @@
</div>
<div class="widget-content no-bg">
<p class="font-felt fleche-left text-lg"><%= image_tag("fleche-left.png", class: 'fleche-left visible-lg') %>
<p class="font-felt fleche-left text-lg"><%= image_tag('fleche-left.png', class: 'fleche-left visible-lg') %>
{{ 'cart.select_a_new_slot_in_the_calendar' | translate }}</p>
</div>
@ -140,12 +140,12 @@
</div>
</div>
<div class="widget-content no-bg auto wrapper" ng-if="modifiedSlots">
<div class="widget-content no-bg auto wrapper" ng-show="events.moved">
<div class="font-sbold m-b-sm " translate>{{ 'cart.your_booking_slot_was_successfully_moved_from_' }}</div>
<div class="panel panel-default bg-light">
<div class="panel-body">
<div class="font-sbold text-u-c">{{ 'cart.datetime_to_time' | translate:{START_DATETIME:(modifiedSlots.oldReservedSlot.start | amDateFormat:'LLLL'), END_TIME:(modifiedSlots.oldReservedSlot.end | amDateFormat:'LT') } }}</div>
<div class="font-sbold text-u-c">{{ 'cart.datetime_to_time' | translate:{START_DATETIME:(events.moved.oldSlot.start | amDateFormat:'LLLL'), END_TIME:(events.moved.oldSlot.end | amDateFormat:'LT') } }}</div>
</div>
</div>
@ -153,7 +153,7 @@
<div class="panel panel-success bg-success bg-light">
<div class="panel-body">
<div class="font-sbold text-u-c">{{ 'cart.datetime_to_time' | translate:{START_DATETIME:(modifiedSlots.newReservedSlot.start | amDateFormat:'LLLL'), END_TIME:(modifiedSlots.newReservedSlot.end | amDateFormat:'LT') } }}</div>
<div class="font-sbold text-u-c">{{ 'cart.datetime_to_time' | translate:{START_DATETIME:(events.moved.newSlot.start | amDateFormat:'LLLL'), END_TIME:(events.moved.newSlot.end | amDateFormat:'LT') } }}</div>
</div>
</div>
</div>