Sha256: f95131155e0de23322da92a0908c78a322388750d5309090b0a303c391e112ee
Contents?: true
Size: 1.5 KB
Versions: 2
Compression:
Stored size: 1.5 KB
Contents
module Scrivito class ClientConfig < Struct.new(:obj, :editing_context, :lookup_context) def to_json config = {} config[:editing_context] = editing_context_config config[:i18n] = i18n_config config[:obj] = obj_config config[:open_resource_dialog] = @resource_dialog_config config.to_json end def open_resource_dialog(obj_id, redirect_to) @resource_dialog_config = { obj_id: obj_id, redirect_to: redirect_to, } end private def editing_context_config { display_mode: editing_context.display_mode, selected_workspace: { id: editing_context.selected_workspace.id, title: editing_context.selected_workspace.title }, visible_workspace: { id: editing_context.visible_workspace.id, title: editing_context.visible_workspace.title } } end def i18n_config {locale: I18n.locale} end def obj_config if obj {current_page: { id: obj.id, obj_class_name: obj.obj_class_name, has_children: obj.children.any?, has_conflict: obj.has_conflict?, has_details_view: obj_has_details_view?, modification: obj_modification, }} end end def obj_has_details_view? lookup_context.find(obj.details_view_path).present? rescue ActionView::MissingTemplate false end def obj_modification if editing_context.comparison.active? editing_context.comparison.modification(obj) else obj.modification end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
scrivito_sdk-0.16.0 | lib/scrivito/client_config.rb |
scrivito_sdk-0.15.0 | lib/scrivito/client_config.rb |