mirror of
https://git.joinsharkey.org/Sharkey/Sharkey.git
synced 2024-11-26 16:03:08 +02:00
fix: being able to set birthday into the future
This commit is contained in:
parent
c3f768181a
commit
e1e02a6dbc
2 changed files with 17 additions and 2 deletions
|
@ -62,7 +62,7 @@ const props = defineProps<{
|
||||||
step?: any;
|
step?: any;
|
||||||
datalist?: string[];
|
datalist?: string[];
|
||||||
min?: number;
|
min?: number;
|
||||||
max?: number;
|
max?: number | string;
|
||||||
inline?: boolean;
|
inline?: boolean;
|
||||||
debounce?: boolean;
|
debounce?: boolean;
|
||||||
manualSave?: boolean;
|
manualSave?: boolean;
|
||||||
|
|
|
@ -28,7 +28,7 @@ SPDX-License-Identifier: AGPL-3.0-only
|
||||||
<template #prefix><i class="ph-map-pin ph-bold ph-lg"></i></template>
|
<template #prefix><i class="ph-map-pin ph-bold ph-lg"></i></template>
|
||||||
</MkInput>
|
</MkInput>
|
||||||
|
|
||||||
<MkInput v-model="profile.birthday" type="date" manualSave>
|
<MkInput v-model="profile.birthday" :max="setMaxBirthDate()" type="date" manualSave>
|
||||||
<template #label>{{ i18n.ts.birthday }}</template>
|
<template #label>{{ i18n.ts.birthday }}</template>
|
||||||
<template #prefix><i class="ph-cake ph-bold ph-lg"></i></template>
|
<template #prefix><i class="ph-cake ph-bold ph-lg"></i></template>
|
||||||
</MkInput>
|
</MkInput>
|
||||||
|
@ -134,6 +134,14 @@ const Sortable = defineAsyncComponent(() => import('vuedraggable').then(x => x.d
|
||||||
|
|
||||||
const reactionAcceptance = computed(defaultStore.makeGetterSetter('reactionAcceptance'));
|
const reactionAcceptance = computed(defaultStore.makeGetterSetter('reactionAcceptance'));
|
||||||
|
|
||||||
|
const now = new Date();
|
||||||
|
|
||||||
|
const setMaxBirthDate = () => {
|
||||||
|
const y = now.getFullYear();
|
||||||
|
|
||||||
|
return `${y}-12-31`;
|
||||||
|
};
|
||||||
|
|
||||||
const profile = reactive({
|
const profile = reactive({
|
||||||
name: $i.name,
|
name: $i.name,
|
||||||
description: $i.description,
|
description: $i.description,
|
||||||
|
@ -178,6 +186,13 @@ function saveFields() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function save() {
|
function save() {
|
||||||
|
if (profile.birthday && profile.birthday > setMaxBirthDate()) {
|
||||||
|
os.alert({
|
||||||
|
type: 'warning',
|
||||||
|
text: 'You can\'t set your birthday to the future',
|
||||||
|
});
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
os.apiWithDialog('i/update', {
|
os.apiWithDialog('i/update', {
|
||||||
// 空文字列をnullにしたいので??は使うな
|
// 空文字列をnullにしたいので??は使うな
|
||||||
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
|
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
|
||||||
|
|
Loading…
Reference in a new issue