Przejdź do głównej zawartości

Class: OrlenMapManager

Orlen Paczka map widget (carrier documentation „Widget mapy ORLEN Paczka" v1.3).

Unlike the InPost geowidget this one is a plain element carrying a marker class — the carrier's script picks it up and opens itself as a modal — and it reports the choice with a DOM event.

The map only offers a choice when it has somewhere to put it. The carrier renders its "select" button for a point ONLY when the mount element names the fields to write the choice into (data-target for the point code, data-label for its name). Without them it builds a map to look at: the buyer sees the points, and no way to pick one. The adapter therefore creates those fields itself — a storefront should not have to know this to get a working map.

The choice arrives as an event that does NOT bubble, fired on whichever element the carrier built (the mount element for an embedded map, its modal for the pop-up variant). A listener on document in the bubbling phase never sees it — the buyer clicks "select" and the checkout learns nothing, an outage that looks like a working shop. The capture phase passes through document on the way down to any element, so one listener there sees every variant without guessing where the carrier chose to fire it.

The value the buyer's choice yields (destinationCode, e.g. WS-241050-U6-12) is exactly what the carrier expects back when the parcel is announced — pass it through unchanged.

The map is built by a one-off scan, so the second open needs a nudge. The script builds every element carrying the mount class at the moment it loads, and never watches for elements added later. A buyer who closes the map and comes back finds the script already in the document, no scan pending and an empty frame — unless the adapter asks for another scan, which is what it does below.

Extends​

Constructors​

Constructor​

new OrlenMapManager(options): OrlenMapManager

Parameters​

options​

PickupWidgetMountOptions

Returns​

OrlenMapManager

Inherited from​

AbstractPickupWidgetManager.constructor

Properties​

container​

protected container: HTMLElement | null = null

Inherited from​

AbstractPickupWidgetManager.container


descriptor​

protected readonly descriptor: PickupWidgetDescriptor

Inherited from​

AbstractPickupWidgetManager.descriptor


element​

protected element: HTMLElement | null = null

Inherited from​

AbstractPickupWidgetManager.element


onSelect​

protected readonly onSelect: (point) => void

Parameters​

point​

PickupPointSelection

Returns​

void

Inherited from​

AbstractPickupWidgetManager.onSelect


token​

protected readonly token: string

Inherited from​

AbstractPickupWidgetManager.token

Methods​

afterAssetsLoaded()​

protected afterAssetsLoaded(__namedParameters): void

The carrier's assets are in the document and the mount element is already in place.

Nothing to do by default: a widget that is a custom element is picked up by the browser itself, whenever the script defines it. A carrier that builds its maps in a one-off scan overrides this — and may throw, because a map that cannot be built has to be visible to the storefront as a failure rather than as a silently empty frame.

Parameters​

__namedParameters​

PickupWidgetAssetsState

Returns​

void

Overrides​

AbstractPickupWidgetManager.afterAssetsLoaded


applyDescriptorAttributes()​

protected applyDescriptorAttributes(element): void

Apply the descriptor's attributes to a freshly created element.

Parameters​

element​

HTMLElement

Returns​

void

Inherited from​

AbstractPickupWidgetManager.applyDescriptorAttributes


createElement()​

protected createElement(): HTMLElement

Create the element the carrier's script turns into a map, with its attributes already set.

Attributes MUST be in place before the element enters the document: a custom element reads its configuration once, when it is connected, and a token set afterwards is ignored. That failure is invisible on the first open (the script is still loading, so the upgrade happens after the attribute lands) and appears only on the second — which is why it belongs here rather than in every storefront that renders a map.

Returns​

HTMLElement

Overrides​

AbstractPickupWidgetManager.createElement


destroy()​

destroy(): void

Remove the widget and release everything it registered. Safe to call more than once.

Returns​

void

Inherited from​

AbstractPickupWidgetManager.destroy


mount()​

mount(container): Promise<void>

Mount the widget: the element enters the document FIRST, the carrier's assets follow.

That order is the whole difference between a map and an empty frame. A carrier whose widget is a plain element scans the document ONCE, when its script finishes loading, and never looks again — so an element inserted after that scan is never turned into a map, and nothing reports a failure. Waiting for the script before inserting made that the normal case; the custom-element carrier survived it only because a browser upgrades elements whenever they are defined, whenever that happens to be. Inserting first is correct for both.

A failure removes the element again. An empty box left in the checkout reads as a map that is still loading, and the storefront needs the rejection to fall back to point search.

Parameters​

container​

HTMLElement

Returns​

Promise<void>

Inherited from​

AbstractPickupWidgetManager.mount


subscribe()​

protected subscribe(): void

Start listening for the buyer's choice.

Returns​

void

Overrides​

AbstractPickupWidgetManager.subscribe


unsubscribe()​

protected unsubscribe(): void

Stop listening and release anything registered globally.

Returns​

void

Overrides​

AbstractPickupWidgetManager.unsubscribe