Sha256: 90d3feeb3751d150bbe9c54de2fc4b0ae4de29c0819f3010791eb209b00e6ee0
Contents?: true
Size: 1.57 KB
Versions: 8
Compression:
Stored size: 1.57 KB
Contents
module Scrivito class UiConfig < Struct.new(:editing_context, :resource, :return_to, :app_extension_tags, :obj_models, :widget_models, :lookup_context) def initialize(options) super(*options.values_at(:editing_context, :resource, :return_to, :app_extension_tags, :obj_models, :widget_models, :lookup_context)) end def to_json { app_extension_tags: app_extension_tags, backend_endpoint: Configuration.endpoint, tenant: Configuration.tenant, i18n: i18n_config, is_development_mode: Rails.env.development?, resource_dialog: resource_dialog_config, class_datas: obj_class_config + widget_class_config, useRailsEngine: true, }.to_json end private def i18n_config locale = editor.try!(:ui_locale) || Scrivito::Configuration.ui_locale {locale: locale} end def obj_class_config obj_models.map do |obj_class| obj_class_formatter.format(obj_class) end end def widget_class_config widget_models.map do |widget_class| obj_class_formatter.format(widget_class) end end def resource_dialog_config return {} unless resource { obj: Configuration.obj_formats.fetch('_default').call(resource, editor), return_to: return_to, } end def editor editing_context.editor end def selected_workspace editing_context.selected_workspace end def obj_class_formatter @obj_class_formatter ||= UiObjClassesJsonFormatter.new(lookup_context) end end end
Version data entries
8 entries across 8 versions & 1 rubygems