Class: Headmin::Form::BlocksView

Inherits:
ViewModel show all
Defined in:
app/models/headmin/form/blocks_view.rb

Instance Method Summary collapse

Methods inherited from ViewModel

#attributes, #initialize, #to_hash

Constructor Details

This class inherits a constructor from ViewModel

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class ViewModel

Instance Method Details

#badge_style(object) ⇒ Object



18
19
20
21
22
23
24
25
26
27
28
29
# File 'app/models/headmin/form/blocks_view.rb', line 18

def badge_style(object)
  visible = object.visible?
  errors = object.errors.present?

  if !visible && !errors
    "bg-light text-secondary"
  elsif errors
    "bg-danger text-white"
  else
    "bg-light text-dark"
  end
end

#pathsObject



10
11
12
# File 'app/models/headmin/form/blocks_view.rb', line 10

def paths
  @paths || []
end

#prefixesObject



14
15
16
# File 'app/models/headmin/form/blocks_view.rb', line 14

def prefixes
  paths + ["admin/blocks", "blocks", ""]
end

#repeater_optionsObject



4
5
6
7
8
# File 'app/models/headmin/form/blocks_view.rb', line 4

def repeater_options
  keys = %i[form attribute names label]
  options = to_h.slice(*keys)
  default_repeater_options.deep_merge(options)
end