diff --git a/README.md b/README.md index 9819acdac..5180ec903 100644 --- a/README.md +++ b/README.md @@ -60,7 +60,9 @@ Add the following code to your page where appropriate. See the [Branded checkout on-order-failed="$event.$window.onOrderFailed($event.donorDetails)" radio-station-api-url="https://api.domain.com/getStations" radio-station-radius="100" - hide-spouse-details="true"> + hide-spouse-details="true" + hide-annual="true" + hide-quarterly="true"> @@ -134,6 +136,8 @@ The `` element is where the branded checkout Angular app will - `radio-station-api-url` - Provides a URL path for fetching a list of radio stations in the donor's vicinity. If you plan to use this feature, contact Cru's Digital Products and Services (DPS) department ([help@cru.org](mailto:help@cru.org)) to have your URL domain whitelisted to interact with our API - *Optional* - `radio-station-radius` - Provides a radius (in miles) for fetching a list of radio stations in the donor's vicinity - *Optional* - `hide-spouse-details` - Hides the spouse detail line initially, and adds a link to toggle the spouse details. If you don't want this feature, do not add this attribute at all. - *Optional* +- `hide-annual` - Hides the annual frequency option. If you don't want this feature, do not add this attribute at all. - *Optional* +- `hide-quarterly` - Hides the quarterly frequency option. If you don't want this feature, do not add this attribute at all. - *Optional* #### Server-side configuration for a new branded checkout domain diff --git a/branded-checkout.html b/branded-checkout.html index ff2e6db51..73feb5ef6 100644 --- a/branded-checkout.html +++ b/branded-checkout.html @@ -11,7 +11,7 @@ - + diff --git a/src/app/branded/branded-checkout.component.js b/src/app/branded/branded-checkout.component.js index 1a45d9ec7..7698e33cb 100644 --- a/src/app/branded/branded-checkout.component.js +++ b/src/app/branded/branded-checkout.component.js @@ -182,6 +182,8 @@ export default angular onOrderFailed: '&', language: '@', showCoverFees: '@', - hideSpouseDetails: '@' + hideSpouseDetails: '@', + hideAnnual: '@', + hideQuarterly: '@' } }) diff --git a/src/app/branded/branded-checkout.tpl.html b/src/app/branded/branded-checkout.tpl.html index c8f7126e1..2e295049d 100644 --- a/src/app/branded/branded-checkout.tpl.html +++ b/src/app/branded/branded-checkout.tpl.html @@ -18,7 +18,9 @@ on-payment-failed="$ctrl.onPaymentFailed($event.donorDetails)" radio-station-api-url="$ctrl.radioStationApiUrl" radio-station-radius="$ctrl.radioStationRadius" - hide-spouse-details="$ctrl.hideSpouseDetails"> + hide-spouse-details="$ctrl.hideSpouseDetails" + hide-quarterly="$ctrl.hideQuarterly" + hide-annual="$ctrl.hideAnnual"> diff --git a/src/app/productConfig/productConfigForm/productConfigForm.component.js b/src/app/productConfig/productConfigForm/productConfigForm.component.js index e6193fe8c..710b91136 100644 --- a/src/app/productConfig/productConfigForm/productConfigForm.component.js +++ b/src/app/productConfig/productConfigForm/productConfigForm.component.js @@ -126,6 +126,9 @@ class ProductConfigFormController { } this.setDefaultAmount() this.setDefaultFrequency() + if (this.envService.read('isBrandedCheckout')) { + this.filterChosenFrequencies() + } }) const nextDrawDateObservable = this.commonService.getNextDrawDate() @@ -247,6 +250,9 @@ class ProductConfigFormController { .subscribe(data => { this.itemConfigForm.$setDirty() this.productData = data + if (this.envService.read('isBrandedCheckout')) { + this.filterChosenFrequencies() + } this.changingFrequency = false this.onStateChange({ state: 'unsubmitted' }) }, @@ -261,6 +267,21 @@ class ProductConfigFormController { } } + filterChosenFrequencies () { + let filteredFrequencies = this.productData.frequencies + if (this.hideQuarterly) { + filteredFrequencies = filteredFrequencies.filter((value) => { + return value.name !== 'QUARTERLY' + }) + } + if (this.hideAnnual) { + filteredFrequencies = filteredFrequencies.filter((value) => { + return value.name !== 'ANNUAL' + }) + } + this.productData.frequencies = filteredFrequencies + } + changeAmount (amount, retainCoverFees) { this.itemConfigForm.$setDirty() this.checkAmountChanged(amount) @@ -416,6 +437,8 @@ export default angular disableSessionRestart: '@', updateQueryParam: '&', submitted: '<', - onStateChange: '&' + onStateChange: '&', + hideAnnual: '<', + hideQuarterly: '<' } }) diff --git a/src/app/productConfig/productConfigForm/productConfigForm.component.spec.js b/src/app/productConfig/productConfigForm/productConfigForm.component.spec.js index de678fb24..798399e24 100644 --- a/src/app/productConfig/productConfigForm/productConfigForm.component.spec.js +++ b/src/app/productConfig/productConfigForm/productConfigForm.component.spec.js @@ -371,8 +371,14 @@ describe('product config form component', function () { it('orders frequency by name', () => { expect($ctrl.frequencyOrder({ name: 'NA' })).toEqual(0) expect($ctrl.frequencyOrder({ name: 'MON' })).toEqual(1) - expect($ctrl.frequencyOrder({ name: 'QUARTERLY' })).toEqual(2) - expect($ctrl.frequencyOrder({ name: 'ANNUAL' })).toEqual(3) + if (!this.hideQuarterly) { + expect($ctrl.frequencyOrder({ name: 'QUARTERLY' })).toEqual(2) + } + if (this.hideAnnual === true && !this.hideQuarterly) { + expect($ctrl.frequencyOrder({ name: 'ANNUAL' })).toEqual(3) + } else if (this.hideAnnual === true) { + expect($ctrl.frequencyOrder({ name: 'ANNUAL' })).toEqual(2) + } }) })