Files
luos/resources/assets/js/components/utils/CustomTooltip.vue

66 lines
1.6 KiB
Vue
Raw Normal View History

<template>
<span
2021-08-17 21:48:08 +00:00
:id="`label-${data.id}`"
@mouseover="hoverHandler"
:title="labelTooltip"
>
2021-08-20 03:50:06 +00:00
{{ data.title }}
<b-tooltip :target="`label-${data.id}`" :ref="`tooltip-${data.id}`">
{{ labelTooltip }}
</b-tooltip>
</span>
</template>
<script>
import api from "./../../api/index";
export default {
name: "CustomTooltip",
props: {
data: Object,
},
data() {
return {
labelTooltip: "",
menuMap: {
CASES_INBOX: "inbox",
CASES_DRAFT: "draft",
CASES_PAUSED: "paused",
2021-08-20 03:40:20 +00:00
CASES_SELFSERVICE: "unassigned",
todo: "inbox",
draft: "draft",
paused: "paused",
2021-08-20 03:50:06 +00:00
unassigned: "unassigned",
},
};
},
methods: {
/**
* Delay the hover event
*/
hoverHandler() {
2021-08-20 03:40:20 +00:00
this.setTooltip();
},
/**
* Reset the delay and hide the tooltip
*/
unhoverHandler() {
2021-08-20 03:50:06 +00:00
let key = `tooltip-${this.data.id}`;
this.labelTooltip = "";
2021-08-20 03:50:06 +00:00
this.$refs[key].$emit("close");
},
/**
* Set the label to show in the tooltip
2021-08-20 03:50:06 +00:00
*/
setTooltip() {
let that = this;
2021-08-20 04:08:57 +00:00
api.menu.getTooltip(that.data.id).then((response) => {
2021-08-20 03:50:06 +00:00
let key = `tooltip-${that.data.id}`;
that.labelTooltip = response.data.label;
that.$refs[key].$emit("open");
});
},
2021-08-20 03:50:06 +00:00
},
};
</script>