Documentation
¶
Index ¶
- Constants
- func NewMenuCreateController(ui UiInterface) *menuCreateController
- func NewMenuDeleteController(ui UiInterface) *menuDeleteController
- func NewMenuManagerController(ui UiInterface) *menuManagerController
- func NewMenuUpdateController(ui UiInterface) *menuUpdateController
- type Node
- type Tree
- func (tree *Tree) Add(parentID string, node Node)
- func (tree *Tree) AddMenuItem(parentID string, menuItem cmsstore.MenuItemInterface)
- func (tree *Tree) Children(parentID string) []Node
- func (tree *Tree) Clone(node Node) Node
- func (tree *Tree) Duplicate(blockID string)
- func (tree *Tree) Exists(nodeID string) bool
- func (tree *Tree) Find(nodeID string) *Node
- func (tree *Tree) FindNextSibling(nodeID string) *Node
- func (tree *Tree) FindPreviousSibling(nodeID string) *Node
- func (tree *Tree) List() []Node
- func (tree *Tree) MoveDown(nodeID string)
- func (tree *Tree) MoveToParent(nodeID string, parentID string)
- func (tree *Tree) MoveToPosition(nodeID string, parentID string, position int)
- func (tree *Tree) MoveUp(nodeID string)
- func (tree *Tree) Parent(nodeID string) *Node
- func (tree *Tree) RecalculateSequences(blockID string)
- func (tree *Tree) Remove(nodeID string)
- func (tree *Tree) RemoveOrphans()
- func (tree *Tree) ToJSON() (jsonString string, err error)
- func (tree *Tree) Traverse(blockID string) []Node
- func (tree *Tree) Update(node Node)
- type UiInterface
Constants ¶
const ACTION_TREEEDITOR_HANDLE = "treeditor_handle"
const ActionModalPageFilterShow = "modal_menu_filter_show"
const VIEW_MENU_ITEMS = "menu_items"
const VIEW_SETTINGS = "settings"
Variables ¶
This section is empty.
Functions ¶
func NewMenuCreateController ¶
func NewMenuCreateController(ui UiInterface) *menuCreateController
func NewMenuDeleteController ¶
func NewMenuDeleteController(ui UiInterface) *menuDeleteController
func NewMenuManagerController ¶
func NewMenuManagerController(ui UiInterface) *menuManagerController
func NewMenuUpdateController ¶
func NewMenuUpdateController(ui UiInterface) *menuUpdateController
Types ¶
type Tree ¶
type Tree struct {
// contains filtered or unexported fields
}
func NewTreeFromJSON ¶
func NewTreeFromMenuItems ¶
func NewTreeFromMenuItems(menuItems []cmsstore.MenuItemInterface) *Tree
func (*Tree) AddMenuItem ¶
func (tree *Tree) AddMenuItem(parentID string, menuItem cmsstore.MenuItemInterface)
AddBlock adds a new ui.BlockInterface to the Tree
func (*Tree) Clone ¶
Clone creates a shallow clone of a Node (no children)
This is used to create a clone of a Node, so that the original Node is not modified, but we can modify the clone safely
Remember to update the ID, Sequence, and ParentID of the copy with new values
func (*Tree) Duplicate ¶
Duplicate creates a deep clone of a Node (with children) and adds it to the tree, under the same parent
Business Logic: - travserses the tree to find all blocks to be duplicated - makes a map with current IDs as keys, newly generated IDs as values - clones each block, and replaces the ID with the new ID - assignes the correct mapped IDs and ParentIDs - adds the cloned blocks to the tree directly (using list) - moves the duplicated block under the block being duplicated
func (*Tree) FindNextSibling ¶
func (*Tree) FindPreviousSibling ¶
func (*Tree) MoveToParent ¶
func (*Tree) MoveToPosition ¶
func (*Tree) RecalculateSequences ¶
func (*Tree) Remove ¶
Remove removes the block with the given id
Buisiness Logic: - checks if the block exists, if not, do nothing - removes the block from the list - recalculates the sequences of the parent's children
func (*Tree) RemoveOrphans ¶
func (tree *Tree) RemoveOrphans()
RemoveOrphans removes all orphaned blocks that have no parent
Buisiness Logic: - finds and creates a new list without orphaned blocks - non orphaned blocks are the ones that have a parent or root blocks - updates the list with the new list
Parameters: - none
Returns: - none
type UiInterface ¶
type UiInterface interface {
shared.UiInterface
MenuCreate(w http.ResponseWriter, r *http.Request)
MenuManager(w http.ResponseWriter, r *http.Request)
MenuDelete(w http.ResponseWriter, r *http.Request)
MenuUpdate(w http.ResponseWriter, r *http.Request)
}
func UI ¶
func UI(config shared.UiConfig) UiInterface