aboutsummaryrefslogtreecommitdiffstats
path: root/core/src/components/UnifiedSearch/CustomDateRangeModal.vue
blob: 332a42868631ba144916cd53e4aaf0447a51001e (plain)
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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
<!--
 - SPDX-FileCopyrightText: 2023 Nextcloud GmbH and Nextcloud contributors
 - SPDX-License-Identifier: AGPL-3.0-or-later
-->
<template>
	<NcModal v-if="isModalOpen"
		id="unified-search"
		:name="t('core', 'Custom date range')"
		:show.sync="isModalOpen"
		:size="'small'"
		:clear-view-delay="0"
		:title="t('core', 'Custom date range')"
		@close="closeModal">
		<!-- Custom date range -->
		<div class="unified-search-custom-date-modal">
			<h1>{{ t('core', 'Custom date range') }}</h1>
			<div class="unified-search-custom-date-modal__pickers">
				<NcDateTimePicker :id="'unifiedsearch-custom-date-range-start'"
					v-model="dateFilter.startFrom"
					:label="t('core', 'Pick start date')"
					type="date" />
				<NcDateTimePicker :id="'unifiedsearch-custom-date-range-end'"
					v-model="dateFilter.endAt"
					:label="t('core', 'Pick end date')"
					type="date" />
			</div>
			<div class="unified-search-custom-date-modal__footer">
				<NcButton @click="applyCustomRange">
					{{ t('core', 'Search in date range') }}
					<template #icon>
						<CalendarRangeIcon :size="20" />
					</template>
				</NcButton>
			</div>
		</div>
	</NcModal>
</template>

<script>
import NcButton from '@nextcloud/vue/dist/Components/NcButton.js'
import NcDateTimePicker from '@nextcloud/vue/dist/Components/NcDateTimePickerNative.js'
import NcModal from '@nextcloud/vue/dist/Components/NcModal.js'
import CalendarRangeIcon from 'vue-material-design-icons/CalendarRange.vue'

export default {
	name: 'CustomDateRangeModal',
	components: {
		NcButton,
		NcModal,
		CalendarRangeIcon,
		NcDateTimePicker,
	},
	props: {
		isOpen: {
			type: Boolean,
			required: true,
		},
	},
	data() {
		return {
			dateFilter: { startFrom: null, endAt: null },
		}
	},
	computed: {
		isModalOpen: {
			get() {
				return this.isOpen
			},
			set(value) {
				this.$emit('update:is-open', value)
			},
		},
	},
	methods: {
		closeModal() {
			this.isModalOpen = false
		},
		applyCustomRange() {
			this.$emit('set:custom-date-range', this.dateFilter)
			this.closeModal()
		},
	},
}
</script>

<style lang="scss" scoped>
.unified-search-custom-date-modal {
	padding: 10px 20px 10px 20px;

	h1 {
		font-size: 16px;
		font-weight: bolder;
		line-height: 2em;
	}

	&__pickers {
		display: flex;
		flex-direction: column;
	}

	&__footer {
		display: flex;
		justify-content: end;
	}

}
</style>