Skip to content

Commit

Permalink
pkp/pkp-lib#9890 Update Navigation's story file to correctly map keys…
Browse files Browse the repository at this point in the history
… from submenu data
  • Loading branch information
blesildaramirez committed Apr 30, 2024
1 parent 0f11d98 commit cd77e95
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 22 deletions.
30 changes: 15 additions & 15 deletions src/components/Navigation/Navigation.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,81 +70,81 @@ export const Default = {
icon: 'Settings',
url: '#',
addMargin: true,
submenu: [
{
submenu: {
context: {
name: 'Journal',
url: '#',
isCurrent: false,
icon: '',
},
{
website: {
name: 'Website',
url: '#',
isCurrent: false,
icon: '',
},
{
workflow: {
name: 'Workflow',
url: '#',
isCurrent: false,
icon: '',
},
{
distribution: {
name: 'Distribution',
url: '#',
isCurrent: false,
icon: '',
},
{
access: {
name: 'Users & Roles',
url: '#',
isCurrent: false,
icon: '',
},
],
},
},
{
name: 'Statistics',
icon: 'Statistics',
url: '#',
submenu: [
{
submenu: {
publications: {
name: 'Articles',
url: '#',
isCurrent: false,
icon: '',
},
{
issues: {
name: 'Issues',
url: '#',
isCurrent: false,
icon: '',
},
{
context: {
name: 'Journal',
url: '#',
isCurrent: false,
icon: '',
},
{
editorial: {
name: 'Editorial Activity',
url: '#',
isCurrent: false,
icon: '',
},
{
users: {
name: 'Users',
url: '#',
isCurrent: false,
icon: '',
},
{
reports: {
name: 'Reports',
url: '#',
isCurrent: false,
icon: '',
},
],
},
},
{
name: 'Tools',
Expand Down
15 changes: 8 additions & 7 deletions src/components/Navigation/Navigation.vue
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@
</div>
<ul>
<li
v-for="(link, index) in currentLink.submenu"
:key="index"
@click="handleSecondNav(currentLink.submenu, index)"
v-for="(link, key) in currentLink.submenu"
:key="key"
@click="handleSecondNav(currentLink.submenu, key)"
>
<PkpButton
element="a"
Expand Down Expand Up @@ -92,9 +92,9 @@ function toggleNav() {
collapsed.value = !collapsed.value;
}
function handleSecondNav(submenu = [], index = 0) {
submenu.forEach((link, i) => {
link.isCurrent = i === index;
function handleSecondNav(submenu = [], smKey) {
Object.keys(submenu).forEach((key) => {
submenu[key].isCurrent = key === smKey;
});
}
Expand All @@ -103,6 +103,7 @@ function handleClick(index) {
link.isCurrent = i === index;
});
currentLink.value = props.links[index];
handleSecondNav(props.links[index]?.submenu, 0);
const submenu = props.links[index]?.submenu || [];
handleSecondNav(submenu, Object.keys(submenu)[0]);
}
</script>

0 comments on commit cd77e95

Please sign in to comment.