Files
firefly-iii/frontend/src/components/dashboard/Calendar.vue

110 lines
3.6 KiB
Vue
Raw Normal View History

2020-11-15 14:05:04 +01:00
<!--
- Calendar.vue
- Copyright (c) 2020 james@firefly-iii.org
-
- This file is part of Firefly III (https://github.com/firefly-iii).
-
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU Affero General Public License as
- published by the Free Software Foundation, either version 3 of the
- License, or (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU Affero General Public License for more details.
-
- You should have received a copy of the GNU Affero General Public License
- along with this program. If not, see <https://www.gnu.org/licenses/>.
-->
<template>
<div>
<div class="row">
<div class="col">Start</div>
<div class="col-8">{{ new Intl.DateTimeFormat(locale, {year: 'numeric', month: 'long', day: 'numeric'}).format(range.start) }}</div>
</div>
<div class="row">
<div class="col">End</div>
<div class="col-8">{{ new Intl.DateTimeFormat(locale, {year: 'numeric', month: 'long', day: 'numeric'}).format(range.end) }}</div>
</div>
<date-picker
v-model="range"
mode="date"
rows="2"
is-range
>
<template v-slot="{ inputValue, inputEvents, isDragging, togglePopover }">
2020-12-22 17:22:50 +01:00
<div class="row">
<div class="col">
<div class="btn-group btn-group-sm d-flex">
<button
2021-02-12 20:15:07 +01:00
class="btn btn-secondary btn-sm" :title="$t('firefly.custom_period')"
2020-12-22 17:22:50 +01:00
@click="togglePopover({ placement: 'auto-start', positionFixed:true })"
><i class="fas fa-calendar-alt"></i></button>
<button
class="btn btn-secondary"
2021-02-12 20:15:07 +01:00
:title="$t('firefly.reset_to_current')"
2020-12-22 17:22:50 +01:00
><i class="fas fa-history"></i></button>
2020-11-15 14:05:04 +01:00
2020-12-22 17:22:50 +01:00
<button class="btn btn-secondary dropdown-toggle" type="button" id="dropdownMenuButton" data-toggle="dropdown" aria-haspopup="true"
2021-02-12 20:15:07 +01:00
:title="$t('firefly.select_period')"
2020-12-22 17:22:50 +01:00
aria-expanded="false">
<i class="fas fa-list"></i>
</button>
<div class="dropdown-menu" aria-labelledby="dropdownMenuButton">
<a class="dropdown-item" href="#">(prev period)</a>
<a class="dropdown-item" href="#">(next period)</a>
<a class="dropdown-item" href="#">(this week?)</a>
</div>
2020-11-15 14:05:04 +01:00
2020-12-22 17:22:50 +01:00
</div>
<input type="hidden"
:class="isDragging ? 'text-gray-600' : 'text-gray-900'"
:value="inputValue.start"
v-on="inputEvents.start"
/>
<input type="hidden"
:class="isDragging ? 'text-gray-600' : 'text-gray-900'"
:value="inputValue.end"
v-on="inputEvents.end"
/>
</div>
2020-11-15 14:05:04 +01:00
</div>
</template>
</date-picker>
</div>
</template>
<script>
export default {
name: "Calendar",
2020-12-22 17:22:50 +01:00
created() {
2021-02-12 20:15:07 +01:00
this.locale = localStorage.locale ?? 'en-US';
2020-11-15 14:05:04 +01:00
},
data() {
return {
locale: 'en-US',
range: {
start: new Date(window.sessionStart),
end: new Date(window.sessionEnd),
},
2020-12-22 17:22:50 +01:00
defaultRange: {
start: new Date(window.sessionStart),
end: new Date(window.sessionEnd),
},
2020-11-15 14:05:04 +01:00
};
},
}
</script>
<style scoped>
2020-12-22 17:22:50 +01:00
.dropdown-item {
color: #212529;
}
.dropdown-item:hover {
color: #212529;
}
2020-11-15 14:05:04 +01:00
</style>