diff --git a/src/app/core/models/payment-method/payment-method.mapper.spec.ts b/src/app/core/models/payment-method/payment-method.mapper.spec.ts index e9e9a207fd..0f1b719cbc 100644 --- a/src/app/core/models/payment-method/payment-method.mapper.spec.ts +++ b/src/app/core/models/payment-method/payment-method.mapper.spec.ts @@ -88,6 +88,12 @@ describe('Payment Method Mapper', () => { name: 'BIC', type: 'string', }, + { + displayName: 'paymentMethodId', + hidden: true, + name: 'paymentMethodId', + type: 'string', + }, ]; it(`should return PaymentMethod when getting a PaymentMethodData`, () => { @@ -119,9 +125,10 @@ describe('Payment Method Mapper', () => { const paymentMethod = PaymentMethodMapper.fromData(paymentMethodData)[0]; expect(paymentMethod.saveAllowed).toBeTrue(); - expect(paymentMethod.parameters).toHaveLength(3); + expect(paymentMethod.parameters).toHaveLength(4); expect(paymentMethod.parameters[0].type).toEqual('input'); expect(paymentMethod.parameters[0].key).toEqual('holder'); + expect(paymentMethod.parameters[0].hide).toBeFalse(); expect(paymentMethod.parameters[0].templateOptions.type).toEqual('text'); expect(paymentMethod.parameters[0].templateOptions.required).toBeTrue(); @@ -129,10 +136,12 @@ describe('Payment Method Mapper', () => { expect(paymentMethod.parameters[1].templateOptions.minLength).toBe(15); expect(paymentMethod.parameters[1].templateOptions.maxLength).toBe(34); expect(paymentMethod.parameters[1].templateOptions.attributes).toBeObject(); + + expect(paymentMethod.parameters[3].hide).toBeTrue(); }); }); - describe('fromOptions', () => { + describe('Payment Method Mapper', () => { const paymentMethodsData = { payments: [ { diff --git a/src/app/core/models/payment-method/payment-method.mapper.ts b/src/app/core/models/payment-method/payment-method.mapper.ts index 32d9c4cd4a..08fa018606 100644 --- a/src/app/core/models/payment-method/payment-method.mapper.ts +++ b/src/app/core/models/payment-method/payment-method.mapper.ts @@ -172,6 +172,7 @@ export class PaymentMethodMapper { : undefined, attributes: {}, }, + hide: p.hidden, }; if (p.constraints) { diff --git a/src/app/pages/checkout-payment/payment-concardis-directdebit/payment-concardis-directdebit.component.ts b/src/app/pages/checkout-payment/payment-concardis-directdebit/payment-concardis-directdebit.component.ts index efdd155282..8182821d7c 100644 --- a/src/app/pages/checkout-payment/payment-concardis-directdebit/payment-concardis-directdebit.component.ts +++ b/src/app/pages/checkout-payment/payment-concardis-directdebit/payment-concardis-directdebit.component.ts @@ -76,7 +76,7 @@ export class PaymentConcardisDirectdebitComponent extends PaymentConcardisCompon * hide fields without labels and enrich mandate reference and mandate text with corresponding values from hosted payment page parameters */ getFieldConfig(): FormlyFieldConfig[] { - return this.paymentMethod.parameters.map(param => (!param.templateOptions.label ? this.modifyParam(param) : param)); + return this.paymentMethod.parameters.map(param => (param.hide ? this.modifyParam(param) : param)); } private modifyParam(p: FormlyFieldConfig): FormlyFieldConfig { @@ -85,7 +85,7 @@ export class PaymentConcardisDirectdebitComponent extends PaymentConcardisCompon if (param.key === 'mandateReference') { param.defaultValue = this.getParamValue('mandateId', ''); } - param.hide = true; + if (param.key === 'mandateText') { param.type = 'checkbox'; param.fieldGroupClassName = 'offset-md-4 col-md-8'; diff --git a/src/app/shared/forms-dynamic/components/input-dynamic/input-dynamic.component.html b/src/app/shared/forms-dynamic/components/input-dynamic/input-dynamic.component.html index bd4fbab3e4..d05c24ca80 100644 --- a/src/app/shared/forms-dynamic/components/input-dynamic/input-dynamic.component.html +++ b/src/app/shared/forms-dynamic/components/input-dynamic/input-dynamic.component.html @@ -1,5 +1,5 @@ { expect(element.querySelector('ish-input')).toBeTruthy(); }); + it('should not display dynamic input when supplied as field but hide option is true', () => { + component.fields = [ + { + key: 'text', + type: 'input', + hide: true, + templateOptions: { + type: 'text', + }, + }, + ]; + + fixture.detectChanges(); + expect(element.querySelector('ish-input')).toBeFalsy(); + }); + it('should display dynamic select when supplied as field', () => { component.fields = [ { @@ -73,6 +89,20 @@ describe('Forms Dynamic', () => { expect(element.querySelector('ish-select')).toBeTruthy(); }); + it('should display dynamic select when supplied as field but hide option is true', () => { + component.fields = [ + { + key: 'text', + type: 'select', + hide: true, + templateOptions: {}, + }, + ]; + + fixture.detectChanges(); + expect(element.querySelector('ish-select')).toBeFalsy(); + }); + it('should display dynamic checkbox when supplied as field', () => { component.fields = [ {