mirror of
https://github.com/lingble/chatwoot.git
synced 2025-11-04 04:57:51 +00:00
This PR updates the contact form validation to allow a minimum length of one character for the first name. Fixes https://linear.app/chatwoot/issue/CW-3993/update-the-validation-on-contact-form-to-support-just-one-character ## Type of change - [x] Bug fix (non-breaking change which fixes an issue) ## How Has This Been Tested? https://github.com/user-attachments/assets/2b95af80-ee70-4f4b-8d0d-b01779db9d94 ## Checklist: - [x] My code follows the style guidelines of this project - [x] I have performed a self-review of my code - [ ] I have commented on my code, particularly in hard-to-understand areas - [ ] I have made corresponding changes to the documentation - [x] My changes generate no new warnings - [ ] I have added tests that prove my fix is effective or that my feature works - [x] New and existing unit tests pass locally with my changes - [ ] Any dependent changes have been merged and published in downstream modules
70 lines
1.8 KiB
Vue
70 lines
1.8 KiB
Vue
<script setup>
|
|
import { ref, computed } from 'vue';
|
|
import { useMapGetter } from 'dashboard/composables/store';
|
|
import { useI18n } from 'vue-i18n';
|
|
|
|
import Dialog from 'dashboard/components-next/dialog/Dialog.vue';
|
|
import Button from 'dashboard/components-next/button/Button.vue';
|
|
import ContactsForm from 'dashboard/components-next/Contacts/ContactsForm/ContactsForm.vue';
|
|
|
|
const emit = defineEmits(['create']);
|
|
|
|
const { t } = useI18n();
|
|
|
|
const dialogRef = ref(null);
|
|
const contactsFormRef = ref(null);
|
|
const contact = ref(null);
|
|
|
|
const uiFlags = useMapGetter('contacts/getUIFlags');
|
|
const isCreatingContact = computed(() => uiFlags.value.isCreating);
|
|
|
|
const createNewContact = contactItem => {
|
|
contact.value = contactItem;
|
|
};
|
|
|
|
const handleDialogConfirm = async () => {
|
|
if (!contact.value) return;
|
|
emit('create', contact.value);
|
|
};
|
|
|
|
const onSuccess = () => {
|
|
contactsFormRef.value?.resetForm();
|
|
dialogRef.value.close();
|
|
};
|
|
|
|
const closeDialog = () => {
|
|
dialogRef.value.close();
|
|
};
|
|
|
|
defineExpose({ dialogRef, contactsFormRef, onSuccess });
|
|
</script>
|
|
|
|
<template>
|
|
<Dialog ref="dialogRef" width="3xl" @confirm="handleDialogConfirm">
|
|
<ContactsForm
|
|
ref="contactsFormRef"
|
|
is-new-contact
|
|
@update="createNewContact"
|
|
/>
|
|
<template #footer>
|
|
<div class="flex items-center justify-between w-full gap-3">
|
|
<Button
|
|
:label="t('DIALOG.BUTTONS.CANCEL')"
|
|
variant="link"
|
|
class="h-10 hover:!no-underline hover:text-n-brand"
|
|
@click="closeDialog"
|
|
/>
|
|
<Button
|
|
:label="
|
|
t('CONTACTS_LAYOUT.HEADER.ACTIONS.CONTACT_CREATION.SAVE_CONTACT')
|
|
"
|
|
color="blue"
|
|
:disabled="contactsFormRef?.isFormInvalid"
|
|
:is-loading="isCreatingContact"
|
|
@click="handleDialogConfirm"
|
|
/>
|
|
</div>
|
|
</template>
|
|
</Dialog>
|
|
</template>
|