GithubHelp home page GithubHelp logo

ineoo / vue-meeting-selector Goto Github PK

View Code? Open in Web Editor NEW
95.0 3.0 20.0 4.65 MB

This component is inspired from the meeting selector from doctolib with the power of Vuejs components.

Home Page: https://vue-meeting-selector.tuturu.io

JavaScript 15.54% HTML 0.92% Vue 60.72% TypeScript 19.94% CSS 2.49% SCSS 0.39%
meeting-selector vuejs vue-component vue-components vue-typescript

vue-meeting-selector's Introduction

This component is inspired from the meeting selector from doctolib with the power of Vuejs components.

Build status Coverage Status

vue-meeting-selector

Dependencies

  • required: Vuejs >= 3.x

Install

npm install vue-meeting-selector --save
yarn add vue-meeting-selector

Include the file in your app

import VueMeetingSelector from 'vue-meeting-selector';
import "vue-meeting-selector/dist/style.css";
import slotsGenerator from "vue-meeting-selector/src/helpers/slotsGenerator";

Contributing

Issues and PR's are much appreciated. When you create a new PR please make it against the develop branch when adding new features and to the fix branch when fixing small issues instead of master.

Usage and Documentation

Fast exemple

<template>
  <vue-meeting-selector
    ref="meetingSelector"
    class="meeting-selector"
    v-model="meeting"
    :date="date"
    :loading="false"
    multi
    :meetings-days="meetingsDays"
    @next-date="nextDate"
    @previous-date="previousDate"
    @update:modelValue="change"
  />
</template>

<script>
import { defineComponent, ref } from "vue";
import VueMeetingSelector from "vue-meeting-selector";
import "vue-meeting-selector/dist/style.css";
import slotsGenerator from "vue-meeting-selector/src/helpers/slotsGenerator";

export default defineComponent({
  components: {
    VueMeetingSelector,
  },
  setup() {
    const meeting = ref([]);
    const meetingsDays = ref([]);
    const nbDaysToDisplay = ref(5);
    const date = ref(new Date());

    const initMeetingsDays = () => {
      const start = {
        hours: 8,
        minutes: 0,
      };
      const end = {
        hours: 16,
        minutes: 0,
      };
      meetingsDays.value = slotsGenerator(
        new Date(),
        nbDaysToDisplay.value,
        start,
        end,
        30
      );
    };

    initMeetingsDays();

    const meetingSelector = ref(null);

    const up = () => meetingSelector.value.previousMeetings();

    const down = () => meetingSelector.value.nextMeetings();

    const nextDate = () => {
      const start = {
        hours: 8,
        minutes: 0,
      };
      const end = {
        hours: 16,
        minutes: 0,
      };
      const d = new Date(date.value);
      const newDate = new Date(d.setDate(d.getDate() + 7));
      date.value = newDate;
      meetingsDays.value = slotsGenerator(
        newDate,
        nbDaysToDisplay.value,
        start,
        end,
        30
      );
    };

    const previousDate = () => {
      const start = {
        hours: 8,
        minutes: 0,
      };
      const end = {
        hours: 16,
        minutes: 0,
      };
      const d = new Date(date.value);
      d.setDate(d.getDate() - 7);
      const formatingDate = (dateToFormat) => {
        const dateParsed = new Date(dateToFormat);
        const day =
          dateParsed.getDate() < 10
            ? `0${dateParsed.getDate()}`
            : dateParsed.getDate();
        const month =
          dateParsed.getMonth() + 1 < 10
            ? `0${dateParsed.getMonth() + 1}`
            : dateParsed.getMonth() + 1;
        const year = dateParsed.getFullYear();
        return `${year}-${month}-${day}`;
      };
      const newDate =
        formatingDate(new Date()) >= formatingDate(d)
          ? new Date()
          : new Date(d);
      date.value = newDate;
      meetingsDays.value = slotsGenerator(
        newDate,
        nbDaysToDisplay.value,
        start,
        end,
        30
      );
    };

    const change = () => {
      console.log(meeting.value);
    };

    return {
      meeting,
      meetingsDays,
      date,
      meetingSelector,
      up,
      down,
      nextDate,
      previousDate,
      change,
    };
  },
});
</script>

