Track changes to the bubble's name

This commit is contained in:
Jason Zimdars
2025-02-04 16:14:29 -06:00
parent 246b44d1f5
commit affa4cae7a
3 changed files with 15 additions and 1 deletions
+3 -1
View File
@@ -71,6 +71,8 @@ module EventsHelper
"#{event.creator.name} changed the date to #{event.particulars.dig('particulars', 'due_date').to_date.strftime('%B %-d')}"
when "due_date_removed"
"#{event.creator.name} removed the date"
when "title_changed"
"#{event.creator.name} renamed this (was: '#{event.particulars.dig('particulars', 'old_title')})'"
end
end
@@ -87,7 +89,7 @@ module EventsHelper
when "due_date_added", "due_date_changed"
"calendar"
else
"check"
"person"
end
end
end
+10
View File
@@ -11,6 +11,7 @@ class Bubble < ApplicationRecord
before_save :set_default_title
after_save :track_due_date_change, if: :saved_change_to_due_on?
after_save :track_title_change, if: :saved_change_to_title?
scope :reverse_chronologically, -> { order created_at: :desc, id: :desc }
scope :chronologically, -> { order created_at: :asc, id: :asc }
@@ -45,6 +46,15 @@ class Bubble < ApplicationRecord
end
end
def track_title_change
if title_before_last_save.present?
track_event("title_changed", particulars: {
old_title: title_before_last_save,
new_title: title
})
end
end
def set_default_title
self.title = title.presence || "Untitled"
end
+2
View File
@@ -35,6 +35,8 @@ class EventSummary < ApplicationRecord
"#{event.creator.name} changed due date to #{event.particulars.dig('particulars', 'due_date').to_date.strftime('%B %-d')}."
when "due_date_removed"
"#{event.creator.name} removed the date."
when "title_changed"
"#{event.creator.name} changed title from '#{event.particulars.dig('particulars', 'old_title')}' to '#{event.particulars.dig('particulars', 'new_title')}'."
end
end