Skip to content

Commit

Permalink
Fixed #1564 - Add tooltipOptions property to Dock v2
Browse files Browse the repository at this point in the history
  • Loading branch information
tugcekucukoglu committed Sep 20, 2021
1 parent a2671a2 commit ff78ee4
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 6 deletions.
6 changes: 6 additions & 0 deletions api-generator/components/dock.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@ const DockProps = [
type: "object",
default: "null",
description: "Inline style of the element."
},
{
name: "tooltipOptions",
type: "object",
default: "null",
description: "Whether to display the tooltip on items. The modifiers of tooltip can be used like an object in it. Valid keys are 'event' and 'position'."
}
];

Expand Down
1 change: 1 addition & 0 deletions src/components/dock/Dock.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ declare class Dock extends Vue {
model?: any[];
className?: string;
styles?: any;
tooltipOptions?: any;
$slots: {
'item': VNode[];
}
Expand Down
5 changes: 3 additions & 2 deletions src/components/dock/Dock.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<template>
<div :class="containerClass" :style="styles">
<DockSub :model="model" :templates="$scopedSlots"></DockSub>
<DockSub :model="model" :templates="$scopedSlots" :tooltipOptions="tooltipOptions"></DockSub>
</div>
</template>

Expand All @@ -16,7 +16,8 @@ export default {
},
model: null,
className: null,
styles: null
styles: null,
tooltipOptions: null
},
data() {
return {
Expand Down
9 changes: 5 additions & 4 deletions src/components/dock/DockSub.vue
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
<template>
<ul ref="list" class="p-dock-list" role="menu" @mouseleave="onListMouseLeave">
<li v-for="(item, index) of model" :class="itemClass(index)" :key="index" role="none" @mouseenter="onItemMouseEnter(index)">
<DockSubTemplate v-if="templates['item']" :item="item" :template="templates['item']" />
<DockSubTemplate v-if="templates['item']" :item="item" :template="templates['item']" :tooltipOptions="tooltipOptions" />
<template v-else>
<router-link v-if="item.to && !item.disabled" :to="item.to" custom v-slot="{href}">
<a :href="href" role="menuitem" :class="['p-dock-action', { 'p-disabled': item.disabled }]" :target="item.target"
:data-pr-tooltip="item.label" @click="onItemClick(e, item)">
v-tooltip:[tooltipOptions]="{value: item.label, disabled: !tooltipOptions}" @click="onItemClick(e, item)">
<template v-if="typeof item.icon === 'string'">
<span :class="['p-dock-action-icon', item.icon]" v-ripple></span>
</template>
<DockSubIconTemplate v-else :icon="item.icon" />
</a>
</router-link>
<a v-else :href="item.url || '#'" role="menuitem" :class="['p-dock-action', { 'p-disabled': item.disabled }]" :target="item.target"
:data-pr-tooltip="item.label" @click="onItemClick($event, item)">
v-tooltip:[tooltipOptions]="{value: item.label, disabled: !tooltipOptions}" @click="onItemClick($event, item)">
<template v-if="typeof item.icon === 'string'">
<span :class="['p-dock-action-icon', item.icon]" v-ripple></span>
</template>
Expand Down Expand Up @@ -69,7 +69,8 @@ export default {
templates: {
type: null,
default: null
}
},
tooltipOptions: null
},
data() {
return {
Expand Down
6 changes: 6 additions & 0 deletions src/views/dock/DockDoc.vue
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,12 @@ export default {
<td>null</td>
<td>Inline style of the element.</td>
</tr>
<tr>
<td>tooltipOptions</td>
<td>object</td>
<td>null</td>
<td>Whether to display the tooltip on items. The modifiers of <router-link to="/tooltip">Tooltip</router-link> can be used like an object in it. Valid keys are 'event' and 'position'.</td>
</tr>
</tbody>
</table>
</div>
Expand Down

0 comments on commit ff78ee4

Please sign in to comment.