Types

interface MeetingSlot {
  date: Date | string;
  [key: string]: any;
}
interface MeetingsDay {
  date: Date | string;
  slots: MeetingSlot[];
  [key: string]: any;
}
interface ClassNames {
  tabClass?: string,
  tabPaginationleft?: string,
  tabPaginationPreviousButton?: string,
  tabPaginationRight?: string,
  tabPaginationNextButton?: string,
  tabPaginationUpButton?: string,
  tabPaginationDownButton?: string,
  tabDays?: string,
  tabDayDisplay?: string,
  tabMeetings?: string,
  tabMeeting?: string,
  tabMeetingButton?: string,
  tabMeetingEmpty?: string,
  tabLoading?: string,
}
// defaults value are available in src/defaults/calendarOptions.ts
interface CalendarOptions {
  daysLabel: string[]; // Labels for days in title, start by sunday
  monthsLabel: string[]; // labels for months in title, start by january
  limit: number, // max nb meetings to display on a same column
  spacing: number, // When clicking next, how many cells do you want to scroll
  loadingLabel: string; // label to display when loading
  disabledDate: Function; // function to disable left button (date is passed as params)
}

Props

Params Type
v-model MeetingSlot | MeetingSlot[]
date Date | string
meetingsDays MeetingsDays[]
calendarOptions Object
classNames Object
multi boolean
loading boolean

Events

Name Params
meeting-slot-selected MeetingSlot | MeetingSlot[]
meeting-slot-unselected -
change MeetingSlot
next-date -
previous-date -

Slots/ScopedSlots available

To change head of every column, a meetings (MeetingsDay) is passed as slot-scope.

<template
  #header="{ meetings }">
  <div>{{ meetings.date }}</div>
</template>

To change the previous/next button.

<template #button-previous>
  <button
    @click="previous">
    previous
  </button>
</template>
<template #button-next>
  <button
    @click="next">
    next
  </button>
</template>

To change up/down button to change hours of meetings, you will have to trigger methods with refs

<template #button-up="{ isDisabled }">
  <button
    :disabled="isDisabled"
    @click="up">
    up
  </button>
</template>
<template
  #button-down="{ isDisabled }">
  <button
    :disabled="isDisabled"
    @click="down">
    down
  </button>
</template>


<script>
export default {
  methods: {
    up() {
      this.$refs.meetingSelector.previousMeetings();
      // (this.$refs.meetingSelector as Vue & { previousMeetings: () => void }).previousMeetings();
    },
    down() {
      this.$refs.meetingSelector.nextMeetings();
      // (this.$refs.meetingSelector as Vue & { nextMeetings: () => void }).nextMeetings();
    },
  },  
};
</script>

To change the display of a meeting. (you will have to manually change the v-model) if the meeting don't have date, it's because the is no meeting. (you will have to handle a different display)

<template
  #meeting="{ meeting }">
  <div>{{ meeting.date }}</div>
</template>

To change the display of loading

<template
  #loading>
  Loading ...
</template>

Project setup

npm install

Compiles and hot-reloads for development component

npm run dev

Compiles and hot-reloads for development doc

npm run doc

Compiles and minifies for production the lib

npm run build:lib

Compiles and minifies for production the doc

npm run build:doc

Run your unit tests

npm run test:unit

Lints and fixes files

npm run lint

Customize configuration

See Configuration Reference.

vue-meeting-selector's People

Contributors

hacknug avatar ineoo avatar marcorivm avatar ravensnowbird avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

vue-meeting-selector's Issues

How to use without Ts

https://codesandbox.io/s/festive-engelbart-8d8pb

You will just have to generate slots like you would do in Ts

in this case slots looks like that

[{
  "date": "2020-10-09T00:00:00.000Z",
  "slots": [{
    "date": "2020-10-09T08:30:00.000Z"
  }, {
    "date": "2020-10-09T09:00:00.000Z"
  }]
}, {
  "date": "2020-10-12T00:00:00.000Z",
  "slots": [{
    "date": "2020-10-12T06:00:00.000Z"
  }, {
    "date": "2020-10-12T06:30:00.000Z"
  }]
}]

