|
1 | 1 | <script setup lang="ts">
|
2 | 2 | import { useCalendarStore } from '@/stores/calendar';
|
3 | 3 | import { storeToRefs } from 'pinia';
|
4 |
| -import { watch } from 'vue'; |
| 4 | +import { computed, ref, watch } from 'vue'; |
5 | 5 |
|
6 | 6 | const calendarStore = useCalendarStore()
|
7 |
| -const { modal } = storeToRefs(calendarStore) |
8 |
| -const { setModal } = calendarStore |
| 7 | +const { modal, getAddedEvents } = storeToRefs(calendarStore) |
| 8 | +const { setModal, setAddedEvents } = calendarStore |
9 | 9 |
|
10 |
| -watch(modal, () => { |
11 |
| - console.log('---', modal.value) |
| 10 | +const eventTitle = ref('') |
| 11 | +const startDateTime = ref<string | Date>( new Date() ) |
| 12 | +const endDateTime = ref<string | Date>( new Date() ) |
| 13 | +const contentText = ref('') |
| 14 | +
|
| 15 | +const titleState = computed(() => (eventTitle.value?.length > 2 ? true : false)) |
| 16 | +
|
| 17 | +const addEvent = () => { |
| 18 | + setAddedEvents({ |
| 19 | + title: eventTitle.value, |
| 20 | + startDataTime: startDateTime.value, |
| 21 | + endDataTime: endDateTime.value, |
| 22 | + contentText: contentText.value |
| 23 | + }, 'add') |
| 24 | +} |
| 25 | +
|
| 26 | +watch(getAddedEvents.value, () => { |
| 27 | + console.log('--->>>>', getAddedEvents.value) |
12 | 28 | })
|
13 | 29 | </script>
|
14 | 30 |
|
15 | 31 | <template>
|
16 | 32 | <teleport to="body">
|
17 | 33 | <div class="modal-wrapper" v-if="modal">
|
18 |
| - <BCard header="Add Event" header-tag="header" footer="Card Footer" footer-tag="footer" |
19 |
| - class="fc-modal text-center bg-white" title="Add Event"> |
20 |
| - <BCardText>Header and footers using props.</BCardText> |
21 |
| - <BButton variant="primary" @click="setModal()">Close</BButton> |
| 34 | + <BCard |
| 35 | + header="Calendar Modal" |
| 36 | + header-tag="header" |
| 37 | + class="fc-modal text-center bg-white fs-5 p-0 min" |
| 38 | + title="Add Event" |
| 39 | + style="min-width: 400px;" |
| 40 | + > |
| 41 | + <BCardBody class="fs-6 pt-0"> |
| 42 | + <div role="group" class="text-start"> |
| 43 | + <BCol cols="12" class="p-1"> |
| 44 | + <label for="title">Title:</label> |
| 45 | + <BFormInput id="title" v-model="eventTitle" placeholder="Enter event title" :state="titleState" trim /> |
| 46 | + <BFormInvalidFeedback id="input-live-feedback"> Enter at least 3 letters </BFormInvalidFeedback> |
| 47 | + </BCol> |
| 48 | + <BCol cols="12" class="p-1"> |
| 49 | + <label for="start">Start:</label> |
| 50 | + <VueDatePicker aria-label="start" v-model="startDateTime" placeholder="Pick the start time" /> |
| 51 | + </BCol> |
| 52 | + <BCol cols="12" class="p-1"> |
| 53 | + <label for="end">Until:</label> |
| 54 | + <VueDatePicker aria-label="end" v-model="endDateTime" placeholder="Pick the End time" /> |
| 55 | + </BCol> |
| 56 | + <BCol cols="12" class="p-1"> |
| 57 | + <BFormTextarea |
| 58 | + id="textarea" |
| 59 | + v-model="contentText" |
| 60 | + placeholder="Enter something..." |
| 61 | + rows="3" |
| 62 | + max-rows="6" |
| 63 | + /> |
| 64 | + </BCol> |
| 65 | + </div> |
| 66 | + |
| 67 | + </BCardBody> |
| 68 | + |
| 69 | + <template v-slot:footer> |
| 70 | + <div tag="footer" class="d-flex justify-content-end"> |
| 71 | + <BButtonGroup> |
| 72 | + <BButton variant="primary" @click="setModal()">Close</BButton> |
| 73 | + <BButton variant="success" @click="addEvent()">Add</BButton> |
| 74 | + </BButtonGroup> |
| 75 | + </div> |
| 76 | + </template> |
22 | 77 | </BCard>
|
23 | 78 | </div>
|
24 | 79 |
|
|
0 commit comments