mirror of
https://github.com/Ocelot-Social-Community/Ocelot-Social.git
synced 2025-12-12 23:35:58 +00:00
* calculate distance between current user and queried user * fix query for unset location * use database to calculate distance * rename distance to distance to me, 100% calculation done in DB * distanceToMe tests * lint fixes * remove comments * Show user teaser popover with badges, Desktop * Refactor UserTeaser and add mobile popover support * Avoid click propagation (WIP) * Prevent event propagation * Adjust alignment and font sizes * More spacing for statistics * Add distance, simplify user link * Refactor location info into own component * Add tests for UserTeaserPopup * Refactor and test LocationInfo * Query distanceToMe, rename distance to distanceToMe * Update test * Improve tests for UserTeaser, WIP * Fix tests * DistanceToMe on User instead of Location * Revert "DistanceToMe on User instead of Location" This reverts commit 96c9db00a44cd120e47bfe9534d3e066a194744c. * Fix notifications * Refactor UserTeaser and fix location info * Fix group member crash * Show 0 distance * Fit in popover on small screens * Allow access to profile on desktop * Revert backend changes * Load user teaser popover data only when needed * Fix type mismatch * Refactor for clarity and accessibility * Litte refactorings and improvements * Fix popover test * Adapt and fix tests * Fix tests and bugs * Add placeholder * cypress: adapt user teaser locator to changes * Remove delays and scrolling * Disable popovers in notification list and fix layout * Remove flickering * Make overlay catch all pointer events on touch devices * Re-add attribute for E2E test * Fix test, return to mouseover * fix snapshot --------- Co-authored-by: Ulf Gebhardt <ulf.gebhardt@webcraft-media.de> Co-authored-by: Wolfgang Huß <wolle.huss@pjannto.com> Co-authored-by: mahula <lenzmath@posteo.de>
115 lines
2.6 KiB
Vue
115 lines
2.6 KiB
Vue
<template>
|
|
<v-popover
|
|
:open.sync="isPopoverOpen"
|
|
:open-group="Math.random().toString()"
|
|
:placement="placement"
|
|
:disabled="disabled"
|
|
trigger="manual"
|
|
:offset="offset"
|
|
>
|
|
<slot :toggleMenu="toggleMenu" :openMenu="openMenu" :closeMenu="closeMenu" :isOpen="isOpen" />
|
|
<div slot="popover" @mouseover="popoverMouseEnter" @mouseleave="popoverMouseLeave">
|
|
<slot
|
|
name="popover"
|
|
:toggleMenu="toggleMenu"
|
|
:openMenu="openMenu"
|
|
:closeMenu="closeMenu"
|
|
:isOpen="isOpen"
|
|
/>
|
|
</div>
|
|
</v-popover>
|
|
</template>
|
|
|
|
<script>
|
|
let mouseEnterTimer = null
|
|
let mouseLeaveTimer = null
|
|
|
|
export default {
|
|
props: {
|
|
placement: { type: String, default: 'bottom-end' },
|
|
disabled: { type: Boolean, default: false },
|
|
offset: { type: [String, Number], default: '16' },
|
|
},
|
|
data() {
|
|
return {
|
|
isPopoverOpen: false,
|
|
developerNoAutoClosing: false, // stops automatic closing of menu for developer purposes: default is 'false'
|
|
}
|
|
},
|
|
computed: {
|
|
isOpen() {
|
|
return this.isPopoverOpen
|
|
},
|
|
},
|
|
watch: {
|
|
isPopoverOpen: {
|
|
handler(isOpen) {
|
|
if (isOpen) {
|
|
document.body.classList.add('dropdown-open')
|
|
} else {
|
|
document.body.classList.remove('dropdown-open')
|
|
}
|
|
},
|
|
},
|
|
},
|
|
beforeDestroy() {
|
|
clearTimeout(mouseEnterTimer)
|
|
clearTimeout(mouseLeaveTimer)
|
|
},
|
|
methods: {
|
|
toggleMenu() {
|
|
this.isPopoverOpen ? this.closeMenu(false) : this.openMenu(false)
|
|
},
|
|
openMenu(useTimeout) {
|
|
if (this.disabled) {
|
|
return
|
|
}
|
|
this.clearTimeouts()
|
|
if (useTimeout === true) {
|
|
this.popoverMouseEnter()
|
|
} else {
|
|
this.isPopoverOpen = true
|
|
}
|
|
},
|
|
closeMenu(useTimeout) {
|
|
if (this.disabled) {
|
|
return
|
|
}
|
|
this.clearTimeouts()
|
|
if (useTimeout === true) {
|
|
this.popoverMouseLeave()
|
|
} else {
|
|
this.isPopoverOpen = false
|
|
}
|
|
},
|
|
popoverMouseEnter() {
|
|
if (this.disabled) {
|
|
return
|
|
}
|
|
this.clearTimeouts()
|
|
if (!this.isPopoverOpen) {
|
|
mouseEnterTimer = setTimeout(() => {
|
|
this.isPopoverOpen = true
|
|
}, 500)
|
|
}
|
|
},
|
|
popoverMouseLeave() {
|
|
if (this.developerNoAutoClosing) return
|
|
if (this.disabled) {
|
|
return
|
|
}
|
|
this.clearTimeouts()
|
|
if (this.isPopoverOpen) {
|
|
mouseLeaveTimer = setTimeout(() => {
|
|
this.isPopoverOpen = false
|
|
}, 300)
|
|
}
|
|
},
|
|
clearTimeouts() {
|
|
clearTimeout(mouseEnterTimer)
|
|
clearTimeout(mouseLeaveTimer)
|
|
},
|
|
},
|
|
}
|
|
</script>
|