diff --git a/app/assets/javascripts/directives/cart.coffee.erb b/app/assets/javascripts/directives/cart.coffee.erb index b49b6c45c..b58958658 100644 --- a/app/assets/javascripts/directives/cart.coffee.erb +++ b/app/assets/javascripts/directives/cart.coffee.erb @@ -111,14 +111,14 @@ Application.Directives.directive 'cart', [ '$rootScope', '$uibModal', 'dialogs', Wallet.getWalletByUser {user_id: $scope.user.id}, (wallet) -> amountToPay = helpers.getAmountToPay($scope.amountTotal, wallet.amount) - if $rootScope.currentUser.role isnt 'admin' and amountToPay > 0 + if not $scope.isAdmin() and amountToPay > 0 payByStripe(reservation) else - if $rootScope.currentUser.role is 'admin' or amountToPay is 0 + if $scope.isAdmin() or amountToPay is 0 payOnSite(reservation) else # otherwise we alert, this error musn't occur when the current user is not admin - growl.error(_t('please_select_a_member_first')) + growl.error(_t('cart.please_select_a_member_first')) ## @@ -133,7 +133,7 @@ Application.Directives.directive 'cart', [ '$rootScope', '$uibModal', 'dialogs', , -> # success $scope.onSlotModifySuccess() if typeof $scope.onSlotModifySuccess == 'function' , (err) -> # failure - growl.error(_t('unable_to_change_the_reservation')) + growl.error(_t('cart.unable_to_change_the_reservation')) console.error(err) @@ -157,21 +157,6 @@ Application.Directives.directive 'cart', [ '$rootScope', '$uibModal', 'dialogs', $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' - ## @@ -186,6 +171,15 @@ Application.Directives.directive 'cart', [ '$rootScope', '$uibModal', 'dialogs', + ## + # Check if the currently logged user has teh 'admin' role? + # @returns {boolean} + ## + $scope.isAdmin = -> + $rootScope.currentUser and $rootScope.currentUser.role is 'admin' + + + ### PRIVATE SCOPE ### ## @@ -265,14 +259,14 @@ Application.Directives.directive 'cart', [ '$rootScope', '$uibModal', 'dialogs', dialogs.confirm resolve: object: -> - title: _t('confirmation_required') - msg: _t('do_you_really_want_to_cancel_this_reservation') + title: _t('cart.confirmation_required') + msg: _t('cart.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') + growl.success _t('cart.reservation_was_cancelled_successfully') $scope.onSlotCancelSuccess() if typeof $scope.onSlotCancelSuccess == 'function' , -> # error while canceling - growl.error _t('cancellation_failed') + growl.error _t('cart.cancellation_failed') @@ -281,7 +275,7 @@ Application.Directives.directive 'cart', [ '$rootScope', '$uibModal', 'dialogs', # @param slot {Object} fullCalendar event object ## slotCanBeModified = (slot)-> - return true if $rootScope.currentUser.role is 'admin' + return true if $scope.isAdmin() slotStart = moment(slot.start) now = moment() if slot.can_modify and $scope.enableBookingMove and slotStart.diff(now, "hours") >= $scope.moveBookingDelay @@ -296,7 +290,7 @@ Application.Directives.directive 'cart', [ '$rootScope', '$uibModal', 'dialogs', # @param slot {Object} fullCalendar event object ## slotCanBeCanceled = (slot) -> - return true if $rootScope.currentUser.role is 'admin' + return true if $scope.isAdmin() slotStart = moment(slot.start) now = moment() if slot.can_modify and $scope.enableBookingCancel and slotStart.diff(now, "hours") >= $scope.cancelBookingDelay @@ -334,7 +328,7 @@ Application.Directives.directive 'cart', [ '$rootScope', '$uibModal', 'dialogs', setSlotsDetails(res.details) else # otherwise we alert, this error musn't occur when the current user is not admin - growl.warning(_t('please_select_a_member_first')) + growl.warning(_t('cart.please_select_a_member_first')) $scope.amountTotal = null @@ -491,10 +485,10 @@ Application.Directives.directive 'cart', [ '$rootScope', '$uibModal', 'dialogs', # Button label if $scope.amount > 0 - $scope.validButtonName = _t('confirm_payment_of_html', {ROLE:$rootScope.currentUser.role, AMOUNT:$filter('currency')($scope.amount)}, "messageformat") + $scope.validButtonName = _t('cart.confirm_payment_of_html', {ROLE:$rootScope.currentUser.role, AMOUNT:$filter('currency')($scope.amount)}, "messageformat") else if price.price > 0 and $scope.walletAmount == 0 - $scope.validButtonName = _t('confirm_payment_of_html', {ROLE:$rootScope.currentUser.role, AMOUNT:$filter('currency')(price.price)}, "messageformat") + $scope.validButtonName = _t('cart.confirm_payment_of_html', {ROLE:$rootScope.currentUser.role, AMOUNT:$filter('currency')(price.price)}, "messageformat") else $scope.validButtonName = _t('confirm') @@ -508,7 +502,7 @@ Application.Directives.directive 'cart', [ '$rootScope', '$uibModal', 'dialogs', $scope.attempting = true , (response)-> $scope.alerts = [] - $scope.alerts.push({msg: _t('a_problem_occured_during_the_payment_process_please_try_again_later'), type: 'danger' }) + $scope.alerts.push({msg: _t('cart.a_problem_occured_during_the_payment_process_please_try_again_later'), type: 'danger' }) $scope.attempting = false $scope.cancel = -> $uibModalInstance.dismiss('cancel') diff --git a/app/assets/javascripts/router.coffee.erb b/app/assets/javascripts/router.coffee.erb index 7179a1da2..4301613db 100644 --- a/app/assets/javascripts/router.coffee.erb +++ b/app/assets/javascripts/router.coffee.erb @@ -373,7 +373,7 @@ angular.module('application.router', ['ui.router']). translations: [ 'Translations', (Translations) -> Translations.query(['app.logged.machines_reserve', 'app.shared.plan_subscribe', 'app.shared.member_select', 'app.shared.stripe', 'app.shared.valid_reservation_modal', 'app.shared.confirm_modify_slot_modal', - 'app.shared.wallet', 'app.shared.coupon_input']).$promise + 'app.shared.wallet', 'app.shared.coupon_input', 'app.shared.cart']).$promise ] .state 'app.admin.machines_edit', url: '/machines/:id/edit' diff --git a/app/assets/templates/shared/_cart.html.erb b/app/assets/templates/shared/_cart.html.erb index a3edf91b6..c25dcb288 100644 --- a/app/assets/templates/shared/_cart.html.erb +++ b/app/assets/templates/shared/_cart.html.erb @@ -1,23 +1,23 @@
-

{{ 'summary' }}

+

{{ 'cart.summary' }}

<%= image_tag("fleche-left.png", class: 'fleche-left visible-lg') %> - {{ 'select_one_or_more_slots_in_the_calendar' | translate }}

+ {{ 'cart.select_one_or_more_slots_in_the_calendar' | translate }}

-
{{ 'you_ve_just_selected_the_slot' }}
+
{{ 'cart.you_ve_just_selected_the_slot' }}
-
{{ 'datetime_to_time' | translate:{START_DATETIME:(slot.start | amDateFormat:'LLLL'), END_TIME:(slot.end | amDateFormat:'LT') } }}
-
{{ 'cost_of_a_machine_hour' | translate }} {{slot.price | currency}}
-
- +
{{ 'cart.datetime_to_time' | translate:{START_DATETIME:(slot.start | amDateFormat:'LLLL'), END_TIME:(slot.end | amDateFormat:'LT') } }}
+
{{ 'cart.cost_of_a_machine_hour' | translate }} {{slot.price | currency}}
+
+
- +
- +
-

{{ 'to_benefit_from_attractive_prices' }}

-
-

{{ 'or' }}

+

{{ 'cart.to_benefit_from_attractive_prices' }}

+
+

{{ 'cart.or' }}

-
{{ 'you_ve_just_selected_a_' | translate }}
{{ '_subscription' }} :
+
{{ 'cart.you_ve_just_selected_a_' | translate }}
{{ 'cart._subscription' }} :
{{selectedPlan | humanReadablePlanName }}
-
{{ 'cost_of_the_subscription' | translate }} {{selectedPlan.amount | currency}}
+
{{ 'cart.cost_of_the_subscription' | translate }} {{selectedPlan.amount | currency}}
@@ -59,29 +59,29 @@
- {{ 'you_have_settled_the_following_machine_hours' | translate }} {{reservableName}}: + {{ 'cart.you_have_settled_the_following_machine_hours' | translate }} {{reservableName}}:
- {{ 'datetime_to_time' | translate:{START_DATETIME:(paidSlot.start | amDateFormat:'LLLL'), END_TIME:(paidSlot.end | amDateFormat:'LT') } }} -
{{ 'cost_of_a_machine_hour' | translate }} {{paidSlot.price | currency}}
+ {{ 'cart.datetime_to_time' | translate:{START_DATETIME:(paidSlot.start | amDateFormat:'LLLL'), END_TIME:(paidSlot.end | amDateFormat:'LT') } }} +
{{ 'cart.cost_of_a_machine_hour' | translate }} {{paidSlot.price | currency}}
-
{{ 'you_have_settled_a_' | translate }}
{{ '_subscription' }} :
+
{{ 'cart.you_have_settled_a_' | translate }}
{{ 'cart._subscription' }} :
{{selectedPlan | humanReadablePlanName }} -
{{ 'cost_of_the_subscription' | translate }} {{selectedPlan.amount | currency}}
+
{{ 'cart.cost_of_the_subscription' | translate }} {{selectedPlan.amount | currency}}
-
{{ 'total_' | translate }} {{amountTotal | currency}}
+
{{ 'cart.total_' | translate }} {{amountTotal | currency}}
-
{{ 'thank_you_your_payment_has_been_successfully_registered' | translate }}
- {{ 'your_invoice_will_be_available_soon_from_your_' | translate }} {{ 'dashboard' }} +
{{ 'cart.thank_you_your_payment_has_been_successfully_registered' | translate }}
+ {{ 'cart.your_invoice_will_be_available_soon_from_your_' | translate }} {{ 'cart.dashboard' }}
@@ -90,40 +90,40 @@
-

{{ 'summary' }}

+

{{ 'cart.summary' }}

-
{{ 'i_want_to_change_the_following_reservation' }}
+
{{ 'cart.i_want_to_change_the_following_reservation' }}
-
{{ 'datetime_to_time' | translate:{START_DATETIME:(events.modifiable.start | amDateFormat:'LLLL'), END_TIME:(events.modifiable.end | amDateFormat:'LT') } }}
+
{{ 'cart.datetime_to_time' | translate:{START_DATETIME:(events.modifiable.start | amDateFormat:'LLLL'), END_TIME:(events.modifiable.end | amDateFormat:'LT') } }}
- +

<%= image_tag("fleche-left.png", class: 'fleche-left visible-lg') %> - {{ 'select_a_new_slot_in_the_calendar' | translate }}

+ {{ 'cart.select_a_new_slot_in_the_calendar' | translate }}

-
{{ 'datetime_to_time' | translate:{START_DATETIME:(events.placable.start | amDateFormat:'LLLL'), END_TIME:(events.placable.end | amDateFormat:'LT') } }}
+
{{ 'cart.datetime_to_time' | translate:{START_DATETIME:(events.placable.start | amDateFormat:'LLLL'), END_TIME:(events.placable.end | amDateFormat:'LT') } }}
- +
- {{ 'tags_of_the_original_slot' | translate }}
+ {{ 'cart.tags_of_the_original_slot' | translate }}
{{tag.name}}

- {{ 'tags_of_the_destination_slot' | translate }}
+ {{ 'cart.tags_of_the_destination_slot' | translate }}
{{tag.name}} @@ -136,24 +136,24 @@
-
{{ 'your_booking_slot_was_successfully_moved_from_' }}
+
{{ 'cart.your_booking_slot_was_successfully_moved_from_' }}
-
{{ 'datetime_to_time' | translate:{START_DATETIME:(modifiedSlots.oldReservedSlot.start | amDateFormat:'LLLL'), END_TIME:(modifiedSlots.oldReservedSlot.end | amDateFormat:'LT') } }}
+
{{ 'cart.datetime_to_time' | translate:{START_DATETIME:(modifiedSlots.oldReservedSlot.start | amDateFormat:'LLLL'), END_TIME:(modifiedSlots.oldReservedSlot.end | amDateFormat:'LT') } }}
-

{{ 'to_date' }}

+

{{ 'cart.to_date' }}

-
{{ 'datetime_to_time' | translate:{START_DATETIME:(modifiedSlots.newReservedSlot.start | amDateFormat:'LLLL'), END_TIME:(modifiedSlots.newReservedSlot.end | amDateFormat:'LT') } }}
+
{{ 'cart.datetime_to_time' | translate:{START_DATETIME:(modifiedSlots.newReservedSlot.start | amDateFormat:'LLLL'), END_TIME:(modifiedSlots.newReservedSlot.end | amDateFormat:'LT') } }}
diff --git a/config/locales/app.logged.en.yml b/config/locales/app.logged.en.yml index 672977d28..ce7947694 100644 --- a/config/locales/app.logged.en.yml +++ b/config/locales/app.logged.en.yml @@ -98,32 +98,11 @@ en: machines_reserve: # book a machine machine_planning: "Machine planning" - offer_this_slot: "Offer this slot" - confirm_this_slot: "Confirm this slot" - remove_this_slot: "Remove this slot" - to_benefit_from_attractive_prices: "To benefit from attractive prices" - view_our_subscriptions: "View our subscriptions" - cost_of_the_subscription: "Cost of the subscription" - you_have_settled_the_following_machine_hours: "You have settled the following machine hours:" - you_have_settled_a_: "You have settled a" - i_want_to_change_the_following_reservation: "I want to change the following reservation:" - cancel_my_modification: "Cancel my modification" - select_a_new_slot_in_the_calendar: "Select a new slot in the calendar" - cancel_my_selection: "Cancel my selection" - tags_of_the_original_slot: "Tags of the original slot:" - tags_of_the_destination_slot: "Tags of the destination slot:" - confirm_my_modification: "Confirm my modification" - your_booking_slot_was_successfully_moved_from_: "Your booking slot was successfully moved from" - i_ve_reserved: "J'ai réservé" + i_ve_reserved: "I've reserved" not_available: "Not available" - unable_to_change_the_reservation: "Unable to change the reservation" i_reserve: "I reserve" i_shift: "I shift" i_change: "I change" - do_you_really_want_to_cancel_this_reservation: "So you really want to cancel this reservation?" - reservation_was_cancelled_successfully: "Reservation was cancelled successfully." - cancellation_failed: "Cancellation failed." - a_problem_occured_during_the_payment_process_please_try_again_later: "A problem occurred during the payment process. Please try again later." trainings_reserve: # book a training diff --git a/config/locales/app.logged.fr.yml b/config/locales/app.logged.fr.yml index 529175ac6..60e0c7521 100644 --- a/config/locales/app.logged.fr.yml +++ b/config/locales/app.logged.fr.yml @@ -98,32 +98,11 @@ fr: machines_reserve: # réserver une machine machine_planning: "Planning machine" - offer_this_slot: "Offrir ce créneau" - confirm_this_slot: "Valider ce créneau" - remove_this_slot: "Supprimer ce créneau" - to_benefit_from_attractive_prices: "Pour bénéficier de prix avantageux" - view_our_subscriptions: "Consultez nos abonnements" - cost_of_the_subscription: "Coût de l'abonnement" - you_have_settled_the_following_machine_hours: "Vous avez réglé les heures machines suivantes :" - you_have_settled_a_: "Vous avez réglé un" - i_want_to_change_the_following_reservation: "Je souhaite modifier ma réservation suivante :" - cancel_my_modification: "Annuler ma modification" - select_a_new_slot_in_the_calendar: "Sélectionnez un nouveau créneau dans le calendrier" - cancel_my_selection: "Annuler ma sélection" - tags_of_the_original_slot: "Étiquettes du créneau d'origine :" - tags_of_the_destination_slot: "Étiquettes du créneau de destination :" - confirm_my_modification: "Valider ma modification" - your_booking_slot_was_successfully_moved_from_: "Votre créneau de réservation a bien été déplacé du" i_ve_reserved: "J'ai réservé" not_available: "Non disponible" - unable_to_change_the_reservation: "Impossible de modifier la réservation" i_reserve: "Je réserve" i_shift: "Je déplace" i_change: "Je change" - do_you_really_want_to_cancel_this_reservation: "Êtes-vous sur de vouloir annuler cette réservation ?" - reservation_was_cancelled_successfully: "La réservation a bien été annulée." - cancellation_failed: "L'annulation a échoué." - a_problem_occured_during_the_payment_process_please_try_again_later: "Il y a eu un problème lors de la procédure de paiement. Veuillez réessayer plus tard." trainings_reserve: # réserver une formation diff --git a/config/locales/app.shared.en.yml b/config/locales/app.shared.en.yml index 45e54346f..11092abe9 100644 --- a/config/locales/app.shared.en.yml +++ b/config/locales/app.shared.en.yml @@ -412,4 +412,37 @@ en: select_one_or_more_slots_in_the_calendar: "Select one or more slots in the calendar" you_ve_just_selected_the_slot: "You've just selected the slot:" datetime_to_time: "{{START_DATETIME}} to {{END_TIME}}" # angular interpolation, eg: Thursday, September 4 1986 8:30 PM to 10:00 PM - cost_of_a_machine_hour: "Cost of a machine hour" \ No newline at end of file + cost_of_a_machine_hour: "Cost of a machine hour" + offer_this_slot: "Offer this slot" + confirm_this_slot: "Confirm this slot" + remove_this_slot: "Remove this slot" + to_benefit_from_attractive_prices: "To benefit from attractive prices" + view_our_subscriptions: "View our subscriptions" + or: "or" + you_ve_just_selected_a_: "You've just selected a" + _subscription: "subscription" + cost_of_the_subscription: "Cost of the subscription" + confirm_and_pay: "Confirm and pay" + you_have_settled_the_following_machine_hours: "You have settled the following machine hours:" + you_have_settled_a_: "You have settled a" + total_: "TOTAL :" + thank_you_your_payment_has_been_successfully_registered: "Thank you. Your payment has been successfully registered !" + your_invoice_will_be_available_soon_from_your_: "Your invoice will be available soon form your" + dashboard: "Dashboard" + i_want_to_change_the_following_reservation: "I want to change the following reservation:" + cancel_my_modification: "Cancel my modification" + select_a_new_slot_in_the_calendar: "Select a new slot in the calendar" + cancel_my_selection: "Cancel my selection" + tags_of_the_original_slot: "Tags of the original slot:" + tags_of_the_destination_slot: "Tags of the destination slot:" + confirm_my_modification: "Confirm my modification" + your_booking_slot_was_successfully_moved_from_: "Your booking slot was successfully moved from" + to_date: "to" # context: date. eg: "from 01/01 to 01/05" + please_select_a_member_first: "Please select a member first" + unable_to_change_the_reservation: "Unable to change the reservation" + confirmation_required: "Confirmation required" + do_you_really_want_to_cancel_this_reservation: "Do you really want to cancel this reservation?" + reservation_was_cancelled_successfully: "Reservation was cancelled successfully." + cancellation_failed: "Cancellation failed." + confirm_payment_of_html: "{ROLE, select, admin{Payment on site} other{Pay}}: {AMOUNT}" # messageFormat interpolation (context: confirm my payment of $20.00) + a_problem_occured_during_the_payment_process_please_try_again_later: "A problem occurred during the payment process. Please try again later." \ No newline at end of file diff --git a/config/locales/app.shared.fr.yml b/config/locales/app.shared.fr.yml index a96329ef7..f278784be 100644 --- a/config/locales/app.shared.fr.yml +++ b/config/locales/app.shared.fr.yml @@ -412,4 +412,37 @@ fr: select_one_or_more_slots_in_the_calendar: "Sélectionnez un ou plusieurs créneaux dans le calendrier" you_ve_just_selected_the_slot: "Vous venez de sélectionner le créneau :" datetime_to_time: "{{START_DATETIME}} à {{END_TIME}}" # angular interpolation, eg: Thursday, September 4 1986 8:30 PM to 10:00 PM - cost_of_a_machine_hour: "Coût de l'heure machine" \ No newline at end of file + cost_of_a_machine_hour: "Coût de l'heure machine" + offer_this_slot: "Offrir ce créneau" + confirm_this_slot: "Valider ce créneau" + remove_this_slot: "Supprimer ce créneau" + to_benefit_from_attractive_prices: "Pour bénéficier de prix avantageux" + view_our_subscriptions: "Consultez nos abonnements" + or: "ou" + you_ve_just_selected_a_: "Vous venez de sélectionner un" + _subscription: "abonnement" + cost_of_the_subscription: "Coût de l'abonnement" + confirm_and_pay: "Valider et payer" + you_have_settled_the_following_machine_hours: "Vous avez réglé les heures machines suivantes :" + you_have_settled_a_: "Vous avez réglé un" + total_: "TOTAL :" + thank_you_your_payment_has_been_successfully_registered: "Merci. Votre paiement a bien été pris en compte !" + your_invoice_will_be_available_soon_from_your_: "Votre facture sera bientôt disponible depuis votre" + dashboard: "Tableau de bord" + i_want_to_change_the_following_reservation: "Je souhaite modifier ma réservation suivante :" + cancel_my_modification: "Annuler ma modification" + select_a_new_slot_in_the_calendar: "Sélectionnez un nouveau créneau dans le calendrier" + cancel_my_selection: "Annuler ma sélection" + tags_of_the_original_slot: "Étiquettes du créneau d'origine :" + tags_of_the_destination_slot: "Étiquettes du créneau de destination :" + confirm_my_modification: "Valider ma modification" + your_booking_slot_was_successfully_moved_from_: "Votre créneau de réservation a bien été déplacé du" + to_date: "au" # context: date. eg: "from 01/01 to 01/05" + please_select_a_member_first: "Veuillez tout d'abord sélectionner un membre" + unable_to_change_the_reservation: "Impossible de modifier la réservation" + confirmation_required: "Confirmation requise" + do_you_really_want_to_cancel_this_reservation: "Êtes-vous sur de vouloir annuler cette réservation ?" + reservation_was_cancelled_successfully: "La réservation a bien été annulée." + cancellation_failed: "L'annulation a échouée." + confirm_payment_of_html: "{ROLE, select, admin{Paiement sur place} other{Payer}} : {AMOUNT}" # messageFormat interpolation (contexte : valider mon paiement de 20,00 €) + a_problem_occured_during_the_payment_process_please_try_again_later: "Il y a eu un problème lors de la procédure de paiement. Veuillez réessayer plus tard."