Skip to content

Commit

Permalink
feat: disable config form modal submit button when nothing changed
Browse files Browse the repository at this point in the history
  • Loading branch information
kunish committed Mar 21, 2024
1 parent ffc92d3 commit b44fb75
Showing 1 changed file with 24 additions and 5 deletions.
29 changes: 24 additions & 5 deletions components/ConfigFormModal.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<script setup lang="ts">
import type { Form, FormErrorEvent, FormSubmitEvent } from '#ui/types'
import { isEqual } from 'lodash-es'
import { z } from 'zod'
withDefaults(
Expand Down Expand Up @@ -223,6 +224,8 @@ enum UTLSImitate {
qq_11_1 = 'qq_11_1'
}
const isResetDisabled = computed(() => isEqual(state, initialState()))
const onReset = () => {
formRef.value?.clear()
Object.assign(state, initialState())
Expand Down Expand Up @@ -324,8 +327,15 @@ defineExpose({
:loading="isLanInterfaceLoading"
:options="lanInterfaceOptions"
multiple
placeholder="Select LanInterfaces"
/>
>
<template #label>
<span v-if="state.lanInterface.length" class="truncate">
{{ state.lanInterface.join(', ') }}
</span>

<span v-else>Select LanInterfaces</span>
</template>
</USelectMenu>
</UFormGroup>

<UFormGroup label="wanInterface">
Expand All @@ -334,8 +344,15 @@ defineExpose({
:loading="isWanInterfaceLoading"
:options="wanInterfaceOptions"
multiple
placeholder="Select wanInterfaces"
/>
>
<template #label>
<span v-if="state.wanInterface.length" class="truncate">
{{ state.wanInterface.join(', ') }}
</span>

<span v-else>Select WanInterfaces</span>
</template>
</USelectMenu>
</UFormGroup>

<UFormGroup label="autoConfigKernelParameter">
Expand Down Expand Up @@ -461,7 +478,9 @@ defineExpose({

<template #footer>
<div class="flex justify-end gap-2">
<UButton color="black" @click="onReset"> Reset </UButton>
<UButton :disabled="isResetDisabled" color="black" @click="onReset">
Reset
</UButton>
<UButton :loading="isLoading" type="submit">Submit</UButton>
</div>
</template>
Expand Down

0 comments on commit b44fb75

Please sign in to comment.