Simplify conditions to pick up a color
This commit is contained in:
+1
-9
@@ -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?
|
||||
|
||||
@@ -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
|
||||
Reference in New Issue
Block a user