Skip to content

Commit

Permalink
Replace old plane schedule table
Browse files Browse the repository at this point in the history
  • Loading branch information
kinoppyd committed Apr 3, 2024
1 parent c769dc5 commit 16d462d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 14 deletions.
3 changes: 1 addition & 2 deletions app/controllers/schedules_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ class SchedulesController < ApplicationController

def index
@schedules = Schedule.on_event(@event).includes(:speakers).order(:start_at)
@table_array = create_table_array(@schedules)
@schedule_table = schedule_table(@table_array)
@schedule_table = Schedule::Tables.new(@schedules)
end

def dialog
Expand Down
24 changes: 12 additions & 12 deletions app/views/schedules/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -13,39 +13,39 @@
<div data-controller="schedule-table" class="max-w-[1120px] mx-auto">
<div class="flex overflow-x-auto overflow-y-hidden gap-2 p-0">
<div class="relative flex-grow shrink-0 basis-auto m-1 before:absolute before:left-0 before:right-0 before:bottom-0 before:border-b-[1px]">
<% @table_array.keys.map do |k| %>
<button data-action="click->schedule-table#switch" value="<%= k %>" class="tab-button bg-transparent appearance-none font-bold font-base text-[rgb(112,109,101)] h-10 solid border-0 border-b-[3px] px-6 box-border border-b-transparent hover:bg-[rgb(248,247,246)] hover:text-[rgb(35,34,30)]">
<%= k %>
<% @schedule_table.days.each do |day| %>
<button data-action="click->schedule-table#switch" value="<%= day %>" class="tab-button bg-transparent appearance-none font-bold font-base text-[rgb(112,109,101)] h-10 solid border-0 border-b-[3px] px-6 box-border border-b-transparent hover:bg-[rgb(248,247,246)] hover:text-[rgb(35,34,30)]">
<%= day %>
</button>
<% end %>
</div>
</div>
<div class="mt-4 overflow-y-auto">
<% @schedule_table.each do |k, v| %>
<div id="schedule-<%= k %>" class="schedule-table hidden">
<% @schedule_table.days.each do |day| %>
<div id="schedule-<%= day %>" class="schedule-table hidden">
<table class="h-full w-full border-collapse border-spacing-0">
<thead>
<th class="p-4 text-sm leading-4 border border-solid border-[rgb(214,211,208)] w-auto min-w-[184px] text-left"><%= I18n.t('table.start_end') %></th>
<% v[:track_list].each do |track| %>
<% @schedule_table[day].track_list.each do |track| %>
<th class="p-4 text-sm leading-4 border border-solid border-[rgb(214,211,208)] w-auto text-center"><%= track %></th>
<% end %>
</thead>
<tbody>
<% v[:rows].each do |row| %>
<% @selected = @plan.plan_schedules.map(&:schedule).any? { row[:schedules].include?(_1) } %>
<% @schedule_table[day].rows.each do |row| %>
<% @selected = @plan.plan_schedules.map(&:schedule).any? { row.schedules.include?(_1) } %>
<tr class="align-baseline">
<th class="py-2 px-0 align-baseline">
<div class="flex flex-col gap-1">
<div class="flex items-center">
<p class="text-xl font-normal mr-4 shrink-0"><%= row[:time][:range] %></p>
<p class="text-xl font-normal mr-4 shrink-0"><%= row.start_end %></p>
<hr class="w-full h-[1px] mr-4 bg-[rgb(214,211,208)] border-none">
</div>
<p class="text-sm font-bold text-[rgb(112,109,101)] text-left"><%= row[:time][:zone] %></p>
<p class="text-sm font-bold text-[rgb(112,109,101)] text-left"><%= row.timezone %></p>
</div>
</th>
<% row[:schedules].each do |schedule| %>
<% @schedule_table[day].track_list.each do |track| %>
<td>
<div class="p-2"><%= schedule ? render("schedules/card", schedule:, mode: :schedule, inactive: @selected) : nil %></div>
<div class="p-2"><%= row.tracks[track] ? render("schedules/card", schedule: row.tracks[track], mode: :schedule, inactive: @selected) : nil %></div>
</td>
<% end %>
</tr>
Expand Down

0 comments on commit 16d462d

Please sign in to comment.