mirror of
https://github.com/YunoHost/yunohost-portal.git
synced 2024-09-03 20:06:23 +02:00
edit: remove submit button disabled state
This commit is contained in:
parent
89a50ab18f
commit
01affca1da
4 changed files with 11 additions and 26 deletions
|
@ -18,33 +18,20 @@ const attrs = computed(() => {
|
||||||
props.loading === true
|
props.loading === true
|
||||||
? props.loadingIcon || 'loading'
|
? props.loadingIcon || 'loading'
|
||||||
: props.loading === false
|
: props.loading === false
|
||||||
? 'thumb-up'
|
? 'thumb-up'
|
||||||
: props.icon,
|
: props.icon,
|
||||||
iconClass: props.loading ? 'animate-spin' : '',
|
iconClass: props.loading ? 'animate-spin' : '',
|
||||||
...baseAttrs,
|
...baseAttrs,
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
const onClick = (e: MouseEvent) => {
|
const onClick = (e: MouseEvent) => {
|
||||||
if (props.loading !== null) {
|
if (props.loading) {
|
||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<YButton
|
<YButton v-bind="attrs" type="submit" @click="onClick" />
|
||||||
v-bind="attrs"
|
|
||||||
:aria-disabled="loading !== null"
|
|
||||||
:class="{ 'btn-disabled no-animation': loading !== null }"
|
|
||||||
type="submit"
|
|
||||||
@click="onClick"
|
|
||||||
/>
|
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<style scoped>
|
|
||||||
.btn-disabled {
|
|
||||||
pointer-events: unset;
|
|
||||||
cursor: not-allowed;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
|
|
|
@ -9,7 +9,7 @@ import type { Feedback } from '@/composables/form'
|
||||||
const { t } = useI18n()
|
const { t } = useI18n()
|
||||||
|
|
||||||
const user = await useUser()
|
const user = await useUser()
|
||||||
const loading: Ref<boolean | null> = ref(false)
|
const loading: Ref<boolean> = ref(false)
|
||||||
const feedback: Ref<Feedback> = ref(null)
|
const feedback: Ref<Feedback> = ref(null)
|
||||||
|
|
||||||
const { handleSubmit, setFieldError, resetForm, meta } = useForm({
|
const { handleSubmit, setFieldError, resetForm, meta } = useForm({
|
||||||
|
@ -29,9 +29,8 @@ const { handleSubmit, setFieldError, resetForm, meta } = useForm({
|
||||||
watch(
|
watch(
|
||||||
() => meta.value.dirty,
|
() => meta.value.dirty,
|
||||||
(value) => {
|
(value) => {
|
||||||
// remove loading and feedback on edition
|
// remove global feedback on edition
|
||||||
if (value) {
|
if (value) {
|
||||||
loading.value = null
|
|
||||||
feedback.value = null
|
feedback.value = null
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -49,7 +48,7 @@ const onSubmit = handleSubmit(async (form) => {
|
||||||
|
|
||||||
if (error.value) {
|
if (error.value) {
|
||||||
// Reset form dirty state but keep previous values
|
// Reset form dirty state but keep previous values
|
||||||
resetForm({ values: form })
|
resetForm({ values: { ...form, mail: user.value.mail } })
|
||||||
const errData = error.value.data
|
const errData = error.value.data
|
||||||
let message
|
let message
|
||||||
|
|
||||||
|
@ -67,7 +66,7 @@ const onSubmit = handleSubmit(async (form) => {
|
||||||
} else if (data.value) {
|
} else if (data.value) {
|
||||||
Object.assign(user.value, data)
|
Object.assign(user.value, data)
|
||||||
resetForm({
|
resetForm({
|
||||||
values: data.value,
|
values: { ...data.value, mail: user.value.mail },
|
||||||
})
|
})
|
||||||
feedback.value = {
|
feedback.value = {
|
||||||
variant: 'success',
|
variant: 'success',
|
||||||
|
|
|
@ -7,7 +7,7 @@ import type { Feedback } from '@/composables/form'
|
||||||
|
|
||||||
const { t } = useI18n()
|
const { t } = useI18n()
|
||||||
|
|
||||||
const loading: Ref<boolean | null> = ref(false)
|
const loading: Ref<boolean> = ref(false)
|
||||||
const feedback: Ref<Feedback> = ref(null)
|
const feedback: Ref<Feedback> = ref(null)
|
||||||
|
|
||||||
const { handleSubmit, setFieldError, resetForm, meta } = useForm({
|
const { handleSubmit, setFieldError, resetForm, meta } = useForm({
|
||||||
|
@ -37,9 +37,8 @@ const { handleSubmit, setFieldError, resetForm, meta } = useForm({
|
||||||
watch(
|
watch(
|
||||||
() => meta.value.dirty,
|
() => meta.value.dirty,
|
||||||
(value) => {
|
(value) => {
|
||||||
// remove loading and feedback on edition
|
// remove global feedback on edition
|
||||||
if (value) {
|
if (value) {
|
||||||
loading.value = null
|
|
||||||
feedback.value = null
|
feedback.value = null
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
@ -3,7 +3,7 @@ import type { Feedback } from '@/composables/form'
|
||||||
|
|
||||||
withDefaults(
|
withDefaults(
|
||||||
defineProps<{
|
defineProps<{
|
||||||
loading: boolean | null
|
loading: boolean
|
||||||
feedback?: Feedback
|
feedback?: Feedback
|
||||||
submitVariant?: 'success' | 'warning' | 'error'
|
submitVariant?: 'success' | 'warning' | 'error'
|
||||||
}>(),
|
}>(),
|
||||||
|
|
Loading…
Reference in a new issue