mirror of
https://github.com/discourse/discourse.git
synced 2024-12-05 12:03:39 +08:00
47 lines
926 B
Ruby
47 lines
926 B
Ruby
|
# frozen_string_literal: true
|
||
|
|
||
|
module DiscourseAutomation
|
||
|
class TemplateSerializer < ApplicationSerializer
|
||
|
attributes :name,
|
||
|
:component,
|
||
|
:extra,
|
||
|
:accepts_placeholders,
|
||
|
:accepted_contexts,
|
||
|
:read_only,
|
||
|
:default_value,
|
||
|
:is_required
|
||
|
|
||
|
def default_value
|
||
|
scope[:automation].scriptable&.forced_triggerable&.dig(:state, name) || object[:default_value]
|
||
|
end
|
||
|
|
||
|
def read_only
|
||
|
scope[:automation].scriptable&.forced_triggerable&.dig(:state, name).present?
|
||
|
end
|
||
|
|
||
|
def name
|
||
|
object[:name]
|
||
|
end
|
||
|
|
||
|
def component
|
||
|
object[:component]
|
||
|
end
|
||
|
|
||
|
def extra
|
||
|
object[:extra]
|
||
|
end
|
||
|
|
||
|
def accepts_placeholders
|
||
|
object[:accepts_placeholders]
|
||
|
end
|
||
|
|
||
|
def accepted_contexts
|
||
|
object[:accepted_contexts]
|
||
|
end
|
||
|
|
||
|
def is_required
|
||
|
object[:required]
|
||
|
end
|
||
|
end
|
||
|
end
|