Sha256: 09be1e22c7a47c55b984a9dc8648731b3560aff45349d2921eb2f8b1c9249c77
Contents?: true
Size: 1.47 KB
Versions: 16
Compression:
Stored size: 1.47 KB
Contents
module Scrivito class UiConfig < Struct.new(:editing_context, :resource, :return_to, :app_extension_tags, :obj_models, :widget_models, :lookup_context) def initialize(**named_params) named_params.each { |key, value| self[key] = value } 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
16 entries across 16 versions & 1 rubygems