add new feature report page

This commit is contained in:
Adrian Zürcher
2026-02-12 12:08:55 +01:00
parent 9a55d4c2f0
commit 1657123cc1
11 changed files with 327 additions and 34 deletions

View File

@@ -1,5 +1,8 @@
<template>
<div class="q-gutter-sm">
<div
class="q-ma-sm q-gutter-sm"
:style="{ height: props.height + 'px', width: props.width + 'px' }"
>
<h6 class="text-center text-bold q-ma-md text-primary">{{ props.title }}</h6>
<div class="row">
<q-checkbox
@@ -14,30 +17,30 @@
</div>
<div class="row">
<q-date v-model="dateRange" range flat />
<div>
<q-badge color="secondary"> Total dates selected: {{ filteredDates.length }} </q-badge>
</div>
</div>
</div>
</template>
<script setup lang="ts">
import { ref, computed, onMounted } from 'vue';
import { ref, onMounted, watch } from 'vue';
import { date } from 'quasar';
import { i18n } from 'src/boot/lang';
const props = defineProps({
title: String,
height: { type: Number, default: 400 },
width: { type: Number, default: 300 },
});
const startDate = new Date();
// Initial range (format: YYYY/MM/DD)
const dateRange = ref();
// Initial range (format: YYYY-MM-DD)
const dateRange = ref<string | { to: string; from: string }>('');
const selectedWeekdays = ref([0, 3]); // Default to weekdays
const emit = defineEmits(['update:dates']);
onMounted(() => {
dateRange.value = date.formatDate(startDate, 'YYYY/MM/DD');
dateRange.value = date.formatDate(startDate, 'YYYY-MM-DD');
});
const weekdayOptions = [
@@ -51,13 +54,14 @@ const weekdayOptions = [
];
// The Logic: Calculate all specific dates within the range that match weekdays
const filteredDates = computed(() => {
watch(dateRange, () => {
if (!dateRange.value) {
return [];
} else if (typeof dateRange.value === 'string') {
const current = new Date(dateRange.value);
if (current !== undefined && selectedWeekdays.value.includes(current.getDay())) {
return [date.formatDate(current, 'YYYY/MM/DD')];
emit('update:dates', [date.formatDate(current, 'YYYY-MM-DD')]);
return [date.formatDate(current, 'YYYY-MM-DD')];
}
return [];
}
@@ -69,10 +73,12 @@ const filteredDates = computed(() => {
while (current <= end) {
if (selectedWeekdays.value.includes(current.getDay())) {
result.push(date.formatDate(current, 'YYYY/MM/DD'));
result.push(date.formatDate(current, 'YYYY-MM-DD'));
}
current = date.addToDate(current, { days: 1 });
}
emit('update:dates', result);
return result;
});
</script>