fix: refs #8655 fixed button problems & added translations
gitea/salix-front/pipeline/pr-dev There was a failure building this commit Details

This commit is contained in:
Pau Rovira 2025-03-03 09:49:32 +01:00
parent 69452e2627
commit 27866e7090
4 changed files with 31 additions and 5 deletions

View File

@ -226,6 +226,16 @@ onUnmounted(async () => {
if ($props.isEditable) document.removeEventListener('click', clickHandler);
});
watch(
mode,
(newMode) => {
if (newMode === CARD_MODE) {
showButton.value = false;
}
},
{ immediate: true }
);
watch(
() => $props.columns,
(value) => splitColumns(value),

View File

@ -1,11 +1,16 @@
<script setup>
import { ref, onMounted, onUnmounted, watch } from 'vue';
const props = defineProps({
scrollTarget: { type: [String, Object], default: 'window' } // Puede ser un selector o un ref
});
const scrollPosition = ref(0);
const showButton = ref(false);
let scrollContainer = null;
const onScroll = () => {
scrollPosition.value = window.scrollY;
scrollPosition.value = scrollContainer.scrollTop || window.scrollY;
};
watch(scrollPosition, (newValue) => {
@ -13,17 +18,24 @@ watch(scrollPosition, (newValue) => {
});
const scrollToTop = () => {
window.scrollTo({ top: 0, behavior: 'smooth' });
scrollContainer.scrollTo({ top: 0, behavior: 'smooth' });
};
onMounted(() => {
window.addEventListener('scroll', onScroll);
scrollContainer = props.scrollTarget === 'window' ? window : document.querySelector(props.scrollTarget);
if (scrollContainer) {
scrollContainer.addEventListener('scroll', onScroll);
}
});
onUnmounted(() => {
window.removeEventListener('scroll', onScroll);
if (scrollContainer) {
scrollContainer.removeEventListener('scroll', onScroll);
}
});
</script>
<template>
<QBtn
v-if="showButton"
@ -32,7 +44,9 @@ onUnmounted(() => {
icon="arrow_upward"
class="scroll-to-top"
@click="scrollToTop"
/>
>
<QTooltip>{{ $t('globals.scrollToTop') }}</QTooltip>
</QBtn>
</template>
<style scoped>

View File

@ -6,6 +6,7 @@ globals:
quantity: Quantity
entity: Entity
preview: Preview
scrollToTop: Go up
user: User
details: Details
collapseMenu: Collapse lateral menu

View File

@ -6,6 +6,7 @@ globals:
quantity: Cantidad
entity: Entidad
preview: Vista previa
scrollToTop: Ir arriba
user: Usuario
details: Detalles
collapseMenu: Contraer menú lateral