NavigationTree.Helper
Summary
allowed_tree(node, roles) | Recursivly walks the tree, removing all nodes that given roles do not satisfy |
at(node, list) | Traverses the tree searching for the names given in list |
at2(node, list2) | |
join_slash(parent \\ "", child \\ "") | |
safe_name(name) | Replaces German Umlauts äöü and ß with ae oe ue, downcases the string and replaces all nonword sequences to “-“ |
thaw(node) | |
thaw(node, parent_url, parent_name_path, parent_roles, paths_acc) |
Functions
Recursivly walks the tree, removing all nodes that given roles do not satisfy.
Examples
iex> alias NavigationTree.Node, as: Node
nil
iex> NavigationTree.Agent.start_link %Node{name: "A", children: [%Node{name: "B", roles: ["b"], children: [%Node{name: "C", roles: ["c"]}]}]}
{:ok, pid }
iex> NavigationTree.Helper.allowed_tree NavigationTree.Agent.get.tree, ["a"]
%{children: [], controller: nil, name: "A", roles: [], url: "/a"}
iex> NavigationTree.Helper.allowed_tree NavigationTree.Agent.get.tree, ["b"]
%{children: [%{children: [], controller: nil, name: "B", roles: ["b"], url: "/a/b"}], controller: nil, name: "A", roles: [], url: "/a"}
iex> NavigationTree.Helper.allowed_tree NavigationTree.Agent.get.tree, ["c","b"]
%{children: [%{children: [%{children: [], controller: nil, name: "C", roles: ["b", "c"], url: "/a/b/c"}], controller: nil, name: "B", roles: ["b"], url: "/a/b"}], controller: nil, name: "A", roles: [], url: "/a"}
Traverses the tree searching for the names given in list.
Specs:
Replaces German Umlauts äöü and ß with ae oe ue, downcases the string and replaces all nonword sequences to “-“
Example
iex> NavigationTree.Helper.safe_name “Hane Büchener Unsinn” “hane-buechener-unsinn”