add i1_n keys + add global error message on edit form

This commit is contained in:
axolotle 2023-11-07 18:45:21 +01:00
parent f10a8063f7
commit fd95f788c9
3 changed files with 16 additions and 7 deletions

View file

@ -5,8 +5,9 @@ const props = defineProps<{
name: string name: string
label: string label: string
inputLabel: string inputLabel: string
buttonLabel: string
type: HTMLInputElement['type'] type: HTMLInputElement['type']
placeholder?: string placeholder?: string,
}>() }>()
const group: Ref<HTMLElement | null> = ref(null) const group: Ref<HTMLElement | null> = ref(null)
@ -55,6 +56,6 @@ function onAdd() {
</div> </div>
</FormField> </FormField>
<YButton :text="$t('add')" @click="onAdd" /> <YButton :text="buttonLabel" @click="onAdd" />
</fieldset> </fieldset>
</template> </template>

View file

@ -54,6 +54,8 @@
"footerlink_documentation": "Documentation", "footerlink_documentation": "Documentation",
"footerlink_support": "Support", "footerlink_support": "Support",
"footerlink_administration": "Administration", "footerlink_administration": "Administration",
"remove": "Remove",
"save": "Save",
"skip_to_main_content": "Skip to main content", "skip_to_main_content": "Skip to main content",
"v": { "v": {
"field_invalid": "Field value is invalid", "field_invalid": "Field value is invalid",

View file

@ -78,14 +78,18 @@ const onSubmit = handleSubmit(async (form) => {
// Reset form dirty state but keep previous values // Reset form dirty state but keep previous values
resetForm({ values: form }) resetForm({ values: form })
const errData = error.value.data const errData = error.value.data
let message
if (errData.path) { if (errData.path) {
setFieldError(errData.path, errData.error) setFieldError(errData.path, errData.error)
message = t('user_saving_fail')
} else { } else {
message = errData.error || errData
}
feedback.value = { feedback.value = {
variant: 'error', variant: 'error',
icon: 'mdi:alert', icon: 'mdi:alert',
message: errData.error || errData, message,
}
} }
} else if (data.value) { } else if (data.value) {
// redirect on password change // redirect on password change
@ -145,6 +149,7 @@ const onSubmit = handleSubmit(async (form) => {
type="email" type="email"
:label="$t('mail_addresses')" :label="$t('mail_addresses')"
:input-label="$t('mail_address')" :input-label="$t('mail_address')"
:button-label="$t('add_mail')"
:placeholder="$t('new_mail')" :placeholder="$t('new_mail')"
class="mb-10" class="mb-10"
/> />
@ -154,6 +159,7 @@ const onSubmit = handleSubmit(async (form) => {
type="email" type="email"
:label="$t('mail_forwards')" :label="$t('mail_forwards')"
:input-label="$t('mail_forward')" :input-label="$t('mail_forward')"
:button-label="$t('add_forward')"
:placeholder="$t('new_forward')" :placeholder="$t('new_forward')"
/> />
</div> </div>