From f90665cce9c887ad726b7a6f57377de721816ee7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ars=C3=A8ne=20Reymond?= <66876397+p0lycarpio@users.noreply.github.com> Date: Tue, 9 Sep 2025 19:21:58 +0200 Subject: [PATCH] feat: Improve first time setup ux (#6106) --- .../Domain/User/UserPasswordStrength.vue | 2 +- .../Domain/User/UserRegistrationForm.vue | 4 +- frontend/components/global/AppLogo.vue | 48 + frontend/components/global/AutoForm.vue | 78 +- frontend/components/global/BaseWizard.vue | 293 ----- frontend/pages/admin/setup.vue | 1014 +++++++++-------- frontend/pages/login.vue | 21 +- frontend/pages/register/index.vue | 20 +- frontend/types/components.d.ts | 4 +- 9 files changed, 662 insertions(+), 822 deletions(-) create mode 100644 frontend/components/global/AppLogo.vue delete mode 100644 frontend/components/global/BaseWizard.vue diff --git a/frontend/components/Domain/User/UserPasswordStrength.vue b/frontend/components/Domain/User/UserPasswordStrength.vue index 4e05d76c2..a4871ad14 100644 --- a/frontend/components/Domain/User/UserPasswordStrength.vue +++ b/frontend/components/Domain/User/UserPasswordStrength.vue @@ -1,5 +1,5 @@ + + + + diff --git a/frontend/components/global/AutoForm.vue b/frontend/components/global/AutoForm.vue index 95869f38b..27792d8ba 100644 --- a/frontend/components/global/AutoForm.vue +++ b/frontend/components/global/AutoForm.vue @@ -33,9 +33,10 @@ @@ -70,9 +71,9 @@ @@ -89,12 +90,11 @@ @@ -127,7 +127,7 @@ +
@@ -150,7 +151,7 @@

@@ -160,15 +161,15 @@ class="ml-5" x-small delete - @click="removeByIndex(modelValue[inputField.varName], idx)" + @click="removeByIndex(model[inputField.varName], idx)" />

@@ -176,7 +177,7 @@ {{ $t("general.new") }} @@ -197,7 +198,13 @@ const BLUR_EVENT = "blur"; type ValidatorKey = keyof typeof validators; // Use defineModel for v-model -const modelValue = defineModel<[object, Array]>(); +const modelValue = defineModel | any[]>({ + type: [Object, Array], + required: true, +}); + +// alias to avoid template TS complaining about possible undefined +const model = modelValue as any; const props = defineProps({ updateMode: { @@ -238,26 +245,39 @@ const emit = defineEmits(["blur", "update:modelValue"]); function rulesByKey(keys?: ValidatorKey[] | null) { if (keys === undefined || keys === null) { - return []; + return [] as any[]; } - const list = [] as ((v: string) => boolean | string)[]; + const list: any[] = []; keys.forEach((key) => { const split = key.split(":"); const validatorKey = split[0] as ValidatorKey; if (validatorKey in validators) { if (split.length === 1) { - list.push(validators[validatorKey]); + list.push((validators as any)[validatorKey]); } else { - list.push(validators[validatorKey](split[1])); + list.push((validators as any)[validatorKey](split[1] as any)); } } }); return list; } -const defaultRules = computed(() => rulesByKey(props.globalRules as ValidatorKey[])); +const defaultRules = computed(() => rulesByKey(props.globalRules as any)); + +// Combined state map for readonly and disabled fields +const fieldState = computed>(() => { + const map: Record = {}; + (props.items || []).forEach((field: any) => { + const base = (field.disableUpdate && props.updateMode) || (!props.updateMode && field.disableCreate); + map[field.varName] = { + readonly: base || !!props.readonlyFields?.includes(field.varName), + disabled: base || !!props.disabledFields?.includes(field.varName), + }; + }); + return map; +}); function removeByIndex(list: never[], index: number) { // Removes the item at the index diff --git a/frontend/components/global/BaseWizard.vue b/frontend/components/global/BaseWizard.vue deleted file mode 100644 index 102f068c8..000000000 --- a/frontend/components/global/BaseWizard.vue +++ /dev/null @@ -1,293 +0,0 @@ - - - - - diff --git a/frontend/pages/admin/setup.vue b/frontend/pages/admin/setup.vue index 31c5c3879..00970d191 100644 --- a/frontend/pages/admin/setup.vue +++ b/frontend/pages/admin/setup.vue @@ -1,115 +1,239 @@