diff --git a/custom-elements.json b/custom-elements.json index 14e6bba87..4fd3f17c4 100644 --- a/custom-elements.json +++ b/custom-elements.json @@ -18682,39 +18682,15 @@ { "name": "foxy-payment-card", "path": "./src/elements/public/PaymentCard/index.ts", - "description": "Basic card displaying a payment.\n\nNote: payment gateway names need to be loaded separately. You can obtain\nthem from `fx:property_helpers` using your own Backend API proxy or just hardcode the values\nyou need. Once you have the gateway names, call `I18n.setGateways(names)`.", + "description": "Basic card displaying a payment resource (`fx:payment`).", "attributes": [ { - "name": "mode", - "type": "string", - "default": "\"production\"" - }, - { - "name": "readonly", - "type": "boolean", - "default": "false" + "name": "hosted-payment-gateways-helper", + "description": "URL of the `fx:hosted_payment_gateways` property helper resource." }, { - "name": "readonlycontrols", - "default": "\"False\"" - }, - { - "name": "disabled", - "type": "boolean", - "default": "false" - }, - { - "name": "disabledcontrols", - "default": "\"False\"" - }, - { - "name": "hidden", - "type": "boolean", - "default": "false" - }, - { - "name": "hiddencontrols", - "default": "\"False\"" + "name": "payment-gateways-helper", + "description": "URL of the `fx:payment_gateways` property helper resource." }, { "name": "ns", @@ -18757,60 +18733,14 @@ ], "properties": [ { - "name": "templates", - "type": "Templates", - "default": "{}" - }, - { - "name": "mode", - "attribute": "mode", - "type": "string", - "default": "\"production\"" + "name": "hostedPaymentGatewaysHelper", + "attribute": "hosted-payment-gateways-helper", + "description": "URL of the `fx:hosted_payment_gateways` property helper resource." }, { - "name": "readonly", - "attribute": "readonly", - "type": "boolean", - "default": "false" - }, - { - "name": "readonlyControls", - "attribute": "readonlycontrols", - "default": "\"False\"" - }, - { - "name": "disabled", - "attribute": "disabled", - "type": "boolean", - "default": "false" - }, - { - "name": "disabledControls", - "attribute": "disabledcontrols", - "default": "\"False\"" - }, - { - "name": "hidden", - "attribute": "hidden", - "type": "boolean", - "default": "false" - }, - { - "name": "hiddenControls", - "attribute": "hiddencontrols", - "default": "\"False\"" - }, - { - "name": "readonlySelector", - "type": "BooleanSelector" - }, - { - "name": "disabledSelector", - "type": "BooleanSelector" - }, - { - "name": "hiddenSelector", - "type": "BooleanSelector" + "name": "paymentGatewaysHelper", + "attribute": "payment-gateways-helper", + "description": "URL of the `fx:payment_gateways` property helper resource." }, { "name": "ns", @@ -18823,6 +18753,10 @@ "type": "Translator", "default": "\"(key, options) => {\\n const I18nElement = customElements.get('foxy-i18n') as typeof I18n | undefined;\\n\\n if (!I18nElement) return key;\\n\\n const keys = [\\n ...this.ns\\n .split(' ')\\n .reverse()\\n .map(v => v.trim())\\n .filter(v => v.length > 0)\\n .reverse()\\n .map((v, i, a) => `${v}:${[...a.slice(i + 1), key].join('.')}`),\\n `shared:${key}`,\\n ];\\n\\n return I18nElement.i18next.t(keys, { lng: this.lang, ...options }).toString();\\n }\"" }, + { + "name": "isBodyReady", + "type": "boolean" + }, { "name": "UpdateEvent", "description": "Instances of this event are dispatched on an element whenever it changes its\nstate (e.g. when going from `busy` to `idle` or on `form` data change).\nThis event isn't cancelable, and it does not bubble.", @@ -18910,38 +18844,6 @@ "name": "fetch", "description": "Instance of `NucleonElement.API.FetchEvent`. Emitted before each API request." } - ], - "slots": [ - { - "name": "title:before" - }, - { - "name": "title:after" - }, - { - "name": "subtitle:before" - }, - { - "name": "subtitle:after" - }, - { - "name": "card-info:before" - }, - { - "name": "card-info:after" - }, - { - "name": "fraud-risk:before" - }, - { - "name": "fraud-risk:after" - }, - { - "name": "processor-response:before" - }, - { - "name": "processor-response:after" - } ] }, { @@ -21716,40 +21618,8 @@ { "name": "foxy-shipment-card", "path": "./src/elements/public/ShipmentCard/index.ts", - "description": "Basic card displaying a shipment.", + "description": "Basic card displaying a shipment (`fx:shipment`).", "attributes": [ - { - "name": "mode", - "type": "string", - "default": "\"production\"" - }, - { - "name": "readonly", - "type": "boolean", - "default": "false" - }, - { - "name": "readonlycontrols", - "default": "\"False\"" - }, - { - "name": "disabled", - "type": "boolean", - "default": "false" - }, - { - "name": "disabledcontrols", - "default": "\"False\"" - }, - { - "name": "hidden", - "type": "boolean", - "default": "false" - }, - { - "name": "hiddencontrols", - "default": "\"False\"" - }, { "name": "ns", "type": "string", @@ -21790,61 +21660,6 @@ } ], "properties": [ - { - "name": "templates", - "default": "{}" - }, - { - "name": "mode", - "attribute": "mode", - "type": "string", - "default": "\"production\"" - }, - { - "name": "readonly", - "attribute": "readonly", - "type": "boolean", - "default": "false" - }, - { - "name": "readonlyControls", - "attribute": "readonlycontrols", - "default": "\"False\"" - }, - { - "name": "disabled", - "attribute": "disabled", - "type": "boolean", - "default": "false" - }, - { - "name": "disabledControls", - "attribute": "disabledcontrols", - "default": "\"False\"" - }, - { - "name": "hidden", - "attribute": "hidden", - "type": "boolean", - "default": "false" - }, - { - "name": "hiddenControls", - "attribute": "hiddencontrols", - "default": "\"False\"" - }, - { - "name": "readonlySelector", - "type": "BooleanSelector" - }, - { - "name": "disabledSelector", - "type": "BooleanSelector" - }, - { - "name": "hiddenSelector", - "type": "BooleanSelector" - }, { "name": "ns", "attribute": "ns", @@ -26034,6 +25849,12 @@ { "name": "google-analytics:after" }, + { + "name": "google-tag:before" + }, + { + "name": "google-tag:after" + }, { "name": "troubleshooting:before" }, @@ -26930,6 +26751,14 @@ "path": "./src/elements/public/Transaction/index.ts", "description": "Transaction summary page (`fx:transaction`).", "attributes": [ + { + "name": "hosted-payment-gateways-helper", + "description": "URL of the `fx:hosted_payment_gateways` property helper resource." + }, + { + "name": "payment-gateways-helper", + "description": "URL of the `fx:payment_gateways` property helper resource." + }, { "name": "ns", "type": "string", @@ -27007,6 +26836,16 @@ } ], "properties": [ + { + "name": "hostedPaymentGatewaysHelper", + "attribute": "hosted-payment-gateways-helper", + "description": "URL of the `fx:hosted_payment_gateways` property helper resource." + }, + { + "name": "paymentGatewaysHelper", + "attribute": "payment-gateways-helper", + "description": "URL of the `fx:payment_gateways` property helper resource." + }, { "name": "getSubscriptionPageHref" }, @@ -27324,6 +27163,10 @@ "type": "Translator", "default": "\"(key, options) => {\\n const I18nElement = customElements.get('foxy-i18n') as typeof I18n | undefined;\\n\\n if (!I18nElement) return key;\\n\\n const keys = [\\n ...this.ns\\n .split(' ')\\n .reverse()\\n .map(v => v.trim())\\n .filter(v => v.length > 0)\\n .reverse()\\n .map((v, i, a) => `${v}:${[...a.slice(i + 1), key].join('.')}`),\\n `shared:${key}`,\\n ];\\n\\n return I18nElement.i18next.t(keys, { lng: this.lang, ...options }).toString();\\n }\"" }, + { + "name": "isBodyReady", + "type": "boolean" + }, { "name": "UpdateEvent", "description": "Instances of this event are dispatched on an element whenever it changes its\nstate (e.g. when going from `busy` to `idle` or on `form` data change).\nThis event isn't cancelable, and it does not bubble.", diff --git a/src/elements/public/AdminSubscriptionCard/AdminSubscriptionCard.test.ts b/src/elements/public/AdminSubscriptionCard/AdminSubscriptionCard.test.ts index 155c1da9f..abe22236c 100644 --- a/src/elements/public/AdminSubscriptionCard/AdminSubscriptionCard.test.ts +++ b/src/elements/public/AdminSubscriptionCard/AdminSubscriptionCard.test.ts @@ -692,4 +692,50 @@ describe('AdminSubscriptionCard', () => { expect(element.renderRoot).to.include.text('test@test-remote.com'); }); + + it('renders customer name in line 3 from embedded fx:customer', async () => { + type Subscription = Resource; + + const router = createRouter(); + const href = 'https://demo.api/hapi/subscriptions/0?zoom=customer'; + const data = await getTestData(href, router); + + const element = await fixture(html` + router.handleEvent(evt)} + > + + `); + + data._embedded['fx:customer'].first_name = 'Test'; + data._embedded['fx:customer'].last_name = 'User'; + element.data = data; + + await waitUntil(() => element.isBodyReady, '', { timeout: 5000 }); + expect(element.renderRoot).to.include.text('Test User'); + }); + + it('renders customer name in line 3 from remote fx:customer', async () => { + const router = createRouter(); + const href = 'https://demo.api/hapi/subscriptions/0'; + const data = await getTestData>(href, router); + + const element = await fixture(html` + router.handleEvent(evt)} + > + + `); + + await new Card.API(element).fetch(data._links['fx:customer'].href, { + method: 'PATCH', + body: JSON.stringify({ first_name: 'Test', last_name: 'User' }), + }); + + await waitUntil(() => element.isBodyReady, '', { timeout: 5000 }); + expect(element.renderRoot).to.include.text('Test User'); + }); }); diff --git a/src/elements/public/AdminSubscriptionCard/AdminSubscriptionCard.ts b/src/elements/public/AdminSubscriptionCard/AdminSubscriptionCard.ts index 313bf24e7..2e932ab3a 100644 --- a/src/elements/public/AdminSubscriptionCard/AdminSubscriptionCard.ts +++ b/src/elements/public/AdminSubscriptionCard/AdminSubscriptionCard.ts @@ -45,12 +45,15 @@ export class AdminSubscriptionCard extends Base { private readonly __templateSetLoaderId = 'templateSetLoader'; + private readonly __customerLoaderId = 'customerLoader'; + private readonly __itemsLoaderId = 'itemsLoader'; private readonly __storeLoaderId = 'storeLoader'; renderBody(): TemplateResult { const isFailed = !!this.data?.first_failed_transaction_date; + const customer = this.__customer; const cart = this.__transactionTemplate; const priceKey = this.__priceKey; @@ -97,6 +100,15 @@ export class AdminSubscriptionCard extends Base { > + +