you can provide any additional params in slots.

Missing imports with fresh install

Hi !

First, I want to thank you for coding such a package. It looks great!
However, I couldn't get it to work for the moment.
I'm running a Vue 3 project in which I want to add a timeslot reservation system.
I followed the instructions given on your website (npm install + import), and tried to implement your example (https://vue-meeting-selector.tuturu.io/#simpleexample). But when I refresh, I get
image

Did I do something wrong?

Thanks a lot!

how to overide labels for monthLabel and dayLabel

hi it might be a silly question but i'm struggling to overide default labels, how should I implement this settings change?
I've attempted to pass it as a prop, in the data, an attribute parameter, but nothing seems to pick up. thanks for the help.

Uncaught TypeError: Object(...) is not a function error on console

hi
im facing this error on console while adding simple example to the view

app.js:762 Uncaught TypeError: Object(...) is not a function
at Module.fb15 (MeetingDisplay.vue?4fdd:5:1)
at nested_webpack_require_2552 (bootstrap?5c00:19:1)
at module.exports.00ee (bootstrap?5c00:83:1)
at eval (bootstrap?5c00:83:1)
at Object../node_modules/vue-meeting-selector/dist/lib/vue-meeting-selector.common.js (chunk-vendors.js:4155:1)
at webpack_require (app.js:759:33)
at fn (app.js:1010:21)
at eval (index.js??clonedRuleSet-40[0].rules[0].use[0]!./node_modules/@vue/vue-loader-v15/lib/index.js??vue-loader-options!./src/views/Home.vue?vue&type=script&lang=js&:4:78)
at Module../node_modules/babel-loader/lib/index.js??clonedRuleSet-40[0].rules[0].use[0]!./node_modules/@vue/vue-loader-v15/lib/index.js??vue-loader-options!./src/views/Home.vue?vue&type=script&lang=js& (app.js:347:1)
at webpack_require (app.js:759:33)

My dependncies are:
"dependencies": {
"axios": "^0.27.2",
"babel-eslint": "^10.1.0",
"bootstrap": "^5.1.3",
"bootstrap-vue": "^2.22.0",
"core-js": "^3.22.6",
"crypto-js": "^4.1.1",
"express": "^4.18.1",
"lodash": "^4.17.21",
"path": "^0.12.7",
"serve-static": "^1.15.0",
"socket.io-client": "^4.5.1",
"vue": "^2.6.14",
"vue-cookies": "^1.8.1",
"vue-meeting-selector": "^2.0.0-beta-3",
"vue-router": "^3.5.1",
"vue-webrtc": "^3.0.1",
"vuex": "^3.6.2"
},

slotsGenerator setting the date one day before

Using the basic example with
slotsGenerator( newDate, nbDaysToDisplay.value, start, end, 30 );

Will generate this array
[ { date: Date Sun May 15 2022 19:00:00 GMT-0500 (Central Daylight Time), slots: [ { date: Date Mon May 16 2022 15:00:00 GMT-0500 (Central Daylight Time) }, ​​​... ] } ​}, ... ]

As you can see, the first object has a date of Sunday May 15 and the first slot has a date of Monday May 16.
This is causing the days to be one off when selecting them as you can see in the next picture:

Screenshot_2022-05-16_14-47-31

It should be 05/17/2022 09:30:00.

This issue also happens on the official example.

How to select date by default

Hello,

First of all, thank you for your amazing component.

I would like to select a slot by default when component is loaded, I tried to update v-model, it does indeed change the date inside my variable but it doesn't give the selected class to the appropriate button.

Uncaught (in promise) TypeError: Cannot read properties of null (reading 'isCE')

For some reason I get this error in one of my quasar projects when displaying the vue-meeting-selector?
Any ideas how to resolve this?

