Class: RailsAdmin::Config::Fields::Group

Inherits:
Object
  • Object
show all
Defined in:
lib/hancock/rails_admin_ext/patches/group_patch.rb,
lib/hancock/rails_admin_ext/patches/fieldset_patch.rb

Instance Method Summary collapse

Instance Method Details

#group(name, &block) ⇒ Object



19
20
21
22
23
24
25
# File 'lib/hancock/rails_admin_ext/patches/group_patch.rb', line 19

def group(name, &block)
  _groups = parent.groups rescue root.groups
  group = _groups.detect { |g| name == g.name }
  group ||= (parent.groups << RailsAdmin::Config::Fields::Group.new(self, name)).last
  group.tap { |g| g.section = self }.instance_eval(&block) if block
  group
end

#visible_fieldsObject



11
12
13
14
15
16
17
# File 'lib/hancock/rails_admin_ext/patches/group_patch.rb', line 11

def visible_fields
  section.with(bindings).visible_fields.select { |f|
    f.group == self
  }.sort do |a, b|
    a.weight <=> b.weight
  end
end