Skip to content

Commit 5271428

Browse files
author
valère pique
committed
Build: Build 3.1.0
1 parent fdd99b9 commit 5271428

File tree

3 files changed

+123
-37
lines changed

3 files changed

+123
-37
lines changed

README.md

+120-36
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ yarn add vue-meeting-selector
2020
Include the file in your app
2121
```javascript
2222
import VueMeetingSelector from 'vue-meeting-selector';
23+
import "vue-meeting-selector/dist/style.css";
24+
import slotsGenerator from "vue-meeting-selector/src/helpers/slotsGenerator";
2325
```
2426

2527
## Contributing
@@ -32,56 +34,137 @@ When you create a new PR please make it against the develop branch when adding n
3234
```html
3335
<template>
3436
<vue-meeting-selector
37+
ref="meetingSelector"
38+
class="meeting-selector"
3539
v-model="meeting"
3640
:date="date"
37-
:loading="loading"
41+
:loading="false"
42+
multi
3843
:meetings-days="meetingsDays"
3944
@next-date="nextDate"
40-
@previous-date="previousDate" />
45+
@previous-date="previousDate"
46+
@update:modelValue="change"
47+
/>
4148
</template>
4249

4350
<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";
4555
46-
export default {
56+
export default defineComponent({
4757
components: {
4858
VueMeetingSelector,
4959
},
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+
51155
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,
56165
};
57166
},
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+
});
85168
</script>
86169
```
87170

@@ -118,6 +201,7 @@ interface CalendarOptions {
118201
daysLabel: string[]; // Labels for days in title, start by sunday
119202
monthsLabel: string[]; // labels for months in title, start by january
120203
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
121205
loadingLabel: string; // label to display when loading
122206
disabledDate: Function; // function to disable left button (date is passed as params)
123207
}

doc/src/components/GettingStarted/WhatSNew.vue

+2
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
</h3>
77
<ul>
88
<li>
9+
<h6>3.1.0</h6>
10+
<p>Add spacing params. When clicking next, scroll a custom number of slots</p>
911
<h6>3.0.0</h6>
1012
<p>Upgrade to vue3, build with vite (need to update readme)</p>
1113
<h6>1.1.0</h6>

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "vue-meeting-selector",
3-
"version": "3.0.3",
3+
"version": "3.1.0",
44
"author": "Valère Pique <[email protected]>",
55
"main": "./dist/lib/vue-meeting-selector.umd.js",
66
"module": "./dist/vue-meeting-selector.mjs",

0 commit comments

Comments
 (0)