docbrown/app/lib/menu.rb
ludwiczakpawel b321d1ec11
Removing bootstrap: admin sidebar navigation (#16618)
* 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>
2022-03-01 15:46:45 +01:00

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