Sha256: f4e532f3c4e33a604cf733b809afc43a7e7067e6ab5f9c71486e7d48de94787a

Contents?: true

Size: 1.56 KB

Versions: 1

Compression:

Stored size: 1.56 KB

Contents

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.reject(&:binary?).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

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
infopark_fiona7-1.6.1.1.5 lib/fiona7/scrivito_patches/page_config.rb