Fix admin entity decoration
This commit is contained in:
53
slices/admin/decorators/books/decorator.rb
Normal file
53
slices/admin/decorators/books/decorator.rb
Normal file
@@ -0,0 +1,53 @@
|
||||
# frozen_string_literal: false
|
||||
|
||||
# auto_register: false
|
||||
|
||||
module Admin
|
||||
module Decorators
|
||||
module Books
|
||||
class Decorator < SimpleDelegator
|
||||
def display_published_at
|
||||
published_at.strftime("%e %B, %Y")
|
||||
end
|
||||
|
||||
def machine_published_at
|
||||
published_at.rfc2822
|
||||
end
|
||||
|
||||
def syndicated?
|
||||
!syndication_sources.empty?
|
||||
end
|
||||
|
||||
def template_type
|
||||
:book
|
||||
end
|
||||
|
||||
def authors
|
||||
book_author.split(";").join(" ")
|
||||
end
|
||||
|
||||
def status_colour
|
||||
case book_status
|
||||
when "read" || "finished"
|
||||
"text-green-100 bg-green-500"
|
||||
when "to-read"
|
||||
"text-blue-100 bg-blue-500"
|
||||
when "reading"
|
||||
"text-orange-100 bg-orange-500"
|
||||
end
|
||||
end
|
||||
|
||||
def status_label
|
||||
case book_status
|
||||
when "read" || "finished"
|
||||
"Read"
|
||||
when "to-read"
|
||||
"To read"
|
||||
when "reading"
|
||||
"Reading"
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
Reference in New Issue
Block a user