Fixed #949 - Router support for PanelMenu headers
parent
5319c59d01
commit
22fc6b212a
|
@ -3,7 +3,13 @@
|
|||
<template v-for="(item, index) of model" :key="item.label + '_' + index">
|
||||
<div v-if="visible(item)" :class="getPanelClass(item)" :style="item.style">
|
||||
<div :class="getHeaderClass(item)" :style="item.style">
|
||||
<a :href="item.url" class="p-panelmenu-header-link" @click="onItemClick($event, item)" :tabindex="item.disabled ? null : '0'"
|
||||
<router-link v-if="item.to && !item.disabled" :to="item.to" custom v-slot="{navigate, href}">
|
||||
<a :href="href" class="p-panelmenu-header-link" @click="onItemClick($event, item, navigate)" role="treeitem">
|
||||
<span v-if="item.icon" :class="getPanelIcon(item)"></span>
|
||||
<span class="p-menuitem-text">{{item.label}}</span>
|
||||
</a>
|
||||
</router-link>
|
||||
<a v-else :href="item.url" class="p-panelmenu-header-link" @click="onItemClick($event, item)" :tabindex="item.disabled ? null : '0'"
|
||||
:aria-expanded="isActive(item)" :id="ariaId +'_header'" :aria-controls="ariaId +'_content'">
|
||||
<span v-if="item.items" :class="getPanelToggleIcon(item)"></span>
|
||||
<span v-if="item.icon" :class="getPanelIcon(item)"></span>
|
||||
|
@ -41,16 +47,12 @@ export default {
|
|||
}
|
||||
},
|
||||
methods: {
|
||||
onItemClick(event, item) {
|
||||
onItemClick(event, item, navigate) {
|
||||
if (item.disabled) {
|
||||
event.preventDefault();
|
||||
return;
|
||||
}
|
||||
|
||||
if (!item.url && !item.to) {
|
||||
event.preventDefault();
|
||||
}
|
||||
|
||||
if (item.command) {
|
||||
item.command({
|
||||
originalEvent: event,
|
||||
|
@ -62,6 +64,10 @@ export default {
|
|||
this.activeItem = null;
|
||||
else
|
||||
this.activeItem = item;
|
||||
|
||||
if (item.to && navigate) {
|
||||
navigate(event);
|
||||
}
|
||||
},
|
||||
getPanelClass(item) {
|
||||
return ['p-panelmenu-panel', item.class];
|
||||
|
|
|
@ -40,7 +40,7 @@ export default {
|
|||
}
|
||||
},
|
||||
methods: {
|
||||
onItemClick($event, item, navigate) {
|
||||
onItemClick(event, item, navigate) {
|
||||
if (item.disabled) {
|
||||
event.preventDefault();
|
||||
return;
|
||||
|
|
Loading…
Reference in New Issue