Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

156
Visualizações
Filter dates and move back and forth VUE

I have a select where I filter tasks on week, month and year and it works fine. But I want to have a buttons next to the select where I can move to the previous or next week (If I'm filtering on week, otherwise month or year). That's where I get stuck.

For now I have this component for my select:

export default base({
    setup() {
        const now = DateTime.local()
        return {
            items: [
                {
                    text: i18n.tc('Current week'),
                    value: now.startOf('week').until(now.endOf('week')),
                },
                {
                    text: i18n.tc('Current month'),
                    value: now.startOf('month').until(now.endOf('month')),
                },
                {
                    text: i18n.tc('Current year'),
                    value: now.startOf('year').until(now.endOf('year')),
                },
            ],
            label: i18n.tc('Period'),
        }
    },
    itemText: 'text',
    itemValue: 'value',
})

I'm importing and using the component in another file where I first in the setup declare:

const dateFilter = ref<string | null>(
    DateTime.local().startOf('month').until(DateTime.local().endOf('month')).toISODate(),
)

I then have this computed:

const filterTasks = computed(() => {
    function filterDate(filterDate: string | null, taskDate: string | null) {
        return filterDate && taskDate ? filterDate > taskDate : false
    }
    return tasks.value.filter(task => {
                if (filterDate(dateFilter.value, task.dateAdd)) {
                    return false
                }
                return task.id
            }),
    )
})

Then in my template where I use my select component:

        <div class="flex gap-2 items-center">
            <duration
                v-model="dateFilter"
                hide-details
            />
            <div>
                <v-btn icon><v-icon> chevron_left </v-icon></v-btn>
                      {{ buttonText }}
                <v-btn icon @click="dateFilter.plus({ weeks: 1 })">
                    <v-icon> chevron_right </v-icon></v-btn>
            </div>
        </div>

I'm just completely lost on where to proceed from now. I'm also thinking that I'm starting off in the wrong way and should change my Select component as well. Maybe move it into the same or create a new one. Someone that can guide me a bit? :)

about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda