2024-04-29 00:17:15 +02:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2023-03-22 09:28:08 +01:00
|
|
|
require "administrate/field/base"
|
|
|
|
|
|
|
|
class IdField < Administrate::Field::Number
|
|
|
|
def to_s
|
|
|
|
return "" if data.nil?
|
|
|
|
return data.ids.map { format(_1) }.join(", ") if data.respond_to?(:ids)
|
|
|
|
|
|
|
|
format(data.id)
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def format(id)
|
|
|
|
"##{id}"
|
|
|
|
end
|
|
|
|
end
|