* nav * nav * move cheese around * helpers * optimize * optimize * optimization * optimization * children helper * children helper * Update app/views/admin/shared/_nested_sidebar.html.erb Co-authored-by: Suzanne Aitchison <suzanne@forem.com> Co-authored-by: Suzanne Aitchison <suzanne@forem.com>
23 lines
539 B
Ruby
23 lines
539 B
Ruby
class Menu
|
|
# Used to build the data structure for the Admin Menu model.
|
|
|
|
def self.define(&block)
|
|
builder = new
|
|
builder.instance_exec(&block)
|
|
builder.items
|
|
end
|
|
|
|
attr_reader :items
|
|
|
|
def initialize
|
|
@items = {}
|
|
end
|
|
|
|
def scope(name, svg, children)
|
|
@items[name] = { svg: "#{svg}.svg", children: children }
|
|
end
|
|
|
|
def item(name:, controller: name, children: [], visible: true, parent: nil)
|
|
{ name: name, controller: controller.tr(" ", "_"), children: children, visible: visible, parent: parent }
|
|
end
|
|
end
|