diff --git a/app/controllers/plans_controller.rb b/app/controllers/plans_controller.rb index a30c05a5..31c8875d 100644 --- a/app/controllers/plans_controller.rb +++ b/app/controllers/plans_controller.rb @@ -162,9 +162,9 @@ def set_attributes_for_turbo_stream @row, @track_list = catch(:abort) do @schedule_table.days.each do |day| - @table = @schedule_table[day] - @table.rows.each do |row| - throw :abort, [row, @table.track_list] if row.schedules.map(&:id).include?(target_schedule_id) + table = @schedule_table[day] + table.rows.each do |row| + throw :abort, [row, table.track_list] if row.schedules.map(&:id).include?(target_schedule_id) end end end diff --git a/app/models/schedule/table.rb b/app/models/schedule/table.rb index 2acaccff..8275b352 100644 --- a/app/models/schedule/table.rb +++ b/app/models/schedule/table.rb @@ -2,10 +2,9 @@ class Schedule class Table - attr_reader :track_list, :rows, :day + attr_reader :track_list, :rows - def initialize(schedules, day = nil) - @day = day + def initialize(schedules) @track_list = schedules.map(&:track).uniq.sort_by(&:position).map(&:name) grouped_schedules = schedules.group_by do |s| diff --git a/app/models/schedule/tables.rb b/app/models/schedule/tables.rb index bb1933a2..a4112c01 100644 --- a/app/models/schedule/tables.rb +++ b/app/models/schedule/tables.rb @@ -6,8 +6,8 @@ class Tables def initialize(schedules) @schedules = schedules - @map = @schedules.group_by { _1.start_at.strftime(DATE_FORMAT) }.to_h do |k, v| - [k, Schedule::Table.new(v, k)] + @map = @schedules.group_by { _1.start_at.strftime(DATE_FORMAT) }.transform_values do |v| + Schedule::Table.new(v) end end diff --git a/app/views/plans/update.turbo_stream.erb b/app/views/plans/update.turbo_stream.erb index de2dac87..6d71a3d1 100644 --- a/app/views/plans/update.turbo_stream.erb +++ b/app/views/plans/update.turbo_stream.erb @@ -1,8 +1,3 @@ <%= turbo_stream.replace @row.turbo_stream_id do %> <%= render partial: 'schedules/table_row', locals: { row: @row, plan: @plan, track_list: @track_list} %> <% end %> -<%= turbo_stream.update "mobile-table-#{@table.day}" do %> - <% @table.rows.each do |row| %> - <%= render partial: 'schedules/mobile_table_row', locals: { row: row, plan: @plan, track_list: @table.track_list } %> - <% end %> -<% end %> diff --git a/app/views/schedules/_card.html.erb b/app/views/schedules/_card.html.erb index 442de64e..8c8f9057 100644 --- a/app/views/schedules/_card.html.erb +++ b/app/views/schedules/_card.html.erb @@ -1,6 +1,6 @@ <%= turbo_frame_tag schedule do %>