From 9f90a65c61ea63107abe6103e31cc900768a7c38 Mon Sep 17 00:00:00 2001 From: Odalys Adam Date: Wed, 23 Oct 2024 21:16:54 +0200 Subject: [PATCH 01/31] add max length validation for room title --- src/modules/feature/room/RoomForm.vue | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/modules/feature/room/RoomForm.vue b/src/modules/feature/room/RoomForm.vue index 4d05048e69..b9f3917ea6 100644 --- a/src/modules/feature/room/RoomForm.vue +++ b/src/modules/feature/room/RoomForm.vue @@ -62,7 +62,7 @@ import { computed, PropType, unref } from "vue"; import RoomColorPicker from "./RoomColorPicker/RoomColorPicker.vue"; import { DatePicker } from "@ui-date-time-picker"; import { ErrorObject, useVuelidate } from "@vuelidate/core"; -import { helpers, required } from "@vuelidate/validators"; +import { helpers, required, maxLength } from "@vuelidate/validators"; import { useI18n } from "vue-i18n"; import { RoomCreateParams, RoomUpdateParams } from "@/types/room/Room"; @@ -90,6 +90,7 @@ const onUpdateEndDate = (newDate: string) => { const rules = computed(() => ({ roomData: { name: { + maxLength: maxLength(100), required: helpers.withMessage(t("common.validation.required2"), required), }, }, From e40089f814796206b44cc662b448ecdf28b95898 Mon Sep 17 00:00:00 2001 From: Odalys Adam Date: Mon, 28 Oct 2024 15:01:05 +0100 Subject: [PATCH 02/31] add min date --- src/modules/feature/room/RoomForm.vue | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/modules/feature/room/RoomForm.vue b/src/modules/feature/room/RoomForm.vue index df1bd05e2e..c8e145784f 100644 --- a/src/modules/feature/room/RoomForm.vue +++ b/src/modules/feature/room/RoomForm.vue @@ -23,6 +23,7 @@
props.room); +const todayISO = computed(() => + dayjs.tz(new Date(), "DD.MM.YYYY", "UTC").format(DATETIME_FORMAT.inputDate) +); // Validation const validationRules = computed(() => ({ From 98bbeb24e48cc9c1f8aeb9dcb57d68a1c8be7f5d Mon Sep 17 00:00:00 2001 From: Odalys Adam Date: Fri, 1 Nov 2024 17:17:54 +0100 Subject: [PATCH 03/31] fix vuetify lang key missing warning --- src/locales/schema.ts | 8 +++++- src/plugins/i18n.ts | 29 ++++++++++++++++++--- src/plugins/vuetify.ts | 8 ++++++ tests/test-utils/i18nMock.ts | 4 +-- tests/test-utils/setup/createTestingI18n.ts | 6 ++--- 5 files changed, 45 insertions(+), 10 deletions(-) diff --git a/src/locales/schema.ts b/src/locales/schema.ts index 624098e811..96409b57cd 100644 --- a/src/locales/schema.ts +++ b/src/locales/schema.ts @@ -1,3 +1,9 @@ import deDE from "./de"; +import { de } from "vuetify/locale"; -export type MessageSchema = typeof deDE; +export type MessageSchemaCustom = typeof deDE; +export type MessageSchemaVuetify = { + $vuetify: typeof de; +}; + +export type MessageSchema = MessageSchemaCustom | MessageSchemaVuetify; diff --git a/src/plugins/i18n.ts b/src/plugins/i18n.ts index 099e6264f0..c80fc3b149 100644 --- a/src/plugins/i18n.ts +++ b/src/plugins/i18n.ts @@ -9,14 +9,35 @@ import enGB from "../locales/en"; import esES from "../locales/es"; import ukUA from "../locales/uk"; import { MessageSchema } from "@/locales/schema"; +import { de, en, es, uk } from "vuetify/locale"; declare type SupportedLanguages = "en" | "de" | "es" | "uk"; const messages: Record = { - en: enGB, - de: deDE, - es: esES, - uk: ukUA, + en: { + $vuetify: { + ...en, + }, + ...enGB, + }, + de: { + $vuetify: { + ...de, + }, + ...deDE, + }, + es: { + $vuetify: { + ...es, + }, + ...esES, + }, + uk: { + $vuetify: { + ...uk, + }, + ...ukUA, + }, }; const fileSizeFormat = { diff --git a/src/plugins/vuetify.ts b/src/plugins/vuetify.ts index bf0474172e..855781d4dd 100644 --- a/src/plugins/vuetify.ts +++ b/src/plugins/vuetify.ts @@ -1,10 +1,18 @@ import "@/styles/global.scss"; import { createVuetify } from "vuetify"; +import { createVueI18nAdapter } from "vuetify/locale/adapters/vue-i18n"; +import { useI18n } from "vue-i18n"; +import { createI18n } from "./i18n"; import theme from "@/vuetify.options"; +const i18n = createI18n(); + export default createVuetify({ ...theme, + locale: { + adapter: createVueI18nAdapter({ i18n, useI18n }), + }, defaults: { VAlert: { variant: "tonal" }, VAutocomplete: { color: "primary" }, diff --git a/tests/test-utils/i18nMock.ts b/tests/test-utils/i18nMock.ts index 75e4ba0c0e..7898ac11b2 100644 --- a/tests/test-utils/i18nMock.ts +++ b/tests/test-utils/i18nMock.ts @@ -1,9 +1,9 @@ -import { MessageSchema } from "@/locales/schema"; +import { MessageSchemaCustom } from "@/locales/schema"; import { createMock } from "@golevelup/ts-jest"; export const i18nMock = createMock<{ t: ( - key: keyof MessageSchema, + key: keyof MessageSchemaCustom, placeholders?: Record ) => string; }>({ diff --git a/tests/test-utils/setup/createTestingI18n.ts b/tests/test-utils/setup/createTestingI18n.ts index 57c5f91c19..e6009d99ca 100644 --- a/tests/test-utils/setup/createTestingI18n.ts +++ b/tests/test-utils/setup/createTestingI18n.ts @@ -1,8 +1,8 @@ -import { MessageSchema } from "@/locales/schema"; +import { MessageSchemaCustom } from "@/locales/schema"; import { createI18n } from "vue-i18n"; export const createTestingI18n = (options = {}) => { - const i18n = createI18n({ + const i18n = createI18n({ legacy: false, locale: "en", fallbackLocale: ["en"], @@ -12,7 +12,7 @@ export const createTestingI18n = (options = {}) => { fallbackWarn: false, silentTranslationWarn: true, messages: { - en: {} as MessageSchema, + en: {} as MessageSchemaCustom, }, ...options, }); From 27e3def2d5f1cc46b9cdb71b60a3c7efa56a2074 Mon Sep 17 00:00:00 2001 From: Odalys Adam Date: Sun, 3 Nov 2024 13:54:37 +0100 Subject: [PATCH 04/31] startBeforeEndDate validator --- src/modules/feature/room/RoomForm.vue | 28 ++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/src/modules/feature/room/RoomForm.vue b/src/modules/feature/room/RoomForm.vue index c8e145784f..62a639ad25 100644 --- a/src/modules/feature/room/RoomForm.vue +++ b/src/modules/feature/room/RoomForm.vue @@ -64,7 +64,7 @@