Moved 'useForm' into modal component

This commit is contained in:
Leah Schumann 2023-02-13 15:06:18 -05:00
parent 9fa85f6295
commit eb87accfb7
4 changed files with 7 additions and 15 deletions

View file

@ -1,10 +1,14 @@
import { shallowMount } from "@vue/test-utils"; import { shallowMount } from "@vue/test-utils";
import Modal from "./modal"; import Modal from "./modal";
import crypto from "crypto";
import { useForm } from "vee-validate";
const modalId = "modal-one"; const modalId = "modal-one";
const footerButtonText = "Sample footer text here."; const footerButtonText = "Sample footer text here.";
const headerText = "Sample header text here."; const headerText = "Sample header text here.";
global.crypto = crypto;
describe("modal.vue", () => { describe("modal.vue", () => {
it("Should display footer button text when footerButtonText is defined", async () => { it("Should display footer button text when footerButtonText is defined", async () => {
const wrapper = shallowMount(Modal, { const wrapper = shallowMount(Modal, {

View file

@ -43,7 +43,7 @@
<script> <script>
import buttonMain from "@/ux-components/button-main/button-main"; import buttonMain from "@/ux-components/button-main/button-main";
import { Modal } from "bootstrap"; import { Modal } from "bootstrap";
import { useIsFormTouched, useIsFormDirty, useIsFormValid } from "vee-validate"; import { useForm, useIsFormTouched, useIsFormDirty, useIsFormValid } from "vee-validate";
export default { export default {
name: "modal", name: "modal",
@ -60,12 +60,14 @@ export default {
setup() { setup() {
const modalId = `modal-${crypto.randomUUID()}`; const modalId = `modal-${crypto.randomUUID()}`;
const modalForm = useForm();
const isTouched = useIsFormTouched(); const isTouched = useIsFormTouched();
const isDirty = useIsFormDirty(); const isDirty = useIsFormDirty();
const isValid = useIsFormValid(); const isValid = useIsFormValid();
return { return {
modalId, modalId,
modalForm,
isTouched, isTouched,
isDirty, isDirty,
isValid, isValid,

View file

@ -68,13 +68,6 @@ export default {
}, },
}; };
}, },
setup() {
const modalForm = useForm();
return {
modalForm,
};
},
props: { props: {
modelValue: { modelValue: {
type: Object, type: Object,

View file

@ -71,13 +71,6 @@ export default {
textboxQuestionWidgetName: String, textboxQuestionWidgetName: String,
alertInvalidZipWidgetName: String, alertInvalidZipWidgetName: String,
}, },
setup() {
const modalForm = useForm();
return {
modalForm,
};
},
computed: { computed: {
serviceZipLinkText() { serviceZipLinkText() {
if (this.modelValue.zipCode && this.modelValue.zipCode.length > 0) { if (this.modelValue.zipCode && this.modelValue.zipCode.length > 0) {