addons-cm/website_sale_aplicoop/views/load_from_history_templates.xml
GitHub Copilot 5de7573fba [IMP] website_sale_aplicoop: accessibility and responsive polish — phase 8
Quantity control layout: changed from wrapping flex to deliberate two-row
grid so the add-to-cart button sits full-width underneath the stepper,
avoiding accidental line breaks and giving the primary action more pulsing
area. Also removed the /Kg suffix's redundant font rules.

Order card delivery row: reordered to badge-then-date (visually centred),
removed the "Delivery" label, and swapped bg-primary to text-bg-primary for
proper contrast on the home-delivery badge (3.13:1 minimum).

Tooltip translations: moved hardcoded static tooltips from data-bs-title
(untranslatable) to title (QWeb-translatable). Handled the edge case of
"Save Cart" and "Back to Cart" which had translations but no model_terms
reference in the POT, causing the merge to discard them — added the view
reference so translations now apply.

Load-from-history page: added accessibility: a visible status message
("Loading your order…"), a <noscript> fallback with link to the group
order, lang and viewport meta tags, and localised strings for all three
languages. Gave the page a minimal inline style block since it does not
inherit the token system (no website.layout).

Translations: 11 new entries (es/eu/ca) for new/reworded UI strings, plus
two code catalogue entries (products found, Close) that needed the
#. odoo-python comment for _() resolution. Documented the silent-failure
pattern in docs/TRANSLATIONS.md: the POT merge, untranslatable attributes,
and missing code comments.

Tests: 246 passing. Pre-commit: clean.

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2026-08-16 11:34:38 +02:00

110 lines
6.8 KiB
XML

<?xml version="1.0" encoding="UTF-8"?>
<odoo>
<data>
<!-- Template to load items from history and redirect to group order -->
<template id="eskaera_load_from_history" name="Load Order from History">
<html t-att-lang="page_lang or 'en-US'">
<head>
<meta charset="utf-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>Loading Order...</title>
<!-- Standalone document: it does not go through website.layout, so
web.assets_frontend is not loaded and there is no design token to
reach for. Hence the local style block. -->
<style>
.eskaera-redirect-page {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
min-height: 60vh;
padding: 2rem 1rem;
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
"Helvetica Neue", Arial, sans-serif;
text-align: center;
color: #1a202c;
}
.eskaera-redirect-message {
font-size: 1.125rem;
}
</style>
</head>
<body>
<!-- This page only stages the cart in sessionStorage and redirects, but it is
still a page a person can land on: give it something to read while that
happens, announced politely, and a way out if the script never runs. -->
<main class="eskaera-redirect-page">
<p class="eskaera-redirect-message" role="status">Loading your order…</p>
<noscript>
<p>This page needs JavaScript to load the order into your cart.</p>
<p>
<a t-att-href="group_order_url">Continue to the group order</a>
</p>
</noscript>
</main>
<script type="text/javascript">
// Items are embedded directly in the script (pre-serialized JSON from controller)
var itemsJson = <t t-raw="items_json"/>; // This is a JSON array/string
var groupOrderId = <t t-esc="group_order_id"/>;
var groupOrderUrl = '<t t-esc="group_order_url"/>';
var saleOrderName = '<t t-esc="sale_order_name"/>';
var pickupDay = '<t t-esc="pickup_day or ''"/>';
var pickupDate = '<t t-esc="pickup_date or ''"/>';
var pickupSlotLabel = '<t t-esc="pickup_slot_label or ''"/>';
var homeDelivery = <t t-esc="home_delivery and 'true' or 'false'"/>;
var sameGroupOrder = <t t-esc="same_group_order and 'true' or 'false'"/>;
// Product availability warning
var hasUnavailableItems = <t t-esc="has_unavailable_items and 'true' or 'false'"/>;
var warningMessage = '<t t-esc="warning_message or ''"/>';
console.log('load_from_history template: groupOrderId=', groupOrderId);
console.log('load_from_history template: saleOrderName=', saleOrderName);
console.log('load_from_history template: pickupDay=', pickupDay);
console.log('load_from_history template: pickupDate=', pickupDate);
console.log('load_from_history template: homeDelivery=', homeDelivery);
console.log('load_from_history template: sameGroupOrder=', sameGroupOrder);
console.log('load_from_history template: hasUnavailableItems=', hasUnavailableItems);
console.log('load_from_history template: itemsJson type=', typeof itemsJson);
console.log('load_from_history template: itemsJson value=', itemsJson);
// If itemsJson is already a string, use it directly; if it's an array, stringify it
var itemsJsonString = (typeof itemsJson === 'string') ? itemsJson : JSON.stringify(itemsJson);
// Store items to sessionStorage
sessionStorage['load_from_history_' + groupOrderId] = itemsJsonString;
// Store sale order name separately
sessionStorage['load_from_history_order_name_' + groupOrderId] = saleOrderName;
// Store pickup fields ONLY if from same group order
if (sameGroupOrder === 'true') {
sessionStorage['load_from_history_pickup_day_' + groupOrderId] = pickupDay;
sessionStorage['load_from_history_pickup_date_' + groupOrderId] = pickupDate;
// Only store a human-readable label for pickup slot.
// Do NOT persist or expose internal slot IDs to sessionStorage.
sessionStorage['load_from_history_pickup_slot_label_' + groupOrderId] = pickupSlotLabel;
sessionStorage['load_from_history_home_delivery_' + groupOrderId] = homeDelivery;
console.log('Saved pickup fields (same group order)');
} else {
console.log('Skipped saving pickup fields (different group order - will use current group order days)');
}
// Store warning about unavailable products if they exist
if (hasUnavailableItems === 'true') {
sessionStorage['load_from_history_warning_' + groupOrderId] = warningMessage;
console.log('Unavailable products detected:', warningMessage);
}
console.log('Saved to sessionStorage[load_from_history_' + groupOrderId + ']:', itemsJsonString);
console.log('Saved order name to sessionStorage[load_from_history_order_name_' + groupOrderId + ']:', saleOrderName);
// Redirect to group order page
// The JavaScript on that page will detect this and load the items
window.location.href = groupOrderUrl;
</script>
</body>
</html>
</template>
</data>
</odoo>