1
0
mirror of https://github.com/LaCasemate/fab-manager.git synced 2024-12-11 22:24:21 +01:00
fab-manager/app/helpers/availability_helper.rb

63 lines
1.3 KiB
Ruby
Raw Normal View History

2019-04-04 09:33:41 +02:00
# frozen_string_literal: true
# Helpers methods about calendar availabilities
module AvailabilityHelper
MACHINE_COLOR = '#e4cd78'
TRAINING_COLOR = '#bd7ae9'
2017-02-15 13:18:03 +01:00
SPACE_COLOR = '#3fc7ff'
EVENT_COLOR = '#dd7e6b'
IS_RESERVED_BY_CURRENT_USER = '#b2e774'
MACHINE_IS_RESERVED_BY_USER = '#1d98ec'
2022-07-12 17:46:01 +02:00
IS_FULL = '#eeeeee'
def availability_border_color(availability)
2017-02-15 13:18:03 +01:00
case availability.available_type
2019-04-04 09:33:41 +02:00
when 'machines'
MACHINE_COLOR
when 'training'
TRAINING_COLOR
when 'space'
SPACE_COLOR
else
EVENT_COLOR
end
end
def machines_slot_border_color(slot)
2017-02-23 17:45:55 +01:00
if slot.is_reserved
2022-07-12 17:46:01 +02:00
slot.current_user_slots_reservations_ids.empty? ? IS_FULL : IS_RESERVED_BY_CURRENT_USER
2017-02-23 17:45:55 +01:00
else
MACHINE_COLOR
end
end
def space_slot_border_color(slot)
if slot.is_reserved
IS_RESERVED_BY_CURRENT_USER
2022-07-12 17:46:01 +02:00
elsif slot.full?
IS_FULL
2017-02-23 17:45:55 +01:00
else
SPACE_COLOR
end
end
def trainings_events_border_color(availability)
if availability.is_reserved
IS_RESERVED_BY_CURRENT_USER
2022-06-29 10:30:17 +02:00
elsif availability.full?
2022-07-12 17:46:01 +02:00
IS_FULL
else
2017-02-23 17:45:55 +01:00
case availability.available_type
2019-04-04 09:33:41 +02:00
when 'training'
TRAINING_COLOR
when 'event'
EVENT_COLOR
when 'space'
SPACE_COLOR
else
'#000'
end
end
end
end