require 'scrivito/page_config' module Scrivito class PageConfig def current_page_config # TODO: add permission info return {} unless obj config = { id: obj.id, path: obj.path, obj_class: obj.obj_class, description_for_editor: obj.description_for_editor, has_children: obj.children.any?, has_conflict: obj.has_conflict?, has_details_view: obj_has_details_view?, modification: modification(obj), parent_path: obj.parent_path, restriction_messages: editor.restriction_messages_for(obj), } if ::Fiona7.workflows_enabled? fiona_obj = obj.fiona_obj if fiona_obj.workflow.present? # without a workflow or with workflows disabled this will be falsy config[:workflow] = true # this just the returns the currently set editor config[:editor] = fiona_obj.editor # this is the most important bit: when to disable the editing # altough simple this implementation handles the following cases: # 1. someone outside the workflow visits the page # 2. a current editor within the workflow visits the page # 3. someone within the workflow visits the page config[:editing_disabled] = fiona_obj.editor != editor.id # this contains validActionKeys from cms # TODO: this should be implemented in reactor config[:buttons] = fiona_obj.send(:crul_obj).valid_actions end end config end end end