change timeline to tables for responsiveness

This commit is contained in:
Torsten 2023-06-10 20:10:05 +03:00
parent 7c5df992ed
commit 0db45d5834
2 changed files with 31 additions and 21 deletions

View File

@ -30,7 +30,7 @@ module TimelineHelper
data = {}
week = 0
while( week < @weeks ) do
data[ week ] = 0
data[ week ] = -1
start_week = Date.today.at_beginning_of_month + week.weeks
end_week = Date.today.at_beginning_of_month + (week + 1).weeks
@members.each do |mem|

View File

@ -1,20 +1,30 @@
.flex.flex-col.mx-10
.flex
- (5..25).each do |week|
.mx-2.mb-2{class: week == @weeks ? "bg-orange-100" : "bg-white"}
.mx-10
%table.table-fixed.w-full
%tr
- ((@weeks - 5)..(@weeks + 5)).each do |week|
%td.mx-2.mb-2{colspan: 4 , class: week == @weeks ? "bg-orange-100" : "bg-white"}
=link_to week.to_s , timeline_path( weeks: week)
.flex
%tr
- (0...@weeks*7).each do |week|
%td{width: 100.0 / (@weeks * 7) }
%tr
- (0...@weeks).each do |week|
%div{class: bg_for(week) , style: "width: #{week_pixels}px;"}
= (Date.today.at_beginning_of_month + week.weeks).day.to_s + "."
= (Date.today.at_beginning_of_month + week.weeks).month
.flex
%td{colspan: 7 , class: bg_for(week + 2) }
= small_date(Date.today.at_beginning_of_month + week.weeks)
%tr
- weekly.each do |week , amount|
%div{class: bg_for(week) , style: "width: #{week_pixels}px;"}= amount
%td{colspan: 7, class: bg_for(week + 2) , style: "width: #{week_pixels}px;"}= amount
- @members.each_with_index do |member , index|
.flex
.bg-white{style: "width: #{day_pixels*started_days(member)}px;"}
.flex.pt-1.inline.justify-between{class: bg_for(index) ,style: "width: #{day_pixels*stay_days(member)}px;"}
%div= small_date(member.arriving) + " " + member.name
%div= small_date(member.leaving)
.name
%tr{class: bg_for(index)}
- if( (days = started_days(member)) > 0)
%td.bg-white{colspan: started_days(member)}
- if( (days = stay_days(member)) < 14)
%td{colspan: days}
= small_date(member.arriving)
= member.name
= small_date(member.leaving)
-else
%td.py-1{colspan: 4,}= small_date(member.arriving)
%td{colspan: days - 8}= member.name
%td{colspan: 4}= small_date(member.leaving)