CSR-1012 | modal open and close functions
This commit is contained in:
parent
338d9b7935
commit
ced1c18c04
2 changed files with 22 additions and 11 deletions
|
|
@ -2,7 +2,7 @@
|
||||||
<!-- Modal -->
|
<!-- Modal -->
|
||||||
<div
|
<div
|
||||||
class="modal fade modal-component"
|
class="modal fade modal-component"
|
||||||
v-on="{ 'hidden.bs.modal': resetButtonStyle, 'shown.bs.modal': onShownCallback }"
|
v-on="{ 'hidden.bs.modal': resetButtonStyle, 'shown.bs.modal': onModalOpenedCallback }"
|
||||||
:id="cmsWidgetName"
|
:id="cmsWidgetName"
|
||||||
tabindex="-1"
|
tabindex="-1"
|
||||||
aria-labelledby="ModalComponentLabel"
|
aria-labelledby="ModalComponentLabel"
|
||||||
|
|
@ -44,12 +44,13 @@
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import buttonMain from "@/ux-components/button-main/button-main";
|
import buttonMain from "@/ux-components/button-main/button-main";
|
||||||
|
import { Modal } from "bootstrap";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: "modal",
|
name: "modal",
|
||||||
props: {
|
props: {
|
||||||
cmsWidgetName: String,
|
cmsWidgetName: String,
|
||||||
onShownCallback: {
|
onModalOpenedCallback: {
|
||||||
type: Function,
|
type: Function,
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
@ -59,6 +60,14 @@ export default {
|
||||||
// if undefined, footer button closes modal
|
// if undefined, footer button closes modal
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
myModal: null,
|
||||||
|
};
|
||||||
|
},
|
||||||
|
mounted() {
|
||||||
|
this.myModal = new Modal(document.getElementById(this.cmsWidgetName));
|
||||||
|
},
|
||||||
computed: {
|
computed: {
|
||||||
ModalHeadline() {
|
ModalHeadline() {
|
||||||
return this.getCmsContent(this.cmsWidgetName, "HeaderText");
|
return this.getCmsContent(this.cmsWidgetName, "HeaderText");
|
||||||
|
|
@ -86,8 +95,11 @@ export default {
|
||||||
resetButtonStyle() {
|
resetButtonStyle() {
|
||||||
this.$refs.buttonMain.resetButtonStyle();
|
this.$refs.buttonMain.resetButtonStyle();
|
||||||
},
|
},
|
||||||
|
openModal() {
|
||||||
|
this.myModal.show();
|
||||||
|
},
|
||||||
closeModal() {
|
closeModal() {
|
||||||
this.$refs.modalXButton.click();
|
this.myModal.hide();
|
||||||
},
|
},
|
||||||
async footerButtonClick() {
|
async footerButtonClick() {
|
||||||
if (this.footerButtonCallback) {
|
if (this.footerButtonCallback) {
|
||||||
|
|
|
||||||
|
|
@ -1,25 +1,25 @@
|
||||||
<template>
|
<template>
|
||||||
<div class="text-center">
|
<div class="text-center">
|
||||||
<label
|
<label
|
||||||
:for="serviceZipCodeInput"
|
:for="displayModalLink"
|
||||||
:aria-label="questionText"
|
:aria-label="questionText"
|
||||||
class="form-label fw-bold w-100 ps-4 pe-4 pt-4"
|
class="form-label fw-bold w-100 ps-4 pe-4 pt-4"
|
||||||
:class="[questionAlignment === 'center' ? 'text-center w-100 mb-5' : '']"
|
:class="[questionAlignment === 'center' ? 'text-center w-100 mb-5' : '']"
|
||||||
v-html="questionText"></label>
|
v-html="questionText"></label>
|
||||||
<div class="update-zip-text-link">
|
<div class="update-zip-text-link">
|
||||||
<textLink
|
<textLink
|
||||||
|
id="displayModalLink"
|
||||||
linkType="text"
|
linkType="text"
|
||||||
:text="this.serviceZipDisplayText"
|
:text="this.serviceZipDisplayText"
|
||||||
href="#!"
|
href="#!"
|
||||||
data-bs-toggle="modal"
|
@click-event="openZipCodeModal"
|
||||||
:data-bs-target="getModalId"
|
|
||||||
aria-label="Modal window" />
|
aria-label="Modal window" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<modal
|
<modal
|
||||||
ref="zipCodeInputModal"
|
ref="zipCodeInputModal"
|
||||||
:cmsWidgetName="this.modalWidgetName"
|
:cmsWidgetName="this.modalWidgetName"
|
||||||
:onShownCallback="onModalOpen"
|
:onModalOpenedCallback="onModalOpen"
|
||||||
:footerButtonCallback="setZip">
|
:footerButtonCallback="setZip">
|
||||||
<div class="ps-4 pe-4 pb-4">
|
<div class="ps-4 pe-4 pb-4">
|
||||||
<textboxQuestion
|
<textboxQuestion
|
||||||
|
|
@ -62,7 +62,6 @@ import textboxQuestion from "@/digital-components/textbox-question/textbox-quest
|
||||||
import { defineRule } from "vee-validate";
|
import { defineRule } from "vee-validate";
|
||||||
import { required, regex } from "@/helpers/validation-rules";
|
import { required, regex } from "@/helpers/validation-rules";
|
||||||
import { errorMessages } from "@/constants/error-messages";
|
import { errorMessages } from "@/constants/error-messages";
|
||||||
import { isNoUnitNumericStyleProp } from "@vue/shared";
|
|
||||||
|
|
||||||
// Define Validation Rules
|
// Define Validation Rules
|
||||||
defineRule("zip-required", required(errorMessages.SERVICE_ZIP_REQUIRED));
|
defineRule("zip-required", required(errorMessages.SERVICE_ZIP_REQUIRED));
|
||||||
|
|
@ -87,6 +86,9 @@ export default {
|
||||||
alertInvalidZipWidgetName: String,
|
alertInvalidZipWidgetName: String,
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
openZipCodeModal() {
|
||||||
|
this.$refs.zipCodeInputModal.openModal();
|
||||||
|
},
|
||||||
getZipFromStore() {
|
getZipFromStore() {
|
||||||
return this.$store.getters.order.serviceLocation.zipCode;
|
return this.$store.getters.order.serviceLocation.zipCode;
|
||||||
},
|
},
|
||||||
|
|
@ -145,9 +147,6 @@ export default {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
getModalId() {
|
|
||||||
return "#" + this.modalWidgetName;
|
|
||||||
},
|
|
||||||
questionText() {
|
questionText() {
|
||||||
return this.getCmsContent(this.cmsWidgetName, "HeaderText");
|
return this.getCmsContent(this.cmsWidgetName, "HeaderText");
|
||||||
},
|
},
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue