lib/scrivito/ui_config.rb in scrivito_sdk-1.8.1 vs lib/scrivito/ui_config.rb in scrivito_sdk-1.9.0.rc1

- old
+ new

@@ -7,63 +7,37 @@ end def to_json { app_extension_tags: app_extension_tags, - editing_context: editing_context_config, backend_endpoint: Configuration.endpoint, tenant: Configuration.tenant, i18n: i18n_config, is_development_mode: Rails.env.development?, resource_dialog: resource_dialog_config, - revision: revision_config, user: user_config, user_permissions: user_permissions_config, - obj_class: obj_class_config, - widget_class: widget_class_config, + class_datas: obj_class_config + widget_class_config, + useRailsEngine: true, }.to_json end private - def editing_context_config - { - display_mode: editing_context.display_mode, - selected_workspace: workspace_config(selected_workspace), - visible_workspace: workspace_config(visible_workspace), - } - end - - def workspace_config(workspace) - { - id: workspace.id, - memberships: workspace.memberships.map do |membership| - { - user_id: membership.user_id, - role: membership.role, - description: membership.user.description - } - end, - outdated: workspace.outdated?, - auto_update: workspace.auto_update?, - title: workspace.title, - } - end - def i18n_config {locale: Scrivito::Configuration.ui_locale || I18n.locale} end def obj_class_config obj_models.map do |obj_class| - obj_class.as_json.merge(hasDetailsView: details_view?(obj_class.name)) + obj_class_formatter.format(obj_class) end end def widget_class_config widget_models.map do |widget_class| - widget_class.as_json.merge(hasDetailsView: details_view?(widget_class.name)) + obj_class_formatter.format(widget_class) end end def resource_dialog_config return {} unless resource @@ -88,29 +62,19 @@ { current: editor.as_json, } end - def revision_config - {published_revision_id: Workspace.published.revision_id} - end - def editor editing_context.editor end def selected_workspace editing_context.selected_workspace end - def visible_workspace - editing_context.visible_workspace - end - - def details_view?(obj_class_name) - lookup_context.find("#{obj_class_name.underscore}/details").present? - rescue ActionView::MissingTemplate - false + def obj_class_formatter + @obj_class_formatter ||= UiObjClassesJsonFormatter.new(lookup_context) end end end