mirror of
https://github.com/LaCasemate/fab-manager.git
synced 2025-02-20 14:54:15 +01:00
(bug) invalid border color for slots
This commit is contained in:
parent
6d9b4b2c70
commit
ee2cbc332f
@ -1,6 +1,7 @@
|
||||
# Changelog Fab-manager
|
||||
|
||||
- Fix a bug: unable to update recurrent events
|
||||
- Fix a bug: invalid border color for slots
|
||||
|
||||
## v5.7.1 2023 February 20
|
||||
|
||||
|
@ -23,10 +23,11 @@ module AvailabilityHelper
|
||||
end
|
||||
|
||||
# @param slot [Slot]
|
||||
# @param reservable [Machine]
|
||||
# @param customer [User]
|
||||
def machines_slot_border_color(slot, customer = nil)
|
||||
if slot.reserved?
|
||||
slot.reserved_by?(customer&.id) ? IS_RESERVED_BY_CURRENT_USER : IS_FULL
|
||||
def machines_slot_border_color(slot, reservable = nil, customer = nil)
|
||||
if slot.reserved?(reservable)
|
||||
slot.reserved_by?(customer&.id, [reservable]) ? IS_RESERVED_BY_CURRENT_USER : IS_FULL
|
||||
else
|
||||
MACHINE_COLOR
|
||||
end
|
||||
|
@ -11,7 +11,7 @@ class Slots::TitleService
|
||||
# @param reservables [Array<Machine, Space, Training, Event>]
|
||||
def call(slot, reservables = nil)
|
||||
reservables = all_reservables(slot) if reservables.nil?
|
||||
is_reserved = slot.reserved?
|
||||
is_reserved = reservables.map { |r| slot.reserved?(r) }.reduce(:|)
|
||||
is_reserved_by_user = slot.reserved_by?(@user&.id, reservables)
|
||||
|
||||
name = reservables.map(&:name).join(', ')
|
||||
@ -37,6 +37,7 @@ class Slots::TitleService
|
||||
end
|
||||
|
||||
# @param slot [Slot]
|
||||
# @return [Array<Machine, Space, Training, Event>]
|
||||
def all_reservables(slot)
|
||||
slot.places.pluck('reservable_type', 'reservable_id').map { |r| r[0].classify.constantize.find(r[1]) }
|
||||
end
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
json.array!(@slots) do |slot|
|
||||
json.partial! 'api/availabilities/slot', slot: slot, operator_role: @operator_role, reservable: @machine
|
||||
json.borderColor machines_slot_border_color(slot, @customer)
|
||||
json.borderColor machines_slot_border_color(slot, @machine, @customer)
|
||||
|
||||
json.machine do
|
||||
json.id @machine.id
|
||||
|
Loading…
x
Reference in New Issue
Block a user