1
0
mirror of https://github.com/LaCasemate/fab-manager.git synced 2024-12-01 12:24:28 +01:00
fab-manager/app/views/api/availabilities/public.json.jbuilder

49 lines
1.6 KiB
Plaintext
Raw Normal View History

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
if availability.try(:available_type)
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
if availability.available_type != 'machines'
json.borderColor trainings_events_border_color(availability)
if availability.is_reserved
json.is_reserved true
json.title "#{availability.title}' - #{t('trainings.i_ve_reserved')}"
elsif availability.is_completed
json.is_completed true
json.title "#{availability.title} - #{t('trainings.completed')}"
end
else
json.borderColor availability_border_color(availability)
end
2016-06-29 17:58:53 +02:00
# machine slot object ( here => availability = slot )
2016-06-28 18:58:44 +02:00
else
json.title availability.title
2016-06-29 17:58:53 +02:00
json.machine_id availability.machine.id
2016-06-28 18:58:44 +02:00
json.borderColor machines_slot_border_color(availability)
json.tag_ids availability.availability.tag_ids
json.tags availability.availability.tags do |t|
json.id t.id
json.name t.name
end
json.is_reserved availability.is_reserved
2016-06-28 18:58:44 +02:00
end
end