open and close modal

This commit is contained in:
Kroell 2023-04-17 13:41:10 -04:00
parent b036decd48
commit 66fa86d944

View file

@ -10,19 +10,28 @@
aria-label="Modal window" />
</div>
</div>
<contentGroupModal
<modal
:ref="modalName"
cmsWidgetName="ServiceZipModalWidget"
ref="ServiceZipModalWidget"
modalId="ServiceZipModalWidget" />
:onModalOpenedCallback="onModalOpened"
:onModalClosedCallback="onModalClosed"
:footerButtonText="modalFooterText"
@footer-button-event="setZipCode"
/>
</template>
<script>
import contentGroupModal from "@/iss-components/content-group-modal/content-group-modal.vue";
import modal from "@/digital-components/modal/modal.vue"
import textLink from "@/ux-components/text-link/text-link";
export default {
name: "service-zip-modal-question",
emits: ["update:modalValue"],
data() {
return {
internalModel: this.copyModel(this.modelValue),
};
},
props: {
modelValue: {
type: Object,
@ -39,11 +48,50 @@ export default {
return this.modelValue.serviceZipState + ", " + this.modelValue.serviceZip;
}
},
modalFooterText() {
return this.getCmsContent(this.modalWidgetName, "FooterText");
},
modalName() {
return this.modalWidgetName;
},
},
methods: {
copyModel(modelToCopy) {
return {
serviceZipState: modelToCopy.serviceZipState,
serviceZip: modelToCopy.serviceZip,
};
},
openModal() {
this.$refs[this.modalName].openModal();
},
closeModal() {
this.$refs[this.modalName].closeModal();
},
onModalOpened() {
this.internalModel.serviceZip = this.modelValue.serviceZip;
this.focusOnZipInput();
},
onModalClosed() {
this.internalModel.serviceZip = this.modelValue.serviceZip;
this.resetsOnZipInput();
},
},
watch: {
modelValue(newValue) {
this.internalModel = this.copyModel(newValue);
},
"internalModel.serviceZip": {
handler() {
this.resetsOnZipInput();
},
},
},
components: {
contentGroupModal,
textLink
textLink,
modal
},
};
</script>