Update WorkerCalendarItem

This commit is contained in:
Kevin Martinez 2024-04-02 09:00:15 -03:00
parent 0dee7e8cc9
commit 47a588fff4
2 changed files with 50 additions and 24 deletions

View File

@ -5,7 +5,7 @@ import WorkerCalendarFilter from 'pages/Worker/Card/WorkerCalendarFilter.vue';
import FetchData from 'components/FetchData.vue'; import FetchData from 'components/FetchData.vue';
import { useRoute } from 'vue-router'; import { useRoute } from 'vue-router';
import { ref } from 'vue'; import { ref } from 'vue';
import WorkerCalendarItem from "pages/Worker/Card/WorkerCalendarItem.vue"; import WorkerCalendarItem from 'pages/Worker/Card/WorkerCalendarItem.vue';
const stateStore = useStateStore(); const stateStore = useStateStore();
const route = useRoute(); const route = useRoute();
@ -67,25 +67,36 @@ const onFetchActiveContract = (data) => {
</QCardSection> </QCardSection>
</QCard> </QCard>
<QCard class="full-width"> <QCard class="full-width">
<QCardSection class="card-calendar"> <QCardSection class="calendar-container">
<WorkerCalendarItem <div v-for="month in 12" :key="month" class="full-width full-height">
class="full-width" <WorkerCalendarItem class="full-width" :year="year" :month="month" />
show-work-weeks </div>
animated
bordered
mini-mode
:year="year"
month="1"
/>
</QCardSection> </QCardSection>
</QCard> </QCard>
</QPage> </QPage>
</template> </template>
<style lang="scss" scoped> <style lang="scss" scoped>
.card-calendar{ .calendar-container {
display: grid; display: grid;
gap: 32px;
grid-template-columns: repeat(3, minmax(0, 1fr)); grid-template-columns: repeat(3, minmax(0, 1fr));
} }
@media (max-width: $breakpoint-md) {
.calendar-container {
grid-template-columns: repeat(2, minmax(0, 1fr));
}
}
@media (max-width: $breakpoint-sm) {
.calendar-container {
grid-template-columns: repeat(1, minmax(0, 1fr));
}
}
.calendar-item {
max-width: 324px;
}
</style> </style>
<i18n> <i18n>

View File

@ -1,9 +1,11 @@
<script setup> <script setup>
import {onBeforeMount, ref} from 'vue'; import { onBeforeMount, ref, watch } from 'vue';
import { QCalendarMonth, today } from '@quasar/quasar-ui-qcalendar/src/index.js'; import { QCalendarMonth, today } from '@quasar/quasar-ui-qcalendar/src/index.js';
import '@quasar/quasar-ui-qcalendar/src/QCalendarVariables.sass'; import '@quasar/quasar-ui-qcalendar/src/QCalendarVariables.sass';
import '@quasar/quasar-ui-qcalendar/src/QCalendarTransitions.sass'; import '@quasar/quasar-ui-qcalendar/src/QCalendarTransitions.sass';
import '@quasar/quasar-ui-qcalendar/src/QCalendarMonth.sass'; import '@quasar/quasar-ui-qcalendar/src/QCalendarMonth.sass';
import { date } from 'quasar';
import { useI18n } from 'vue-i18n';
const props = defineProps({ const props = defineProps({
year: { year: {
@ -13,29 +15,42 @@ const props = defineProps({
month: { month: {
type: Number, type: Number,
required: true, required: true,
} },
}) });
const { locale } = useI18n();
const calendarRef = ref(null); const calendarRef = ref(null);
const selectedDate = ref(today()); const selectedDate = ref(today());
const updateSelectedDate = (year) => {
const dateObject = Date.vnNew();
dateObject.setFullYear(year);
dateObject.setMonth(props.month - 1);
selectedDate.value = date.formatDate(dateObject, 'YYYY-MM-DD');
console.log(date.formatDate(dateObject, 'YYYY-MM-DD'));
};
onBeforeMount(() => { onBeforeMount(() => {
const date = Date.vnNew() updateSelectedDate(props.year);
date.setFullYear(props.year) });
date.setMonth(props.month - 1)
selectedDate.value = date.toDateString() watch(
}) () => props.year,
(newValue) => {
updateSelectedDate(newValue);
}
);
</script> </script>
<template> <template>
{{selectedDate}}
<QCalendarMonth <QCalendarMonth
ref="calendarRef" ref="calendarRef"
v-model="selectedDate" v-model="selectedDate"
v-bind="$attrs"
show-work-weeks show-work-weeks
no-outside-days no-outside-days
:disabled-weekdays="[0,6]" :selected-dates="[]"
:disabled-weekdays="[0, 6]"
:locale="locale"
animated animated
bordered
mini-mode mini-mode
/> />
</template> </template>