enhance: enable deletion of protocol content
This commit is contained in:
parent
5b7a9a3ace
commit
2ce66da1d1
5 changed files with 124 additions and 9 deletions
64
src/components/DoubleConfirmClick.vue
Normal file
64
src/components/DoubleConfirmClick.vue
Normal file
|
@ -0,0 +1,64 @@
|
|||
<template>
|
||||
<div
|
||||
class="cursor-pointer"
|
||||
:class="{ 'text-white': light, 'animate-pulse': isSensitive }"
|
||||
:title="`2 mal klicken für ${action}`"
|
||||
@click.prevent="handleClick"
|
||||
>
|
||||
<slot :isSensitive="isSensitive">
|
||||
<CursorArrowRaysIcon v-if="!isSensitive" class="h-5 w-5" />
|
||||
<CursorArrowRippleIcon v-else class="h-5 w-5" />
|
||||
</slot>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { CursorArrowRaysIcon, CursorArrowRippleIcon } from "@heroicons/vue/24/outline";
|
||||
import { defineComponent } from "vue";
|
||||
</script>
|
||||
|
||||
<script lang="ts">
|
||||
export default defineComponent({
|
||||
props: {
|
||||
light: {
|
||||
type: Boolean,
|
||||
default: false,
|
||||
},
|
||||
action: {
|
||||
type: String,
|
||||
default: "Bestätigung",
|
||||
},
|
||||
},
|
||||
emits: ["click:first", "click:submit", "click:reset"],
|
||||
data() {
|
||||
return {
|
||||
isSensitive: false as boolean,
|
||||
timeout: undefined as any,
|
||||
};
|
||||
},
|
||||
beforeUnmount() {
|
||||
try {
|
||||
clearTimeout(this.timeout);
|
||||
} catch (error) {}
|
||||
},
|
||||
methods: {
|
||||
handleClick() {
|
||||
if (this.isSensitive) {
|
||||
clearTimeout(this.timeout);
|
||||
this.isSensitive = false;
|
||||
this.$emit("click:submit");
|
||||
} else {
|
||||
this.timeout = setTimeout(() => {
|
||||
this.isSensitive = true;
|
||||
this.$emit("click:first");
|
||||
|
||||
this.timeout = setTimeout(() => {
|
||||
this.isSensitive = false;
|
||||
this.$emit("click:reset");
|
||||
}, 2000);
|
||||
}, 500);
|
||||
}
|
||||
},
|
||||
},
|
||||
});
|
||||
</script>
|
Loading…
Add table
Add a link
Reference in a new issue