2016-06-28 18:58:44 +02:00
|
|
|
json.array!(@availabilities) do |availability|
|
|
|
|
json.id availability.id
|
|
|
|
json.start availability.start_at.iso8601
|
|
|
|
json.end availability.end_at.iso8601
|
2016-07-01 12:31:59 +02:00
|
|
|
json.textColor 'black'
|
2016-06-28 18:58:44 +02:00
|
|
|
json.backgroundColor 'white'
|
|
|
|
# availability object
|
2017-02-28 11:59:48 +01:00
|
|
|
if availability.instance_of? Availability
|
2016-07-14 18:36:52 +02:00
|
|
|
json.title availability.title(@title_filter)
|
2016-06-28 18:58:44 +02:00
|
|
|
if availability.available_type == 'event'
|
|
|
|
json.event_id availability.event.id
|
|
|
|
end
|
|
|
|
if availability.available_type == 'training'
|
|
|
|
json.training_id availability.trainings.first.id
|
|
|
|
end
|
|
|
|
json.available_type availability.available_type
|
|
|
|
json.tag_ids availability.tag_ids
|
|
|
|
json.tags availability.tags do |t|
|
|
|
|
json.id t.id
|
|
|
|
json.name t.name
|
|
|
|
end
|
2016-06-29 17:37:22 +02:00
|
|
|
|
2017-02-28 11:59:48 +01:00
|
|
|
if availability.available_type == 'training' or availability.available_type == 'event'
|
2016-06-29 17:37:22 +02:00
|
|
|
json.borderColor trainings_events_border_color(availability)
|
|
|
|
if availability.is_reserved
|
|
|
|
json.is_reserved true
|
|
|
|
json.title "#{availability.title}' - #{t('trainings.i_ve_reserved')}"
|
2022-06-29 10:30:17 +02:00
|
|
|
elsif availability.full?
|
2016-06-29 17:37:22 +02:00
|
|
|
json.is_completed true
|
|
|
|
json.title "#{availability.title} - #{t('trainings.completed')}"
|
|
|
|
end
|
2017-02-28 11:59:48 +01:00
|
|
|
elsif availability.available_type == 'space'
|
2017-02-28 16:51:56 +01:00
|
|
|
complete = availability.slots.length >= availability.available_space_places
|
2017-02-28 11:59:48 +01:00
|
|
|
json.is_completed complete
|
|
|
|
json.borderColor availability_border_color(availability)
|
|
|
|
if complete
|
|
|
|
json.title "#{availability.title} - #{t('trainings.completed')}"
|
2022-07-12 17:46:01 +02:00
|
|
|
json.borderColor AvailabilityHelper::IS_FULL
|
2017-02-28 16:51:56 +01:00
|
|
|
end
|
|
|
|
if availability.is_reserved
|
|
|
|
json.is_reserved true
|
|
|
|
json.title "#{availability.title} - #{t('trainings.i_ve_reserved')}"
|
2017-02-28 11:59:48 +01:00
|
|
|
end
|
2016-06-29 17:37:22 +02:00
|
|
|
else
|
|
|
|
json.borderColor availability_border_color(availability)
|
|
|
|
end
|
|
|
|
|
2017-02-28 11:59:48 +01:00
|
|
|
# slot object ( here => availability = slot )
|
|
|
|
# -> machines / spaces
|
|
|
|
elsif availability.instance_of? Slot
|
2016-07-14 18:36:52 +02:00
|
|
|
json.title availability.title
|
2016-06-28 18:58:44 +02:00
|
|
|
json.tag_ids availability.availability.tag_ids
|
|
|
|
json.tags availability.availability.tags do |t|
|
|
|
|
json.id t.id
|
|
|
|
json.name t.name
|
|
|
|
end
|
2017-02-28 11:59:48 +01:00
|
|
|
if availability.try(:machine)
|
|
|
|
json.machine_id availability.machine.id
|
|
|
|
json.borderColor machines_slot_border_color(availability)
|
|
|
|
json.is_reserved availability.is_reserved
|
|
|
|
elsif availability.try(:space)
|
|
|
|
json.space_id availability.space.id
|
|
|
|
json.borderColor space_slot_border_color(availability)
|
2022-07-12 17:46:01 +02:00
|
|
|
json.is_completed availability.full?
|
2017-02-28 11:59:48 +01:00
|
|
|
else
|
|
|
|
json.title 'Unknown slot'
|
|
|
|
end
|
|
|
|
else
|
|
|
|
json.title 'Unknown object'
|
2016-06-28 18:58:44 +02:00
|
|
|
end
|
|
|
|
end
|