1
0
mirror of https://github.com/LaCasemate/fab-manager.git synced 2025-01-18 07:52:23 +01:00

Fix a bug: unable to show machine availability slot for admin

This commit is contained in:
Du Peng 2022-04-05 14:11:46 +02:00
parent f24002e323
commit 08b072e33c
21 changed files with 31 additions and 9 deletions

View File

@ -1,5 +1,7 @@
# Changelog Fab-manager # Changelog Fab-manager
- Fix a bug: unable to show machine availability slot for admin
## v5.3.9 2022 April 01 ## v5.3.9 2022 April 01
- Optimise sql query, avoid to N+1 - Optimise sql query, avoid to N+1

View File

@ -564,7 +564,12 @@ Application.Directives.directive('cart', ['$rootScope', '$uibModal', 'dialogs',
return dialogs.confirm({ return dialogs.confirm({
templateUrl: '/shared/confirm_modify_slot_modal.html', templateUrl: '/shared/confirm_modify_slot_modal.html',
resolve: { resolve: {
object () { return $scope.slot; } object () {
if ($scope.slot.user && !$scope.slot.user.name) {
$scope.slot.user.name = _t('app.shared.confirm_modify_slot_modal.deleted_user');
}
return $scope.slot;
}
} }
} }
, function (type) { , function (type) {

View File

@ -80,7 +80,8 @@
<div class="widget-content no-bg auto wrapper" ng-class="{'reservations-locked': availability.lock}"> <div class="widget-content no-bg auto wrapper" ng-class="{'reservations-locked': availability.lock}">
<ul class="list-unstyled" ng-if="reservations.length > 0"> <ul class="list-unstyled" ng-if="reservations.length > 0">
<li ng-repeat="r in reservations" class="m-b-xs" ng-class="{'reservation-canceled':r.canceled_at}"> <li ng-repeat="r in reservations" class="m-b-xs" ng-class="{'reservation-canceled':r.canceled_at}">
{{r.user.name}} <span ng-if="r.user.name">{{r.user.name}}</span>
<span translate ng-if="!r.user.name">{{ 'app.admin.calendar.deleted_user' }}</span>
- <span class="label reservation-time">{{ r.start_at | amDateFormat:'LLL' }} - {{ r.end_at | amDateFormat:'LT' }}</span> - <span class="label reservation-time">{{ r.start_at | amDateFormat:'LLL' }} - {{ r.end_at | amDateFormat:'LT' }}</span>
- <span class="label label-success text-white">{{r.reservable.name}}</span> - <span class="label label-success text-white">{{r.reservable.name}}</span>
<span class="btn btn-warning btn-xs" ng-click="cancelBooking(r)" ng-if="!r.canceled_at"><i class="fa fa-times red"></i></span> <span class="btn btn-warning btn-xs" ng-click="cancelBooking(r)" ng-if="!r.canceled_at"><i class="fa fa-times red"></i></span>

View File

@ -3,8 +3,8 @@
<h1 translate>{{ 'app.shared.confirm_modify_slot_modal.change_the_slot' }}</h1> <h1 translate>{{ 'app.shared.confirm_modify_slot_modal.change_the_slot' }}</h1>
</div> </div>
<div class="modal-body"> <div class="modal-body">
<p ng-show="currentUser.id === object.user.id" translate>{{ 'app.shared.confirm_modify_slot_modal.do_you_want_to_change_your_booking_slot_initially_planned_at' }} </p> <p ng-show="!object.user" translate>{{ 'app.shared.confirm_modify_slot_modal.do_you_want_to_change_your_booking_slot_initially_planned_at' }} </p>
<p ng-show="currentUser.id !== object.user.id" translate translate-values="{NAME: object.user.name}">{{ 'app.shared.confirm_modify_slot_modal.do_you_want_to_change_NAME_s_booking_slot_initially_planned_at' }}</p> <p ng-show="object.user && currentUser.id !== object.user.id" translate translate-values="{NAME: object.user.name}">{{ 'app.shared.confirm_modify_slot_modal.do_you_want_to_change_NAME_s_booking_slot_initially_planned_at' }}</p>
<p><strong>{{object.start | amDateFormat: 'LL'}} : {{object.start | amDateFormat:'LT'}} - {{object.end | amDateFormat:'LT'}}</strong></p> <p><strong>{{object.start | amDateFormat: 'LL'}} : {{object.start | amDateFormat:'LT'}} - {{object.end | amDateFormat:'LT'}}</strong></p>
</div> </div>
<div class="modal-footer"> <div class="modal-footer">

View File

@ -18,8 +18,8 @@ json.array!(@slots) do |slot|
# the user who booked the slot, if the slot was reserved # the user who booked the slot, if the slot was reserved
if (%w[admin manager].include? @current_user_role) && slot.reservation if (%w[admin manager].include? @current_user_role) && slot.reservation
json.user do json.user do
json.id slot.reservation.user.id json.id slot.reservation.user&.id
json.name slot.reservation.user.profile.full_name json.name slot.reservation.user&.profile&.full_name
end end
end end
json.tag_ids slot.availability.tag_ids json.tag_ids slot.availability.tag_ids

View File

@ -19,8 +19,8 @@ json.array!(@slots) do |slot|
# the user who booked the slot, if the slot was reserved # the user who booked the slot, if the slot was reserved
if (%w[admin manager].include? @current_user_role) && slot.reservation if (%w[admin manager].include? @current_user_role) && slot.reservation
json.user do json.user do
json.id slot.reservation.user.id json.id slot.reservation.user&.id
json.name slot.reservation.user.profile.full_name json.name slot.reservation.user&.profile&.full_name
end end
end end
json.tag_ids slot.availability.tag_ids json.tag_ids slot.availability.tag_ids

View File

@ -2,7 +2,7 @@
json.id reservation.id json.id reservation.id
json.user_id reservation.statistic_profile.user_id json.user_id reservation.statistic_profile.user_id
json.user_full_name reservation.user.profile.full_name json.user_full_name reservation.user&.profile&.full_name
json.message reservation.message json.message reservation.message
json.slots_attributes reservation.slots do |s| json.slots_attributes reservation.slots do |s|
json.id s.id json.id s.id

View File

@ -109,6 +109,7 @@ de:
slots: "Slots" slots: "Slots"
slots_of: "von" slots_of: "von"
minutes: "Minuten" minutes: "Minuten"
deleted_user: "Deleted user"
#import external iCal calendar #import external iCal calendar
icalendar: icalendar:
icalendar_import: "iCalendar Import" icalendar_import: "iCalendar Import"

View File

@ -109,6 +109,7 @@ en:
slots: "slots" slots: "slots"
slots_of: "of" slots_of: "of"
minutes: "minutes" minutes: "minutes"
deleted_user: "Deleted user"
# import external iCal calendar # import external iCal calendar
icalendar: icalendar:
icalendar_import: "iCalendar import" icalendar_import: "iCalendar import"

View File

@ -109,6 +109,7 @@ es:
slots: "slots" slots: "slots"
slots_of: "of" slots_of: "of"
minutes: "minutes" minutes: "minutes"
deleted_user: "Deleted user"
#import external iCal calendar #import external iCal calendar
icalendar: icalendar:
icalendar_import: "iCalendar import" icalendar_import: "iCalendar import"

View File

@ -109,6 +109,7 @@ fr:
slots: "créneaux" slots: "créneaux"
slots_of: "de" slots_of: "de"
minutes: "minutes" minutes: "minutes"
deleted_user: "Utilisateur supprimé"
#import external iCal calendar #import external iCal calendar
icalendar: icalendar:
icalendar_import: "Import iCalendar" icalendar_import: "Import iCalendar"

View File

@ -109,6 +109,7 @@
slots: "reservasjoner" slots: "reservasjoner"
slots_of: "av" slots_of: "av"
minutes: "minutter" minutes: "minutter"
deleted_user: "Deleted user"
#import external iCal calendar #import external iCal calendar
icalendar: icalendar:
icalendar_import: "iCalendar import" icalendar_import: "iCalendar import"

View File

@ -109,6 +109,7 @@ pt:
slots: "slots" slots: "slots"
slots_of: "do" slots_of: "do"
minutes: "minutos" minutes: "minutos"
deleted_user: "Deleted user"
#import external iCal calendar #import external iCal calendar
icalendar: icalendar:
icalendar_import: "importar iCalendar" icalendar_import: "importar iCalendar"

View File

@ -109,6 +109,7 @@ zu:
slots: "crwdns20302:0crwdne20302:0" slots: "crwdns20302:0crwdne20302:0"
slots_of: "crwdns20304:0crwdne20304:0" slots_of: "crwdns20304:0crwdne20304:0"
minutes: "crwdns20288:0crwdne20288:0" minutes: "crwdns20288:0crwdne20288:0"
deleted_user: "Deleted user"
#import external iCal calendar #import external iCal calendar
icalendar: icalendar:
icalendar_import: "crwdns6855:0crwdne6855:0" icalendar_import: "crwdns6855:0crwdne6855:0"

View File

@ -283,6 +283,7 @@ de:
do_you_want_to_change_NAME_s_booking_slot_initially_planned_at: "Möchten Sie den {NAME}-Buchungsplatz ändern? Ursprünglich geplant um:" do_you_want_to_change_NAME_s_booking_slot_initially_planned_at: "Möchten Sie den {NAME}-Buchungsplatz ändern? Ursprünglich geplant um:"
cancel_this_reservation: "Reservierung stornieren" cancel_this_reservation: "Reservierung stornieren"
i_want_to_change_date: "Ich möchte das Datum ändern" i_want_to_change_date: "Ich möchte das Datum ändern"
deleted_user: "Deleted user"
#user public profile #user public profile
public_profile: public_profile:
last_activity_html: "Letzte Aktivität <br><strong>am {DATE}</strong>" last_activity_html: "Letzte Aktivität <br><strong>am {DATE}</strong>"

View File

@ -283,6 +283,7 @@ en:
do_you_want_to_change_NAME_s_booking_slot_initially_planned_at: "Do you want to change {NAME}'s booking slot, initially planned at:" do_you_want_to_change_NAME_s_booking_slot_initially_planned_at: "Do you want to change {NAME}'s booking slot, initially planned at:"
cancel_this_reservation: "Cancel this reservation" cancel_this_reservation: "Cancel this reservation"
i_want_to_change_date: "I want to change date" i_want_to_change_date: "I want to change date"
deleted_user: "deleted user"
#user public profile #user public profile
public_profile: public_profile:
last_activity_html: "Last activity <br><strong>on {DATE}</strong>" last_activity_html: "Last activity <br><strong>on {DATE}</strong>"

View File

@ -283,6 +283,7 @@ es:
do_you_want_to_change_NAME_s_booking_slot_initially_planned_at: "Desea cambiar la reserva de {NAME} , efectuada inicialmente el:" do_you_want_to_change_NAME_s_booking_slot_initially_planned_at: "Desea cambiar la reserva de {NAME} , efectuada inicialmente el:"
cancel_this_reservation: "Cancelar reserva" cancel_this_reservation: "Cancelar reserva"
i_want_to_change_date: "Quiero cambiar la fecha" i_want_to_change_date: "Quiero cambiar la fecha"
deleted_user: "deleted user"
#user public profile #user public profile
public_profile: public_profile:
last_activity_html: "Last activity <br><strong>on {DATE}</strong>" last_activity_html: "Last activity <br><strong>on {DATE}</strong>"

View File

@ -283,6 +283,7 @@ fr:
do_you_want_to_change_NAME_s_booking_slot_initially_planned_at: "Souhaitez-vous changer le créneau de réservation de {NAME}, initialement prévu au :" do_you_want_to_change_NAME_s_booking_slot_initially_planned_at: "Souhaitez-vous changer le créneau de réservation de {NAME}, initialement prévu au :"
cancel_this_reservation: "Annuler cette réservation" cancel_this_reservation: "Annuler cette réservation"
i_want_to_change_date: "Je veux changer de date" i_want_to_change_date: "Je veux changer de date"
deleted_user: "l'utilisateur supprimé"
#user public profile #user public profile
public_profile: public_profile:
last_activity_html: "Dernière activité <br><strong>le {DATE}</strong>" last_activity_html: "Dernière activité <br><strong>le {DATE}</strong>"

View File

@ -283,6 +283,7 @@
do_you_want_to_change_NAME_s_booking_slot_initially_planned_at: "Vil du endre {NAME} sin bestillingsplass, som opprinnelig er planlagt på:" do_you_want_to_change_NAME_s_booking_slot_initially_planned_at: "Vil du endre {NAME} sin bestillingsplass, som opprinnelig er planlagt på:"
cancel_this_reservation: "Avbryt reservasjon" cancel_this_reservation: "Avbryt reservasjon"
i_want_to_change_date: "Jeg vil endre dato" i_want_to_change_date: "Jeg vil endre dato"
deleted_user: "deleted user"
#user public profile #user public profile
public_profile: public_profile:
last_activity_html: "Siste aktivitet <br><strong>{DATE}</strong>" last_activity_html: "Siste aktivitet <br><strong>{DATE}</strong>"

View File

@ -283,6 +283,7 @@ pt:
do_you_want_to_change_NAME_s_booking_slot_initially_planned_at: "Você deseja alterar o agendamento do usuário {NAME}, inicialmente marcado para:" do_you_want_to_change_NAME_s_booking_slot_initially_planned_at: "Você deseja alterar o agendamento do usuário {NAME}, inicialmente marcado para:"
cancel_this_reservation: "Cancelar essa reserva" cancel_this_reservation: "Cancelar essa reserva"
i_want_to_change_date: "Eu quero alterar a data" i_want_to_change_date: "Eu quero alterar a data"
deleted_user: "deleted user"
#user public profile #user public profile
public_profile: public_profile:
last_activity_html: "Última atividade <br><strong>em {DATE}</strong>" last_activity_html: "Última atividade <br><strong>em {DATE}</strong>"

View File

@ -283,6 +283,7 @@ zu:
do_you_want_to_change_NAME_s_booking_slot_initially_planned_at: "crwdns9825:0{NAME}crwdne9825:0" do_you_want_to_change_NAME_s_booking_slot_initially_planned_at: "crwdns9825:0{NAME}crwdne9825:0"
cancel_this_reservation: "crwdns9827:0crwdne9827:0" cancel_this_reservation: "crwdns9827:0crwdne9827:0"
i_want_to_change_date: "crwdns9829:0crwdne9829:0" i_want_to_change_date: "crwdns9829:0crwdne9829:0"
deleted_user: "deleted user"
#user public profile #user public profile
public_profile: public_profile:
last_activity_html: "crwdns9843:0{DATE}crwdne9843:0" last_activity_html: "crwdns9843:0{DATE}crwdne9843:0"