Sha256: ff6f1b68fe4c9e2d39c60b6cb80a72e873031776f514dc0166e1fd7789e44efa

Contents?: true

Size: 1.55 KB

Versions: 12

Compression:

Stored size: 1.55 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.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

12 entries across 12 versions & 1 rubygems

Version Path
infopark_fiona7-1.6.1.1.1 lib/fiona7/scrivito_patches/page_config.rb
infopark_fiona7-1.6.1.1.0 lib/fiona7/scrivito_patches/page_config.rb
infopark_fiona7-1.5.5.5.1 lib/fiona7/scrivito_patches/page_config.rb
infopark_fiona7-1.5.5.5.0 lib/fiona7/scrivito_patches/page_config.rb
infopark_fiona7-1.5.5.4.1 lib/fiona7/scrivito_patches/page_config.rb
infopark_fiona7-1.5.5.4.0 lib/fiona7/scrivito_patches/page_config.rb
infopark_fiona7-1.5.5.3.1 lib/fiona7/scrivito_patches/page_config.rb
infopark_fiona7-1.5.4.3.0 lib/fiona7/scrivito_patches/page_config.rb
infopark_fiona7-1.5.3.2.0 lib/fiona7/scrivito_patches/page_config.rb
infopark_fiona7-1.5.3.2.0.pre.beta1 lib/fiona7/scrivito_patches/page_config.rb
infopark_fiona7-1.5.2.1.0.pre.beta1 lib/fiona7/scrivito_patches/page_config.rb
infopark_fiona7-1.5.2.0.0 lib/fiona7/scrivito_patches/page_config.rb