mirror of
https://github.com/discourse/discourse.git
synced 2024-12-30 21:43:43 +08:00
3d4faf3272
Automation (previously known as discourse-automation) is now a core plugin.
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
|