menus

package
v0.1.7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 22, 2020 License: Apache-2.0 Imports: 7 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddMenuToMapFromEtree

func AddMenuToMapFromEtree(element *etree.Element, mMap map[string]*Menu) map[string]*Menu

AddMenuToMapFromEtree reads the menu from the given element and adds it to the given map.

func BootStrap

func BootStrap()

BootStrap the menus by linking parents and children and populates the Registry

func LoadFromEtree

func LoadFromEtree(element *etree.Element)

LoadFromEtree reads the menu given etree.Element, creates or updates the menu and adds it to the menu registry if it not already.

Types

type Collection

type Collection struct {
	sync.RWMutex
	Menus []*Menu
	// contains filtered or unexported fields
}

A Collection is a hierarchical and sortable Collection of menus

var (
	Registry *Collection
)

Registry is the menu Collection of the application

func NewCollection

func NewCollection() *Collection

NewCollection returns a pointer to a new Collection instance

func (*Collection) Add

func (mc *Collection) Add(m *Menu)

Add adds a menu to the menu Collection

func (*Collection) All added in v0.1.0

func (mc *Collection) All() []*Menu

All returns all menus recursively

func (*Collection) GetByID

func (mc *Collection) GetByID(id int64) *Menu

GetByID returns the Menu with the given id

func (*Collection) GetByXMLID added in v0.1.0

func (mc *Collection) GetByXMLID(xmlid string) *Menu

GetByXMLID returns the Menu with the given xmlid

func (*Collection) Len

func (mc *Collection) Len() int

func (*Collection) Less

func (mc *Collection) Less(i, j int) bool

func (*Collection) Swap

func (mc *Collection) Swap(i, j int)
type Menu struct {
	ID               int64
	XMLID            string
	Name             string
	ParentID         string
	Parent           *Menu
	ParentCollection *Collection
	Children         *Collection
	Sequence         uint8
	ActionID         string
	Action           *actions.Action
	HasChildren      bool
	HasAction        bool
	WebIcon          string
	// contains filtered or unexported fields
}

A Menu is the representation of a single menu item

func (m Menu) TranslatedName(lang string) string

TranslatedName returns the translated name of this menu in the given language

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL