fix start of timeline

This commit is contained in:
Torsten 2023-07-11 09:07:27 +03:00
parent 3cb5e2965d
commit 2a7582211e
2 changed files with 5 additions and 2 deletions

View File

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

View File

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