Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix(VCalendar): fix intervalDay slot name #20877

Open
wants to merge 1 commit into
base: feat/v3-calendar-slots-events
Choose a base branch
from

Conversation

CrazyFish08
Copy link

Description

Help implement #19568

Markup:

<template>
  <v-app>
    <v-container>
      <v-row class="fill-height">
    <v-col>
      <v-sheet
      class="d-flex"
      height="54"
      tile
    >
      <v-select
        v-model="type"
        :items="types"
        class="ma-2"
        label="View Mode"
        variant="outlined"
        dense
        hide-details
      ></v-select>
    </v-sheet>
      <v-sheet height="600">
        <v-calendar
          ref="calendar"
          v-model="today"
          :events="events"
          color="primary"
          :view-mode="type"
          :interval-format="formatDate"
          :interval-duration="30"
          :intervals="48"
          @click:event="clickedEvent"
        >
        <template #weekDayCalendarCell="{ props, day, events, dayIndex }">
          <v-calendar-day :day="day" :events="events" @click:event="clickedEvent" />
        </template>
      </v-calendar>
      </v-sheet>
    </v-col>
  </v-row>
    </v-container>
  </v-app>
</template>

<script setup>
  import { onMounted, ref } from 'vue'
  import { useDate } from 'vuetify'

  const calendar = ref()

  const today = ref([new Date()])
  const events = ref([])
  const colors = ['blue', 'indigo', 'deep-purple', 'cyan', 'green', 'orange', 'grey darken-1']
  const names = ['Meeting', 'Holiday', 'PTO', 'Travel', 'Event', 'Birthday', 'Conference', 'Party']
  const type = ref('month');
      const types =  ref(['month', 'week', 'day'])

  const clickedEvent = function (data, event) {
    console.log('clicked Event', event)
  }

  onMounted(() => {
    const adapter = useDate()
    fetchEvents({ start: adapter.startOfDay(adapter.startOfMonth(new Date())), end: adapter.endOfDay(adapter.endOfMonth(new Date())) })
  })
  function fetchEvents ({ start, end }) {
    const _events = []
    const min = start
    const max = end
    const days = (max.getTime() - min.getTime()) / 86400000
    const eventCount = rnd(days, days + 20)
    for (let i = 0; i < eventCount; i++) {
      const allDay = rnd(0, 3) === 0
      const firstTimestamp = rnd(min.getTime(), max.getTime())
      const first = new Date(firstTimestamp - (firstTimestamp % 900000))
      const secondTimestamp = rnd(2, allDay ? 288 : 8) * 900000
      const second = new Date(first.getTime() + secondTimestamp)
      _events.push({
        title: names[rnd(0, names.length - 1)],
        start: first,
        end: second,
        color: colors[rnd(0, colors.length - 1)],
        allDay: allDay,
      })
    }
    events.value = _events
  }
  function rnd (a, b) {
    return Math.floor((b - a + 1) * Math.random()) + a
  }
  function formatDate(value) {
    return value.start.toLocaleTimeString({}, { hour: "2-digit", minute: "2-digit", hour12: true})
  }
</script>

@CrazyFish08 CrazyFish08 changed the base branch from master to feat/v3-calendar-slots-events January 17, 2025 20:12
@CrazyFish08 CrazyFish08 force-pushed the feat/v3-calendar-slots-events--fix-slot-name branch from e6850d9 to a64b27e Compare January 17, 2025 20:37
@blalan05
Copy link
Member

What is the bug? Changing a slot name to a different name based on opinion isn't a fix IMO. weekDayCalendarCell is just as confusing and I think too long. Do you have more substantial reasons for this change?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants