From 1d8d10ce63d6edeaa7067b01686dad1ff68c72ba Mon Sep 17 00:00:00 2001 From: Jeffrey Hardy Date: Wed, 18 Sep 2024 16:00:29 -0400 Subject: [PATCH] Replace Bubble#color enum with a standard attribute with a default --- app/models/bubble.rb | 7 ++----- app/models/bubble/colored.rb | 9 +++++++++ app/views/bubbles/_bubble.html.erb | 5 ++++- app/views/bubbles/_color.html.erb | 4 ++-- app/views/bubbles/new.html.erb | 5 ++++- 5 files changed, 21 insertions(+), 9 deletions(-) create mode 100644 app/models/bubble/colored.rb diff --git a/app/models/bubble.rb b/app/models/bubble.rb index 64fd11e3a..27dd5bceb 100644 --- a/app/models/bubble.rb +++ b/app/models/bubble.rb @@ -1,4 +1,6 @@ class Bubble < ApplicationRecord + include Colored + belongs_to :project belongs_to :creator, class_name: "User", default: -> { Current.user } @@ -12,9 +14,4 @@ class Bubble < ApplicationRecord has_many :assignees, through: :assignments, source: :user has_one_attached :image, dependent: :purge_later - - enum :color, %w[ - #BF1B1B #ED3F1C #ED8008 #7C956B - #698F9C #3B4B59 #5D618F #3B3633 #67695E - ].index_by(&:itself), suffix: true, default: "#698F9C" end diff --git a/app/models/bubble/colored.rb b/app/models/bubble/colored.rb new file mode 100644 index 000000000..613a4e4a0 --- /dev/null +++ b/app/models/bubble/colored.rb @@ -0,0 +1,9 @@ +module Bubble::Colored + extend ActiveSupport::Concern + + COLORS = %w[ #BF1B1B #ED3F1C #ED8008 #7C956B #698F9C #3B4B59 #5D618F #3B3633 #67695E ] + + included do + attribute :color, default: "#698F9C" + end +end diff --git a/app/views/bubbles/_bubble.html.erb b/app/views/bubbles/_bubble.html.erb index b85ab8473..a1951aa43 100644 --- a/app/views/bubbles/_bubble.html.erb +++ b/app/views/bubbles/_bubble.html.erb @@ -1,4 +1,7 @@ -
+
+

<%= turbo_frame_tag bubble, :edit do %> <%= link_to bubble.title, edit_project_bubble_path(bubble.project, bubble), class: "txt-undecorated" %> diff --git a/app/views/bubbles/_color.html.erb b/app/views/bubbles/_color.html.erb index 73bcee6f3..b9034ccec 100644 --- a/app/views/bubbles/_color.html.erb +++ b/app/views/bubbles/_color.html.erb @@ -6,9 +6,9 @@ <%= form_with model: bubble, url: project_bubble_path(bubble.project, bubble), data: { controller: "form", action: "change->form#submit" } do |form| %> - <% Bubble.colors.keys.each do |color| %> + <% Bubble::COLORS.each do |color| %> -