runtime-core.esm-bundler.js:2819 Uncaught (in promise) TypeError: Cannot read properties of null (reading 'isCE')
    at renderSlot (runtime-core.esm-bundler.js:2819:32)
    at Proxy.fe (vue-meeting-selector.mjs:363:9)
    at renderComponentRoot (runtime-core.esm-bundler.js:816:16)
    at ReactiveEffect.componentUpdateFn [as fn] (runtime-core.esm-bundler.js:5701:46)
    at ReactiveEffect.run (reactivity.esm-bundler.js:178:19)
    at instance.update (runtime-core.esm-bundler.js:5814:51)
    at setupRenderEffect (runtime-core.esm-bundler.js:5822:5)
    at mountComponent (runtime-core.esm-bundler.js:5612:5)
    at processComponent (runtime-core.esm-bundler.js:5565:9)
    at patch (runtime-core.esm-bundler.js:5040:11)
renderSlot @ runtime-core.esm-bundler.js:2819
fe @ vue-meeting-selector.mjs:363
renderComponentRoot @ runtime-core.esm-bundler.js:816
componentUpdateFn @ runtime-core.esm-bundler.js:5701
run @ reactivity.esm-bundler.js:178
instance.update @ runtime-core.esm-bundler.js:5814
setupRenderEffect @ runtime-core.esm-bundler.js:5822
mountComponent @ runtime-core.esm-bundler.js:5612
processComponent @ runtime-core.esm-bundler.js:5565
patch @ runtime-core.esm-bundler.js:5040
mountChildren @ runtime-core.esm-bundler.js:5284
mountElement @ runtime-core.esm-bundler.js:5191
processElement @ runtime-core.esm-bundler.js:5156
patch @ runtime-core.esm-bundler.js:5028
componentUpdateFn @ runtime-core.esm-bundler.js:5708
run @ reactivity.esm-bundler.js:178
instance.update @ runtime-core.esm-bundler.js:5814
setupRenderEffect @ runtime-core.esm-bundler.js:5822
mountComponent @ runtime-core.esm-bundler.js:5612
processComponent @ runtime-core.esm-bundler.js:5565
patch @ runtime-core.esm-bundler.js:5040
mountChildren @ runtime-core.esm-bundler.js:5284
mountElement @ runtime-core.esm-bundler.js:5191
processElement @ runtime-core.esm-bundler.js:5156
patch @ runtime-core.esm-bundler.js:5028
mountChildren @ runtime-core.esm-bundler.js:5284
mountElement @ runtime-core.esm-bundler.js:5191
processElement @ runtime-core.esm-bundler.js:5156
patch @ runtime-core.esm-bundler.js:5028
patchKeyedChildren @ runtime-core.esm-bundler.js:6098
patchChildren @ runtime-core.esm-bundler.js:5879
patchElement @ runtime-core.esm-bundler.js:5332
processElement @ runtime-core.esm-bundler.js:5167
patch @ runtime-core.esm-bundler.js:5028
componentUpdateFn @ runtime-core.esm-bundler.js:5773
run @ reactivity.esm-bundler.js:178
instance.update @ runtime-core.esm-bundler.js:5814
callWithErrorHandling @ runtime-core.esm-bundler.js:158
flushJobs @ runtime-core.esm-bundler.js:357
Promise.then (async)
queueFlush @ runtime-core.esm-bundler.js:270
queueJob @ runtime-core.esm-bundler.js:264
(anonymous) @ runtime-core.esm-bundler.js:5810
triggerEffect @ reactivity.esm-bundler.js:373
triggerEffects @ reactivity.esm-bundler.js:363
trigger @ reactivity.esm-bundler.js:335
set2 @ reactivity.esm-bundler.js:487
set value @ reactivity.esm-bundler.js:1089
set2 @ reactivity.esm-bundler.js:477
set @ pinia.mjs:924
(anonymous) @ places.ts:41
Promise.then (async)
then @ CancelablePromise.ts:96
getPlaceDetails @ places.ts:40
(anonymous) @ pinia.mjs:1375
store.<computed> @ pinia.mjs:930
(anonymous) @ PlaceDetailsPage.vue:57
(anonymous) @ runtime-core.esm-bundler.js:2675
callWithErrorHandling @ runtime-core.esm-bundler.js:158
callWithAsyncErrorHandling @ runtime-core.esm-bundler.js:166
hook.__weh.hook.__weh @ runtime-core.esm-bundler.js:2655
invokeArrayFns @ shared.esm-bundler.js:77
componentUpdateFn @ runtime-core.esm-bundler.js:5657
run @ reactivity.esm-bundler.js:178
instance.update @ runtime-core.esm-bundler.js:5814
setupRenderEffect @ runtime-core.esm-bundler.js:5822
mountComponent @ runtime-core.esm-bundler.js:5612
processComponent @ runtime-core.esm-bundler.js:5565
patch @ runtime-core.esm-bundler.js:5040
componentUpdateFn @ runtime-core.esm-bundler.js:5773
run @ reactivity.esm-bundler.js:178
instance.update @ runtime-core.esm-bundler.js:5814
callWithErrorHandling @ runtime-core.esm-bundler.js:158
flushJobs @ runtime-core.esm-bundler.js:357
Promise.then (async)
queueFlush @ runtime-core.esm-bundler.js:270
queuePostFlushCb @ runtime-core.esm-bundler.js:290
queueEffectWithSuspense @ runtime-core.esm-bundler.js:1603
scheduler @ runtime-core.esm-bundler.js:1773
triggerEffect @ reactivity.esm-bundler.js:373
triggerEffects @ reactivity.esm-bundler.js:363
triggerRefValue @ reactivity.esm-bundler.js:974
(anonymous) @ reactivity.esm-bundler.js:1135
triggerEffect @ reactivity.esm-bundler.js:373
triggerEffects @ reactivity.esm-bundler.js:358
triggerRefValue @ reactivity.esm-bundler.js:974
(anonymous) @ reactivity.esm-bundler.js:1135
triggerEffect @ reactivity.esm-bundler.js:373
triggerEffects @ reactivity.esm-bundler.js:358
triggerRefValue @ reactivity.esm-bundler.js:974
set value @ reactivity.esm-bundler.js:1018
finalizeNavigation @ vue-router.mjs:3353
(anonymous) @ vue-router.mjs:3218
Promise.then (async)
pushWithRedirect @ vue-router.mjs:3185
push @ vue-router.mjs:3110
navigateToRouterLink @ quasar.esm.js:2951
go @ quasar.esm.js:2962
navigateOnClick @ quasar.esm.js:2965
onClick @ quasar.esm.js:16739
callWithErrorHandling @ runtime-core.esm-bundler.js:158
callWithAsyncErrorHandling @ runtime-core.esm-bundler.js:166
invoker @ runtime-dom.esm-bundler.js:278

