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); if ($props.isEditable) document.removeEventListener('click', clickHandler);
}); });
watch(
mode,
(newMode) => {
if (newMode === CARD_MODE) {
showButton.value = false;
}
},
{ immediate: true }
);
watch( watch(
() => $props.columns, () => $props.columns,
(value) => splitColumns(value), (value) => splitColumns(value),

View File

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

View File

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

View File

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