mirror of
https://github.com/LaCasemate/fab-manager.git
synced 2025-01-29 18:52:22 +01:00
display correct slot status in space reservation calendar
This commit is contained in:
parent
af5f3c777d
commit
847a0ba140
@ -182,6 +182,11 @@ class API::AvailabilitiesController < API::ApiController
|
||||
end
|
||||
end
|
||||
end
|
||||
@slots.each do |s|
|
||||
if s.is_complete?
|
||||
s.title = t('availabilities.not_available')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def reservations
|
||||
@ -243,7 +248,7 @@ class API::AvailabilitiesController < API::ApiController
|
||||
if s.start_at == slot.start_at and r.user == user and s.canceled_at == nil
|
||||
slot.title = t('availabilities.i_ve_reserved')
|
||||
slot.can_modify = true
|
||||
slot.is_reserved_by_current_user = true
|
||||
slot.is_reserved = true
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -30,11 +30,9 @@ module AvailabilityHelper
|
||||
|
||||
def space_slot_border_color(slot)
|
||||
if slot.is_reserved
|
||||
if slot.is_reserved_by_current_user
|
||||
IS_RESERVED_BY_CURRENT_USER
|
||||
elsif slot.availability.is_completed
|
||||
IS_COMPLETED
|
||||
end
|
||||
IS_RESERVED_BY_CURRENT_USER
|
||||
elsif slot.is_complete?
|
||||
IS_COMPLETED
|
||||
else
|
||||
SPACE_COLOR
|
||||
end
|
||||
|
@ -22,6 +22,10 @@ class Slot < ActiveRecord::Base
|
||||
super
|
||||
end
|
||||
|
||||
def is_complete?
|
||||
reservations.length >= availability.nb_total_places
|
||||
end
|
||||
|
||||
private
|
||||
def notify_member_and_admin_slot_is_modified
|
||||
NotificationCenter.call type: 'notify_member_slot_is_modified',
|
||||
|
@ -5,6 +5,7 @@ json.array!(@slots) do |slot|
|
||||
json.start slot.start_at.iso8601
|
||||
json.end slot.end_at.iso8601
|
||||
json.is_reserved slot.is_reserved
|
||||
json.is_completed slot.is_complete?
|
||||
json.backgroundColor 'white'
|
||||
json.borderColor space_slot_border_color(slot)
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user