|
| 1 | +<template> |
| 2 | + <div class="wmde-banner-wrapper" :class="contentState"> |
| 3 | + <MainBanner |
| 4 | + @form-interaction="$emit( 'bannerContentChanged' )" |
| 5 | + v-if="contentState === ContentStates.Main" |
| 6 | + :bannerState="bannerState" |
| 7 | + > |
| 8 | + <template #close-button> |
| 9 | + <ButtonClose @close="onCloseMain"/> |
| 10 | + </template> |
| 11 | + |
| 12 | + <template #banner-title> |
| 13 | + <BannerTitle/> |
| 14 | + </template> |
| 15 | + |
| 16 | + <template #banner-text> |
| 17 | + <BannerText/> |
| 18 | + </template> |
| 19 | + |
| 20 | + <template #banner-slides="{ play }: any"> |
| 21 | + <KeenSlider :with-navigation="true" :play="play" :interval="10000" :delay="2000" :navigation-color="'#ffffff'"> |
| 22 | + |
| 23 | + <template #slides="{ currentSlide }: any"> |
| 24 | + <BannerSlides :currentSlide="currentSlide"/> |
| 25 | + </template> |
| 26 | + |
| 27 | + </KeenSlider> |
| 28 | + </template> |
| 29 | + |
| 30 | + <template #progress> |
| 31 | + <ProgressBar amount-to-show-on-right="TARGET"/> |
| 32 | + </template> |
| 33 | + |
| 34 | + <template #donation-form="{ formInteraction }: any"> |
| 35 | + <div class="wmde-banner-usage-link-wrapper"> |
| 36 | + <a |
| 37 | + id="application-of-funds-link" |
| 38 | + class="wmde-banner-usage-link t-use-of-funds-link" |
| 39 | + :title="$translate( 'use-of-funds-link-description' )" |
| 40 | + @click.prevent="onModalOpened" |
| 41 | + > |
| 42 | + {{ $translate( 'use-of-funds-link' ) }} |
| 43 | + </a> |
| 44 | + </div> |
| 45 | + |
| 46 | + <MultiStepDonation |
| 47 | + :step-controllers="stepControllers" |
| 48 | + @form-interaction="formInteraction" |
| 49 | + :submit-callback="onSubmit" |
| 50 | + > |
| 51 | + |
| 52 | + <template #[FormStepNames.MainDonationFormStep]="{ pageIndex, submit, isCurrent, previous }: any"> |
| 53 | + <MainDonationForm |
| 54 | + :page-index="pageIndex" |
| 55 | + @submit="submit" |
| 56 | + :is-current="isCurrent" |
| 57 | + @previous="previous" |
| 58 | + > |
| 59 | + <template #label-payment-ppl> |
| 60 | + <span class="wmde-banner-select-group-label with-logos paypal"> |
| 61 | + <PayPalIcon/><span>Paypal</span> |
| 62 | + </span> |
| 63 | + </template> |
| 64 | + |
| 65 | + <template #interval-select-group="{ fieldName, selectionItems, isValid, errorMessage, disabledOptions }: any"> |
| 66 | + <SelectGroup |
| 67 | + :field-name="fieldName" |
| 68 | + :selectionItems="selectionItems" |
| 69 | + :isValid="isValid" |
| 70 | + :errorMessage="errorMessage" |
| 71 | + v-model:inputValue="interval" |
| 72 | + :disabledOptions="disabledOptions" |
| 73 | + /> |
| 74 | + </template> |
| 75 | + |
| 76 | + <template #label-payment-mcp> |
| 77 | + <span class="wmde-banner-select-group-label with-logos credit-cards"> |
| 78 | + <MasterCardIcon/><span>Kreditkarte</span> |
| 79 | + </span> |
| 80 | + </template> |
| 81 | + |
| 82 | + <template #label-payment-ueb> |
| 83 | + <span class="wmde-banner-select-group-label with-logos bank-transfer"> |
| 84 | + <BankTransferIcon/><span>Überweisung</span> |
| 85 | + </span> |
| 86 | + </template> |
| 87 | + |
| 88 | + <template #label-payment-bez> |
| 89 | + <span class="wmde-banner-select-group-label with-logos bank-transfer"> |
| 90 | + <DirectDebitIcon/><span>Lastschrift</span> |
| 91 | + </span> |
| 92 | + </template> |
| 93 | + </MainDonationForm> |
| 94 | + </template> |
| 95 | + |
| 96 | + <template #[FormStepNames.UpgradeToYearlyFormStep]="{ pageIndex, submit, isCurrent, previous }: any"> |
| 97 | + <UpgradeToYearlyButtonForm |
| 98 | + :page-index="pageIndex" |
| 99 | + @submit="submit" |
| 100 | + :is-current="isCurrent" |
| 101 | + @previous="previous" |
| 102 | + /> |
| 103 | + </template> |
| 104 | + |
| 105 | + </MultiStepDonation> |
| 106 | + </template> |
| 107 | + |
| 108 | + <template #footer> |
| 109 | + <FooterAlreadyDonatedWithoutFundsLink |
| 110 | + @showFundsModal="onModalOpened" |
| 111 | + @clickedAlreadyDonatedLink="onClose( 'MainBanner', CloseChoices.AlreadyDonated )" |
| 112 | + /> |
| 113 | + </template> |
| 114 | + |
| 115 | + </MainBanner> |
| 116 | + |
| 117 | + <FundsModal |
| 118 | + :content="useOfFundsContent" |
| 119 | + :visible="isFundsModalVisible" |
| 120 | + @hide="onHideFundsModal" |
| 121 | + @call-to-action="onHideFundsModal" |
| 122 | + /> |
| 123 | + </div> |
| 124 | +</template> |
| 125 | + |
| 126 | +<script setup lang="ts"> |
| 127 | +import { BannerStates } from '@src/components/BannerConductor/StateMachine/BannerStates'; |
| 128 | +import { inject, ref, watch } from 'vue'; |
| 129 | +import { UseOfFundsContent as useOfFundsContentInterface } from '@src/domain/UseOfFunds/UseOfFundsContent'; |
| 130 | +import MainBanner from './MainBanner.vue'; |
| 131 | +import FundsModal from '@src/components/UseOfFunds/UseOfFundsModal.vue'; |
| 132 | +import BannerText from '../content/BannerText.vue'; |
| 133 | +import BannerSlides from '../content/BannerSlides.vue'; |
| 134 | +import MultiStepDonation from '@src/components/DonationForm/MultiStepDonation.vue'; |
| 135 | +import MainDonationForm from '@src/components/DonationForm/Forms/MainDonationForm.vue'; |
| 136 | +import UpgradeToYearlyButtonForm from '@src/components/DonationForm/Forms/UpgradeToYearlyButtonForm.vue'; |
| 137 | +import KeenSlider from '@src/components/Slider/KeenSlider.vue'; |
| 138 | +import { useFormModel } from '@src/components/composables/useFormModel'; |
| 139 | +import { |
| 140 | + createSubmittableMainDonationForm |
| 141 | +} from '@src/components/DonationForm/StepControllers/SubmittableMainDonationForm'; |
| 142 | +import { |
| 143 | + createSubmittableUpgradeToYearly |
| 144 | +} from '@src/components/DonationForm/StepControllers/SubmittableUpgradeToYearly'; |
| 145 | +import { CloseChoices } from '@src/domain/CloseChoices'; |
| 146 | +import { CloseEvent } from '@src/tracking/events/CloseEvent'; |
| 147 | +import { TrackingFeatureName } from '@src/tracking/TrackingEvent'; |
| 148 | +import ButtonClose from '@src/components/ButtonClose/ButtonClose.vue'; |
| 149 | +import FooterAlreadyDonatedWithoutFundsLink from '@src/components/Footer/FooterAlreadyDonatedWithoutFundsLink.vue'; |
| 150 | +import { LocalCloseTracker } from '@src/utils/LocalCloseTracker'; |
| 151 | +import { BannerSubmitOnReturnEvent } from '@src/tracking/events/BannerSubmitOnReturnEvent'; |
| 152 | +import { Tracker } from '@src/tracking/Tracker'; |
| 153 | +import { useBannerHider } from '@src/components/composables/useBannerHider'; |
| 154 | +import BannerTitle from '../content/BannerTitle.vue'; |
| 155 | +import BankTransferIcon from '@src/components/PaymentLogos/BankTransferIcon.vue'; |
| 156 | +import PayPalIcon from '@src/components/PaymentLogos/PayPalIcon.vue'; |
| 157 | +import DirectDebitIcon from '@src/components/PaymentLogos/DirectDebitIcon.vue'; |
| 158 | +import MasterCardIcon from '@src/components/PaymentLogos/MasterCardIcon.vue'; |
| 159 | +import ProgressBar from '@src/components/ProgressBar/ProgressBar.vue'; |
| 160 | +import SelectGroup from '@src/components/DonationForm/SubComponents/SelectGroupHighlightedInterval.vue'; |
| 161 | +
|
| 162 | +enum ContentStates { |
| 163 | + Main = 'wmde-banner-wrapper--main', |
| 164 | +} |
| 165 | +
|
| 166 | +enum FormStepNames { |
| 167 | + MainDonationFormStep = 'MainDonationForm', |
| 168 | + UpgradeToYearlyFormStep = 'UpgradeToYearlyForm' |
| 169 | +} |
| 170 | +
|
| 171 | +interface Props { |
| 172 | + bannerState: BannerStates; |
| 173 | + useOfFundsContent: useOfFundsContentInterface; |
| 174 | + localCloseTracker: LocalCloseTracker; |
| 175 | +} |
| 176 | +
|
| 177 | +const props = defineProps<Props>(); |
| 178 | +const emit = defineEmits( [ 'bannerClosed', 'bannerContentChanged', 'modalOpened', 'modalClosed' ] ); |
| 179 | +useBannerHider( 800, emit ); |
| 180 | +
|
| 181 | +const tracker = inject<Tracker>( 'tracker' ); |
| 182 | +
|
| 183 | +const isFundsModalVisible = ref<boolean>( false ); |
| 184 | +const contentState = ref<ContentStates>( ContentStates.Main ); |
| 185 | +const formModel = useFormModel(); |
| 186 | +const { interval } = formModel; |
| 187 | +const stepControllers = [ |
| 188 | + createSubmittableMainDonationForm( formModel, FormStepNames.UpgradeToYearlyFormStep ), |
| 189 | + createSubmittableUpgradeToYearly( formModel, FormStepNames.MainDonationFormStep, FormStepNames.MainDonationFormStep ) |
| 190 | +]; |
| 191 | +
|
| 192 | +watch( contentState, async () => { |
| 193 | + emit( 'bannerContentChanged' ); |
| 194 | +} ); |
| 195 | +
|
| 196 | +const onSubmit = (): void => { |
| 197 | + // special callback function: asking for previous close choices |
| 198 | + const closeChoice = props.localCloseTracker.getItem(); |
| 199 | + if ( closeChoice !== '' ) { |
| 200 | + tracker.trackEvent( new BannerSubmitOnReturnEvent( closeChoice ) ); |
| 201 | + } |
| 202 | +}; |
| 203 | +
|
| 204 | +function onCloseMain(): void { |
| 205 | + onClose( 'MainBanner', CloseChoices.Close ); |
| 206 | +} |
| 207 | +
|
| 208 | +function onClose( feature: TrackingFeatureName, userChoice: CloseChoices ): void { |
| 209 | + emit( 'bannerClosed', new CloseEvent( feature, userChoice ) ); |
| 210 | +} |
| 211 | +
|
| 212 | +function onHideFundsModal(): void { |
| 213 | + isFundsModalVisible.value = false; |
| 214 | + emit( 'modalClosed' ); |
| 215 | +} |
| 216 | +
|
| 217 | +function onModalOpened(): void { |
| 218 | + isFundsModalVisible.value = true; |
| 219 | + emit( 'modalOpened' ); |
| 220 | +} |
| 221 | +
|
| 222 | +</script> |
0 commit comments