forked from area17/twill
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPubAccordion.vue
executable file
·84 lines (79 loc) · 2.79 KB
/
PubAccordion.vue
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
<template>
<a17-accordion :open="open" @toggleVisibility="notifyOpen">
<span slot="accordion__title"><slot></slot></span>
<div slot="accordion__value">
<template v-if="startDate">
{{ startDate | formatCalendarDate }}
</template>
<template v-else>
{{ defaultStartDate }}
</template>
</div>
<div class="accordion__fields">
<a17-datepicker name="publish_date" place-holder="Start Date" :initialValue="startDate" :maxDate="endDate" :enableTime="true" :allowInput="true" :staticMode="true" @open="openStartCalendar" @close="closeCalendar" @input="updateStartDate" :clear="true"></a17-datepicker>
<a17-datepicker name="end_date" place-holder="End Date" :initialValue="endDate" :minDate="startDate" :enableTime="true" :allowInput="true" :staticMode="true" @open="openEndCalendar" @close="closeCalendar" @input="updateEndDate" :clear="true"></a17-datepicker>
</div>
</a17-accordion>
</template>
<script>
import { mapState } from 'vuex'
import { PUBLICATION } from '@/store/mutations'
import a17VueFilters from '@/utils/filters.js'
import a17Accordion from './Accordion.vue'
import VisibilityMixin from '@/mixins/toggleVisibility'
export default {
name: 'A17Pubaccordion',
components: {
'a17-accordion': a17Accordion
},
mixins: [VisibilityMixin],
props: {
defaultStartDate: {
type: String,
default: 'Immediate'
},
defaultEndDate: {
type: String,
default: ''
}
},
filters: a17VueFilters,
computed: {
...mapState({
startDate: state => state.publication.startDate,
endDate: state => state.publication.endDate
})
},
methods: {
updateStartDate: function (newValue) {
this.$store.commit(PUBLICATION.UPDATE_PUBLISH_START_DATE, newValue)
},
updateEndDate: function (newValue) {
this.$store.commit(PUBLICATION.UPDATE_PUBLISH_END_DATE, newValue)
},
notifyOpen: function (newValue) {
this.$emit('open', newValue, this.$options.name)
},
openCalendar: function () {
setTimeout(function () {
const accordions = document.querySelectorAll('.accordion.s--open, .accordion.s--open .accordion__dropdown')
accordions.forEach(function (accordion) {
accordion.style.overflow = 'visible'
})
}, 10)
},
openStartCalendar: function () {
this.openCalendar()
},
openEndCalendar: function () {
this.openCalendar()
},
closeCalendar: function () {
const accordions = document.querySelectorAll('.accordion.s--open, .accordion.s--open .accordion__dropdown')
accordions.forEach(function (accordion) {
accordion.style.overflow = ''
})
}
}
}
</script>