Skip to content

Commit bae22e3

Browse files
committed
Seitch to nextclouds own date picker
Signed-off-by: Philip Gouverneur <philipgouverneur@gmx.de>
1 parent e91a035 commit bae22e3

File tree

2 files changed

+34
-97
lines changed

2 files changed

+34
-97
lines changed
Lines changed: 17 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -1,75 +1,37 @@
11
<template>
2-
<div class="go-to-date">
3-
<NcButton
4-
class="memories-menu-item"
5-
variant="tertiary-no-background"
6-
:title="t('memories', 'Go to date')"
7-
:aria-label="t('memories', 'Go to date')"
8-
>
9-
<template #icon>
10-
<CalendarSearchIcon :size="20" />
11-
</template>
12-
</NcButton>
13-
<input ref="dateInput" type="date" class="date-input-overlay" @click="constrainRange" @change="onDateSelected" />
14-
</div>
2+
<NcDateTimePicker
3+
v-model="selectedDate"
4+
type="date"
5+
:clearable="false"
6+
:placeholder="t('memories', 'Go to date')"
7+
@change="onDateSelected"
8+
/>
159
</template>
1610

1711
<script lang="ts">
1812
import { defineComponent } from 'vue';
1913
20-
import NcButton from '@nextcloud/vue/dist/Components/NcButton.js';
21-
import CalendarSearchIcon from 'vue-material-design-icons/CalendarSearch.vue';
14+
import NcDateTimePicker from '@nextcloud/vue/dist/Components/NcDateTimePicker.js';
2215
2316
import * as utils from '@services/utils';
2417
2518
export default defineComponent({
2619
name: 'GoToDateMenuItem',
2720
components: {
28-
NcButton,
29-
CalendarSearchIcon,
21+
NcDateTimePicker,
3022
},
3123
32-
methods: {
33-
constrainRange() {
34-
const input = this.$refs.dateInput as HTMLInputElement;
35-
const event = { result: null as { min: Date; max: Date } | null };
36-
utils.bus.emit('memories:timeline:getDateRange', event);
37-
if (event.result) {
38-
input.min = this.toISODate(event.result.min);
39-
input.max = this.toISODate(event.result.max);
40-
}
41-
},
42-
43-
onDateSelected(event: Event) {
44-
const input = event.target as HTMLInputElement;
45-
if (!input.value) return;
24+
data() {
25+
return {
26+
selectedDate: new Date(),
27+
};
28+
},
4629
47-
const date = new Date(input.value + 'T00:00:00Z');
30+
methods: {
31+
onDateSelected(date: Date) {
32+
if (!date) return;
4833
utils.bus.emit('memories:timeline:scrollToDate', date);
49-
50-
input.value = '';
51-
},
52-
53-
toISODate(date: Date): string {
54-
return date.toISOString().split('T')[0];
5534
},
5635
},
5736
});
5837
</script>
59-
60-
<style lang="scss" scoped>
61-
.go-to-date {
62-
position: relative;
63-
}
64-
65-
.date-input-overlay {
66-
position: absolute;
67-
top: 0;
68-
left: 0;
69-
width: 100%;
70-
height: 100%;
71-
opacity: 0;
72-
cursor: pointer;
73-
z-index: 1;
74-
}
75-
</style>

src/components/top-matter/FolderTopMatter.vue

Lines changed: 17 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -54,13 +54,15 @@
5454
</template>
5555
</NcActionButton>
5656

57-
<NcActionButton :aria-label="t('memories', 'Go to date')" @click="openDatePicker()" close-after-click>
58-
{{ t('memories', 'Go to date') }}
59-
<template #icon> <CalendarSearchIcon :size="20" /> </template>
60-
</NcActionButton>
6157
</NcActions>
6258

63-
<input ref="dateInput" type="date" class="date-input-hidden" @change="onDateSelected" />
59+
<NcDateTimePicker
60+
v-model="goToDate"
61+
type="date"
62+
:clearable="false"
63+
:placeholder="t('memories', 'Go to date')"
64+
@change="onDateSelected"
65+
/>
6466
</div>
6567
</div>
6668
</template>
@@ -74,6 +76,7 @@ const NcBreadcrumbs = () => import('@nextcloud/vue/dist/Components/NcBreadcrumbs
7476
const NcBreadcrumb = () => import('@nextcloud/vue/dist/Components/NcBreadcrumb.js');
7577
import NcActions from '@nextcloud/vue/dist/Components/NcActions.js';
7678
import NcActionButton from '@nextcloud/vue/dist/Components/NcActionButton.js';
79+
import NcDateTimePicker from '@nextcloud/vue/dist/Components/NcDateTimePicker.js';
7780
import PublicUploadHandler from '@components/upload/PublicUploadHandler.vue';
7881
7982
import * as utils from '@services/utils';
@@ -84,7 +87,6 @@ import ShareIcon from 'vue-material-design-icons/ShareVariant.vue';
8487
import TimelineIcon from 'vue-material-design-icons/ImageMultiple.vue';
8588
import FoldersIcon from 'vue-material-design-icons/FolderMultiple.vue';
8689
import UploadIcon from 'vue-material-design-icons/Upload.vue';
87-
import CalendarSearchIcon from 'vue-material-design-icons/CalendarSearch.vue';
8890
8991
export default defineComponent({
9092
name: 'FolderTopMatter',
@@ -94,17 +96,23 @@ export default defineComponent({
9496
NcBreadcrumb,
9597
NcActions,
9698
NcActionButton,
99+
NcDateTimePicker,
97100
PublicUploadHandler,
98101
HomeIcon,
99102
ShareIcon,
100103
TimelineIcon,
101104
FoldersIcon,
102105
UploadIcon,
103-
CalendarSearchIcon,
104106
},
105107
106108
mixins: [UserConfig],
107109
110+
data() {
111+
return {
112+
goToDate: new Date(),
113+
};
114+
},
115+
108116
computed: {
109117
list(): {
110118
text: string;
@@ -171,33 +179,9 @@ export default defineComponent({
171179
return (this.$refs.uploadHandler as InstanceType<typeof PublicUploadHandler>) || null;
172180
},
173181
174-
openDatePicker() {
175-
const input = this.$refs.dateInput as HTMLInputElement;
176-
const event = { result: null as { min: Date; max: Date } | null };
177-
utils.bus.emit('memories:timeline:getDateRange', event);
178-
if (event.result) {
179-
input.min = event.result.min.toISOString().split('T')[0];
180-
input.max = event.result.max.toISOString().split('T')[0];
181-
}
182-
183-
// Temporarily make visible for showPicker to work
184-
input.style.width = '1px';
185-
input.style.height = '1px';
186-
try {
187-
input.showPicker();
188-
} catch {
189-
input.click();
190-
}
191-
input.style.width = '';
192-
input.style.height = '';
193-
},
194-
195-
onDateSelected(event: Event) {
196-
const input = event.target as HTMLInputElement;
197-
if (!input.value) return;
198-
const date = new Date(input.value + 'T00:00:00Z');
182+
onDateSelected(date: Date) {
183+
if (!date) return;
199184
utils.bus.emit('memories:timeline:scrollToDate', date);
200-
input.value = '';
201185
},
202186
},
203187
});
@@ -219,14 +203,5 @@ export default defineComponent({
219203
gap: 10px; // Add spacing between actions and progress bar
220204
}
221205
222-
.date-input-hidden {
223-
position: absolute;
224-
width: 0;
225-
height: 0;
226-
overflow: hidden;
227-
border: 0;
228-
padding: 0;
229-
margin: 0;
230-
}
231206
}
232207
</style>

0 commit comments

Comments
 (0)