Fix admin entity decoration

This commit is contained in:
2024-03-29 13:48:24 +11:00
parent 1364d78f29
commit 59f42c235c
8 changed files with 370 additions and 6 deletions

View 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