|
| 1 | +<template> |
| 2 | + <div class="subcontent"> |
| 3 | + <div class="line"> |
| 4 | + The next 4 days after the current day have been disabled with the <code class="example-token">disabled-days</code> property.<br> |
| 5 | + The first example uses an array of dates to disable each specific date.<br> |
| 6 | + The second example uses a range, which is an array within an array of start and end dates.<br> |
| 7 | + </div> |
| 8 | + |
| 9 | + <navigation-bar |
| 10 | + @today="onToday" |
| 11 | + @prev="onPrev" |
| 12 | + @next="onNext" |
| 13 | + /> |
| 14 | + |
| 15 | + <div class="row justify-center"> |
| 16 | + <div class="q-gutter-md" style="display: flex; flex-direction: column; max-width: 800px; width: 90%;"> |
| 17 | + <q-calendar-agenda |
| 18 | + ref="calendar" |
| 19 | + v-model="selectedDate" |
| 20 | + view="week" |
| 21 | + :disabled-days="disabledDays" |
| 22 | + :left-column-options="leftColumnOptions" |
| 23 | + :right-column-options="rightColumnOptions" |
| 24 | + column-options-id="id" |
| 25 | + column-options-label="label" |
| 26 | + :day-min-height="200" |
| 27 | + animated |
| 28 | + bordered |
| 29 | + @change="onChange" |
| 30 | + @moved="onMoved" |
| 31 | + @click-date="onClickDate" |
| 32 | + @click-time="onClickTime" |
| 33 | + @click-interval="onClickInterval" |
| 34 | + @click-head-intervals="onClickHeadIntervals" |
| 35 | + @click-head-day="onClickHeadDay" |
| 36 | + style="max-height: 200px;" |
| 37 | + /> |
| 38 | + <q-calendar-agenda |
| 39 | + ref="calendar2" |
| 40 | + v-model="selectedDate" |
| 41 | + view="week" |
| 42 | + :disabled-days="disabledDaysRange" |
| 43 | + :left-column-options="leftColumnOptions" |
| 44 | + :right-column-options="rightColumnOptions" |
| 45 | + column-options-id="id" |
| 46 | + column-options-label="label" |
| 47 | + :day-min-height="200" |
| 48 | + animated |
| 49 | + bordered |
| 50 | + @change="onChange" |
| 51 | + @moved="onMoved" |
| 52 | + @click-date="onClickDate" |
| 53 | + @click-time="onClickTime" |
| 54 | + @click-interval="onClickInterval" |
| 55 | + @click-head-intervals="onClickHeadIntervals" |
| 56 | + @click-head-day="onClickHeadDay" |
| 57 | + style="max-height: 200px;" |
| 58 | + /> |
| 59 | + </div> |
| 60 | + </div> |
| 61 | + </div> |
| 62 | +</template> |
| 63 | + |
| 64 | +<script> |
| 65 | +import { |
| 66 | + QCalendarAgenda, |
| 67 | + addToDate, |
| 68 | + parseTimestamp, |
| 69 | + today |
| 70 | +} from '@quasar/quasar-ui-qcalendar' |
| 71 | +import '@quasar/quasar-ui-qcalendar/src/QCalendarVariables.sass' |
| 72 | +import '@quasar/quasar-ui-qcalendar/src/QCalendarTransitions.sass' |
| 73 | +import '@quasar/quasar-ui-qcalendar/src/QCalendarAgenda.sass' |
| 74 | +
|
| 75 | +import { defineComponent } from 'vue' |
| 76 | +import NavigationBar from '../components/NavigationBar.vue' |
| 77 | +
|
| 78 | +export default defineComponent({ |
| 79 | + name: 'AgendaDisabledDays', |
| 80 | + components: { |
| 81 | + NavigationBar, |
| 82 | + QCalendarAgenda |
| 83 | + }, |
| 84 | + data () { |
| 85 | + return { |
| 86 | + selectedDate: today(), |
| 87 | + leftColumnOptions: [ |
| 88 | + { |
| 89 | + id: 'overdue', |
| 90 | + label: 'Overdue' |
| 91 | + } |
| 92 | + ], |
| 93 | + rightColumnOptions: [ |
| 94 | + { |
| 95 | + id: 'summary', |
| 96 | + label: 'Summary' |
| 97 | + } |
| 98 | + ] |
| 99 | + } |
| 100 | + }, |
| 101 | + computed: { |
| 102 | + disabledDays () { |
| 103 | + const days = [] |
| 104 | + const ts = parseTimestamp(today()) |
| 105 | + // make next 4 days, after today, disabled |
| 106 | + Array.from(Array(4)).forEach((_, i) => { |
| 107 | + days.push(addToDate(ts, { day: i + 1 }).date) |
| 108 | + }) |
| 109 | + return days |
| 110 | + }, |
| 111 | +
|
| 112 | + disabledDaysRange () { |
| 113 | + // create the range for example 2 |
| 114 | + // Note: this is an array, within an array |
| 115 | + return [[ this.disabledDays[ 0 ], this.disabledDays[ this.disabledDays.length - 1 ] ]] |
| 116 | + } |
| 117 | + }, |
| 118 | + methods: { |
| 119 | + onToday () { |
| 120 | + this.$refs.calendar.moveToToday() |
| 121 | + }, |
| 122 | + onPrev () { |
| 123 | + this.$refs.calendar.prev() |
| 124 | + }, |
| 125 | + onNext () { |
| 126 | + this.$refs.calendar.next() |
| 127 | + }, |
| 128 | +
|
| 129 | + onMoved (data) { |
| 130 | + console.log('onMoved', data) |
| 131 | + }, |
| 132 | + onChange (data) { |
| 133 | + console.log('onChange', data) |
| 134 | + }, |
| 135 | + onClickDate (data) { |
| 136 | + console.log('onClickDate', data) |
| 137 | + }, |
| 138 | + onClickTime (data) { |
| 139 | + console.log('onClickTime', data) |
| 140 | + }, |
| 141 | + onClickInterval (data) { |
| 142 | + console.log('onClickInterval', data) |
| 143 | + }, |
| 144 | + onClickHeadIntervals (data) { |
| 145 | + console.log('onClickHeadIntervals', data) |
| 146 | + }, |
| 147 | + onClickHeadDay (data) { |
| 148 | + console.log('onClickHeadDay', data) |
| 149 | + } |
| 150 | + } |
| 151 | +}) |
| 152 | +</script> |
0 commit comments