Simplify conditions to pick up a color

This commit is contained in:
Jorge Manrubia
2025-04-10 12:40:14 +02:00
parent ced24d8a7c
commit c6b2e5461b
2 changed files with 13 additions and 9 deletions
+1 -9
View File
@@ -1,5 +1,5 @@
class Card < ApplicationRecord
include Assignable, Boostable, Commentable, Engageable, Eventable,
include Assignable, Boostable, Colored, Commentable, Engageable, Eventable,
Messages, Notifiable, Pinnable, Closeable, Scorable, Searchable, Staged, Statuses, Taggable, Watchable
belongs_to :collection, touch: true
@@ -33,14 +33,6 @@ class Card < ApplicationRecord
[ super, collection&.name ].compact.join("/")
end
def color
return Colorable::DEFAULT_COLOR unless collection&.workflow.present?
return Colorable::DEFAULT_COLOR unless doing?
return Colorable::DEFAULT_COLOR unless stage.present?
stage.color.presence || Colorable::DEFAULT_COLOR
end
private
def track_due_date_change
if due_on.present?
+12
View File
@@ -0,0 +1,12 @@
module Card::Colored
extend ActiveSupport::Concern
def color
color_from_stage || Colorable::DEFAULT_COLOR
end
private
def color_from_stage
stage&.color&.presence if doing?
end
end