Uncaught (in promise) TypeError: Cannot read property '_init' of undefined

Hello,
When adding the example code I am getting error in my vite app

vue.runtime.esm.js:5168 Uncaught (in promise) TypeError: Cannot read property '_init' of undefined
at VueMeetingSelector (vue.runtime.esm.js:5168)
at renderComponentRoot (runtime-core.esm-bundler.js:782)
at ReactiveEffect.componentUpdateFn [as fn] (runtime-core.esm-bundler.js:4532)
at ReactiveEffect.run (reactivity.esm-bundler.js:160)
at setupRenderEffect (runtime-core.esm-bundler.js:4657)
at mountComponent (runtime-core.esm-bundler.js:4443)
at processComponent (runtime-core.esm-bundler.js:4401)
at patch (runtime-core.esm-bundler.js:3995)
at mountChildren (runtime-core.esm-bundler.js:4191)
at mountElement (runtime-core.esm-bundler.js:4100)

Select or unselect a meeting by method call

Hiya!

Is there any way to select or unselect an event by hand (i.e. by a method call)?
I want to allow the user to select a maximum of two events. Thus, it would be great if there was a way to unselect the event that was just selected. I didn't find a way to do that in the documentation. Am I missing anything?

Thank you so much and kind regards

How to access meeting.value after meeting-slot-selected is fired?

Hello, im trying to access meeting.value after a slot is selected.

