Class: Alchemy::ElementEditor

Inherits:
SimpleDelegator
  • Object
show all
Defined in:
app/decorators/alchemy/element_editor.rb

Instance Method Summary collapse

Instance Method Details

#css_classesObject

CSS classes for the element editor partial.


12
13
14
15
16
17
18
19
20
21
22
# File 'app/decorators/alchemy/element_editor.rb', line 12

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

#editable?Boolean

Tells us, if we should show the element footer and form inputs.

Returns:

  • (Boolean)

25
26
27
28
29
# File 'app/decorators/alchemy/element_editor.rb', line 25

def editable?
  return false if folded?

  content_definitions.present? || taggable?
end

#respond_to?(method_name) ⇒ Boolean

Fixes Rails partial renderer calling to_model on the object which reveals the delegated element instead of this decorator.

Returns:

  • (Boolean)

33
34
35
36
37
# File 'app/decorators/alchemy/element_editor.rb', line 33

def respond_to?(method_name)
  return false if method_name == :to_model

  super
end

#to_partial_pathObject


7
8
9
# File 'app/decorators/alchemy/element_editor.rb', line 7

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