Re-enable items dragging

This commit is contained in:
Bubka 2023-10-24 08:53:55 +02:00
parent 865daa1cf6
commit db295f97e9
2 changed files with 86 additions and 74 deletions

View File

@ -26,6 +26,7 @@
"unplugin-auto-import": "^0.16.6",
"vite": "^4.4.9",
"vue": "^3.3.4",
"vue-draggable-plus": "^0.2.6",
"vue-router": "^4.2.4"
}
}

View File

@ -17,6 +17,7 @@
import { useGroups } from '@/stores/groups'
import { useAppSettingsStore } from '@/stores/appSettings'
import { useDisplayablePassword } from '@/composables/helpers'
import { vDraggable } from 'vue-draggable-plus'
const $2fauth = inject('2fauth')
const notify = useNotifyStore()
@ -141,6 +142,22 @@
}
})
}
/**
* Dragging start
*/
function onStart() {
isDragging.value = true
}
/**
* Dragging end
*/
function onEnd() {
isDragging.value = false
twofaccounts.saveOrder()
}
</script>
<template>
@ -197,19 +214,20 @@
<!-- show accounts list -->
<div class="container" v-if="showAccounts" :class="bus.inManagementMode ? 'is-edit-mode' : ''">
<!-- accounts -->
<!-- <vue-pull-refresh :on-refresh="onRefresh" :config="{
errorLabel: 'error',
startLabel: '',
readyLabel: '',
loadingLabel: 'refreshing'
}" > -->
<!-- <draggable v-model="twofaccounts.filtered" @start="isDragging = true" @end="() => {isDragging = false; twofaccounts.saveOrder()}" ghost-class="ghost" handle=".tfa-dots" animation="200" class="accounts"> -->
<div class="accounts">
<!-- <transition-group class="columns is-multiline" :class="{ 'is-centered': user.preferences.displayMode === 'grid' }" type="transition" :name="!isDragging ? 'flip-list' : null"> -->
<span class="columns is-multiline">
<span class="columns is-multiline" :class="{ 'is-centered': user.preferences.displayMode === 'grid' }" v-draggable="[
twofaccounts.filtered,
{
animation: 150,
ghostClass: 'ghost',
handle: '.tfa-dots',
onEnd,
onStart
}
]">
<div :class="[user.preferences.displayMode === 'grid' ? 'tfa-grid' : 'tfa-list']" class="column is-narrow" v-for="account in twofaccounts.filtered" :key="account.id">
<div class="tfa-container">
<!-- <transition name="slideCheckbox"> -->
<transition name="slideCheckbox">
<div class="tfa-cell tfa-checkbox" v-if="bus.inManagementMode">
<div class="field">
<UseColorMode v-slot="{ mode }">
@ -218,7 +236,7 @@
<label tabindex="0" :for="'ckb_' + account.id" v-on:keypress.space.prevent="twofaccounts.select(account.id)"></label>
</div>
</div>
<!-- </transition> -->
</transition>
<div tabindex="0" class="tfa-cell tfa-content is-size-3 is-size-4-mobile" @click.exact="showOrCopy(account)" @keyup.enter="showOrCopy(account)" @click.ctrl="getAndCopyOTP(account)" role="button">
<div class="tfa-text has-ellipsis">
<img class="tfa-icon" :src="$2fauth.config.subdirectory + '/storage/icons/' + account.icon" v-if="account.icon && user.preferences.showAccountsIcons" :alt="$t('twofaccounts.icon_for_account_x_at_service_y', {account: account.account, service: account.service})">
@ -226,7 +244,7 @@
<span class="has-ellipsis is-family-primary is-size-6 is-size-7-mobile has-text-grey ">{{ account.account }}</span>
</div>
</div>
<!-- <transition name="popLater"> -->
<transition name="popLater">
<div v-show="user.preferences.getOtpOnRequest == false && !bus.inManagementMode" class="has-text-right">
<span v-if="account.otp != undefined && isRenewingOTPs" class="has-nowrap has-text-grey has-text-centered is-size-5">
<FontAwesomeIcon :icon="['fas', 'circle-notch']" spin />
@ -244,8 +262,8 @@
</span>
<!-- <dots v-if="account.otp_type.includes('totp')" @hook:mounted="turnDotsOnFromCache(account.period)" :class="'condensed'" :ref="'dots_' + account.period"></dots> -->
</div>
<!-- </transition> -->
<!-- <transition name="fadeInOut"> -->
</transition>
<transition name="fadeInOut">
<div class="tfa-cell tfa-edit has-text-grey" v-if="bus.inManagementMode">
<UseColorMode v-slot="{ mode }">
<RouterLink :to="{ name: 'editAccount', params: { twofaccountId: account.id }}" class="tag is-rounded mr-1" :class="mode == 'dark' ? 'is-dark' : 'is-white'">
@ -256,19 +274,16 @@
</RouterLink>
</UseColorMode>
</div>
<!-- </transition> -->
<!-- <transition name="fadeInOut"> -->
</transition>
<transition name="fadeInOut">
<div class="tfa-cell tfa-dots has-text-grey" v-if="bus.inManagementMode">
<FontAwesomeIcon :icon="['fas', 'bars']" />
</div>
<!-- </transition> -->
</transition>
</div>
</div>
</span>
<!-- </transition-group> -->
</div>
<!-- </draggable> -->
<!-- </vue-pull-refresh> -->
<VueFooter :showButtons="true" v-on:management-mode-exited="twofaccounts.selectNone()">
<ActionButtons
v-model:inManagementMode="bus.inManagementMode"
@ -428,10 +443,6 @@
</script>
<style scoped>
.flip-list-move {
transition: transform 0.5s;
}
.ghost {
opacity: 1;
/*background: hsl(0, 0%, 21%);*/