Skip to content

Commit 2abc4de

Browse files
authored
auto expanding of manus & actions (#16)
1 parent 9162f1b commit 2abc4de

File tree

3 files changed

+20
-5
lines changed

3 files changed

+20
-5
lines changed

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,17 @@ createCustomElement("menu-editor", {
4040
parent: {
4141
default: null,
4242
},
43+
44+
expandParent: {
45+
default: null,
46+
}
4347
},
4448
actionHandlers: {
4549
"NOW_DROPDOWN#ITEM_CLICKED": ({
4650
action: {
4751
payload: { item },
4852
},
49-
properties: { parent },
53+
properties: { parent, expandParent },
5054
dispatch,
5155
}) => {
5256
let choice = "";
@@ -69,6 +73,7 @@ createCustomElement("menu-editor", {
6973

7074
// Dispatch back to menu-builder component the new menu item information
7175
dispatch("MENU_ITEM_EDITED", eventPayload);
76+
expandParent();
7277
},
7378
},
7479
});

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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import "./menu-editor";
1111

1212
const view = (
1313
{
14-
properties: { id, choice, label, type, page, sysId, href },
14+
properties: { id, choice, label, type, page, sysId, href, expandParent },
1515
labelInput,
1616
typeInput,
1717
pageInput,
@@ -110,7 +110,7 @@ const view = (
110110
></now-dropdown>
111111
</div>
112112
<div className="rightMenu">
113-
<menu-editor parent={id}></menu-editor>
113+
<menu-editor parent={id} expandParent={expandParent}></menu-editor>
114114
<now-collapse expanded={editMode}>
115115
<div>
116116
{typeValue == "route" ? (
@@ -201,6 +201,9 @@ createCustomElement("menu-item", {
201201
href: {
202202
default: undefined,
203203
},
204+
expandParent: {
205+
default: undefined
206+
}
204207
},
205208
// Keeps track of any changes made during editing
206209
initialState: {

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

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,18 @@ 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 }) => {
11+
const view = ({ properties: { tree }, expanded }, { updateState }) => {
1212
const { id, children, parent, choice, label, type, page, sys_id, href } =
1313
tree;
1414

1515
const hasChildren = children && children.length > 0;
1616

17+
const EXPAND_PARENT = () => {
18+
updateState({
19+
expanded: true,
20+
});
21+
}
22+
1723
return (
1824
<Fragment>
1925
<div>
@@ -35,6 +41,7 @@ const view = ({ properties: { tree }, expanded }) => {
3541
sysId={sys_id}
3642
href={href}
3743
className="menu-item"
44+
expandParent={EXPAND_PARENT}
3845
></menu-item>
3946
</div>
4047
{/* Render child menu items in a collapsible container if they exist */}
@@ -62,7 +69,7 @@ createCustomElement("menu-tree", {
6269
},
6370
},
6471
initialState: {
65-
expanded: false,
72+
expanded: true,
6673
},
6774
actionHandlers: {
6875
"NOW_BUTTON_ICONIC#CLICKED": ({

0 commit comments

Comments
 (0)