From cd497d0e2f8f1534a0277e48ddc0d882dcaad1eb Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 29 Oct 2026 02:41:00 +0000 Subject: [PATCH] Retail: a Manager button on the order screen (#432) In retail, the order screen had only Log Out where restaurants have Tables, and logging back in starts on the menu, so a manager had no way to the Manager menu (or to switch the store back to restaurant). A manager now gets Manager where restaurants have Send (retail has no Send); a cashier doesn't see it. Stores that edited their order page get the button too: a new starter button may share a spot with one shown only for another way of serving. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_015JJaarEt6reBcV4yp7BjZA --- modern/README.md | 2 +- modern/docs/manual/manual.html | 1 + modern/layout/layout.cpp | 16 +++++++++-- modern/seed/pages/order-template-phone.json | 10 +++++++ modern/seed/pages/order-template.json | 30 +++++++++++++++++++++ modern/tests/test_layout.cpp | 24 +++++++++++++++++ modern/tests/test_truck.cpp | 10 ++++++- 7 files changed, 89 insertions(+), 4 deletions(-) diff --git a/modern/README.md b/modern/README.md index 5556cdeb3..456a2837e 100644 --- a/modern/README.md +++ b/modern/README.md @@ -358,7 +358,7 @@ A screen where guests order on their own, then pay at the counter. Store Settings → *How you serve* (`PosSettings::serviceMode`), or one screen's Manager → Terminals → *How this screen serves* (`TerminalConfig::service`); the setup guide asks on its first page. Code: `app/pos_truck.cpp`. - **Food truck:** nobody logs in. The session runs as the built-in *Counter* (role cashier: orders and payments, never a manager's), and the screen starts on the menu; after a payment, the menu again. Idle and Log Out don't sign the Counter out. A page it may not open (Manager) goes to the login page for a PIN and opens once someone steps in; their Log Out goes back to the Counter with the order still open. *Ask who's working* makes the first PIN the counter's person (clocked in, credited) until **Switch Person**. - **Orders:** quick checks on a truck are numbered from 1 each business day (`Check::orderNumber`, label "#27 Maria" once named) and carry the guest's pager (`Check::pager`, + Pager on the check; one waiting order a pager). The **Orders** page (`truckOrders` widget) lists those sent and not picked up: **Ready** (`readyAt`) tells every truck screen "#27 Maria is ready: buzz pager 12", **Picked Up** (`pickedUpAt`) takes it off. A kitchen screen bumping the last of an order calls it too. Pagers are buzzed by hand on the pager system's transmitter. -- **Retail:** logins stay; the menu comes first instead of the floor plan, and the order screen has Log Out where restaurants have Tables. Lines rung in are `kitchenHide` (no tickets, no kitchen screen) and Send is hidden: Pay finishes the sale. A scan on any page rings the item in and goes back to the sale (`LayoutController::scanned`). +- **Retail:** logins stay; the menu comes first instead of the floor plan, and the order screen has Log Out where restaurants have Tables, and Manager (for a manager only: `showWhen.login` `manager`) where they have Send. Lines rung in are `kitchenHide` (no tickets, no kitchen screen) and Send is hidden: Pay finishes the sale. A scan on any page rings the item in and goes back to the sale (`LayoutController::scanned`). - **Now serving:** on a truck, the customer display shows Ready and Preparing between guests, and a Ready strip while the next guest orders (`CustomerDisplay.qml`, from `truckOrders`). - **Offline:** a screen's offline kit carries `firstOrderNumber`, a hundred on from the store's last order for each screen, so orders taken offline never share a number with the store's. `setCustomer` and `setPager` work offline; taken in, the order keeps its number, name and pager. - Buttons can show for one way only: `showWhen.service` (`restaurant`, `foodTruck`, `retail`, or several with commas). diff --git a/modern/docs/manual/manual.html b/modern/docs/manual/manual.html index 01080781e..baa401abe 100644 --- a/modern/docs/manual/manual.html +++ b/modern/docs/manual/manual.html @@ -903,6 +903,7 @@

How you serve: restaurant, food truck or retail

  • Food truck: nobody logs in (below).
  • Retail: staff still log in, so each sale is the cashier's. After login they start on the menu instead of the floor plan, and the order screen has Log Out where restaurants have Tables.
      +
    • Manager's pages: when a manager is logged in, the order screen has Manager where restaurants have Send. It opens the Manager menu: the Dashboard, reports and the rest, and Settings → How you serve to switch the store back to restaurant. A cashier doesn't see it: they log out, and the manager logs in.
    • Scan from anywhere: a barcode scanned on any screen (even Pay, for the item the customer remembers at the last moment) rings the item in and goes back to the sale. An empty check says Scan or touch an item to start a sale.
    • No kitchen: nothing a shop sells goes to a kitchen printer or a kitchen screen, and there's no Send: Pay finishes the sale.
  • diff --git a/modern/layout/layout.cpp b/modern/layout/layout.cpp index 703d7dc56..fde3b9793 100644 --- a/modern/layout/layout.cpp +++ b/modern/layout/layout.cpp @@ -325,7 +325,7 @@ QString Layout::fingerprint(const Page &page) const QStringList &Layout::newStarterButtons() { - static const QStringList buttons = {u"check-options#tax-exempt"_s}; + static const QStringList buttons = {u"check-options#tax-exempt"_s, u"order-template#flow-manager"_s}; return buttons; } @@ -335,10 +335,22 @@ namespace { // that's free; else into its column of buttons (the same x and width) after // the one above it in the starter, the column's buttons made shorter to fit // in the same space (no shorter than a finger: 64 units). +// Shown only where a store serves another way (retail's buttons, a +// restaurant's): never on the same screen, so in the same spot is fine. +bool otherService(const Zone &a, const Zone &b) +{ + const auto modes = [](const Zone &z) { + const QString s = z.extra.value(u"showWhen").toObject().value(u"service").toString(); + return s.isEmpty() ? QStringList{} : s.split(u','); + }; + const QStringList ma = modes(a), mb = modes(b); + return !ma.isEmpty() && !mb.isEmpty() && std::ranges::none_of(ma, [&](const QString &m) { return mb.contains(m); }); +} + bool placeNewButton(Page &mine, const Page &fresh, Zone zone) { const auto free = [&](const QRect &r) { - return std::ranges::none_of(mine.zones, [&](const Zone &z) { return z.rect.intersects(r); }); + return std::ranges::none_of(mine.zones, [&](const Zone &z) { return z.rect.intersects(r) && !otherService(z, zone); }); }; if (free(zone.rect)) { mine.zones.append(zone); diff --git a/modern/seed/pages/order-template-phone.json b/modern/seed/pages/order-template-phone.json index 3ae1a5edc..14f07ca8d 100644 --- a/modern/seed/pages/order-template-phone.json +++ b/modern/seed/pages/order-template-phone.json @@ -193,6 +193,16 @@ "h": 130 } }, + { + "id": "flow-manager", + "shared": true, + "rect": { + "x": 370, + "y": 2134, + "w": 338, + "h": 130 + } + }, { "id": "flow-pay", "shared": true, diff --git a/modern/seed/pages/order-template.json b/modern/seed/pages/order-template.json index de19d6622..80cfbe34d 100644 --- a/modern/seed/pages/order-template.json +++ b/modern/seed/pages/order-template.json @@ -240,6 +240,30 @@ "service": "restaurant,foodTruck" } }, + { + "id": "flow-manager", + "kind": "button", + "rect": { + "x": 1486, + "y": 980, + "w": 202, + "h": 84 + }, + "shape": "rect", + "behavior": "blink", + "label": "Manager", + "actions": [ + { + "type": "jump", + "mode": "push", + "role": "manager" + } + ], + "showWhen": { + "service": "retail", + "login": "manager" + } + }, { "id": "flow-pay", "kind": "button", @@ -560,6 +584,12 @@ "y": 16, "w": 176, "h": 72 + }, + "flow-manager": { + "x": 1440, + "y": 980, + "w": 216, + "h": 84 } } } diff --git a/modern/tests/test_layout.cpp b/modern/tests/test_layout.cpp index f9bf57804..8379a2cbd 100644 --- a/modern/tests/test_layout.cpp +++ b/modern/tests/test_layout.cpp @@ -364,6 +364,30 @@ TEST_CASE("Starter update: a new starter button joins a page the store edited", CHECK_FALSE(later.page(u"check-options"_s)->zone(u"tax-exempt"_s)); } +TEST_CASE("Starter update: retail's Manager button joins an order page the store edited", "[layout][starter]") +{ + const auto starter = Layout::loadDirectory(QStringLiteral(VTM_SEED_DIR)); + REQUIRE(starter); + // The store's order page as it was before the button (and edited here). + Page old = *starter->page(u"order-template"_s); + old.zones.removeIf([](const Zone &z) { return z.id == u"flow-manager"_s; }); + const QHash installed{{u"order-template"_s, Layout::fingerprint(old)}}; + for (Zone &z : old.zones) + if (z.id == u"flow-pay"_s) + z.label = u"Checkout"_s; // edited here + Layout saved; + saved.pages = {old}; + // Even a store from before buttons were tracked gets it. + const auto update = saved.updateFromStarter(*starter, {u"order-template"_s}, installed); + CHECK(update.buttonsAdded == QStringList{u"order-template#flow-manager"_s}); + const Page &p = *saved.page(u"order-template"_s); + const Zone *manager = p.zone(u"flow-manager"_s); + REQUIRE(manager); + // Where Send is (retail has no Send): the two never show on the same screen. + CHECK(manager->rect == p.zone(u"flow-send"_s)->rect); + CHECK(p.zone(u"flow-pay"_s)->label == u"Checkout"_s); +} + TEST_CASE("Store style: Modern and back to Classic, the store's own theme changes kept in each", "[layout][style]") { auto l = Layout::loadDirectory(QStringLiteral(VTM_SEED_DIR)); diff --git a/modern/tests/test_truck.cpp b/modern/tests/test_truck.cpp index 0edab4fbb..d7a2ae4fa 100644 --- a/modern/tests/test_truck.cpp +++ b/modern/tests/test_truck.cpp @@ -571,7 +571,7 @@ TEST_CASE("Restaurant and retail screens keep their own buttons", "[truck][ui]") }; const QJsonObject tables = rule("order-template", "flow-tables"), orders = rule("order-template", "flow-orders"), logOut = rule("order-template", "flow-logout"), back = rule("login", "back-to-order"), - switchPerson = rule("login", "switch-person"); + switchPerson = rule("login", "switch-person"), manager = rule("order-template", "flow-manager"); // A restaurant: Tables, no truck or retail buttons; logging in goes to the floor. { @@ -586,6 +586,7 @@ TEST_CASE("Restaurant and retail screens keep their own buttons", "[truck][ui]") CHECK(c.ruleShows(tables)); CHECK_FALSE(c.ruleShows(orders)); CHECK_FALSE(c.ruleShows(logOut)); + CHECK_FALSE(c.ruleShows(manager)); CHECK_FALSE(c.ruleShows(back)); CHECK_FALSE(c.ruleShows(switchPerson)); } @@ -605,9 +606,16 @@ TEST_CASE("Restaurant and retail screens keep their own buttons", "[truck][ui]") CHECK_FALSE(c.ruleShows(tables)); CHECK_FALSE(c.ruleShows(orders)); CHECK(c.ruleShows(logOut)); + CHECK_FALSE(c.ruleShows(manager)); // a cashier: no way into the manager's pages c.activate(u"flow-logout"_s); CHECK_FALSE(pos.loggedIn()); CHECK(c.pageId() == u"login"_s); + // A manager: Manager on the order page, to the manager's pages (and back to restaurant from there). + REQUIRE(pos.loginWithPin(u"1234"_s)); + CHECK(c.pageId() == u"index-lunch"_s); + CHECK(c.ruleShows(manager)); + c.activate(u"flow-manager"_s); + CHECK(c.pageId() == u"manager"_s); } // A truck: Orders; on the PIN page, Back to Ordering and Switch Person. {