Squashed commit of the following:
All checks were successful
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 40s
All checks were successful
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 40s
commit 579f0878e5240dc17db69be1e0b0c0f5af7ef9fe
Author: Arno Kaimbacher <arno.kaimbacher@geosphere.at>
Date: Tue Jun 9 09:25:44 2026 +0200
feat: Refactor error handling in Dataset Edit form and improve validation messages
- Updated error handling in the Dataset Edit form to use a centralized formatError function for displaying validation messages.
- Enhanced user feedback by ensuring that error messages are displayed consistently across various fields.
- Modified the validation rule for arrayContainsTypes to provide clearer error messages for missing main and translated titles/abstracts.
- Introduced a new ValidationService to manage manual construction of validation errors.
- Updated Vite configuration to streamline asset loading and improve performance.
- Adjusted Inertia setup to utilize dynamic imports for page-specific assets.
- Cleaned up unnecessary comments and code in various files for better readability.
commit 5efddc2a58c0e164fef585cc7344c06155dbc2c1
Author: Arno Kaimbacher <arno.kaimbacher@geosphere.at>
Date: Mon Jan 12 17:02:47 2026 +0100
feat: add dataset change detection and form submission composables
- Implemented `useDatasetChangeDetection` for tracking unsaved changes in dataset forms, including comparisons for licenses, basic properties, files, coverage, and more.
- Added `useDatasetFormSubmission` for handling dataset form submissions with validation, success/error handling, and auto-save functionality.
This commit is contained in:
parent
0680879e2f
commit
9368a0dd8d
38 changed files with 5588 additions and 6181 deletions
|
|
@ -1,6 +1,6 @@
|
|||
<script setup lang="ts">
|
||||
import { ref } from 'vue';
|
||||
import { Head, useForm, router } from '@inertiajs/vue3';
|
||||
import { Head, useForm } from '@inertiajs/vue3';
|
||||
import { mdiAccountKey, mdiArrowLeftBoldOutline } from '@mdi/js';
|
||||
import LayoutAuthenticated from '@/Layouts/LayoutAuthenticated.vue';
|
||||
import SectionMain from '@/Components/SectionMain.vue';
|
||||
|
|
@ -13,29 +13,18 @@ import BaseDivider from '@/Components/BaseDivider.vue';
|
|||
import BaseButton from '@/Components/BaseButton.vue';
|
||||
import BaseButtons from '@/Components/BaseButtons.vue';
|
||||
import { stardust } from '@eidellev/adonis-stardust/client';
|
||||
// import { Inertia } from '@inertiajs/inertia';
|
||||
import PasswordMeter from '@/Components/SimplePasswordMeter/password-meter.vue';
|
||||
|
||||
const enabled = ref(false);
|
||||
const props = defineProps({
|
||||
user: {
|
||||
type: Object,
|
||||
default: () => ({}),
|
||||
},
|
||||
roles: {
|
||||
type: Object,
|
||||
default: () => ({}),
|
||||
},
|
||||
userHasRoles: {
|
||||
type: Object,
|
||||
default: () => ({}),
|
||||
},
|
||||
errors: {
|
||||
type: Object,
|
||||
default: () => ({}),
|
||||
},
|
||||
user: { type: Object, default: () => ({}) },
|
||||
roles: { type: Object, default: () => ({}) },
|
||||
userHasRoles: { type: Object, default: () => ({}) },
|
||||
errors: { type: Object, default: () => ({}) }, // Fallback
|
||||
});
|
||||
|
||||
// enabled ist true, solange kein (schwaches) Passwort eingegeben wird
|
||||
const enabled = ref(true);
|
||||
|
||||
const form = useForm({
|
||||
_method: 'put',
|
||||
login: props.user.login,
|
||||
|
|
@ -47,30 +36,34 @@ const form = useForm({
|
|||
roles: props.userHasRoles, // fill actual user roles from db
|
||||
});
|
||||
|
||||
const submit = async () => {
|
||||
// await Inertia.post(stardust.route('user.store'), form);
|
||||
// await router.put(stardust.route('settings.user.update', [props.user.id]), form);
|
||||
await form.put(stardust.route('settings.user.update', [props.user.id]), {
|
||||
const submit = () => {
|
||||
form.put(stardust.route('settings.user.update', [props.user.id]), {
|
||||
preserveScroll: true,
|
||||
onSuccess: () => {
|
||||
form.reset();
|
||||
// Bei Erfolg Passwortfelder leeren
|
||||
form.reset('new_password', 'password_confirmation');
|
||||
},
|
||||
onError: () => {
|
||||
if (form.errors.new_password) {
|
||||
form.reset('new_password');
|
||||
form.reset('new_password', 'password_confirmation');
|
||||
enabled.value = false;
|
||||
// newPasswordInput.value.focus();
|
||||
// newPasswordInput.value?.focus();
|
||||
}
|
||||
|
||||
},
|
||||
});
|
||||
};
|
||||
|
||||
const formatError = (error: string | string[] | undefined) => {
|
||||
if (!error) return '';
|
||||
return Array.isArray(error) ? error.join(', ') : error;
|
||||
};
|
||||
|
||||
const handleScore = (score: number) => {
|
||||
if (score >= 4){
|
||||
// Wenn das Feld leer ist, ist der Status egal (Passwort wird nicht geändert)
|
||||
// Wenn etwas drin steht, muss der Score >= 4 sein
|
||||
if (form.new_password === '') {
|
||||
enabled.value = true;
|
||||
} else {
|
||||
enabled.value = false;
|
||||
enabled.value = score >= 4;
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
|
@ -89,89 +82,87 @@ const handleScore = (score: number) => {
|
|||
small
|
||||
/>
|
||||
</SectionTitleLineWithButton>
|
||||
<!-- <CardBox form @submit.prevent="form.put(stardust.route('user.update', [props.user.id]))"> -->
|
||||
<CardBox form @submit.prevent="submit()">
|
||||
<FormField label="Enter Login" :class="{ 'text-red-400': errors.name }">
|
||||
<FormControl v-model="form.login" type="text" placeholder="Name" :errors="errors.login">
|
||||
<div class="text-red-400 text-sm" v-if="errors.login">
|
||||
{{ errors.login }}
|
||||
|
||||
<CardBox form @submit.prevent="submit">
|
||||
<FormField label="Login" :class="{ 'text-red-400': form.errors.login }">
|
||||
<FormControl v-model="form.login" type="text" placeholder="Login" :errors="form.errors.login">
|
||||
<div class="text-red-400 text-sm mt-1" v-if="form.errors.login">
|
||||
{{ formatError(form.errors.login) }}
|
||||
</div>
|
||||
</FormControl>
|
||||
</FormField>
|
||||
|
||||
<FormField label="First Name" :class="{ 'text-red-400': errors.first_name }">
|
||||
<FormControl v-model="form.first_name" type="text" placeholder="Enter First Name" :errors="errors.first_name">
|
||||
<div class="text-red-400 text-sm" v-if="errors.first_name && Array.isArray(errors.first_name)">
|
||||
{{ errors.first_name.join(', ') }}
|
||||
<FormField label="First Name" :class="{ 'text-red-400': form.errors.first_name }">
|
||||
<FormControl v-model="form.first_name" type="text" placeholder="First Name" :errors="form.errors.first_name">
|
||||
<div class="text-red-400 text-sm mt-1" v-if="form.errors.first_name">
|
||||
{{ formatError(form.errors.first_name) }}
|
||||
</div>
|
||||
</FormControl>
|
||||
</FormField>
|
||||
|
||||
<FormField label="Last Name" :class="{ 'text-red-400': errors.last_name }">
|
||||
<FormControl v-model="form.last_name" type="text" placeholder="Enter Last Name" :errors="errors.last_name">
|
||||
<div class="text-red-400 text-sm" v-if="errors.last_name && Array.isArray(errors.last_name)">
|
||||
{{ errors.last_name.join(', ') }}
|
||||
<FormField label="Last Name" :class="{ 'text-red-400': form.errors.last_name }">
|
||||
<FormControl v-model="form.last_name" type="text" placeholder="Last Name" :errors="form.errors.last_name">
|
||||
<div class="text-red-400 text-sm mt-1" v-if="form.errors.last_name">
|
||||
{{ formatError(form.errors.last_name) }}
|
||||
</div>
|
||||
</FormControl>
|
||||
</FormField>
|
||||
|
||||
<FormField label="Enter Email" :class="{ 'text-red-400': errors.email }">
|
||||
<FormControl v-model="form.email" type="text" placeholder="Email" :errors="errors.email">
|
||||
<div class="text-red-400 text-sm" v-if="errors.email && Array.isArray(errors.email)">
|
||||
{{ errors.email.join(', ') }}
|
||||
<FormField label="Email" :class="{ 'text-red-400': form.errors.email }">
|
||||
<FormControl v-model="form.email" type="text" placeholder="Email" :errors="form.errors.email">
|
||||
<div class="text-red-400 text-sm mt-1" v-if="form.errors.email">
|
||||
{{ formatError(form.errors.email) }}
|
||||
</div>
|
||||
</FormControl>
|
||||
</FormField>
|
||||
|
||||
<!-- <FormField label="Password" :class="{ 'text-red-400': errors.password }">
|
||||
<FormControl v-model="form.password" type="password" placeholder="Enter Password" :errors="errors.password">
|
||||
<div class="text-red-400 text-sm" v-if="errors.password">
|
||||
{{ errors.password }}
|
||||
</div>
|
||||
</FormControl>
|
||||
</FormField> -->
|
||||
<div class="py-4">
|
||||
<PasswordMeter
|
||||
field-label="Reset User Password (leave blank to keep current)"
|
||||
:show-required-message="false"
|
||||
v-model="form.new_password"
|
||||
:errors="form.errors"
|
||||
@score="handleScore"
|
||||
/>
|
||||
<!-- <div class="text-red-400 text-sm mt-1" v-if="form.errors.new_password">
|
||||
{{ formatError(form.errors.new_password) }}
|
||||
</div> -->
|
||||
</div>
|
||||
|
||||
<PasswordMeter field-label="Reset User Password" :show-required-message="false" ref="newPasswordInput" v-model="form.new_password" :errors="form.errors" @score="handleScore" />
|
||||
|
||||
|
||||
<FormField label="Password Confirmation" :class="{ 'text-red-400': errors.password_confirmation }">
|
||||
<FormField label="Password Confirmation" :class="{ 'text-red-400': form.errors.password_confirmation }">
|
||||
<FormControl
|
||||
v-model="form.password_confirmation"
|
||||
type="password"
|
||||
placeholder="Enter Password Confirmation"
|
||||
:errors="errors.password"
|
||||
placeholder="Confirm New Password"
|
||||
:errors="form.errors.password_confirmation"
|
||||
>
|
||||
<div
|
||||
class="text-red-400 text-sm"
|
||||
v-if="errors.password_confirmation && Array.isArray(errors.password_confirmation)"
|
||||
>
|
||||
{{ errors.password_confirmation.join(', ') }}
|
||||
<div class="text-red-400 text-sm mt-1" v-if="form.errors.password_confirmation">
|
||||
{{ formatError(form.errors.password_confirmation) }}
|
||||
</div>
|
||||
</FormControl>
|
||||
</FormField>
|
||||
|
||||
<BaseDivider />
|
||||
|
||||
<FormField label="Roles" wrap-body :class="{ 'text-red-400': errors.roles }">
|
||||
<FormField label="Roles" wrap-body :class="{ 'text-red-400': form.errors.roles }">
|
||||
<FormCheckRadioGroup v-model="form.roles" name="roles" is-column :options="props.roles" />
|
||||
<div class="text-red-400 text-sm mt-1" v-if="form.errors.roles">
|
||||
{{ formatError(form.errors.roles) }}
|
||||
</div>
|
||||
</FormField>
|
||||
<div class="text-red-400 text-sm" v-if="errors.roles && Array.isArray(errors.roles)">
|
||||
<!-- {{ errors.password_confirmation }} -->
|
||||
{{ errors.roles.join(', ') }}
|
||||
</div>
|
||||
|
||||
<template #footer>
|
||||
<BaseButtons>
|
||||
<BaseButton
|
||||
type="submit"
|
||||
color="info"
|
||||
label="Submit"
|
||||
label="Update User"
|
||||
:class="{ 'opacity-25': form.processing }"
|
||||
:disabled="form.processing == true|| (form.new_password != '' && enabled == false)"
|
||||
:disabled="form.processing || !enabled"
|
||||
/>
|
||||
</BaseButtons>
|
||||
</template>
|
||||
</CardBox>
|
||||
</SectionMain>
|
||||
</LayoutAuthenticated>
|
||||
</template>
|
||||
</template>
|
||||
Loading…
Add table
Add a link
Reference in a new issue