Module: EntityHelper

Defined in:
app/helpers/entity_helper.rb

Overview

Helpers for displaying common entity-related blocks

Instance Method Summary collapse

Instance Method Details

#entity_form_block(f, *types) ⇒ Object



67
68
69
70
71
72
73
74
75
76
# File 'app/helpers/entity_helper.rb', line 67

def entity_form_block(f, *types)
  permitted = i[priority entity_flags simple_image]

  buffer = ''
  types.select { |i| permitted.include?(i.to_sym)}.each do |type|
    buffer += render partial: "shared/forms/#{type}", locals: { f: f }
  end

  raw buffer
end

#entity_list(collection, scope: nil, handler: component_handler, with_priority: false) ⇒ Object

Parameters:

  • collection (Enumerable)
  • scope (Symbol|String|nil) (defaults to: nil)
  • handler (Biovision::Components::BaseComponent|nil) (defaults to: component_handler)
  • with_priority (TrueClass|FalseClass) (defaults to: false)


9
10
11
12
13
14
15
16
17
# File 'app/helpers/entity_helper.rb', line 9

def entity_list(collection, scope: nil, handler: component_handler, with_priority: false)
  scope = controller.class.module_parent_name.to_s.downcase if scope.nil?
  suffix = with_priority ? '_with_priority' : ''

  render(
    partial: "shared/entity/list#{suffix}",
    locals: { collection: collection, handler: handler, scope: scope.to_sym }
  )
end

#entity_partial_block(entity, *types) ⇒ Object

Parameters:

  • entity (ApplicationRecord)
  • types (String|Symbol)


54
55
56
57
58
59
60
61
62
63
64
65
# File 'app/helpers/entity_helper.rb', line 54

def entity_partial_block(entity, *types)
  permitted = i[
    priority uuid slug timestamps language simple_image meta_texts track
  ]

  buffer = ''
  types.select { |i| permitted.include?(i.to_sym)}.each do |type|
    buffer += render(partial: "shared/entity/#{type}", locals: { entity: entity })
  end

  raw buffer
end

#entity_priority_icons(entity, scope: nil) ⇒ Object

Parameters:

  • entity (ApplicationRecord)
  • scope (Symbol|String|nil) (defaults to: nil)


32
33
34
35
36
37
38
39
# File 'app/helpers/entity_helper.rb', line 32

def entity_priority_icons(entity, scope: nil)
  scope = controller.class.module_parent_name.to_s.downcase if scope.nil?

  render(
    partial: 'shared/entity/priority_icons',
    locals: { entity: entity, scope: scope.to_sym }
  )
end

#entity_toggle(entity, scope: nil) ⇒ Object

Parameters:

  • entity (ApplicationRecord)
  • scope (Symbol|String|nil) (defaults to: nil)


21
22
23
24
25
26
27
28
# File 'app/helpers/entity_helper.rb', line 21

def entity_toggle(entity, scope: nil)
  scope = controller.class.module_parent_name.to_s.downcase if scope.nil?

  render(
    partial: 'shared/entity/toggle',
    locals: { entity: entity, scope: scope.to_sym }
  )
end

#linked_entity_block(entity, text: nil) ⇒ Object

Parameters:

  • entity (ApplicationRecord)
  • text (String) (defaults to: nil)


43
44
45
46
47
48
49
50
# File 'app/helpers/entity_helper.rb', line 43

def linked_entity_block(entity, text: nil)
  return '' if entity.blank?

  render(
    partial: 'shared/entity/linked_entity',
    locals: { entity: entity, text: text }
  )
end