Skip to content

fix: make the label screen work in the default-twig back office - #41

Open
mabruchet wants to merge 4 commits into
thelia-modules:mainfrom
mabruchet:fix/order-edit-bill-tab
Open

mabruchet wants to merge 4 commits into
thelia-modules:mainfrom
mabruchet:fix/order-edit-bill-tab

Conversation

@mabruchet

Copy link
Copy Markdown

Problem

On a Thelia 3 shop with the default-twig back office, the label generator of the order page does nothing:

  1. order-edit-js.html.twig inserts the label table into #bill. In default-twig the invoicing pane is #tab-bill, so the table and the "Generate new label" button never appear.
  2. The inline script calls bootstrap.Modal.getOrCreateInstance() while the page is still being parsed. In default-twig Bootstrap is exposed by a deferred module, so the script stops with bootstrap is not defined before the click handlers are bound.
  3. When the generation fails (WSDL unreachable, bad credentials, a SOAP fault), OrderController::generateLabelAction() redirects to the label list. The modal expects JSON (json.error), parses the HTML of the redirect and shows SyntaxError: Unexpected token '<'.

The same SOAP failure on /admin/module/ColissimoLabel/bordereau/generate is not caught and ends as a 500.

Changes

  • order-edit-js.html.twig: look for #tab-bill first and fall back to #bill; run the script on DOMContentLoaded.
  • OrderController: with ?edit-order=1, a failure returns {"error": "<message>"} with a 500 status instead of a redirect. The label page keeps its redirect and its error context.
  • BordereauController: a SoapFault is shown on the bordereau list like the other errors of that page.

How to check

On a base where the endpoint of the module points to an address that never answers (for example https://example.invalid/ws?wsdl):

  1. Open an order shipped by Colissimo, tab "Invoicing and delivery": the label table and both buttons are there.
  2. "Generate new label", enter a weight, print: the modal shows SOAP-ERROR: Parsing WSDL: Couldn't load from ..., the response is application/json with status 500, and no row is added to colissimo_label.
  3. /admin/module/ColissimoLabel/bordereau/generate shows the same message in the page.

Checked in a browser on Thelia 3.2 / default-twig. No change to the SOAP request, the stored data or the configuration keys.

Not covered

The default (Smarty) templates are untouched. A successful generation against the real service was not run.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant