class AdminUI::MenuItem
Menu item (hash of title, description and full route (path and query string)
Attributes
Public Class Methods
Source
# File app/lib/ui/context.rb, line 184 def initialize(parent, route, title, item, classes: '') @parent = parent @title = title @route = route @confmsg = item.fetch(:confmsg, title) @classes = classes @description = item.fetch(:description, '') @tbd = item.fetch(:tbd, false) @external = item.fetch(:external, false) @method = item.fetch(:method, 'get') @breadcrumb = item.fetch(:breadcrumb, false) @parent.top.route_names[route_normalized] = { title: title, description: description, route: @route, method: @method } end
Public Instance Methods
Source
# File app/lib/ui/context.rb, line 210 def render return '' if @breadcrumb carr = @classes.split carr << 'tbd' if @tbd lclass = carr.join(' ') if @method == 'get' icon = @external ? ' 🔗' : '' target = @external ? '_blank' : '_self' %( <li role="none"> <a role="menuitem" class="#{lclass}" href="#{route}" title="#{title}" target="#{target}" > <span>#{title}#{icon}</span> </a> </li> ) else icon = ' ⚙️' %( <li role="none"> <a role="none" class="post-link" data-route="#{route}" confmsg="#{confmsg}" title="#{title}" > <span>#{title}#{icon}</span> </a> </li> ) end end
Source
# File app/lib/ui/context.rb, line 202 def route_normalized arr = @route.split('?') return @route if arr.length == 1 arr[1] = arr[1].gsub('/', '_') arr.join('?') end