fix start of timeline

This commit is contained in:
Torsten 2023-07-11 09:07:35 +03:00
parent 6279b7df4c
commit 1b44e9464f
2 changed files with 7 additions and 2 deletions

View File

@ -9,18 +9,23 @@ module TimelineHelper
def max_days
@weeks * 7
end
# number of days from start of month to start of stay
def started_days(member)
return 0 unless member.arriving
return 0 if member.arriving < Date.today.at_beginning_of_month
distance = (member.arriving - Date.today.at_beginning_of_month).to_i
distance > max_days ? max_days : distance
end
def left_max
Date.today.at_beginning_of_month + 3.months
end
# amount of days of the stay, maxed at the number fo weeks shown
def stay_days(member)
return 0 unless member.leaving
start = member.arriving
start = Date.today.at_beginning_of_month if member.arriving < Date.today.at_beginning_of_month
distance = ( member.leaving - member.arriving ).to_i
distance = ( member.leaving - start ).to_i
max = max_days - started_days(member)
distance > max ? max : distance
end

View File

@ -18,7 +18,7 @@
- @members.each_with_index do |member , index|
%tr{class: bg_for(index)}
- if( (days = started_days(member)) > 0)
%td.bg-white{colspan: started_days(member)}
%td.bg-white{colspan: days }
- if( (days = stay_days(member)) < 14)
%td{colspan: days}
= small_date(member.arriving)