Skip to content

Render the back-office lists with the data table and post every state change with a token - #45

Merged
ThomasDaSilva merged 3 commits into
thelia-modules:mainfrom
ThomasDaSilva:fix/bo-data-table-lists
Oct 28, 2026
Merged

ThomasDaSilva merged 3 commits into
thelia-modules:mainfrom
ThomasDaSilva:fix/bo-data-table-lists

Conversation

@ThomasDaSilva

@ThomasDaSilva ThomasDaSilva commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

The labels and bordereaux pages of the Twig back office now use the theme's BoDataTable, like the other admin lists. Every action that deletes or creates a file is a POST that carries the admin token.

Lists

  • Labels: one table with selection, order (reference and date), destination (flag, city, zip code, country, label error), delivery (pickup point or home, with an icon), price, weight, signature, tracking number and actions. It fits a 1440 px screen with the sidebar open. It used to be 1760 px wide in a 1093 px container.
  • The "Process selected orders" button also sits above the table.
  • Each cell is a Twig macro, so every value goes through auto-escaping.
  • Dates, amounts, countries and delivery modules follow the interface language (request locale). They used to follow the edit language.
  • Bordereaux: same table, with download and delete row actions and a message when the list is empty.

Actions

  • Deleting a label is POST /admin/module/ColissimoLabel/label/delete with _token, number, and optionally edit-order and order_id. It replaces GET /label/delete/{number}. A second click on the same button redirects where it used to return a 500. An empty number is refused: it would have matched every file of the label folder.
  • Generating a bordereau is a POST with the token. After a generation, a deletion or a failed download, the page redirects to the list and shows the error as a flash message, so a reload posts nothing.
  • GET /label/{number} answers 404 for an unknown label or a missing file (it was a 500).
  • Deleting a label removes <number>.* and <number>-CN23.* at the root of the label folder only, using the stored tracking number. The old prefix match also removed the files of any longer number starting with the same characters.
  • Deleting a bordereau refuses anything that is not a file.
  • GET /customs-invoice/{orderId} answers 404 for a non-numeric id, an order without a label or a missing CN23 file (it was a 500 or an empty PDF), and sends the file with a proper Content-Disposition.
  • A SOAP answer without <messageContent> shows "Unknown error" on the bordereau page instead of a 500.

Order page

  • The order page of the theme only opens the shipments tab from the URL. The module script now opens the bill tab when the URL has ?tab=bill, which is where the module redirects after a label deletion and where the list links to.
  • The label generation error from the Colissimo web service is shown as text, no longer injected as HTML.
  • The label table of the order page stays within its column: the tracking number is the link to the La Poste tracking page (the full URL is no longer printed), the row actions are icon buttons with a title, and the table sits in a table-responsive wrapper. At 1440 px it used to be 1543 px wide in a 734 px column, which pushed the generate and delete buttons off screen.

Signature rule

New ColissimoLabel::canCountryBeNotSigned(string $numericIsoCode), used by canOrderBeNotSigned() and by the list. It compares strictly after padding the code to three digits, so 40 (Austria) and 56 (Belgium), as stored by a shop migrated from Thelia 2, are still accepted, as the former loose comparison did.

Performance

The list loads labels, delivery addresses, countries with their translation, currencies and order weights once for all orders. On a migrated database with 128 orders, that brings the page from 576 SQL queries to about 190. The rest comes mostly from Order::getTotalAmount() per order, kept so the total uses the core formula.

Breaking changes, hence 3.1.0

  • $CLEAR_LABEL_URL (loop colissimolabel.label-info) is now the URL to POST to. The Readme lists the parameters.
  • GET /label/delete/{number} and GET /bordereau/generate are gone.
  • BordereauController::listBordereauAction() takes the request and has no $error argument any more.

Tests

New PHPUnit tests in tests/, with no database: the HTTP method of the three state-changing routes, the signature rule, the refusal of an empty tracking number, the exact file deletion and the deletion limited to the root of the folder. They do not cover the token and permission checks, which need a booted kernel. From the root of a Thelia install:

vendor/bin/phpunit --bootstrap local/modules/ColissimoLabel/tests/bootstrap.php local/modules/ColissimoLabel/tests

tests/* is excluded from the module services.

How it was checked

Thelia 3 (main) with the default-twig back office, at 1440 px: label deletion from the list and from the order page, the bill tab opened after it, the order page label table and its buttons within the column, bordereau deletion, customs invoice download and its 404s, a wrong token (403), the old GET routes (404 and 405), PHPStan level 0 and Twig lint. All product weights of the test orders were 0 or empty, so the grouped weight query was only compared on those values. Bordereau generation was not run against the Colissimo web service.

@ThomasDaSilva
ThomasDaSilva merged commit 466269c into thelia-modules:main Oct 28, 2026
5 checks passed
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