Im using this

@meeting-slot-selected="handler"

and for handler I have this function:

const handler = () => {
  console.log(meeting.value);
};

Whenever I click on a slot I get null printed.

Thanks!

Allow override of empty templates

Hello iNeoO,

i want to remove the button-previous and button-next button from the ui, but with the current approach (slot with if) it does not work.

For example:

  <vue-meeting-selector :date="currentDate" :meetings-days="meetingsDays">
    <template #button-previous/>
    <template #button-next />
  </vue-meeting-selector>

Current Output:

<div class="tab__pagination" :class="cssClass.tabPaginationNext">
    <button type="button" class="tab__pagination__button tab__pagination__button--right" :disabled="loading"
        :class="cssClass.tabPaginationNextButton" @click="nextDate">
        <arrow-icon direction="right" />
    </button>
</div>

Expected Output:

<div class="tab__pagination" :class="cssClass.tabPaginationNext">
</div>

Putting the button into the slot tag would solve this problem, but i did not check if something else would get broken. What is the reason to use <slot if.../> <button v-else /> instead of <slot> <button/> </slot>?

parameterize Skip

Hi, I've been this line of code, that would be great could be parameterized through calendarOptions prop:
https://github.com/iNeoO/vue-meeting-selector/blob/master/src/components/VueMeetingSelector.vue#L158

https://github.com/iNeoO/vue-meeting-selector/blob/master/src/components/VueMeetingSelector.vue#L132

Here when you invoke previousMeetings() and nextMeetings too https://github.com/iNeoO/vue-meeting-selector/blob/master/src/components/VueMeetingSelector.vue#L209 would be great to be able to go 1 by 1 for example

Uncaught TypeError: Cannot read property '_init' of null

I am using javascript. When adding the demo code I am getting below error in my nuxt app.

vue.runtime.esm.js?2b0e:5168 Uncaught TypeError: Cannot read property '_init' of null
    at VueMeetingSelector (vue.runtime.esm.js?2b0e:5168)
    at Function.Vue.use (vue.runtime.esm.js?2b0e:5123)
    at eval (timeslotSelector.js?8003:3)
    at Module../plugins/timeslotSelector.js (app.js:579)
    at __webpack_require__ (runtime.js:854)
    at fn (runtime.js:151)
    at eval (index.js:53)
    at Module../.nuxt/index.js (app.js:239)
    at __webpack_require__ (runtime.js:854)
    at fn (runtime.js:151)

I have created a sample project with the error link github

Nuxt3 css is not loaded

Hi, I've been following documentation example and I found some trouble while installing component, I'm able now to make it build but looks like css is not loaded. Could you please give me any clue how can I finally use this component.

I have no error on console neither network when I inspect browser tab with F12.

This is my component

