rewrite ExtraButtons using v-tooltip
This commit is contained in:
parent
1727c815f8
commit
005815c825
3 changed files with 13 additions and 48 deletions
|
@ -1,45 +1,21 @@
|
||||||
import Popper from 'vue-popperjs/src/component/popper.js.vue'
|
|
||||||
|
|
||||||
const ExtraButtons = {
|
const ExtraButtons = {
|
||||||
props: [ 'status' ],
|
props: [ 'status' ],
|
||||||
components: {
|
|
||||||
Popper
|
|
||||||
},
|
|
||||||
data () {
|
|
||||||
return {
|
|
||||||
showDropDown: false,
|
|
||||||
showPopper: true
|
|
||||||
}
|
|
||||||
},
|
|
||||||
methods: {
|
methods: {
|
||||||
deleteStatus () {
|
deleteStatus () {
|
||||||
this.refreshPopper()
|
|
||||||
const confirmed = window.confirm(this.$t('status.delete_confirm'))
|
const confirmed = window.confirm(this.$t('status.delete_confirm'))
|
||||||
if (confirmed) {
|
if (confirmed) {
|
||||||
this.$store.dispatch('deleteStatus', { id: this.status.id })
|
this.$store.dispatch('deleteStatus', { id: this.status.id })
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
toggleMenu () {
|
|
||||||
this.showDropDown = !this.showDropDown
|
|
||||||
},
|
|
||||||
pinStatus () {
|
pinStatus () {
|
||||||
this.refreshPopper()
|
|
||||||
this.$store.dispatch('pinStatus', this.status.id)
|
this.$store.dispatch('pinStatus', this.status.id)
|
||||||
.then(() => this.$emit('onSuccess'))
|
.then(() => this.$emit('onSuccess'))
|
||||||
.catch(err => this.$emit('onError', err.error.error))
|
.catch(err => this.$emit('onError', err.error.error))
|
||||||
},
|
},
|
||||||
unpinStatus () {
|
unpinStatus () {
|
||||||
this.refreshPopper()
|
|
||||||
this.$store.dispatch('unpinStatus', this.status.id)
|
this.$store.dispatch('unpinStatus', this.status.id)
|
||||||
.then(() => this.$emit('onSuccess'))
|
.then(() => this.$emit('onSuccess'))
|
||||||
.catch(err => this.$emit('onError', err.error.error))
|
.catch(err => this.$emit('onError', err.error.error))
|
||||||
},
|
|
||||||
refreshPopper () {
|
|
||||||
this.showPopper = false
|
|
||||||
this.showDropDown = false
|
|
||||||
setTimeout(() => {
|
|
||||||
this.showPopper = true
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
|
|
|
@ -1,23 +1,16 @@
|
||||||
<template>
|
<template>
|
||||||
<Popper
|
<v-popover
|
||||||
v-if="enabled && showPopper"
|
v-if="enabled"
|
||||||
trigger="click"
|
trigger="click"
|
||||||
append-to-body
|
class="extra-button-popover"
|
||||||
:options="{
|
|
||||||
placement: 'top',
|
|
||||||
modifiers: {
|
|
||||||
arrow: { enabled: true },
|
|
||||||
offset: { offset: '0, 5px' },
|
|
||||||
}
|
|
||||||
}"
|
|
||||||
@hide="showDropDown = false"
|
|
||||||
>
|
>
|
||||||
<div class="popper-wrapper">
|
<div class="popper-wrapper" slot="popover">
|
||||||
<div class="dropdown-menu">
|
<div class="dropdown-menu">
|
||||||
<button
|
<button
|
||||||
v-if="!status.pinned && canPin"
|
v-if="!status.pinned && canPin"
|
||||||
class="dropdown-item dropdown-item-icon"
|
class="dropdown-item dropdown-item-icon"
|
||||||
@click.prevent="pinStatus"
|
@click.prevent="pinStatus"
|
||||||
|
v-close-popover
|
||||||
>
|
>
|
||||||
<i class="icon-pin" /><span>{{ $t("status.pin") }}</span>
|
<i class="icon-pin" /><span>{{ $t("status.pin") }}</span>
|
||||||
</button>
|
</button>
|
||||||
|
@ -25,6 +18,7 @@
|
||||||
v-if="status.pinned && canPin"
|
v-if="status.pinned && canPin"
|
||||||
class="dropdown-item dropdown-item-icon"
|
class="dropdown-item dropdown-item-icon"
|
||||||
@click.prevent="unpinStatus"
|
@click.prevent="unpinStatus"
|
||||||
|
v-close-popover
|
||||||
>
|
>
|
||||||
<i class="icon-pin" /><span>{{ $t("status.unpin") }}</span>
|
<i class="icon-pin" /><span>{{ $t("status.unpin") }}</span>
|
||||||
</button>
|
</button>
|
||||||
|
@ -32,22 +26,16 @@
|
||||||
v-if="canDelete"
|
v-if="canDelete"
|
||||||
class="dropdown-item dropdown-item-icon"
|
class="dropdown-item dropdown-item-icon"
|
||||||
@click.prevent="deleteStatus"
|
@click.prevent="deleteStatus"
|
||||||
|
v-close-popover
|
||||||
>
|
>
|
||||||
<i class="icon-cancel" /><span>{{ $t("status.delete") }}</span>
|
<i class="icon-cancel" /><span>{{ $t("status.delete") }}</span>
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div
|
<div class="button-icon">
|
||||||
slot="reference"
|
<i class="icon-ellipsis" />
|
||||||
class="button-icon"
|
|
||||||
@click="toggleMenu"
|
|
||||||
>
|
|
||||||
<i
|
|
||||||
class="icon-ellipsis"
|
|
||||||
:class="{'icon-clicked': showDropDown}"
|
|
||||||
/>
|
|
||||||
</div>
|
</div>
|
||||||
</Popper>
|
</v-popover>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script src="./extra_buttons.js" ></script>
|
<script src="./extra_buttons.js" ></script>
|
||||||
|
@ -59,7 +47,8 @@
|
||||||
.icon-ellipsis {
|
.icon-ellipsis {
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
|
|
||||||
&:hover, &.icon-clicked {
|
&:hover,
|
||||||
|
.extra-button-popover.open & {
|
||||||
color: $fallback--text;
|
color: $fallback--text;
|
||||||
color: var(--text, $fallback--text);
|
color: var(--text, $fallback--text);
|
||||||
}
|
}
|
||||||
|
|
|
@ -824,7 +824,7 @@ $status-margin: 0.75em;
|
||||||
display: flex;
|
display: flex;
|
||||||
margin-top: $status-margin;
|
margin-top: $status-margin;
|
||||||
|
|
||||||
div, favorite-button {
|
> * {
|
||||||
max-width: 4em;
|
max-width: 4em;
|
||||||
flex: 1;
|
flex: 1;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue