Skip to content

Commit 1c17b9e

Browse files
authored
Implemented limits of menu nesting. (#23)
1 parent 19a2bf7 commit 1c17b9e

File tree

2 files changed

+22
-8
lines changed

2 files changed

+22
-8
lines changed

src/x-759224-menu-builder-uic/components/menu-item.js

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import iconlist from "../icons";
1212

1313
const view = (
1414
{
15-
properties: { id, choice, label, type, page, sysId, href, expandParent, rightIcon },
15+
properties: { id, choice, label, type, page, sysId, href, expandParent, rightIcon, level },
1616
labelInput,
1717
typeInput,
1818
pageInput,
@@ -112,7 +112,7 @@ const view = (
112112
<now-dropdown
113113
// mapping iconlist for required data in now-dropdown
114114
// adding no-icon as a no selection
115-
items={[{ id: null, label: "no-icon" }, ...iconlist.map(e => ({ id: e, label: e }))]}
115+
items={[{ id: null, label: "no-icon", type: 'icon' }, ...iconlist.map(e => ({ id: e, label: e, type: 'icon' }))]}
116116
selectedItems={[iconValue]}
117117
name="iconInput"
118118
select="single"
@@ -135,9 +135,12 @@ const view = (
135135
</p>
136136
}
137137
</div>
138-
<div className="rightMenu">
139-
<menu-editor parent={id} expandParent={expandParent}></menu-editor>
140-
</div>
138+
{
139+
level < 4 ? <div className="rightMenu">
140+
<menu-editor parent={id} expandParent={expandParent}></menu-editor>
141+
</div> : <div></div>
142+
}
143+
141144
</div>
142145
<now-collapse expanded={editMode}>
143146
<div className="menu-row">
@@ -251,6 +254,9 @@ createCustomElement("menu-item", {
251254
},
252255
rightIcon: {
253256
default: null
257+
},
258+
level: {
259+
default: 0
254260
}
255261
},
256262
// Keeps track of any changes made during editing
@@ -272,13 +278,17 @@ createCustomElement("menu-item", {
272278
* Only handle this event if called from this component
273279
* Since menu-editor also uses this event
274280
*/
281+
275282
switch (payload.item.id) {
276283
case "route":
277284
case "external":
278285
updateState({ typeInput: payload.item.id });
279286
break;
280287
default:
281-
updateState({ iconInput: payload.item.id }); // action on icon selection
288+
}
289+
290+
if(payload.item.type === 'icon'){
291+
updateState({ iconInput: payload.item.id }); // action on icon selection
282292
}
283293
},
284294
// Text input field has changed (someone typed in the field or cleared value for example)

src/x-759224-menu-builder-uic/components/menu-tree.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import "./menu-item";
88
// File description: This displays a top-level menu item (and child items), expand/collapse functionality for the container
99

1010

11-
const view = ({ properties: { tree }, expanded }, { updateState }) => {
11+
const view = ({ properties: { tree, level }, expanded }, { updateState }) => {
1212
const { id, children, parent, choice, label, type, page, sys_id, href, rightIcon } =
1313
tree;
1414

@@ -43,14 +43,15 @@ const view = ({ properties: { tree }, expanded }, { updateState }) => {
4343
rightIcon={rightIcon}
4444
className="menu-item"
4545
expandParent={EXPAND_PARENT}
46+
level={level}
4647
></menu-item>
4748
</div>
4849
{/* Render child menu items in a collapsible container if they exist */}
4950
{hasChildren ? (
5051
<ul>
5152
<now-collapse expanded={expanded}>
5253
{children.map((child) => {
53-
return <menu-tree key={child.id} tree={child}></menu-tree>;
54+
return <menu-tree key={child.id} tree={child} level={level + 1}></menu-tree>;
5455
})}
5556
</now-collapse>
5657
</ul>
@@ -68,6 +69,9 @@ createCustomElement("menu-tree", {
6869
tree: {
6970
default: {},
7071
},
72+
level: {
73+
default: 1
74+
}
7175
},
7276
initialState: {
7377
expanded: true,

0 commit comments

Comments
 (0)