fix the timeline stay issue (right side)

This commit is contained in:
Torsten 2023-06-10 12:03:32 +03:00
parent 9dcc422f75
commit 7c5df992ed
3 changed files with 9 additions and 7 deletions

View File

@ -2,6 +2,10 @@ class TimelineController < ApplicationController
def index
@weeks = (params[:weeks] || "12").to_i
@members = Member.visible_scope.where("leaving > ? " , Date.today).order(:arriving).page(1).per(50)
@members = Member.visible_scope.
where("leaving > ? " , Date.today).
where("arriving < ? " , Date.today.at_beginning_of_month + @weeks.weeks).
order(:arriving).
page(1).per(50)
end
end

View File

@ -23,7 +23,8 @@ module TimelineHelper
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 > max_days ? max_days : distance
max = max_days - started_days(member)
distance > max ? max : distance
end
def weekly
data = {}

View File

@ -4,20 +4,17 @@
.mx-2.mb-2{class: week == @weeks ? "bg-orange-100" : "bg-white"}
=link_to week.to_s , timeline_path( weeks: week)
.flex
.w-60 Weeks
- (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
.w-60 Weekly
- weekly.each do |week , amount|
%div{class: bg_for(week) , style: "width: #{week_pixels}px;"}= amount
- @members.each_with_index do |member , index|
.flex
.w-60= member.name
.bg-white{style: "width: #{day_pixels*started_days(member)}px;"}
.flex.inline.justify-between{class: bg_for(index) ,style: "width: #{day_pixels*stay_days(member)}px;"}
%div= small_date(member.arriving)
.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