Merge pull request #1999 from basecamp/refactor-column-title-route

Make column have a proper ID instead of inferring it from the title
This commit is contained in:
Jorge Manrubia
2025-12-07 11:39:35 +01:00
committed by GitHub
3 changed files with 13 additions and 17 deletions
+5 -5
View File
@@ -30,15 +30,15 @@ class User::DayTimeline
end
def added_column
@added_column ||= build_column("Added", 1, events.where(action: %w[card_published card_reopened]))
@added_column ||= build_column(:added, "Added", 1, events.where(action: %w[card_published card_reopened]))
end
def updated_column
@updated_column ||= build_column("Updated", 2, events.where.not(action: %w[card_published card_closed card_reopened]))
@updated_column ||= build_column(:updated, "Updated", 2, events.where.not(action: %w[card_published card_closed card_reopened]))
end
def closed_column
@closed_column ||= build_column("Done", 3, events.where(action: "card_closed"))
@closed_column ||= build_column(:closed, "Done", 3, events.where(action: "card_closed"))
end
def cache_key
@@ -84,8 +84,8 @@ class User::DayTimeline
filtered_events.where(created_at: ...day.beginning_of_day).chronologically.last
end
def build_column(base_title, index, events)
Column.new(self, base_title, index, events)
def build_column(id, base_title, index, events)
Column.new(self, id, base_title, index, events)
end
def window
+7 -11
View File
@@ -1,9 +1,10 @@
class User::DayTimeline::Column
include ActionView::Helpers::TagHelper, ActionView::Helpers::OutputSafetyHelper, TimeHelper
attr_reader :index, :base_title, :day_timeline, :events
attr_reader :index, :id, :base_title, :day_timeline, :events
def initialize(day_timeline, base_title, index, events)
def initialize(day_timeline, id, base_title, index, events)
@id = id
@day_timeline = day_timeline
@base_title = base_title
@index = index
@@ -17,15 +18,6 @@ class User::DayTimeline::Column
safe_join(parts, " ")
end
def base_title_for_route
case base_title
when "Done"
"closed"
else
base_title.downcase
end
end
def events_by_hour
limited_events.group_by { it.created_at.hour }
end
@@ -38,6 +30,10 @@ class User::DayTimeline::Column
full_events_count - limited_events.count
end
def to_param
id
end
private
def limited_events
@limited_events ||= events.limit(100).load
@@ -3,7 +3,7 @@
<%= column.title %>
<% if column.events_by_hour.any? %>
<%= link_to events_day_timeline_column_path(id: column.base_title_for_route, day: column.day_timeline.day.to_date), class: "events__maximize-button btn btn--circle txt-x-small borderless", data: { turbo_frame: "_top" } do %>
<%= link_to events_day_timeline_column_path(column, day: column.day_timeline.day.to_date), class: "events__maximize-button btn btn--circle txt-x-small borderless", data: { turbo_frame: "_top" } do %>
<%= icon_tag "grid", class: "translucent" %>
<span class="for-screen-reader">Expand column</span>
<% end %>