<template>
    <div class="simple-multi-example">
      <vue-meeting-selector
        class="simple-multi-example__meeting-selector"
        v-model="meeting"
        :date="date"
        :loading="loading"
        :class-names="classNames"
        :meetings-days="meetingsDays"
        :multi="true"
        @next-date="nextDate"
        @previous-date="previousDate"
      />
      <p>meeting Selected: {{ meeting.length ? meeting : 'No Meeting selected' }}</p>
    </div>
  </template>
  
  <script lang="ts">
  import {
    defineComponent,
    onMounted,
    ref,
    computed,
  } from 'vue';
  
  import VueMeetingSelector from 'vue-meeting-selector';
  // Function used to generate slots, use your own function
  import slotsGenerator from '@/helpers/slotsGenerator';
  
  import type MeetingsDay from 'vue-meeting-selector/src/interfaces/MeetingsDay.interface';
  import type MeetingSlot from 'vue-meeting-selector/src/interfaces/MeetingSlot.interface';
  import type Time from 'vue-meeting-selector/src/interfaces/Time.interface';
  
  export default defineComponent({
    name: 'SimpleMultiExample',
    components: {
      VueMeetingSelector,
    },
    setup() {
      const date = ref(new Date());
      const meetingsDays = ref<MeetingsDay[]>([]);
      const meeting = ref<MeetingSlot[]>([]);
      const loading = ref(true);
  
      const nbDaysToDisplay = computed(() => 5);
  
      // because of line-height, font-type you might need to change top value
      const classNames = computed(() => ({
        tabLoading: 'loading-div',
      }));
  
      // juste set async the gettings of meeting to display loading
      const slotsGeneratorAsync = (
        d: Date, // date
        n: number, // nbDaysToDisplay
        start: Time,
        end: Time,
        timesBetween: number,
      ):Promise<MeetingsDay[]> => new Promise((resolve) => {
        setTimeout(() => {
          resolve(slotsGenerator(d, n, start, end, timesBetween));
        }, 1000);
      });
  
      const nextDate = async () => {
        loading.value = true;
        const start: Time = {
          hours: 8,
          minutes: 0,
        };
        const end: Time = {
          hours: 16,
          minutes: 0,
        };
        const dateCopy = new Date(date.value);
        const newDate = new Date(dateCopy.setDate(dateCopy.getDate() + 7));
        date.value = newDate;
        meetingsDays.value = await slotsGeneratorAsync(
          newDate,
          nbDaysToDisplay.value,
          start,
          end,
          30,
        );
        loading.value = false;
      };
  
      const previousDate = async () => {
        loading.value = true;
        const start: Time = {
          hours: 8,
          minutes: 0,
        };
        const end: Time = {
          hours: 16,
          minutes: 0,
        };
        const dateCopy = new Date(date.value);
        dateCopy.setDate(dateCopy.getDate() - 7);
        const formatingDate = (dateToFormat: Date): String => {
          const d = new Date(dateToFormat);
          const day = d.getDate() < 10 ? `0${d.getDate()}` : d.getDate();
          const month = d.getMonth() + 1 < 10 ? `0${d.getMonth() + 1}` : d.getMonth() + 1;
          const year = d.getFullYear();
          return `${year}-${month}-${day}`;
        };
        const newDate = formatingDate(new Date()) >= formatingDate(dateCopy)
          ? new Date()
          : new Date(dateCopy);
        date.value = newDate;
        meetingsDays.value = await slotsGeneratorAsync(
          newDate,
          nbDaysToDisplay.value,
          start,
          end,
          30,
        );
        loading.value = false;
      };
  
      onMounted(async () => {
        const start: Time = {
          hours: 8,
          minutes: 0,
        };
        const end: Time = {
          hours: 16,
          minutes: 0,
        };
        meetingsDays.value = await slotsGeneratorAsync(
          date.value,
          nbDaysToDisplay.value,
          start,
          end,
          30,
        );
        loading.value = false;
      });
  
      return {
        date,
        meetingsDays,
        meeting,
        loading,
        nbDaysToDisplay,
        classNames,
        nextDate,
        previousDate,
      };
    },
  });
  </script>
  
  <style scoped lang="scss">
  .simple-multi-example {
    &__meeting-selector {
      max-width: 542px;
    }
  }
  // since our scss is scoped we need to use ::v-deep
  :deep(.loading-div) {
    top: 58px!important;
  }
  </style>

This my nuxt configuration

export default defineNuxtConfig({
    ssr: false,
    app: {
        head: {
            title: "test",
        },
    },
	css: [ "~/assets/css/main.css"],
	postcss: {
		plugins: {
			tailwindcss: {},
			autoprefixer: {},
		},
	},
    devServer: {
        port: 12345,
    },
    modules: [],
    build: {
    }
})

image

Getting Vue Warn

Hi guys, I am trying trying to get this works too, I added it on Nuxtjs via plugins but I get console errors regarding reactive property.

For instance
[Vue warn]: Property or method "date" is not defined on the instance but referenced during render.
[Vue warn]: Property or method "loading" is not defined on the instance but referenced during render.
[Vue warn]: Property or method "classNames" is not defined on the instance but referenced during render.

and so on ...

I just followed the simple example on https://vue-meeting-selector.tuturu.io/#simpleexample

Any help would be appreciated.

Thanx

nuxt3 - document is not defined

Hi,

