-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement VAR for C24_WMDE_Desktop_EN_05
VAR has a new main donation form with an address checkbox. Ticket: https://phabricator.wikimedia.org/T380360
- Loading branch information
Showing
14 changed files
with
597 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import CustomAmountFormEn from '@src/components/DonationForm/Forms/messages/CustomAmountForm.en'; | ||
import DynamicCampaignTextEn from '@src/utils/DynamicContent/messages/DynamicCampaignText.en'; | ||
import { TranslationMessages } from '@src/Translator'; | ||
import UpgradeToYearlyEn from '@src/components/DonationForm/Forms/messages/UpgradeToYearly.en'; | ||
import SoftCloseEn from '@src/components/SoftClose/messages/SoftClose.en'; | ||
import AddressFormEn from '@src/components/DonationForm/Forms/messages/AddressForm.en'; | ||
import FooterEn from '@src/components/Footer/messages/Footer.en'; | ||
import MainDonationFormEn from '@src/components/DonationForm/Forms/messages/MainDonationForm.en'; | ||
import AlreadyDonatedModalEn from '@src/components/AlreadyDonatedModal/translations/AlreadyDonatedModal.en'; | ||
import FallbackBanner from '@src/components/FallbackBanner/messages/FallbackBanner.en'; | ||
|
||
const messages: TranslationMessages = { | ||
...CustomAmountFormEn, | ||
...DynamicCampaignTextEn, | ||
...UpgradeToYearlyEn, | ||
...SoftCloseEn, | ||
...AddressFormEn, | ||
...FooterEn, | ||
...MainDonationFormEn, | ||
...AlreadyDonatedModalEn, | ||
...FallbackBanner, | ||
'upgrade-to-yearly-copy': '<p>Every year we are dependent on the support of people like you. Yearly donations ' + | ||
'help sustainably and enable long term development.</p>' + | ||
'<p>No risks attached, you can tell us to stop at any time.</p>', | ||
'donation-receipt-checkbox-label': 'Please send me a tax deductible donation receipt to my postal address.' | ||
}; | ||
|
||
export default messages; |
60 changes: 60 additions & 0 deletions
60
banners/english/C24_WMDE_Desktop_EN_05/styles/styles_var.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
// This is the file where we import the theme-specific component styles | ||
@use 'src/themes/Treedip/swatches/skin_vector-2022' with ( | ||
$slider: true, | ||
$select-group-bubble: true, | ||
$select-group-image-label: true, | ||
$upgrade-to-yearly: true, | ||
$fallback-banner: true, | ||
$progress-bar: true, | ||
$soft-close: true, | ||
); | ||
@use 'src/themes/Treedip/variables/breakpoints'; | ||
@use 'src/components/BannerConductor/banner-transition'; | ||
@use 'Banner'; | ||
@use 'MainBanner' with ( | ||
$banner-height: 355px, | ||
$form-width: 300px | ||
); | ||
@use 'src/themes/UseOfFunds/swatches/skin_vector-2022' as uof-vector-2022; | ||
@use 'src/themes/UseOfFunds/UseOfFunds'; | ||
@use 'src/themes/Treedip/defaults'; | ||
@use 'src/themes/Treedip/ButtonClose/ButtonClose' with ( | ||
$padding: 4px, | ||
$top: 12px, | ||
$right: 8px, | ||
$margin: -4.5px | ||
); | ||
@use 'src/themes/Treedip/ProgressBar/ProgressBarAlternative' with ( | ||
$progress-bar-margin: 0 15px | ||
); | ||
@use 'src/themes/Treedip/DonationForm/DonationForm'; | ||
@use 'src/themes/Treedip/DonationForm/MultiStepDonation'; | ||
@use 'src/themes/Treedip/DonationForm/BubbleForm/SelectGroupBubble'; | ||
@use 'src/themes/Treedip/DonationForm/BubbleForm/SelectGroupRadioBubbles' with ( | ||
$height: 34px, | ||
$font-size: 14px | ||
); | ||
@use 'src/themes/Treedip/DonationForm/BubbleForm/SelectCustomAmountRadioBubble' with ( | ||
$height: 34px, | ||
$font-size: 14px | ||
); | ||
@use 'src/themes/Treedip/DonationForm/BubbleForm/SelectGroupBubbleImageLabel'; | ||
@use 'src/themes/Treedip/DonationForm/SubComponents/SmsBox'; | ||
@use 'src/themes/Treedip/DonationForm/Forms/MainDonationFormDonationReceipt' with ( | ||
$padding: 14px 0 0 | ||
); | ||
@use 'src/themes/Treedip/DonationForm/Forms/UpgradeToYearlyButtonForm'; | ||
@use 'src/themes/Treedip/DonationForm/Forms/CustomAmountForm'; | ||
@use 'src/themes/Treedip/Footer/FooterAlreadyDonated' with ( | ||
$right-column-width: 300px | ||
); | ||
@use 'src/themes/Treedip/Footer/SelectionInput'; | ||
@use 'src/themes/Treedip/Message/Message' with ( | ||
$font-sizes: ( 1400px: 15px, 1600px: 16px, 1800px: 18px ) | ||
); | ||
@use 'src/themes/Treedip/Slider/KeenSlider'; | ||
@use 'src/themes/Treedip/SoftClose/SoftClose'; | ||
@use 'FallbackBanner'; | ||
@use 'src/themes/Fijitiv/FallbackBanner/FallbackButton'; | ||
@use 'src/themes/Fijitiv/FallbackBanner/LargeFooter'; | ||
@use 'src/themes/Fijitiv/FallbackBanner/SmallFooter'; |
31 changes: 31 additions & 0 deletions
31
src/components/DonationForm/Forms/MainDonationFormDonationReceipt.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
@mixin layout { | ||
&-sub-form-donation { | ||
.wmde-banner-form-field-group { | ||
border: 0; | ||
margin: 0; | ||
display: block; | ||
|
||
&-legend { | ||
width: 100%; | ||
position: relative; | ||
padding: 0; | ||
} | ||
} | ||
} | ||
|
||
.wmde-banner-form-donation-receipt-checkbox { | ||
display: inline-block; | ||
cursor: pointer; | ||
position: relative; | ||
padding: 0 0 10px 24px; | ||
|
||
input[ type='checkbox' ] { | ||
display: block; | ||
float: left; | ||
height: 16px; | ||
margin: 0 0 0 -24px; | ||
transition: background 0.15s ease-out; | ||
width: 16px; | ||
} | ||
} | ||
} |
176 changes: 176 additions & 0 deletions
176
src/components/DonationForm/Forms/MainDonationFormDonationReceipt.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,176 @@ | ||
<template> | ||
<form | ||
method="post" | ||
class="wmde-banner-sub-form wmde-banner-sub-form-donation" | ||
@submit.prevent="validate" | ||
> | ||
<fieldset class="wmde-banner-form-field-group"> | ||
<legend class="wmde-banner-form-field-group-legend">{{ $translate( 'intervals-header' ) }}</legend> | ||
<SelectGroup | ||
:field-name="'select-interval'" | ||
:selectionItems="formItems.intervals" | ||
:isValid="isValidOrUnset( intervalValidity )" | ||
:errorMessage="$translate( 'no-interval-message' )" | ||
v-model:inputValue="interval" | ||
:disabledOptions="disabledIntervals" | ||
/> | ||
</fieldset> | ||
|
||
<fieldset class="wmde-banner-form-field-group"> | ||
<legend class="wmde-banner-form-field-group-legend">{{ $translate( 'amounts-header' ) }}</legend> | ||
<SelectGroup | ||
fieldName="select-amount" | ||
:selectionItems="formItems.amounts" | ||
:isValid="isValidOrUnset( amountValidity )" | ||
:errorMessage="$translate( amountValidityMessageKey( amountValidity ) )" | ||
v-model:inputValue="selectedAmount" | ||
> | ||
<SelectCustomAmount | ||
fieldName="select-amount" | ||
v-model:inputValue="customAmount" | ||
@focus="clearSelectedAmount" | ||
@blur="formatCustomAmount" | ||
:placeholder="$translate( customAmountPlaceholderKey )" | ||
/> | ||
</SelectGroup> | ||
</fieldset> | ||
|
||
<fieldset class="wmde-banner-form-field-group"> | ||
<legend class="wmde-banner-form-field-group-legend">{{ $translate( 'payments-header' ) }}</legend> | ||
<SelectGroup | ||
:field-name="'select-payment-method'" | ||
:selectionItems="formItems.paymentMethods" | ||
:isValid="isValidOrUnset( paymentMethodValidity )" | ||
:errorMessage="$translate( 'no-payment-type-message' )" | ||
v-model:inputValue="paymentMethod" | ||
:disabledOptions="disabledPaymentMethods" | ||
> | ||
<template #select-group-label="{ label, slotName }: any"> | ||
<slot :name="'label-' + slotName" :label="label"/> | ||
</template> | ||
<SmsBox> | ||
<template #sms-icon> | ||
<slot name="sms-icon"/> | ||
</template> | ||
</SmsBox> | ||
</SelectGroup> | ||
</fieldset> | ||
|
||
<div class="wmde-banner-form-donation-receipt-checkbox" v-if="showReceiptCheckbox"> | ||
<input | ||
class="wmde-banner-form-field-checkbox" | ||
type="checkbox" | ||
value="person" | ||
id="wmde-banner-form-donation-receipt" | ||
v-model="receiptNeeded" | ||
> | ||
<label for="wmde-banner-form-donation-receipt"> | ||
{{ $translate( 'donation-receipt-checkbox-label' ) }} | ||
</label> | ||
</div> | ||
|
||
<div class="wmde-banner-form-button-container"> | ||
<slot name="button"> | ||
<MainDonationFormButtonMultiStep/> | ||
</slot> | ||
<button v-if="!isFormValid && showErrorScrollLink" class="wmde-banner-form-button-error"> | ||
{{ $translate( 'global-error' ) }} | ||
</button> | ||
</div> | ||
</form> | ||
</template> | ||
|
||
<script lang="ts"> | ||
// All form components must have names | ||
export default { | ||
name: 'MainDonationFormDonationReceipt' | ||
}; | ||
</script> | ||
<script setup lang="ts"> | ||
import { computed, inject, onMounted, ref, watch } from 'vue'; | ||
import SelectGroup from '@src/components/DonationForm/SubComponents/SelectGroup.vue'; | ||
import { DonationFormItems } from '@src/utils/FormItemsBuilder/DonationFormItems'; | ||
import SelectCustomAmount from '@src/components/DonationForm/SubComponents/SelectCustomAmount.vue'; | ||
import SmsBox from '@src/components/DonationForm/SubComponents/SmsBox.vue'; | ||
import { useFormModel } from '@src/components/composables/useFormModel'; | ||
import { newDonationFormValidator } from '@src/validation/DonationFormValidator'; | ||
import { amountValidityMessageKey } from '@src/utils/amountValidityMessageKey'; | ||
import { isValidOrUnset } from '@src/components/DonationForm/Forms/isValidOrUnset'; | ||
import { Currency } from '@src/utils/DynamicContent/formatters/Currency'; | ||
import MainDonationFormButtonMultiStep from '@src/components/DonationForm/Forms/MainDonationFormButtonMultiStep.vue'; | ||
import { AddressTypes } from '@src/utils/FormItemsBuilder/fields/AddressTypes'; | ||
import { PaymentMethods } from '@src/utils/FormItemsBuilder/fields/PaymentMethods'; | ||
interface Props { | ||
showErrorScrollLink?: boolean; | ||
customAmountPlaceholderKey?: string; | ||
} | ||
withDefaults( defineProps<Props>(), { | ||
showErrorScrollLink: false, | ||
customAmountPlaceholderKey: 'custom-amount-placeholder' | ||
} ); | ||
const emit = defineEmits( [ 'submit' ] ); | ||
const currencyFormatter = inject<Currency>( 'currencyFormatter' ); | ||
const formItems = inject<DonationFormItems>( 'formItems' ); | ||
const formModel = useFormModel(); | ||
const validator = newDonationFormValidator( formModel ); | ||
const showReceiptCheckbox = computed<boolean>( () => { | ||
if ( interval.value === '' ) { | ||
return false; | ||
} | ||
if ( paymentMethod.value === '' || paymentMethod.value === PaymentMethods.DIRECT_DEBIT.value ) { | ||
return false; | ||
} | ||
if ( numericAmount.value === 0 ) { | ||
return false; | ||
} | ||
return true; | ||
} ); | ||
const receiptNeeded = ref<boolean>( false ); | ||
const isFormValid = ref<boolean>( true ); | ||
const validate = (): void => { | ||
isFormValid.value = validator.validate(); | ||
if ( isFormValid.value ) { | ||
emit( 'submit' ); | ||
} | ||
}; | ||
const { | ||
interval, intervalValidity, disabledIntervals, | ||
selectedAmount, customAmount, numericAmount, amountValidity, | ||
paymentMethod, paymentMethodValidity, disabledPaymentMethods, | ||
addressType | ||
} = formModel; | ||
const clearSelectedAmount = (): void => { | ||
selectedAmount.value = ''; | ||
}; | ||
const formatCustomAmount = (): void => { | ||
if ( customAmount.value !== '' ) { | ||
customAmount.value = currencyFormatter.customAmountInput( numericAmount.value ); | ||
} | ||
}; | ||
watch( receiptNeeded, ( newValue: boolean ) => { | ||
addressType.value = newValue ? '' : AddressTypes.ANONYMOUS.value; | ||
} ); | ||
watch( [ interval, paymentMethod, numericAmount ], () => { | ||
if ( !showReceiptCheckbox.value ) { | ||
receiptNeeded.value = false; | ||
} | ||
} ); | ||
onMounted( () => { | ||
addressType.value = AddressTypes.ANONYMOUS.value; | ||
} ); | ||
</script> |
Oops, something went wrong.