Sha256: 13e19fce8f2fdaa2d2f26eb5c7b14f93ac3fb664c044ee845571e566e1306767

Contents?: true

Size: 1.03 KB

Versions: 18

Compression:

Stored size: 1.03 KB

Contents

# frozen_string_literal: true

module Alchemy
  class ElementEditor < SimpleDelegator
    alias_method :element, :__getobj__

    def to_partial_path
      "alchemy/admin/elements/element"
    end

    # CSS classes for the element editor partial.
    def css_classes
      [
        "element-editor",
        content_definitions.present? ? "with-contents" : "without-contents",
        nestable_elements.any? ? "nestable" : "not-nestable",
        taggable? ? "taggable" : "not-taggable",
        folded ? "folded" : "expanded",
        compact? ? "compact" : nil,
        fixed? ? "is-fixed" : "not-fixed",
      ].join(" ")
    end

    # Tells us, if we should show the element footer and form inputs.
    def editable?
      return false if folded?

      content_definitions.present? || taggable?
    end

    # Fixes Rails partial renderer calling to_model on the object
    # which reveals the delegated element instead of this decorator.
    def respond_to?(method_name)
      return false if method_name == :to_model

      super
    end
  end
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
alchemy_cms-5.0.10 app/decorators/alchemy/element_editor.rb
alchemy_cms-5.0.9 app/decorators/alchemy/element_editor.rb
alchemy_cms-5.0.8 app/decorators/alchemy/element_editor.rb
alchemy_cms-5.0.7 app/decorators/alchemy/element_editor.rb
alchemy_cms-5.0.6 app/decorators/alchemy/element_editor.rb
alchemy_cms-5.0.5 app/decorators/alchemy/element_editor.rb
alchemy_cms-5.0.4 app/decorators/alchemy/element_editor.rb
alchemy_cms-5.0.3 app/decorators/alchemy/element_editor.rb
alchemy_cms-5.0.2 app/decorators/alchemy/element_editor.rb
alchemy_cms-5.1.0.rc1 app/decorators/alchemy/element_editor.rb
alchemy_cms-5.1.0.beta2 app/decorators/alchemy/element_editor.rb
alchemy_cms-5.1.0.beta1 app/decorators/alchemy/element_editor.rb
alchemy_cms-5.0.1 app/decorators/alchemy/element_editor.rb
alchemy_cms-5.0.0 app/decorators/alchemy/element_editor.rb
alchemy_cms-5.0.0.rc2 app/decorators/alchemy/element_editor.rb
alchemy_cms-5.0.0.rc1 app/decorators/alchemy/element_editor.rb
alchemy_cms-5.0.0.beta2 app/decorators/alchemy/element_editor.rb
alchemy_cms-5.0.0.beta1 app/decorators/alchemy/element_editor.rb