colorgrade and more weeks
This commit is contained in:
parent
6c2e11f8a6
commit
9dcc422f75
@ -1,6 +1,7 @@
|
||||
class TimelineController < ApplicationController
|
||||
|
||||
def index
|
||||
@members = Member.visible_scope.where("leaving > ? " , Date.today).order(:arriving).page(1)
|
||||
@weeks = (params[:weeks] || "12").to_i
|
||||
@members = Member.visible_scope.where("leaving > ? " , Date.today).order(:arriving).page(1).per(50)
|
||||
end
|
||||
end
|
||||
|
@ -1,19 +1,19 @@
|
||||
module TimelineHelper
|
||||
|
||||
def month_pixels
|
||||
300
|
||||
def week_pixels
|
||||
70
|
||||
end
|
||||
def day_pixels
|
||||
month_pixels / 30
|
||||
week_pixels / 7
|
||||
end
|
||||
def max_pixels
|
||||
(month_pixels * 3 ) / day_pixels
|
||||
def max_days
|
||||
@weeks * 7
|
||||
end
|
||||
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_pixels ? max_pixels : distance
|
||||
distance > max_days ? max_days : distance
|
||||
end
|
||||
def left_max
|
||||
Date.today.at_beginning_of_month + 3.months
|
||||
@ -23,12 +23,12 @@ 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_pixels ? max_pixels : distance
|
||||
distance > max_days ? max_days : distance
|
||||
end
|
||||
def weekly
|
||||
data = {}
|
||||
week = 0
|
||||
while( week < 13 ) do
|
||||
while( week < @weeks ) do
|
||||
data[ week ] = 0
|
||||
start_week = Date.today.at_beginning_of_month + week.weeks
|
||||
end_week = Date.today.at_beginning_of_month + (week + 1).weeks
|
||||
@ -41,22 +41,22 @@ module TimelineHelper
|
||||
end
|
||||
week += 1
|
||||
end
|
||||
puts data
|
||||
data
|
||||
end
|
||||
def bg_for(week)
|
||||
case week % 5
|
||||
when 0
|
||||
"bg-cyan-50"
|
||||
when 1
|
||||
"bg-cyan-100"
|
||||
when 2
|
||||
"bg-cyan-200"
|
||||
when 3
|
||||
"bg-cyan-300"
|
||||
when 4
|
||||
"bg-cyan-400"
|
||||
end
|
||||
[ "bg-cyan-100",
|
||||
"bg-blue-100",
|
||||
"bg-violet-100",
|
||||
"bg-fuchsia-100",
|
||||
"bg-pink-100",
|
||||
"bg-rose-100",
|
||||
"bg-orange-100",
|
||||
"bg-amber-100",
|
||||
"bg-yellow-100",
|
||||
"bg-lime-100",
|
||||
"bg-green-100",
|
||||
"bg-teal-100",
|
||||
][week%12]
|
||||
end
|
||||
def small_date(date)
|
||||
date.strftime("%-d.%-m")
|
||||
|
@ -1,20 +1,23 @@
|
||||
= paginate @members
|
||||
.flex.flex-col.mx-10
|
||||
.flex
|
||||
.w-60 Weekly
|
||||
- (0..12).each do |week|
|
||||
%div{class: bg_for(week) , style: "width: #{7*day_pixels}px;"}
|
||||
- (5..25).each do |week|
|
||||
.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: #{7*day_pixels}px;"}= 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.bg-yellow-100{style: "width: #{day_pixels*stay_days(member)}px;"}
|
||||
.flex.inline.justify-between{class: bg_for(index) ,style: "width: #{day_pixels*stay_days(member)}px;"}
|
||||
%div= small_date(member.arriving)
|
||||
%div= small_date(member.leaving)
|
||||
.name
|
||||
|
Loading…
Reference in New Issue
Block a user