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

feat(VCalendar): port to v3 #15038

Closed
wants to merge 24 commits into from
Closed

feat(VCalendar): port to v3 #15038

wants to merge 24 commits into from

Conversation

blalan05
Copy link
Member

@blalan05 blalan05 commented May 4, 2022

Markup:

<template>
  <v-app full-height>
    <div>
      <v-sheet tile height="54" class="d-flex">
        <v-btn icon class="ma-2" @click="calendar.prev()">
          <v-icon>mdi-chevron-left</v-icon>
        </v-btn>
        <v-select
          v-model="type"
          :items="types"
          dense
          outlined
          hide-details
          class="ma-2"
          label="type"
        />
        <v-select
          v-model="mode"
          :items="modes"
          dense
          outlined
          hide-details
          label="event-overlap-mode"
          class="ma-2"
        />
        <v-select
          v-model="weekday"
          :items="weekdays"
          dense
          outlined
          hide-details
          label="weekdays"
          class="ma-2"
        />
        <v-btn color="primary" @click="getEvents({ start, end })">
          Get Events
        </v-btn>
        <v-spacer />
        <v-btn icon class="ma-2" @click="calendar.next()">
          <v-icon>mdi-chevron-right</v-icon>
        </v-btn>
      </v-sheet>
      <v-sheet height="600">
        <v-calendar
          ref="calendar"
          :categories="names"
          v-model="value"
          :weekdays="weekday"
          :start="start"
          :end="end"
          :type="type"
          :events="events"
          :event-overlap-mode="mode"
          :event-overlap-threshold="30"
          :event-color="getEventColor"
          @change="getEvents"
        />
      </v-sheet>
    </div>
  </v-app>
</template>

<script>
  import { ref } from 'vue'

  export default {
    setup(props, context) {
      const calendar = ref(null)
      const start = '2022-05-01'
      const end = '2022-05-31'
      const type = ref('month')
      const types = ['month', 'week', 'day', '4day', 'category']
      const mode = ref('stack')
      const events = ref([])
      const modes = ['stack', 'column']
      const weekday = ref([0, 1, 2, 3, 4, 5, 6])
      const weekdays = [
        { title: 'Sun - Sat', value: [0, 1, 2, 3, 4, 5, 6] },
        { title: 'Mon - Sun', value: [1, 2, 3, 4, 5, 6, 0] },
        { title: 'Mon - Fri', value: [1, 2, 3, 4, 5] },
        { title: 'Mon, Wed, Fri', value: [1, 3, 5] },
      ]
      const value = ref('')
      const colors = [
        'blue',
        'indigo',
        'deep-purple',
        'cyan',
        'green',
        'orange',
        'grey darken-1',
      ]
      const names = [
        'Meeting',
        'Holiday',
        'PTO',
        'Travel',
        'Event',
        'Birthday',
        'Conference',
        'Party',
      ]

      const getEvents = ({ start, end }) => {
        const min = new Date(`${start}T00:00:00`)
        const max = new Date(`${end}T23:59:59`)
        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)
          const name = names[rnd(0, names.length - 1)]

          events.value.push({
            name,
            category: name,
            start: first,
            end: second,
            color: colors[rnd(0, colors.length - 1)],
            timed: !allDay,
          })
        }
      }
      const getEventColor = event => {
        return event.color
      };
      const rnd = (a, b) => {
        return Math.floor((b - a + 1) * Math.random()) + a
      };

      return {
        calendar,
        start,
        end,
        type,
        types,
        mode,
        modes,
        weekday,
        weekdays,
        value,
        events,
        colors,
        names,
        getEvents,
        getEventColor,
        rnd,
      }
    },
  }
</script>

@blalan05 blalan05 changed the base branch from dev to master February 22, 2023 03:02
@johnleider johnleider changed the title Feat/v3 calendar feat(VCalendar): port to v3 Feb 22, 2023
@septatrix
Copy link

I see you, @blalan05, have been working on this a few weeks ago. Would you mind giving a rough status update how far you are with the porting or which parts do and do not work yet?

Also for bookkeeping:
fixes #13469

@MajesticPotatoe
Copy link
Member

closed in favor of #16803

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C: VCalendar VCalendar T: feature A new feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Task] v-calendar
5 participants