mirror of
https://github.com/mayswind/ezbookkeeping.git
synced 2026-05-14 23:17:33 +08:00
support calendar display type (Gregorian and Buddhist)
This commit is contained in:
@@ -14,31 +14,13 @@
|
||||
<span>{{ endDateTime }}</span>
|
||||
</p>
|
||||
<slot></slot>
|
||||
<vue-date-picker inline enable-seconds auto-apply
|
||||
ref="datetimepicker"
|
||||
month-name-format="long"
|
||||
six-weeks="center"
|
||||
class="justify-content-center margin-bottom"
|
||||
:clearable="false"
|
||||
:dark="isDarkMode"
|
||||
:week-start="firstDayOfWeek"
|
||||
:year-range="yearRange"
|
||||
:day-names="dayNames"
|
||||
:year-first="isYearFirst"
|
||||
:is24="is24Hour"
|
||||
:range="{ partialRange: false }"
|
||||
:preset-dates="presetRanges"
|
||||
v-model="dateRange">
|
||||
<template #month="{ text }">
|
||||
{{ getMonthShortName(text) }}
|
||||
</template>
|
||||
<template #month-overlay-value="{ text }">
|
||||
{{ getMonthShortName(text) }}
|
||||
</template>
|
||||
<template #am-pm-button="{ toggle, value }">
|
||||
<button class="dp__pm_am_button" tabindex="0" @click="toggle">{{ tt(`datetime.${value}.content`) }}</button>
|
||||
</template>
|
||||
</vue-date-picker>
|
||||
<date-time-picker ref="datetimepicker"
|
||||
datetime-picker-class="justify-content-center margin-bottom"
|
||||
:is-dark-mode="isDarkMode"
|
||||
:enable-time-picker="true"
|
||||
:preset-dates="presetRanges"
|
||||
v-model="dateRange">
|
||||
</date-time-picker>
|
||||
<f7-button large fill
|
||||
:class="{ 'disabled': !dateRange[0] || !dateRange[1] }"
|
||||
:text="tt('Continue')"
|
||||
@@ -53,17 +35,14 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import DateTimePicker from '@/components/common/DateTimePicker.vue';
|
||||
import { computed, useTemplateRef } from 'vue';
|
||||
import VueDatePicker from '@vuepic/vue-datepicker';
|
||||
|
||||
import { useI18n } from '@/locales/helpers.ts';
|
||||
import { useI18nUIComponents } from '@/lib/ui/mobile.ts';
|
||||
import { type CommonDateRangeSelectionProps, useDateRangeSelectionBase } from '@/components/base/DateRangeSelectionBase.ts';
|
||||
|
||||
import { useEnvironmentsStore } from '@/stores/environment.ts';
|
||||
import { useUserStore } from '@/stores/user.ts';
|
||||
|
||||
import { type WeekDayValue } from '@/core/datetime.ts';
|
||||
|
||||
import {
|
||||
getLocalDatetimeFromUnixTime,
|
||||
@@ -72,7 +51,7 @@ import {
|
||||
getBrowserTimezoneOffsetMinutes
|
||||
} from '@/lib/datetime.ts';
|
||||
|
||||
type VueDatePickerType = InstanceType<typeof VueDatePicker>;
|
||||
type DateTimePickerType = InstanceType<typeof DateTimePicker>;
|
||||
|
||||
const props = defineProps<CommonDateRangeSelectionProps>();
|
||||
const emit = defineEmits<{
|
||||
@@ -80,16 +59,14 @@ const emit = defineEmits<{
|
||||
(e: 'dateRange:change', minUnixTime: number, maxUnixTime: number): void;
|
||||
}>();
|
||||
|
||||
const { tt, getMonthShortName } = useI18n();
|
||||
const { tt } = useI18n();
|
||||
const { showToast } = useI18nUIComponents();
|
||||
const { yearRange, dateRange, dayNames, isYearFirst, is24Hour, beginDateTime, endDateTime, presetRanges, getFinalDateRange } = useDateRangeSelectionBase(props);
|
||||
const { dateRange, beginDateTime, endDateTime, presetRanges, getFinalDateRange } = useDateRangeSelectionBase(props);
|
||||
|
||||
const environmentsStore = useEnvironmentsStore();
|
||||
const userStore = useUserStore();
|
||||
|
||||
const datetimepicker = useTemplateRef<VueDatePickerType>('datetimepicker');
|
||||
const datetimepicker = useTemplateRef<DateTimePickerType>('datetimepicker');
|
||||
const isDarkMode = computed<boolean>(() => environmentsStore.framework7DarkMode || false);
|
||||
const firstDayOfWeek = computed<WeekDayValue>(() => userStore.currentUserFirstDayOfWeek);
|
||||
|
||||
function confirm(): void {
|
||||
try {
|
||||
@@ -121,10 +98,7 @@ function onSheetOpen(): void {
|
||||
}
|
||||
|
||||
window.dispatchEvent(new Event('resize')); // fix vue-datepicker preset max-width
|
||||
|
||||
if (datetimepicker.value) {
|
||||
datetimepicker.value.switchView('calendar');
|
||||
}
|
||||
datetimepicker.value?.switchView('calendar');
|
||||
}
|
||||
|
||||
function onSheetClosed(): void {
|
||||
|
||||
@@ -12,26 +12,12 @@
|
||||
</f7-toolbar>
|
||||
<f7-page-content>
|
||||
<div class="block block-outline no-margin no-padding">
|
||||
<vue-date-picker inline auto-apply
|
||||
month-name-format="long"
|
||||
model-type="yyyy-MM-dd"
|
||||
six-weeks="center"
|
||||
class="justify-content-center"
|
||||
:enable-time-picker="false"
|
||||
:clearable="true"
|
||||
:dark="isDarkMode"
|
||||
:week-start="firstDayOfWeek"
|
||||
:year-range="yearRange"
|
||||
:day-names="dayNames"
|
||||
:year-first="isYearFirst"
|
||||
v-model="dateTime">
|
||||
<template #month="{ text }">
|
||||
{{ getMonthShortName(text) }}
|
||||
</template>
|
||||
<template #month-overlay-value="{ text }">
|
||||
{{ getMonthShortName(text) }}
|
||||
</template>
|
||||
</vue-date-picker>
|
||||
<date-time-picker datetime-picker-class="justify-content-center"
|
||||
:is-dark-mode="isDarkMode"
|
||||
:enable-time-picker="false"
|
||||
:clearable="true"
|
||||
v-model="dateTime">
|
||||
</date-time-picker>
|
||||
</div>
|
||||
</f7-page-content>
|
||||
</f7-sheet>
|
||||
@@ -43,11 +29,13 @@ import { ref, computed } from 'vue';
|
||||
import { useI18n } from '@/locales/helpers.ts';
|
||||
|
||||
import { useEnvironmentsStore } from '@/stores/environment.ts';
|
||||
import { useUserStore } from '@/stores/user.ts';
|
||||
|
||||
import { type TextualYearMonthDay, type WeekDayValue } from '@/core/datetime.ts';
|
||||
import { arrangeArrayWithNewStartIndex } from '@/lib/common.ts';
|
||||
import { getAllowedYearRange } from '@/lib/datetime.ts';
|
||||
import { type TextualYearMonthDay } from '@/core/datetime.ts';
|
||||
|
||||
import {
|
||||
getLocalDateFromYearDashMonthDashDay,
|
||||
getGregorianCalendarYearAndMonthFromLocalDate
|
||||
} from '@/lib/datetime.ts';
|
||||
|
||||
const props = defineProps<{
|
||||
modelValue?: TextualYearMonthDay;
|
||||
@@ -55,35 +43,30 @@ const props = defineProps<{
|
||||
}>();
|
||||
|
||||
const emit = defineEmits<{
|
||||
(e: 'update:modelValue', value: TextualYearMonthDay): void;
|
||||
(e: 'update:modelValue', value: TextualYearMonthDay | ''): void;
|
||||
(e: 'update:show', value: boolean): void;
|
||||
}>();
|
||||
|
||||
const { tt, getAllMinWeekdayNames, getMonthShortName, isLongDateMonthAfterYear } = useI18n();
|
||||
const { tt } = useI18n();
|
||||
|
||||
const environmentsStore = useEnvironmentsStore();
|
||||
const userStore = useUserStore();
|
||||
|
||||
const yearRange = ref<number[]>(getAllowedYearRange());
|
||||
const dateTime = ref<string>('');
|
||||
const dateTime = ref<Date | null>(null);
|
||||
|
||||
const isDarkMode = computed<boolean>(() => environmentsStore.framework7DarkMode || false);
|
||||
const firstDayOfWeek = computed<WeekDayValue>(() => userStore.currentUserFirstDayOfWeek);
|
||||
const dayNames = computed<string[]>(() => arrangeArrayWithNewStartIndex(getAllMinWeekdayNames(), firstDayOfWeek.value));
|
||||
const isYearFirst = computed<boolean>(() => isLongDateMonthAfterYear());
|
||||
|
||||
function clear(): void {
|
||||
dateTime.value = '';
|
||||
dateTime.value = null;
|
||||
confirm();
|
||||
}
|
||||
|
||||
function confirm(): void {
|
||||
emit('update:modelValue', dateTime.value as TextualYearMonthDay);
|
||||
emit('update:modelValue', dateTime.value ? getGregorianCalendarYearAndMonthFromLocalDate(dateTime.value) : '');
|
||||
emit('update:show', false);
|
||||
}
|
||||
|
||||
function onSheetOpen(): void {
|
||||
dateTime.value = props.modelValue ?? '';
|
||||
dateTime.value = props.modelValue ? getLocalDateFromYearDashMonthDashDay(props.modelValue) : null;
|
||||
}
|
||||
|
||||
function onSheetClosed(): void {
|
||||
|
||||
@@ -12,27 +12,13 @@
|
||||
</f7-toolbar>
|
||||
<f7-page-content class="padding-bottom">
|
||||
<div class="block block-outline no-margin no-padding">
|
||||
<vue-date-picker inline enable-seconds auto-apply
|
||||
ref="datetimepicker"
|
||||
month-name-format="long"
|
||||
six-weeks="center"
|
||||
class="justify-content-center"
|
||||
:enable-time-picker="false"
|
||||
:clearable="false"
|
||||
:dark="isDarkMode"
|
||||
:week-start="firstDayOfWeek"
|
||||
:year-range="yearRange"
|
||||
:day-names="dayNames"
|
||||
:year-first="isYearFirst"
|
||||
v-model="dateTime"
|
||||
v-show="mode === 'date'">
|
||||
<template #month="{ text }">
|
||||
{{ getMonthShortName(text) }}
|
||||
</template>
|
||||
<template #month-overlay-value="{ text }">
|
||||
{{ getMonthShortName(text) }}
|
||||
</template>
|
||||
</vue-date-picker>
|
||||
<date-time-picker ref="datetimepicker"
|
||||
datetime-picker-class="justify-content-center"
|
||||
:is-dark-mode="isDarkMode"
|
||||
:enable-time-picker="false"
|
||||
v-model="dateTime"
|
||||
v-show="mode === 'date'">
|
||||
</date-time-picker>
|
||||
</div>
|
||||
<div class="block block-outline no-margin no-padding padding-vertical-half" v-show="mode === 'time'">
|
||||
<div id="time-picker-container" class="time-picker-container">
|
||||
@@ -115,8 +101,8 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import DateTimePicker from '@/components/common/DateTimePicker.vue';
|
||||
import { ref, computed, nextTick, useTemplateRef, watch } from 'vue';
|
||||
import VueDatePicker from '@vuepic/vue-datepicker';
|
||||
|
||||
import { useI18n } from '@/locales/helpers.ts';
|
||||
import { useI18nUIComponents } from '@/lib/ui/mobile.ts';
|
||||
@@ -137,7 +123,7 @@ import {
|
||||
getCombinedDateAndTimeValues
|
||||
} from '@/lib/datetime.ts';
|
||||
|
||||
type VueDatePickerType = InstanceType<typeof VueDatePicker>;
|
||||
type DateTimePickerType = InstanceType<typeof DateTimePicker>;
|
||||
|
||||
const props = defineProps<{
|
||||
modelValue: number;
|
||||
@@ -150,11 +136,7 @@ const emit = defineEmits<{
|
||||
(e: 'update:show', value: boolean): void;
|
||||
}>();
|
||||
|
||||
const {
|
||||
tt,
|
||||
getMonthShortName,
|
||||
formatUnixTimeToLongDateTime
|
||||
} = useI18n();
|
||||
const { tt, formatUnixTimeToLongDateTime } = useI18n();
|
||||
const { showToast } = useI18nUIComponents();
|
||||
|
||||
const {
|
||||
@@ -163,11 +145,7 @@ const {
|
||||
isMinuteTwoDigits,
|
||||
isSecondTwoDigits,
|
||||
isMeridiemIndicatorFirst,
|
||||
yearRange,
|
||||
meridiemItems,
|
||||
firstDayOfWeek,
|
||||
dayNames,
|
||||
isYearFirst,
|
||||
getDisplayTimeValue,
|
||||
generateAllHours,
|
||||
generateAllMinutesOrSeconds
|
||||
@@ -175,7 +153,7 @@ const {
|
||||
|
||||
const environmentsStore = useEnvironmentsStore();
|
||||
|
||||
const datetimepicker = useTemplateRef<VueDatePickerType>('datetimepicker');
|
||||
const datetimepicker = useTemplateRef<DateTimePickerType>('datetimepicker');
|
||||
|
||||
let resetTimePickerItemPositionItemsClass: string | undefined = undefined;
|
||||
let resetTimePickerItemPositionItemClass: string | undefined = undefined;
|
||||
@@ -455,9 +433,7 @@ function onSheetOpen(): void {
|
||||
});
|
||||
}
|
||||
|
||||
if (datetimepicker.value) {
|
||||
datetimepicker.value.switchView('calendar');
|
||||
}
|
||||
datetimepicker.value?.switchView('calendar');
|
||||
}
|
||||
|
||||
function onSheetClosed(): void {
|
||||
@@ -465,8 +441,8 @@ function onSheetClosed(): void {
|
||||
}
|
||||
|
||||
watch(mode, (newValue) => {
|
||||
if (newValue === 'date' && datetimepicker.value) {
|
||||
datetimepicker.value.switchView('calendar');
|
||||
if (newValue === 'date') {
|
||||
datetimepicker.value?.switchView('calendar');
|
||||
} else if (newValue === 'time') {
|
||||
nextTick(() => {
|
||||
initTimePickerStyle();
|
||||
|
||||
@@ -12,29 +12,16 @@
|
||||
</f7-toolbar>
|
||||
<f7-page-content>
|
||||
<div class="block block-outline no-margin no-padding">
|
||||
<vue-date-picker inline auto-apply disable-year-select
|
||||
month-name-format="long"
|
||||
model-type="MM-dd"
|
||||
six-weeks="center"
|
||||
class="justify-content-center"
|
||||
:config="{ noSwipe: true }"
|
||||
:month-change-on-scroll="false"
|
||||
:enable-time-picker="false"
|
||||
:min-date="allowedMinDate"
|
||||
:max-date="allowedMaxDate"
|
||||
:disabled-dates="disabledDates"
|
||||
:clearable="false"
|
||||
:dark="isDarkMode"
|
||||
:week-start="firstDayOfWeek"
|
||||
:day-names="dayNames"
|
||||
v-model="selectedFiscalYearStartValue">
|
||||
<template #month="{ text }">
|
||||
{{ getMonthShortName(text) }}
|
||||
</template>
|
||||
<template #month-overlay-value="{ text }">
|
||||
{{ getMonthShortName(text) }}
|
||||
</template>
|
||||
</vue-date-picker>
|
||||
<date-time-picker datetime-picker-class="justify-content-center"
|
||||
:is-dark-mode="isDarkMode"
|
||||
:enable-time-picker="false"
|
||||
:disable-year-select="true"
|
||||
:no-swipe-and-scroll="true"
|
||||
:min-date="allowedMinDate"
|
||||
:max-date="allowedMaxDate"
|
||||
:disabled-dates="disabledDates"
|
||||
v-model="selectedFiscalYearStartValue">
|
||||
</date-time-picker>
|
||||
</div>
|
||||
</f7-page-content>
|
||||
</f7-sheet>
|
||||
@@ -67,7 +54,7 @@ interface MobileFiscalYearStartSelectionSheetEmits extends CommonFiscalYearStart
|
||||
const props = defineProps<MobileFiscalYearStartSelectionSheetProps>();
|
||||
const emit = defineEmits<MobileFiscalYearStartSelectionSheetEmits>();
|
||||
|
||||
const { tt, getMonthShortName } = useI18n();
|
||||
const { tt } = useI18n();
|
||||
|
||||
const environmentsStore = useEnvironmentsStore();
|
||||
const userStore = useUserStore();
|
||||
@@ -78,8 +65,6 @@ const {
|
||||
selectedFiscalYearStartValue,
|
||||
allowedMinDate,
|
||||
allowedMaxDate,
|
||||
firstDayOfWeek,
|
||||
dayNames
|
||||
} = useFiscalYearStartSelectionBase(props);
|
||||
|
||||
const isDarkMode = computed<boolean>(() => environmentsStore.framework7DarkMode || false);
|
||||
|
||||
@@ -14,22 +14,8 @@
|
||||
<span>{{ endDateTime }}</span>
|
||||
</p>
|
||||
<slot></slot>
|
||||
<vue-date-picker inline month-picker auto-apply
|
||||
month-name-format="long"
|
||||
class="justify-content-center margin-bottom"
|
||||
:clearable="false"
|
||||
:dark="isDarkMode"
|
||||
:year-range="yearRange"
|
||||
:year-first="isYearFirst"
|
||||
:range="{ partialRange: false }"
|
||||
v-model="dateRange">
|
||||
<template #month="{ text }">
|
||||
{{ getMonthShortName(text) }}
|
||||
</template>
|
||||
<template #month-overlay-value="{ text }">
|
||||
{{ getMonthShortName(text) }}
|
||||
</template>
|
||||
</vue-date-picker>
|
||||
<month-picker month-picker-class="justify-content-center margin-bottom"
|
||||
:is-dark-mode="isDarkMode" v-model="dateRange"></month-picker>
|
||||
<f7-button large fill
|
||||
:class="{ 'disabled': !dateRange[0] || !dateRange[1] }"
|
||||
:text="tt('Continue')"
|
||||
@@ -54,15 +40,17 @@ import { useEnvironmentsStore } from '@/stores/environment.ts';
|
||||
|
||||
import { type TextualYearMonth } from '@/core/datetime.ts';
|
||||
|
||||
import { getYear0BasedMonthObjectFromString } from '@/lib/datetime.ts';
|
||||
|
||||
const props = defineProps<CommonMonthRangeSelectionProps>();
|
||||
const emit = defineEmits<{
|
||||
(e: 'update:show', value: boolean): void;
|
||||
(e: 'dateRange:change', minYearMonth: TextualYearMonth | '', maxYearMonth: TextualYearMonth | ''): void;
|
||||
}>();
|
||||
|
||||
const { tt, getMonthShortName } = useI18n();
|
||||
const { tt } = useI18n();
|
||||
const { showToast } = useI18nUIComponents();
|
||||
const { yearRange, dateRange, isYearFirst, beginDateTime, endDateTime, getMonthSelectionValue, getFinalMonthRange } = useMonthRangeSelectionBase(props);
|
||||
const { dateRange, beginDateTime, endDateTime, getFinalMonthRange } = useMonthRangeSelectionBase(props);
|
||||
|
||||
const environmentsStore = useEnvironmentsStore();
|
||||
|
||||
@@ -90,7 +78,7 @@ function cancel(): void {
|
||||
|
||||
function onSheetOpen(): void {
|
||||
if (props.minTime) {
|
||||
const yearMonth = getMonthSelectionValue(props.minTime);
|
||||
const yearMonth = getYear0BasedMonthObjectFromString(props.minTime);
|
||||
|
||||
if (yearMonth) {
|
||||
dateRange.value[0] = yearMonth;
|
||||
@@ -98,7 +86,7 @@ function onSheetOpen(): void {
|
||||
}
|
||||
|
||||
if (props.maxTime) {
|
||||
const yearMonth = getMonthSelectionValue(props.maxTime);
|
||||
const yearMonth = getYear0BasedMonthObjectFromString(props.maxTime);
|
||||
|
||||
if (yearMonth) {
|
||||
dateRange.value[1] = yearMonth;
|
||||
|
||||
@@ -9,21 +9,8 @@
|
||||
<div class="padding-horizontal padding-bottom">
|
||||
<p class="no-margin-top" v-if="hint">{{ hint }}</p>
|
||||
<slot></slot>
|
||||
<vue-date-picker inline month-picker auto-apply
|
||||
month-name-format="long"
|
||||
class="justify-content-center margin-bottom"
|
||||
:clearable="false"
|
||||
:dark="isDarkMode"
|
||||
:year-range="yearRange"
|
||||
:year-first="isYearFirst"
|
||||
v-model="monthValue">
|
||||
<template #month="{ text }">
|
||||
{{ getMonthShortName(text) }}
|
||||
</template>
|
||||
<template #month-overlay-value="{ text }">
|
||||
{{ getMonthShortName(text) }}
|
||||
</template>
|
||||
</vue-date-picker>
|
||||
<month-picker month-picker-class="justify-content-center margin-bottom"
|
||||
:is-dark-mode="isDarkMode" v-model="monthValue"></month-picker>
|
||||
<f7-button large fill
|
||||
:class="{ 'disabled': !monthValue }"
|
||||
:text="tt('Continue')"
|
||||
@@ -38,43 +25,43 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { computed } from 'vue';
|
||||
import { ref, computed } from 'vue';
|
||||
|
||||
import { useI18n } from '@/locales/helpers.ts';
|
||||
import { useI18nUIComponents } from '@/lib/ui/mobile.ts';
|
||||
import { type CommonMonthSelectionProps, useMonthSelectionBase } from '@/components/base/MonthSelectionBase.ts';
|
||||
|
||||
import type { Year0BasedMonth } from '@/core/datetime.ts';
|
||||
import { useEnvironmentsStore } from '@/stores/environment.ts';
|
||||
|
||||
const props = defineProps<CommonMonthSelectionProps>();
|
||||
import { getYear0BasedMonthObjectFromUnixTime, getThisMonthFirstUnixTime } from '@/lib/datetime.ts';
|
||||
|
||||
const props = defineProps<{
|
||||
modelValue?: Year0BasedMonth;
|
||||
title?: string;
|
||||
hint?: string;
|
||||
show: boolean;
|
||||
}>();
|
||||
|
||||
const emit = defineEmits<{
|
||||
(e: 'update:modelValue', value: Year0BasedMonth): void;
|
||||
(e: 'update:show', value: boolean): void;
|
||||
}>();
|
||||
|
||||
const { tt, getMonthShortName } = useI18n();
|
||||
const { tt } = useI18n();
|
||||
const { showToast } = useI18nUIComponents();
|
||||
const { yearRange, monthValue, isYearFirst, getMonthSelectionValue, getYear0BasedMonth } = useMonthSelectionBase(props);
|
||||
|
||||
const environmentsStore = useEnvironmentsStore();
|
||||
|
||||
const monthValue = ref<Year0BasedMonth>(getYear0BasedMonthObjectFromUnixTime(getThisMonthFirstUnixTime()));
|
||||
const isDarkMode = computed<boolean>(() => environmentsStore.framework7DarkMode || false);
|
||||
|
||||
function confirm(): void {
|
||||
try {
|
||||
const finalMonthRange = getYear0BasedMonth();
|
||||
|
||||
if (!finalMonthRange) {
|
||||
return;
|
||||
}
|
||||
|
||||
emit('update:modelValue', finalMonthRange);
|
||||
} catch (ex: unknown) {
|
||||
if (ex instanceof Error) {
|
||||
showToast(ex.message);
|
||||
}
|
||||
if (monthValue.value.year <= 0 || monthValue.value.month0base < 0) {
|
||||
showToast('Date is too early');
|
||||
return;
|
||||
}
|
||||
|
||||
emit('update:modelValue', monthValue.value);
|
||||
}
|
||||
|
||||
function cancel(): void {
|
||||
@@ -83,11 +70,7 @@ function cancel(): void {
|
||||
|
||||
function onSheetOpen(): void {
|
||||
if (props.modelValue) {
|
||||
const yearMonth = getMonthSelectionValue(props.modelValue);
|
||||
|
||||
if (yearMonth) {
|
||||
monthValue.value = yearMonth;
|
||||
}
|
||||
monthValue.value = props.modelValue;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user