@@ -20,6 +20,8 @@ yarn add vue-meeting-selector
20
20
Include the file in your app
21
21
``` javascript
22
22
import VueMeetingSelector from ' vue-meeting-selector' ;
23
+ import " vue-meeting-selector/dist/style.css" ;
24
+ import slotsGenerator from " vue-meeting-selector/src/helpers/slotsGenerator" ;
23
25
```
24
26
25
27
## Contributing
@@ -32,56 +34,137 @@ When you create a new PR please make it against the develop branch when adding n
32
34
``` html
33
35
<template >
34
36
<vue-meeting-selector
37
+ ref =" meetingSelector"
38
+ class =" meeting-selector"
35
39
v-model =" meeting"
36
40
:date =" date"
37
- :loading =" loading"
41
+ :loading =" false"
42
+ multi
38
43
:meetings-days =" meetingsDays"
39
44
@next-date =" nextDate"
40
- @previous-date =" previousDate" />
45
+ @previous-date =" previousDate"
46
+ @update:modelValue =" change"
47
+ />
41
48
</template >
42
49
43
50
<script >
44
- import VueMeetingSelector from ' vueMeetingSelector' ;
51
+ import { defineComponent , ref } from " vue" ;
52
+ import VueMeetingSelector from " vue-meeting-selector" ;
53
+ import " vue-meeting-selector/dist/style.css" ;
54
+ import slotsGenerator from " vue-meeting-selector/src/helpers/slotsGenerator" ;
45
55
46
- export default {
56
+ export default defineComponent ( {
47
57
components: {
48
58
VueMeetingSelector,
49
59
},
50
- data () {
60
+ setup () {
61
+ const meeting = ref ([]);
62
+ const meetingsDays = ref ([]);
63
+ const nbDaysToDisplay = ref (5 );
64
+ const date = ref (new Date ());
65
+
66
+ const initMeetingsDays = () => {
67
+ const start = {
68
+ hours: 8 ,
69
+ minutes: 0 ,
70
+ };
71
+ const end = {
72
+ hours: 16 ,
73
+ minutes: 0 ,
74
+ };
75
+ meetingsDays .value = slotsGenerator (
76
+ new Date (),
77
+ nbDaysToDisplay .value ,
78
+ start,
79
+ end,
80
+ 30
81
+ );
82
+ };
83
+
84
+ initMeetingsDays ();
85
+
86
+ const meetingSelector = ref (null );
87
+
88
+ const up = () => meetingSelector .value .previousMeetings ();
89
+
90
+ const down = () => meetingSelector .value .nextMeetings ();
91
+
92
+ const nextDate = () => {
93
+ const start = {
94
+ hours: 8 ,
95
+ minutes: 0 ,
96
+ };
97
+ const end = {
98
+ hours: 16 ,
99
+ minutes: 0 ,
100
+ };
101
+ const d = new Date (date .value );
102
+ const newDate = new Date (d .setDate (d .getDate () + 7 ));
103
+ date .value = newDate;
104
+ meetingsDays .value = slotsGenerator (
105
+ newDate,
106
+ nbDaysToDisplay .value ,
107
+ start,
108
+ end,
109
+ 30
110
+ );
111
+ };
112
+
113
+ const previousDate = () => {
114
+ const start = {
115
+ hours: 8 ,
116
+ minutes: 0 ,
117
+ };
118
+ const end = {
119
+ hours: 16 ,
120
+ minutes: 0 ,
121
+ };
122
+ const d = new Date (date .value );
123
+ d .setDate (d .getDate () - 7 );
124
+ const formatingDate = (dateToFormat ) => {
125
+ const dateParsed = new Date (dateToFormat);
126
+ const day =
127
+ dateParsed .getDate () < 10
128
+ ? ` 0${ dateParsed .getDate ()} `
129
+ : dateParsed .getDate ();
130
+ const month =
131
+ dateParsed .getMonth () + 1 < 10
132
+ ? ` 0${ dateParsed .getMonth () + 1 } `
133
+ : dateParsed .getMonth () + 1 ;
134
+ const year = dateParsed .getFullYear ();
135
+ return ` ${ year} -${ month} -${ day} ` ;
136
+ };
137
+ const newDate =
138
+ formatingDate (new Date ()) >= formatingDate (d)
139
+ ? new Date ()
140
+ : new Date (d);
141
+ date .value = newDate;
142
+ meetingsDays .value = slotsGenerator (
143
+ newDate,
144
+ nbDaysToDisplay .value ,
145
+ start,
146
+ end,
147
+ 30
148
+ );
149
+ };
150
+
151
+ const change = () => {
152
+ console .log (meeting .value );
153
+ };
154
+
51
155
return {
52
- date: new Date (' 2020-01-01:01:00' ),
53
- meeting: null ,
54
- loading: false ,
55
- meetingsDays: [],
156
+ meeting,
157
+ meetingsDays,
158
+ date,
159
+ meetingSelector,
160
+ up,
161
+ down,
162
+ nextDate,
163
+ previousDate,
164
+ change,
56
165
};
57
166
},
58
- methods: {
59
- getMeetings (date ) {
60
- // methods who return the meetings
61
- },
62
- async nextDate () {
63
- this .loading = true ;
64
- const date = new Date (this .date );
65
- date .setDate (date .getDate () + 7 );
66
- this .meetingsDays = await this .getMeetings (date);
67
- this .date = date;
68
- this .loading = false ;
69
- },
70
- async previousDate () {
71
- this .loading = true ;
72
- const date = new Date (this .date );
73
- date .setDate (date .getDate () - 7 );
74
- this .meetingsDays = await this .getMeetings (date);
75
- this .date = date;
76
- this .loading = false ;
77
- },
78
- },
79
- async created () {
80
- this .loading = true ;
81
- this .meetingsDays = await this .getMeetings (this .date );
82
- this .loading = false ;
83
- },
84
- };
167
+ });
85
168
</script >
86
169
```
87
170
@@ -118,6 +201,7 @@ interface CalendarOptions {
118
201
daysLabel: string []; // Labels for days in title, start by sunday
119
202
monthsLabel: string []; // labels for months in title, start by january
120
203
limit: number , // max nb meetings to display on a same column
204
+ spacing: number , // When clicking next, how many cells do you want to scroll
121
205
loadingLabel: string ; // label to display when loading
122
206
disabledDate: Function ; // function to disable left button (date is passed as params)
123
207
}
0 commit comments