mirror of
https://github.com/LaCasemate/fab-manager.git
synced 2025-01-29 18:52:22 +01:00
get availability border color in helper
This commit is contained in:
parent
0af0cc7878
commit
44b0fd8aa8
@ -285,13 +285,13 @@ Application.Controllers.controller "ReserveMachineController", ["$scope", "$stat
|
|||||||
PREVENT_BOOKING_MODIFICATION_DELAY = 1
|
PREVENT_BOOKING_MODIFICATION_DELAY = 1
|
||||||
|
|
||||||
# Slot already booked by the current user
|
# Slot already booked by the current user
|
||||||
FREE_SLOT_BORDER_COLOR = '#e4cd78'
|
FREE_SLOT_BORDER_COLOR = '<%= AvailabilityHelper::MACHINE_COLOR %>'
|
||||||
|
|
||||||
# Slot already booked by another user
|
# Slot already booked by another user
|
||||||
UNAVAILABLE_SLOT_BORDER_COLOR = '#1d98ec'
|
UNAVAILABLE_SLOT_BORDER_COLOR = '<%= AvailabilityHelper::MACHINE_IS_RESERVED_BY_USER %>'
|
||||||
|
|
||||||
# Slot free to be booked
|
# Slot free to be booked
|
||||||
BOOKED_SLOT_BORDER_COLOR = '#b2e774'
|
BOOKED_SLOT_BORDER_COLOR = '<%= AvailabilityHelper::IS_RESERVED_BY_CURRENT_USER %>'
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -71,7 +71,7 @@ Application.Controllers.controller "ReserveTrainingController", ["$scope", "$sta
|
|||||||
SELECTED_EVENT_BG_COLOR = '#ffdd00'
|
SELECTED_EVENT_BG_COLOR = '#ffdd00'
|
||||||
|
|
||||||
# Slot already booked by the current user
|
# Slot already booked by the current user
|
||||||
FREE_SLOT_BORDER_COLOR = '#bd7ae9'
|
FREE_SLOT_BORDER_COLOR = '<%= AvailabilityHelper::TRAINING_COLOR %>'
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -6,6 +6,7 @@
|
|||||||
.bg-token { background-color: rgba(230, 208, 137, 0.49); }
|
.bg-token { background-color: rgba(230, 208, 137, 0.49); }
|
||||||
.bg-machine { background-color: $beige; }
|
.bg-machine { background-color: $beige; }
|
||||||
.bg-formation { background-color: $violet; }
|
.bg-formation { background-color: $violet; }
|
||||||
|
.bg-event { background-color: $japonica; }
|
||||||
.bg-atelier { background-color: $blue; }
|
.bg-atelier { background-color: $blue; }
|
||||||
.bg-stage { background-color: $violet; }
|
.bg-stage { background-color: $violet; }
|
||||||
.bg-success { background-color: $brand-success; }
|
.bg-success { background-color: $brand-success; }
|
||||||
|
@ -43,6 +43,7 @@ $blue: $brand-info;
|
|||||||
$green: $brand-success;
|
$green: $brand-success;
|
||||||
$beige: #e4cd78;
|
$beige: #e4cd78;
|
||||||
$violet: #bd7ae9;
|
$violet: #bd7ae9;
|
||||||
|
$japonica: #dd7e6b;
|
||||||
|
|
||||||
$border-color: #dddddd;
|
$border-color: #dddddd;
|
||||||
$header-bg: $bg-gray;
|
$header-bg: $bg-gray;
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="col-xs-10 col-sm-10 col-md-8 b-l b-r-md">
|
<div class="col-xs-10 col-sm-10 col-md-8 b-l b-r-md">
|
||||||
<section class="heading-title">
|
<section class="heading-title">
|
||||||
<h1>{{ event.title }} <span class="v-middle badge text-xs bg-formation">{{event.categories[0].name}}</span></h1>
|
<h1>{{ event.title }} <span class="v-middle badge text-xs bg-event">{{event.categories[0].name}}</span></h1>
|
||||||
</section>
|
</section>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
32
app/helpers/availability_helper.rb
Normal file
32
app/helpers/availability_helper.rb
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
module AvailabilityHelper
|
||||||
|
MACHINE_COLOR = '#e4cd78'
|
||||||
|
TRAINING_COLOR = '#bd7ae9'
|
||||||
|
EVENT_COLOR = '#dd7e6b'
|
||||||
|
IS_RESERVED_BY_CURRENT_USER = '#b2e774'
|
||||||
|
MACHINE_IS_RESERVED_BY_USER = '#1d98ec'
|
||||||
|
TRAINING_IS_COMPLETED = '#eeeeee'
|
||||||
|
|
||||||
|
def availability_border_color(availability)
|
||||||
|
if availability.available_type == 'machines'
|
||||||
|
MACHINE_COLOR
|
||||||
|
elsif availability.available_type == 'training'
|
||||||
|
TRAINING_COLOR
|
||||||
|
else
|
||||||
|
EVENT_COLOR
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def machines_slot_border_color(slot)
|
||||||
|
slot.is_reserved ? (slot.is_reserved_by_current_user ? IS_RESERVED_BY_CURRENT_USER : MACHINE_IS_RESERVED_BY_USER) : MACHINE_COLOR
|
||||||
|
end
|
||||||
|
|
||||||
|
def trainings_border_color(availability)
|
||||||
|
if availability.is_reserved
|
||||||
|
IS_RESERVED_BY_CURRENT_USER
|
||||||
|
elsif availability.is_completed
|
||||||
|
TRAINING_IS_COMPLETED
|
||||||
|
else
|
||||||
|
TRAINING_COLOR
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
@ -7,7 +7,7 @@ json.array!(@availabilities) do |availability|
|
|||||||
json.machine_ids availability.machine_ids
|
json.machine_ids availability.machine_ids
|
||||||
json.training_ids availability.training_ids
|
json.training_ids availability.training_ids
|
||||||
json.backgroundColor 'white'
|
json.backgroundColor 'white'
|
||||||
json.borderColor availability.available_type == 'machines' ? '#e4cd78' : '#bd7ae9'
|
json.borderColor availability_border_color(availability)
|
||||||
json.tag_ids availability.tag_ids
|
json.tag_ids availability.tag_ids
|
||||||
json.tags availability.tags do |t|
|
json.tags availability.tags do |t|
|
||||||
json.id t.id
|
json.id t.id
|
||||||
|
@ -6,7 +6,7 @@ json.array!(@slots) do |slot|
|
|||||||
json.end slot.end_at.iso8601
|
json.end slot.end_at.iso8601
|
||||||
json.is_reserved slot.is_reserved
|
json.is_reserved slot.is_reserved
|
||||||
json.backgroundColor 'white'
|
json.backgroundColor 'white'
|
||||||
json.borderColor slot.is_reserved ? (slot.is_reserved_by_current_user ? '#b2e774' : '#1d98ec') : '#e4cd78'
|
json.borderColor machines_slot_border_color(slot)
|
||||||
|
|
||||||
json.availability_id slot.availability_id
|
json.availability_id slot.availability_id
|
||||||
json.machine do
|
json.machine do
|
||||||
|
@ -4,7 +4,7 @@ json.end_at @availability.end_at.iso8601
|
|||||||
json.available_type @availability.available_type
|
json.available_type @availability.available_type
|
||||||
json.machine_ids @availability.machine_ids
|
json.machine_ids @availability.machine_ids
|
||||||
json.backgroundColor 'white'
|
json.backgroundColor 'white'
|
||||||
json.borderColor @availability.available_type == 'machines' ? '#e4cd78' : '#bd7ae9'
|
json.borderColor availability_border_color(@availability)
|
||||||
json.title @availability.title
|
json.title @availability.title
|
||||||
json.tag_ids @availability.tag_ids
|
json.tag_ids @availability.tag_ids
|
||||||
json.tags @availability.tags do |t|
|
json.tags @availability.tags do |t|
|
||||||
|
@ -4,15 +4,13 @@ json.array!(@availabilities) do |a|
|
|||||||
if a.is_reserved
|
if a.is_reserved
|
||||||
json.is_reserved true
|
json.is_reserved true
|
||||||
json.title "#{a.trainings[0].name}' - #{t('trainings.i_ve_reserved')}"
|
json.title "#{a.trainings[0].name}' - #{t('trainings.i_ve_reserved')}"
|
||||||
json.borderColor '#b2e774'
|
|
||||||
elsif a.is_completed
|
elsif a.is_completed
|
||||||
json.is_completed true
|
json.is_completed true
|
||||||
json.title "#{a.trainings[0].name} - #{t('trainings.completed')}"
|
json.title "#{a.trainings[0].name} - #{t('trainings.completed')}"
|
||||||
json.borderColor '#eeeeee'
|
|
||||||
else
|
else
|
||||||
json.title a.trainings[0].name
|
json.title a.trainings[0].name
|
||||||
json.borderColor '#bd7ae9'
|
|
||||||
end
|
end
|
||||||
|
json.borderColor trainings_border_color(a)
|
||||||
json.start a.start_at.iso8601
|
json.start a.start_at.iso8601
|
||||||
json.end a.end_at.iso8601
|
json.end a.end_at.iso8601
|
||||||
json.backgroundColor 'white'
|
json.backgroundColor 'white'
|
||||||
|
Loading…
x
Reference in New Issue
Block a user