Just followed this demo in order to install VueMeetingSelector (^2.0.0-beta-3) on nuxt3 (RC9) and I got this error:

[nuxt] [request error] [unhandled] [500] document is not defined
  at addStyle (./node_modules/vue-meeting-selector/dist/lib/vue-meeting-selector.common.js:1070:22)
  at addStylesToDom (./node_modules/vue-meeting-selector/dist/lib/vue-meeting-selector.common.js:1054:20)
  at addStylesClient (./node_modules/vue-meeting-selector/dist/lib/vue-meeting-selector.common.js:1008:3)
  at Object.c7 (./node_modules/vue-meeting-selector/dist/lib/vue-meeting-selector.common.js:3176:14)
  at __webpack_require__ (./node_modules/vue-meeting-selector/dist/lib/vue-meeting-selector.common.js:21:30)
  at Module.fb15 (./node_modules/vue-meeting-selector/dist/lib/vue-meeting-selector.common.js:4238:18)
  at __webpack_require__ (./node_modules/vue-meeting-selector/dist/lib/vue-meeting-selector.common.js:21:30)
  at ./node_modules/vue-meeting-selector/dist/lib/vue-meeting-selector.common.js:85:18
  at Object.<anonymous> (./node_modules/vue-meeting-selector/dist/lib/vue-meeting-selector.common.js:88:10)
  at Module._compile (node:internal/modules/cjs/loader:1105:14)

Didn't even work even after putting <client-only> around.

Would you please suggest a proper way of solving this?

Thanks,
Keep up the great work

Vue3 + Typescript support

Hello I would be interested with a Vue3 support for this library.

I came across this issue after attempting this #14.

Also there is no .d.ts in exported /dist/lib which makes TypeScript complain with

TS7016: Could not find a declaration file for module 'vue-meeting-selector'

Uncaught TypeError: Super expression must either be null or a function

Hi,
I really want to try out VueMeetingSelector's component but I can't manage to make it work.
I have this error in the console : Uncaught TypeError: Super expression must either be null or a function

I just copied the example codes to work from there, but this error is preventing me from doing this.

I'm using Vue 3.0.0 with TypeScript.
Did I do something wrong ?

New functionality : show more meetings for one date ?

Hi,

Thanks for this plugin!

Is it possible to have an option with a number of meetings to display, or display all meetings?
Or maybe there is a possibility to do it now, but I don't really know how.

We would like to do like Doctolib, with a "See more slots" button :

Capture d’écran 2022-06-01 à 17 10 47

Thank you!

TypeError: Super expression must either be null or a function

I copied pasted the "Fast exemple" and I got this error:

app.js:74403 Uncaught (in promise) TypeError: Super expression must either be null or a function
    at _inherits (app.js:74403:11)
    at app.js:75420:3
    at Module.fb15 (app.js:75488:2)
    at __nested_webpack_require_187__ (app.js:70087:30)
    at app.js:70151:18
    at Object../node_modules/vue-meeting-selector/dist/lib/vue-meeting-selector.common.js (app.js:70154:10)
    at __webpack_require__ (app.js:78998:33)
    at fn (app.js:79250:21)
    at Module../node_modules/babel-loader/lib/index.js??clonedRuleSet-5.use[0]!./node_modules/vue-loader/dist/index.js??ruleSet[0].use[0]!./resources/js/Pages/FlowBooking.vue?vue&type=script&lang=js (app.js:27153:78)
    at __webpack_require__ (app.js:78998:33)

I guess it's because I use Vue 3

How to change data with getMeetings function

After read this issue: #8
the codepen link doesn't work and it would maybe help me i guess.

The component works great but I don't know how to edit the getMeetings(date) function.

Actually I just receive every availabilities of a collaborator by props. But I don't know how to split the different available dates with that function. (create slots and return them)

Actually my function has this, but It just return the entire data. In this case, when I click next page, I just have the same datas:
getMeetings(date) { console.log(date) return this.available },

Here my code https://gist.github.com/jervalles/38fd703a2634d3cd8489585e7bce89b2
I've also paster the test Data (availability of a collaborator)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.