Spaces:
Running on CPU Upgrade
Running on CPU Upgrade
Deploy AIOS web (React glide grid + FastAPI slice)
Browse files- RELEASES.json +7 -1
- VERSION +1 -1
- api/aios_session.py +1 -1
- api/deps.py +17 -1
- api/routes_admin.py +614 -33
- api/routes_auth.py +38 -3
- api/routes_automation.py +97 -2
- api/routes_customers.py +21 -2
- api/routes_products.py +8 -1
- api/routes_shares.py +264 -7
- api/routes_slack.py +20 -3
- platform/aios_grid_fields.json +188 -14
- platform/core/data_binding.py +25 -0
- platform/core/field_permissions.py +213 -5
- platform/core/grid_events.py +171 -2
- platform/core/perm_scope.py +624 -4
- platform/core/shared_overlay.py +25 -0
- platform/core/shares.py +278 -14
- platform/core/users.py +40 -3
- platform/harness/semantic.py +177 -11
- platform/model/topics/odoo_customers.yml +20 -10
- platform/model/topics/odoo_products.yml +158 -10
- platform/modules/customer_data.py +73 -1
- platform/modules/inventory.py +46 -3
- platform/modules/product_data.py +206 -4
- platform/modules/products.py +109 -2
- web/public/sample_customers.json +26 -10
- web/src/customer-grid/ColumnMenu.tsx +196 -59
- web/src/customer-grid/CustomerGrid.tsx +420 -142
- web/src/customer-grid/RecordDetail.tsx +41 -1
- web/src/customer-grid/ViewSidebar.tsx +296 -63
- web/src/customer-grid/cells.ts +8 -0
- web/src/customer-grid/display.ts +174 -1
- web/src/customer-grid/export.ts +160 -11
- web/src/customer-grid/folders.ts +82 -2
- web/src/customer-grid/iconShapes.ts +35 -0
- web/src/customer-grid/overlayPlacement.ts +156 -37
- web/src/customer-grid/rowStar.css +10 -3
- web/src/customer-grid/types.ts +189 -1
- web/src/customer-grid/useGridColumns.ts +70 -9
- web/src/filter-kit/FieldsHidePanel.tsx +111 -18
- web/src/filter-kit/FilterBuilderPanel.tsx +45 -3
- web/src/filter-kit/ops.ts +37 -11
- web/src/index.css +149 -54
- web/src/settings/DatabasePermsPane.tsx +174 -0
- web/src/settings/ModulePermsList.tsx +101 -11
- web/src/settings/PermsEditor.tsx +415 -143
- web/src/settings/perms.css +173 -4
- web/src/settings/permsModel.ts +372 -4
- web/src/shell/Shell.tsx +29 -71
RELEASES.json
CHANGED
|
@@ -1,6 +1,12 @@
|
|
| 1 |
{
|
| 2 |
-
"current": "
|
| 3 |
"releases": [
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 4 |
{
|
| 5 |
"version": "v52",
|
| 6 |
"sha": "8263493",
|
|
|
|
| 1 |
{
|
| 2 |
+
"current": "v53 (89ed2cb)",
|
| 3 |
"releases": [
|
| 4 |
+
{
|
| 5 |
+
"version": "v53",
|
| 6 |
+
"sha": "89ed2cb",
|
| 7 |
+
"date": "2026-08-24",
|
| 8 |
+
"subject": "release v53"
|
| 9 |
+
},
|
| 10 |
{
|
| 11 |
"version": "v52",
|
| 12 |
"sha": "8263493",
|
VERSION
CHANGED
|
@@ -1 +1 @@
|
|
| 1 |
-
|
|
|
|
| 1 |
+
v53 (89ed2cb)
|
api/aios_session.py
CHANGED
|
@@ -11,7 +11,7 @@ audit view, not the source of truth) arrives with C-2 and is deliberately deferr
|
|
| 11 |
WHY STATELESS STILL REVOKES. A cookie nobody can delete sounds like a cookie nobody can revoke.
|
| 12 |
The answer is the `epoch` integer on the user record (`core.users.epoch` / `bump_epoch`): the
|
| 13 |
cookie carries the epoch it was minted under, every verification re-reads the account's current
|
| 14 |
-
epoch, and a password change
|
| 15 |
user dies at once, without a session table.
|
| 16 |
|
| 17 |
β NO FALLBACK SECRET, EVER. With `AIOS_SESSION_SECRET` unset this module mints a RANDOM
|
|
|
|
| 11 |
WHY STATELESS STILL REVOKES. A cookie nobody can delete sounds like a cookie nobody can revoke.
|
| 12 |
The answer is the `epoch` integer on the user record (`core.users.epoch` / `bump_epoch`): the
|
| 13 |
cookie carries the epoch it was minted under, every verification re-reads the account's current
|
| 14 |
+
epoch, and a password change, a deactivation, or (wave 40, R2) any LOGIN bumps it β so every outstanding cookie for that
|
| 15 |
user dies at once, without a session table.
|
| 16 |
|
| 17 |
β NO FALLBACK SECRET, EVER. With `AIOS_SESSION_SECRET` unset this module mints a RANDOM
|
api/deps.py
CHANGED
|
@@ -296,7 +296,20 @@ def assistant_read_scope(session: Session, database, fields=None, filters=None):
|
|
| 296 |
perm_scope.validate_assistant_filter((grant or {}).get("filter"), canonical_fields)
|
| 297 |
except ValueError as exc:
|
| 298 |
_assistant_refuse(400, "assistant_bad_filter", str(exc))
|
| 299 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 300 |
if grant is not None else list(rows or ()))
|
| 301 |
visible = (perm_scope.assistant_visible_fields(canonical_fields, session.user, key)
|
| 302 |
if grant is not None else list(canonical_fields))
|
|
@@ -551,8 +564,11 @@ def _user_for(claims):
|
|
| 551 |
# The emergency master is TENANT #0's break-glass, not the platform's: a synthetic
|
| 552 |
# all-access identity minted into another tenant's session would be the exact
|
| 553 |
# cross-tenant widening the rule above closes.
|
|
|
|
|
|
|
| 554 |
return {"username": "admin", "name": "Administrator", "role": "admin",
|
| 555 |
"bus": "all", "modules": "all", "tenant": "royal-imports",
|
|
|
|
| 556 |
"epoch": int(claims.get("e") or 0)}
|
| 557 |
return None
|
| 558 |
|
|
|
|
| 296 |
perm_scope.validate_assistant_filter((grant or {}).get("filter"), canonical_fields)
|
| 297 |
except ValueError as exc:
|
| 298 |
_assistant_refuse(400, "assistant_bad_filter", str(exc))
|
| 299 |
+
# β OWNER I16 β the tenant handle rides into the row wall here too, so one stored rule means
|
| 300 |
+
# the same thing in the Analyst's answer as it does on the grid (see
|
| 301 |
+
# `perm_scope._enrich_for_wall`).
|
| 302 |
+
#
|
| 303 |
+
# β AND IT CHANGES NOTHING ON THIS PATH TODAY, WHICH IS STATED RATHER THAN LEFT TO BE
|
| 304 |
+
# REDISCOVERED. `validate_assistant_filter` three lines up refuses any leaf naming a column
|
| 305 |
+
# outside `canonical_fields`, so a wall on a user-generated column is rejected before it can
|
| 306 |
+
# reach this call at all. The handle is passed anyway because the alternative is a door that
|
| 307 |
+
# walls these modules WITHOUT it β and "all six or none" is the property that keeps one wall
|
| 308 |
+
# from having two meanings. Widening the Assistant's own validator to admit such a column is
|
| 309 |
+
# a separate decision about what E may read, not a side effect of a grid fix.
|
| 310 |
+
permitted_rows = (perm_scope.assistant_apply_row_scope(rows, session.user, key,
|
| 311 |
+
canonical_fields,
|
| 312 |
+
st=getattr(session, "runtime", None))
|
| 313 |
if grant is not None else list(rows or ()))
|
| 314 |
visible = (perm_scope.assistant_visible_fields(canonical_fields, session.user, key)
|
| 315 |
if grant is not None else list(canonical_fields))
|
|
|
|
| 564 |
# The emergency master is TENANT #0's break-glass, not the platform's: a synthetic
|
| 565 |
# all-access identity minted into another tenant's session would be the exact
|
| 566 |
# cross-tenant widening the rule above closes.
|
| 567 |
+
# β WAVE 40 (R2): the same mark `users.verify`'s master branch carries. The two dicts are
|
| 568 |
+
# documented mirrors of each other, so the key rides on both or they are not mirrors.
|
| 569 |
return {"username": "admin", "name": "Administrator", "role": "admin",
|
| 570 |
"bus": "all", "modules": "all", "tenant": "royal-imports",
|
| 571 |
+
"emergency_master": True,
|
| 572 |
"epoch": int(claims.get("e") or 0)}
|
| 573 |
return None
|
| 574 |
|
api/routes_admin.py
CHANGED
|
@@ -607,9 +607,7 @@ def _module_fields(key, session=None):
|
|
| 607 |
f"{key!r} is not a database in this workspace")
|
| 608 |
src = defn.get("fields") or []
|
| 609 |
else:
|
| 610 |
-
|
| 611 |
-
"product_data": aios_grid.product_fields}
|
| 612 |
-
provider = providers.get(key)
|
| 613 |
if provider is None:
|
| 614 |
# Reached only by a caller that skipped `_perm_modules`. Loud, because the alternative
|
| 615 |
# (`[]`) is an empty option list read as an ANSWER β wave 26 item 24, `if ([])` is
|
|
@@ -617,7 +615,32 @@ def _module_fields(key, session=None):
|
|
| 617 |
raise err(400, "ungoverned_module",
|
| 618 |
f"{key!r} has no permission-editor field schema. The editor governs "
|
| 619 |
f"{sorted(providers)} and this tenant's own databases")
|
| 620 |
-
src = provider()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 621 |
known = _server_side_vocabularies()
|
| 622 |
out = []
|
| 623 |
for f in src:
|
|
@@ -631,10 +654,145 @@ def _module_fields(key, session=None):
|
|
| 631 |
out.append({"key": f["key"], "label": f.get("label") or f["key"],
|
| 632 |
"type": f.get("type") or "text",
|
| 633 |
**({"options": list(opts)} if isinstance(opts, list) and opts else {}),
|
| 634 |
-
**({"pinned": True} if f.get("pinned") else {})
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 635 |
return out
|
| 636 |
|
| 637 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 638 |
def _server_side_vocabularies():
|
| 639 |
"""`{field key: [choice, β¦]}` for choice columns whose vocabulary is CLOSED and known here,
|
| 640 |
but which the grid contract does not declare.
|
|
@@ -654,23 +812,337 @@ def _server_side_vocabularies():
|
|
| 654 |
for the same reason `aios_grid`'s is: this route should not pull the analytics stack at
|
| 655 |
module load.
|
| 656 |
|
| 657 |
-
|
| 658 |
-
|
| 659 |
-
|
| 660 |
-
|
| 661 |
-
|
| 662 |
-
|
| 663 |
-
|
| 664 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 665 |
"""
|
| 666 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 667 |
import modules.inventory as inventory
|
| 668 |
-
|
| 669 |
-
|
| 670 |
-
|
| 671 |
-
|
| 672 |
-
|
| 673 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 674 |
|
| 675 |
|
| 676 |
def _clean_perms(v, governed_keys=None, session=None):
|
|
@@ -724,11 +1196,60 @@ def _clean_perms(v, governed_keys=None, session=None):
|
|
| 724 |
for key, raw in v.items():
|
| 725 |
if not isinstance(raw, dict):
|
| 726 |
raise err(400, "bad_perms", f"{key}: each entry must be an object")
|
| 727 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 728 |
hidden = raw.get("hiddenFields") or []
|
| 729 |
if not isinstance(hidden, list):
|
| 730 |
raise err(400, "bad_perms", f"{key}: hiddenFields must be a list")
|
| 731 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 732 |
if bad:
|
| 733 |
# A hiddenFields entry naming nothing hides nothing β and reads as a restriction
|
| 734 |
# that is not there.
|
|
@@ -746,15 +1267,50 @@ def _clean_perms(v, governed_keys=None, session=None):
|
|
| 746 |
if conj not in ("and", "or"):
|
| 747 |
raise err(400, "bad_filter", f"{key}: conj must be 'and' or 'or'")
|
| 748 |
nodes = tree["nodes"]
|
| 749 |
-
|
| 750 |
-
|
| 751 |
-
|
| 752 |
-
|
| 753 |
-
|
| 754 |
-
|
| 755 |
-
|
| 756 |
-
|
| 757 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 758 |
# ββ W38-T19 β `metrics` IS THE FOURTH FIELD OF AN ENTRY, AND ITS DEFAULT IS GRANT.
|
| 759 |
# `raw.get("metrics", True)` rather than a required key: a PUT composed by an older
|
| 760 |
# client, or a copy of a record written before this ticket, must not read as a
|
|
@@ -762,7 +1318,7 @@ def _clean_perms(v, governed_keys=None, session=None):
|
|
| 762 |
# the validator and the wall cannot disagree about what an absent key means.
|
| 763 |
out[key] = {"access": bool(raw.get("access", True)),
|
| 764 |
"filter": clean_tree,
|
| 765 |
-
"hiddenFields": sorted(
|
| 766 |
"metrics": bool(raw.get("metrics", True))}
|
| 767 |
_refuse_unshapeable_bu(out)
|
| 768 |
return out
|
|
@@ -1052,6 +1608,31 @@ def get_perms(username: str, session: Session = Depends(admin_gate)):
|
|
| 1052 |
# ββ W36-T22 / C2 β EVERY listed database, not an `enforced` subset of them. See
|
| 1053 |
# `perms.tenant_governable_modules` for why the flag is deleted rather than defaulted.
|
| 1054 |
governed = [m["key"] for m in modules]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1055 |
perms_out = {}
|
| 1056 |
for k in governed:
|
| 1057 |
e = stored.get(k)
|
|
@@ -1116,7 +1697,7 @@ def get_perms(username: str, session: Session = Depends(admin_gate)):
|
|
| 1116 |
# item 11's *"EVERY database should be able to be toggleable by admin"*, and it is
|
| 1117 |
# the SAME resolver `_clean_perms` validates against, so the picker cannot offer a
|
| 1118 |
# column the validator will reject.
|
| 1119 |
-
"fields_by_module":
|
| 1120 |
|
| 1121 |
|
| 1122 |
@router.put("/admin/users/{username}/perms")
|
|
|
|
| 607 |
f"{key!r} is not a database in this workspace")
|
| 608 |
src = defn.get("fields") or []
|
| 609 |
else:
|
| 610 |
+
provider = _static_field_providers().get(key)
|
|
|
|
|
|
|
| 611 |
if provider is None:
|
| 612 |
# Reached only by a caller that skipped `_perm_modules`. Loud, because the alternative
|
| 613 |
# (`[]`) is an empty option list read as an ANSWER β wave 26 item 24, `if ([])` is
|
|
|
|
| 615 |
raise err(400, "ungoverned_module",
|
| 616 |
f"{key!r} has no permission-editor field schema. The editor governs "
|
| 617 |
f"{sorted(providers)} and this tenant's own databases")
|
| 618 |
+
src = list(provider())
|
| 619 |
+
import core.perm_scope as perm_scope
|
| 620 |
+
# ββ W40-T05 / OWNER I16 β THE USER-GENERATED COLUMNS JOIN THE TOPIC'S VOCABULARY.
|
| 621 |
+
# *"Permission Filters must be able to filter on user-generated Fields too."* The two topic
|
| 622 |
+
# providers above are the STATIC contract (`aios_grid.FIELDS` = 35, `product_fields()` = 40
|
| 623 |
+
# including the built-in Image column), so until this line NO column a user created could
|
| 624 |
+
# ever reach the picker β measured, both topics, zero `custom_` keys in either. The `ut_*`
|
| 625 |
+
# arm never needed it: a user table's stored definition IS its user-generated schema.
|
| 626 |
+
#
|
| 627 |
+
# β ADDITIVE AND DEDUPED, so a declared column always wins its own key β the same rule the
|
| 628 |
+
# metric rows are appended under below. A user column shadowing a contract column would let
|
| 629 |
+
# an admin hide or filter something other than what they read off the label.
|
| 630 |
+
#
|
| 631 |
+
# β NO SESSION MEANS TODAY'S ANSWER, AND THAT IS CORRECT RATHER THAN DEGRADED. A workspace
|
| 632 |
+
# bucket is per-tenant data with no tenant-blind read, and two callers arrive without one:
|
| 633 |
+
# `_fold_legacy_scope` on the live PUT path and `verify_api`'s W30a probe. Both get the
|
| 634 |
+
# pre-set list they have always had, and the legacy fold cannot start dropping a leaf it used
|
| 635 |
+
# to keep, because `_prune_to_module` only ever narrows the LEGACY tree (`dba`/`agent`) to
|
| 636 |
+
# keys the contract already carries.
|
| 637 |
+
if key in _FIELD_PROVIDER_KEYS:
|
| 638 |
+
_have = {f.get("key") for f in src if isinstance(f, dict)}
|
| 639 |
+
for _uf in (perm_scope.user_generated_fields(
|
| 640 |
+
key, st=getattr(session, "runtime", None)) or ()):
|
| 641 |
+
if isinstance(_uf, dict) and _uf.get("key") and _uf["key"] not in _have:
|
| 642 |
+
_have.add(_uf["key"])
|
| 643 |
+
src.append(_uf)
|
| 644 |
known = _server_side_vocabularies()
|
| 645 |
out = []
|
| 646 |
for f in src:
|
|
|
|
| 654 |
out.append({"key": f["key"], "label": f.get("label") or f["key"],
|
| 655 |
"type": f.get("type") or "text",
|
| 656 |
**({"options": list(opts)} if isinstance(opts, list) and opts else {}),
|
| 657 |
+
**({"pinned": True} if f.get("pinned") else {}),
|
| 658 |
+
# ββ CONTRACT C3 / AM-2 β THE FOUR MEMBERSHIP BOOLEANS, ON EVERY ROW.
|
| 659 |
+
# READ OFF THE FIELD'S OWN DECLARATION, never inferred from its key, because
|
| 660 |
+
# the declaration is the authority the GRID already uses:
|
| 661 |
+
# `aios_grid.clean_measure_field` writes `custom: True` on a user-created
|
| 662 |
+
# column, the product contract declares `shared: true` on its nine
|
| 663 |
+
# tenant-wide-value columns, and `filterable: False` is how a column states
|
| 664 |
+
# the engine cannot filter it (`est_missed` is the one that does).
|
| 665 |
+
#
|
| 666 |
+
# β `shared` IS INFORMATIONAL AND MUST NEVER BECOME THE HIDE RULE. AM-2's
|
| 667 |
+
# rule is `metric || !custom`. Nine declared PRODUCT columns carry
|
| 668 |
+
# `shared: true` (`first_cost`, `supplier`, `notes`, ...) and every one of
|
| 669 |
+
# them has to stay hideable β `verify_api`'s legacy-fold leg hides
|
| 670 |
+
# `first_cost` by name. A client that excluded rows on `shared` would revoke
|
| 671 |
+
# the admin's control over nine pre-set columns, which is I15's own defect
|
| 672 |
+
# one word over.
|
| 673 |
+
"custom": bool(f.get("custom")),
|
| 674 |
+
"shared": (bool(f.get("shared"))
|
| 675 |
+
or f.get(perm_scope.FIELD_GRANT_MARK) is True),
|
| 676 |
+
"filterable": f.get("filterable") is not False,
|
| 677 |
+
"metric": False})
|
| 678 |
+
# ββ I13 β THE METRIC ROWS, APPENDED LAST so no declared column is ever displaced, and
|
| 679 |
+
# skipped on a key collision so a declared column always wins its own key.
|
| 680 |
+
taken = {f["key"] for f in out}
|
| 681 |
+
out.extend(m for m in _metric_fields(key) if m["key"] not in taken)
|
| 682 |
+
return out
|
| 683 |
+
|
| 684 |
+
|
| 685 |
+
def _metric_fields(key):
|
| 686 |
+
"""One `measure_`-namespaced pseudo-field per measure BOUND to `key`'s entity topic.
|
| 687 |
+
|
| 688 |
+
ββ I13 β THE ROW THE OWNER ASKED FOR: *"Fold 'Metrics fields (lookback measures over
|
| 689 |
+
this database)' into the 'Hide fields' checkboxes, one row per metric, named
|
| 690 |
+
'Metric - Revenue', 'Metric - Order' and so on, so a user can check the ones the
|
| 691 |
+
permissioning is limited to."* Until this existed the entire capability was ONE boolean
|
| 692 |
+
(`perm_scope.may_metrics`), so an administrator could revoke every metric on a database or
|
| 693 |
+
none of them.
|
| 694 |
+
|
| 695 |
+
ββ AND IT IS WHY I15 HAD NO CONTROL TO OFFER. *"Shantal has access to gross profit."*
|
| 696 |
+
"Gross profit" is the measure `margin` β label "Gross margin $", defined at
|
| 697 |
+
`platform/model/metrics/sales.yml::margin` and bound onto this grid by
|
| 698 |
+
`platform/model/topics/odoo_products.yml::measures`. **It is not a column in
|
| 699 |
+
`aios_grid_fields.json` and never was**, so a picker built from the declared contract alone
|
| 700 |
+
could not list it however carefully that contract was read. No key literally named
|
| 701 |
+
`gross_profit` reaches this grid at all.
|
| 702 |
+
|
| 703 |
+
β THE OFFER IS READ, NEVER RESTATED. `semantic.entity_measures` is the ONE catalogue, and
|
| 704 |
+
it REFUSES a key it cannot prove β a half-synced mirror, a metric with no `empty:` family,
|
| 705 |
+
a format with no grid type β with the cause available through `entity_measure_refusals`.
|
| 706 |
+
Re-measured 2026-08-24 in this tree, after W40-T10 bound the channel split: the product topic
|
| 707 |
+
declares **27 key-slots across five bindings** and the catalogue offers **24**;
|
| 708 |
+
`stock_in`/`stock_out`/`stock_net` are refused because `stock_move` has not finished syncing.
|
| 709 |
+
Hardcoding a declared list would offer three columns that render blank today AND would stop
|
| 710 |
+
growing the day a binding is added. The offer widens on its own when the mirror catches up,
|
| 711 |
+
because this asks rather than remembers β and the eighteen channel rows below
|
| 712 |
+
("Metric - Revenue (Fisch)", "Metric - Revenue (Amazon)", β¦) arrived here with NO change to
|
| 713 |
+
this function for exactly that reason.
|
| 714 |
+
|
| 715 |
+
ββ W40-T10 / owner item 26 (R7) β AND THAT IS WHY THE CHANNEL RIDES THE MEASURE KEY. A
|
| 716 |
+
per-metric channel spelled as a member of the stored field spec would be invisible here:
|
| 717 |
+
this row is minted from `m["key"]` and `m["label"]`, so a channel carried anywhere else
|
| 718 |
+
would give an admin eighteen columns they can neither tell apart nor hide separately.
|
| 719 |
+
`semantic._one_binding_offer` therefore namespaces the key and appends "(Fisch)" to the
|
| 720 |
+
label, and both halves land in this vocabulary for free.
|
| 721 |
+
|
| 722 |
+
β THE TOPIC IS DERIVED, NEVER MAPPED. `semantic.topic_for_grid` reads the `grid:` key the
|
| 723 |
+
topic file already declares, which is the reason its own docstring gives for existing: a
|
| 724 |
+
`{module: topic}` literal in a route would be a second statement of one fact and would
|
| 725 |
+
drift the day a topic is renamed. It answers for every arm β `product_data` ->
|
| 726 |
+
`odoo_products`, `customer_data` -> `odoo_customers` (which binds none), `ut_odoo_agents` ->
|
| 727 |
+
`odoo_agents` (which binds seven) β so this needs NO per-module branch, and a database
|
| 728 |
+
with no bound measure simply receives no rows.
|
| 729 |
+
|
| 730 |
+
ββ IT CANNOT RAISE, AND THAT IS LOAD-BEARING RATHER THAN DEFENSIVE. Two callers reach
|
| 731 |
+
`_module_fields` with NO session and outside any store fixture: `_fold_legacy_scope`, on the
|
| 732 |
+
live migration path of a PUT, and `verify_api`'s W30a probe, which runs ABOVE the line that
|
| 733 |
+
installs the fake store. A raise on either is not a red gate but a CRASHED one
|
| 734 |
+
[[gate-must-go-red-not-crash]], and on the route it is a 500 on the administrator's own save.
|
| 735 |
+
`entity_measures` already degrades to `[]` when the mirror cannot be read; this makes the
|
| 736 |
+
whole derivation degrade with it, so the payload simply carries no metric rows.
|
| 737 |
+
|
| 738 |
+
β `filterable: False`, AND IT IS A MEASUREMENT RATHER THAN A PREFERENCE. A pseudo-key is
|
| 739 |
+
not a column any row carries β a real Metric column is keyed `measure_<slug>_<rand>` by
|
| 740 |
+
`CustomerGrid.createField`. Measured: `clean_filter_tree` ACCEPTS a leaf on `measure_margin`
|
| 741 |
+
once the key is admitted, and `harness.filter_eval.permits` then answers **False for every
|
| 742 |
+
product row**, because the row has no such key. That is exactly the "deny-everything trap
|
| 743 |
+
wearing a saved-successfully toast" `_module_fields`' own docstring forbids. The governed way
|
| 744 |
+
to filter on a measure is the measure CONDITION channel (`measure_sets`, CG-8), not a field
|
| 745 |
+
leaf, so these rows join the HIDE vocabulary only.
|
| 746 |
+
|
| 747 |
+
β THE PREFIX IS `aios_grid.MEASURE_FIELD_PREFIX`, IMPORTED. Spelling "measure_" here would
|
| 748 |
+
be a second copy of a constant two features already share
|
| 749 |
+
[[constant-two-features-share]], and `verify_fields_contract` gates that the client keys its
|
| 750 |
+
real measure columns off the same one.
|
| 751 |
+
"""
|
| 752 |
+
try:
|
| 753 |
+
import aios_grid
|
| 754 |
+
import harness.semantic as semantic
|
| 755 |
+
topic = semantic.topic_for_grid(key)
|
| 756 |
+
if not topic:
|
| 757 |
+
return []
|
| 758 |
+
offer = semantic.entity_measures(topic)
|
| 759 |
+
except Exception: # noqa: BLE001
|
| 760 |
+
return []
|
| 761 |
+
out = []
|
| 762 |
+
for m in offer or ():
|
| 763 |
+
if not isinstance(m, dict):
|
| 764 |
+
continue
|
| 765 |
+
mkey = str(m.get("key") or "").strip()
|
| 766 |
+
if not mkey:
|
| 767 |
+
continue
|
| 768 |
+
# β THE LABEL IS THE MEASURE'S OWN, prefixed. A hand-written second vocabulary here
|
| 769 |
+
# would read "Metric - Gross profit" while the grid column read "Gross margin $", and an
|
| 770 |
+
# admin cannot hide what they cannot recognise. ASCII hyphen, exactly as the owner wrote
|
| 771 |
+
# it β CLAUDE.md rule 2 bars a dash in copy that reaches a screen.
|
| 772 |
+
label = str(m.get("label") or mkey).strip()
|
| 773 |
+
mtype = m.get("type")
|
| 774 |
+
out.append({"key": f"{aios_grid.MEASURE_FIELD_PREFIX}{mkey}",
|
| 775 |
+
"label": f"Metric - {label}",
|
| 776 |
+
"type": mtype if mtype in aios_grid.MEASURE_FIELD_TYPES else "currency",
|
| 777 |
+
"custom": False,
|
| 778 |
+
"shared": False,
|
| 779 |
+
"filterable": False,
|
| 780 |
+
"metric": True})
|
| 781 |
return out
|
| 782 |
|
| 783 |
|
| 784 |
+
#: The value every blank Odoo connector attribute displays as. The writer is
|
| 785 |
+
#: `modules/customers._partner_attrs` (`... or '(none)'`) and the client mirror is
|
| 786 |
+
#: `customer-grid/types.ts::CONNECTOR_BLANK`. It is a DELIBERATE, documented, visible value, so a
|
| 787 |
+
#: choice vocabulary that omitted it would deny an admin any rule about the blank rows.
|
| 788 |
+
BLANK = "(none)"
|
| 789 |
+
|
| 790 |
+
#: `_server_side_vocabularies`' per-process memo. `None` until a COMPLETE build succeeds; a build
|
| 791 |
+
#: with any failed arm is returned but NOT stored, so a transient Odoo outage cannot pin a short
|
| 792 |
+
#: answer for the life of the worker.
|
| 793 |
+
_VOCAB_CACHE = None
|
| 794 |
+
|
| 795 |
+
|
| 796 |
def _server_side_vocabularies():
|
| 797 |
"""`{field key: [choice, β¦]}` for choice columns whose vocabulary is CLOSED and known here,
|
| 798 |
but which the grid contract does not declare.
|
|
|
|
| 812 |
for the same reason `aios_grid`'s is: this route should not pull the analytics stack at
|
| 813 |
module load.
|
| 814 |
|
| 815 |
+
ββ W40-T06 / OWNER I11+I23 β NINE MORE CHOICE COLUMNS, AND WHY THE OLD REFUSAL EXPIRED.
|
| 816 |
+
Ruling R5 retyped ten Odoo customer columns off `text`, so nine of them now reach the branch
|
| 817 |
+
above and D-236 (`category` renders an EMPTY dropdown here) would have been multiplied by
|
| 818 |
+
nine rather than fixed. `category` was refused in this docstring because "discovering it
|
| 819 |
+
would mean a pool read on an admin route". That reason was WRONG about the cost, not about
|
| 820 |
+
the principle: none of the reads below is a pool read. Each is either a `read_group` over
|
| 821 |
+
`res.partner` (one grouped row per distinct value) or a whole small master table, and the
|
| 822 |
+
dearest of them was MEASURED at 1.8s cold, once per process.
|
| 823 |
+
|
| 824 |
+
ββ A VOCABULARY MUST MATCH THE CELL, NOT THE RAW SOURCE, and the pricelist is the proof.
|
| 825 |
+
`modules/customers._partner_attrs` writes `O.m2o_name(property_product_pricelist)`, which is
|
| 826 |
+
Odoo's DISPLAY name: the cell reads "Fisch (USD)". `product.pricelist.name` reads "Fisch".
|
| 827 |
+
A vocabulary built from `name` would therefore offer five options, and every one of them
|
| 828 |
+
would match ZERO rows. So every arm below reproduces the writer's own expression:
|
| 829 |
+
`display_name` for an m2o, `.strip().title()` for `city`, the `', '.join(...)` for the m2m
|
| 830 |
+
`agent`, and `'(none)'` wherever `_partner_attrs` collapses a blank (the set of fields that
|
| 831 |
+
do is documented in the contract JSON's own `_comment`).
|
| 832 |
+
MEASURED against real cells over all 5,282 partners, 2026-08-23: country 20 offered / 20
|
| 833 |
+
observed, state 64 / 64, agent 14 / 13, city 1,254 / 1,245, pricelist 5 / 4,
|
| 834 |
+
payment_terms 15 / 10, tags 6 / 5. β Read the direction: NOT ONE observed cell value is
|
| 835 |
+
missing from what is offered. The overshoot is partners outside the grid's own 24 month
|
| 836 |
+
population, and it is the SAFE direction. A missing option is the dangerous one, because it
|
| 837 |
+
silently denies the admin any rule about those rows.
|
| 838 |
+
|
| 839 |
+
β `tags` IS A MULTISELECT, so it is offered as MEMBERS, not as joined cells.
|
| 840 |
+
`choiceVocabulary` splits a multiselect cell on commas, so "Fisch, Royal" must arrive as
|
| 841 |
+
"Fisch" and "Royal". `agent` stays a SINGLE select per R5 and therefore keeps its joined
|
| 842 |
+
combinations. β NOTE FOR THE OWNER, not acted on here: `agent` is comma joined multi value
|
| 843 |
+
exactly as `tags` is (13 observed cells are combinations such as "Avi Ash, Martin
|
| 844 |
+
Pasternak"), so R5's own argument for making Tags a multiselect applies to it too. R5 rules
|
| 845 |
+
single select, so single select is what this builds.
|
| 846 |
+
|
| 847 |
+
β DEGRADE BY OMITTING THE KEY, NEVER BY RETURNING `[]`. `FilterBuilderPanel::choicesFor`
|
| 848 |
+
treats a supplied list as authoritative INCLUDING when it is empty, so an empty list asserts
|
| 849 |
+
"this column has no values". Every arm is therefore isolated in its own try/except and a
|
| 850 |
+
failed read leaves its key OUT, exactly as the original single-arm version did.
|
| 851 |
+
|
| 852 |
+
β CACHED PER PROCESS, because `_module_fields` runs on every admin GET and on every PUT via
|
| 853 |
+
`_fold_legacy_scope`. Only SUCCESSES are cached, so a transient Odoo outage cannot pin an
|
| 854 |
+
empty answer for the life of the worker. STALE WHEN: someone adds or renames a pricelist,
|
| 855 |
+
payment term, partner tag or product category; a customer moves city, state or country; an
|
| 856 |
+
agent is assigned or unassigned; a new salesperson takes their first order. None of those is
|
| 857 |
+
observable from here, and the refresh is a process restart, which a deploy already does.
|
| 858 |
+
|
| 859 |
+
β ONE COLUMN IS STILL DELIBERATELY ABSENT, and R6's second sentence says to name it rather
|
| 860 |
+
than let it look handled:
|
| 861 |
+
Β· `odoo_status` (customer) β WAS bare and is NOT any more: lane E answered `ASK D-15` by
|
| 862 |
+
declaring `options: ['Active','Archived']` on the CONTRACT, which is the right home (the
|
| 863 |
+
grid picks a declared list up for free) and is why this function never needed an arm for
|
| 864 |
+
it. Recorded because the ask, not a guess, is what settled it.
|
| 865 |
"""
|
| 866 |
+
global _VOCAB_CACHE
|
| 867 |
+
if _VOCAB_CACHE is not None:
|
| 868 |
+
return dict(_VOCAB_CACHE)
|
| 869 |
+
|
| 870 |
+
out = {}
|
| 871 |
+
|
| 872 |
+
def arm(fn):
|
| 873 |
+
"""Run one source. A failure omits its keys and never touches the others."""
|
| 874 |
+
try:
|
| 875 |
+
for key, values in (fn() or {}).items():
|
| 876 |
+
clean = sorted({str(v) for v in values if str(v or "").strip()})
|
| 877 |
+
if clean:
|
| 878 |
+
out[key] = clean
|
| 879 |
+
return True
|
| 880 |
+
except Exception: # noqa: BLE001
|
| 881 |
+
return False
|
| 882 |
+
|
| 883 |
+
def _stock_bucket():
|
| 884 |
+
# IMPORTED, NEVER RESTATED: the same constant `_bucket()` mints from, so a renamed band
|
| 885 |
+
# cannot leave a second vocabulary behind [[constant-two-features-share]]. Lazy for the
|
| 886 |
+
# same reason `aios_grid`'s import is: no analytics stack at module load.
|
| 887 |
import modules.inventory as inventory
|
| 888 |
+
return {"stock_bucket": list(inventory.COVERAGE_LABELS or ())}
|
| 889 |
+
|
| 890 |
+
def _categories():
|
| 891 |
+
import modules.inventory as inventory
|
| 892 |
+
# W40-T06: the root maps to None now, so "All" cannot reach either list. The sentinel is
|
| 893 |
+
# what `products.catalogue` and `sales._product_cat` substitute for that None.
|
| 894 |
+
cats = sorted({v for v in inventory._cat_main_map().values() if v})
|
| 895 |
+
return {"category": cats + ["(uncategorized)"],
|
| 896 |
+
"top_category": cats + ["(uncategorized)", BLANK]}
|
| 897 |
+
|
| 898 |
+
def _suppliers():
|
| 899 |
+
"""The product `supplier` column's observed values.
|
| 900 |
+
|
| 901 |
+
ββ THIS ARM EXISTS BECAUSE W40-T06 CREATED THE HOLE IT FILLS. `supplier` was `text`
|
| 902 |
+
until I18 made it a multiselect, and a choice column with no declared options and no
|
| 903 |
+
entry here is precisely D-236's empty dropdown. The flip would otherwise have ADDED a
|
| 904 |
+
tenth blank picker while this ticket was removing nine.
|
| 905 |
+
|
| 906 |
+
ββ DECISION OWED, AND IT IS VISIBLE ON SCREEN: 18 of the 88 distinct suppliers carry a
|
| 907 |
+
COMMA INSIDE THE COMPANY NAME ("CANDLE ARTISANS, INC", "BAOBEI INT'L CO.,LTD"), spanning
|
| 908 |
+
371 product codes. A multiselect cell is by contract a comma-joined SET, and
|
| 909 |
+
`types.ts::choiceVocabulary` SPLITS it, so the grid's own row-derived picker will offer
|
| 910 |
+
26 fragments ("CANDLE ARTISANS", "INC") where 18 real suppliers should be. That is a
|
| 911 |
+
data fact about supplier names, not a bug in the splitter: unlike `tags`, `supplier` is
|
| 912 |
+
a SINGLE value that merely contains punctuation. This function serves the WHOLE values,
|
| 913 |
+
which is what the cells actually hold and what an admin means to filter on. The kind
|
| 914 |
+
itself is the owner's to settle (`select` would make the collision disappear); I18 says
|
| 915 |
+
multi-select, so multi-select is what the contract carries.
|
| 916 |
+
|
| 917 |
+
β SEED VALUES, NOT LIVE CELLS. `supplier` is an OVERLAY column a user may retype per
|
| 918 |
+
record, and those edits live in the tenant's workspace, which this route cannot read
|
| 919 |
+
tenant-blind. So a supplier somebody typed by hand is missing from this list until the
|
| 920 |
+
mastersheet carries it. Cheap and safe: `supplier_master()` is a local file cached per
|
| 921 |
+
process, and it degrades to `{}` rather than raising.
|
| 922 |
+
"""
|
| 923 |
+
import modules.product_data as product_data
|
| 924 |
+
return {"supplier": [(v.get("supplier") or "").strip()
|
| 925 |
+
for v in (product_data.supplier_master() or {}).values()]}
|
| 926 |
+
|
| 927 |
+
def _masters():
|
| 928 |
+
import core.odoo as O
|
| 929 |
+
got = {}
|
| 930 |
+
for key, model in (("pricelist", "product.pricelist"),
|
| 931 |
+
("payment_terms", "account.payment.term"),
|
| 932 |
+
("tags", "res.partner.category")):
|
| 933 |
+
# display_name, never name: see the pricelist proof in the docstring.
|
| 934 |
+
got[key] = [c["display_name"] for c in O.search_read(model, [], ["display_name"])]
|
| 935 |
+
if key != "pricelist": # measured: every customer carries a pricelist
|
| 936 |
+
got[key] = got[key] + [BLANK]
|
| 937 |
+
return got
|
| 938 |
+
|
| 939 |
+
def _partner_dims():
|
| 940 |
+
import core.odoo as O
|
| 941 |
+
rg = lambda field: O.read_group("res.partner", [], ["id"], [field], lazy=False)
|
| 942 |
+
return {
|
| 943 |
+
"country": [O.m2o_name(r.get("country_id")) or BLANK for r in rg("country_id")],
|
| 944 |
+
"state": [O.m2o_name(r.get("state_id")) or BLANK for r in rg("state_id")],
|
| 945 |
+
# `.strip().title()` is `_partner_attrs`' own expression. Raw mirror values would
|
| 946 |
+
# offer "NEW YORK" where the cell says "New York": no match, in both directions.
|
| 947 |
+
"city": [(r.get("city") or "").strip().title() or BLANK for r in rg("city")],
|
| 948 |
+
}
|
| 949 |
+
|
| 950 |
+
def _agents():
|
| 951 |
+
import core.odoo as O
|
| 952 |
+
rows = O.search_read("res.partner", [], ["agent_ids"])
|
| 953 |
+
ids = {i for r in rows for i in (r.get("agent_ids") or [])}
|
| 954 |
+
names = {p["id"]: p["name"]
|
| 955 |
+
for p in O.search_read("res.partner", [("id", "in", list(ids))], ["name"])}
|
| 956 |
+
return {"agent": [", ".join(n for n in (names.get(i) for i in (r.get("agent_ids") or []))
|
| 957 |
+
if n) or BLANK for r in rows]}
|
| 958 |
+
|
| 959 |
+
def _salespeople():
|
| 960 |
+
# The ORDER TAKER over LTM (`sale.order.user_id`), which is what the column holds, NOT
|
| 961 |
+
# `res.users`: `modules/customer_data._salesperson_attrs` is the writer, and it reads the
|
| 962 |
+
# order's taker. Grouped, so the result is one row per distinct person.
|
| 963 |
+
import core.odoo as O
|
| 964 |
+
import core.periods as P
|
| 965 |
+
import modules.sales as S
|
| 966 |
+
mf, mt = P.ltm(P.today())
|
| 967 |
+
rows = O.read_group("sale.order", S.order_domain(str(mf), str(mt), None),
|
| 968 |
+
["amount_untaxed:sum"], ["user_id"], lazy=False)
|
| 969 |
+
return {"salesperson": [O.m2o_name(r.get("user_id")) or BLANK for r in rows]}
|
| 970 |
+
|
| 971 |
+
complete = all([arm(source) for source in
|
| 972 |
+
(_stock_bucket, _categories, _suppliers, _masters, _partner_dims,
|
| 973 |
+
_agents, _salespeople)])
|
| 974 |
+
if complete:
|
| 975 |
+
_VOCAB_CACHE = dict(out)
|
| 976 |
+
return out
|
| 977 |
+
|
| 978 |
+
|
| 979 |
+
def _prunable_vocabulary(key, session=None, fields=None):
|
| 980 |
+
"""The field keys `key` HAS right now β or `None` when that is not trustworthy enough to
|
| 981 |
+
prune a stored permission filter against.
|
| 982 |
+
|
| 983 |
+
ββ THE RETURN IS A SAFETY DEVICE, NOT A CONVENIENCE. The cascade below DELETES a filter leaf
|
| 984 |
+
naming a key that is not in this set, so a set that is short by one column revokes a live
|
| 985 |
+
permission rule β permanently, silently, and in the WIDENING direction. Three separate ways
|
| 986 |
+
to be short are refused here rather than papered over:
|
| 987 |
+
|
| 988 |
+
* a TOPIC whose workspace bucket could not be read (`user_generated_fields` answers `None`,
|
| 989 |
+
which is exactly why it distinguishes that from `[]`). This is the case that would fire
|
| 990 |
+
under ordinary store contention, and it is the dangerous one: measured in this tree, a
|
| 991 |
+
busy DuckDB already takes `_module_fields('product_data')` from 45 rows to 39.
|
| 992 |
+
* a SURFACE (Assistant, Agents), whose vocabulary is `[]` by design. Pruning against an
|
| 993 |
+
empty set would drop every leaf of anything stored there.
|
| 994 |
+
* any key whose schema read RAISES β an unknown module, a `ut_*` database whose definition
|
| 995 |
+
the store cannot serve.
|
| 996 |
+
|
| 997 |
+
β `fields` is threaded so the ONE `_module_fields` call a caller has already paid for is
|
| 998 |
+
reused. Recomputing it would double a read that costs a store round-trip per module on a
|
| 999 |
+
route that already makes one per governed database.
|
| 1000 |
+
"""
|
| 1001 |
+
import core.perm_scope as perm_scope
|
| 1002 |
+
|
| 1003 |
+
key = str(key or "")
|
| 1004 |
+
if key in _FIELD_PROVIDER_KEYS:
|
| 1005 |
+
if perm_scope.user_generated_fields(key, st=getattr(session, "runtime", None)) is None:
|
| 1006 |
+
return None
|
| 1007 |
+
elif not key.startswith("ut_"):
|
| 1008 |
+
return None
|
| 1009 |
+
if fields is None:
|
| 1010 |
+
try:
|
| 1011 |
+
fields = _module_fields(key, session=session)
|
| 1012 |
+
except Exception: # noqa: BLE001
|
| 1013 |
+
return None
|
| 1014 |
+
return {f["key"] for f in fields if isinstance(f, dict) and f.get("key")} or None
|
| 1015 |
+
|
| 1016 |
+
|
| 1017 |
+
def _prune_stale_filters(block, session=None):
|
| 1018 |
+
"""`(block, {module: [dropped keys]})` β owner I16's cascade over a whole stored perms block.
|
| 1019 |
+
|
| 1020 |
+
ββ *"If the field is deleted, its permission filter goes with it."* Run at the ADMIN DOOR,
|
| 1021 |
+
on the record, never in the wall: `perm_scope.prune_filter_to_fields`' own docstring carries
|
| 1022 |
+
the reason (`verify_perm_scope`'s "a wall naming a DELETED column denies every row" leg must
|
| 1023 |
+
stay green, and it asserts on `apply_row_scope` directly).
|
| 1024 |
+
|
| 1025 |
+
β NON-DESTRUCTIVE and entry-wise: an entry with no filter, an entry whose vocabulary will not
|
| 1026 |
+
resolve, and an entry with nothing stale all come back as the object that went in. Only an
|
| 1027 |
+
entry that actually lost a leaf is rebuilt, so a caller can use the returned map as its
|
| 1028 |
+
"is a write needed" test rather than comparing documents.
|
| 1029 |
+
"""
|
| 1030 |
+
import core.perm_scope as perm_scope
|
| 1031 |
+
|
| 1032 |
+
out, dropped = dict(block or {}), {}
|
| 1033 |
+
for key, entry in (block or {}).items():
|
| 1034 |
+
if not isinstance(entry, dict) or not entry.get("filter"):
|
| 1035 |
+
continue
|
| 1036 |
+
vocab = _prunable_vocabulary(key, session=session)
|
| 1037 |
+
if vocab is None:
|
| 1038 |
+
continue
|
| 1039 |
+
tree, gone = perm_scope.prune_filter_to_fields(entry["filter"], vocab)
|
| 1040 |
+
if gone:
|
| 1041 |
+
out[key] = dict(entry, filter=tree)
|
| 1042 |
+
dropped[key] = gone
|
| 1043 |
+
return out, dropped
|
| 1044 |
+
|
| 1045 |
+
|
| 1046 |
+
def _static_field_providers():
|
| 1047 |
+
"""The STATIC contract behind each topic grid, read by TWO callers.
|
| 1048 |
+
|
| 1049 |
+
`_module_fields` builds the picker from it and then APPENDS the user-generated columns;
|
| 1050 |
+
`_row_wall_blind_keys` needs the same set to tell those two apart. A second copy of this map
|
| 1051 |
+
would let them disagree about which columns are the database's own, and the disagreement
|
| 1052 |
+
would show up as a permission filter refused on a column that was never user-generated.
|
| 1053 |
+
"""
|
| 1054 |
+
import aios_grid
|
| 1055 |
+
|
| 1056 |
+
return {"customer_data": lambda: aios_grid.FIELDS,
|
| 1057 |
+
"product_data": aios_grid.product_fields}
|
| 1058 |
+
|
| 1059 |
+
|
| 1060 |
+
def _leaf_col_ids(nodes):
|
| 1061 |
+
"""Every `colId` a filter tree names, at any depth. Groups carry `children`; leaves do not."""
|
| 1062 |
+
found = set()
|
| 1063 |
+
for node in nodes or ():
|
| 1064 |
+
if not isinstance(node, dict):
|
| 1065 |
+
continue
|
| 1066 |
+
if isinstance(node.get("children"), list):
|
| 1067 |
+
found |= _leaf_col_ids(node["children"])
|
| 1068 |
+
elif node.get("colId"):
|
| 1069 |
+
found.add(str(node["colId"]))
|
| 1070 |
+
return found
|
| 1071 |
+
|
| 1072 |
+
|
| 1073 |
+
def _row_wall_blind_keys(key, session=None):
|
| 1074 |
+
"""User-generated columns of a TOPIC grid that the row wall STILL cannot answer.
|
| 1075 |
+
|
| 1076 |
+
THE DEFECT THIS REFUSES. W40-T05 taught `_module_fields` to append
|
| 1077 |
+
`perm_scope.user_generated_fields`, so the permission editor now OFFERS a column a user made
|
| 1078 |
+
(owner instruction 16), and this validator accepted a wall naming it. But on the two topic
|
| 1079 |
+
grids the wall ran as `apply_row_scope(rows, user, MODULE, <the STATIC contract>)`, over
|
| 1080 |
+
PRE-OVERLAY rows: the column was neither declared in that field list nor present on the row,
|
| 1081 |
+
and `filter_eval.permits` DENIES every leaf it cannot answer.
|
| 1082 |
+
|
| 1083 |
+
Measured on the integrated head, one leaf {colId: fld_region, op: eq, value: West}, two rows:
|
| 1084 |
+
|
| 1085 |
+
static contract + pre-overlay rows (THE OLD CALL SITE) -> [] every row denied
|
| 1086 |
+
column declared + rows carrying the value -> ['1'] correct
|
| 1087 |
+
column declared + pre-overlay rows -> []
|
| 1088 |
+
a DECLARED odoo column, same shape -> ['1'] the evaluator is fine
|
| 1089 |
+
|
| 1090 |
+
So an administrator saved a rule, was told it saved, and that account opened an empty grid
|
| 1091 |
+
with nothing on screen saying why. Fail-CLOSED, and one click undid it, but silent.
|
| 1092 |
+
|
| 1093 |
+
ββ AND THE PROPER FIX IS NOW DONE, SO THIS SET NARROWS RATHER THAN COVERING EVERY USER
|
| 1094 |
+
COLUMN. `perm_scope.apply_row_scope` takes a tenant handle and every door that walls these
|
| 1095 |
+
two modules passes it (`routes_customers` twice, `routes_products`, `routes_slack`,
|
| 1096 |
+
`deps`, and `perm_scope._scoped`); with it, a TENANT-WIDE overlay column is merged onto the
|
| 1097 |
+
rows and declared to the evaluator before `permits` runs. What is left blind is what stays
|
| 1098 |
+
genuinely unanswerable HERE, and it is `perm_scope.wallable_overlay_keys` that decides,
|
| 1099 |
+
never a list restated in this file β one evaluator, so the write door and the wall cannot
|
| 1100 |
+
disagree about which columns are filterable:
|
| 1101 |
+
|
| 1102 |
+
* a `formula` or `created_time` column, whose value is computed in the BROWSER over the
|
| 1103 |
+
rendered row and never sits on a stored one;
|
| 1104 |
+
* a `measure_*` column, computed from the measure catalogue per render;
|
| 1105 |
+
* a PER-USER private overlay column, whose values live in the subject's own stratum β an
|
| 1106 |
+
account may edit those freely, so a wall over one is a wall its subject can walk out of,
|
| 1107 |
+
and the admin who wrote the rule cannot see the values at all.
|
| 1108 |
+
|
| 1109 |
+
REFUSED AT THE WRITE, WHERE A PERSON IS PRESENT TO FIX IT, which is the same call
|
| 1110 |
+
`_refuse_unshapeable_bu` makes further down this file for the same reason.
|
| 1111 |
+
|
| 1112 |
+
NARROW BY CONSTRUCTION, three ways. Only the two TOPIC grids: a `ut_*` database enforces
|
| 1113 |
+
correctly today, because its stored definition IS its user-generated schema and its rows carry
|
| 1114 |
+
the values. Only the FILTER: `hiddenFields` still accepts these columns, because hiding is
|
| 1115 |
+
applied to the assembled field list, which does have them. And only columns the static
|
| 1116 |
+
contract does NOT declare, so a user column shadowing a real one cannot make the real one
|
| 1117 |
+
unfilterable.
|
| 1118 |
+
|
| 1119 |
+
`user_generated_fields` answers `None` when the vocabulary cannot be read, and `None` is
|
| 1120 |
+
handled by NOT narrowing, which is correct rather than lax: on that same answer
|
| 1121 |
+
`_module_fields` appended nothing, so there is nothing in `filter_keys` to take out.
|
| 1122 |
+
|
| 1123 |
+
β AND THE TWO DEGRADED READS FAIL CLOSED THROUGH DIFFERENT DOORS, WHICH IS WORTH TRACING
|
| 1124 |
+
RATHER THAN ASSUMING. If the whole vocabulary is unreadable, `user_generated_fields` answers
|
| 1125 |
+
`None` and this set is EMPTY β it refuses nothing, because there is nothing here to refuse:
|
| 1126 |
+
`_module_fields` appended nothing on that same answer, so the column is not in `filter_keys`
|
| 1127 |
+
either and the generic `clean_filter_tree` leaf-count check 400s it one branch down (with
|
| 1128 |
+
the "unknown field" wording, which is the honest thing to say when the server cannot see the
|
| 1129 |
+
column at all). If instead the vocabulary resolves and only `wallable_overlay_keys` degrades
|
| 1130 |
+
to `{}`, this set becomes EVERY user column β the widest refusal, and the pre-change
|
| 1131 |
+
behaviour. Neither path can accept a wall the enforcement layer will be unable to apply.
|
| 1132 |
+
"""
|
| 1133 |
+
if key not in _FIELD_PROVIDER_KEYS:
|
| 1134 |
+
return set()
|
| 1135 |
+
import core.perm_scope as perm_scope
|
| 1136 |
+
|
| 1137 |
+
st = getattr(session, "runtime", None)
|
| 1138 |
+
provider = _static_field_providers().get(key)
|
| 1139 |
+
declared = {f.get("key") for f in (provider() if provider else ())
|
| 1140 |
+
if isinstance(f, dict)}
|
| 1141 |
+
found = perm_scope.user_generated_fields(key, st=st)
|
| 1142 |
+
wallable = set(perm_scope.wallable_overlay_keys(key, st=st))
|
| 1143 |
+
return {f["key"] for f in (found or ())
|
| 1144 |
+
if isinstance(f, dict) and f.get("key") and f["key"] not in declared
|
| 1145 |
+
and f["key"] not in wallable}
|
| 1146 |
|
| 1147 |
|
| 1148 |
def _clean_perms(v, governed_keys=None, session=None):
|
|
|
|
| 1196 |
for key, raw in v.items():
|
| 1197 |
if not isinstance(raw, dict):
|
| 1198 |
raise err(400, "bad_perms", f"{key}: each entry must be an object")
|
| 1199 |
+
# ββ AM-2 β ONE SOURCE, TWO VOCABULARIES, AND THE VALIDATOR READS BOTH. The
|
| 1200 |
+
# picker and this validator still call the SAME function, which is the property
|
| 1201 |
+
# `_module_fields`' docstring exists to protect; what changed is that a field now states
|
| 1202 |
+
# which vocabulary it belongs to, and each consumer reads its own membership instead of
|
| 1203 |
+
# the whole list.
|
| 1204 |
+
#
|
| 1205 |
+
# β THE SPLIT IS WHY THE METRIC ROWS ARE SAFE TO ADD. `hiddenFields` is validated
|
| 1206 |
+
# against EVERY key (a metric row is hideable β that is I13's whole point), while the
|
| 1207 |
+
# permanent FILTER is validated against `filterable` only. Without the second set,
|
| 1208 |
+
# admitting `measure_margin` would make {"colId": "measure_margin", ...} a storable
|
| 1209 |
+
# permanent wall, and `permits()` answers False for every row that has no such key:
|
| 1210 |
+
# measured, not feared. `clean_filter_tree` takes bare strings and cannot see the flag,
|
| 1211 |
+
# so the narrowing has to happen HERE, at the call.
|
| 1212 |
+
fields_here = _module_fields(key, session=session)
|
| 1213 |
+
valid_keys = {f["key"] for f in fields_here}
|
| 1214 |
+
filter_keys = {f["key"] for f in fields_here if f.get("filterable")}
|
| 1215 |
+
# W40-T05 x W40-T18, see `_row_wall_blind_keys`. A user-generated column of a TOPIC grid
|
| 1216 |
+
# is always HIDEABLE (it stays in `valid_keys`), and it is FILTERABLE only when the wall
|
| 1217 |
+
# can actually answer it β a tenant-wide overlay column can, a browser-computed one and a
|
| 1218 |
+
# per-user private one cannot, and those keep denying every leaf they are named in.
|
| 1219 |
+
row_wall_blind = _row_wall_blind_keys(key, session)
|
| 1220 |
+
filter_keys -= row_wall_blind
|
| 1221 |
hidden = raw.get("hiddenFields") or []
|
| 1222 |
if not isinstance(hidden, list):
|
| 1223 |
raise err(400, "bad_perms", f"{key}: hiddenFields must be a list")
|
| 1224 |
+
submitted = {str(h) for h in hidden}
|
| 1225 |
+
# ββ A METRIC TICK IS ADMITTED ON ITS PREFIX, NOT ON THE LIVE OFFER, AND THAT CLOSES A
|
| 1226 |
+
# GET/PUT SKEW RATHER THAN WEAKENING THE GUARD.
|
| 1227 |
+
#
|
| 1228 |
+
# `_metric_fields` asks `semantic.entity_measures`, which REFUSES every key while the
|
| 1229 |
+
# mirror cannot be read β measured twice in this tree on 2026-08-23, when another
|
| 1230 |
+
# process held the DuckDB and the offer came back empty. That answer is deliberately not
|
| 1231 |
+
# cached (`_ENTITY_OFFER_CACHE` skips an indeterminate one), so the state recurs freely.
|
| 1232 |
+
# Without this line the sequence is: the editor GETs a payload carrying
|
| 1233 |
+
# `measure_margin`, the admin ticks "Metric - Gross margin $", the PUT lands a moment
|
| 1234 |
+
# later while the store is busy, `valid_keys` has 39 entries instead of 45, and the
|
| 1235 |
+
# administrator is told their own tick *"names unknown fields"*. That is this function's
|
| 1236 |
+
# ONE SOURCE invariant running backwards β the validator rejecting exactly what the
|
| 1237 |
+
# picker offered.
|
| 1238 |
+
#
|
| 1239 |
+
# β AND ADMITTING IT IS CORRECT, not merely convenient, because the ENFORCEMENT keys off
|
| 1240 |
+
# the measure NAME and not off the offer: `perm_scope._measure_bound_keys` hides every
|
| 1241 |
+
# column whose `measure.key` matches, whether or not the catalogue is answering right now.
|
| 1242 |
+
# So a tick stored during a warm-up walls the right columns the moment they render. A
|
| 1243 |
+
# metric key that never comes back hides nothing, which is the harmless direction; the
|
| 1244 |
+
# refusal is the harmful one.
|
| 1245 |
+
#
|
| 1246 |
+
# β NARROW BY CONSTRUCTION: only the `measure_` namespace is admitted this way, and only
|
| 1247 |
+
# with a non-empty suffix. Every other unknown key is still refused, because a
|
| 1248 |
+
# `hiddenFields` entry naming nothing reads as a restriction that is not there.
|
| 1249 |
+
_mpre = aios_grid.MEASURE_FIELD_PREFIX
|
| 1250 |
+
metric_ticks = {h for h in submitted
|
| 1251 |
+
if h.startswith(_mpre) and len(h) > len(_mpre)}
|
| 1252 |
+
bad = sorted(submitted - valid_keys - metric_ticks)
|
| 1253 |
if bad:
|
| 1254 |
# A hiddenFields entry naming nothing hides nothing β and reads as a restriction
|
| 1255 |
# that is not there.
|
|
|
|
| 1267 |
if conj not in ("and", "or"):
|
| 1268 |
raise err(400, "bad_filter", f"{key}: conj must be 'and' or 'or'")
|
| 1269 |
nodes = tree["nodes"]
|
| 1270 |
+
# ββ THE CASCADE DOES **NOT** RUN ON THE SUBMITTED TREE, AND W40-T05 SHIPPED THE
|
| 1271 |
+
# OPPOSITE FOR AN HOUR. It pruned here first, so that an administrator with a stale
|
| 1272 |
+
# tab would not be told their own saved rule was a client error. Sympathetic, and
|
| 1273 |
+
# WRONG: `verify_api`'s leg *"β a filter naming an unknown FIELD -> 400, never
|
| 1274 |
+
# saved-minus-the-bad-leaf"* went red on the very case it exists for β a PUT naming
|
| 1275 |
+
# `ghost` was accepted and stored minus that leaf. This validator is a SECURITY door,
|
| 1276 |
+
# and the sentence the refusal below already carried says why: a wall saved with its
|
| 1277 |
+
# bad conditions silently removed is WEAKER THAN THE ONE ON SCREEN.
|
| 1278 |
+
#
|
| 1279 |
+
# β SO THE CASCADE LIVES ON THE **STORED** RECORD ONLY, in `get_perms` (see
|
| 1280 |
+
# `_prunable_vocabulary`'s own docstring). That is the honest split, and it is enough
|
| 1281 |
+
# for I16: the leaf disappears when the record is next read, which is the same page
|
| 1282 |
+
# load a stale tab has to do anyway. A leaf in a payload the client just SENT is
|
| 1283 |
+
# refused, loudly, whatever its history β the server cannot tell a deleted column from
|
| 1284 |
+
# a typo in a submission, and only one of those two guesses is safe.
|
| 1285 |
+
# β AN EMPTIED FILTER IS `None`, NEVER `{"conj": "and", "nodes": []}`. Measured:
|
| 1286 |
+
# `filter_eval.permits` returns True on an empty node list, so an empty-but-present
|
| 1287 |
+
# tree admits every row β while `perm_scope.wall_declared` and `row_scope_applies`
|
| 1288 |
+
# both read it as TRUTHY and answer that a wall applies. A door would then build rows
|
| 1289 |
+
# in order to filter them against nothing, and the editor would paint a rule that is
|
| 1290 |
+
# not there. This also normalises a client that PUTs `{"nodes": []}` to mean "no
|
| 1291 |
+
# filter", which is what it has always meant on screen.
|
| 1292 |
+
if nodes:
|
| 1293 |
+
# Named before the generic refusal below, because "an unknown field" is exactly
|
| 1294 |
+
# what this is NOT: the picker offered it one request ago. The admin needs to be
|
| 1295 |
+
# told which column and why, or they will simply try again.
|
| 1296 |
+
blind = sorted(_leaf_col_ids(nodes) & row_wall_blind)
|
| 1297 |
+
if blind:
|
| 1298 |
+
raise err(400, "bad_filter",
|
| 1299 |
+
f"{key}: a permission filter cannot use {blind}. Those columns are "
|
| 1300 |
+
f"computed in the browser, or stored privately for one user, so "
|
| 1301 |
+
f"the server cannot evaluate them for this account and the rule "
|
| 1302 |
+
f"would hide EVERY row with nothing on screen saying why. Hide the "
|
| 1303 |
+
f"column instead, or filter on one of the database's own columns "
|
| 1304 |
+
f"or on a column shared with the whole workspace.")
|
| 1305 |
+
cleaned = aios_grid.clean_filter_tree(nodes, filter_keys, cohort_ids=None)
|
| 1306 |
+
if _leaf_count(cleaned) != _leaf_count(nodes):
|
| 1307 |
+
raise err(400, "bad_filter",
|
| 1308 |
+
f"{key}: the filter contains conditions this module cannot evaluate "
|
| 1309 |
+
f"(an unknown field, an unknown operator, or a cohort leaf β cohorts "
|
| 1310 |
+
f"are per-user and cannot be a permanent rule). Refused rather than "
|
| 1311 |
+
f"saved with the bad conditions silently removed, which would store "
|
| 1312 |
+
f"a weaker wall than the one on screen.")
|
| 1313 |
+
clean_tree = {"conj": conj, "nodes": cleaned}
|
| 1314 |
# ββ W38-T19 β `metrics` IS THE FOURTH FIELD OF AN ENTRY, AND ITS DEFAULT IS GRANT.
|
| 1315 |
# `raw.get("metrics", True)` rather than a required key: a PUT composed by an older
|
| 1316 |
# client, or a copy of a record written before this ticket, must not read as a
|
|
|
|
| 1318 |
# the validator and the wall cannot disagree about what an absent key means.
|
| 1319 |
out[key] = {"access": bool(raw.get("access", True)),
|
| 1320 |
"filter": clean_tree,
|
| 1321 |
+
"hiddenFields": sorted(submitted),
|
| 1322 |
"metrics": bool(raw.get("metrics", True))}
|
| 1323 |
_refuse_unshapeable_bu(out)
|
| 1324 |
return out
|
|
|
|
| 1608 |
# ββ W36-T22 / C2 β EVERY listed database, not an `enforced` subset of them. See
|
| 1609 |
# `perms.tenant_governable_modules` for why the flag is deleted rather than defaulted.
|
| 1610 |
governed = [m["key"] for m in modules]
|
| 1611 |
+
# β ONE `_module_fields` PASS, SHARED BY THE PICKER AND THE CASCADE. It used to be built
|
| 1612 |
+
# inline at the return; hoisted so the prune below reads the SAME vocabulary the payload
|
| 1613 |
+
# offers rather than paying a second store round-trip per database to ask again.
|
| 1614 |
+
fields_by_module = {k: _module_fields(k, session=session) for k in governed}
|
| 1615 |
+
# ββ W40-T05 / OWNER I16 β THE CASCADE, AT THE ADMIN DOOR. *"If the field is deleted, its
|
| 1616 |
+
# permission filter goes with it."* A stored leaf naming a column the database no longer has
|
| 1617 |
+
# is not ignored by the wall β `apply_row_scope` uses `permits`, which DENIES what it cannot
|
| 1618 |
+
# answer β so a deleted column silently converts that account's grid to zero rows. Dropping
|
| 1619 |
+
# the leaf here means the editor renders, and the record stores, only rules that still exist.
|
| 1620 |
+
#
|
| 1621 |
+
# ββ GUARDED ON `is_migrated`, AND THAT GUARD IS A BU LEAK AWAY FROM OPTIONAL.
|
| 1622 |
+
# `users.set_access(perms=β¦)` STAMPS `perms_v` in the same read-modify-write, so writing here
|
| 1623 |
+
# would MIGRATE an un-migrated record β and `_fold_legacy_scope` runs only WHILE a record is
|
| 1624 |
+
# un-migrated. A GET would then consume the one chance to fold the legacy `bus`/`agent` scope
|
| 1625 |
+
# in, and the account would silently acquire the other business unit's customers. The
|
| 1626 |
+
# `stored` test alone would very nearly cover it (an un-migrated record carries no perms
|
| 1627 |
+
# block), so the marker is asked explicitly rather than inferred from an empty dict.
|
| 1628 |
+
if stored and perm_scope.is_migrated(rec):
|
| 1629 |
+
_pruned, _gone = _prune_stale_filters(stored, session=session)
|
| 1630 |
+
if _gone:
|
| 1631 |
+
users.set_access(uname, perms=_pruned)
|
| 1632 |
+
# Re-read rather than trust the write: this route's whole job is to report what is
|
| 1633 |
+
# STORED, and a store that took nothing must not be reported as if it had.
|
| 1634 |
+
rec = _registry().get(uname) or rec
|
| 1635 |
+
stored = rec.get("perms") or _pruned
|
| 1636 |
perms_out = {}
|
| 1637 |
for k in governed:
|
| 1638 |
e = stored.get(k)
|
|
|
|
| 1697 |
# item 11's *"EVERY database should be able to be toggleable by admin"*, and it is
|
| 1698 |
# the SAME resolver `_clean_perms` validates against, so the picker cannot offer a
|
| 1699 |
# column the validator will reject.
|
| 1700 |
+
"fields_by_module": fields_by_module}
|
| 1701 |
|
| 1702 |
|
| 1703 |
@router.put("/admin/users/{username}/perms")
|
api/routes_auth.py
CHANGED
|
@@ -180,7 +180,41 @@ def login(request: Request, response: Response, body: dict = Body(default=None))
|
|
| 180 |
raise err(401, "invalid_credentials", "that username and password do not match")
|
| 181 |
|
| 182 |
_clear_failures(throttle_key)
|
| 183 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 184 |
aios_session.set_cookie(response, request, value)
|
| 185 |
# Wave 19 (R4): the login stamp. THE RESOLVED username, never the posted identifier β the
|
| 186 |
# person may have typed an email address and `users.verify` resolved it to the registry key;
|
|
@@ -214,8 +248,9 @@ def logout(request: Request):
|
|
| 214 |
|
| 215 |
β This clears the BROWSER's copy only β the signed value stays cryptographically valid until
|
| 216 |
it expires, which is the honest cost of a stateless session. "Sign me out everywhere" is
|
| 217 |
-
`core.users.bump_epoch` (a password change already does it
|
| 218 |
-
|
|
|
|
| 219 |
"""
|
| 220 |
out = Response(status_code=204)
|
| 221 |
aios_session.clear_cookie(out, request)
|
|
|
|
| 180 |
raise err(401, "invalid_credentials", "that username and password do not match")
|
| 181 |
|
| 182 |
_clear_failures(throttle_key)
|
| 183 |
+
|
| 184 |
+
# β WAVE 40, R2 β SINGLE SESSION, NEWEST WINS. Signing in here signs out every session this
|
| 185 |
+
# account already holds, so a forgotten sign-in on someone else's computer cannot lock the
|
| 186 |
+
# owner of the account out of it. NO SESSION REGISTRY IS BUILT and none is needed: the cookie
|
| 187 |
+
# is stateless and carries the epoch it was minted under, `deps._user_for` admits only on an
|
| 188 |
+
# exact match, so one bump kills every outstanding cookie for this user at once.
|
| 189 |
+
#
|
| 190 |
+
# β MINT FROM THE BUMPED VALUE, NEVER FROM `user["epoch"]` AGAIN. `user` was projected BEFORE
|
| 191 |
+
# the bump; minting from it would issue every cookie in the product at the OLD epoch, which
|
| 192 |
+
# `_user_for` refuses on the very next request β "200, then 401 forever".
|
| 193 |
+
#
|
| 194 |
+
# TWO IDENTITIES ARE EXEMPT, both by design:
|
| 195 |
+
# * `qa_runner` β the synthetic staging identity has no registry record to bump (its epoch is
|
| 196 |
+
# derived from APP_PASSWORD), and `verify_api.py` asserts its login path reads and writes
|
| 197 |
+
# NOTHING on tenant #0's `users` key, which a bump's read-modify-write would violate.
|
| 198 |
+
# * `emergency_master` β `deps._user_for` admits that identity whatever the record's epoch
|
| 199 |
+
# says, so a bump revokes nothing there and only risks a store write on the break-glass
|
| 200 |
+
# path that exists precisely for a store outage.
|
| 201 |
+
#
|
| 202 |
+
# A FAILED BUMP MUST NOT FAIL THE LOGIN. `store.update` raises `StoreWriteRefused` where the
|
| 203 |
+
# deployment may not write this tenant (mapped to 503 in `main.py`) and `RuntimeError` when the
|
| 204 |
+
# store is unavailable, so an unguarded bump would turn every sign-in on such a deployment into
|
| 205 |
+
# a 503. The sign-in stands at the epoch it can prove; only the sign-out-everywhere half is
|
| 206 |
+
# lost, and the log says so rather than leaving it silent.
|
| 207 |
+
session_epoch = int(user.get("epoch") or 0)
|
| 208 |
+
if not (user.get("qa_runner") or user.get("emergency_master")):
|
| 209 |
+
try:
|
| 210 |
+
bumped = users.bump_epoch(user["username"])
|
| 211 |
+
if bumped is not None:
|
| 212 |
+
session_epoch = int(bumped)
|
| 213 |
+
except Exception as exc:
|
| 214 |
+
print(f"[aios-api] login for {user['username']!r}: could not bump the session epoch "
|
| 215 |
+
f"({type(exc).__name__}). This sign-in stands, but the account's previous "
|
| 216 |
+
f"session was NOT signed out.")
|
| 217 |
+
value, _claims = aios_session.mint(tenant, user["username"], session_epoch)
|
| 218 |
aios_session.set_cookie(response, request, value)
|
| 219 |
# Wave 19 (R4): the login stamp. THE RESOLVED username, never the posted identifier β the
|
| 220 |
# person may have typed an email address and `users.verify` resolved it to the registry key;
|
|
|
|
| 248 |
|
| 249 |
β This clears the BROWSER's copy only β the signed value stays cryptographically valid until
|
| 250 |
it expires, which is the honest cost of a stateless session. "Sign me out everywhere" is
|
| 251 |
+
`core.users.bump_epoch` (a password change already does it, and since wave 40's R2 so does
|
| 252 |
+
every LOGIN β signing in anywhere signs out every other session the account holds); D2's
|
| 253 |
+
Postgres session mirror makes per-device revocation possible and arrives with C-2.
|
| 254 |
"""
|
| 255 |
out = Response(status_code=204)
|
| 256 |
aios_session.clear_cookie(out, request)
|
api/routes_automation.py
CHANGED
|
@@ -299,6 +299,66 @@ ODOO_CADENCE_PHRASE = {"30m": "Every 30 minutes", "1h": "Every hour",
|
|
| 299 |
"4h": "Every 4 hours", "daily": "Every day"}
|
| 300 |
|
| 301 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 302 |
def _odoo_sync_row(session, detail=False):
|
| 303 |
"""ββ CONTRACT C4 (ruling R22) β the Odoo sync, as an agent you can SEE.
|
| 304 |
|
|
@@ -325,9 +385,23 @@ def _odoo_sync_row(session, detail=False):
|
|
| 325 |
β `detail=False` IS THE LIST PATH AND IT STAYS CHEAP. The keychain label and the last-sync
|
| 326 |
stamp each cost their own store read, and `GET /automations` is the route two waves were spent
|
| 327 |
taking reads OFF. They are resolved only on the DETAIL fetch, which is one automation and one
|
| 328 |
-
click.
|
| 329 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 330 |
"""
|
|
|
|
|
|
|
|
|
|
|
|
|
| 331 |
try:
|
| 332 |
import odoo_relational as rel
|
| 333 |
except Exception: # noqa: BLE001
|
|
@@ -1601,6 +1675,18 @@ def patch_automation(auto_id: str, body: dict = Body(default=None),
|
|
| 1601 |
"this agent is an AI enrichment column. Change its prompt, model or schedule on "
|
| 1602 |
"the column itself and this page follows")
|
| 1603 |
if str(auto_id) == ODOO_SYNC_ID:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1604 |
return _patch_odoo_sync(session, body or {})
|
| 1605 |
# D-75, same channel as `create` above β an EDIT is where this matters most, because the
|
| 1606 |
# person has just typed the thing that gets dropped.
|
|
@@ -1648,6 +1734,15 @@ def delete_automation(auto_id: str, session: Session = Depends(_GATE)):
|
|
| 1648 |
if str(auto_id).startswith("field:"):
|
| 1649 |
raise err(409, "system_agent", engine.system_agent_refusal(SYSTEM_FIELD_AGENT))
|
| 1650 |
if str(auto_id) == ODOO_SYNC_ID:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1651 |
raise err(409, "system_agent", engine.system_agent_refusal(SYSTEM_ODOO_SYNC))
|
| 1652 |
if engine.running(session.tenant, auto_id):
|
| 1653 |
raise err(409, "automation_running", "it is running. Wait for it to finish")
|
|
|
|
| 299 |
"4h": "Every 4 hours", "daily": "Every day"}
|
| 300 |
|
| 301 |
|
| 302 |
+
def _odoo_connected(session):
|
| 303 |
+
"""Would a credential actually SERVE this tenant's Odoo? (W40-T12, owner instruction I28.)
|
| 304 |
+
|
| 305 |
+
ββ NOBODY WAS ASKING THIS, AND THE CARD IS THE ONLY THING THAT NEEDED TO. `_odoo_sync_row`
|
| 306 |
+
below promised `None` for a tenant with no Odoo; its only guard was a bare `try/except` around
|
| 307 |
+
`odoo_relational.read_config`, whose own docstring says it NEVER RAISES β a store hiccup must
|
| 308 |
+
not make a connector look disconnected. So every tenant on the platform fell through to the
|
| 309 |
+
default `{"syncEvery": "30m", "frozen": False}` and got the card. Owner I28: *"The 'Odoo sync'
|
| 310 |
+
automation must appear only in a tenant that actually has the Odoo sync (Royal Imports). It is
|
| 311 |
+
showing under the Nurilab tenant."* An agent for a connector nobody connected is a card that
|
| 312 |
+
lies, and it had been lying since wave 34.
|
| 313 |
+
|
| 314 |
+
ββ WHICH QUESTION THIS IS MATTERS MORE THAN THE LINE. Three were available; only one is the
|
| 315 |
+
owner's *"ACTUAL Odoo sync"*:
|
| 316 |
+
* `odoo_relational.is_royal(tenant)` is ENTITLEMENT β a hardcoded `RI_SLUGS` list, and
|
| 317 |
+
`is_royal("")` is deliberately TRUE (`verify_automation`'s W35-T35 leg pins that as a
|
| 318 |
+
looser question on purpose). It answers "may this tenant have the mirror", never "has
|
| 319 |
+
anyone connected it", so it would hide the card from a future tenant that genuinely
|
| 320 |
+
connects Odoo. That is this ticket's own negative case, failed by the check meant to fix it.
|
| 321 |
+
* `routes_keychain.env_odoo_available(rt)` is the ENV half only (`ODOO_URL` present AND
|
| 322 |
+
tenant #0). Its own docstring says it stays True for Royal even when a keychain entry is
|
| 323 |
+
the thing actually serving, because the connectors pane needs to list an inactive env
|
| 324 |
+
source beside an active one. Structurally it can never be True for tenant #1.
|
| 325 |
+
* `runtime.odoo_flag_key()` is D-10's ONE resolver: first unlocked keychain `odoo` entry,
|
| 326 |
+
else tenant #0's compiled env source, else None. CREDENTIAL PRESENCE, which is what was
|
| 327 |
+
asked for.
|
| 328 |
+
β AND THE LAST ONE IS THE RIGHT ONE FOR C4 SPECIFICALLY, not merely the most accurate. C4's
|
| 329 |
+
clause is that the card "cannot drift from the running loop", and `odoo_flag_key` is the SAME
|
| 330 |
+
resolution `odoo_source()` builds the running client from β so the card's EXISTENCE is decided
|
| 331 |
+
by the loop's own resolver, exactly as its cadence already is. A locked keychain resolves to
|
| 332 |
+
None and nothing syncs, so the card goes rather than advertising a 30m cadence nothing keeps.
|
| 333 |
+
Re-deriving those three rules here would be D-10 a third time, in a third file.
|
| 334 |
+
|
| 335 |
+
β FAIL-CLOSED, AND THE `except` IS NOT BLANKET DEFENSIVENESS. A production `TenantRuntime` is
|
| 336 |
+
a dataclass with `key` always set and `list_entries` already wrapped, so its own branches
|
| 337 |
+
cannot raise; the handler covers a store outage and any caller holding a runtime-shaped object
|
| 338 |
+
instead of the real one. "We could not tell" must mean NO CARD rather than a 500 on the one
|
| 339 |
+
route the whole Agents surface polls β the posture `_field_agent_rows` and
|
| 340 |
+
`seed_statements_agent` already take on this same route, for the same reason.
|
| 341 |
+
|
| 342 |
+
β THE COST, REPORTED RATHER THAN LEFT TO BE DISCOVERED. On a CONNECTED tenant this adds one
|
| 343 |
+
`core.keychain.list_entries` read to `GET /automations`, a route two waves were spent taking
|
| 344 |
+
reads off. It is the keychain METADATA bucket (`MAX_ENTRIES = 40` rows of label/type/preview,
|
| 345 |
+
never a decrypted field), not the 28.6 MB `user_tables` document D-185 removed. MEASURED, and
|
| 346 |
+
the measurement is reported for what it is: this whole guard costs **0.017 ms/call** warm over
|
| 347 |
+
2,000 calls, three runs (`list_entries` itself under 0.01), against an in-memory bucket rather
|
| 348 |
+
than a real store, which is the honest scope of the number. So the RESOLUTION is
|
| 349 |
+
below the noise of the route it sits on; what production adds on top is one `rt.get` of that
|
| 350 |
+
metadata bucket, which is the same order as the `read_config` reads already on this path. On a
|
| 351 |
+
DISCONNECTED tenant it is strictly CHEAPER than before, because the row now returns before
|
| 352 |
+
`read_config` + `sync_seconds` + `frozen` β three separate `rt.get(CONFIG_KEY)` reads, since
|
| 353 |
+
the latter two each call `read_config` again β that were being spent to build a card nobody
|
| 354 |
+
should ever have seen.
|
| 355 |
+
"""
|
| 356 |
+
try:
|
| 357 |
+
return bool(session.runtime.odoo_flag_key())
|
| 358 |
+
except Exception: # noqa: BLE001
|
| 359 |
+
return False
|
| 360 |
+
|
| 361 |
+
|
| 362 |
def _odoo_sync_row(session, detail=False):
|
| 363 |
"""ββ CONTRACT C4 (ruling R22) β the Odoo sync, as an agent you can SEE.
|
| 364 |
|
|
|
|
| 385 |
β `detail=False` IS THE LIST PATH AND IT STAYS CHEAP. The keychain label and the last-sync
|
| 386 |
stamp each cost their own store read, and `GET /automations` is the route two waves were spent
|
| 387 |
taking reads OFF. They are resolved only on the DETAIL fetch, which is one automation and one
|
| 388 |
+
click.
|
| 389 |
+
|
| 390 |
+
ββ RETURNS `None` UNLESS A CREDENTIAL WOULD ACTUALLY SERVE THIS TENANT'S ODOO (W40-T12 /
|
| 391 |
+
I28), AND UNTIL W40-T12 THAT SENTENCE WAS ASPIRATIONAL. This docstring already claimed *"None
|
| 392 |
+
when this tenant has no Odoo at all"*, but no line here ever asked: the only guard was the
|
| 393 |
+
`try/except` below around `read_config`, which never raises, so every tenant got the card. The
|
| 394 |
+
question is asked out loud now, in `_odoo_connected` β CREDENTIAL PRESENCE via
|
| 395 |
+
`runtime.odoo_flag_key()`, the same resolver the running sync builds its client from. It is
|
| 396 |
+
NOT `odoo_relational.is_royal` (entitlement, a slug list, true for the empty slug) and NOT
|
| 397 |
+
`routes_keychain.env_odoo_available` (the environment half only); read that function for why
|
| 398 |
+
each of those answers a different question, and why picking one of them would have broken this
|
| 399 |
+
ticket's own negative case.
|
| 400 |
"""
|
| 401 |
+
# β PRESENCE FIRST, ABOVE THE CONNECTOR READS. Cheapest correct order: a tenant with no Odoo
|
| 402 |
+
# never pays `read_config` + `sync_seconds` + `frozen` to build a row that is thrown away.
|
| 403 |
+
if not _odoo_connected(session):
|
| 404 |
+
return None
|
| 405 |
try:
|
| 406 |
import odoo_relational as rel
|
| 407 |
except Exception: # noqa: BLE001
|
|
|
|
| 1675 |
"this agent is an AI enrichment column. Change its prompt, model or schedule on "
|
| 1676 |
"the column itself and this page follows")
|
| 1677 |
if str(auto_id) == ODOO_SYNC_ID:
|
| 1678 |
+
# ββ W40-T12 / I28 β A LIST AND A DETAIL THAT DISAGREE IS THE DEFECT THIS FILE'S OWN C3
|
| 1679 |
+
# COMMENTS RAIL ABOUT, and a PATCH that CONFIGURES a row neither of them will admit exists
|
| 1680 |
+
# is that same disagreement with a write in it. `get_automation` already answers
|
| 1681 |
+
# `404 unknown_automation` for this id when the row is None; this is the identical
|
| 1682 |
+
# condition and the identical error, so the three doors give one answer.
|
| 1683 |
+
# β AT THE DOOR, BEFORE `_patch_odoo_sync` β which writes `rel.CONFIG_KEY` and only THEN
|
| 1684 |
+
# rebuilds the row. Reaching it on a disconnected tenant would persist a cadence for a
|
| 1685 |
+
# connector nobody connected and 404 afterwards: a refusal that had already written. Its
|
| 1686 |
+
# own trailing `row is None` 404 stays exactly where it is, unreachable from this route
|
| 1687 |
+
# now but still the guard for any other caller of that function.
|
| 1688 |
+
if not _odoo_connected(session):
|
| 1689 |
+
raise err(404, "unknown_automation", "no automation with that id")
|
| 1690 |
return _patch_odoo_sync(session, body or {})
|
| 1691 |
# D-75, same channel as `create` above β an EDIT is where this matters most, because the
|
| 1692 |
# person has just typed the thing that gets dropped.
|
|
|
|
| 1734 |
if str(auto_id).startswith("field:"):
|
| 1735 |
raise err(409, "system_agent", engine.system_agent_refusal(SYSTEM_FIELD_AGENT))
|
| 1736 |
if str(auto_id) == ODOO_SYNC_ID:
|
| 1737 |
+
# ββ W40-T12 / I28 β 404 BEFORE 409, AND THE ORDER IS THE WHOLE POINT. The 409 below is
|
| 1738 |
+
# C4/R22 law and does not move: on a tenant that HAS Odoo this agent exists, is derived,
|
| 1739 |
+
# and is undeletable. But 409 is a statement that the thing EXISTS and is protected, and
|
| 1740 |
+
# telling a Nurilab admin that a card they cannot see is protected is the same list/detail
|
| 1741 |
+
# disagreement as the PATCH case, wearing a refusal instead of a write. Where there is no
|
| 1742 |
+
# credential there is no agent, so the answer is the unknown-id 404 every other absent
|
| 1743 |
+
# automation gets.
|
| 1744 |
+
if not _odoo_connected(session):
|
| 1745 |
+
raise err(404, "unknown_automation", "no automation with that id")
|
| 1746 |
raise err(409, "system_agent", engine.system_agent_refusal(SYSTEM_ODOO_SYNC))
|
| 1747 |
if engine.running(session.tenant, auto_id):
|
| 1748 |
raise err(409, "automation_running", "it is running. Wait for it to finish")
|
api/routes_customers.py
CHANGED
|
@@ -274,7 +274,21 @@ def grid_assembly(session: Session, scope: str = "customer", storage_key: str =
|
|
| 274 |
# reasons: the assembled list is not built yet (it needs `pids`), and a permanent filter may
|
| 275 |
# only ever name a canonical field anyway β `routes_admin._clean_perms` validates it against
|
| 276 |
# exactly this schema and 400s otherwise. `permits()` denies on anything it cannot answer.
|
| 277 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 278 |
pids = frozenset(r["pid"] for r in rows_src if r.get("pid") is not None)
|
| 279 |
# β W38-T20 β THE COLUMN DEFINITIONS ARE READ **ONCE** PER ASSEMBLY AND THREADED, because
|
| 280 |
# `core.store.get` deep-copies whatever it hands back on every call. Three consumers want this
|
|
@@ -488,12 +502,17 @@ def allowed_pids(session: Session):
|
|
| 488 |
paths close that gap with `apply_row_scope`; without the same call here the write wall would
|
| 489 |
be the wider set, and a restricted user could PATCH a row this API will not show them.
|
| 490 |
Same function, same order as `grid_assembly`, so the two walls cannot drift.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 491 |
"""
|
| 492 |
import core.perm_scope as perm_scope
|
| 493 |
import aios_grid
|
| 494 |
|
| 495 |
rows = perm_scope.apply_row_scope(_pool_rows(session), session.user, MODULE,
|
| 496 |
-
aios_grid.FIELDS)
|
| 497 |
return frozenset(r["pid"] for r in rows if r.get("pid") is not None)
|
| 498 |
|
| 499 |
|
|
|
|
| 274 |
# reasons: the assembled list is not built yet (it needs `pids`), and a permanent filter may
|
| 275 |
# only ever name a canonical field anyway β `routes_admin._clean_perms` validates it against
|
| 276 |
# exactly this schema and 400s otherwise. `permits()` denies on anything it cannot answer.
|
| 277 |
+
#
|
| 278 |
+
# ββ OWNER I16 β `st=rt` IS WHAT MAKES A WALL ON A USER-GENERATED COLUMN MEAN ANYTHING
|
| 279 |
+
# HERE. *"Permission Filters must be able to filter on user-generated Fields too."* The
|
| 280 |
+
# sentence above is exactly why it was needed: the canonical list has no `custom_` column in
|
| 281 |
+
# it and these rows are PRE-OVERLAY, so such a leaf denied every row while the editor
|
| 282 |
+
# reported the rule saved. With the handle, `perm_scope._enrich_for_wall` merges the
|
| 283 |
+
# tenant-wide value for the named column onto a COPY of each row and declares it for the
|
| 284 |
+
# evaluator. Nothing else about this call changes, and a caller with no handle still gets
|
| 285 |
+
# the wall exactly as it was.
|
| 286 |
+
#
|
| 287 |
+
# β THE SAME HANDLE GOES TO `allowed_pids` BELOW, AND THE PAIR IS NOT OPTIONAL. That is the
|
| 288 |
+
# WRITE wall to this one's READ wall; lending it here alone would make a user-generated rule
|
| 289 |
+
# narrow what an account SEES while leaving what it may PATCH untouched.
|
| 290 |
+
rows_src = perm_scope.apply_row_scope(rows_src, session.user, MODULE, aios_grid.FIELDS,
|
| 291 |
+
st=rt)
|
| 292 |
pids = frozenset(r["pid"] for r in rows_src if r.get("pid") is not None)
|
| 293 |
# β W38-T20 β THE COLUMN DEFINITIONS ARE READ **ONCE** PER ASSEMBLY AND THREADED, because
|
| 294 |
# `core.store.get` deep-copies whatever it hands back on every call. Three consumers want this
|
|
|
|
| 502 |
paths close that gap with `apply_row_scope`; without the same call here the write wall would
|
| 503 |
be the wider set, and a restricted user could PATCH a row this API will not show them.
|
| 504 |
Same function, same order as `grid_assembly`, so the two walls cannot drift.
|
| 505 |
+
|
| 506 |
+
β AND `st` IS PART OF "SAME FUNCTION, SAME ORDER" (owner I16). `grid_assembly` lends the
|
| 507 |
+
tenant handle so a wall naming a user-generated column can be answered at all; without the
|
| 508 |
+
identical argument here that rule would narrow the READ and not the WRITE β the drift this
|
| 509 |
+
docstring already refuses, wearing a new argument's clothes.
|
| 510 |
"""
|
| 511 |
import core.perm_scope as perm_scope
|
| 512 |
import aios_grid
|
| 513 |
|
| 514 |
rows = perm_scope.apply_row_scope(_pool_rows(session), session.user, MODULE,
|
| 515 |
+
aios_grid.FIELDS, st=session.runtime)
|
| 516 |
return frozenset(r["pid"] for r in rows if r.get("pid") is not None)
|
| 517 |
|
| 518 |
|
api/routes_products.py
CHANGED
|
@@ -115,7 +115,14 @@ def scoped_pool(session: Session):
|
|
| 115 |
# The SAME wall the customer assembly applies, in the same order: rows first (before pids
|
| 116 |
# are taken, so an out-of-filter row never enters allowed_pids), then the field closure,
|
| 117 |
# then the values stripped from the rows as well as the field list.
|
| 118 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 119 |
pids = frozenset(r["pid"] for r in rows_src if r.get("pid") is not None)
|
| 120 |
return pids, team_id, rows_src, fields_base
|
| 121 |
|
|
|
|
| 115 |
# The SAME wall the customer assembly applies, in the same order: rows first (before pids
|
| 116 |
# are taken, so an out-of-filter row never enters allowed_pids), then the field closure,
|
| 117 |
# then the values stripped from the rows as well as the field list.
|
| 118 |
+
# ββ OWNER I16 β AND THE SAME TENANT HANDLE, for the same reason and with the same
|
| 119 |
+
# consequence if it is left off. `fields_base` is this topic's contract plus its declared
|
| 120 |
+
# tenant-wide columns; a column a USER made is in neither, and these rows are pre-overlay,
|
| 121 |
+
# so such a leaf denied every product row while the admin was told the rule saved. See
|
| 122 |
+
# `perm_scope._enrich_for_wall`. This route is BOTH walls at once (it returns the pids the
|
| 123 |
+
# write door uses), so there is no second call here to keep in step.
|
| 124 |
+
rows_src = perm_scope.apply_row_scope(rows_src, session.user, MODULE, fields_base,
|
| 125 |
+
st=session.runtime)
|
| 126 |
pids = frozenset(r["pid"] for r in rows_src if r.get("pid") is not None)
|
| 127 |
return pids, team_id, rows_src, fields_base
|
| 128 |
|
api/routes_shares.py
CHANGED
|
@@ -18,11 +18,55 @@ is 404'd trying to share the thing they just made) and `_object_ref` (without it
|
|
| 18 |
18's silent half, reopened one kind over). `_can_see_object` stays deliberately CLOSED for
|
| 19 |
anything that is not a view.
|
| 20 |
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 26 |
|
| 27 |
β **THE GRANT NEVER WIDENS PAST THE MODULE WALL β ON A GOVERNED MODULE.** `*` ("everyone") means
|
| 28 |
every account that can already open the surface: `require_session` plus the topic's own gate run
|
|
@@ -275,6 +319,88 @@ def _entries_or_400(session, entries):
|
|
| 275 |
+ ". Nothing was shared. Pick people from the list rather than typing a name.")
|
| 276 |
|
| 277 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 278 |
@router.get("/share/mine")
|
| 279 |
def my_shares(session: Session = Depends(require_session)):
|
| 280 |
"""Everything shared WITH me, by kind β the "Shared with me" rail section (R10).
|
|
@@ -324,6 +450,13 @@ def get_share(kind: str, oid: str, session: Session = Depends(require_session)):
|
|
| 324 |
# β W32-T26 (audit S-3) β the roster is the EDITOR's data, so it rides only for a caller
|
| 325 |
# who may open the editor. A read-only grantee gets the grant list (their fair question is
|
| 326 |
# "who else has this?") and not a directory of every account in the workspace.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 327 |
"people": _people(session.tenant) if may_admin else [],
|
| 328 |
}
|
| 329 |
|
|
@@ -356,6 +489,10 @@ def put_share(kind: str, oid: str, body: dict = Body(default=None),
|
|
| 356 |
oid = shares.field_oid(_field_storage_keys(table_key)[2], field_key)
|
| 357 |
body = body or {}
|
| 358 |
rec = shares.grants(kind, oid, st=session.runtime)
|
|
|
|
|
|
|
|
|
|
|
|
|
| 359 |
# An object with NO grant record yet has no owner β the first person to share it claims it.
|
| 360 |
# That is safe because reaching this route at all means passing the surface's own wall, and
|
| 361 |
# the alternative (refusing until somebody seeds an owner) would make a brand-new folder
|
|
@@ -363,6 +500,10 @@ def put_share(kind: str, oid: str, body: dict = Body(default=None),
|
|
| 363 |
if rec["owner"]:
|
| 364 |
if not shares.may_administer(kind, oid, session.uname, is_admin=session.admin,
|
| 365 |
st=session.runtime):
|
|
|
|
|
|
|
|
|
|
|
|
|
| 366 |
raise err(403, "not_owner",
|
| 367 |
"only the owner of this item (or an administrator) can change who it is "
|
| 368 |
"shared with")
|
|
@@ -374,12 +515,102 @@ def put_share(kind: str, oid: str, body: dict = Body(default=None),
|
|
| 374 |
# stamp itself owner of an id it had never seen and lock the real creator out for good.
|
| 375 |
elif not _owns_object(session, kind, oid):
|
| 376 |
raise err(404, "no_object", "no such item, or it is not shared with this account")
|
|
|
|
|
|
|
| 377 |
entries = body.get("entries")
|
| 378 |
if not isinstance(entries, list):
|
| 379 |
raise err(400, "bad_entries",
|
| 380 |
"entries must be a list of {user, role}. Send [] to un-share, which is how "
|
| 381 |
"revoking is expressed")
|
| 382 |
_entries_or_400(session, entries)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 383 |
if kind == "field":
|
| 384 |
# A field grant is a visibility and edit wall. Promote a private custom
|
| 385 |
# field exactly once, then keep the requested Share field role as the
|
|
@@ -399,8 +630,34 @@ def put_share(kind: str, oid: str, body: dict = Body(default=None),
|
|
| 399 |
stamped["granted"] = True
|
| 400 |
shared_overlay.put_field(shared_key, field_key, stamped, st=session.runtime)
|
| 401 |
oid = shares.field_oid(grant_topic, field_key)
|
| 402 |
-
|
| 403 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 404 |
_notify_new_grantees(session, kind, oid, before=rec["entries"], after=out.get("entries") or [])
|
| 405 |
return out
|
| 406 |
|
|
|
|
| 18 |
18's silent half, reopened one kind over). `_can_see_object` stays deliberately CLOSED for
|
| 19 |
anything that is not a view.
|
| 20 |
|
| 21 |
+
ββ **A "Can edit" GRANTEE MAY RE-SHARE A VIEW β OWNER RULING R4, BUILT AS W40-T02** (instruction
|
| 22 |
+
4: *"Edit View so a member can share a View as well, not just an admin"*). This REVERSES the flat
|
| 23 |
+
owner-or-admin sentence that stood here, and the reversal is bounded three ways, all enforced HERE
|
| 24 |
+
and not in the client:
|
| 25 |
+
|
| 26 |
+
1. **ONLY `kind='view'`.** `shares.RESHARE_KINDS` is the one spelling of that. `folder`,
|
| 27 |
+
`database` and `field` still require the owner or an admin, and the paragraph below is why
|
| 28 |
+
the `database` kind in particular was never a candidate: a `ut_*` grant's blast radius is a
|
| 29 |
+
whole table, where a view is one saved SELECTION over rows the receiver's own wall governs.
|
| 30 |
+
2. **A RE-SHARE MAY NEVER EXCEED THE RE-SHARER'S OWN ROLE**, and the strict reading ships: an
|
| 31 |
+
`edit` grantee may hand out `view` and NEVER `edit`. `shares.max_grantable_role` answers the
|
| 32 |
+
ceiling, `put_share` enforces it on the DELTA (a name arriving at `edit`, or one raised to
|
| 33 |
+
it) β never on every row of the body, because the `PUT` REPLACES and `ShareDialog.save`
|
| 34 |
+
therefore re-sends the whole list with the re-sharer's own `edit` row inside it. Conferring
|
| 35 |
+
`edit` stays the owner's alone.
|
| 36 |
+
3. **OWNERSHIP NEVER MOVES.** A caller re-sharing rather than owning passes the EXISTING owner
|
| 37 |
+
straight through (`put_share` below, stated rather than incidental).
|
| 38 |
+
|
| 39 |
+
ββ **AND R4 BOUNDED ONLY THE ROLE. TWO MORE BOUNDS ARRIVED WITH THE OWNER'S RULING OF
|
| 40 |
+
2026-08-24, BECAUSE THE GAPS WERE MEASURED ON THE SHIPPED BUILD:**
|
| 41 |
+
|
| 42 |
+
4. **A RE-SHARER MAY SHARE ONLY WITH SPECIFIC PEOPLE (D-473).** Owner: *"a re-sharer can only
|
| 43 |
+
share to specific people"*. Before this, `[fisch:edit, *:view]` from an `edit` grantee was a
|
| 44 |
+
`200` β the role ceiling could not see it, because `*` at `view` never exceeds a `view`
|
| 45 |
+
ceiling. `_audience_added` refuses an `EVERYONE` entry this caller is ADDING, and lets one
|
| 46 |
+
the OWNER already placed ride along untouched, for the same delta reason as (2).
|
| 47 |
+
5. **A RE-SHARER MAY UN-SHARE ONLY THE PEOPLE THEY SHARED TO (D-474).** Owner: *"a re-sharer
|
| 48 |
+
can only unshare the people it shared to"*. Before this, an `edit` grantee PUTting a list
|
| 49 |
+
that omitted another grantee got `200` and that person's access was gone; `PUT []` left the
|
| 50 |
+
view shared with nobody. Answering this needs a fact the registry did not store, so each
|
| 51 |
+
entry now carries `by` β who placed it β stamped by `shares.set_grants(granter=β¦)` and
|
| 52 |
+
consulted by `_unremovable`. β An entry with NO `by` (every grant predating the change) is
|
| 53 |
+
the owner's or an admin's to revoke and nobody else's: fail-closed, because from the door
|
| 54 |
+
"unstamped" and "somebody else's" are the same observation.
|
| 55 |
+
|
| 56 |
+
β **SO BOTH FEARS THE OLD SENTENCE NAMED ARE NOW ANSWERED, AND THE PARAGRAPH THAT PRICED THE
|
| 57 |
+
SECOND ONE IS GONE RATHER THAN SOFTENED.** It read *"'Widen a users-scoped view to everyone' is
|
| 58 |
+
NOT closed β an `edit` grantee may add `*` β it is CAPPED at Can view"*, and that was an accurate
|
| 59 |
+
account of R4 that the owner overruled the moment it was put in front of them. *"Grant themselves
|
| 60 |
+
ownership and lock you out"* stays closed by (3) and `set_grants`' sticky owner. A `view` grantee
|
| 61 |
+
still cannot share at all, and still gets `403`. The client greys the editor for
|
| 62 |
+
non-administrators and offers "Can edit" to anyone it greys in; that is a courtesy, and these
|
| 63 |
+
checks are the wall.
|
| 64 |
+
|
| 65 |
+
β **WHAT `GET` NOW DISCLOSES.** The grant record carries `by`, and this route returns the record
|
| 66 |
+
verbatim β so anybody who may read a view's grant list also learns who added each person, a
|
| 67 |
+
`view` grantee included. Accepted deliberately (the alternative is a second, stripped read path
|
| 68 |
+
and therefore a second answer to one question), and stated here because this file states costs
|
| 69 |
+
rather than leaving them to be discovered.
|
| 70 |
|
| 71 |
β **THE GRANT NEVER WIDENS PAST THE MODULE WALL β ON A GOVERNED MODULE.** `*` ("everyone") means
|
| 72 |
every account that can already open the surface: `require_session` plus the topic's own gate run
|
|
|
|
| 319 |
+ ". Nothing was shared. Pick people from the list rather than typing a name.")
|
| 320 |
|
| 321 |
|
| 322 |
+
def _named(who):
|
| 323 |
+
"""The people in a refusal, in the words the person reading it uses.
|
| 324 |
+
|
| 325 |
+
ONE spelling, used by all three re-share refusals below. `*` is never printed raw: the store's
|
| 326 |
+
wildcard is a single character, and a 403 reading *"set * to Can view"* names nothing a person
|
| 327 |
+
can find in the dialog they are looking at.
|
| 328 |
+
"""
|
| 329 |
+
return ", ".join("everyone in this workspace" if w == shares.EVERYONE else w
|
| 330 |
+
for w in sorted(who))
|
| 331 |
+
|
| 332 |
+
|
| 333 |
+
def _audience_added(entries, held):
|
| 334 |
+
"""ββ D-473 β the `EVERYONE` grant this caller is ADDING, or the empty set.
|
| 335 |
+
|
| 336 |
+
OWNER RULING 2026-08-24, verbatim: *"a re-sharer can only share to specific people"*. R4's
|
| 337 |
+
ceiling bounded the ROLE a re-sharer may hand out and said nothing about the AUDIENCE, and the
|
| 338 |
+
gap was measured rather than argued: an `edit` grantee PUTting `[fisch:edit, *:view]` was
|
| 339 |
+
answered `200`, widening a two-person view to the whole tenant at `Can view`. The role check
|
| 340 |
+
could not catch it, because `*` at `view` never exceeds a `view` ceiling.
|
| 341 |
+
|
| 342 |
+
β IT IS THE ADDITION THAT IS REFUSED, NOT THE PRESENCE, and that is the same shape as the
|
| 343 |
+
role check one arm above, for the same reason: the `PUT` REPLACES, so `ShareDialog.save`
|
| 344 |
+
re-sends the WHOLE list every time. An `*` the OWNER placed rides along in every payload the
|
| 345 |
+
re-sharer is able to produce, and refusing on presence would `403` every save on a view the
|
| 346 |
+
owner had already opened to everyone β a re-sharer locked out of a list they may legitimately
|
| 347 |
+
edit, with a message about a row they did not touch.
|
| 348 |
+
|
| 349 |
+
β ROLE IS NOT CONSULTED HERE, DELIBERATELY. This answers "may this caller widen the
|
| 350 |
+
AUDIENCE", and `*` held at `view` and resubmitted at `edit` is a ROLE escalation that the
|
| 351 |
+
check above already refuses, by name. Two questions, two predicates
|
| 352 |
+
([[one-evaluator-per-question]]) β and separable is also what lets a gate disarm one of them
|
| 353 |
+
in memory and prove the other still fires.
|
| 354 |
+
|
| 355 |
+
β `_clean_entries`, NEVER THE RAW BODY: an entry with a junk role is dropped by the writer,
|
| 356 |
+
so reading the raw list would refuse a widening that was never going to be stored.
|
| 357 |
+
"""
|
| 358 |
+
if shares.EVERYONE in (held or {}):
|
| 359 |
+
return set()
|
| 360 |
+
return {e["user"] for e in shares._clean_entries(entries) if e["user"] == shares.EVERYONE}
|
| 361 |
+
|
| 362 |
+
|
| 363 |
+
def _unremovable(held_rows, entries, uname):
|
| 364 |
+
"""ββ D-474 β the people this caller is dropping from the list but may NOT revoke.
|
| 365 |
+
|
| 366 |
+
OWNER RULING 2026-08-24, verbatim: *"a re-sharer can only unshare the people it shared to"*.
|
| 367 |
+
R4 bounded what a re-sharer may HAND OUT and left what they may TAKE AWAY unbounded, and both
|
| 368 |
+
halves of that were measured: an `edit` grantee PUTting a list that omits another grantee was
|
| 369 |
+
answered `200` and that person's access was gone; `PUT []` left the view shared with nobody.
|
| 370 |
+
|
| 371 |
+
ββ AN ENTRY WITH NO `by` IS NOT REMOVABLE BY A RE-SHARER β ONLY BY THE OWNER OR AN ADMIN,
|
| 372 |
+
AND THAT IS THE FAIL-CLOSED DIRECTION RATHER THAN AN OVERSIGHT. Every grant written before
|
| 373 |
+
provenance existed carries no stamp, so "no `by`" and "granted by somebody else" are
|
| 374 |
+
indistinguishable from here. Reading absence as *"nobody claims it, so anyone may take it"*
|
| 375 |
+
would hand every re-sharer the power to revoke the entire pre-existing grant set on day one
|
| 376 |
+
of this change, which is the exact capability the ruling withholds. A re-sharer must not be
|
| 377 |
+
able to revoke a grant they cannot PROVE they made [[aios-permissioning]].
|
| 378 |
+
|
| 379 |
+
β SO A RE-SHARER CANNOT REMOVE THEMSELVES EITHER, AND THAT IS STATED BECAUSE IT LOOKS LIKE A
|
| 380 |
+
BUG. Their own row was placed by the owner, so it carries the owner's `by` and lands in this
|
| 381 |
+
set. Read literally, the ruling says a re-sharer unshares only who THEY shared to, and their
|
| 382 |
+
own grant is not one of those. Leaving the view is the owner's to do, like every other
|
| 383 |
+
revocation of an owner-placed grant. β Do not carve an exception here without a ruling: the
|
| 384 |
+
carve-out is indistinguishable from "a re-sharer may revoke any row whose `by` names the
|
| 385 |
+
owner", which is the wall itself.
|
| 386 |
+
|
| 387 |
+
β `_clean_entries`, NEVER THE RAW BODY, AND THIS IS THE HOLE THAT SHAPE CLOSES. A role the
|
| 388 |
+
writer rejects is a row that will NOT be stored, so `{user: victim, role: "nonsense"}` looks
|
| 389 |
+
present in the raw payload and is a silent REVOCATION once written. Asking the same
|
| 390 |
+
normaliser the store uses is what makes "submitted" mean the same thing at both ends.
|
| 391 |
+
"""
|
| 392 |
+
me = str(uname or "").strip().lower()
|
| 393 |
+
submitted = {e["user"] for e in shares._clean_entries(entries)}
|
| 394 |
+
stuck = set()
|
| 395 |
+
for user, row in (held_rows or {}).items():
|
| 396 |
+
if user in submitted:
|
| 397 |
+
continue
|
| 398 |
+
stamp = str((row or {}).get("by") or "").strip().lower()
|
| 399 |
+
if not me or not stamp or stamp != me:
|
| 400 |
+
stuck.add(user)
|
| 401 |
+
return stuck
|
| 402 |
+
|
| 403 |
+
|
| 404 |
@router.get("/share/mine")
|
| 405 |
def my_shares(session: Session = Depends(require_session)):
|
| 406 |
"""Everything shared WITH me, by kind β the "Shared with me" rail section (R10).
|
|
|
|
| 450 |
# β W32-T26 (audit S-3) β the roster is the EDITOR's data, so it rides only for a caller
|
| 451 |
# who may open the editor. A read-only grantee gets the grant list (their fair question is
|
| 452 |
# "who else has this?") and not a directory of every account in the workspace.
|
| 453 |
+
# ββ W40-T02 / R4 β AND THAT RULE IS WHY THIS LINE NEEDED NO EDIT. `may_administer` now
|
| 454 |
+
# answers True for an `edit` grantee on a VIEW, which MOVES that account into "may open
|
| 455 |
+
# the editor" β so the picker they need arrives by the roster riding on the same flag it
|
| 456 |
+
# always did. Gating it on anything else (owner, `role == 'owner'`, a fresh predicate)
|
| 457 |
+
# would be a second answer to a question this file already answers once, and would leave
|
| 458 |
+
# the new grantee with an editor and no people to put in it. A `view` grantee is still
|
| 459 |
+
# `may_admin=False` here and still gets `[]`.
|
| 460 |
"people": _people(session.tenant) if may_admin else [],
|
| 461 |
}
|
| 462 |
|
|
|
|
| 489 |
oid = shares.field_oid(_field_storage_keys(table_key)[2], field_key)
|
| 490 |
body = body or {}
|
| 491 |
rec = shares.grants(kind, oid, st=session.runtime)
|
| 492 |
+
# `claiming` is the "no owner yet, and this caller may become one" branch, hoisted to a name
|
| 493 |
+
# because TWO decisions below need it: the ceiling (a claimant is about to be the owner, so
|
| 494 |
+
# their ceiling is an owner's) and the owner written back (D3 β see `set_grants` at the end).
|
| 495 |
+
claiming = False
|
| 496 |
# An object with NO grant record yet has no owner β the first person to share it claims it.
|
| 497 |
# That is safe because reaching this route at all means passing the surface's own wall, and
|
| 498 |
# the alternative (refusing until somebody seeds an owner) would make a brand-new folder
|
|
|
|
| 500 |
if rec["owner"]:
|
| 501 |
if not shares.may_administer(kind, oid, session.uname, is_admin=session.admin,
|
| 502 |
st=session.runtime):
|
| 503 |
+
# β R4 / W40-T02 β `may_administer` now also admits an `edit` grantee on a VIEW, so
|
| 504 |
+
# the population refused here is narrower than the code word `not_owner` suggests: a
|
| 505 |
+
# `view` grantee, or an account with an `edit` role on a kind outside
|
| 506 |
+
# `shares.RESHARE_KINDS`. The code string is kept because clients match on it.
|
| 507 |
raise err(403, "not_owner",
|
| 508 |
"only the owner of this item (or an administrator) can change who it is "
|
| 509 |
"shared with")
|
|
|
|
| 515 |
# stamp itself owner of an id it had never seen and lock the real creator out for good.
|
| 516 |
elif not _owns_object(session, kind, oid):
|
| 517 |
raise err(404, "no_object", "no such item, or it is not shared with this account")
|
| 518 |
+
else:
|
| 519 |
+
claiming = True
|
| 520 |
entries = body.get("entries")
|
| 521 |
if not isinstance(entries, list):
|
| 522 |
raise err(400, "bad_entries",
|
| 523 |
"entries must be a list of {user, role}. Send [] to un-share, which is how "
|
| 524 |
"revoking is expressed")
|
| 525 |
_entries_or_400(session, entries)
|
| 526 |
+
# ββ R4 / W40-T02 β THE CEILING. `may_administer` above now opens this door to an `edit`
|
| 527 |
+
# grantee on a VIEW, so R4's other half ("a re-share may never exceed the role the re-sharer
|
| 528 |
+
# holds") needs a check of its own: that caller may hand out `view`, and conferring `edit`
|
| 529 |
+
# stays the owner's or an administrator's.
|
| 530 |
+
#
|
| 531 |
+
# β AFTER THE ADMISSION, NEVER BEFORE, AND THAT ORDER IS A SECURITY PROPERTY. A caller with
|
| 532 |
+
# no role at all must keep receiving `404 no_object` (audit S-1/S-3: a stranger learns
|
| 533 |
+
# nothing, so this route cannot be used to probe which ids are real). A ceiling raised first
|
| 534 |
+
# would answer that caller `403` and turn the one route hardened against id-probing back into
|
| 535 |
+
# an oracle that confirms an id exists. It also runs before the `field` promotion below, so a
|
| 536 |
+
# refusal cannot leave a column promoted with no grant written.
|
| 537 |
+
#
|
| 538 |
+
# β AND IT IS THE DELTA, NOT EVERY ROW OF THE BODY β read off the shipped client, not
|
| 539 |
+
# assumed. `ShareDialog.save` PUTs the WHOLE list every time ("a body assembled from a delta
|
| 540 |
+
# would revoke everyone it failed to mention"), so the re-sharer's OWN `{user, role: "edit"}`
|
| 541 |
+
# row rides in every payload they are able to produce. Refusing per-entry would `403` the
|
| 542 |
+
# exact re-share this ticket exists to enable, and the only body that would pass is one that
|
| 543 |
+
# revokes the re-sharer. So what is refused is edit access this caller is CREATING: a name
|
| 544 |
+
# arriving at `edit`, or an existing `view` grantee raised to it. A row that already stood at
|
| 545 |
+
# `edit` was the OWNER's decision, and is not this caller's to be refused for.
|
| 546 |
+
#
|
| 547 |
+
# β A CLAIMANT IS AN OWNER. The branch above admits a Member who owns an object that has no
|
| 548 |
+
# grant record yet, and `set_grants` is about to stamp them owner β asking the registry for
|
| 549 |
+
# their role here would answer `None` (no record exists to hold one) and refuse the first
|
| 550 |
+
# `edit` grant on every newly created view. Same predicate as the door, one line apart.
|
| 551 |
+
ceiling = "edit" if claiming else shares.max_grantable_role(
|
| 552 |
+
kind, oid, session.uname, is_admin=session.admin, st=session.runtime)
|
| 553 |
+
#
|
| 554 |
+
# ββ OWNER RULING 2026-08-24 (D-473 + D-474) β AND THE CEILING IS NOW ONE OF THREE WALLS IN
|
| 555 |
+
# THIS BLOCK, NOT THE WALL. R4 bounded the ROLE a re-sharer may hand out and was silent on the
|
| 556 |
+
# other two questions a re-share asks, so both gaps shipped and both were measured on the
|
| 557 |
+
# build: an `edit` grantee could PUT `[fisch:edit, *:view]` and widen a two-person view to the
|
| 558 |
+
# whole tenant (200), and could PUT a list omitting another grantee β or `[]` β and revoke
|
| 559 |
+
# people they never granted (200). The owner's answer settles both in one sentence: *"no a
|
| 560 |
+
# re-sharer can only share to specific people and a re-sharer can only unshare the people it
|
| 561 |
+
# shared to"*.
|
| 562 |
+
#
|
| 563 |
+
# β THREE PREDICATES, THREE FUNCTIONS, ONE ORDER: role, then audience, then revocation. They
|
| 564 |
+
# are separate because they answer separate questions and because a wall that cannot be
|
| 565 |
+
# disarmed ALONE cannot be proven alone β `verify_scopes.section_reshare_bounds` patches each
|
| 566 |
+
# one in memory and requires exactly its own leg to go red, which a single fused `if` would
|
| 567 |
+
# make impossible ([[a-declared-gate-is-an-unchecked-claim]]).
|
| 568 |
+
# β ROLE AND AUDIENCE COMPOSE, AND THE ORDER DECIDES WHICH REFUSAL A PERSON READS. `*`
|
| 569 |
+
# submitted at `edit` while held at `view` is BOTH an escalation and (if unheld) a widening;
|
| 570 |
+
# the role check runs first and names the fix that is actually available to this caller
|
| 571 |
+
# ("set it to Can view"), which is the more useful of the two sentences.
|
| 572 |
+
if ceiling != "edit":
|
| 573 |
+
# The prior ROWS, not just their roles: the revocation wall needs each entry's `by`, and
|
| 574 |
+
# reading it from a second place would be a second answer to "what does the store hold".
|
| 575 |
+
held_rows = {e.get("user"): e for e in (rec["entries"] or ())
|
| 576 |
+
if isinstance(e, dict) and e.get("user")}
|
| 577 |
+
held = {u: e.get("role") for u, e in held_rows.items()}
|
| 578 |
+
noun = {"view": "view", "folder": "folder",
|
| 579 |
+
"database": "database", "field": "column"}.get(kind, "item")
|
| 580 |
+
raised = set()
|
| 581 |
+
for e in entries:
|
| 582 |
+
if not isinstance(e, dict):
|
| 583 |
+
continue
|
| 584 |
+
who = str(e.get("user") or "").strip().lower()
|
| 585 |
+
if who and str(e.get("role") or "").strip().lower() == "edit" \
|
| 586 |
+
and held.get(who) != "edit":
|
| 587 |
+
raised.add(who)
|
| 588 |
+
if raised:
|
| 589 |
+
raise err(403, "grant_exceeds_role",
|
| 590 |
+
"you can share this " + noun + " at Can view, which is as far as your own "
|
| 591 |
+
"access reaches. Only its owner (or an administrator) can give somebody "
|
| 592 |
+
"Can edit, so nothing was saved. Set " + _named(raised)
|
| 593 |
+
+ " to Can view and save again.")
|
| 594 |
+
# ββ D-473 β THE AUDIENCE. A re-sharer names PEOPLE; reaching "everyone" is the owner's.
|
| 595 |
+
if _audience_added(entries, held):
|
| 596 |
+
raise err(403, "grant_exceeds_audience",
|
| 597 |
+
"you can share this " + noun + " with specific people, which is as far as "
|
| 598 |
+
"your own access reaches. Only its owner (or an administrator) can open it "
|
| 599 |
+
"to everyone in this workspace, so nothing was saved. Remove Everyone from "
|
| 600 |
+
"the list, add the people you meant by name, and save again.")
|
| 601 |
+
# ββ D-474 β THE REVOCATION. An omission IS a revocation on a replacing PUT, so this is
|
| 602 |
+
# the only place a removal can be refused. β REFUSED WHOLE: `set_grants` has not run, so
|
| 603 |
+
# a payload carrying a legitimate addition ALONGSIDE a forbidden removal saves neither.
|
| 604 |
+
# That is deliberate and it is what the message promises ("nothing was saved") β a
|
| 605 |
+
# half-applied permission change is worse than a refused one, because the person reading
|
| 606 |
+
# the toast has no way to tell which half took.
|
| 607 |
+
stuck = _unremovable(held_rows, entries, session.uname)
|
| 608 |
+
if stuck:
|
| 609 |
+
raise err(403, "revoke_not_yours",
|
| 610 |
+
"you can remove the people you shared this " + noun + " with, and this "
|
| 611 |
+
"workspace has no record of you sharing it with " + _named(stuck)
|
| 612 |
+
+ ". Only its owner (or an administrator) can remove them, so nothing was "
|
| 613 |
+
"saved. Put them back on the list and save again.")
|
| 614 |
if kind == "field":
|
| 615 |
# A field grant is a visibility and edit wall. Promote a private custom
|
| 616 |
# field exactly once, then keep the requested Share field role as the
|
|
|
|
| 630 |
stamped["granted"] = True
|
| 631 |
shared_overlay.put_field(shared_key, field_key, stamped, st=session.runtime)
|
| 632 |
oid = shares.field_oid(grant_topic, field_key)
|
| 633 |
+
# ββ R4 / W40-T02 (D3) β OWNERSHIP NEVER MOVES ON A RE-SHARE, AND IT IS SAID HERE RATHER
|
| 634 |
+
# THAN LEFT TO FALL OUT. `set_grants`' owner is sticky, so the old `rec["owner"] or
|
| 635 |
+
# session.uname` already happened not to transfer ownership β incidentally, as a property of
|
| 636 |
+
# the callee. R4 names ownership transfer as one of the two halves of the old protection that
|
| 637 |
+
# SURVIVES the widening, and a rule that survives by accident is one the next edit deletes
|
| 638 |
+
# without noticing. So the branch is explicit: a claimant becomes the owner, and everybody
|
| 639 |
+
# else β an owner re-saving, an admin, and now an `edit` grantee re-sharing β passes the
|
| 640 |
+
# EXISTING owner straight back through. `claiming` is the same flag the admission set, so
|
| 641 |
+
# there is no second answer to "is this person taking ownership".
|
| 642 |
+
# ββ D-474 β `granter` IS THIS SESSION, ON EVERY SAVE INCLUDING THE OWNER'S. Provenance is
|
| 643 |
+
# recorded for whoever adds a person, not only for a re-sharer: an owner-placed grant carrying
|
| 644 |
+
# NO stamp is indistinguishable from a pre-provenance one, and `_unremovable` would then be
|
| 645 |
+
# deciding on the store's AGE rather than on who granted what. `set_grants` stamps only
|
| 646 |
+
# entries that are NEW to the record and never re-stamps an existing one, so an owner
|
| 647 |
+
# re-saving a list does not quietly take provenance off the re-sharer who built it.
|
| 648 |
+
# ββ THE THREE REFUSALS ABOVE WERE DECIDED AGAINST `rec`, WHICH WAS READ AT THE TOP OF
|
| 649 |
+
# THIS FUNCTION. Handing `expect` to the writer is what makes them true at the moment of the
|
| 650 |
+
# write rather than at the moment of the read: a concurrent save lands between the two, and
|
| 651 |
+
# a wave-40 adversarial probe drove a re-sharer's PUT being ACCEPTED while the grant the
|
| 652 |
+
# owner had just added disappeared. See `shares.set_grants`' own note.
|
| 653 |
+
try:
|
| 654 |
+
out = shares.set_grants(kind, oid, entries,
|
| 655 |
+
owner=session.uname if claiming else rec["owner"],
|
| 656 |
+
granter=session.uname,
|
| 657 |
+
st=session.runtime,
|
| 658 |
+
expect=rec["entries"])
|
| 659 |
+
except shares.GrantsChanged as exc:
|
| 660 |
+
raise err(409, "grants_changed", str(exc))
|
| 661 |
_notify_new_grantees(session, kind, oid, before=rec["entries"], after=out.get("entries") or [])
|
| 662 |
return out
|
| 663 |
|
api/routes_slack.py
CHANGED
|
@@ -182,13 +182,30 @@ def agent_visible_fields(agent, fields, module):
|
|
| 182 |
return perm_scope.visible_fields(fields, agent_principal(agent), module)
|
| 183 |
|
| 184 |
|
| 185 |
-
def agent_rows(agent, rows, module, fields, ctx=None):
|
| 186 |
"""The rows this channel may receive β `permits()`, so an unanswerable permanent filter DENIES
|
| 187 |
-
rather than being ignored.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 188 |
import core.perm_scope as perm_scope
|
| 189 |
p = agent_principal(agent)
|
| 190 |
hide = perm_scope.hidden_keys(p, module, fields)
|
| 191 |
-
kept = perm_scope.apply_row_scope(rows, p, module, fields, ctx)
|
| 192 |
# Both wires, never one: the field list and the row payload are separate, and stripping only
|
| 193 |
# the first leaves the value sitting in the second where anyone can read it.
|
| 194 |
return [perm_scope.strip_row(r, hide) for r in kept]
|
|
|
|
| 182 |
return perm_scope.visible_fields(fields, agent_principal(agent), module)
|
| 183 |
|
| 184 |
|
| 185 |
+
def agent_rows(agent, rows, module, fields, ctx=None, st=None):
|
| 186 |
"""The rows this channel may receive β `permits()`, so an unanswerable permanent filter DENIES
|
| 187 |
+
rather than being ignored.
|
| 188 |
+
|
| 189 |
+
ββ `st` IS THE TENANT HANDLE AND IT IS HERE BECAUSE OF THE SENTENCE IN `agent_principal`:
|
| 190 |
+
a channel agent IS a principal of the same wall, so a permanent filter naming a
|
| 191 |
+
user-generated column has to mean the SAME thing here as it does on the grid (owner I16).
|
| 192 |
+
A door that lends the handle and a door that does not are one stored rule with two meanings.
|
| 193 |
+
|
| 194 |
+
β PASS THE TENANT'S OWN RUNTIME β every other store read in this file takes
|
| 195 |
+
`session.runtime`, and a channel is not a second tenancy. It is a keyword with a `None`
|
| 196 |
+
default for the same reason `perm_scope.apply_row_scope`'s is: without one this is
|
| 197 |
+
byte-identical to the wall that shipped before the argument existed.
|
| 198 |
+
|
| 199 |
+
β `hidden_keys` DELIBERATELY DOES NOT TAKE IT IN THIS CHANGE. Its field-grant leg
|
| 200 |
+
under-hides without a handle (see `perm_scope.visible_overlays`), which is a real and
|
| 201 |
+
separate gap on this surface β but it is the FIELD wall, it moves what a channel receives
|
| 202 |
+
rather than what I16 asked for, and widening two walls in one ticket is how a permission
|
| 203 |
+
change stops being reviewable.
|
| 204 |
+
"""
|
| 205 |
import core.perm_scope as perm_scope
|
| 206 |
p = agent_principal(agent)
|
| 207 |
hide = perm_scope.hidden_keys(p, module, fields)
|
| 208 |
+
kept = perm_scope.apply_row_scope(rows, p, module, fields, ctx, st=st)
|
| 209 |
# Both wires, never one: the field list and the row payload are separate, and stripping only
|
| 210 |
# the first leaves the value sitting in the second where anyone can read it.
|
| 211 |
return [perm_scope.strip_row(r, hide) for r in kept]
|
platform/aios_grid_fields.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
| 1 |
{
|
| 2 |
-
"_comment": "CANONICAL field contract for the AIOS Airtable-style grid β the SINGLE source of truth. Consumed by platform/aios_grid.py (embed/Space host) and aios-web/api/main.py (standalone API), and regenerated into aios-web/web/public/sample_customers.json. Edit HERE only, then run aios-web/verify_fields_contract.py. source=odoo is READ-ONLY; source=overlay is the editable stratum (notes/tags) outside Odoo. type in {text,status,select,currency,int,date,pct} (select = a fixed-choice READ-ONLY brand attribute; dba is the first, wave 2026-08-02). `description` (wave 5) is the CANONICAL per-field description β every field must carry one, and since wave 7 (owner W8, 2026-07-28) every description is ONE SHORT PLAIN sentence (two only when a fact would otherwise mislead): what the field IS, nothing else β no filter tips, no '(none)' coaching, no rationale; the user's workspace NOTE overrides it in the (i) hover, never in this file. BUILDER FACT (documented here, deliberately NOT in user-facing text): blank
|
| 3 |
"fields": [
|
| 4 |
{
|
| 5 |
"key": "customer",
|
|
@@ -34,7 +34,7 @@
|
|
| 34 |
{
|
| 35 |
"key": "agent",
|
| 36 |
"label": "Agent",
|
| 37 |
-
"type": "
|
| 38 |
"source": "odoo",
|
| 39 |
"default": true,
|
| 40 |
"description": "The sales agent who owns this account."
|
|
@@ -55,7 +55,7 @@
|
|
| 55 |
{
|
| 56 |
"key": "salesperson",
|
| 57 |
"label": "Salesperson",
|
| 58 |
-
"type": "
|
| 59 |
"source": "odoo",
|
| 60 |
"default": false,
|
| 61 |
"description": "Who keyed in most of this customer's orders β not the Agent, who owns the account."
|
|
@@ -79,7 +79,7 @@
|
|
| 79 |
{
|
| 80 |
"key": "city",
|
| 81 |
"label": "City",
|
| 82 |
-
"type": "
|
| 83 |
"source": "odoo",
|
| 84 |
"default": true,
|
| 85 |
"description": "City on the customer's Odoo address."
|
|
@@ -87,7 +87,7 @@
|
|
| 87 |
{
|
| 88 |
"key": "state",
|
| 89 |
"label": "State",
|
| 90 |
-
"type": "
|
| 91 |
"source": "odoo",
|
| 92 |
"default": true,
|
| 93 |
"description": "State or province on the customer's Odoo address."
|
|
@@ -95,7 +95,7 @@
|
|
| 95 |
{
|
| 96 |
"key": "country",
|
| 97 |
"label": "Country",
|
| 98 |
-
"type": "
|
| 99 |
"source": "odoo",
|
| 100 |
"default": false,
|
| 101 |
"description": "Country on the customer's Odoo address."
|
|
@@ -108,6 +108,14 @@
|
|
| 108 |
"default": false,
|
| 109 |
"description": "Postal code on the customer's Odoo address."
|
| 110 |
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 111 |
{
|
| 112 |
"key": "customer_since",
|
| 113 |
"label": "Customer since",
|
|
@@ -119,15 +127,15 @@
|
|
| 119 |
{
|
| 120 |
"key": "tags",
|
| 121 |
"label": "Tags",
|
| 122 |
-
"type": "
|
| 123 |
"source": "odoo",
|
| 124 |
"default": false,
|
| 125 |
"description": "Odoo labels on this customer, comma-separated."
|
| 126 |
},
|
| 127 |
{
|
| 128 |
"key": "pricelist",
|
| 129 |
-
"label": "
|
| 130 |
-
"type": "
|
| 131 |
"source": "odoo",
|
| 132 |
"default": false,
|
| 133 |
"description": "The price list this customer buys on."
|
|
@@ -135,7 +143,7 @@
|
|
| 135 |
{
|
| 136 |
"key": "payment_terms",
|
| 137 |
"label": "Payment terms",
|
| 138 |
-
"type": "
|
| 139 |
"source": "odoo",
|
| 140 |
"default": false,
|
| 141 |
"description": "Payment terms on this customer's account β Net 30, for example."
|
|
@@ -244,7 +252,7 @@
|
|
| 244 |
{
|
| 245 |
"key": "top_category",
|
| 246 |
"label": "Top category",
|
| 247 |
-
"type": "
|
| 248 |
"source": "odoo",
|
| 249 |
"default": false,
|
| 250 |
"description": "The category this customer spent the most on in the last 12 months."
|
|
@@ -289,6 +297,14 @@
|
|
| 289 |
"default": false,
|
| 290 |
"description": "Days this customer usually goes between orders, from their own history."
|
| 291 |
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 292 |
{
|
| 293 |
"key": "notes",
|
| 294 |
"label": "Notes",
|
|
@@ -332,7 +348,7 @@
|
|
| 332 |
{
|
| 333 |
"key": "supplier",
|
| 334 |
"label": "Supplier",
|
| 335 |
-
"type": "
|
| 336 |
"source": "overlay",
|
| 337 |
"default": true,
|
| 338 |
"description": "Who makes it. Editable here and shared with everyone in the workspace; seeded from the inventory mastersheet.",
|
|
@@ -391,6 +407,7 @@
|
|
| 391 |
"label": "Price 1",
|
| 392 |
"type": "currency",
|
| 393 |
"source": "odoo",
|
|
|
|
| 394 |
"description": "Cheapest live price for this SKU, across active pricelists."
|
| 395 |
},
|
| 396 |
{
|
|
@@ -398,6 +415,7 @@
|
|
| 398 |
"label": "Unit 1",
|
| 399 |
"type": "text",
|
| 400 |
"source": "odoo",
|
|
|
|
| 401 |
"description": "Package label for Price 1. Blank means Odoo has no package reference for that price."
|
| 402 |
},
|
| 403 |
{
|
|
@@ -405,6 +423,7 @@
|
|
| 405 |
"label": "Price 2",
|
| 406 |
"type": "currency",
|
| 407 |
"source": "odoo",
|
|
|
|
| 408 |
"description": "Second-cheapest live price for this SKU."
|
| 409 |
},
|
| 410 |
{
|
|
@@ -412,6 +431,7 @@
|
|
| 412 |
"label": "Unit 2",
|
| 413 |
"type": "text",
|
| 414 |
"source": "odoo",
|
|
|
|
| 415 |
"description": "Package label for Price 2."
|
| 416 |
},
|
| 417 |
{
|
|
@@ -419,6 +439,7 @@
|
|
| 419 |
"label": "Price 3",
|
| 420 |
"type": "currency",
|
| 421 |
"source": "odoo",
|
|
|
|
| 422 |
"description": "Third-cheapest live price for this SKU."
|
| 423 |
},
|
| 424 |
{
|
|
@@ -426,8 +447,153 @@
|
|
| 426 |
"label": "Unit 3",
|
| 427 |
"type": "text",
|
| 428 |
"source": "odoo",
|
|
|
|
| 429 |
"description": "Package label for Price 3."
|
| 430 |
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 431 |
{
|
| 432 |
"key": "pre_book_qty",
|
| 433 |
"label": "Pre-book qty",
|
|
@@ -518,7 +684,7 @@
|
|
| 518 |
"label": "Days of supply",
|
| 519 |
"type": "int",
|
| 520 |
"source": "odoo",
|
| 521 |
-
"description": "Days of supply at the trailing twelve month rate, counting ON HAND PLUS INBOUND units as stock
|
| 522 |
},
|
| 523 |
{
|
| 524 |
"key": "cover_gap_d",
|
|
@@ -548,7 +714,7 @@
|
|
| 548 |
"label": "Stock status",
|
| 549 |
"type": "select",
|
| 550 |
"source": "odoo",
|
| 551 |
-
"description": "Dead / excess / healthy bucket, from the same days of supply figure beside it, so it counts inbound units too.
|
| 552 |
},
|
| 553 |
{
|
| 554 |
"key": "discontinued",
|
|
@@ -561,6 +727,14 @@
|
|
| 561 |
],
|
| 562 |
"description": "Whether Odoo carries the Discontinued product tag on this SKU. Every row gets an explicit Yes or No rather than a blank, because a blank reads as an inactive condition in the filter engine and would silently WIDEN any view that filtered on it."
|
| 563 |
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 564 |
{
|
| 565 |
"key": "needs_pricing",
|
| 566 |
"label": "Needs pricing",
|
|
|
|
| 1 |
{
|
| 2 |
+
"_comment": "CANONICAL field contract for the AIOS Airtable-style grid β the SINGLE source of truth. Consumed by platform/aios_grid.py (embed/Space host) and aios-web/api/main.py (standalone API), and regenerated into aios-web/web/public/sample_customers.json. Edit HERE only, then run aios-web/verify_fields_contract.py. source=odoo is READ-ONLY; source=overlay is the editable stratum (notes/tags) outside Odoo. type in {text,status,select,multiselect,currency,int,date,pct,url} (select = a fixed-choice READ-ONLY brand attribute; dba is the first, wave 2026-08-02. multiselect = one cell holding a comma-joined SET, so a choice list offers the MEMBERS, not the joined string; customer tags and product supplier are the first, wave 40 W40-T06. url = a link cell, GridCellKind.Uri, drawn by cells.ts and opened by CustomerGrid's scheme-guarded click path; maps_url is the first, wave 40 W40-T08). W40-T08 also adds created_on, the uniform records-created DATE column every database carries (owner I24). It is a plain date field and NOT the created_time TYPE on purpose: created_time renders the row-level _created datum and its value never lives at the field's own key, so it is invisible to the semantic topic, to a stored-cell read and to any host-side export, while a date field is an ordinary cell that all three can see. The _created datum still rides every row for a created_time column a user creates. `description` (wave 5) is the CANONICAL per-field description β every field must carry one, and since wave 7 (owner W8, 2026-07-28) every description is ONE SHORT PLAIN sentence (two only when a fact would otherwise mislead): what the field IS, nothing else β no filter tips, no '(none)' coaching, no rationale; the user's workspace NOTE overrides it in the (i) hover, never in this file. BUILDER FACT (documented here, deliberately NOT in user-facing text): blank connector attributes display as '(none)' (they are no longer all `text`: W40-T06 retyped eight of them to `select` and `tags` to `multiselect`, and the sentinel is a real member of every one of those vocabularies), so `is '(none)'` β not `is empty` β finds the blanks on agent/city/state/country/zip/payment_terms/pricelist/tags. filterable:false = the CONDITION BUILDER does not offer it (still displayed, still sortable); every such field must have a replacement declared in aios-web/verify_fields_contract.py. 2026-07-27 partner attributes: country/zip/payment_terms/pricelist/tags/customer_since all ship default:false. zip is TEXT because a postal code has leading zeros. Odoo's credit_limit (1% populated) and user_id salesperson (2%) are deliberately ABSENT; agent_ids is the salesperson field and AR is where credit exposure comes from. Wave-5 item 8 (2026-07-27): ltm_rev and at_risk are DELETED β LTM's replacement is a creatable Sales measure column (the demo column IS Sales Β· the last 12 months), at_risk's replacement is a formula field, e.g. MAX(0, {revenue_ly} - {revenue_ytd}). Wave-6 item 8 (2026-07-27, the no-buildable-presets rule): revenue_ytd, revenue_ly, orders_24m, aov and yoy_pct are DELETED β every one is self-buildable, so a frozen pre-set beside the builder was two ways to ask one question. Replacements (recorded in verify_fields_contract.py): creatable measure columns for Sales / Orders / Avg order $ over any period (harness/measure_filter.py ADMITTED carries revenue, orders and the composite aov), and a formula over two measure columns for YoY, e.g. ({sales_ytd} - {sales_ly}) / {sales_ly}. Stale view colIds naming the five self-heal on the next autosave (the established rule).",
|
| 3 |
"fields": [
|
| 4 |
{
|
| 5 |
"key": "customer",
|
|
|
|
| 34 |
{
|
| 35 |
"key": "agent",
|
| 36 |
"label": "Agent",
|
| 37 |
+
"type": "select",
|
| 38 |
"source": "odoo",
|
| 39 |
"default": true,
|
| 40 |
"description": "The sales agent who owns this account."
|
|
|
|
| 55 |
{
|
| 56 |
"key": "salesperson",
|
| 57 |
"label": "Salesperson",
|
| 58 |
+
"type": "select",
|
| 59 |
"source": "odoo",
|
| 60 |
"default": false,
|
| 61 |
"description": "Who keyed in most of this customer's orders β not the Agent, who owns the account."
|
|
|
|
| 79 |
{
|
| 80 |
"key": "city",
|
| 81 |
"label": "City",
|
| 82 |
+
"type": "select",
|
| 83 |
"source": "odoo",
|
| 84 |
"default": true,
|
| 85 |
"description": "City on the customer's Odoo address."
|
|
|
|
| 87 |
{
|
| 88 |
"key": "state",
|
| 89 |
"label": "State",
|
| 90 |
+
"type": "select",
|
| 91 |
"source": "odoo",
|
| 92 |
"default": true,
|
| 93 |
"description": "State or province on the customer's Odoo address."
|
|
|
|
| 95 |
{
|
| 96 |
"key": "country",
|
| 97 |
"label": "Country",
|
| 98 |
+
"type": "select",
|
| 99 |
"source": "odoo",
|
| 100 |
"default": false,
|
| 101 |
"description": "Country on the customer's Odoo address."
|
|
|
|
| 108 |
"default": false,
|
| 109 |
"description": "Postal code on the customer's Odoo address."
|
| 110 |
},
|
| 111 |
+
{
|
| 112 |
+
"key": "maps_url",
|
| 113 |
+
"label": "Google Maps",
|
| 114 |
+
"type": "url",
|
| 115 |
+
"source": "odoo",
|
| 116 |
+
"default": true,
|
| 117 |
+
"description": "A Google Maps link to this customer's address."
|
| 118 |
+
},
|
| 119 |
{
|
| 120 |
"key": "customer_since",
|
| 121 |
"label": "Customer since",
|
|
|
|
| 127 |
{
|
| 128 |
"key": "tags",
|
| 129 |
"label": "Tags",
|
| 130 |
+
"type": "multiselect",
|
| 131 |
"source": "odoo",
|
| 132 |
"default": false,
|
| 133 |
"description": "Odoo labels on this customer, comma-separated."
|
| 134 |
},
|
| 135 |
{
|
| 136 |
"key": "pricelist",
|
| 137 |
+
"label": "Customer price list",
|
| 138 |
+
"type": "select",
|
| 139 |
"source": "odoo",
|
| 140 |
"default": false,
|
| 141 |
"description": "The price list this customer buys on."
|
|
|
|
| 143 |
{
|
| 144 |
"key": "payment_terms",
|
| 145 |
"label": "Payment terms",
|
| 146 |
+
"type": "select",
|
| 147 |
"source": "odoo",
|
| 148 |
"default": false,
|
| 149 |
"description": "Payment terms on this customer's account β Net 30, for example."
|
|
|
|
| 252 |
{
|
| 253 |
"key": "top_category",
|
| 254 |
"label": "Top category",
|
| 255 |
+
"type": "select",
|
| 256 |
"source": "odoo",
|
| 257 |
"default": false,
|
| 258 |
"description": "The category this customer spent the most on in the last 12 months."
|
|
|
|
| 297 |
"default": false,
|
| 298 |
"description": "Days this customer usually goes between orders, from their own history."
|
| 299 |
},
|
| 300 |
+
{
|
| 301 |
+
"key": "created_on",
|
| 302 |
+
"label": "Record created",
|
| 303 |
+
"type": "date",
|
| 304 |
+
"source": "odoo",
|
| 305 |
+
"default": false,
|
| 306 |
+
"description": "The date this customer record was created in Odoo."
|
| 307 |
+
},
|
| 308 |
{
|
| 309 |
"key": "notes",
|
| 310 |
"label": "Notes",
|
|
|
|
| 348 |
{
|
| 349 |
"key": "supplier",
|
| 350 |
"label": "Supplier",
|
| 351 |
+
"type": "multiselect",
|
| 352 |
"source": "overlay",
|
| 353 |
"default": true,
|
| 354 |
"description": "Who makes it. Editable here and shared with everyone in the workspace; seeded from the inventory mastersheet.",
|
|
|
|
| 407 |
"label": "Price 1",
|
| 408 |
"type": "currency",
|
| 409 |
"source": "odoo",
|
| 410 |
+
"default": false,
|
| 411 |
"description": "Cheapest live price for this SKU, across active pricelists."
|
| 412 |
},
|
| 413 |
{
|
|
|
|
| 415 |
"label": "Unit 1",
|
| 416 |
"type": "text",
|
| 417 |
"source": "odoo",
|
| 418 |
+
"default": false,
|
| 419 |
"description": "Package label for Price 1. Blank means Odoo has no package reference for that price."
|
| 420 |
},
|
| 421 |
{
|
|
|
|
| 423 |
"label": "Price 2",
|
| 424 |
"type": "currency",
|
| 425 |
"source": "odoo",
|
| 426 |
+
"default": false,
|
| 427 |
"description": "Second-cheapest live price for this SKU."
|
| 428 |
},
|
| 429 |
{
|
|
|
|
| 431 |
"label": "Unit 2",
|
| 432 |
"type": "text",
|
| 433 |
"source": "odoo",
|
| 434 |
+
"default": false,
|
| 435 |
"description": "Package label for Price 2."
|
| 436 |
},
|
| 437 |
{
|
|
|
|
| 439 |
"label": "Price 3",
|
| 440 |
"type": "currency",
|
| 441 |
"source": "odoo",
|
| 442 |
+
"default": false,
|
| 443 |
"description": "Third-cheapest live price for this SKU."
|
| 444 |
},
|
| 445 |
{
|
|
|
|
| 447 |
"label": "Unit 3",
|
| 448 |
"type": "text",
|
| 449 |
"source": "odoo",
|
| 450 |
+
"default": false,
|
| 451 |
"description": "Package label for Price 3."
|
| 452 |
},
|
| 453 |
+
{
|
| 454 |
+
"key": "price_fisch_t1",
|
| 455 |
+
"label": "Fisch tier 1 price",
|
| 456 |
+
"type": "currency",
|
| 457 |
+
"source": "odoo",
|
| 458 |
+
"default": false,
|
| 459 |
+
"description": "Fisch price tier 1, cheapest first. Blank when Fisch does not price this SKU."
|
| 460 |
+
},
|
| 461 |
+
{
|
| 462 |
+
"key": "unit_fisch_t1",
|
| 463 |
+
"label": "Fisch tier 1 unit",
|
| 464 |
+
"type": "text",
|
| 465 |
+
"source": "odoo",
|
| 466 |
+
"default": false,
|
| 467 |
+
"description": "Package label for the Fisch tier 1 price. Blank when Odoo names no package."
|
| 468 |
+
},
|
| 469 |
+
{
|
| 470 |
+
"key": "price_fisch_t2",
|
| 471 |
+
"label": "Fisch tier 2 price",
|
| 472 |
+
"type": "currency",
|
| 473 |
+
"source": "odoo",
|
| 474 |
+
"default": false,
|
| 475 |
+
"description": "Fisch price tier 2. Blank when Fisch prices this SKU at only one tier."
|
| 476 |
+
},
|
| 477 |
+
{
|
| 478 |
+
"key": "unit_fisch_t2",
|
| 479 |
+
"label": "Fisch tier 2 unit",
|
| 480 |
+
"type": "text",
|
| 481 |
+
"source": "odoo",
|
| 482 |
+
"default": false,
|
| 483 |
+
"description": "Package label for the Fisch tier 2 price. Blank when Odoo names no package."
|
| 484 |
+
},
|
| 485 |
+
{
|
| 486 |
+
"key": "price_fisch_t3",
|
| 487 |
+
"label": "Fisch tier 3 price",
|
| 488 |
+
"type": "currency",
|
| 489 |
+
"source": "odoo",
|
| 490 |
+
"default": false,
|
| 491 |
+
"description": "Fisch price tier 3. Blank when Fisch prices this SKU at fewer than three tiers."
|
| 492 |
+
},
|
| 493 |
+
{
|
| 494 |
+
"key": "unit_fisch_t3",
|
| 495 |
+
"label": "Fisch tier 3 unit",
|
| 496 |
+
"type": "text",
|
| 497 |
+
"source": "odoo",
|
| 498 |
+
"default": false,
|
| 499 |
+
"description": "Package label for the Fisch tier 3 price. Blank when Odoo names no package."
|
| 500 |
+
},
|
| 501 |
+
{
|
| 502 |
+
"key": "price_royal1_t1",
|
| 503 |
+
"label": "Royal 1 tier 1 price",
|
| 504 |
+
"type": "currency",
|
| 505 |
+
"source": "odoo",
|
| 506 |
+
"default": false,
|
| 507 |
+
"description": "Royal 1 price tier 1, cheapest first. Blank when Royal 1 does not price this SKU."
|
| 508 |
+
},
|
| 509 |
+
{
|
| 510 |
+
"key": "unit_royal1_t1",
|
| 511 |
+
"label": "Royal 1 tier 1 unit",
|
| 512 |
+
"type": "text",
|
| 513 |
+
"source": "odoo",
|
| 514 |
+
"default": false,
|
| 515 |
+
"description": "Package label for the Royal 1 tier 1 price. Blank when Odoo names no package."
|
| 516 |
+
},
|
| 517 |
+
{
|
| 518 |
+
"key": "price_royal1_t2",
|
| 519 |
+
"label": "Royal 1 tier 2 price",
|
| 520 |
+
"type": "currency",
|
| 521 |
+
"source": "odoo",
|
| 522 |
+
"default": false,
|
| 523 |
+
"description": "Royal 1 price tier 2. Blank when Royal 1 prices this SKU at only one tier."
|
| 524 |
+
},
|
| 525 |
+
{
|
| 526 |
+
"key": "unit_royal1_t2",
|
| 527 |
+
"label": "Royal 1 tier 2 unit",
|
| 528 |
+
"type": "text",
|
| 529 |
+
"source": "odoo",
|
| 530 |
+
"default": false,
|
| 531 |
+
"description": "Package label for the Royal 1 tier 2 price. Blank when Odoo names no package."
|
| 532 |
+
},
|
| 533 |
+
{
|
| 534 |
+
"key": "price_royal1_t3",
|
| 535 |
+
"label": "Royal 1 tier 3 price",
|
| 536 |
+
"type": "currency",
|
| 537 |
+
"source": "odoo",
|
| 538 |
+
"default": false,
|
| 539 |
+
"description": "Royal 1 price tier 3. Blank when Royal 1 prices this SKU at fewer than three tiers."
|
| 540 |
+
},
|
| 541 |
+
{
|
| 542 |
+
"key": "unit_royal1_t3",
|
| 543 |
+
"label": "Royal 1 tier 3 unit",
|
| 544 |
+
"type": "text",
|
| 545 |
+
"source": "odoo",
|
| 546 |
+
"default": false,
|
| 547 |
+
"description": "Package label for the Royal 1 tier 3 price. Blank when Odoo names no package."
|
| 548 |
+
},
|
| 549 |
+
{
|
| 550 |
+
"key": "price_royal2_t1",
|
| 551 |
+
"label": "Royal 2 tier 1 price",
|
| 552 |
+
"type": "currency",
|
| 553 |
+
"source": "odoo",
|
| 554 |
+
"default": false,
|
| 555 |
+
"description": "Royal 2 price tier 1, cheapest first. Blank when Royal 2 does not price this SKU."
|
| 556 |
+
},
|
| 557 |
+
{
|
| 558 |
+
"key": "unit_royal2_t1",
|
| 559 |
+
"label": "Royal 2 tier 1 unit",
|
| 560 |
+
"type": "text",
|
| 561 |
+
"source": "odoo",
|
| 562 |
+
"default": false,
|
| 563 |
+
"description": "Package label for the Royal 2 tier 1 price. Blank when Odoo names no package."
|
| 564 |
+
},
|
| 565 |
+
{
|
| 566 |
+
"key": "price_royal2_t2",
|
| 567 |
+
"label": "Royal 2 tier 2 price",
|
| 568 |
+
"type": "currency",
|
| 569 |
+
"source": "odoo",
|
| 570 |
+
"default": false,
|
| 571 |
+
"description": "Royal 2 price tier 2. Blank when Royal 2 prices this SKU at only one tier."
|
| 572 |
+
},
|
| 573 |
+
{
|
| 574 |
+
"key": "unit_royal2_t2",
|
| 575 |
+
"label": "Royal 2 tier 2 unit",
|
| 576 |
+
"type": "text",
|
| 577 |
+
"source": "odoo",
|
| 578 |
+
"default": false,
|
| 579 |
+
"description": "Package label for the Royal 2 tier 2 price. Blank when Odoo names no package."
|
| 580 |
+
},
|
| 581 |
+
{
|
| 582 |
+
"key": "price_royal2_t3",
|
| 583 |
+
"label": "Royal 2 tier 3 price",
|
| 584 |
+
"type": "currency",
|
| 585 |
+
"source": "odoo",
|
| 586 |
+
"default": false,
|
| 587 |
+
"description": "Royal 2 price tier 3. Blank when Royal 2 prices this SKU at fewer than three tiers."
|
| 588 |
+
},
|
| 589 |
+
{
|
| 590 |
+
"key": "unit_royal2_t3",
|
| 591 |
+
"label": "Royal 2 tier 3 unit",
|
| 592 |
+
"type": "text",
|
| 593 |
+
"source": "odoo",
|
| 594 |
+
"default": false,
|
| 595 |
+
"description": "Package label for the Royal 2 tier 3 price. Blank when Odoo names no package."
|
| 596 |
+
},
|
| 597 |
{
|
| 598 |
"key": "pre_book_qty",
|
| 599 |
"label": "Pre-book qty",
|
|
|
|
| 684 |
"label": "Days of supply",
|
| 685 |
"type": "int",
|
| 686 |
"source": "odoo",
|
| 687 |
+
"description": "Days of supply at the trailing twelve month rate, counting ON HAND PLUS INBOUND units as stock. A blank means there is no honest number to print, and Stock status beside it says which of two reasons applies: 'No recent sales' is stock on the shelf that sold nothing in the window, so there is no rate to divide by; 'No stock record' is a product the inventory read returned no row for, so its shelf is unknown rather than empty. A product that sold nothing and holds nothing reads 0, not blank. Same stock figure as the cover gap columns, so the two cannot disagree about how much you have. They still divide by different rates: this one is the trailing average, the cover gap uses the forward 8 month forecast, so a seasonal SKU reads differently in each. A business unit caller gets this column too, re-scoped: the shelf is the whole warehouse's, the rate is that unit's."
|
| 688 |
},
|
| 689 |
{
|
| 690 |
"key": "cover_gap_d",
|
|
|
|
| 714 |
"label": "Stock status",
|
| 715 |
"type": "select",
|
| 716 |
"source": "odoo",
|
| 717 |
+
"description": "Dead / excess / healthy bucket, from the same days of supply figure beside it, so it counts inbound units too. Two of its values are not coverage bands at all. 'Out of stock' keys on the REAL shelf rather than the inbound-inclusive figure, because that is a present tense fact somebody can walk into the warehouse and check, so a row can honestly read 'Out of stock' with a days of supply beside it when the replenishment is on the water; Inbound units is why. 'No stock record' means the inventory read returned no row for this product, so its shelf is unknown rather than empty: it reads that way for the handful of products carrying no SKU code, and for every row at once if an inventory read fails, which is the case where a blank Days of supply is an outage rather than a slow seller. A business unit caller gets this column too, re-scoped through that unit's own sales rate."
|
| 718 |
},
|
| 719 |
{
|
| 720 |
"key": "discontinued",
|
|
|
|
| 727 |
],
|
| 728 |
"description": "Whether Odoo carries the Discontinued product tag on this SKU. Every row gets an explicit Yes or No rather than a blank, because a blank reads as an inactive condition in the filter engine and would silently WIDEN any view that filtered on it."
|
| 729 |
},
|
| 730 |
+
{
|
| 731 |
+
"key": "created_on",
|
| 732 |
+
"label": "Record created",
|
| 733 |
+
"type": "date",
|
| 734 |
+
"source": "odoo",
|
| 735 |
+
"default": false,
|
| 736 |
+
"description": "The date this product record was created in Odoo. Read from the live product.product create_date: the mirror carries write_date and no create_date, so there is no cheaper source. A SKU whose code is on more than one active record takes the EARLIEST of them, because the row is the SKU and that is when it first existed."
|
| 737 |
+
},
|
| 738 |
{
|
| 739 |
"key": "needs_pricing",
|
| 740 |
"label": "Needs pricing",
|
platform/core/data_binding.py
CHANGED
|
@@ -263,9 +263,34 @@ def describe(repo=None):
|
|
| 263 |
|
| 264 |
β Carries no secret: a Space id and a dataset repo id are public names. The DATA is not, and
|
| 265 |
none of it is here. The field is session-gated anyway (see `routes_admin.settings`).
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 266 |
"""
|
| 267 |
rid = str(repo or '').strip()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 268 |
return {
|
|
|
|
| 269 |
'deployment': deployment_id(),
|
| 270 |
'production': is_production_deployment(),
|
| 271 |
'repo': rid,
|
|
|
|
| 263 |
|
| 264 |
β Carries no secret: a Space id and a dataset repo id are public names. The DATA is not, and
|
| 265 |
none of it is here. The field is session-gated anyway (see `routes_admin.settings`).
|
| 266 |
+
|
| 267 |
+
ββ W40-T13 (D-333) β IT ALSO NAMES THE STORE BACKEND, WHICH IS THE OTHER HALF OF THE SAME
|
| 268 |
+
QUESTION AND THE HALF THAT WENT MISSING. `repo` answers "WHICH STORE am I bound to"; after the
|
| 269 |
+
Postgres cutover the sharper question is "am I READING that store from HF or from Neon", and
|
| 270 |
+
the payload could not answer it at all. W36-T62's `done-when` said *"/settings reports the pg
|
| 271 |
+
backend"* and was therefore unmeasurable, which is how a whole cutover shipped with the
|
| 272 |
+
verification clause pointed at a field that did not exist. It exists now.
|
| 273 |
"""
|
| 274 |
rid = str(repo or '').strip()
|
| 275 |
+
# ββ THE IMPORT IS FUNCTION-LOCAL AND MUST STAY THAT WAY. `core/store.py` imports THIS module
|
| 276 |
+
# at its own module scope, so pulling `core.store` up to the top of this file is a hard import
|
| 277 |
+
# cycle that kills the app at boot rather than at a test. Do not "tidy" it upward.
|
| 278 |
+
#
|
| 279 |
+
# β AND AN UNRECOGNISED BACKEND REPORTS `unknown`, NEVER `hf`. `store.backend()` RAISES on a
|
| 280 |
+
# value it does not know, and this function is called from `routes_admin::_store_binding`
|
| 281 |
+
# inside a bare `except` whose fallback dict has no `backend` key at all β so a raise here
|
| 282 |
+
# would delete the field from the payload on exactly the deployment that most needs it. And
|
| 283 |
+
# defaulting to `hf` would be worse than raising: a misconfigured container would report the
|
| 284 |
+
# store it is NOT reading, which is the guess this field exists to replace. ImportError rides
|
| 285 |
+
# the same branch for the same reason: an honest "I could not tell" beats a confident wrong
|
| 286 |
+
# answer on a surface nobody can inspect from outside (D-160).
|
| 287 |
+
try:
|
| 288 |
+
import core.store as store # noqa: PLC0415 β cycle, see above
|
| 289 |
+
store_backend = store.backend()
|
| 290 |
+
except (RuntimeError, ImportError):
|
| 291 |
+
store_backend = 'unknown'
|
| 292 |
return {
|
| 293 |
+
'backend': store_backend,
|
| 294 |
'deployment': deployment_id(),
|
| 295 |
'production': is_production_deployment(),
|
| 296 |
'repo': rid,
|
platform/core/field_permissions.py
CHANGED
|
@@ -58,6 +58,161 @@ def grant_entries(permissions):
|
|
| 58 |
return []
|
| 59 |
|
| 60 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 61 |
def _field_is_migratable(field):
|
| 62 |
return (isinstance(field, dict) and field.get("custom") is True
|
| 63 |
and field.get("source") == "overlay")
|
|
@@ -74,13 +229,34 @@ def migrate_legacy_fields(table_key, st=None, known_users=None, grant_topic=None
|
|
| 74 |
grant_key = str(grant_topic or key).strip()
|
| 75 |
shared_key = str(shared_key or key).strip()
|
| 76 |
if not key or st is None:
|
| 77 |
-
return {"promoted": 0, "normalized": 0}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 78 |
try:
|
| 79 |
document = st.get(key) or {}
|
| 80 |
except Exception:
|
| 81 |
-
return {"promoted": 0, "normalized": 0}
|
| 82 |
if not isinstance(document, dict):
|
| 83 |
-
return {"promoted": 0, "normalized": 0}
|
| 84 |
|
| 85 |
promoted = 0
|
| 86 |
normalized = 0
|
|
@@ -151,7 +327,10 @@ def migrate_legacy_fields(table_key, st=None, known_users=None, grant_topic=None
|
|
| 151 |
values.pop(field_key, None)
|
| 152 |
return data
|
| 153 |
st.update(key, _remove, flush="sync")
|
| 154 |
-
|
|
|
|
|
|
|
|
|
|
| 155 |
|
| 156 |
|
| 157 |
def promote_field(workspace_key, shared_key, grant_topic, owner, field, st=None):
|
|
@@ -162,7 +341,36 @@ def promote_field(workspace_key, shared_key, grant_topic, owner, field, st=None)
|
|
| 162 |
return dict(field)
|
| 163 |
shared = dict(field)
|
| 164 |
shared.update({"shared": True, "granted": True, "source": "overlay", "custom": True})
|
| 165 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 166 |
shared["permissions"] = permissions
|
| 167 |
shared["createdBy"] = str(shared.get("createdBy") or owner).strip().lower()
|
| 168 |
shared_overlay.put_field(shared_key, key, shared, st=st)
|
|
|
|
| 58 |
return []
|
| 59 |
|
| 60 |
|
| 61 |
+
def permissions_from_grants(entries):
|
| 62 |
+
"""ββ W40-T03 / CONTRACT C4 β THE CLASSIFICATION IS DERIVED FROM THE REGISTRY, NEVER STAMPED.
|
| 63 |
+
|
| 64 |
+
Owner instruction 21 (2026-08-23): *"A Field shared with only Karen Ganley shows under Hide
|
| 65 |
+
Fields as 'Shared with everyone' β it should be 'Shared with me'. Fix the logic. By default
|
| 66 |
+
every Field created is private until it is shared."*
|
| 67 |
+
|
| 68 |
+
The registry (`core/shares.py`) already knows exactly who a column is shared with; the
|
| 69 |
+
`permissions` bag on the definition is only the WORD the client sections on
|
| 70 |
+
(`FieldsHidePanel` buckets by `types.fieldEditMode`). Until now those two could disagree,
|
| 71 |
+
because `promote_field` stamped the bag from a hardcoded fallback BEFORE the request's own
|
| 72 |
+
grant entries were written. This function is the single place the bag is derived from the
|
| 73 |
+
grants, so the word on screen and the wall in the registry answer the same question.
|
| 74 |
+
|
| 75 |
+
β CLASSIFICATION IS ABOUT **WHO**, NOT ABOUT **ROLE**, and that is C4's wording rather than an
|
| 76 |
+
approximation: *"'Shared with me' means grants naming me"*. A `view`-role grantee is a person
|
| 77 |
+
the column is shared with exactly as an `edit`-role one is, so both count. The role itself is
|
| 78 |
+
NOT recoverable from this bag and is not meant to be β `shares.role_for` is what answers "may
|
| 79 |
+
this account change it", on every path that asks (see the four short-circuits named on
|
| 80 |
+
`reconcile_shared_permissions`).
|
| 81 |
+
|
| 82 |
+
β THE WILDCARD WINS, AND THE NAMED USERS ARE DISCARDED. `*` plus named users is still "shared
|
| 83 |
+
with everyone" on screen, because everyone can already reach it; carrying the named few
|
| 84 |
+
alongside would produce a bag that says `users` while the registry admits the room. Discarding
|
| 85 |
+
them is safe precisely because this bag is not a wall for a shared field: `role_for` keeps the
|
| 86 |
+
stronger of an everyone-grant and a personal one, so a named user's raised role survives in
|
| 87 |
+
the registry where it is actually read.
|
| 88 |
+
|
| 89 |
+
β `known_users` IS DELIBERATELY NOT PASSED, HERE OR BY ANY CALLER ON THIS PATH.
|
| 90 |
+
`clean_permissions` collapses to `{'edit': 'personal'}` when the filtered users list ends up
|
| 91 |
+
empty, so ONE grantee missing from the user registry would silently reflip a shared column to
|
| 92 |
+
Private β the owner's defect in the other direction, and just as invisible. `put_share` has
|
| 93 |
+
already validated every grantee through `_entries_or_400` before the grant is stored, so the
|
| 94 |
+
filter would only ever fire on a name that door already accepted.
|
| 95 |
+
|
| 96 |
+
β THE USERS LIST IS SORTED, AND THAT IS WHAT MAKES THE RECONCILE IDEMPOTENT rather than merely
|
| 97 |
+
convergent. `shares._clean_entries` preserves stored insertion order, so two grant sets holding
|
| 98 |
+
the same people in a different order would otherwise derive two different-but-equal bags and
|
| 99 |
+
rewrite each other forever on alternating reads (the D-358 egress class).
|
| 100 |
+
"""
|
| 101 |
+
users = []
|
| 102 |
+
seen = set()
|
| 103 |
+
for entry in entries or ():
|
| 104 |
+
if not isinstance(entry, dict):
|
| 105 |
+
continue
|
| 106 |
+
user = str(entry.get("user") or "").strip().lower()
|
| 107 |
+
if not user or user in seen:
|
| 108 |
+
continue
|
| 109 |
+
seen.add(user)
|
| 110 |
+
if user == shares.EVERYONE:
|
| 111 |
+
return clean_permissions({"edit": "collaborative"})
|
| 112 |
+
users.append(user)
|
| 113 |
+
if not users:
|
| 114 |
+
return clean_permissions({"edit": "personal"})
|
| 115 |
+
return clean_permissions({"edit": "users", "users": sorted(users)})
|
| 116 |
+
|
| 117 |
+
|
| 118 |
+
def _same_classification(left, right):
|
| 119 |
+
"""Do two canonical bags say the same thing about WHO?
|
| 120 |
+
|
| 121 |
+
β THE USERS LIST IS COMPARED AS A SET, not as a sequence, and that is a write-count decision
|
| 122 |
+
rather than a nicety. A stored bag minted before the sort above carries the registry's
|
| 123 |
+
insertion order; comparing sequences would rewrite every such column once for a change no
|
| 124 |
+
reader can see. `shared_overlay.put_field` is a `flush='sync'` store commit per field, so a
|
| 125 |
+
difference nobody can observe must not cost one.
|
| 126 |
+
"""
|
| 127 |
+
if left.get("edit") != right.get("edit"):
|
| 128 |
+
return False
|
| 129 |
+
return set(left.get("users") or ()) == set(right.get("users") or ())
|
| 130 |
+
|
| 131 |
+
|
| 132 |
+
def reconcile_shared_permissions(shared_key, grant_topic, st=None):
|
| 133 |
+
"""Re-derive every SHARED definition's `permissions` bag from the grant registry. Returns the
|
| 134 |
+
number of definitions actually rewritten.
|
| 135 |
+
|
| 136 |
+
ββ THIS IS A **WRITE ON A READ PATH**, ON A TENANT-WIDE STRATUM, AND IT IS DELIBERATE.
|
| 137 |
+
`routes_customers.py`'s `ROUTE_KIND` comment argues the opposite case for route columns
|
| 138 |
+
(*"Backfilling every stored route definition on a read is a write nobody asked for, on a
|
| 139 |
+
tenant-wide stratum, triggered by opening a page"*) and settles it with "re-solving is one
|
| 140 |
+
click and it is the click the owner is already making". A SHARED FIELD HAS NO SUCH CLICK: the
|
| 141 |
+
owner's "Fisch Main Catalog" was shared once, months ago, and nothing will ever rewrite its
|
| 142 |
+
definition again. Leaving it to a future re-share is leaving it wrong forever. C4 also makes
|
| 143 |
+
the registry AUTHORITATIVE, which a stamp that is never re-derived cannot be. This function is
|
| 144 |
+
called from `migrate_legacy_fields`, which is already exactly such a pass β it runs
|
| 145 |
+
`flush='sync'` promotions on the same three read paths β so this adds a kind of write to a
|
| 146 |
+
door that already makes them, not a new door.
|
| 147 |
+
|
| 148 |
+
β ONLY THE SHARED STRATUM, CHECKED ON `shared`/`granted`. On a PER-USER private field the bag
|
| 149 |
+
IS the wall and re-deriving it would move a permission. On a shared one it is not, and that is
|
| 150 |
+
checked rather than reasoned β all four consumers short-circuit on the share marks BEFORE they
|
| 151 |
+
ever read the bag: `grid_events._may_edit_field_definition` and `::_may_edit_field_value` both
|
| 152 |
+
take `_field_share_role` on `definition.get('shared') or definition.get('granted')`;
|
| 153 |
+
`types.mayEditField` and `types.mayEditFieldDefinition` take the same branch in the same order
|
| 154 |
+
on the client; and `perm_scope.field_grant_hidden` keys off `FIELD_GRANT_MARK` plus
|
| 155 |
+
`shares.role_for` and never reads the bag at all. Nothing on this path is a permission
|
| 156 |
+
decision. This is the same fact the `ROUTE_KIND` comment states of its own change: *"AND IT
|
| 157 |
+
MOVES NO WALL, CHECKED RATHER THAN REASONED."*
|
| 158 |
+
|
| 159 |
+
β NO GRANT RECORD AT ALL MEANS **LEAVE IT ALONE**, and the distinction is why `shares.grants`
|
| 160 |
+
returning an owner with zero entries is a different answer from returning neither. A record
|
| 161 |
+
with an owner and no entries is a column somebody has managed and shared with nobody: that is
|
| 162 |
+
`personal`, positively. A column the registry has never heard of is a column this function
|
| 163 |
+
knows nothing about, and inventing a classification for it would be guessing in the direction
|
| 164 |
+
of a visible change.
|
| 165 |
+
|
| 166 |
+
β ONE `put_field` PER CHANGED DEFINITION, and the bound is what makes that acceptable. Only a
|
| 167 |
+
definition whose stored bag DISAGREES with its grants is rewritten, which in practice is the
|
| 168 |
+
handful first shared before this derivation existed; steady state is zero writes, proven by
|
| 169 |
+
the idempotence leg of the harness. `shared_overlay.put_rows`' docstring carries this repo's
|
| 170 |
+
measured scar for the opposite shape (*"18 writes against one document under the store's
|
| 171 |
+
coalescing single-flight landed ZERO while answering 200 eighteen times"*), so if a corpus ever
|
| 172 |
+
makes this pass write in bulk it must become ONE batched write rather than a loop.
|
| 173 |
+
"""
|
| 174 |
+
bucket = str(shared_key or "").strip()
|
| 175 |
+
grant_key = str(grant_topic or bucket).strip()
|
| 176 |
+
if not bucket or st is None:
|
| 177 |
+
return 0
|
| 178 |
+
rewritten = 0
|
| 179 |
+
for field_key, defn in list(shared_overlay.fields(bucket, st=st).items()):
|
| 180 |
+
# β EACH DEFINITION IS GUARDED ON ITS OWN. `shares.field_oid` RAISES on an empty key, and
|
| 181 |
+
# the caller wraps this whole function in one swallowing except β so a single malformed
|
| 182 |
+
# entry would otherwise skip every REMAINING column, including the one the owner reported,
|
| 183 |
+
# and report as "nothing to reclassify" with no failure anywhere near the cause.
|
| 184 |
+
try:
|
| 185 |
+
if not isinstance(defn, dict):
|
| 186 |
+
continue
|
| 187 |
+
if not (defn.get("shared") or defn.get("granted")):
|
| 188 |
+
continue
|
| 189 |
+
key = str(field_key or "").strip()
|
| 190 |
+
if not key:
|
| 191 |
+
continue
|
| 192 |
+
record = shares.grants("field", shares.field_oid(grant_key, key), st=st)
|
| 193 |
+
if not record.get("owner") and not record.get("entries"):
|
| 194 |
+
continue
|
| 195 |
+
derived = permissions_from_grants(record.get("entries"))
|
| 196 |
+
stored = defn.get("permissions")
|
| 197 |
+
# β A MISSING BAG IS ALWAYS A DIFFERENCE, EVEN WHEN THE DERIVATION SAYS `personal`.
|
| 198 |
+
# This is the leg that decides whether the fix is visible at all. The client's own
|
| 199 |
+
# fallback is `"collaborative"` (`types.cleanFieldPermissions(field.permissions,
|
| 200 |
+
# "collaborative")`), so a definition carrying NO bag renders as "Shared with
|
| 201 |
+
# everyone" no matter what the registry says. Comparing canonicalised values would
|
| 202 |
+
# find `personal == personal` and write nothing, and the column would keep reading
|
| 203 |
+
# "Shared with everyone" forever. The server must emit an EXPLICIT bag on every
|
| 204 |
+
# shared definition; absence is not a value the wire can carry.
|
| 205 |
+
if isinstance(stored, dict) and _same_classification(clean_permissions(stored), derived):
|
| 206 |
+
continue
|
| 207 |
+
updated = dict(defn)
|
| 208 |
+
updated["permissions"] = derived
|
| 209 |
+
shared_overlay.put_field(bucket, key, updated, st=st)
|
| 210 |
+
rewritten += 1
|
| 211 |
+
except Exception:
|
| 212 |
+
continue
|
| 213 |
+
return rewritten
|
| 214 |
+
|
| 215 |
+
|
| 216 |
def _field_is_migratable(field):
|
| 217 |
return (isinstance(field, dict) and field.get("custom") is True
|
| 218 |
and field.get("source") == "overlay")
|
|
|
|
| 229 |
grant_key = str(grant_topic or key).strip()
|
| 230 |
shared_key = str(shared_key or key).strip()
|
| 231 |
if not key or st is None:
|
| 232 |
+
return {"promoted": 0, "normalized": 0, "reclassified": 0}
|
| 233 |
+
# ββ W40-T03 β RECONCILE THE SHARED STRATUM'S CLASSIFICATION FIRST, IN ITS OWN SWALLOWING
|
| 234 |
+
# GUARD. This is the ONE seam that reaches every shared-field surface: all three readers
|
| 235 |
+
# (`routes_customers.shared_fields`, `routes_tables._ut_shared_fields`,
|
| 236 |
+
# `product_data`) already call this function with the right keys and read the definitions
|
| 237 |
+
# immediately afterwards, so a reconcile that writes into the shared overlay is picked up by
|
| 238 |
+
# that same read.
|
| 239 |
+
#
|
| 240 |
+
# β THE GUARD IS NOT DEFENSIVENESS, IT IS A BLAST RADIUS. `routes_customers.shared_fields`
|
| 241 |
+
# wraps its whole call in a `try/except` that degrades to `{}` β i.e. a raise in here would
|
| 242 |
+
# blank EVERY shared column on the customer grid and read as "nothing is shared yet". A
|
| 243 |
+
# classification that fails must leave the previous word on screen, never the page empty.
|
| 244 |
+
#
|
| 245 |
+
# β THE TWO KEYS ARE DIFFERENT STRINGS AND THE ORDER MATTERS. `shared_key` names the BUCKET
|
| 246 |
+
# (`product_table_workspace__shared`); `grant_key` names the registry TOPIC
|
| 247 |
+
# (`product_data:<field>`). For the product topic they are not the same value. Swapping them
|
| 248 |
+
# finds no grant record, the "no record" arm fires for every column, and the reconcile
|
| 249 |
+
# silently does nothing at all.
|
| 250 |
+
try:
|
| 251 |
+
reclassified = reconcile_shared_permissions(shared_key, grant_key, st=st)
|
| 252 |
+
except Exception:
|
| 253 |
+
reclassified = 0
|
| 254 |
try:
|
| 255 |
document = st.get(key) or {}
|
| 256 |
except Exception:
|
| 257 |
+
return {"promoted": 0, "normalized": 0, "reclassified": reclassified}
|
| 258 |
if not isinstance(document, dict):
|
| 259 |
+
return {"promoted": 0, "normalized": 0, "reclassified": reclassified}
|
| 260 |
|
| 261 |
promoted = 0
|
| 262 |
normalized = 0
|
|
|
|
| 327 |
values.pop(field_key, None)
|
| 328 |
return data
|
| 329 |
st.update(key, _remove, flush="sync")
|
| 330 |
+
# β `promoted` AND `normalized` KEEP THEIR NAMES AND THEIR MEANINGS.
|
| 331 |
+
# `aios-web/api/verify_field_permissions.py` asserts `result["promoted"] == 1`; renaming or
|
| 332 |
+
# folding either into the new count would turn a green gate red for a change it never made.
|
| 333 |
+
return {"promoted": promoted, "normalized": normalized, "reclassified": reclassified}
|
| 334 |
|
| 335 |
|
| 336 |
def promote_field(workspace_key, shared_key, grant_topic, owner, field, st=None):
|
|
|
|
| 341 |
return dict(field)
|
| 342 |
shared = dict(field)
|
| 343 |
shared.update({"shared": True, "granted": True, "source": "overlay", "custom": True})
|
| 344 |
+
# ββ W40-T03 / OWNER INSTRUCTION 21 β THE FALLBACK IS `personal`, AND IT IS THE ROOT CAUSE.
|
| 345 |
+
#
|
| 346 |
+
# Owner: *"By default every Field created is private until it is shared."*
|
| 347 |
+
#
|
| 348 |
+
# β THE BUG WAS AN ORDERING ONE, WHICH IS WHY IT LOOKED LIKE THE OPPOSITE OF ITSELF.
|
| 349 |
+
# `routes_shares.put_share` promotes FIRST and writes the request's own grant entries one line
|
| 350 |
+
# LATER, so on a first share this function cannot see who the field is being shared with. With
|
| 351 |
+
# `fallback="collaborative"` it therefore stamped `{'edit': 'collaborative'}` on EVERY first
|
| 352 |
+
# share β Karen-only included β and the bag was never re-derived afterwards. `set_grants`
|
| 353 |
+
# immediately replaced the transient `*` grant with Karen's, so the WALL was right the whole
|
| 354 |
+
# time; the permanent lie was the WORD, and the word is what the owner reads under Hide fields.
|
| 355 |
+
#
|
| 356 |
+
# β AN EXPLICIT BAG STILL WINS, AND THAT IS WHAT KEEPS THE OTHER CALLER BYTE-IDENTICAL.
|
| 357 |
+
# `grid_events.field_upsert` (the field editor's permission picker) sets
|
| 358 |
+
# `field['permissions']` in BOTH arms of its `may_change_permissions` branch before calling
|
| 359 |
+
# this, and only reaches it when that bag already says `collaborative` or `users`. The
|
| 360 |
+
# fallback is never consulted there, so this line moves nothing on that path.
|
| 361 |
+
#
|
| 362 |
+
# β THE CALL SITE CHANGES, NOT `stored_permissions`' OWN DEFAULT. That default answers a
|
| 363 |
+
# different question β *"what did an old field, written before this vocabulary existed,
|
| 364 |
+
# mean?"* β and `migrate_legacy_fields` still needs the old answer for its LEGACY promotion
|
| 365 |
+
# leg, which `verify_field_permissions.py` asserts to the letter.
|
| 366 |
+
#
|
| 367 |
+
# β `set_grants` BELOW IS LEFT IN PLACE. With `personal` it writes `[]` plus an owner, which is
|
| 368 |
+
# the shape `routes_customers.py`'s route claim states in full: *"the empty entry list is the
|
| 369 |
+
# point. `set_grants` keeps a record with an owner and no entries, so 'shared with nobody' is
|
| 370 |
+
# STORED and is a different fact from 'never shared'."* `reconcile_shared_permissions` reads
|
| 371 |
+
# exactly that difference, so dropping the call would make a freshly promoted column
|
| 372 |
+
# unclassifiable rather than private.
|
| 373 |
+
permissions = stored_permissions(shared, fallback="personal")
|
| 374 |
shared["permissions"] = permissions
|
| 375 |
shared["createdBy"] = str(shared.get("createdBy") or owner).strip().lower()
|
| 376 |
shared_overlay.put_field(shared_key, key, shared, st=st)
|
platform/core/grid_events.py
CHANGED
|
@@ -420,6 +420,92 @@ def _docs_key(ctx):
|
|
| 420 |
|
| 421 |
|
| 422 |
# ------------------------------------------------------------------ the workspace family (X1 amd.)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 423 |
def table_workspace(ctx, allowed_pids=None, consume_corrections=True):
|
| 424 |
"""Durable Airtable-style view/schema/overlay state, with an honest session fallback.
|
| 425 |
|
|
@@ -427,6 +513,11 @@ def table_workspace(ctx, allowed_pids=None, consume_corrections=True):
|
|
| 427 |
with them. Own views win a same-id collision β a personal view is the user's own object and
|
| 428 |
must never be shadowed by somebody else's share.
|
| 429 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 430 |
β `allowed_pids` is a SECURITY parameter, not a convenience. A shared view carries
|
| 431 |
`memberPids`, which the writer's scope validated on the way IN β but the READER may have a
|
| 432 |
narrower scope. Handing a Fisch-scoped user a view whose member list was built by a
|
|
@@ -457,6 +548,69 @@ def table_workspace(ctx, allowed_pids=None, consume_corrections=True):
|
|
| 457 |
except Exception as _ge:
|
| 458 |
_tel.error('sharedviews:granted', _ge)
|
| 459 |
granted = {}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 460 |
if shared or granted:
|
| 461 |
merged = dict(granted)
|
| 462 |
merged.update(shared) # the everyone-bucket outranks a grant
|
|
@@ -478,9 +632,16 @@ def _granted_views(ctx, uname):
|
|
| 478 |
The R10 registry stores bare ids, tenant-scoped through the SAME store handle this topic's
|
| 479 |
bucket uses; the record itself is fetched out of the OWNER's personal stratum of THIS
|
| 480 |
bucket. An id granted on another topic simply finds nothing here and contributes nothing
|
| 481 |
-
(fail-closed). Each projected view is stamped `shared` / `sharedRole` / `owner`
|
| 482 |
-
client can synthesise the "Shared with me" group and disable edit affordances for
|
| 483 |
role=view β the stamps live on the PROJECTION only, never written back to the store.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 484 |
`role_for` is asked with is_admin=False deliberately: the stamp reports the GRANT (the
|
| 485 |
registry listed only explicit entries), not the caller's rank.
|
| 486 |
"""
|
|
@@ -503,6 +664,12 @@ def _granted_views(ctx, uname):
|
|
| 503 |
v['shared'] = True
|
| 504 |
v['sharedRole'] = role
|
| 505 |
v['owner'] = owner
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 506 |
out[str(vid)] = v
|
| 507 |
|
| 508 |
# β D-37 (2026-08-05) β THE FOLDER LEG. W20's R10 said "a folder share = its views ride
|
|
@@ -537,6 +704,8 @@ def _granted_views(ctx, uname):
|
|
| 537 |
v['shared'] = True
|
| 538 |
v['sharedRole'] = role
|
| 539 |
v['owner'] = owner
|
|
|
|
|
|
|
| 540 |
# The folder's NAME rides so the client can group these together later; today it
|
| 541 |
# renders in the same "Shared with me" group the view leg feeds. Stamps live on the
|
| 542 |
# PROJECTION only and are never written back, exactly as above.
|
|
|
|
| 420 |
|
| 421 |
|
| 422 |
# ------------------------------------------------------------------ the workspace family (X1 amd.)
|
| 423 |
+
def _grant_marker(ctx, ws):
|
| 424 |
+
"""`has_grants(view_id) -> bool` for this tenant, or None when nothing here is granted at all.
|
| 425 |
+
|
| 426 |
+
ββ ONE PREDICATE, THREE MERGE LEGS β W40-T01, owner instruction 2, contract C1.
|
| 427 |
+
`table_workspace` assembles its `views` from three sources (granted / `__shared__` bucket /
|
| 428 |
+
the caller's own stratum) and a share mark has to mean the SAME thing on all three, or the
|
| 429 |
+
client is back to branching on who is looking. So the rule lives here once and the registry is
|
| 430 |
+
read ONCE per workspace read; a closure rather than three calls, because `granted_oids` exists
|
| 431 |
+
precisely to stop this becoming N reads of the whole grant bucket per rail.
|
| 432 |
+
|
| 433 |
+
ββ THE ASYMMETRY THIS CLOSES. Owner, verbatim: *"A shared View must show the
|
| 434 |
+
shared/collaborative icon in EVERY account, not only the recipient's."* Contract C1 states the
|
| 435 |
+
meaning that makes that true: **`shared` on a view means "this view has grants", not "granted
|
| 436 |
+
to me"**. The receiver's copy has been stamped since wave 21 (`_granted_views`); the SHARER's
|
| 437 |
+
copy never was and structurally could not be, because `_granted_views` and `shared_views` both
|
| 438 |
+
EXCLUDE what the caller owns by design β so the person who did the sharing is the one person
|
| 439 |
+
the old projection could never tell.
|
| 440 |
+
|
| 441 |
+
"Carries a grant" is EITHER of two things, and the folder leg is not optional: a receiver
|
| 442 |
+
already gets `shared` stamped through `_granted_views`' folder pass (D-37), so answering only
|
| 443 |
+
the direct-view half here would re-create exactly the asymmetry instruction 2 reports, one
|
| 444 |
+
level down.
|
| 445 |
+
|
| 446 |
+
β THE SOURCE IS THE R10 GRANT REGISTRY ONLY (`core/shares.py`), AND THE NARROWING IS
|
| 447 |
+
DELIBERATE β not an oversight for the next reader to "fix". `routes_shares.py`'s own module
|
| 448 |
+
docstring warns that TWO SYSTEMS answer "is this shared" and they are not the same one (audit
|
| 449 |
+
S-4): the other is the legacy `__shared__` bucket (`permissions.edit in ('collaborative',
|
| 450 |
+
'users')`). BUCKET MEMBERSHIP IS NOT A GRANT. A view living in that bucket is asked the same
|
| 451 |
+
question as any other β does the REGISTRY hold an entry for it β so a `collaborative` view
|
| 452 |
+
nobody ever granted carries no mark, and that stays booked rather than fixed here: marking it
|
| 453 |
+
would additionally need an `owner` stamp on that leg to keep the tooltip honest, which is a
|
| 454 |
+
copy change on a client file outside this ticket.
|
| 455 |
+
|
| 456 |
+
β WHICH IS WHY THE `__shared__` LEG STILL NEEDS ASKING, and it is the corner the own-views
|
| 457 |
+
leg cannot reach. `save_view` moves a `collaborative`/`users` view OUT of the creator's
|
| 458 |
+
personal stratum, so its OWNER has no copy in `ws['views']` at all; and `merged.update(shared)`
|
| 459 |
+
outranks the stamped `granted` copy, so a receiver's mark would be overwritten on the way
|
| 460 |
+
through. Both are answered by asking this predicate on that leg too. β The merge PRECEDENCE
|
| 461 |
+
is untouched β "the everyone-bucket outranks a grant" is deliberate and is not this ticket's
|
| 462 |
+
to reverse; the fix stamps the copy that wins, it does not re-arbitrate which copy wins.
|
| 463 |
+
|
| 464 |
+
β MEMBERSHIP OF THE ID IS THE WHOLE TEST, and there is one known false positive it cannot
|
| 465 |
+
see: a PINNED PER-USER id (`all-customers`, `tpl_overview`) exists once per user, so a grant
|
| 466 |
+
recorded against that id by anybody would mark every user's own copy. That is the same
|
| 467 |
+
first-match hazard `handle_one` documents at the foreign-view wall (W33-T13). It is decoration
|
| 468 |
+
on a view nobody shared, never a widening β and `granted_oids` cannot answer "whose" without
|
| 469 |
+
becoming the N-reads-per-rail shape it exists to avoid. Booked, not papered over.
|
| 470 |
+
|
| 471 |
+
β NO `createdBy` FILTER, on any leg. Ownership is not what this answers β "has grants" is a
|
| 472 |
+
property of the VIEW, which is the whole of C1 β and re-filtering on `createdBy` would drop
|
| 473 |
+
the mark off any record whose copy of it is absent or stale, the same class of trap that keeps
|
| 474 |
+
`scope_view` off the own-views leg. WHO is sharing is answered separately, by `sharedOut`.
|
| 475 |
+
|
| 476 |
+
β THE FOLDER MAP IS THE CALLER'S OWN `itemFolders`, which is the only placement map this read
|
| 477 |
+
has in hand. That is exact for the own-views leg. For a `__shared__` view it answers the
|
| 478 |
+
caller's own filing of it, and a folder grant on somebody else's folder cannot reach a view
|
| 479 |
+
in that bucket anyway (`find_folder` reads the owner's personal stratum, which a shared view
|
| 480 |
+
has already left) β so the direct-view half is what carries that leg in practice.
|
| 481 |
+
"""
|
| 482 |
+
import core.shares as shares
|
| 483 |
+
# The SAME store handle `_granted_views` resolves, and asked for the same reason: the grants
|
| 484 |
+
# bucket is tenant-scoped and must be read out of the tenant whose workspace this is. Written
|
| 485 |
+
# as `_tops(ctx).st` rather than `_store_of(ctx)` so the two legs cannot drift on tenancy.
|
| 486 |
+
st = getattr(_tops(ctx), 'st', None)
|
| 487 |
+
view_oids = shares.granted_oids('view', st=st)
|
| 488 |
+
folder_oids = shares.granted_oids('folder', st=st)
|
| 489 |
+
if not view_oids and not folder_oids:
|
| 490 |
+
return None # nothing in this tenant is granted: no marks, no closure
|
| 491 |
+
# β `itemFolders` IS KEYED BY SURFACE FIRST (`{'views': {itemId: folderId}, β¦}`) β reading item
|
| 492 |
+
# ids off the top level finds the surface NAMES and matches nothing, which is the same trap
|
| 493 |
+
# `table_store.find_folder` carries a note about. It is already in the payload above, so the
|
| 494 |
+
# folder leg costs no extra store read.
|
| 495 |
+
placed = (ws.get('itemFolders') or {}).get('views') or {}
|
| 496 |
+
|
| 497 |
+
def _has_grants(view_id):
|
| 498 |
+
key = str(view_id)
|
| 499 |
+
if key in view_oids:
|
| 500 |
+
return True
|
| 501 |
+
fid = str(placed.get(key) or '')
|
| 502 |
+
# `fid` truthiness FIRST: '' must never match a grant stored under the empty-string oid,
|
| 503 |
+
# which would mark every unfiled view at once.
|
| 504 |
+
return bool(fid and fid in folder_oids)
|
| 505 |
+
|
| 506 |
+
return _has_grants
|
| 507 |
+
|
| 508 |
+
|
| 509 |
def table_workspace(ctx, allowed_pids=None, consume_corrections=True):
|
| 510 |
"""Durable Airtable-style view/schema/overlay state, with an honest session fallback.
|
| 511 |
|
|
|
|
| 513 |
with them. Own views win a same-id collision β a personal view is the user's own object and
|
| 514 |
must never be shadowed by somebody else's share.
|
| 515 |
|
| 516 |
+
β W40-T01 (owner instruction 2, contract C1): every view that HAS grants carries
|
| 517 |
+
`hasShares: True` whoever is asking, and the copy belonging to the account doing the sharing
|
| 518 |
+
additionally carries `sharedOut: True`. Stamped on ALL THREE merge legs from ONE predicate
|
| 519 |
+
(`_grant_marker`), on the PROJECTION only, and never written back.
|
| 520 |
+
|
| 521 |
β `allowed_pids` is a SECURITY parameter, not a convenience. A shared view carries
|
| 522 |
`memberPids`, which the writer's scope validated on the way IN β but the READER may have a
|
| 523 |
narrower scope. Handing a Fisch-scoped user a view whose member list was built by a
|
|
|
|
| 548 |
except Exception as _ge:
|
| 549 |
_tel.error('sharedviews:granted', _ge)
|
| 550 |
granted = {}
|
| 551 |
+
# ββ W40-T01 / OWNER INSTRUCTION 2 / CONTRACT C1 β THE SHARE MARKS, ON THE TWO LEGS THAT
|
| 552 |
+
# ARRIVE UNSTAMPED. `granted` was already stamped by `_granted_views`; these two were not.
|
| 553 |
+
# β AND THIS SITS OUTSIDE THE `if shared or granted:` GUARD BELOW, deliberately. Four
|
| 554 |
+
# traps, all measured, each of which makes the "obvious" placement silently do nothing:
|
| 555 |
+
#
|
| 556 |
+
# β 1. THAT GUARD IS UNREACHABLE FOR THIS TICKET'S CASE. For the exact fixture the
|
| 557 |
+
# owner reports β I own a view, I shared it OUT, nothing is shared TO me β BOTH
|
| 558 |
+
# `shared` and `granted` are empty (`shared_views` and `_granted_views` each exclude
|
| 559 |
+
# what the caller owns, and a new view defaults to `permissions.edit='personal'` so
|
| 560 |
+
# it is not in the `__shared__` bucket either). The whole block is SKIPPED and
|
| 561 |
+
# `ws['views']` returns raw. Stamping "on the legs of the merge" is therefore not
|
| 562 |
+
# enough: the sharer's leg has to run unconditionally or it never runs at all.
|
| 563 |
+
#
|
| 564 |
+
# β 2. DO NOT ROUTE THESE THROUGH `scope_view`. Today own views only reach it when the
|
| 565 |
+
# caller has shares; make the comprehension unconditional and an own view whose
|
| 566 |
+
# `createdBy` is absent or mismatched starts being re-scoped, and `scope_view` with
|
| 567 |
+
# `allowed_pids=None` sets `memberPids: []` β the list, wiped, on the user's OWN view.
|
| 568 |
+
# Stamp beside that path, never into it. The granted/shared legs keep re-scoping
|
| 569 |
+
# exactly as before, and `scope_view` copies (`out = dict(view)`) so the stamps ride.
|
| 570 |
+
#
|
| 571 |
+
# β 3. `table_store.workspace()` RETURNS A SHALLOW COPY: the outer dict is fresh but each
|
| 572 |
+
# view VALUE is a live reference into the cached store document. Mutating one in place
|
| 573 |
+
# would poison the cache every other reader shares and could be written back. So a
|
| 574 |
+
# marked view is REPLACED with a copy; unmarked ones stay the same references they
|
| 575 |
+
# were, and nothing here is ever persisted (the `view_upsert` save path builds its
|
| 576 |
+
# record from a fixed key whitelist, so these stamps cannot survive a round trip).
|
| 577 |
+
# The `shared` leg is copied at the stamp for the same reason, rather than trusting
|
| 578 |
+
# `shared_views`' own `dict(v)` from a distance.
|
| 579 |
+
#
|
| 580 |
+
# β 4. THE `__shared__` LEG IS NOT OPTIONAL, and it is the corner leg 1 cannot reach.
|
| 581 |
+
# `merged.update(shared)` below OUTRANKS the stamped `granted` copy, so a receiver's
|
| 582 |
+
# mark would be overwritten on the way through; and the OWNER of such a view has no
|
| 583 |
+
# copy in `ws['views']` at all, because `save_view` moves a collaborative/users view
|
| 584 |
+
# OUT of the personal stratum. Unmarked in EVERY account: instruction 2's exact
|
| 585 |
+
# defect, one corner over. β The merge PRECEDENCE is untouched β stamping the copy
|
| 586 |
+
# that wins is not re-arbitrating which copy wins.
|
| 587 |
+
#
|
| 588 |
+
# `hasShares` is the marker, NOT `shared`: the client reads `view.shared` as "granted to
|
| 589 |
+
# ME" in two live places (it gates `mayEditView` and it groups the "Shared with me"
|
| 590 |
+
# section), so re-using that key would take the owner's own view away from them.
|
| 591 |
+
# `sharedOut` says WHO is doing the sharing β always true on the caller's own stratum, and
|
| 592 |
+
# on the `__shared__` leg only when the record's `createdBy` is this caller. It is what
|
| 593 |
+
# lets the client word the owner's tooltip as sharing OUT rather than re-using the
|
| 594 |
+
# receiver-worded copy, which C1 forbids.
|
| 595 |
+
# Absence is the negative: an unmarked view is left alone rather than stamped False.
|
| 596 |
+
try:
|
| 597 |
+
_has_grants = _grant_marker(ctx, ws) if (ws.get('views') or shared) else None
|
| 598 |
+
except Exception as _me:
|
| 599 |
+
# A share mark is DECORATION. It must never be the thing that takes down a workspace
|
| 600 |
+
# read, so it fails the way its two siblings above do: log and carry on unmarked.
|
| 601 |
+
_tel.error('sharedviews:marks', _me)
|
| 602 |
+
_has_grants = None
|
| 603 |
+
if _has_grants:
|
| 604 |
+
ws['views'] = {
|
| 605 |
+
vid: ({**v, 'hasShares': True, 'sharedOut': True}
|
| 606 |
+
if isinstance(v, dict) and _has_grants(vid) else v)
|
| 607 |
+
for vid, v in (ws.get('views') or {}).items()}
|
| 608 |
+
if shared:
|
| 609 |
+
shared = {
|
| 610 |
+
vid: ({**v, 'hasShares': True,
|
| 611 |
+
**({'sharedOut': True} if v.get('createdBy') == uname else {})}
|
| 612 |
+
if isinstance(v, dict) and _has_grants(vid) else v)
|
| 613 |
+
for vid, v in shared.items()}
|
| 614 |
if shared or granted:
|
| 615 |
merged = dict(granted)
|
| 616 |
merged.update(shared) # the everyone-bucket outranks a grant
|
|
|
|
| 632 |
The R10 registry stores bare ids, tenant-scoped through the SAME store handle this topic's
|
| 633 |
bucket uses; the record itself is fetched out of the OWNER's personal stratum of THIS
|
| 634 |
bucket. An id granted on another topic simply finds nothing here and contributes nothing
|
| 635 |
+
(fail-closed). Each projected view is stamped `shared` / `sharedRole` / `owner` / `hasShares`
|
| 636 |
+
so the client can synthesise the "Shared with me" group and disable edit affordances for
|
| 637 |
role=view β the stamps live on the PROJECTION only, never written back to the store.
|
| 638 |
+
`hasShares` (W40-T01, contract C1) is the viewer-INDEPENDENT one: `shared` still means
|
| 639 |
+
"granted to me" and only ever appears here, while `hasShares` means "this view has grants"
|
| 640 |
+
and is stamped on ALL THREE of `table_workspace`'s merge legs β this one, the caller's own
|
| 641 |
+
stratum, and the `__shared__` bucket β from the single predicate `_grant_marker`.
|
| 642 |
+
β A view in BOTH this projection and the `__shared__` bucket keeps the bucket's copy, because
|
| 643 |
+
`merged.update(shared)` outranks it there; that copy is stamped on its own leg, which is why
|
| 644 |
+
stamping here is not sufficient on its own.
|
| 645 |
`role_for` is asked with is_admin=False deliberately: the stamp reports the GRANT (the
|
| 646 |
registry listed only explicit entries), not the caller's rank.
|
| 647 |
"""
|
|
|
|
| 664 |
v['shared'] = True
|
| 665 |
v['sharedRole'] = role
|
| 666 |
v['owner'] = owner
|
| 667 |
+
# β W40-T01 (C1): the RECEIVER's half of the one marker both sides now carry. `shared`
|
| 668 |
+
# keeps its old meaning here β "granted to ME" β because the client still reads it that
|
| 669 |
+
# way; `hasShares` is the viewer-independent fact underneath it, and stamping it on this
|
| 670 |
+
# leg too is what lets the client draw ONE mark from ONE key instead of branching on who
|
| 671 |
+
# is looking. No `sharedOut`: this account is not the one sharing it.
|
| 672 |
+
v['hasShares'] = True
|
| 673 |
out[str(vid)] = v
|
| 674 |
|
| 675 |
# β D-37 (2026-08-05) β THE FOLDER LEG. W20's R10 said "a folder share = its views ride
|
|
|
|
| 704 |
v['shared'] = True
|
| 705 |
v['sharedRole'] = role
|
| 706 |
v['owner'] = owner
|
| 707 |
+
v['hasShares'] = True # W40-T01 (C1) β the folder pass carries it too, or a
|
| 708 |
+
# folder share would still be marked on one side only
|
| 709 |
# The folder's NAME rides so the client can group these together later; today it
|
| 710 |
# renders in the same "Shared with me" group the view leg feeds. Stamps live on the
|
| 711 |
# PROJECTION only and are never written back, exactly as above.
|
platform/core/perm_scope.py
CHANGED
|
@@ -274,6 +274,45 @@ def field_grant_hidden(user, table_key, fields, st=None):
|
|
| 274 |
return hide
|
| 275 |
|
| 276 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 277 |
def hidden_keys(user, module, fields, st=None):
|
| 278 |
"""The TRANSITIVE closure of hidden field keys (C-PERM amendment 5).
|
| 279 |
|
|
@@ -328,6 +367,33 @@ def hidden_keys(user, module, fields, st=None):
|
|
| 328 |
hidden |= {str(k) for k in (e.get('hiddenFields') or ()) if k}
|
| 329 |
if not hidden:
|
| 330 |
return frozenset()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 331 |
|
| 332 |
refs = {}
|
| 333 |
for f in fields or ():
|
|
@@ -378,6 +444,13 @@ def assistant_visible_fields(fields, user, module):
|
|
| 378 |
hidden = {str(k) for k in (e.get('hiddenFields') or ()) if k}
|
| 379 |
if not hidden:
|
| 380 |
return list(fields or ())
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 381 |
|
| 382 |
refs = {}
|
| 383 |
for field in fields or ():
|
|
@@ -408,13 +481,225 @@ def strip_row(row, hide):
|
|
| 408 |
return {k: v for k, v in row.items() if k not in hide}
|
| 409 |
|
| 410 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 411 |
# ββ ROWS βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 412 |
-
def
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 413 |
"""The rows this account may receive: `filter_eval.permits` over the permanent filter.
|
| 414 |
|
| 415 |
`permits`, never `matches` β an unanswerable permanent filter DENIES rather than being
|
| 416 |
ignored. See `harness/filter_eval`'s docstring for the field-rename walkthrough that makes
|
| 417 |
the difference a leak rather than a preference.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 418 |
"""
|
| 419 |
if perms.is_admin(user):
|
| 420 |
return list(rows or ())
|
|
@@ -423,11 +708,48 @@ def apply_row_scope(rows, user, module, fields, ctx=None):
|
|
| 423 |
if not tree:
|
| 424 |
return list(rows or ())
|
| 425 |
from harness import filter_eval as fe
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 426 |
return [r for r in (rows or ()) if fe.permits(tree, r, fields, ctx)]
|
| 427 |
|
| 428 |
|
| 429 |
-
def assistant_apply_row_scope(rows, user, module, fields, ctx=None):
|
| 430 |
-
"""Apply an explicit Assistant grant's permanent filter without an admin bypass.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 431 |
e = assistant_entry(user, module)
|
| 432 |
if e is None:
|
| 433 |
return []
|
|
@@ -435,6 +757,21 @@ def assistant_apply_row_scope(rows, user, module, fields, ctx=None):
|
|
| 435 |
if not tree:
|
| 436 |
return list(rows or ())
|
| 437 |
from harness import filter_eval as fe
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 438 |
return [row for row in (rows or ()) if fe.permits(tree, row, fields, ctx)]
|
| 439 |
|
| 440 |
|
|
@@ -509,6 +846,284 @@ def validate_assistant_filter(tree, fields):
|
|
| 509 |
return {'conj': tree['conj'], 'nodes': [_node(node) for node in nodes]}
|
| 510 |
|
| 511 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 512 |
# ββ THE PUSHDOWN βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 513 |
#: `dba` value sets that pin a BU, and the Odoo team they pin. `_dba_attrs` emits exactly
|
| 514 |
#: {'Fisch','Royal','Both'} (blank for "no brand attributable in 24 months"), so a permission
|
|
@@ -926,7 +1541,12 @@ def _scoped(user, table_key, st=None, ctx=None, want_rows=True):
|
|
| 926 |
# rather than being ignored. Evaluated against the UNSTRIPPED contract on purpose: a
|
| 927 |
# permanent filter may name a column the reader is not allowed to SEE, and dropping the
|
| 928 |
# predicate would widen the read rather than narrow it.
|
| 929 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 930 |
if hide:
|
| 931 |
fields = visible_fields(fields, user, key, st=st)
|
| 932 |
rows = [strip_row(r, hide) for r in rows]
|
|
|
|
| 274 |
return hide
|
| 275 |
|
| 276 |
|
| 277 |
+
def _measure_bound_keys(hidden, fields):
|
| 278 |
+
"""Every column BOUND to a measure whose `measure_<key>` pseudo-field is in `hidden`.
|
| 279 |
+
|
| 280 |
+
β THE PREFIX IS IMPORTED, NEVER SPELLED. `aios_grid.MEASURE_FIELD_PREFIX` is the one
|
| 281 |
+
constant the client's `createField`, the host's `clean_measure_field` and now this wall all
|
| 282 |
+
key off; a literal "measure_" here would be the third copy, and the first to drift
|
| 283 |
+
[[constant-two-features-share]]. The import is lazy and function-local, which is the
|
| 284 |
+
established shape in this layer (`core/grid_events.py`, `core/user_tables.py` both do it) and
|
| 285 |
+
keeps `core` from pulling the grid module at import time.
|
| 286 |
+
|
| 287 |
+
β CHEAP FIRST. Called only once `hidden` is already non-empty, and it returns on an empty
|
| 288 |
+
`wanted` before touching `fields` β so a wall with no metric tick costs one set
|
| 289 |
+
comprehension over a handful of strings, on a function that runs at every grid door.
|
| 290 |
+
|
| 291 |
+
β A FAILED IMPORT HIDES NOTHING EXTRA RATHER THAN TAKING THE DOOR DOWN, matching
|
| 292 |
+
`field_grant_hidden`'s treatment of an unreachable `core.shares`. The direction is stated
|
| 293 |
+
because it is the unsafe one: this leg only ever WIDENS the hidden set, so losing it
|
| 294 |
+
under-hides β visible, reportable, and the symptom is a metric column that should have
|
| 295 |
+
been walled, not a database that will not open.
|
| 296 |
+
"""
|
| 297 |
+
try:
|
| 298 |
+
import aios_grid as _agm
|
| 299 |
+
prefix = _agm.MEASURE_FIELD_PREFIX
|
| 300 |
+
except Exception: # noqa: BLE001
|
| 301 |
+
return set()
|
| 302 |
+
wanted = {h[len(prefix):] for h in hidden
|
| 303 |
+
if isinstance(h, str) and h.startswith(prefix) and len(h) > len(prefix)}
|
| 304 |
+
if not wanted:
|
| 305 |
+
return set()
|
| 306 |
+
out = set()
|
| 307 |
+
for f in fields or ():
|
| 308 |
+
if not isinstance(f, dict) or not f.get('key'):
|
| 309 |
+
continue
|
| 310 |
+
spec = f.get('measure')
|
| 311 |
+
if isinstance(spec, dict) and str(spec.get('key') or '') in wanted:
|
| 312 |
+
out.add(str(f['key']))
|
| 313 |
+
return out
|
| 314 |
+
|
| 315 |
+
|
| 316 |
def hidden_keys(user, module, fields, st=None):
|
| 317 |
"""The TRANSITIVE closure of hidden field keys (C-PERM amendment 5).
|
| 318 |
|
|
|
|
| 367 |
hidden |= {str(k) for k in (e.get('hiddenFields') or ()) if k}
|
| 368 |
if not hidden:
|
| 369 |
return frozenset()
|
| 370 |
+
# ββ W40-T04 / I13 β A THIRD SOURCE, SEEDED BEFORE THE FIXPOINT FOR THE SAME REASON THE
|
| 371 |
+
# OTHER TWO ARE, AND IT IS WHAT MAKES THE NEW CHECKBOX ENFORCE ANYTHING.
|
| 372 |
+
#
|
| 373 |
+
# The permission editor now offers one `measure_`-namespaced PSEUDO-field per bound measure
|
| 374 |
+
# (`routes_admin._metric_fields`), so an administrator can tick "Metric - Gross margin $" and
|
| 375 |
+
# the wall stores `hiddenFields: ['measure_margin']`. But the COLUMNS that carry that number
|
| 376 |
+
# are keyed `measure_<slug>_<rand>` by `CustomerGrid.createField` β `measure_margin_a1b2`,
|
| 377 |
+
# not `measure_margin` β and the seeding above compares KEYS. Without this line the box
|
| 378 |
+
# ticks, the record saves, every gate stays green and the reader keeps every gross-margin
|
| 379 |
+
# column on the grid. I13's own words are *"so a user can check the ones the permissioning is
|
| 380 |
+
# LIMITED TO"*; a control that limits nothing is the failure
|
| 381 |
+
# `verify_ui.py::metrics_toggle_has_a_mount_site` exists because of.
|
| 382 |
+
#
|
| 383 |
+
# β SO THE JOIN IS ON THE BINDING, NOT THE KEY: a hidden `measure_<mkey>` hides every column
|
| 384 |
+
# whose `measure.key` IS `<mkey>`, which is the same spec `aios_grid.clean_measure_field`
|
| 385 |
+
# wrote and `measure_fields_of` reads. One measure, however many windows a user minted over
|
| 386 |
+
# it, all walled by one tick.
|
| 387 |
+
#
|
| 388 |
+
# β ADDITIVE, NEVER SUBSTITUTIVE. The pseudo-key stays in `hidden` on its own account, so a
|
| 389 |
+
# real column that happens to be keyed exactly `measure_margin` is hidden exactly as before
|
| 390 |
+
# and nothing depends on the pseudo-field existing.
|
| 391 |
+
#
|
| 392 |
+
# β AND IT GOES HERE, ABOVE THE FIXPOINT, so the transitive argument this docstring already
|
| 393 |
+
# makes covers it unchanged: a FORMULA over a walled metric column, or a ROLLUP whose link is
|
| 394 |
+
# one, comes out with it. Seeded after the loop it would leak through the derived column,
|
| 395 |
+
# which is outcome two of the three the docstring enumerates.
|
| 396 |
+
hidden |= _measure_bound_keys(hidden, fields)
|
| 397 |
|
| 398 |
refs = {}
|
| 399 |
for f in fields or ():
|
|
|
|
| 444 |
hidden = {str(k) for k in (e.get('hiddenFields') or ()) if k}
|
| 445 |
if not hidden:
|
| 446 |
return list(fields or ())
|
| 447 |
+
# ββ THE SAME LEAK ONE DOOR OVER, AND IT IS THE SAME `hiddenFields`. `assistant_entry`
|
| 448 |
+
# returns the very dict `entry()` does, so once the permission editor can store
|
| 449 |
+
# `measure_margin` the Assistant's grant carries it too β and comparing KEYS would leave
|
| 450 |
+
# `measure_gross_profit_a1b2` in the snapshot this reader is handed. Seeded here for the
|
| 451 |
+
# identical reason and at the identical point as in `hidden_keys`: before the fixpoint, so a
|
| 452 |
+
# formula over a walled metric column comes out with it.
|
| 453 |
+
hidden |= _measure_bound_keys(hidden, fields)
|
| 454 |
|
| 455 |
refs = {}
|
| 456 |
for field in fields or ():
|
|
|
|
| 481 |
return {k: v for k, v in row.items() if k not in hide}
|
| 482 |
|
| 483 |
|
| 484 |
+
def visible_overlays(overlays, user, module, fields, st=None):
|
| 485 |
+
"""The overlay CELL MAP minus every column this reader may not receive β D-427.
|
| 486 |
+
|
| 487 |
+
ββ THE THIRD WIRE, AND IT CARRIES THE RAW VALUE. `strip_row`'s own docstring makes the
|
| 488 |
+
argument for two wires: *"the field list and the row payload are two different wires, and
|
| 489 |
+
stripping only the first would leave the value sitting in the second where anyone can read
|
| 490 |
+
it."* There is a THIRD. `/workspace?scope=product` serves
|
| 491 |
+
`workspace["overlays"] = g["ws"].get("overlays")` verbatim β the persisted user/tenant
|
| 492 |
+
stratum, keyed `{row id: {field key: value}}` β and that assignment never asks who is
|
| 493 |
+
reading. So an administrator hides `first_cost`, the grid dutifully drops the column and the
|
| 494 |
+
cell, and the same number is still sitting in the workspace payload under the same key. The
|
| 495 |
+
wall holds on two wires out of three, which is not a wall.
|
| 496 |
+
|
| 497 |
+
β WHY THIS LIVES HERE RATHER THAN AT THE DOORS. `hidden_keys` is already the ONE evaluator
|
| 498 |
+
every grid door calls, and the three leaking assignments are one line each in three files.
|
| 499 |
+
Putting the narrowing beside `strip_row` means the fix at each door is a single call to the
|
| 500 |
+
module that already owns the question, instead of a fourth place that decides what a reader
|
| 501 |
+
may see. A second idea of who hides what is the failure `may_open`'s own note records.
|
| 502 |
+
|
| 503 |
+
β SAME ARGUMENT ORDER AS `visible_fields`, deliberately: a door that already narrows its
|
| 504 |
+
field list has the four values to hand, and `st` MUST be the same handle it passed there.
|
| 505 |
+
The field-grant leg under-hides without a tenant handle, so a door that lends one to
|
| 506 |
+
`visible_fields` and not to this would strip the COLUMN while leaving the overlay VALUE β
|
| 507 |
+
the half-wall this function exists to close, re-created by the fix for it.
|
| 508 |
+
|
| 509 |
+
β NON-DESTRUCTIVE. A new dict is built rather than the caller's mutated, because the same
|
| 510 |
+
overlay object is read again by `rows_from_pool` on the assembly path; and the input is
|
| 511 |
+
returned untouched when nothing is hidden, so a database with no wall pays one set test.
|
| 512 |
+
"""
|
| 513 |
+
hide = hidden_keys(user, module, fields, st=st)
|
| 514 |
+
if not hide or not isinstance(overlays, dict):
|
| 515 |
+
return overlays
|
| 516 |
+
return {rid: strip_row(cells, hide) if isinstance(cells, dict) else cells
|
| 517 |
+
for rid, cells in overlays.items()}
|
| 518 |
+
|
| 519 |
+
|
| 520 |
# ββ ROWS βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 521 |
+
def _wall_leaf_keys(nodes):
|
| 522 |
+
"""Every `colId` a filter tree names, at any depth. Groups carry `children`; leaves do not.
|
| 523 |
+
|
| 524 |
+
β THE SAME WALK AS `routes_admin._leaf_col_ids`, and the duplication is deliberate rather
|
| 525 |
+
than lazy: that one runs at the ADMIN DOOR inside the API package, this one runs in `core`
|
| 526 |
+
on the request path, and `core` never imports up (see `platform/ARCHITECTURE.md`). The two
|
| 527 |
+
are three lines each and `verify_api` asserts they answer the same set on the same tree, so
|
| 528 |
+
a grammar change cannot land in one and not the other. That equality is the point: the door
|
| 529 |
+
refuses through one walk and the wall resolves through the other, and a wall the editor
|
| 530 |
+
accepts but the enforcement path cannot see is the defect this whole change is about.
|
| 531 |
+
|
| 532 |
+
β AN `rhs` COLUMN IS NOT COLLECTED, MATCHING `_leaf_col_ids` AND FAILING CLOSED. A
|
| 533 |
+
column-to-column leaf whose RIGHT side is a user-generated column stays unenriched, so
|
| 534 |
+
`is_rule_active` finds that side outside the contract, calls the rule inactive, and strict
|
| 535 |
+
mode turns that into a DENY. That is the safe answer, and it is the same one this door gave
|
| 536 |
+
before the enrichment existed. `prune_filter_to_fields` does walk `rhs`, deliberately, and
|
| 537 |
+
the asymmetry is the direction each function fails in: deleting a leaf WIDENS a wall, so
|
| 538 |
+
that one must see every column a leaf names; refusing to enrich one only narrows.
|
| 539 |
+
"""
|
| 540 |
+
found = set()
|
| 541 |
+
for node in nodes or ():
|
| 542 |
+
if not isinstance(node, dict):
|
| 543 |
+
continue
|
| 544 |
+
if isinstance(node.get('children'), list):
|
| 545 |
+
found |= _wall_leaf_keys(node['children'])
|
| 546 |
+
elif node.get('colId'):
|
| 547 |
+
found.add(str(node['colId']))
|
| 548 |
+
return found
|
| 549 |
+
|
| 550 |
+
|
| 551 |
+
def _enrich_for_wall(tree, rows, fields, module, st):
|
| 552 |
+
"""`(rows, fields)` β the same wall inputs, plus any USER-GENERATED column this wall names
|
| 553 |
+
that the SERVER can actually answer. Owner I16, the half `ut_*` got for free.
|
| 554 |
+
|
| 555 |
+
ββ THE DEFECT. On the two Odoo topic grids the wall runs as
|
| 556 |
+
`apply_row_scope(rows, user, MODULE, <the STATIC contract>)` over PRE-OVERLAY rows, so a
|
| 557 |
+
column a user created is neither declared in that field list nor present on the row β and
|
| 558 |
+
`filter_eval.permits` DENIES every leaf it cannot answer. Measured four ways on the
|
| 559 |
+
integrated head, one leaf `{colId: <a user column>, op: eq, value: West}`, two rows:
|
| 560 |
+
|
| 561 |
+
static contract + pre-overlay rows (THE LIVE CALL SITE) -> [] every row denied
|
| 562 |
+
column declared + rows carrying the value -> ['1'] correct
|
| 563 |
+
column declared + pre-overlay rows -> []
|
| 564 |
+
a DECLARED odoo column, same shape -> ['1'] the evaluator is fine
|
| 565 |
+
|
| 566 |
+
So the administrator saves a rule, is told it saved, and that account opens an empty grid
|
| 567 |
+
with nothing on screen saying why. BOTH halves are needed and neither alone does anything,
|
| 568 |
+
which is why this function supplies both from one read.
|
| 569 |
+
|
| 570 |
+
ββ IT MAY ONLY EVER ADD THE ABILITY TO ANSWER β IT MUST NEVER ADMIT A ROW THE WALL WOULD
|
| 571 |
+
OTHERWISE REFUSE. That is why `wallable_overlay_keys` is defined as *the keys whose values
|
| 572 |
+
the very `cells` read below serves*, and not as "every overlay column". Merge a blank for a
|
| 573 |
+
key this store cannot really answer and `custom_x is not West` flips from denying every row
|
| 574 |
+
(undeclared leaf) to admitting every row (`'' != 'West'`), with `is empty` doing the same β
|
| 575 |
+
a silent widening wearing the shape of a fix. The set and the values come from ONE stratum
|
| 576 |
+
so they cannot disagree about what is answerable.
|
| 577 |
+
|
| 578 |
+
β AND THE WHOLE THING IS WRAPPED FAIL-CLOSED. On ANY failure the caller's own `rows` and
|
| 579 |
+
`fields` come back untouched and `permits` denies exactly as it does today. A wall that
|
| 580 |
+
cannot be enriched is a wall that keeps refusing, never one that opens.
|
| 581 |
+
|
| 582 |
+
β THE ORDER IS A COST DECISION, NOT A STYLE ONE. `missing` is answered from the tree and the
|
| 583 |
+
field list already in memory, and an empty `missing` returns BEFORE `wallable_overlay_keys`
|
| 584 |
+
is called β so a wall naming only declared columns (every wall that exists today) pays one
|
| 585 |
+
set difference and reaches no store at all.
|
| 586 |
+
"""
|
| 587 |
+
try:
|
| 588 |
+
from harness import filter_eval as fe
|
| 589 |
+
# β `tree_parts`, NEVER `tree['nodes']`. A `FilterTree` is a PAIR and a BARE LIST is also
|
| 590 |
+
# a legal shape (C-PERM amendment 2); a second reader of it here would answer "no leaves"
|
| 591 |
+
# for a wall the evaluator one line down reads perfectly well.
|
| 592 |
+
nodes, _conj = fe.tree_parts(tree)
|
| 593 |
+
leaves = _wall_leaf_keys(nodes)
|
| 594 |
+
if not leaves:
|
| 595 |
+
return rows, fields, frozenset()
|
| 596 |
+
declared = {str(f['key']) for f in (fields or ())
|
| 597 |
+
if isinstance(f, dict) and f.get('key')}
|
| 598 |
+
missing = leaves - declared
|
| 599 |
+
if not missing:
|
| 600 |
+
return rows, fields, frozenset() # nothing to add β the common case, and it is free
|
| 601 |
+
resolvable = missing
|
| 602 |
+
if not resolvable: # unreachable as written: `missing` is non-empty three lines up.
|
| 603 |
+
# Kept as the SHAPE of the guard, because `resolvable` is narrowed AGAIN below once
|
| 604 |
+
# the snapshot says what is actually answerable, and that narrowing can empty it.
|
| 605 |
+
# A wall naming a column NOTHING here can answer still denies, which is the whole
|
| 606 |
+
# point of `permits`. Enrichment is not a licence to ignore an unanswerable leaf.
|
| 607 |
+
return rows, fields, frozenset()
|
| 608 |
+
import core.shared_overlay as so
|
| 609 |
+
import core.view_templates as vt
|
| 610 |
+
ws_key = vt.workspace_key(str(module or ''))
|
| 611 |
+
if not ws_key:
|
| 612 |
+
return rows, fields, frozenset()
|
| 613 |
+
source = list(rows or ())
|
| 614 |
+
# β THE ROW'S CELL KEY IS DERIVED BY `shared_overlay`'s OWN RULE, `str(int(pid))`, and
|
| 615 |
+
# not by `str(pid)`. That is the one coercion the stratum has (pids are ints in the grid
|
| 616 |
+
# and strings in JSON), so a second spelling here would look up `'1.0'` in a document
|
| 617 |
+
# keyed `'1'` and merge a blank over a value that is right there. It also RAISES on a
|
| 618 |
+
# pid-less or non-numeric row: a `cells` call carrying one would fail the whole request
|
| 619 |
+
# CLOSED, i.e. disable the fix silently for every other row rather than going red, so
|
| 620 |
+
# such a row is simply given the blank instead.
|
| 621 |
+
keys = {}
|
| 622 |
+
for i, r in enumerate(source):
|
| 623 |
+
if not isinstance(r, dict):
|
| 624 |
+
continue
|
| 625 |
+
try:
|
| 626 |
+
keys[i] = str(int(r.get('pid')))
|
| 627 |
+
except (TypeError, ValueError):
|
| 628 |
+
continue
|
| 629 |
+
# ββ ONE READ FOR THE WHOLE PAGE, AND FOR BOTH HALVES OF THE QUESTION. `snapshot`
|
| 630 |
+
# returns the shared stratum's SCHEMA and its CELLS from a single `st.get`, and it
|
| 631 |
+
# refuses an "everything" read by signature, so the row set handed in IS the bound.
|
| 632 |
+
#
|
| 633 |
+
# ββ THE TWO HALVES MUST COME FROM ONE SNAPSHOT, AND THIS USED TO BE TWO READS. A
|
| 634 |
+
# wave-40 adversarial probe drove the gap: with the second read returning an emptied
|
| 635 |
+
# `cells`, a blank is merged for a key the store cannot really serve, and
|
| 636 |
+
# `custom_x is not West` flips from denying every row to ADMITTING a row whose true
|
| 637 |
+
# value IS West. `is empty` does the same. Narrow under today's cache-first store and
|
| 638 |
+
# structurally real under a threaded server, so it is closed by construction rather
|
| 639 |
+
# than by being unlikely.
|
| 640 |
+
_defs, cells = so.snapshot(ws_key, list(keys.values()), st=st)
|
| 641 |
+
wallable = wallable_overlay_keys(module, st=st, defs=_defs)
|
| 642 |
+
resolvable = resolvable & set(wallable)
|
| 643 |
+
if not resolvable:
|
| 644 |
+
return rows, fields, frozenset()
|
| 645 |
+
merged, denied = [], []
|
| 646 |
+
for i, r in enumerate(source):
|
| 647 |
+
if not isinstance(r, dict):
|
| 648 |
+
merged.append(r)
|
| 649 |
+
continue
|
| 650 |
+
if i not in keys:
|
| 651 |
+
# ββ A ROW WHOSE `pid` DOES NOT RESOLVE GETS NOTHING MERGED, AND THAT IS THE
|
| 652 |
+
# WHOLE POINT. `keys` holds only indices whose pid survived `str(int(pid))`; for
|
| 653 |
+
# any other row the store was never asked, so its value is UNKNOWN -- a different
|
| 654 |
+
# thing from the legitimately blank cell a real pid with no stored value has.
|
| 655 |
+
# Merging `''` for it hands `is not X` and `is empty` a FABRICATION and treats it
|
| 656 |
+
# as ground truth: a wave-40 adversarial probe drove exactly that, admitting a
|
| 657 |
+
# no-pid row under `is not West`, and a non-numeric-pid row under `less than 5`
|
| 658 |
+
# on a numeric column -- both of which the un-enriched wall refuses. Leaving the
|
| 659 |
+
# key off keeps the leaf unanswerable, so `permits` denies.
|
| 660 |
+
#
|
| 661 |
+
# β Not reachable through either registered reader today: `customer_data` and
|
| 662 |
+
# `product_data` both emit integer Odoo ids. Fixed because the invariant this
|
| 663 |
+
# function states is UNCONDITIONAL, not because it happened to be reachable.
|
| 664 |
+
# β DENIED, not merely un-merged. Leaving the key off the row is NOT
|
| 665 |
+
# enough: `wall_fields` DECLARES the column, and `permits` reads a declared
|
| 666 |
+
# field whose key is absent from the row as BLANK -- the same fabrication one
|
| 667 |
+
# level down, and measured doing exactly that. The index is recorded and the
|
| 668 |
+
# door drops the row outright.
|
| 669 |
+
merged.append(r)
|
| 670 |
+
denied.append(i)
|
| 671 |
+
continue
|
| 672 |
+
row_cells = cells.get(keys[i]) or {}
|
| 673 |
+
# A COPY, never the caller's dict mutated. These rows are the pool the tenant
|
| 674 |
+
# runtime caches and hands to every other consumer on the request (the workspace,
|
| 675 |
+
# the cohorts, the measures); writing a wall's working value into them would put a
|
| 676 |
+
# column on a payload nobody asked for it on.
|
| 677 |
+
merged.append(dict(r, **{k: row_cells.get(k, '') for k in resolvable}))
|
| 678 |
+
return (merged, list(fields or ()) + [wallable[k] for k in resolvable],
|
| 679 |
+
frozenset(denied))
|
| 680 |
+
except Exception: # noqa: BLE001
|
| 681 |
+
return rows, fields, frozenset()
|
| 682 |
+
|
| 683 |
+
|
| 684 |
+
def apply_row_scope(rows, user, module, fields, ctx=None, st=None):
|
| 685 |
"""The rows this account may receive: `filter_eval.permits` over the permanent filter.
|
| 686 |
|
| 687 |
`permits`, never `matches` β an unanswerable permanent filter DENIES rather than being
|
| 688 |
ignored. See `harness/filter_eval`'s docstring for the field-rename walkthrough that makes
|
| 689 |
the difference a leak rather than a preference.
|
| 690 |
+
|
| 691 |
+
ββ `st` IS OWNER I16's SECOND HALF AND IT IS OPTIONAL SO THE FIRST HALF CANNOT MOVE.
|
| 692 |
+
*"Permission Filters must be able to filter on user-generated Fields too."* With a tenant
|
| 693 |
+
handle this door can resolve a user-generated column the static contract does not declare
|
| 694 |
+
(see `_enrich_for_wall`); WITHOUT one it is byte-identical to the wall that shipped before
|
| 695 |
+
this parameter existed, which is what keeps a cold process β a gate, a worker, E's sandbox β
|
| 696 |
+
behaving exactly as it always has.
|
| 697 |
+
|
| 698 |
+
β PASS IT AT EVERY DOOR THAT WALLS A TOPIC GRID, OR AT NONE OF THEM. One stored wall read
|
| 699 |
+
through a door that lends the handle and a door that does not is one rule with two meanings,
|
| 700 |
+
which is worse than a uniform refusal: `allowed_pids` is the WRITE wall and `grid_assembly`
|
| 701 |
+
the READ one, and a user who may PATCH a row they cannot SEE is the hole
|
| 702 |
+
`allowed_pids`' own docstring exists to close.
|
| 703 |
"""
|
| 704 |
if perms.is_admin(user):
|
| 705 |
return list(rows or ())
|
|
|
|
| 708 |
if not tree:
|
| 709 |
return list(rows or ())
|
| 710 |
from harness import filter_eval as fe
|
| 711 |
+
if st is not None:
|
| 712 |
+
# ββ THE ENRICHMENT ANSWERS THE WALL AND MUST NEVER REACH A CALLER. It merges a
|
| 713 |
+
# column's value onto a COPY of each row so `permits` can evaluate a leaf naming it;
|
| 714 |
+
# returning those copies hands every consumer a column the caller's own field list
|
| 715 |
+
# does not declare. Measured in wave-40 QA against `core/script_sandbox.py`, which
|
| 716 |
+
# passes `scoped_table()`'s rows straight to a user-authored script:
|
| 717 |
+
#
|
| 718 |
+
# scoped_fields() declared keys: ['dba']
|
| 719 |
+
# scoped_table() returned rows : [{'pid': 2, 'dba': 'Fisch',
|
| 720 |
+
# 'custom_region_qa': 'TOP-SECRET-VALUE'}]
|
| 721 |
+
#
|
| 722 |
+
# reachable by any ordinary session through `POST /script-views/{id}/run`. And the
|
| 723 |
+
# field-grant hide could never have caught it: `field_grant_hidden` can only mark a
|
| 724 |
+
# key already present in the `fields` it is handed, and this key never is.
|
| 725 |
+
#
|
| 726 |
+
# β So the decision is made on the enriched copy and the ORIGINAL row is what
|
| 727 |
+
# survives. `_enrich_for_wall` returns one entry per input row, in order, which is
|
| 728 |
+
# what makes the pairing sound; the copy is ONLY ever an argument to `permits`.
|
| 729 |
+
# β A length disagreement means the enrichment did not do what it promises, so the
|
| 730 |
+
# fall-through is the UN-enriched wall, which denies. Never the enriched rows.
|
| 731 |
+
# β MATERIALISED BEFORE THE ENRICHMENT SEES IT. `rows` may be any iterable, and
|
| 732 |
+
# `_enrich_for_wall` has three early-return paths that hand it straight back -- so a
|
| 733 |
+
# GENERATOR reached `len(judged)` and raised `TypeError: object of type 'generator' has
|
| 734 |
+
# no len()` on the common wall (one naming only declared columns), or, when enrichment
|
| 735 |
+
# did run, left the outer generator exhausted and the length check comparing against
|
| 736 |
+
# zero. Both fail closed, but one is a crash and the other a silent empty answer. One
|
| 737 |
+
# `list()` removes the class. Found by a wave-40 adversarial probe.
|
| 738 |
+
source = list(rows or ())
|
| 739 |
+
judged, wall_fields, denied = _enrich_for_wall(tree, source, fields, module, st)
|
| 740 |
+
if len(judged) == len(source):
|
| 741 |
+
return [orig for i, (orig, seen) in enumerate(zip(source, judged))
|
| 742 |
+
if i not in denied and fe.permits(tree, seen, wall_fields, ctx)]
|
| 743 |
return [r for r in (rows or ()) if fe.permits(tree, r, fields, ctx)]
|
| 744 |
|
| 745 |
|
| 746 |
+
def assistant_apply_row_scope(rows, user, module, fields, ctx=None, st=None):
|
| 747 |
+
"""Apply an explicit Assistant grant's permanent filter without an admin bypass.
|
| 748 |
+
|
| 749 |
+
`st` carries the same meaning it does on `apply_row_scope`, for the same reason: an Assistant
|
| 750 |
+
grant is stored by the same editor, against the same vocabulary, and a wall that means one
|
| 751 |
+
thing on the grid and another in the Analyst's answer is two walls.
|
| 752 |
+
"""
|
| 753 |
e = assistant_entry(user, module)
|
| 754 |
if e is None:
|
| 755 |
return []
|
|
|
|
| 757 |
if not tree:
|
| 758 |
return list(rows or ())
|
| 759 |
from harness import filter_eval as fe
|
| 760 |
+
if st is not None:
|
| 761 |
+
# Same rule as `apply_row_scope`: judge on the copy, return the ORIGINAL. See the block
|
| 762 |
+
# there for the measured leak this prevents.
|
| 763 |
+
# β MATERIALISED BEFORE THE ENRICHMENT SEES IT. `rows` may be any iterable, and
|
| 764 |
+
# `_enrich_for_wall` has three early-return paths that hand it straight back -- so a
|
| 765 |
+
# GENERATOR reached `len(judged)` and raised `TypeError: object of type 'generator' has
|
| 766 |
+
# no len()` on the common wall (one naming only declared columns), or, when enrichment
|
| 767 |
+
# did run, left the outer generator exhausted and the length check comparing against
|
| 768 |
+
# zero. Both fail closed, but one is a crash and the other a silent empty answer. One
|
| 769 |
+
# `list()` removes the class. Found by a wave-40 adversarial probe.
|
| 770 |
+
source = list(rows or ())
|
| 771 |
+
judged, wall_fields, denied = _enrich_for_wall(tree, source, fields, module, st)
|
| 772 |
+
if len(judged) == len(source):
|
| 773 |
+
return [orig for i, (orig, seen) in enumerate(zip(source, judged))
|
| 774 |
+
if i not in denied and fe.permits(tree, seen, wall_fields, ctx)]
|
| 775 |
return [row for row in (rows or ()) if fe.permits(tree, row, fields, ctx)]
|
| 776 |
|
| 777 |
|
|
|
|
| 846 |
return {'conj': tree['conj'], 'nodes': [_node(node) for node in nodes]}
|
| 847 |
|
| 848 |
|
| 849 |
+
# ββ USER-GENERATED COLUMNS + THE FILTER CASCADE (W40-T05 / owner I16) ββββββββββββββββββββββββ
|
| 850 |
+
def user_generated_fields(module, st=None):
|
| 851 |
+
"""Every USER-CREATED column of `module`, across EVERY stratum -- or `None` when that
|
| 852 |
+
cannot be established.
|
| 853 |
+
|
| 854 |
+
ββ OWNER I16 β *"Permission Filters must be able to filter on user-generated Fields too.
|
| 855 |
+
If the field is deleted, its permission filter goes with it."* The permission editor built
|
| 856 |
+
its pickers from the STATIC contract (`aios_grid.FIELDS`, the product JSON), so a column a
|
| 857 |
+
USER made was invisible to the admin choosing what to filter on. This is the half that finds
|
| 858 |
+
them; `prune_filter_to_fields` below is the half that lets one go.
|
| 859 |
+
|
| 860 |
+
ββ `None` IS NOT `[]`, AND THE DIFFERENCE IS A SILENTLY WIDENED WALL. `[]` means
|
| 861 |
+
"resolved: this database has no user columns". `None` means "the vocabulary could not be
|
| 862 |
+
read". The cascade prunes a filter leaf naming a column that is NOT in this list, so a
|
| 863 |
+
DEGRADED answer would DELETE a live permission rule the moment the store was busy β
|
| 864 |
+
permanently, silently, and in the widening direction. Every unresolvable path therefore
|
| 865 |
+
answers `None` and every caller declines to prune on it. This is the GET/PUT skew
|
| 866 |
+
`routes_admin._clean_perms`' metric-tick note records one door over, except that there the
|
| 867 |
+
failure mode was a REFUSAL and here it would be a REVOCATION.
|
| 868 |
+
|
| 869 |
+
β THE UNION OF EVERY STRATUM, DELIBERATELY. `<key>_table_workspace` is
|
| 870 |
+
`{username: {views, fields, overlays}, '__shared__': {...}}` and a column lives in exactly
|
| 871 |
+
one of them. `_module_fields`' own docstring says this list is *"the admin choosing what to
|
| 872 |
+
hide"* and the SUBJECT USER IS NOT A PARAMETER OF IT, so a per-user read would make a column
|
| 873 |
+
unpickable for the very user who owns it.
|
| 874 |
+
|
| 875 |
+
ββ AND THE TENANT-WIDE STRATUM MOVED OUT OF THAT DOCUMENT, WHICH IS HOW "EVERY STRATUM"
|
| 876 |
+
STOPPED BEING TRUE. `core/shared_overlay.py`'s own RESIDENCY note says it: a SHARED column
|
| 877 |
+
lives in `<key>_table_workspace__shared`, *"its own bucket, beside the per-user one β never
|
| 878 |
+
a `__shared__` member"*, and `field_permissions.promote_field` POPS the definition out of
|
| 879 |
+
the creator's stratum once it is promoted. So the loop below, reading one document, saw
|
| 880 |
+
exactly the columns nobody had shared. Measured on the live tenant: 21 of the 22 custom
|
| 881 |
+
columns on these two grids carry `source: "overlay", shared: true` β i.e. the function
|
| 882 |
+
returned the ONE column it was least useful for.
|
| 883 |
+
|
| 884 |
+
β THE CONSEQUENCE WAS NOT A MISSING PICKER ROW, IT WAS A SILENT REVOCATION. This list is
|
| 885 |
+
also `routes_admin._prunable_vocabulary`'s answer, and `prune_filter_to_fields` DELETES a
|
| 886 |
+
leaf naming a column outside it. A wall stored against a shared column would therefore have
|
| 887 |
+
had its leaf pruned on the next read of the record β permanently, silently, and in the
|
| 888 |
+
widening direction, which is the exact failure the `None`-is-not-`[]` note above exists to
|
| 889 |
+
prevent, arriving through the door this function opens.
|
| 890 |
+
|
| 891 |
+
β A SHARED READ THAT RAISES ANSWERS `None`, LIKE THE PER-USER ONE; an ABSENT shared bucket
|
| 892 |
+
is "nothing has been shared here yet" and does NOT poison the answer. Both arms are
|
| 893 |
+
deliberate: the first keeps the vocabulary honest under contention, and the second is what
|
| 894 |
+
stops a tenant that has never shared a column from losing the per-user half of I16.
|
| 895 |
+
|
| 896 |
+
β THE BUCKET NAME IS `view_templates.workspace_key`, NEVER SPELLED. `customer_data`'s bucket
|
| 897 |
+
is `customer_table_workspace` β the module key is NOT the storage key β and `_WS_KEYS` is
|
| 898 |
+
already the one place that mapping lives ([[one-question-two-normalizers]]).
|
| 899 |
+
|
| 900 |
+
β THE SHAPE COMES FROM `aios_grid.fields_from_workspace`, NEVER HAND-BUILT. That is the
|
| 901 |
+
function the GRID overlays a saved stratum with, so a column reaches the permission editor
|
| 902 |
+
described exactly as the user sees it β including `filterable: False` on a `measure_` column,
|
| 903 |
+
whose value is host-computed into `derived` and never sits on a row. A hand-shaped dict here
|
| 904 |
+
would be a second idea of what a field is, and the first thing it would lose is that flag.
|
| 905 |
+
`fields_base=[]` makes the base loop a no-op, so what comes back is the SAVED stratum alone.
|
| 906 |
+
|
| 907 |
+
β `scope_key=None` DROPS A COHORT-SCOPED COLUMN, AND THAT IS THE ANSWER RATHER THAN A GAP.
|
| 908 |
+
`grid_events` writes `scope: 'cohort'` on a column created from the Cohort surface, and such
|
| 909 |
+
a column is not on the Customer grid's rows at all. Offering it to the permanent filter would
|
| 910 |
+
admit a leaf that can only ever DENY every row β the exact reason `_metric_fields` marks a
|
| 911 |
+
metric pseudo-field unfilterable. The narrow read is the honest one here.
|
| 912 |
+
"""
|
| 913 |
+
if st is None:
|
| 914 |
+
return None
|
| 915 |
+
try:
|
| 916 |
+
import aios_grid
|
| 917 |
+
import core.shared_overlay as shared_overlay
|
| 918 |
+
import core.view_templates as view_templates
|
| 919 |
+
except Exception: # noqa: BLE001
|
| 920 |
+
return None
|
| 921 |
+
bucket = view_templates.workspace_key(str(module or ''))
|
| 922 |
+
if not bucket:
|
| 923 |
+
return None # a SURFACE, or nothing this layer knows as a table
|
| 924 |
+
try:
|
| 925 |
+
doc = st.get(bucket)
|
| 926 |
+
except Exception: # noqa: BLE001
|
| 927 |
+
return None
|
| 928 |
+
if not isinstance(doc, dict):
|
| 929 |
+
# β AN ABSENT BUCKET IS `None`, NOT `[]`. A store that cannot answer and a database
|
| 930 |
+
# nobody has opened are indistinguishable from here, and only one of them is safe to
|
| 931 |
+
# prune against. Declining costs nothing real: a workspace with no bucket has no column
|
| 932 |
+
# to have deleted either.
|
| 933 |
+
return None
|
| 934 |
+
# β READ THROUGH `st` RATHER THAN `shared_overlay.fields()`, AND ONLY THE NAME COMES FROM
|
| 935 |
+
# THAT MODULE. `shared_overlay._read` swallows every exception and answers `{}`, so an
|
| 936 |
+
# unreadable store would be indistinguishable from "nothing is shared" β which is precisely
|
| 937 |
+
# the `None`-collapsed-into-`[]` this function refuses everywhere else. `bucket()` is still
|
| 938 |
+
# the ONE spelling of the key, so there is no second naming convention to get wrong.
|
| 939 |
+
try:
|
| 940 |
+
shared_doc = st.get(shared_overlay.bucket(bucket))
|
| 941 |
+
except Exception: # noqa: BLE001
|
| 942 |
+
return None
|
| 943 |
+
strata = list(doc.values())
|
| 944 |
+
if isinstance(shared_doc, dict):
|
| 945 |
+
strata.append(shared_doc)
|
| 946 |
+
out, seen = [], set()
|
| 947 |
+
for blob in strata:
|
| 948 |
+
if not isinstance(blob, dict):
|
| 949 |
+
continue
|
| 950 |
+
saved = blob.get('fields')
|
| 951 |
+
if not isinstance(saved, dict) or not saved:
|
| 952 |
+
continue
|
| 953 |
+
try:
|
| 954 |
+
got = aios_grid.fields_from_workspace({'fields': saved}, fields_base=[])
|
| 955 |
+
except Exception: # noqa: BLE001
|
| 956 |
+
# One malformed stratum must not make the whole vocabulary unresolvable β that would
|
| 957 |
+
# turn a bad saved field into a frozen cascade. Skip it; the other strata still count.
|
| 958 |
+
continue
|
| 959 |
+
for f in got or ():
|
| 960 |
+
key = f.get('key') if isinstance(f, dict) else None
|
| 961 |
+
if not key or key in seen:
|
| 962 |
+
continue
|
| 963 |
+
seen.add(key)
|
| 964 |
+
out.append(f)
|
| 965 |
+
return out
|
| 966 |
+
|
| 967 |
+
|
| 968 |
+
def wallable_overlay_keys(module, st=None, defs=None):
|
| 969 |
+
"""`{key: Field}` β the user-generated columns of `module` a PERMANENT FILTER can be
|
| 970 |
+
evaluated against on the server. Owner I16, narrowed to what is true rather than to what is
|
| 971 |
+
offered.
|
| 972 |
+
|
| 973 |
+
ββ THE DEFINITION IS "WHOSE VALUES `shared_overlay.cells` SERVES", AND EVERY OTHER PROPERTY
|
| 974 |
+
FOLLOWS FROM IT. `_enrich_for_wall` merges these keys onto the rows from exactly one read of
|
| 975 |
+
exactly this bucket, so defining the set any other way would let it name a column whose value
|
| 976 |
+
the merge cannot supply β and a blank merged for a column the store cannot really answer
|
| 977 |
+
turns `is not X` and `is empty` from "denies every row" into "admits every row". The set and
|
| 978 |
+
the values therefore come from ONE stratum, by construction rather than by care.
|
| 979 |
+
|
| 980 |
+
β SO A `formula`, `created_time` OR `measure_*` COLUMN CAN NEVER BE IN HERE, AND IT IS
|
| 981 |
+
`aios_grid.fields_from_workspace` THAT SAYS SO RATHER THAN A LIST OF TYPE NAMES. That is the
|
| 982 |
+
normaliser the GRID itself overlays a saved stratum with: it emits the read-only user pair
|
| 983 |
+
and the measure columns as `source: 'odoo', derived: True` (their values are computed in the
|
| 984 |
+
BROWSER, or from the measure catalogue, and never sit on a stored row) and an editable
|
| 985 |
+
overlay column as `source: 'overlay'` with no `derived` at all. Testing the two flags is
|
| 986 |
+
testing the grid's own declaration; a hand-built type list here would be a second idea of
|
| 987 |
+
what a field is, and the first thing it would lose is the next read-only kind somebody adds.
|
| 988 |
+
|
| 989 |
+
β AND A PER-USER PRIVATE OVERLAY COLUMN IS OUT TOO, which is the part that looks like a gap
|
| 990 |
+
and is not. Its values ARE server-readable (`<bucket>[username]['overlays']`), but they are
|
| 991 |
+
readable only for the SUBJECT of the wall β an account that may edit that column freely, and
|
| 992 |
+
would therefore be one cell edit away from walking out of its own permission wall. The admin
|
| 993 |
+
who wrote the rule cannot even see the values. `routes_admin._row_wall_blind_keys` keeps
|
| 994 |
+
refusing those at the write door, where a person is present to choose a shared column
|
| 995 |
+
instead.
|
| 996 |
+
|
| 997 |
+
β `{}` ON ANY FAILURE, NEVER `None` AND NEVER A PARTIAL SET. This is read by a wall, and the
|
| 998 |
+
only safe degraded answer for a wall is "I can answer nothing extra" β which leaves `permits`
|
| 999 |
+
denying an unresolvable leaf exactly as it does today. A half-resolved set could ADMIT a row,
|
| 1000 |
+
which is the one direction this must never fail in.
|
| 1001 |
+
|
| 1002 |
+
β AND IT ANSWERS `{}` FOR A `ut_*` DATABASE β DELIBERATELY, NOT BY ACCIDENT OF THE KEY. The
|
| 1003 |
+
two topic grids name their shared stratum off the WORKSPACE key
|
| 1004 |
+
(`customer_table_workspace__shared`), while a user table names its own off the TABLE key
|
| 1005 |
+
(`routes_tables._ut_shared_fields` reads `shared_overlay.fields(table_key)`, i.e.
|
| 1006 |
+
`ut_leads__shared`, not `ut_leads_table_workspace__shared`). Deriving from `workspace_key`
|
| 1007 |
+
therefore finds nothing on a `ut_*` key, and that is the right answer TODAY rather than a
|
| 1008 |
+
gap to paper over: a `ut_*` wall is validated by `routes_admin._module_fields` against the
|
| 1009 |
+
database's own stored DEFINITION, which the enforcement path already declares and whose rows
|
| 1010 |
+
already carry the values β so there is nothing for this to add, and the permission editor
|
| 1011 |
+
cannot offer a `ut_*` shared column in the first place. Wiring that stratum in is a change
|
| 1012 |
+
to what an admin may WALL ON, and it belongs with the picker change that offers it.
|
| 1013 |
+
"""
|
| 1014 |
+
if st is None:
|
| 1015 |
+
return {}
|
| 1016 |
+
try:
|
| 1017 |
+
import aios_grid
|
| 1018 |
+
import core.shared_overlay as shared_overlay
|
| 1019 |
+
import core.view_templates as view_templates
|
| 1020 |
+
|
| 1021 |
+
bucket = view_templates.workspace_key(str(module or ''))
|
| 1022 |
+
if not bucket:
|
| 1023 |
+
return {}
|
| 1024 |
+
# β `defs` IS THE CALLER'S SNAPSHOT, AND PASSING IT IS NOT AN OPTIMISATION.
|
| 1025 |
+
# `_enrich_for_wall` derives the VALUES from one read of this bucket and the
|
| 1026 |
+
# answerable SET from this function; taking a second read here would let the
|
| 1027 |
+
# two disagree, and a set that names a key the values cannot serve is exactly
|
| 1028 |
+
# how a blank gets merged and `is not` flips from deny-all to admit-all. See
|
| 1029 |
+
# `shared_overlay.snapshot`.
|
| 1030 |
+
doc = ({'fields': dict(defs)} if defs is not None
|
| 1031 |
+
else st.get(shared_overlay.bucket(bucket)))
|
| 1032 |
+
saved = doc.get('fields') if isinstance(doc, dict) else None
|
| 1033 |
+
if not isinstance(saved, dict) or not saved:
|
| 1034 |
+
return {}
|
| 1035 |
+
out = {}
|
| 1036 |
+
for f in (aios_grid.fields_from_workspace({'fields': saved}, fields_base=[]) or ()):
|
| 1037 |
+
if not isinstance(f, dict) or not f.get('key'):
|
| 1038 |
+
continue
|
| 1039 |
+
if f.get('source') != 'overlay' or f.get('derived'):
|
| 1040 |
+
continue
|
| 1041 |
+
out[str(f['key'])] = f
|
| 1042 |
+
return out
|
| 1043 |
+
except Exception: # noqa: BLE001
|
| 1044 |
+
return {}
|
| 1045 |
+
|
| 1046 |
+
|
| 1047 |
+
def prune_filter_to_fields(tree, valid_keys):
|
| 1048 |
+
"""`(tree, dropped)` β `tree` with every leaf naming a column outside `valid_keys` removed.
|
| 1049 |
+
|
| 1050 |
+
ββ THE CASCADE OWNER I16 ASKS FOR: *"If the field is deleted, its permission filter goes
|
| 1051 |
+
with it."* A stored permanent filter naming a column the database no longer has is not
|
| 1052 |
+
ignored by the wall β `apply_row_scope` uses `permits`, which DENIES anything it cannot
|
| 1053 |
+
answer β so a deleted column silently converts that account's grid to zero rows. Dropping
|
| 1054 |
+
the leaf is what the owner accepted instead.
|
| 1055 |
+
|
| 1056 |
+
ββ THIS IS AN ADMIN-DOOR OPERATION AND IT MUST NEVER MOVE INTO THE ENFORCEMENT PATH.
|
| 1057 |
+
`verify_perm_scope`'s row-scope leg asserts, in these words, *"a wall naming a DELETED column
|
| 1058 |
+
denies every row (never ignored)"* β it puts `{'colId': 'ghost', ...}` in a stored filter and
|
| 1059 |
+
calls `apply_row_scope` directly. If the wall started ignoring unknown leaves, that gate would
|
| 1060 |
+
flip in the FAIL-OPEN direction and a real permission wall would quietly stop walling. So the
|
| 1061 |
+
prune runs where a RECORD is read or written, and the wall keeps denying as the backstop for
|
| 1062 |
+
anything the prune has not reached yet.
|
| 1063 |
+
|
| 1064 |
+
β PER LEAF, WHERE `routes_admin._prune_to_module` IS ALL-OR-NOTHING PER GROUP, AND THE
|
| 1065 |
+
DIFFERENCE IS DELIBERATE. That function folds a LEGACY wall into a module that may not be
|
| 1066 |
+
able to evaluate it, where half a group is a rule nobody wrote. This one answers a different
|
| 1067 |
+
question: one named column is GONE, and the owner's instruction is that its leaf goes with it
|
| 1068 |
+
while the rest of the admin's rule stands. `done-when` says so in as many words -- *"leaving
|
| 1069 |
+
the user's other filters intact"*.
|
| 1070 |
+
|
| 1071 |
+
β AND THE WIDENING IS REAL, SO IT IS STATED RATHER THAN BURIED. Dropping a leaf from an `and`
|
| 1072 |
+
group WIDENS that wall, and dropping the last leaf anywhere removes it altogether. That is
|
| 1073 |
+
the direction the owner chose over deny-every-row; it is also why `valid_keys` must be a
|
| 1074 |
+
RESOLVED vocabulary (see `user_generated_fields`) and never a degraded one.
|
| 1075 |
+
|
| 1076 |
+
β A LEAF'S `rhs` COUNTS AS NAMING A COLUMN. A column-to-column comparison whose right side
|
| 1077 |
+
was deleted is just as stale as one whose left side was, and `clean_filter_tree` would answer
|
| 1078 |
+
it by dropping the `rhs` alone -- turning "revenue > forecast" into a comparison against a
|
| 1079 |
+
literal, which is a DIFFERENT question wearing the original's shape.
|
| 1080 |
+
|
| 1081 |
+
β AN EMPTIED TREE IS `None`, NEVER `{'conj': 'and', 'nodes': []}`. Measured: `permits`
|
| 1082 |
+
returns True on an empty node list, so an empty-but-present tree admits every row -- while
|
| 1083 |
+
`wall_declared` and `row_scope_applies` both read it as TRUTHY and answer that a wall applies.
|
| 1084 |
+
A door would then build rows to filter them against nothing, and an editor would paint a rule
|
| 1085 |
+
that is not there. `None` is the one shape all three agree about.
|
| 1086 |
+
"""
|
| 1087 |
+
valid = {str(k) for k in (valid_keys or ())}
|
| 1088 |
+
if not valid:
|
| 1089 |
+
# β A FLOOR, NOT AN OPTIMISATION. An empty vocabulary would prune EVERY leaf, which for a
|
| 1090 |
+
# module whose schema momentarily failed to resolve is the whole wall gone in one read.
|
| 1091 |
+
return tree, []
|
| 1092 |
+
dropped = []
|
| 1093 |
+
|
| 1094 |
+
def _keep(node):
|
| 1095 |
+
if not isinstance(node, dict):
|
| 1096 |
+
return None
|
| 1097 |
+
kids = node.get('children')
|
| 1098 |
+
if isinstance(kids, list):
|
| 1099 |
+
surviving = [k for k in (_keep(k) for k in kids) if k is not None]
|
| 1100 |
+
# An emptied GROUP carries no meaning once persisted -- the same rule
|
| 1101 |
+
# `clean_filter_tree` applies to one it built.
|
| 1102 |
+
return dict(node, children=surviving) if surviving else None
|
| 1103 |
+
named = [node.get('colId')]
|
| 1104 |
+
rhs = node.get('rhs')
|
| 1105 |
+
if isinstance(rhs, dict) and rhs.get('kind') != 'stat' and rhs.get('colId') is not None:
|
| 1106 |
+
named.append(rhs.get('colId'))
|
| 1107 |
+
stale = [str(c) for c in named if c is not None and str(c) not in valid]
|
| 1108 |
+
if stale:
|
| 1109 |
+
dropped.extend(stale)
|
| 1110 |
+
return None
|
| 1111 |
+
return node
|
| 1112 |
+
|
| 1113 |
+
if not isinstance(tree, dict):
|
| 1114 |
+
return tree, []
|
| 1115 |
+
nodes = tree.get('nodes')
|
| 1116 |
+
if not isinstance(nodes, list):
|
| 1117 |
+
return tree, []
|
| 1118 |
+
kept = [n for n in (_keep(n) for n in nodes) if n is not None]
|
| 1119 |
+
if not dropped:
|
| 1120 |
+
return tree, [] # unchanged by construction, not merely equal
|
| 1121 |
+
if not kept:
|
| 1122 |
+
return None, sorted(set(dropped))
|
| 1123 |
+
return {'conj': 'or' if tree.get('conj') == 'or' else 'and', 'nodes': kept}, \
|
| 1124 |
+
sorted(set(dropped))
|
| 1125 |
+
|
| 1126 |
+
|
| 1127 |
# ββ THE PUSHDOWN βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 1128 |
#: `dba` value sets that pin a BU, and the Odoo team they pin. `_dba_attrs` emits exactly
|
| 1129 |
#: {'Fisch','Royal','Both'} (blank for "no brand attributable in 24 months"), so a permission
|
|
|
|
| 1541 |
# rather than being ignored. Evaluated against the UNSTRIPPED contract on purpose: a
|
| 1542 |
# permanent filter may name a column the reader is not allowed to SEE, and dropping the
|
| 1543 |
# predicate would widen the read rather than narrow it.
|
| 1544 |
+
# β OWNER I16 β `st` RIDES INTO THE ROW WALL TOO, and this door is the one that already had
|
| 1545 |
+
# the handle and simply did not pass it down. The field wall two lines up has taken it since
|
| 1546 |
+
# W38-T16 for the same reason: a wall resolved without a tenant handle answers from the
|
| 1547 |
+
# module default, and here that means a user-generated column reads as unanswerable and
|
| 1548 |
+
# denies every row.
|
| 1549 |
+
rows = apply_row_scope(rows, user, key, fields, ctx, st=st)
|
| 1550 |
if hide:
|
| 1551 |
fields = visible_fields(fields, user, key, st=st)
|
| 1552 |
rows = [strip_row(r, hide) for r in rows]
|
platform/core/shared_overlay.py
CHANGED
|
@@ -211,6 +211,31 @@ def cells(table_key, pids, st=None):
|
|
| 211 |
if pid in wanted and isinstance(row, dict) and row}
|
| 212 |
|
| 213 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 214 |
def put_cell(table_key, pid, field_key, value, st=None):
|
| 215 |
"""Write ONE shared cell. Returns the value as stored (which may be truncated)."""
|
| 216 |
return put_cells(table_key, pid, {field_key: value}, st=st).get(str(field_key or ''))
|
|
|
|
| 211 |
if pid in wanted and isinstance(row, dict) and row}
|
| 212 |
|
| 213 |
|
| 214 |
+
def snapshot(table_key, pids, st=None):
|
| 215 |
+
"""`(fields, cells)` for `pids` β the shared stratum's SCHEMA and VALUES, from ONE read.
|
| 216 |
+
|
| 217 |
+
ββ THIS EXISTS BECAUSE TWO READS OF THIS BUCKET CAN DISAGREE, AND THE DISAGREEMENT OPENS A
|
| 218 |
+
WALL. `perm_scope._enrich_for_wall` needs both halves: the schema decides WHICH user columns
|
| 219 |
+
the row wall may answer, and the cells are the values it answers with. Taking them as two
|
| 220 |
+
`st.get()` calls leaves a gap in which a concurrent write can land, and a wave-40 adversarial
|
| 221 |
+
probe drove exactly that: with the second read returning an emptied `cells`, a blank is merged
|
| 222 |
+
for a key the store cannot really serve and `custom_x is not West` flips from denying every row
|
| 223 |
+
to ADMITTING a row whose true value IS West. `is empty` does the same. The set and the values
|
| 224 |
+
must come from one snapshot or they are not talking about the same tenant state.
|
| 225 |
+
|
| 226 |
+
β `pids` IS REQUIRED, exactly as in `cells()` β the row wall expressed as a signature, so no
|
| 227 |
+
caller can get "every shared cell in the tenant" by forgetting an argument.
|
| 228 |
+
"""
|
| 229 |
+
if pids is None:
|
| 230 |
+
raise TypeError('shared_overlay.snapshot: pids is required β pass the row set you have '
|
| 231 |
+
'already scoped for this reader (there is deliberately no "all" call)')
|
| 232 |
+
stored = _read(table_key, st)
|
| 233 |
+
wanted = {_pid(p) for p in pids}
|
| 234 |
+
served = {pid: dict(row) for pid, row in stored['cells'].items()
|
| 235 |
+
if pid in wanted and isinstance(row, dict) and row} if wanted else {}
|
| 236 |
+
return dict(stored['fields']), served
|
| 237 |
+
|
| 238 |
+
|
| 239 |
def put_cell(table_key, pid, field_key, value, st=None):
|
| 240 |
"""Write ONE shared cell. Returns the value as stored (which may be truncated)."""
|
| 241 |
return put_cells(table_key, pid, {field_key: value}, st=st).get(str(field_key or ''))
|
platform/core/shares.py
CHANGED
|
@@ -11,16 +11,47 @@ definition; giving each its own grant field would put the same three-line permis
|
|
| 11 |
three files owned by two sessions, which is how the three drift. One registry, one predicate,
|
| 12 |
three callers.
|
| 13 |
|
| 14 |
-
shares.set_grants(kind, oid, entries, owner=β¦, st=β¦) # replaces the whole
|
| 15 |
shares.grants(kind, oid, st=β¦) # -> {'owner': str, 'entries': [...]}
|
| 16 |
shares.role_for(kind, oid, user, is_admin=β¦, st=β¦) # -> 'owner'|'edit'|'view'|None
|
|
|
|
| 17 |
shares.shared_with(user, kind=β¦, st=β¦) # -> [oid] this user was granted
|
| 18 |
|
| 19 |
THE ROLE VOCABULARY IS TWO WORDS AND THE DEFAULT IS THE NARROW ONE. `view` = may open and read;
|
| 20 |
-
`edit` = may also change the object's CONTENT.
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 24 |
|
| 25 |
β AN UNREADABLE GRANT IS NO GRANT. Every path here fails closed β junk in the bucket, a missing
|
| 26 |
owner, an unknown role string all resolve to None rather than to a default that opens something.
|
|
@@ -88,6 +119,31 @@ EVERYONE = '*'
|
|
| 88 |
|
| 89 |
ROLES = ('view', 'edit')
|
| 90 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 91 |
#: ββ A FIELD's OBJECT ID IS TOPIC-QUALIFIED, AND THE SEPARATOR IS DECLARED HERE SO THERE IS ONE
|
| 92 |
#: SPELLING OF IT. A bare field key is NOT unique: `notes` exists on a dozen databases, and a
|
| 93 |
#: grant stored under it would admit a grantee to every `notes` column in the tenant at once β
|
|
@@ -137,12 +193,34 @@ def _check_kind(kind):
|
|
| 137 |
|
| 138 |
|
| 139 |
def _clean_entries(entries):
|
| 140 |
-
"""Normalise + REJECT junk, returning [{'user': str, 'role': 'view'|'edit'}]
|
|
|
|
| 141 |
|
| 142 |
Silently dropping a malformed entry is right here and wrong elsewhere: the caller is a UI
|
| 143 |
that just listed the people it is about to grant, so a rejected row must not abort the whole
|
| 144 |
save β but an entry with an unknown ROLE must not be stored as something else's default
|
| 145 |
either. Dropped, never coerced.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 146 |
"""
|
| 147 |
out, seen = [], set()
|
| 148 |
for e in entries or ():
|
|
@@ -153,12 +231,29 @@ def _clean_entries(entries):
|
|
| 153 |
if not user or role not in ROLES or user in seen:
|
| 154 |
continue
|
| 155 |
seen.add(user)
|
| 156 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 157 |
return out
|
| 158 |
|
| 159 |
|
| 160 |
def grants(kind, oid, st=None):
|
| 161 |
-
"""`{'owner': str|None, 'entries': [{'user','role'}]}` β never raises on a junk bucket.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 162 |
kind = _check_kind(kind)
|
| 163 |
try:
|
| 164 |
bucket = (_st(st).get(SHARES_KEY) or {}).get(kind) or {}
|
|
@@ -171,30 +266,106 @@ def grants(kind, oid, st=None):
|
|
| 171 |
'entries': _clean_entries(rec.get('entries'))}
|
| 172 |
|
| 173 |
|
| 174 |
-
def set_grants(kind, oid, entries, owner=None, st=None):
|
| 175 |
"""REPLACE the grant set for one object. Returns the stored record.
|
| 176 |
|
| 177 |
β REPLACE, NOT MERGE, and that is the contract the UI needs: revoking is expressed by an
|
| 178 |
entry's ABSENCE. A merge-only API cannot remove anybody without a second verb, and the
|
| 179 |
manage-access editor R10 asks for is exactly "here is the list now".
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 180 |
"""
|
| 181 |
kind = _check_kind(kind)
|
| 182 |
oid = str(oid)
|
| 183 |
clean = _clean_entries(entries)
|
| 184 |
owner_l = str(owner).strip().lower() if owner else None
|
|
|
|
| 185 |
|
| 186 |
def _apply(data):
|
| 187 |
by_kind = dict(data.get(kind) or {})
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 188 |
prior = by_kind.get(oid) if isinstance(by_kind.get(oid), dict) else {}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 189 |
# The owner is STICKY: set once, and a later save that omits it must not orphan the
|
| 190 |
# object. An ownerless grant record cannot answer "who may re-share this", so every
|
| 191 |
# administer check would fail closed and the object would become unmanageable.
|
| 192 |
keep_owner = owner_l or (str(prior.get('owner')).strip().lower()
|
| 193 |
if prior.get('owner') else None)
|
| 194 |
-
if not
|
| 195 |
by_kind.pop(oid, None) # fully un-shared and unowned: leave no empty husk
|
| 196 |
else:
|
| 197 |
-
by_kind[oid] = {'owner': keep_owner, 'entries':
|
| 198 |
data[kind] = by_kind
|
| 199 |
return data
|
| 200 |
|
|
@@ -236,9 +407,65 @@ def may_edit(kind, oid, user, is_admin=False, st=None):
|
|
| 236 |
|
| 237 |
|
| 238 |
def may_administer(kind, oid, user, is_admin=False, st=None):
|
| 239 |
-
"""
|
| 240 |
-
|
| 241 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 242 |
|
| 243 |
|
| 244 |
def shared_with(user, kind=None, st=None):
|
|
@@ -272,6 +499,43 @@ def shared_with(user, kind=None, st=None):
|
|
| 272 |
return out if kind is None else {_check_kind(kind): out[_check_kind(kind)]}
|
| 273 |
|
| 274 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 275 |
def drop_objects(pairs, st=None):
|
| 276 |
"""Remove whole grant RECORDS, owner husk included β wave 21, item 6a (C3).
|
| 277 |
|
|
|
|
| 11 |
three files owned by two sessions, which is how the three drift. One registry, one predicate,
|
| 12 |
three callers.
|
| 13 |
|
| 14 |
+
shares.set_grants(kind, oid, entries, owner=β¦, granter=β¦, st=β¦) # replaces the whole set
|
| 15 |
shares.grants(kind, oid, st=β¦) # -> {'owner': str, 'entries': [...]}
|
| 16 |
shares.role_for(kind, oid, user, is_admin=β¦, st=β¦) # -> 'owner'|'edit'|'view'|None
|
| 17 |
+
shares.max_grantable_role(kind, oid, user, β¦) # -> 'edit'|'view'|None (R4's ceiling)
|
| 18 |
shares.shared_with(user, kind=β¦, st=β¦) # -> [oid] this user was granted
|
| 19 |
|
| 20 |
THE ROLE VOCABULARY IS TWO WORDS AND THE DEFAULT IS THE NARROW ONE. `view` = may open and read;
|
| 21 |
+
`edit` = may also change the object's CONTENT.
|
| 22 |
+
|
| 23 |
+
ββ AND ON A VIEW, `edit` NOW ALSO MEANS "MAY RE-SHARE" β OWNER RULING R4, instruction 4 (*"Edit
|
| 24 |
+
View so a member can share a View as well, not just an admin"*), built as W40-T02. This REVERSES
|
| 25 |
+
the flat owner-or-admin rule this paragraph used to state, and it reverses it for ONE kind:
|
| 26 |
+
`RESHARE_KINDS` below is where the widening is spelled, once, and `folder` / `database` / `field`
|
| 27 |
+
are untouched β still the owner's or an admin's, for the reason given at that constant.
|
| 28 |
+
|
| 29 |
+
β WHICH HALF OF THE OLD PROTECTION SURVIVES, BECAUSE THE FEAR IT NAMED WAS REAL AND ONLY HALF OF
|
| 30 |
+
IT IS ANSWERED. The sentence here used to be *"a collaborator who could rewrite grants could grant
|
| 31 |
+
themselves sole ownership of somebody else's object, or quietly widen a users-scoped share to
|
| 32 |
+
everyone"*. Taking those one at a time:
|
| 33 |
+
* **SOLE OWNERSHIP IS BLOCKED β and now stated rather than incidental.** The owner is STICKY in
|
| 34 |
+
`set_grants` and `routes_shares.put_share` passes the EXISTING owner straight back through, so
|
| 35 |
+
a re-share cannot transfer ownership and no grantee can lock the creator out of their own view.
|
| 36 |
+
Ownership moves for nobody, by any path this registry offers.
|
| 37 |
+
* **WIDENING IS NOW BLOCKED TOO β OWNER RULING 2026-08-24, D-473.** β THE SENTENCE HERE USED
|
| 38 |
+
TO PRICE THIS AS A COST R4 ACCEPTED: *"an `edit` grantee may add somebody β `*` included β at
|
| 39 |
+
`view`"*. Measured and reported as such, and the owner's answer was *"no a re-sharer can only
|
| 40 |
+
share to specific people"*. So a re-sharer may name PEOPLE and may not reach `EVERYONE`, and
|
| 41 |
+
the second half of the old fear is closed rather than merely capped. The ROLE ceiling below
|
| 42 |
+
still stands beside it β they are two different questions and both are asked.
|
| 43 |
+
* **THE ROLE CEILING SURVIVES UNCHANGED.** A re-share may never exceed the role the re-sharer
|
| 44 |
+
holds, and the STRICTER reading of that ships: an `edit` grantee may add somebody at `view`,
|
| 45 |
+
and can never mint `edit` access for anyone. Handing out `edit` stays the owner's (or an
|
| 46 |
+
admin's) alone. A `view` grantee still cannot share at all. `max_grantable_role` is that
|
| 47 |
+
ceiling, and `routes_shares.put_share` is where it bites.
|
| 48 |
+
* **AND REVOCATION IS BOUNDED BY PROVENANCE β OWNER RULING 2026-08-24, D-474.** *"a re-sharer
|
| 49 |
+
can only unshare the people it shared to"*. R4 bounded the role a re-sharer may HAND OUT and
|
| 50 |
+
said nothing about what they may TAKE AWAY, so an `edit` grantee could `PUT []` and leave the
|
| 51 |
+
view shared with nobody. Answering that needs a fact the record did not carry, which is what
|
| 52 |
+
the `by` member on each entry is (`_clean_entries` / `set_grants`' `granter`). β An entry
|
| 53 |
+
with NO `by` β every grant written before this change β is the OWNER's to revoke and nobody
|
| 54 |
+
else's: a re-sharer must never revoke a grant they cannot prove they made.
|
| 55 |
|
| 56 |
β AN UNREADABLE GRANT IS NO GRANT. Every path here fails closed β junk in the bucket, a missing
|
| 57 |
owner, an unknown role string all resolve to None rather than to a default that opens something.
|
|
|
|
| 119 |
|
| 120 |
ROLES = ('view', 'edit')
|
| 121 |
|
| 122 |
+
#: ββ THE KINDS AN `edit` GRANTEE MAY RE-SHARE β R4 / W40-T02, and it is `view` ALONE.
|
| 123 |
+
#:
|
| 124 |
+
#: R4's words are "may re-share **A VIEW**", and the widening goes no further than the ruling
|
| 125 |
+
#: names. That restraint is the whole reason this is a tuple rather than a bare `role == 'edit'`
|
| 126 |
+
#: arm inside `may_administer`: every predicate in this file treats `kind` as an opaque bucket key
|
| 127 |
+
#: (see the note on `KINDS`), so an UNGATED widening would reach `folder`, `database` and `field`
|
| 128 |
+
#: in the same line β handing an `edit` grantee on a `ut_*` DATABASE the power to re-share the
|
| 129 |
+
#: whole table. The asymmetry is one of blast radius: a view is one saved SELECTION, opened through
|
| 130 |
+
#: the receiver's own module wall and row scope; a database grant admits an account to a database.
|
| 131 |
+
#: `routes_shares.py`'s module docstring carries that argument at the door where it is enforced.
|
| 132 |
+
#:
|
| 133 |
+
#: β ONE SPELLING, DELIBERATELY. `may_administer` and `max_grantable_role` both consult this, so
|
| 134 |
+
#: "who may open the editor" and "what may they hand out" cannot come apart about the same kind.
|
| 135 |
+
RESHARE_KINDS = ('view',)
|
| 136 |
+
|
| 137 |
+
|
| 138 |
+
class GrantsChanged(Exception):
|
| 139 |
+
"""A grant write was decided against a record that is no longer the stored one.
|
| 140 |
+
|
| 141 |
+
Raised by `set_grants` when its `expect` does not match what is in the store at write time.
|
| 142 |
+
The door turns it into a 409 rather than a 500: it is not an error in the request, it is two
|
| 143 |
+
people editing the same sharing list at once, and the honest answer is to say so.
|
| 144 |
+
"""
|
| 145 |
+
|
| 146 |
+
|
| 147 |
#: ββ A FIELD's OBJECT ID IS TOPIC-QUALIFIED, AND THE SEPARATOR IS DECLARED HERE SO THERE IS ONE
|
| 148 |
#: SPELLING OF IT. A bare field key is NOT unique: `notes` exists on a dozen databases, and a
|
| 149 |
#: grant stored under it would admit a grantee to every `notes` column in the tenant at once β
|
|
|
|
| 193 |
|
| 194 |
|
| 195 |
def _clean_entries(entries):
|
| 196 |
+
"""Normalise + REJECT junk, returning [{'user': str, 'role': 'view'|'edit'}] β plus an
|
| 197 |
+
OPTIONAL `'by'`, present only when the record already carried one.
|
| 198 |
|
| 199 |
Silently dropping a malformed entry is right here and wrong elsewhere: the caller is a UI
|
| 200 |
that just listed the people it is about to grant, so a rejected row must not abort the whole
|
| 201 |
save β but an entry with an unknown ROLE must not be stored as something else's default
|
| 202 |
either. Dropped, never coerced.
|
| 203 |
+
|
| 204 |
+
ββ D-474 β `by` IS PROVENANCE: THE USERNAME OF WHOEVER PLACED THIS GRANT. Owner ruling
|
| 205 |
+
2026-08-24: *"a re-sharer can only unshare the people it shared to"*. That question has no
|
| 206 |
+
answer in a record that stores only WHO HOLDS the grant, so the record grew a third member and
|
| 207 |
+
this normaliser is where it survives the round trip (`grants` reads every stored entry back
|
| 208 |
+
through here, so a member this function drops is a member the door can never consult).
|
| 209 |
+
|
| 210 |
+
ββ AND THIS FUNCTION STAYS A PURE NORMALISER: IT NEVER INVENTS A `by`, AND IT NEVER
|
| 211 |
+
VALIDATES ONE. That is not tidiness, it is the whole security property. `set_grants` is handed
|
| 212 |
+
a caller-supplied list, so a `by` arriving HERE may be forged β and the merge inside
|
| 213 |
+
`set_grants._apply` therefore OVERWRITES it in both directions from the PRIOR record and the
|
| 214 |
+
`granter`, never from the payload. Were this function to treat a submitted `by` as
|
| 215 |
+
authoritative, a re-sharer could PUT `{user: victim, role: view, by: <themselves>}` to
|
| 216 |
+
re-stamp somebody else's grant as their own, then PUT again omitting the victim, and the wall
|
| 217 |
+
at the door would be decoration. Normalise the SHAPE here; decide the VALUE there.
|
| 218 |
+
|
| 219 |
+
β KEY ORDER IS `user, role, by` AND `by` IS ABSENT RATHER THAN `None` WHEN THERE IS NONE.
|
| 220 |
+
Absence is what keeps every pre-existing record byte-identical after this change (an added
|
| 221 |
+
`by: None` would rewrite the whole bucket on the next save, for nothing), and it is what
|
| 222 |
+
`aios-web/api/verify_field_permissions.py` reads when it compares `tuple(entry.values())`
|
| 223 |
+
against a 2-tuple.
|
| 224 |
"""
|
| 225 |
out, seen = [], set()
|
| 226 |
for e in entries or ():
|
|
|
|
| 231 |
if not user or role not in ROLES or user in seen:
|
| 232 |
continue
|
| 233 |
seen.add(user)
|
| 234 |
+
row = {'user': user, 'role': role}
|
| 235 |
+
by = str(e.get('by') or '').strip().lower()
|
| 236 |
+
if by:
|
| 237 |
+
row['by'] = by
|
| 238 |
+
out.append(row)
|
| 239 |
return out
|
| 240 |
|
| 241 |
|
| 242 |
def grants(kind, oid, st=None):
|
| 243 |
+
"""`{'owner': str|None, 'entries': [{'user','role','by'?}]}` β never raises on a junk bucket.
|
| 244 |
+
|
| 245 |
+
ββ D-474 β `by` RIDES THE READ, because the DOOR is what has to consult it. The revocation
|
| 246 |
+
wall lives in `routes_shares.put_share` (it needs the session, which this layer does not
|
| 247 |
+
have), and a wall cannot read a member this function strips. `_clean_entries` carries it,
|
| 248 |
+
so every reader here sees it and no reader has to reach into the raw bucket.
|
| 249 |
+
|
| 250 |
+
β THE COST, STATED RATHER THAN DISCOVERED: `GET /api/v1/share/{kind}/{oid}` returns this
|
| 251 |
+
record verbatim, so anyone who may read a grant list now also learns WHO ADDED each person,
|
| 252 |
+
a `view` grantee included. That is a mild widening of *"who has this?"* into *"who let them
|
| 253 |
+
in?"*. It is accepted deliberately: the alternative is a second, provenance-stripped read
|
| 254 |
+
path, which is a second answer to one question and is how the two come apart
|
| 255 |
+
([[one-evaluator-per-question]]).
|
| 256 |
+
"""
|
| 257 |
kind = _check_kind(kind)
|
| 258 |
try:
|
| 259 |
bucket = (_st(st).get(SHARES_KEY) or {}).get(kind) or {}
|
|
|
|
| 266 |
'entries': _clean_entries(rec.get('entries'))}
|
| 267 |
|
| 268 |
|
| 269 |
+
def set_grants(kind, oid, entries, owner=None, st=None, granter=None, expect=None):
|
| 270 |
"""REPLACE the grant set for one object. Returns the stored record.
|
| 271 |
|
| 272 |
β REPLACE, NOT MERGE, and that is the contract the UI needs: revoking is expressed by an
|
| 273 |
entry's ABSENCE. A merge-only API cannot remove anybody without a second verb, and the
|
| 274 |
manage-access editor R10 asks for is exactly "here is the list now".
|
| 275 |
+
|
| 276 |
+
ββ D-474 β `granter` IS WHO IS DOING THIS SAVE, AND IT IS THE ONLY SOURCE OF A NEW `by`.
|
| 277 |
+
Owner ruling 2026-08-24: *"a re-sharer can only unshare the people it shared to"*. The wall
|
| 278 |
+
is at the door (`routes_shares.put_share`), but the FACT it consults can only be recorded
|
| 279 |
+
here, at the write.
|
| 280 |
+
|
| 281 |
+
ββ AND THE STAMP IS DECIDED INSIDE `_apply`, NOT ABOVE IT, BECAUSE `_apply` IS THE ONLY
|
| 282 |
+
PLACE THE PRIOR RECORD IS VISIBLE. Two rules, and the first is the one that matters:
|
| 283 |
+
* a user ALREADY in the prior record keeps their stored `by` VERBATIM. Never re-stamped β
|
| 284 |
+
a re-save would otherwise transfer provenance to whoever saved last, so every re-sharer
|
| 285 |
+
would silently inherit the right to revoke everybody the owner had ever added, simply by
|
| 286 |
+
pressing Save. That is the ruling inverted, arriving by accident.
|
| 287 |
+
* a user who is NEW to the record takes `by = granter`, or carries NO `by` at all when no
|
| 288 |
+
granter was named.
|
| 289 |
+
|
| 290 |
+
β IN BOTH ARMS THE VALUE IS OVERWRITTEN FROM (prior, granter) AND NEVER READ OFF THE
|
| 291 |
+
SUBMITTED ENTRY. `_clean_entries` preserves a submitted `by` because a STORED one has to
|
| 292 |
+
survive the read; a caller-supplied one is untrusted input. Filling in only a MISSING `by`
|
| 293 |
+
would leave the two-step forgery open: PUT `{user: victim, by: <me>}` to claim provenance,
|
| 294 |
+
then PUT again omitting the victim.
|
| 295 |
+
|
| 296 |
+
β `granter` DEFAULTS TO `None`, AND THAT IS WHAT MAKES THIS SHAPE CHANGE SAFE. Every
|
| 297 |
+
non-door caller β `core.field_permissions` (promote + reconcile), `modules.product_data`'s
|
| 298 |
+
Image field, `core.grid_events`' cleanup on delete, the gates β replaces a whole grant set
|
| 299 |
+
with no caller identity in hand, and each keeps producing EXACTLY the record it produced
|
| 300 |
+
before this change: no `by`, no new bytes, no behaviour moved. A grant with no `by` is one
|
| 301 |
+
nobody can prove they made, and the door treats it as the owner's alone to revoke
|
| 302 |
+
(fail-closed). β A future edit that defaults this to a session, or stamps it from the entry,
|
| 303 |
+
deletes that property without touching a line the compiler can complain about.
|
| 304 |
+
|
| 305 |
+
β `_apply` MAY RUN MORE THAN ONCE. `store._update_locked` re-applies the mutation on a
|
| 306 |
+
`parent_commit` rebase, so the merge builds FRESH dicts from `clean` on every invocation
|
| 307 |
+
rather than mutating it in place; a second pass must see the same untouched input, and it
|
| 308 |
+
must be free to reclassify a user who was "new" on the first pass and is "prior" on the
|
| 309 |
+
second (exactly what a rebase against another writer's save looks like).
|
| 310 |
"""
|
| 311 |
kind = _check_kind(kind)
|
| 312 |
oid = str(oid)
|
| 313 |
clean = _clean_entries(entries)
|
| 314 |
owner_l = str(owner).strip().lower() if owner else None
|
| 315 |
+
granter_l = str(granter).strip().lower() if granter else None
|
| 316 |
|
| 317 |
def _apply(data):
|
| 318 |
by_kind = dict(data.get(kind) or {})
|
| 319 |
+
# ββ COMPARE-AND-SET, AND IT IS A SECURITY BOUNDARY RATHER THAN A TIDINESS ONE.
|
| 320 |
+
# `routes_shares.put_share` reads the record ONCE, decides against it (may this caller
|
| 321 |
+
# remove that person, raise that role, add that audience), and only then calls this. The
|
| 322 |
+
# store re-reads `prior` fresh in here, so between the decision and the write another
|
| 323 |
+
# save can land and the decision is being applied to a record it never saw.
|
| 324 |
+
#
|
| 325 |
+
# Measured by a wave-40 adversarial probe, and it needs no attacker timing: the owner and
|
| 326 |
+
# a re-sharer both have Manage Access open and both press Save. The re-sharer's PUT was
|
| 327 |
+
# ACCEPTED with 200 and the grant the owner had just added was gone, with no error on
|
| 328 |
+
# either screen. That is D-474's wall failing open in the one window where two people are
|
| 329 |
+
# actually editing the same thing.
|
| 330 |
+
#
|
| 331 |
+
# β THE LOST UPDATE PREDATES THE WALL -- REPLACE semantics plus read-modify-write have
|
| 332 |
+
# always meant last-write-wins here. What is new is that a PERMISSION decision now rests
|
| 333 |
+
# on that read. So the caller states what it decided against, and a write that would land
|
| 334 |
+
# on anything else is refused rather than merged.
|
| 335 |
+
#
|
| 336 |
+
# `expect=None` keeps every existing caller byte-identical: the server-derived callers
|
| 337 |
+
# (`field_permissions`, `product_data`, the `[]` revokes) are not deciding anything about
|
| 338 |
+
# a person and have nothing to compare.
|
| 339 |
+
if expect is not None:
|
| 340 |
+
_now = [(e['user'], e['role']) for e in _clean_entries(
|
| 341 |
+
(by_kind.get(oid) or {}).get('entries') if isinstance(by_kind.get(oid), dict)
|
| 342 |
+
else [])]
|
| 343 |
+
if _now != [(e['user'], e['role']) for e in _clean_entries(expect)]:
|
| 344 |
+
raise GrantsChanged(
|
| 345 |
+
'this item was shared with somebody else while you were editing, so nothing '
|
| 346 |
+
'was saved. Reopen the sharing panel to see who has access now, then make '
|
| 347 |
+
'your change again.')
|
| 348 |
prior = by_kind.get(oid) if isinstance(by_kind.get(oid), dict) else {}
|
| 349 |
+
# Read the prior entries through the SAME normaliser every other reader uses, so "was
|
| 350 |
+
# this user already here" cannot be answered one way by the store and another by the
|
| 351 |
+
# door ([[one-question-two-normalizers]]).
|
| 352 |
+
prior_by = {e['user']: e.get('by') for e in _clean_entries(prior.get('entries'))}
|
| 353 |
+
merged = []
|
| 354 |
+
for e in clean:
|
| 355 |
+
row = {'user': e['user'], 'role': e['role']}
|
| 356 |
+
stamp = prior_by[e['user']] if e['user'] in prior_by else granter_l
|
| 357 |
+
if stamp:
|
| 358 |
+
row['by'] = stamp
|
| 359 |
+
merged.append(row)
|
| 360 |
# The owner is STICKY: set once, and a later save that omits it must not orphan the
|
| 361 |
# object. An ownerless grant record cannot answer "who may re-share this", so every
|
| 362 |
# administer check would fail closed and the object would become unmanageable.
|
| 363 |
keep_owner = owner_l or (str(prior.get('owner')).strip().lower()
|
| 364 |
if prior.get('owner') else None)
|
| 365 |
+
if not merged and not keep_owner:
|
| 366 |
by_kind.pop(oid, None) # fully un-shared and unowned: leave no empty husk
|
| 367 |
else:
|
| 368 |
+
by_kind[oid] = {'owner': keep_owner, 'entries': merged}
|
| 369 |
data[kind] = by_kind
|
| 370 |
return data
|
| 371 |
|
|
|
|
| 407 |
|
| 408 |
|
| 409 |
def may_administer(kind, oid, user, is_admin=False, st=None):
|
| 410 |
+
"""May this caller change WHO ELSE reaches the object, and revoke them?
|
| 411 |
+
|
| 412 |
+
ββ R4 / W40-T02 β AN `edit` GRANTEE ANSWERS TRUE, ON A `RESHARE_KINDS` KIND. Owner
|
| 413 |
+
instruction 4: *"Edit View so a member can share a View as well, not just an admin"*. That
|
| 414 |
+
reverses this function's old owner-or-admin rule for exactly one kind; the module note says
|
| 415 |
+
which half of the protection survives and `RESHARE_KINDS` says why it stops at `view`.
|
| 416 |
+
|
| 417 |
+
β ADMINISTERING IS NOT GRANTING, AND THE SECOND QUESTION HAS ITS OWN PREDICATE. True here
|
| 418 |
+
means "may open the editor and rewrite the list"; it does NOT mean every role is theirs to
|
| 419 |
+
hand out. `max_grantable_role` is the ceiling, and R4's two halves are only both honoured if
|
| 420 |
+
a caller consults both ([[one-evaluator-per-question]]).
|
| 421 |
+
|
| 422 |
+
β THE GATE IS THE KIND, NOT THE ROLE ALONE. `role_for` is deliberately kind-agnostic, so
|
| 423 |
+
testing `== 'edit'` without `RESHARE_KINDS` would widen all four kinds in one line.
|
| 424 |
+
"""
|
| 425 |
+
role = role_for(kind, oid, user, is_admin=is_admin, st=st)
|
| 426 |
+
if role == 'owner':
|
| 427 |
+
return True
|
| 428 |
+
return role == 'edit' and _check_kind(kind) in RESHARE_KINDS
|
| 429 |
+
|
| 430 |
+
|
| 431 |
+
def max_grantable_role(kind, oid, user, is_admin=False, st=None):
|
| 432 |
+
"""The STRONGEST role this caller may hand SOMEBODY ELSE on this object, fail-closed.
|
| 433 |
+
|
| 434 |
+
`'edit'` for the owner or an admin Β· `'view'` for an `edit` grantee on a `RESHARE_KINDS` kind
|
| 435 |
+
Β· `None` for anybody who may not administer the object at all.
|
| 436 |
+
|
| 437 |
+
ββ WHY A SECOND PREDICATE RATHER THAN A FLAG ON `may_administer` (R4 / W40-T02). R4 grants an
|
| 438 |
+
`edit` holder the right to re-share and caps it in the same breath: *"a re-share may never
|
| 439 |
+
exceed the role the re-sharer holds"*. Those are two different questions, and a single boolean
|
| 440 |
+
answering both is exactly how the cap gets dropped by the next caller that only needs the door.
|
| 441 |
+
|
| 442 |
+
β THE NARROWER OF R4's TWO READINGS SHIPS, AND ON PURPOSE. "Never exceed the role you hold"
|
| 443 |
+
reads either as *may grant up to and including `edit`* (an edit holder confers edit) or as *may
|
| 444 |
+
confer strictly less than the owner can*. This returns `'view'` β the second β because it is the
|
| 445 |
+
FAIL-CLOSED direction. A wrong `'view'` costs the owner one click to raise somebody; a wrong
|
| 446 |
+
`'edit'` lets a chain of collaborators propagate edit access the owner never approved, with
|
| 447 |
+
nothing in the store recording who widened it. W40-T02's `done-when` pins the same reading.
|
| 448 |
+
|
| 449 |
+
β THIS CAPS WHAT A CALLER GRANTS, NOT WHAT THE STORED SET ALREADY HOLDS, and the difference is
|
| 450 |
+
load-bearing. `routes_shares.put_share` enforces it against the DELTA β a name arriving at
|
| 451 |
+
`edit`, or an existing `view` grantee raised to it β never against every row of a body, because
|
| 452 |
+
the PUT REPLACES and the client therefore re-sends the whole list, the re-sharer's own `edit`
|
| 453 |
+
row included. The evidence for that is at the call site, where the body is.
|
| 454 |
+
|
| 455 |
+
ββ AND IT IS ONE OF THREE BOUNDS ON A RE-SHARE, NOT THE BOUND. Owner ruling 2026-08-24 added
|
| 456 |
+
two more, and both live at the door because both need the SESSION: `_audience_added` (D-473,
|
| 457 |
+
a re-sharer may name people and may not reach `EVERYONE`) and `_unremovable` (D-474, a
|
| 458 |
+
re-sharer may revoke only what their own `by` stamp says they granted). β A reader who takes
|
| 459 |
+
this function for the whole ceiling will widen the other two by leaving them alone β which is
|
| 460 |
+
exactly how R4 shipped with an audience hole and a revocation hole under a docstring that
|
| 461 |
+
read like a complete account of the limits.
|
| 462 |
+
"""
|
| 463 |
+
role = role_for(kind, oid, user, is_admin=is_admin, st=st)
|
| 464 |
+
if role == 'owner':
|
| 465 |
+
return 'edit'
|
| 466 |
+
if role == 'edit' and _check_kind(kind) in RESHARE_KINDS:
|
| 467 |
+
return 'view'
|
| 468 |
+
return None
|
| 469 |
|
| 470 |
|
| 471 |
def shared_with(user, kind=None, st=None):
|
|
|
|
| 499 |
return out if kind is None else {_check_kind(kind): out[_check_kind(kind)]}
|
| 500 |
|
| 501 |
|
| 502 |
+
def granted_oids(kind, st=None):
|
| 503 |
+
"""Every object id of one `kind` that carries AT LEAST ONE grant entry β in ONE bucket read.
|
| 504 |
+
|
| 505 |
+
β W40-T01 / OWNER INSTRUCTION 2 ("a shared View must show the shared icon in EVERY account,
|
| 506 |
+
not only the recipient's"). `shared_with` answers *what was granted TO me* and deliberately
|
| 507 |
+
EXCLUDES what the caller owns β so it structurally cannot answer the other question a share
|
| 508 |
+
mark asks: *does this object have grants at all*. That question has no viewer in it, which is
|
| 509 |
+
why this is a separate function rather than a flag bolted onto `shared_with`.
|
| 510 |
+
|
| 511 |
+
β ONE READ, NOT N β and that is the whole reason this exists rather than a loop at the caller.
|
| 512 |
+
The obvious spelling is `grants(kind, oid)` per view, and `grants` re-reads the WHOLE bucket
|
| 513 |
+
on every call; a busy rail carries dozens of views, so painting one icon would cost dozens of
|
| 514 |
+
full reads of the tenant's entire grant registry. This reads the bucket once and hands back a
|
| 515 |
+
set the caller tests in O(1).
|
| 516 |
+
|
| 517 |
+
β AN ENTRY IS WHAT COUNTS, NOT A RECORD. `set_grants` keeps an owner-only HUSK after a full
|
| 518 |
+
revoke β the owner is sticky, deliberately, see its own note β so testing for the record's
|
| 519 |
+
mere EXISTENCE would leave the mark lit forever after the last person was removed. That is
|
| 520 |
+
exactly the revoke case, so it is the difference between this being right and being decorative
|
| 521 |
+
noise. `_clean_entries` is the same normaliser every other read here uses, so a junk entry
|
| 522 |
+
cannot mark an object either.
|
| 523 |
+
|
| 524 |
+
β FAIL-CLOSED like the rest of this module: an unreadable bucket answers the EMPTY set β no
|
| 525 |
+
marks β never a default that claims something is shared. An unknown KIND still RAISES, exactly
|
| 526 |
+
as `grants` / `shared_with` / `drop_objects` do: that is a typo in a caller, not junk in the
|
| 527 |
+
store, and swallowing it into "nothing is shared" would hide a caller that never works.
|
| 528 |
+
"""
|
| 529 |
+
kind = _check_kind(kind)
|
| 530 |
+
try:
|
| 531 |
+
by_kind = (_st(st).get(SHARES_KEY) or {}).get(kind) or {}
|
| 532 |
+
rows = list(by_kind.items())
|
| 533 |
+
except Exception:
|
| 534 |
+
return set()
|
| 535 |
+
return {str(oid) for oid, rec in rows
|
| 536 |
+
if isinstance(rec, dict) and _clean_entries(rec.get('entries'))}
|
| 537 |
+
|
| 538 |
+
|
| 539 |
def drop_objects(pairs, st=None):
|
| 540 |
"""Remove whole grant RECORDS, owner husk included β wave 21, item 6a (C3).
|
| 541 |
|
platform/core/users.py
CHANGED
|
@@ -185,15 +185,44 @@ def epoch(username):
|
|
| 185 |
|
| 186 |
|
| 187 |
def bump_epoch(username):
|
| 188 |
-
"""Revoke every outstanding API session for this account.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 189 |
username = (username or '').strip().lower()
|
|
|
|
| 190 |
|
| 191 |
def _set(reg):
|
| 192 |
u = reg.get(username)
|
| 193 |
if u:
|
| 194 |
u['epoch'] = int(u.get('epoch') or 0) + 1
|
|
|
|
| 195 |
return reg
|
| 196 |
-
store.update('users', _set)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 197 |
|
| 198 |
|
| 199 |
def verify(username, pw):
|
|
@@ -240,8 +269,16 @@ def verify(username, pw):
|
|
| 240 |
# session. Matching the epoch means the record branch wins and the account's real scope
|
| 241 |
# applies, leaving the master fallback as the true last resort it is meant to be.
|
| 242 |
# 0 when the store is unreachable, which is the case this branch was written for.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 243 |
return {'username': 'admin', 'name': 'Administrator', 'role': 'admin', 'bus': 'all',
|
| 244 |
-
'modules': 'all', 'epoch': int((reg.get('admin') or {}).get('epoch') or 0)
|
|
|
|
| 245 |
return None
|
| 246 |
|
| 247 |
|
|
|
|
| 185 |
|
| 186 |
|
| 187 |
def bump_epoch(username):
|
| 188 |
+
"""Revoke every outstanding API session for this account, and RETURN the new epoch.
|
| 189 |
+
|
| 190 |
+
None when there was no such record: nothing was bumped, and inventing 0 would hand a caller an
|
| 191 |
+
epoch that no cookie should ever be minted under.
|
| 192 |
+
|
| 193 |
+
β WHY IT RETURNS β WAVE 40, R2 ("signing in on computer B signs computer A out immediately").
|
| 194 |
+
A login now bumps the epoch and then has to MINT under it, and the minting caller cannot find
|
| 195 |
+
that number by reading the registry back: between the write and the read another writer (this
|
| 196 |
+
module's own `touch_login` thread, a second login, an admin edit) can land, and a cookie minted
|
| 197 |
+
at the wrong epoch is refused by `deps._user_for` on the very next request β a 200 login
|
| 198 |
+
followed by 401 forever. The write is the only place that knows what it wrote.
|
| 199 |
+
|
| 200 |
+
The value comes from the document `store.update` RETURNED rather than from what we tried to
|
| 201 |
+
write: on the HF backend a cross-process rebase can rebuild that document from a newer copy and
|
| 202 |
+
replay this closure against it, so the LANDED epoch is the authority. If another process bumped
|
| 203 |
+
the same account concurrently the landed value is higher than ours, which is still exactly the
|
| 204 |
+
newest-wins answer R2 asks for. The closure-captured value is the fallback for a store whose
|
| 205 |
+
`update` returns nothing.
|
| 206 |
+
"""
|
| 207 |
username = (username or '').strip().lower()
|
| 208 |
+
bumped = {}
|
| 209 |
|
| 210 |
def _set(reg):
|
| 211 |
u = reg.get(username)
|
| 212 |
if u:
|
| 213 |
u['epoch'] = int(u.get('epoch') or 0) + 1
|
| 214 |
+
bumped['epoch'] = u['epoch']
|
| 215 |
return reg
|
| 216 |
+
landed = store.update('users', _set)
|
| 217 |
+
if 'epoch' not in bumped:
|
| 218 |
+
return None # no such record: nothing was revoked, so promise nothing
|
| 219 |
+
try:
|
| 220 |
+
rec = (landed or {}).get(username) or {}
|
| 221 |
+
if rec.get('epoch') is not None:
|
| 222 |
+
return int(rec['epoch'])
|
| 223 |
+
except Exception:
|
| 224 |
+
pass
|
| 225 |
+
return int(bumped['epoch'])
|
| 226 |
|
| 227 |
|
| 228 |
def verify(username, pw):
|
|
|
|
| 269 |
# session. Matching the epoch means the record branch wins and the account's real scope
|
| 270 |
# applies, leaving the master fallback as the true last resort it is meant to be.
|
| 271 |
# 0 when the store is unreachable, which is the case this branch was written for.
|
| 272 |
+
#
|
| 273 |
+
# β WAVE 40 (R2) β `emergency_master` MARKS THIS DICT SO THE LOGIN CAN SKIP THE EPOCH BUMP.
|
| 274 |
+
# Every ordinary sign-in now bumps the account's epoch to sign its other sessions out, but
|
| 275 |
+
# this identity is deliberately NOT epoch-revocable: `deps._user_for`'s master fallback
|
| 276 |
+
# admits it whatever the record says. A bump here would therefore revoke nothing, while
|
| 277 |
+
# forcing a store WRITE on the one code path that exists for a store outage. Internal to
|
| 278 |
+
# the server: `routes_auth._public_user` is a whitelist projection and does not name it.
|
| 279 |
return {'username': 'admin', 'name': 'Administrator', 'role': 'admin', 'bus': 'all',
|
| 280 |
+
'modules': 'all', 'epoch': int((reg.get('admin') or {}).get('epoch') or 0),
|
| 281 |
+
'emergency_master': True}
|
| 282 |
return None
|
| 283 |
|
| 284 |
|
platform/harness/semantic.py
CHANGED
|
@@ -617,6 +617,83 @@ def store_columns(topic, include_measures=True, grain="aggregate"):
|
|
| 617 |
MAX_GROUPS = 200_000
|
| 618 |
|
| 619 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 620 |
def _scope_for_binding(store, scope_variant=None):
|
| 621 |
"""The effective store scope for one ENTITY measure binding.
|
| 622 |
|
|
@@ -629,6 +706,12 @@ def _scope_for_binding(store, scope_variant=None):
|
|
| 629 |
fences (team and GIFTWARE partner) but does not broaden the fact to quotes/cancellations.
|
| 630 |
A BU argument must likewise be ignored under this variant: filtering team 5 or 6 after
|
| 631 |
opening the scope would silently throw Amazon (team 7) back out.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 632 |
"""
|
| 633 |
if scope_variant is None:
|
| 634 |
return render_scope(store["scope_sql"].strip())
|
|
@@ -636,6 +719,12 @@ def _scope_for_binding(store, scope_variant=None):
|
|
| 636 |
if store.get("table") != "sale_order_line":
|
| 637 |
raise ModelError("scope_variant 'all_channels' is only defined for sale_order_line")
|
| 638 |
return "o.state IN ('sale','done')"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 639 |
raise ModelError(f"unknown entity-measure scope_variant {scope_variant!r}")
|
| 640 |
|
| 641 |
|
|
@@ -718,7 +807,13 @@ def store_query(topic, measures, group_by=None, grain=None, date_from=None, date
|
|
| 718 |
if date_to:
|
| 719 |
where.append(f"CAST({s['date_col']} AS TIMESTAMP) <= ?")
|
| 720 |
params.append(f"{date_to} 23:59:59")
|
| 721 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 722 |
if not s.get("team_col"):
|
| 723 |
raise ModelError(f"topic {topic!r} is company-level β it has no business-unit filter")
|
| 724 |
where.append(f"{s['team_col']} = ?"); params.append(int(team_id))
|
|
@@ -1091,8 +1186,16 @@ def _entity_offer(topic, strict=False):
|
|
| 1091 |
def _entity_offer_uncached(topic, strict=False):
|
| 1092 |
out, refused = [], []
|
| 1093 |
seen = set()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1094 |
for b in entity_measure_bindings(topic):
|
| 1095 |
-
o, r = _one_binding_offer(topic, b, strict=strict)
|
| 1096 |
# β FIRST BINDING WINS A DUPLICATE KEY, and the collision is REPORTED rather than
|
| 1097 |
# silently resolved: two fact topics offering the same metric key would otherwise give a
|
| 1098 |
# column whose source depends on dict order.
|
|
@@ -1150,7 +1253,7 @@ def _source_ready(name):
|
|
| 1150 |
pass
|
| 1151 |
|
| 1152 |
|
| 1153 |
-
def _one_binding_offer(topic, b, strict=False):
|
| 1154 |
src = _model()["topics"].get(b["source"])
|
| 1155 |
if not src or "store" not in src:
|
| 1156 |
raise _EntityMeasureError(
|
|
@@ -1163,9 +1266,36 @@ def _one_binding_offer(topic, b, strict=False):
|
|
| 1163 |
# Validate the declared variant at OFFER time. An unanswerable binding must be refused
|
| 1164 |
# before the UI promises a metric column that only errors when its first cell is fetched.
|
| 1165 |
_scope_for_binding(src["store"], b.get("scope_variant"))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1166 |
# β THE TABLE CHECK, before any key is offered from this binding.
|
| 1167 |
_tbl = (src["store"] or {}).get("table")
|
| 1168 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1169 |
if _rdy is not True:
|
| 1170 |
# β `None` REFUSES TOO, and that is the opposite of the obvious reading. `None` means "the
|
| 1171 |
# store could not be asked" β a warming or absent mirror β and a store that cannot answer
|
|
@@ -1179,13 +1309,16 @@ def _one_binding_offer(topic, b, strict=False):
|
|
| 1179 |
f"refusing rather than promising a column that may render blank"))
|
| 1180 |
if strict:
|
| 1181 |
raise _EntityMeasureError(f"{topic}: {why}")
|
| 1182 |
-
return [], [{"key": k, "reason": why, "indeterminate": _rdy is None}
|
| 1183 |
for k in b["keys"]]
|
| 1184 |
|
| 1185 |
mts = _model()["metrics"]
|
| 1186 |
out, refused = [], []
|
| 1187 |
|
| 1188 |
def refuse(key, reason):
|
|
|
|
|
|
|
|
|
|
| 1189 |
if strict:
|
| 1190 |
raise _EntityMeasureError(f"{topic}: measure {key!r} refused β {reason}")
|
| 1191 |
refused.append({"key": key, "reason": reason})
|
|
@@ -1218,12 +1351,32 @@ def _one_binding_offer(topic, b, strict=False):
|
|
| 1218 |
f"(aios_grid.MEASURE_FIELD_TYPES is currency|int|pct)")
|
| 1219 |
continue
|
| 1220 |
out.append({
|
| 1221 |
-
|
| 1222 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1223 |
"type": ftype,
|
| 1224 |
"format": m.get("format"),
|
| 1225 |
"empty": empty,
|
| 1226 |
# The denominator whose zero blanks a ratio. None for an additive metric.
|
|
|
|
|
|
|
|
|
|
| 1227 |
"guard": m.get("denominator") if m.get("agg") == "ratio" else None,
|
| 1228 |
# ββ TWO NORMALIZERS OF ONE WORD, and this is the seam between them
|
| 1229 |
# ([[one-question-two-normalizers]]). A `pct` METRIC is a FRACTION internally
|
|
@@ -1302,9 +1455,19 @@ def entity_measure_values(topic, keys, date_from=None, date_to=None, team_id=Non
|
|
| 1302 |
merged.setdefault(gk, {}).update(cell)
|
| 1303 |
return merged
|
| 1304 |
(src, dim, scope_variant), want = next(iter(groups.items()))
|
| 1305 |
-
|
| 1306 |
-
|
| 1307 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1308 |
# β A TRUNCATED GROUP SET IS A WRONG ANSWER PER ROW, not a short list β the same refusal
|
| 1309 |
# `rollup_sql.group_values` makes, for the same reason. Never write cells from one.
|
| 1310 |
if res.get("truncated"):
|
|
@@ -1323,9 +1486,12 @@ def entity_measure_values(topic, keys, date_from=None, date_to=None, team_id=Non
|
|
| 1323 |
cell = {}
|
| 1324 |
for k in want:
|
| 1325 |
m = by_key[k]
|
|
|
|
|
|
|
|
|
|
| 1326 |
if m["guard"] is not None and not row.get(m["guard"]):
|
| 1327 |
continue # ratio over a zero denominator -> blank, never 0.0
|
| 1328 |
-
v = row.get(k)
|
| 1329 |
if v is None:
|
| 1330 |
continue
|
| 1331 |
# β THE SCALE BOUNDARY, crossed exactly once β see `scale` in `_entity_offer`.
|
|
|
|
| 617 |
MAX_GROUPS = 200_000
|
| 618 |
|
| 619 |
|
| 620 |
+
#: ββ W40-T10 / owner item 26 (ruling R7, contract C6) β THE CHANNEL VOCABULARY, and it is
|
| 621 |
+
#: CLOSED. C6 fixes it as `all | fisch | royal | amazon`: `all` is the existing `all_channels`
|
| 622 |
+
#: variant (no suffix, the base key), and the three named channels each get their own binding.
|
| 623 |
+
#: The display name here is the ONE place a channel is spelled for a human β the key suffix and
|
| 624 |
+
#: the "(Fisch)" in a measure label are both derived from it, so there is no second list to drift.
|
| 625 |
+
#:
|
| 626 |
+
#: β `amazon` IS DEFINED BY THE EXCLUDED PARTNER, NOT BY `team_id = 7`, and that distinction is
|
| 627 |
+
#: measured rather than stylistic. `core/odoo.sale_line_domain` fences wholesale on BOTH
|
| 628 |
+
#: `team_id IN (5,6)` AND `partner NOT IN excluded_partner_ids()`, and the two are not the same
|
| 629 |
+
#: set: GIFTWARE DEALS carries 24 orders on team 7 and 2 on team 5. Defining the channel by team
|
| 630 |
+
#: would be a SECOND idea of what Amazon is, disagreeing with the fence the rest of the platform
|
| 631 |
+
#: already draws. Taking the partner instead makes the three channels mutually exclusive by
|
| 632 |
+
#: construction: `fisch` and `royal` are their team MINUS the excluded partner, `amazon` IS that
|
| 633 |
+
#: partner, so no line can be counted twice.
|
| 634 |
+
#:
|
| 635 |
+
#: β THE THREE DO NOT SUM TO `all`, AND THAT IS A FACT ABOUT THE DATA, NOT A DEFECT. crm.team 1
|
| 636 |
+
#: ("Sales") is neither brand nor Amazon and carried $31,988.00 over the trailing year. The
|
| 637 |
+
#: channels therefore sum TOWARD the all-channels figure; a gate asserting equality would be
|
| 638 |
+
#: asserting something untrue.
|
| 639 |
+
_CHANNELS = {
|
| 640 |
+
"fisch": {"label": "Fisch"},
|
| 641 |
+
"royal": {"label": "Royal"},
|
| 642 |
+
"amazon": {"label": "Amazon"},
|
| 643 |
+
}
|
| 644 |
+
|
| 645 |
+
#: The prefix that turns a channel name into a binding's `scope_variant`. Declared once so the
|
| 646 |
+
#: parse and the render cannot disagree about where the name starts.
|
| 647 |
+
_CHANNEL_VARIANT_PREFIX = "channel_"
|
| 648 |
+
|
| 649 |
+
|
| 650 |
+
def channel_of_variant(scope_variant):
|
| 651 |
+
"""The channel name inside a `channel_*` scope variant, or None for every other variant.
|
| 652 |
+
|
| 653 |
+
The single parser. `_scope_for_binding` uses it to build SQL and `_one_binding_offer` uses it
|
| 654 |
+
to build the key suffix and the label, so a variant can never mean one channel to the filter
|
| 655 |
+
and another to the column heading.
|
| 656 |
+
"""
|
| 657 |
+
v = str(scope_variant or "")
|
| 658 |
+
if not v.startswith(_CHANNEL_VARIANT_PREFIX):
|
| 659 |
+
return None
|
| 660 |
+
ch = v[len(_CHANNEL_VARIANT_PREFIX):]
|
| 661 |
+
return ch if ch in _CHANNELS else None
|
| 662 |
+
|
| 663 |
+
|
| 664 |
+
def _channel_sql(channel):
|
| 665 |
+
"""The WHERE predicate selecting ONE channel out of the confirmed sale-line population.
|
| 666 |
+
|
| 667 |
+
β THE IDS AND THE PARTNER PATTERN COME FROM `tenant.yml`, never from a literal here. The
|
| 668 |
+
tenant already declares `team_names: {5: Fisch, 6: Royal}` and
|
| 669 |
+
`excluded_partner_name_like`, and `sales_lines.scope_sql` is built from the same two params β
|
| 670 |
+
so the channel filter and the wholesale fence stay one definition. A hard-coded `team_id = 5`
|
| 671 |
+
would be a second copy of a number the tenant file owns.
|
| 672 |
+
|
| 673 |
+
β The `NOT IN (SELECT β¦)` shape is COPIED from `sales_lines.scope_sql` deliberately, down to
|
| 674 |
+
the subquery, so a channel's exclusion is byte-for-byte the exclusion the wholesale scope
|
| 675 |
+
applies rather than a lookalike that could diverge on NULL handling.
|
| 676 |
+
"""
|
| 677 |
+
params = _tenant().get("params") or {}
|
| 678 |
+
excl = params.get("excluded_partner_name_like")
|
| 679 |
+
if not excl:
|
| 680 |
+
raise ModelError(
|
| 681 |
+
f"channel {channel!r} needs the tenant param `excluded_partner_name_like` to say "
|
| 682 |
+
f"which partner IS the Amazon channel, and this tenant declares none")
|
| 683 |
+
in_excluded = (f"l.order_partner_id IN (SELECT id FROM res_partner WHERE name LIKE "
|
| 684 |
+
f"{_sql_value(excl)})")
|
| 685 |
+
if channel == "amazon":
|
| 686 |
+
return in_excluded
|
| 687 |
+
names = {str(v).strip().lower(): k for k, v in (params.get("team_names") or {}).items()}
|
| 688 |
+
tid = names.get(channel)
|
| 689 |
+
if tid is None:
|
| 690 |
+
raise ModelError(
|
| 691 |
+
f"channel {channel!r} is not a team this tenant names β `tenant.yml::team_names` "
|
| 692 |
+
f"carries {sorted(names)}, so the channel cannot be resolved to a team id")
|
| 693 |
+
return f"o.team_id = {int(tid)} AND l.order_partner_id NOT IN " \
|
| 694 |
+
f"(SELECT id FROM res_partner WHERE name LIKE {_sql_value(excl)})"
|
| 695 |
+
|
| 696 |
+
|
| 697 |
def _scope_for_binding(store, scope_variant=None):
|
| 698 |
"""The effective store scope for one ENTITY measure binding.
|
| 699 |
|
|
|
|
| 706 |
fences (team and GIFTWARE partner) but does not broaden the fact to quotes/cancellations.
|
| 707 |
A BU argument must likewise be ignored under this variant: filtering team 5 or 6 after
|
| 708 |
opening the scope would silently throw Amazon (team 7) back out.
|
| 709 |
+
|
| 710 |
+
ββ W40-T10 adds `channel_fisch` / `channel_royal` / `channel_amazon` beside it (R7/C6). They
|
| 711 |
+
narrow the SAME confirmed-sales population to one channel, so `all_channels` stays the union
|
| 712 |
+
and the named three stay disjoint. The BU-suppression argument above generalises with them
|
| 713 |
+
and is stated in `store_query`: a variant IS a statement about the channel dimension, so a
|
| 714 |
+
caller's `team_id` must never be a second, conflicting statement of it.
|
| 715 |
"""
|
| 716 |
if scope_variant is None:
|
| 717 |
return render_scope(store["scope_sql"].strip())
|
|
|
|
| 719 |
if store.get("table") != "sale_order_line":
|
| 720 |
raise ModelError("scope_variant 'all_channels' is only defined for sale_order_line")
|
| 721 |
return "o.state IN ('sale','done')"
|
| 722 |
+
ch = channel_of_variant(scope_variant)
|
| 723 |
+
if ch:
|
| 724 |
+
if store.get("table") != "sale_order_line":
|
| 725 |
+
raise ModelError(
|
| 726 |
+
f"scope_variant {scope_variant!r} is only defined for sale_order_line")
|
| 727 |
+
return f"o.state IN ('sale','done') AND {_channel_sql(ch)}"
|
| 728 |
raise ModelError(f"unknown entity-measure scope_variant {scope_variant!r}")
|
| 729 |
|
| 730 |
|
|
|
|
| 807 |
if date_to:
|
| 808 |
where.append(f"CAST({s['date_col']} AS TIMESTAMP) <= ?")
|
| 809 |
params.append(f"{date_to} 23:59:59")
|
| 810 |
+
# β A BINDING SCOPE VARIANT OWNS THE CHANNEL DIMENSION, so a caller's BU fence is suppressed
|
| 811 |
+
# under EVERY variant, not only under `all_channels`. The variant set IS the channel
|
| 812 |
+
# vocabulary (W40-T10/C6): `all_channels` is the union and `channel_*` names one member, so
|
| 813 |
+
# intersecting either with a `team_id` restates the same dimension a second time and the two
|
| 814 |
+
# statements can disagree. Concretely, `channel_amazon` AND `team_id = 5` returns an empty
|
| 815 |
+
# cell that reads as "this SKU sold nothing on Amazon" β a FALSE number, not a narrower one.
|
| 816 |
+
if team_id and scope_variant is None:
|
| 817 |
if not s.get("team_col"):
|
| 818 |
raise ModelError(f"topic {topic!r} is company-level β it has no business-unit filter")
|
| 819 |
where.append(f"{s['team_col']} = ?"); params.append(int(team_id))
|
|
|
|
| 1186 |
def _entity_offer_uncached(topic, strict=False):
|
| 1187 |
out, refused = [], []
|
| 1188 |
seen = set()
|
| 1189 |
+
# β ONE READINESS PROBE PER TABLE, not per BINDING (W40-T10). `_source_ready` opens a store
|
| 1190 |
+
# connection and costs ~440 ms cold; the channel split took `odoo_products` from two bindings
|
| 1191 |
+
# to five, and FOUR of those five ask about the same `sale_order_line`. Measured on this tree:
|
| 1192 |
+
# 5 probes = 2,194 ms cold, 2 probes = 878 ms β so without this the split would have put
|
| 1193 |
+
# 1.3 s onto the first `routes_grid::events` rebuild after every restart, which is exactly the
|
| 1194 |
+
# path W30-T30 records the cost of. Scoped to ONE build deliberately: the process-lifetime
|
| 1195 |
+
# cache above still refuses to memoise an indeterminate answer, and this must not weaken that.
|
| 1196 |
+
ready = {}
|
| 1197 |
for b in entity_measure_bindings(topic):
|
| 1198 |
+
o, r = _one_binding_offer(topic, b, strict=strict, ready=ready)
|
| 1199 |
# β FIRST BINDING WINS A DUPLICATE KEY, and the collision is REPORTED rather than
|
| 1200 |
# silently resolved: two fact topics offering the same metric key would otherwise give a
|
| 1201 |
# column whose source depends on dict order.
|
|
|
|
| 1253 |
pass
|
| 1254 |
|
| 1255 |
|
| 1256 |
+
def _one_binding_offer(topic, b, strict=False, ready=None):
|
| 1257 |
src = _model()["topics"].get(b["source"])
|
| 1258 |
if not src or "store" not in src:
|
| 1259 |
raise _EntityMeasureError(
|
|
|
|
| 1266 |
# Validate the declared variant at OFFER time. An unanswerable binding must be refused
|
| 1267 |
# before the UI promises a metric column that only errors when its first cell is fetched.
|
| 1268 |
_scope_for_binding(src["store"], b.get("scope_variant"))
|
| 1269 |
+
# ββ W40-T10 / R7 β THE CHANNEL RIDES THE OFFERED KEY, and this is the whole mechanism.
|
| 1270 |
+
#
|
| 1271 |
+
# β IT CANNOT RIDE THE STORED METRIC SPEC, which is what C6's wording suggests and what an
|
| 1272 |
+
# implementer will try first: `aios_grid.clean_measure_field` REBUILDS the stored dict from
|
| 1273 |
+
# known members and returns `{"key", "window"}`, so a `channel` member is dropped on save
|
| 1274 |
+
# with nothing to notice. The key survives that rebuild (up to 80 chars) β so the channel
|
| 1275 |
+
# goes IN the key, and "Revenue (Fisch)" and "Revenue (Amazon)" become two distinct offers
|
| 1276 |
+
# over one metric. No client change at all: the picker already offers what the catalogue does.
|
| 1277 |
+
#
|
| 1278 |
+
# β AND IT MUST NOT BECOME A REAL METRIC. Synthesising `revenue_fisch` into
|
| 1279 |
+
# `_model()["metrics"]` would make every one of these resolve natively β and would inject 18
|
| 1280 |
+
# channel keys into `sem.metrics()`, which is enumerated by the Analyst tool schema
|
| 1281 |
+
# (`harness/tools.py`), the CUSTOMER grid's measure vocabulary (`harness/measure_filter.py`),
|
| 1282 |
+
# the metric dictionary and `routes_tables`. On `sales_lines`' own wholesale scope
|
| 1283 |
+
# `revenue_amazon` is 0 by construction, so those surfaces would be offered a metric that can
|
| 1284 |
+
# only ever answer zero. The suffixed key therefore lives ONLY between `entity_measures` and
|
| 1285 |
+
# `entity_measure_values`, and `base_key` below is what carries it home.
|
| 1286 |
+
_chan = channel_of_variant(b.get("scope_variant"))
|
| 1287 |
+
_suffix = f"_{_chan}" if _chan else ""
|
| 1288 |
+
_chan_label = _CHANNELS[_chan]["label"] if _chan else ""
|
| 1289 |
# β THE TABLE CHECK, before any key is offered from this binding.
|
| 1290 |
_tbl = (src["store"] or {}).get("table")
|
| 1291 |
+
if not _tbl:
|
| 1292 |
+
_rdy = True
|
| 1293 |
+
elif ready is not None and _tbl in ready:
|
| 1294 |
+
_rdy = ready[_tbl] # already probed in THIS build β see `ready` above
|
| 1295 |
+
else:
|
| 1296 |
+
_rdy = _source_ready(_tbl)
|
| 1297 |
+
if ready is not None:
|
| 1298 |
+
ready[_tbl] = _rdy
|
| 1299 |
if _rdy is not True:
|
| 1300 |
# β `None` REFUSES TOO, and that is the opposite of the obvious reading. `None` means "the
|
| 1301 |
# store could not be asked" β a warming or absent mirror β and a store that cannot answer
|
|
|
|
| 1309 |
f"refusing rather than promising a column that may render blank"))
|
| 1310 |
if strict:
|
| 1311 |
raise _EntityMeasureError(f"{topic}: {why}")
|
| 1312 |
+
return [], [{"key": k + _suffix, "reason": why, "indeterminate": _rdy is None}
|
| 1313 |
for k in b["keys"]]
|
| 1314 |
|
| 1315 |
mts = _model()["metrics"]
|
| 1316 |
out, refused = [], []
|
| 1317 |
|
| 1318 |
def refuse(key, reason):
|
| 1319 |
+
# Reported under the key the OFFER would have carried, so a refusal names the column the
|
| 1320 |
+
# user did not get rather than a base metric they never asked for.
|
| 1321 |
+
key = key + _suffix
|
| 1322 |
if strict:
|
| 1323 |
raise _EntityMeasureError(f"{topic}: measure {key!r} refused β {reason}")
|
| 1324 |
refused.append({"key": key, "reason": reason})
|
|
|
|
| 1351 |
f"(aios_grid.MEASURE_FIELD_TYPES is currency|int|pct)")
|
| 1352 |
continue
|
| 1353 |
out.append({
|
| 1354 |
+
# The OFFERED key: the metric key, namespaced by channel. `_entity_offer_uncached`
|
| 1355 |
+
# refuses a duplicate key across bindings ("first binding wins"), so four bindings
|
| 1356 |
+
# over the same six metrics REQUIRE this to be distinct β the namespacing is what
|
| 1357 |
+
# makes the split exist at all, not a cosmetic prefix on a label.
|
| 1358 |
+
"key": key + _suffix,
|
| 1359 |
+
# β THE WAY HOME. `store_query` resolves `measures` against `_model()["metrics"]`,
|
| 1360 |
+
# where no suffixed key exists β so `entity_measure_values` translates back to this
|
| 1361 |
+
# before querying and renames on the way out. Read it as `.get("base_key") or key`:
|
| 1362 |
+
# gate fixtures that build a synthetic offer by hand do not carry this member.
|
| 1363 |
+
"base_key": key,
|
| 1364 |
+
# β THE LABEL IS THE METRIC'S OWN PLUS THE CHANNEL, in that order β "Revenue (Fisch)".
|
| 1365 |
+
# ASCII parentheses and no dash of any kind: a measure label reaches a screen twice
|
| 1366 |
+
# over (the column heading, and `routes_admin::_module_fields`' "Metric - <label>"
|
| 1367 |
+
# row in the permission editor), so CLAUDE.md rule 2 binds here.
|
| 1368 |
+
"label": (f"{m.get('label') or key} ({_chan_label})" if _chan
|
| 1369 |
+
else (m.get("label") or key)),
|
| 1370 |
+
# `all` for the unsuffixed binding, so the whole offer answers "which channel?" and a
|
| 1371 |
+
# caller never has to infer it from the absence of a suffix (C6's vocabulary).
|
| 1372 |
+
"channel": _chan or "all",
|
| 1373 |
"type": ftype,
|
| 1374 |
"format": m.get("format"),
|
| 1375 |
"empty": empty,
|
| 1376 |
# The denominator whose zero blanks a ratio. None for an additive metric.
|
| 1377 |
+
# β NEVER SUFFIXED. This names a column of the GROUPED ROW, and those rows come back
|
| 1378 |
+
# keyed by BASE metric β suffix it and `row.get(guard)` is None for every group, so
|
| 1379 |
+
# every ratio (margin_pct, asp) silently drops out of all three channels at once.
|
| 1380 |
"guard": m.get("denominator") if m.get("agg") == "ratio" else None,
|
| 1381 |
# ββ TWO NORMALIZERS OF ONE WORD, and this is the seam between them
|
| 1382 |
# ([[one-question-two-normalizers]]). A `pct` METRIC is a FRACTION internally
|
|
|
|
| 1455 |
merged.setdefault(gk, {}).update(cell)
|
| 1456 |
return merged
|
| 1457 |
(src, dim, scope_variant), want = next(iter(groups.items()))
|
| 1458 |
+
# ββ THE SUFFIXED KEY STOPS HERE (W40-T10). `store_query` resolves its `measures` against
|
| 1459 |
+
# `_model()["metrics"]` via `_expand_measures`, and no `revenue_fisch` exists there β asking
|
| 1460 |
+
# for one raises "unknown metric". So the offered key is translated back to its base on the
|
| 1461 |
+
# way IN and the value is re-keyed on the way OUT. Two channels of one measure never collide,
|
| 1462 |
+
# because they are separate `groups` entries (the scope variant is part of the group key) and
|
| 1463 |
+
# each is renamed from the same base column into its own offered key.
|
| 1464 |
+
# β `.get("base_key") or k` β NOT a subscript. `verify_scopes` monkeypatches `entity_measures`
|
| 1465 |
+
# with a hand-built offer and `verify_grid_events` captures one into a fixture; neither
|
| 1466 |
+
# carries the member, and a hard subscript would CRASH those gates rather than red them.
|
| 1467 |
+
base_of = {k: (by_key[k].get("base_key") or k) for k in want}
|
| 1468 |
+
res = store_query(src, [base_of[k] for k in want], group_by=[dim], date_from=date_from,
|
| 1469 |
+
date_to=date_to, team_id=team_id, exclude_services=exclude_services,
|
| 1470 |
+
limit=MAX_GROUPS, scope_variant=scope_variant)
|
| 1471 |
# β A TRUNCATED GROUP SET IS A WRONG ANSWER PER ROW, not a short list β the same refusal
|
| 1472 |
# `rollup_sql.group_values` makes, for the same reason. Never write cells from one.
|
| 1473 |
if res.get("truncated"):
|
|
|
|
| 1486 |
cell = {}
|
| 1487 |
for k in want:
|
| 1488 |
m = by_key[k]
|
| 1489 |
+
# `guard` is a BASE metric key and the row is keyed by base metrics, so this needs no
|
| 1490 |
+
# translation β see the `guard` comment in `_one_binding_offer` for why suffixing it
|
| 1491 |
+
# would blank every ratio on every channel.
|
| 1492 |
if m["guard"] is not None and not row.get(m["guard"]):
|
| 1493 |
continue # ratio over a zero denominator -> blank, never 0.0
|
| 1494 |
+
v = row.get(base_of[k]) # base column in, offered key out
|
| 1495 |
if v is None:
|
| 1496 |
continue
|
| 1497 |
# β THE SCALE BOUNDARY, crossed exactly once β see `scale` in `_entity_offer`.
|
platform/model/topics/odoo_customers.yml
CHANGED
|
@@ -48,7 +48,7 @@ fields:
|
|
| 48 |
means: "Whether this customer still exists in Odoo. Archived means deleted there."
|
| 49 |
- key: agent
|
| 50 |
label: "Agent"
|
| 51 |
-
type:
|
| 52 |
kind: data
|
| 53 |
means: "The sales agent who owns this account."
|
| 54 |
- key: dba
|
|
@@ -58,7 +58,7 @@ fields:
|
|
| 58 |
means: "The brand this customer buys from - Fisch, Royal, or both. Amazon-channel orders are not a DBA."
|
| 59 |
- key: salesperson
|
| 60 |
label: "Salesperson"
|
| 61 |
-
type:
|
| 62 |
kind: data
|
| 63 |
means: "Who keyed in most of this customer's orders β not the Agent, who owns the account."
|
| 64 |
- key: street
|
|
@@ -73,17 +73,17 @@ fields:
|
|
| 73 |
means: "Second address line (suite, unit, floor) on the customer's Odoo address."
|
| 74 |
- key: city
|
| 75 |
label: "City"
|
| 76 |
-
type:
|
| 77 |
kind: data
|
| 78 |
means: "City on the customer's Odoo address."
|
| 79 |
- key: state
|
| 80 |
label: "State"
|
| 81 |
-
type:
|
| 82 |
kind: data
|
| 83 |
means: "State or province on the customer's Odoo address."
|
| 84 |
- key: country
|
| 85 |
label: "Country"
|
| 86 |
-
type:
|
| 87 |
kind: data
|
| 88 |
means: "Country on the customer's Odoo address."
|
| 89 |
- key: zip
|
|
@@ -91,6 +91,11 @@ fields:
|
|
| 91 |
type: text
|
| 92 |
kind: data
|
| 93 |
means: "Postal code on the customer's Odoo address."
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 94 |
- key: customer_since
|
| 95 |
label: "Customer since"
|
| 96 |
type: date
|
|
@@ -98,17 +103,17 @@ fields:
|
|
| 98 |
means: "When this customer was first set up in Odoo."
|
| 99 |
- key: tags
|
| 100 |
label: "Tags"
|
| 101 |
-
type:
|
| 102 |
kind: data
|
| 103 |
means: "Odoo labels on this customer, comma-separated."
|
| 104 |
- key: pricelist
|
| 105 |
-
label: "
|
| 106 |
-
type:
|
| 107 |
kind: data
|
| 108 |
means: "The price list this customer buys on."
|
| 109 |
- key: payment_terms
|
| 110 |
label: "Payment terms"
|
| 111 |
-
type:
|
| 112 |
kind: data
|
| 113 |
means: "Payment terms on this customer's account β Net 30, for example."
|
| 114 |
- key: last_order
|
|
@@ -173,7 +178,7 @@ fields:
|
|
| 173 |
means: "Average days to pay an invoice in full. Blank means no fully paid invoice yet."
|
| 174 |
- key: top_category
|
| 175 |
label: "Top category"
|
| 176 |
-
type:
|
| 177 |
kind: data
|
| 178 |
means: "The category this customer spent the most on in the last 12 months."
|
| 179 |
- key: top_category_pct
|
|
@@ -201,6 +206,11 @@ fields:
|
|
| 201 |
type: int
|
| 202 |
kind: data
|
| 203 |
means: "Days this customer usually goes between orders, from their own history."
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 204 |
- key: notes
|
| 205 |
label: "Notes"
|
| 206 |
type: text
|
|
|
|
| 48 |
means: "Whether this customer still exists in Odoo. Archived means deleted there."
|
| 49 |
- key: agent
|
| 50 |
label: "Agent"
|
| 51 |
+
type: select
|
| 52 |
kind: data
|
| 53 |
means: "The sales agent who owns this account."
|
| 54 |
- key: dba
|
|
|
|
| 58 |
means: "The brand this customer buys from - Fisch, Royal, or both. Amazon-channel orders are not a DBA."
|
| 59 |
- key: salesperson
|
| 60 |
label: "Salesperson"
|
| 61 |
+
type: select
|
| 62 |
kind: data
|
| 63 |
means: "Who keyed in most of this customer's orders β not the Agent, who owns the account."
|
| 64 |
- key: street
|
|
|
|
| 73 |
means: "Second address line (suite, unit, floor) on the customer's Odoo address."
|
| 74 |
- key: city
|
| 75 |
label: "City"
|
| 76 |
+
type: select
|
| 77 |
kind: data
|
| 78 |
means: "City on the customer's Odoo address."
|
| 79 |
- key: state
|
| 80 |
label: "State"
|
| 81 |
+
type: select
|
| 82 |
kind: data
|
| 83 |
means: "State or province on the customer's Odoo address."
|
| 84 |
- key: country
|
| 85 |
label: "Country"
|
| 86 |
+
type: select
|
| 87 |
kind: data
|
| 88 |
means: "Country on the customer's Odoo address."
|
| 89 |
- key: zip
|
|
|
|
| 91 |
type: text
|
| 92 |
kind: data
|
| 93 |
means: "Postal code on the customer's Odoo address."
|
| 94 |
+
- key: maps_url
|
| 95 |
+
label: "Google Maps"
|
| 96 |
+
type: url
|
| 97 |
+
kind: data
|
| 98 |
+
means: "A Google Maps link to this customer's address."
|
| 99 |
- key: customer_since
|
| 100 |
label: "Customer since"
|
| 101 |
type: date
|
|
|
|
| 103 |
means: "When this customer was first set up in Odoo."
|
| 104 |
- key: tags
|
| 105 |
label: "Tags"
|
| 106 |
+
type: multiselect
|
| 107 |
kind: data
|
| 108 |
means: "Odoo labels on this customer, comma-separated."
|
| 109 |
- key: pricelist
|
| 110 |
+
label: "Customer price list"
|
| 111 |
+
type: select
|
| 112 |
kind: data
|
| 113 |
means: "The price list this customer buys on."
|
| 114 |
- key: payment_terms
|
| 115 |
label: "Payment terms"
|
| 116 |
+
type: select
|
| 117 |
kind: data
|
| 118 |
means: "Payment terms on this customer's account β Net 30, for example."
|
| 119 |
- key: last_order
|
|
|
|
| 178 |
means: "Average days to pay an invoice in full. Blank means no fully paid invoice yet."
|
| 179 |
- key: top_category
|
| 180 |
label: "Top category"
|
| 181 |
+
type: select
|
| 182 |
kind: data
|
| 183 |
means: "The category this customer spent the most on in the last 12 months."
|
| 184 |
- key: top_category_pct
|
|
|
|
| 206 |
type: int
|
| 207 |
kind: data
|
| 208 |
means: "Days this customer usually goes between orders, from their own history."
|
| 209 |
+
- key: created_on
|
| 210 |
+
label: "Record created"
|
| 211 |
+
type: date
|
| 212 |
+
kind: data
|
| 213 |
+
means: "The date this customer record was created in Odoo."
|
| 214 |
- key: notes
|
| 215 |
label: "Notes"
|
| 216 |
type: text
|
platform/model/topics/odoo_products.yml
CHANGED
|
@@ -1,10 +1,21 @@
|
|
| 1 |
# ββ W33-T49 (owner item 13) β an ENTITY topic: the semantic layer can finally see
|
| 2 |
# the databases a person actually opens, not only the line and document grains.
|
| 3 |
#
|
| 4 |
-
# β THE `fields:` BLOCK IS
|
| 5 |
-
#
|
| 6 |
-
#
|
| 7 |
-
#
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 8 |
key: odoo_products
|
| 9 |
label: "Odoo products"
|
| 10 |
entity: product.product
|
|
@@ -83,6 +94,48 @@ measures:
|
|
| 83 |
cause: "adjustments and scrap are ~30% of IN / ~20% of OUT and the two obvious exclusions are NOT equivalent - the 5,320-unit gap between them is entirely `Virtual Locations/Scrap`, so the choice is a business ruling rather than a filter"
|
| 84 |
fix: "ask the owner which exclusion they mean, then add it as a SEPARATE metric with `store_filter_sql` narrowed on `sl.usage`/`sd.usage` - never by changing what `stock_in` means"
|
| 85 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 86 |
# key / label / type / kind, derived from the grid contract. `kind` says where the
|
| 87 |
# value COMES FROM: a `data` column is stored on the row; a `rollup` is computed
|
| 88 |
# from another topic; a `link` points at another database.
|
|
@@ -104,7 +157,7 @@ fields:
|
|
| 104 |
means: "Product category; '(uncategorized)' when Odoo carries none."
|
| 105 |
- key: supplier
|
| 106 |
label: "Supplier"
|
| 107 |
-
type:
|
| 108 |
kind: data
|
| 109 |
means: "Who makes it. Editable here and shared with everyone in the workspace; seeded from the inventory mastersheet."
|
| 110 |
- key: origin_country
|
|
@@ -141,7 +194,7 @@ fields:
|
|
| 141 |
label: "Price 1"
|
| 142 |
type: currency
|
| 143 |
kind: data
|
| 144 |
-
means: "Cheapest live package price for this SKU across active pricelists."
|
| 145 |
- key: unit_1
|
| 146 |
label: "Unit 1"
|
| 147 |
type: text
|
|
@@ -151,7 +204,7 @@ fields:
|
|
| 151 |
label: "Price 2"
|
| 152 |
type: currency
|
| 153 |
kind: data
|
| 154 |
-
means: "Second-cheapest live package price
|
| 155 |
- key: unit_2
|
| 156 |
label: "Unit 2"
|
| 157 |
type: text
|
|
@@ -161,12 +214,102 @@ fields:
|
|
| 161 |
label: "Price 3"
|
| 162 |
type: currency
|
| 163 |
kind: data
|
| 164 |
-
means: "Third-cheapest live package price
|
| 165 |
- key: unit_3
|
| 166 |
label: "Unit 3"
|
| 167 |
type: text
|
| 168 |
kind: data
|
| 169 |
means: "Package label for Price 3."
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 170 |
- key: pre_book_qty
|
| 171 |
label: "Pre-book qty"
|
| 172 |
type: int
|
|
@@ -226,7 +369,7 @@ fields:
|
|
| 226 |
label: "Days of supply"
|
| 227 |
type: int
|
| 228 |
kind: data
|
| 229 |
-
means: "Days of supply at the
|
| 230 |
- key: cover_gap_d
|
| 231 |
label: "Cover gap (days)"
|
| 232 |
type: int
|
|
@@ -236,7 +379,12 @@ fields:
|
|
| 236 |
label: "Stock status"
|
| 237 |
type: select
|
| 238 |
kind: data
|
| 239 |
-
means: "Dead / excess / healthy bucket from the inventory module.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 240 |
|
| 241 |
ai_context: >
|
| 242 |
The product CATALOGUE β the database labelled 'Odoo products'.
|
|
|
|
| 1 |
# ββ W33-T49 (owner item 13) β an ENTITY topic: the semantic layer can finally see
|
| 2 |
# the databases a person actually opens, not only the line and document grains.
|
| 3 |
#
|
| 4 |
+
# β THE `fields:` BLOCK IS A HAND-MAINTAINED, CURATED SUBSET OF THE GRID'S FIELD
|
| 5 |
+
# CONTRACT, AND NOTHING ENFORCES IT. This comment used to say the block was GENERATED
|
| 6 |
+
# and "held to it by `verify_query.py::section_entity_topics`. Do not hand-edit a field
|
| 7 |
+
# row." MEASURED 2026-08-24: `section_entity_topics` does not exist anywhere in the tree
|
| 8 |
+
# and no gate compares this file to `aios_grid_fields.json`, so that sentence was an
|
| 9 |
+
# unchecked claim forbidding the only edit anyone can actually make
|
| 10 |
+
# ([[a-declared-gate-is-an-unchecked-claim]]).
|
| 11 |
+
#
|
| 12 |
+
# What is TRUE: 9 of the product contract's keys are deliberately absent (D-400 β
|
| 13 |
+
# incoming, cover_gap_units, demand_fwd, discontinued, needs_pricing, march_pricelist,
|
| 14 |
+
# price_changes, closeouts, notes), and no key here is absent from the contract. So a
|
| 15 |
+
# field row IS hand-edited, and the rule is the honest one: the key, type and label must
|
| 16 |
+
# match `aios_grid_fields.json`, because the agent is otherwise trained on a schema the
|
| 17 |
+
# product does not have. Building the missing gate is booked; until it exists, this
|
| 18 |
+
# paragraph is the only thing keeping the two in step.
|
| 19 |
key: odoo_products
|
| 20 |
label: "Odoo products"
|
| 21 |
entity: product.product
|
|
|
|
| 94 |
cause: "adjustments and scrap are ~30% of IN / ~20% of OUT and the two obvious exclusions are NOT equivalent - the 5,320-unit gap between them is entirely `Virtual Locations/Scrap`, so the choice is a business ruling rather than a filter"
|
| 95 |
fix: "ask the owner which exclusion they mean, then add it as a SEPARATE metric with `store_filter_sql` narrowed on `sl.usage`/`sd.usage` - never by changing what `stock_in` means"
|
| 96 |
|
| 97 |
+
# ββ W40-T10 / owner item 26 (ruling R7, contract C6) β PER-METRIC CHANNEL SCOPE. Owner:
|
| 98 |
+
# *"Separate revenue and the other Odoo products metrics by Analytics, as a filter under the
|
| 99 |
+
# Metrics field, specific to the Odoo databases."* R7 makes it PER METRIC rather than per grid, so
|
| 100 |
+
# "Revenue (Fisch)" and "Revenue (Amazon)" sit side by side on one grid and answer differently.
|
| 101 |
+
#
|
| 102 |
+
# β THE CHANNEL IS A BINDING, NOT A MEMBER OF THE SAVED FIELD. C6 words it as part of the stored
|
| 103 |
+
# Metric spec and it CANNOT be one: `aios_grid.clean_measure_field` rebuilds that dict from known
|
| 104 |
+
# members and returns `{key, window}`, so a `channel` member is dropped on save with nothing to
|
| 105 |
+
# notice, and `aios_grid.py` is in no lane's fence. The key survives, so the channel rides the
|
| 106 |
+
# KEY: `semantic._one_binding_offer` derives the suffix and the "(Fisch)" from the variant name,
|
| 107 |
+
# and the catalogue offers `revenue` / `revenue_fisch` / `revenue_royal` / `revenue_amazon` as
|
| 108 |
+
# four distinct keys. No client change: the picker already offers whatever the catalogue offers.
|
| 109 |
+
#
|
| 110 |
+
# β THESE MUST STAY *AFTER* THE TWO ABOVE. `entity_measure_binding()` and two gates
|
| 111 |
+
# (`verify_product_pool::W39-T11`, `verify_odoo_relational::_prove_entity_measures`) read
|
| 112 |
+
# `bindings[0]` as "the" binding; putting a channel binding first would silently retarget them.
|
| 113 |
+
#
|
| 114 |
+
# β `not_yet:` is deliberately NOT repeated here. It documents the METRIC and why the wave does
|
| 115 |
+
# not ship it, which is a fact about the metric and not about the channel β copying it four times
|
| 116 |
+
# would be four statements of one thing, and the day one is answered three would go stale.
|
| 117 |
+
#
|
| 118 |
+
# β COST: one grouped scan PER CHANNEL, because `entity_measure_values` groups by
|
| 119 |
+
# `(topic, dim, scope_variant)`. Four channel columns of the same measure over the same window
|
| 120 |
+
# are four scans, ~0.22 s each against the mirror. A grid carrying one channel costs exactly what
|
| 121 |
+
# it costs today.
|
| 122 |
+
- source: sales_lines
|
| 123 |
+
dim: product_code
|
| 124 |
+
scope_variant: channel_fisch
|
| 125 |
+
keys: [units, revenue, margin, cogs, margin_pct, asp]
|
| 126 |
+
- source: sales_lines
|
| 127 |
+
dim: product_code
|
| 128 |
+
scope_variant: channel_royal
|
| 129 |
+
keys: [units, revenue, margin, cogs, margin_pct, asp]
|
| 130 |
+
# β `amazon` IS THE EXCLUDED PARTNER, NOT crm.team 7 β measured, and the difference is real:
|
| 131 |
+
# GIFTWARE DEALS carries 24 orders on team 7 AND 2 on team 5, so the partner and the team name
|
| 132 |
+
# different sets. `core/odoo.sale_line_domain` already fences wholesale on the PARTNER, so taking
|
| 133 |
+
# the team here would be a second, disagreeing idea of what Amazon is.
|
| 134 |
+
- source: sales_lines
|
| 135 |
+
dim: product_code
|
| 136 |
+
scope_variant: channel_amazon
|
| 137 |
+
keys: [units, revenue, margin, cogs, margin_pct, asp]
|
| 138 |
+
|
| 139 |
# key / label / type / kind, derived from the grid contract. `kind` says where the
|
| 140 |
# value COMES FROM: a `data` column is stored on the row; a `rollup` is computed
|
| 141 |
# from another topic; a `link` points at another database.
|
|
|
|
| 157 |
means: "Product category; '(uncategorized)' when Odoo carries none."
|
| 158 |
- key: supplier
|
| 159 |
label: "Supplier"
|
| 160 |
+
type: multiselect
|
| 161 |
kind: data
|
| 162 |
means: "Who makes it. Editable here and shared with everyone in the workspace; seeded from the inventory mastersheet."
|
| 163 |
- key: origin_country
|
|
|
|
| 194 |
label: "Price 1"
|
| 195 |
type: currency
|
| 196 |
kind: data
|
| 197 |
+
means: "Cheapest live package price for this SKU pooled across ALL active pricelists and unattributed. Ask the per-list tier fields for what a named list charges."
|
| 198 |
- key: unit_1
|
| 199 |
label: "Unit 1"
|
| 200 |
type: text
|
|
|
|
| 204 |
label: "Price 2"
|
| 205 |
type: currency
|
| 206 |
kind: data
|
| 207 |
+
means: "Second-cheapest live package price pooled across ALL pricelists, unattributed."
|
| 208 |
- key: unit_2
|
| 209 |
label: "Unit 2"
|
| 210 |
type: text
|
|
|
|
| 214 |
label: "Price 3"
|
| 215 |
type: currency
|
| 216 |
kind: data
|
| 217 |
+
means: "Third-cheapest live package price pooled across ALL pricelists, unattributed."
|
| 218 |
- key: unit_3
|
| 219 |
label: "Unit 3"
|
| 220 |
type: text
|
| 221 |
kind: data
|
| 222 |
means: "Package label for Price 3."
|
| 223 |
+
- key: price_fisch_t1
|
| 224 |
+
label: "Fisch tier 1 price"
|
| 225 |
+
type: currency
|
| 226 |
+
kind: data
|
| 227 |
+
means: "Fisch price tier 1, cheapest first. Blank when Fisch does not price this SKU."
|
| 228 |
+
- key: unit_fisch_t1
|
| 229 |
+
label: "Fisch tier 1 unit"
|
| 230 |
+
type: text
|
| 231 |
+
kind: data
|
| 232 |
+
means: "Package label for the Fisch tier 1 price. Blank when Odoo names no package."
|
| 233 |
+
- key: price_fisch_t2
|
| 234 |
+
label: "Fisch tier 2 price"
|
| 235 |
+
type: currency
|
| 236 |
+
kind: data
|
| 237 |
+
means: "Fisch price tier 2. Blank when Fisch prices this SKU at only one tier."
|
| 238 |
+
- key: unit_fisch_t2
|
| 239 |
+
label: "Fisch tier 2 unit"
|
| 240 |
+
type: text
|
| 241 |
+
kind: data
|
| 242 |
+
means: "Package label for the Fisch tier 2 price. Blank when Odoo names no package."
|
| 243 |
+
- key: price_fisch_t3
|
| 244 |
+
label: "Fisch tier 3 price"
|
| 245 |
+
type: currency
|
| 246 |
+
kind: data
|
| 247 |
+
means: "Fisch price tier 3. Blank when Fisch prices this SKU at fewer than three tiers."
|
| 248 |
+
- key: unit_fisch_t3
|
| 249 |
+
label: "Fisch tier 3 unit"
|
| 250 |
+
type: text
|
| 251 |
+
kind: data
|
| 252 |
+
means: "Package label for the Fisch tier 3 price. Blank when Odoo names no package."
|
| 253 |
+
- key: price_royal1_t1
|
| 254 |
+
label: "Royal 1 tier 1 price"
|
| 255 |
+
type: currency
|
| 256 |
+
kind: data
|
| 257 |
+
means: "Royal 1 price tier 1, cheapest first. Blank when Royal 1 does not price this SKU."
|
| 258 |
+
- key: unit_royal1_t1
|
| 259 |
+
label: "Royal 1 tier 1 unit"
|
| 260 |
+
type: text
|
| 261 |
+
kind: data
|
| 262 |
+
means: "Package label for the Royal 1 tier 1 price. Blank when Odoo names no package."
|
| 263 |
+
- key: price_royal1_t2
|
| 264 |
+
label: "Royal 1 tier 2 price"
|
| 265 |
+
type: currency
|
| 266 |
+
kind: data
|
| 267 |
+
means: "Royal 1 price tier 2. Blank when Royal 1 prices this SKU at only one tier."
|
| 268 |
+
- key: unit_royal1_t2
|
| 269 |
+
label: "Royal 1 tier 2 unit"
|
| 270 |
+
type: text
|
| 271 |
+
kind: data
|
| 272 |
+
means: "Package label for the Royal 1 tier 2 price. Blank when Odoo names no package."
|
| 273 |
+
- key: price_royal1_t3
|
| 274 |
+
label: "Royal 1 tier 3 price"
|
| 275 |
+
type: currency
|
| 276 |
+
kind: data
|
| 277 |
+
means: "Royal 1 price tier 3. Blank when Royal 1 prices this SKU at fewer than three tiers."
|
| 278 |
+
- key: unit_royal1_t3
|
| 279 |
+
label: "Royal 1 tier 3 unit"
|
| 280 |
+
type: text
|
| 281 |
+
kind: data
|
| 282 |
+
means: "Package label for the Royal 1 tier 3 price. Blank when Odoo names no package."
|
| 283 |
+
- key: price_royal2_t1
|
| 284 |
+
label: "Royal 2 tier 1 price"
|
| 285 |
+
type: currency
|
| 286 |
+
kind: data
|
| 287 |
+
means: "Royal 2 price tier 1, cheapest first. Blank when Royal 2 does not price this SKU."
|
| 288 |
+
- key: unit_royal2_t1
|
| 289 |
+
label: "Royal 2 tier 1 unit"
|
| 290 |
+
type: text
|
| 291 |
+
kind: data
|
| 292 |
+
means: "Package label for the Royal 2 tier 1 price. Blank when Odoo names no package."
|
| 293 |
+
- key: price_royal2_t2
|
| 294 |
+
label: "Royal 2 tier 2 price"
|
| 295 |
+
type: currency
|
| 296 |
+
kind: data
|
| 297 |
+
means: "Royal 2 price tier 2. Blank when Royal 2 prices this SKU at only one tier."
|
| 298 |
+
- key: unit_royal2_t2
|
| 299 |
+
label: "Royal 2 tier 2 unit"
|
| 300 |
+
type: text
|
| 301 |
+
kind: data
|
| 302 |
+
means: "Package label for the Royal 2 tier 2 price. Blank when Odoo names no package."
|
| 303 |
+
- key: price_royal2_t3
|
| 304 |
+
label: "Royal 2 tier 3 price"
|
| 305 |
+
type: currency
|
| 306 |
+
kind: data
|
| 307 |
+
means: "Royal 2 price tier 3. Blank when Royal 2 prices this SKU at fewer than three tiers."
|
| 308 |
+
- key: unit_royal2_t3
|
| 309 |
+
label: "Royal 2 tier 3 unit"
|
| 310 |
+
type: text
|
| 311 |
+
kind: data
|
| 312 |
+
means: "Package label for the Royal 2 tier 3 price. Blank when Odoo names no package."
|
| 313 |
- key: pre_book_qty
|
| 314 |
label: "Pre-book qty"
|
| 315 |
type: int
|
|
|
|
| 369 |
label: "Days of supply"
|
| 370 |
type: int
|
| 371 |
kind: data
|
| 372 |
+
means: "Days of supply at the trailing twelve month rate, counting on hand plus inbound units as stock. Blank means there is no honest number: either the product sold nothing in the window and Stock status reads 'No recent sales', or the inventory read returned no row for it and Stock status reads 'No stock record'. A product that sold nothing and holds nothing reads 0, not blank. A business unit caller gets this column too, re-scoped: the shelf is the whole warehouse's, the rate is that unit's."
|
| 373 |
- key: cover_gap_d
|
| 374 |
label: "Cover gap (days)"
|
| 375 |
type: int
|
|
|
|
| 379 |
label: "Stock status"
|
| 380 |
type: select
|
| 381 |
kind: data
|
| 382 |
+
means: "Dead / excess / healthy bucket from the inventory module, off the same days of supply figure beside it. Two values are not coverage bands: 'Out of stock' keys on the real shelf rather than the inbound-inclusive figure, and 'No stock record' means the inventory read returned no row for this product, so its shelf is unknown rather than empty. A business unit caller gets this column too, re-scoped through that unit's own sales rate."
|
| 383 |
+
- key: created_on
|
| 384 |
+
label: "Record created"
|
| 385 |
+
type: date
|
| 386 |
+
kind: data
|
| 387 |
+
means: "The date this product record was created in Odoo. The same uniform records-created column the customer topic carries."
|
| 388 |
|
| 389 |
ai_context: >
|
| 390 |
The product CATALOGUE β the database labelled 'Odoo products'.
|
platform/modules/customer_data.py
CHANGED
|
@@ -18,6 +18,9 @@ tie. Persistence: HF store key 'customer_lists'
|
|
| 18 |
The userβagent link (users.py 'agent' field) scopes the pool to that agent's book; users with
|
| 19 |
no link (owner/CFO/admin) see the whole book.
|
| 20 |
"""
|
|
|
|
|
|
|
|
|
|
| 21 |
import core.odoo as O
|
| 22 |
import core.periods as P
|
| 23 |
import core.store as store
|
|
@@ -31,6 +34,57 @@ LIMIT = 500 # honest builder display cap β always shown with the full
|
|
| 31 |
KEY = 'customer_lists'
|
| 32 |
TABLE_KEY = 'customer_table_workspace'
|
| 33 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 34 |
# ------------------------------------------------------------------ the metric pool
|
| 35 |
# Field metadata for the rule builder: key -> (label, kind). 'num' fields take >=/<=/>/</=,
|
| 36 |
# 'text' fields take contains/=. Every field is a column of pool() rows.
|
|
@@ -577,6 +631,19 @@ def _pool_build(agent_name, team_id, limit, fast=False):
|
|
| 577 |
# Row-level datum for the `created_time` field type (wave-5 item 11) β rides every
|
| 578 |
# row like pid, no column of its own until a user creates one.
|
| 579 |
'_created': a.get('created_at', ''),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 580 |
'tags': a.get('tags', '(none)'), 'pricelist': a.get('pricelist', '(none)'),
|
| 581 |
# AR / credit exposure β composed from the already-reconciled ar.py blocks, so the
|
| 582 |
# Customer table and the Collections page cannot disagree.
|
|
@@ -679,7 +746,12 @@ def _reconcile_ledger(rows, total, agent_name, team_id):
|
|
| 679 |
'agent': '(none)', 'street': '(none)', 'street2': '(none)',
|
| 680 |
'city': '(none)', 'state': '(none)', 'country': '(none)',
|
| 681 |
'zip': '(none)', 'payment_terms': '(none)', 'customer_since': '',
|
| 682 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 683 |
'ar_open': 0.0, 'ar_overdue': 0.0, 'ar_outstanding': 0.0, 'ar_exposure': 0.0,
|
| 684 |
'days_to_pay': None,
|
| 685 |
**{k: 0.0 for k in AR_BUCKET_FIELDS.values()},
|
|
|
|
| 18 |
The userβagent link (users.py 'agent' field) scopes the pool to that agent's book; users with
|
| 19 |
no link (owner/CFO/admin) see the whole book.
|
| 20 |
"""
|
| 21 |
+
import re
|
| 22 |
+
from urllib.parse import quote_plus
|
| 23 |
+
|
| 24 |
import core.odoo as O
|
| 25 |
import core.periods as P
|
| 26 |
import core.store as store
|
|
|
|
| 34 |
KEY = 'customer_lists'
|
| 35 |
TABLE_KEY = 'customer_table_workspace'
|
| 36 |
|
| 37 |
+
# ------------------------------------------------------------------ the Google Maps link
|
| 38 |
+
#: The sentinel every blank connector attribute collapses to (`customers._partner_attrs` writes
|
| 39 |
+
#: it; the client's `CONNECTOR_BLANK` renders it). It is a real, visible value on the grid, NOT a
|
| 40 |
+
#: null β so an address builder that treats it as text pastes the literal string "(none)" into a
|
| 41 |
+
#: query and sends the reader to a place called none.
|
| 42 |
+
BLANK_ATTR = '(none)'
|
| 43 |
+
|
| 44 |
+
#: A trailing ISO country code in parentheses, as `O.m2o_name(state_id)` yields it: Odoo's state
|
| 45 |
+
#: names read "Texas (US)". β ANCHORED and UPPERCASE-ONLY on purpose. A greedy "strip the last
|
| 46 |
+
#: parenthetical" would eat a legitimate name that happens to end in brackets, and there is no
|
| 47 |
+
#: reason to risk that for a tidiness fix.
|
| 48 |
+
_STATE_COUNTRY_SUFFIX = re.compile(r'\s*\([A-Z]{2,3}\)$')
|
| 49 |
+
|
| 50 |
+
#: Google's documented Maps URLs endpoint for a place SEARCH. The same shape the client already
|
| 51 |
+
#: builds for a pin (`customer-grid/mapProjection.ts`), so the two doors agree.
|
| 52 |
+
MAPS_SEARCH_URL = 'https://www.google.com/maps/search/?api=1&query='
|
| 53 |
+
|
| 54 |
+
|
| 55 |
+
def _addr_part(v):
|
| 56 |
+
"""One address line, or '' β the sentinel and whitespace both read as absent."""
|
| 57 |
+
s = str(v or '').strip()
|
| 58 |
+
return '' if not s or s == BLANK_ATTR else s
|
| 59 |
+
|
| 60 |
+
|
| 61 |
+
def maps_url(a):
|
| 62 |
+
"""A Google Maps link to a partner's address, or '' when there is no address to point at.
|
| 63 |
+
|
| 64 |
+
ββ W40-T08 (owner I27) β SERVER-SIDE, and that is the whole design, per the wave's AM-1. The
|
| 65 |
+
owner's instruction offered a client Formula as one option; D-115 says a formula column's
|
| 66 |
+
values exist only in the browser, so the link would be blank in every host-side export and
|
| 67 |
+
invisible to anything reading the stored cell. Computed here it is an ordinary cell value on
|
| 68 |
+
the pool row, so it exports, filters and reads back like any other column.
|
| 69 |
+
|
| 70 |
+
β BLANK UNLESS THE ROW CAN ACTUALLY BE LOCATED. The gate is street OR city OR zip: a country
|
| 71 |
+
alone ("United States") resolves to a link that opens the middle of a continent, which is
|
| 72 |
+
worse than an empty cell because it looks like an answer. MEASURED 2026-08-23: 140 of 3,641
|
| 73 |
+
customers have no street, city or zip, and those are the rows this returns '' for.
|
| 74 |
+
|
| 75 |
+
β `state` is stripped of its country suffix. It arrives as `O.m2o_name(state_id)`, i.e.
|
| 76 |
+
"Texas (US)", and the country is already its own part of the address. Google resolves the
|
| 77 |
+
string either way, so this is a tidiness call, not a correctness one.
|
| 78 |
+
"""
|
| 79 |
+
street, street2 = _addr_part(a.get('street')), _addr_part(a.get('street2'))
|
| 80 |
+
city, zipcode = _addr_part(a.get('city')), _addr_part(a.get('zip'))
|
| 81 |
+
if not (street or city or zipcode):
|
| 82 |
+
return ''
|
| 83 |
+
state = _STATE_COUNTRY_SUFFIX.sub('', _addr_part(a.get('state')))
|
| 84 |
+
parts = [p for p in (street, street2, city, state, zipcode,
|
| 85 |
+
_addr_part(a.get('country'))) if p]
|
| 86 |
+
return MAPS_SEARCH_URL + quote_plus(', '.join(parts))
|
| 87 |
+
|
| 88 |
# ------------------------------------------------------------------ the metric pool
|
| 89 |
# Field metadata for the rule builder: key -> (label, kind). 'num' fields take >=/<=/>/</=,
|
| 90 |
# 'text' fields take contains/=. Every field is a column of pool() rows.
|
|
|
|
| 631 |
# Row-level datum for the `created_time` field type (wave-5 item 11) β rides every
|
| 632 |
# row like pid, no column of its own until a user creates one.
|
| 633 |
'_created': a.get('created_at', ''),
|
| 634 |
+
# ββ W40-T08 (owner I24) β the DECLARED pre-set date column, beside the row datum
|
| 635 |
+
# above rather than instead of it. `_created` is only ever readable through a
|
| 636 |
+
# `created_time` column the user has to create; this is a real cell under its own key,
|
| 637 |
+
# so it exports, filters and appears in the semantic topic. Truncated the way
|
| 638 |
+
# `customer_since` is, and for the same reason: a date-typed column compared
|
| 639 |
+
# ISO-LEXICALLY drifts by the time component if the time is left on.
|
| 640 |
+
# β The value is IDENTICAL to `customer_since` on this database, because both come
|
| 641 |
+
# from `res.partner.create_date`. That is not a duplicate by accident: "Customer
|
| 642 |
+
# since" is a business fact about the relationship and cannot be the uniform
|
| 643 |
+
# records-created column I24 asks every database for (Products has no such notion).
|
| 644 |
+
'created_on': str(a.get('created_at') or '')[:10],
|
| 645 |
+
# ββ W40-T08 (owner I27) β the Google Maps link, replacing the hardcoded "Go" column.
|
| 646 |
+
'maps_url': maps_url(a),
|
| 647 |
'tags': a.get('tags', '(none)'), 'pricelist': a.get('pricelist', '(none)'),
|
| 648 |
# AR / credit exposure β composed from the already-reconciled ar.py blocks, so the
|
| 649 |
# Customer table and the Collections page cannot disagree.
|
|
|
|
| 746 |
'agent': '(none)', 'street': '(none)', 'street2': '(none)',
|
| 747 |
'city': '(none)', 'state': '(none)', 'country': '(none)',
|
| 748 |
'zip': '(none)', 'payment_terms': '(none)', 'customer_since': '',
|
| 749 |
+
# W40-T08 lands on BOTH row templates, which is the warning above being obeyed
|
| 750 |
+
# rather than restated. A revived row has no address and no create_date to read,
|
| 751 |
+
# so both are blank β and blank is exactly what `maps_url` returns for an
|
| 752 |
+
# addressless customer anyway, so the archived rows agree with the live ones.
|
| 753 |
+
'_created': '', 'created_on': '', 'maps_url': '',
|
| 754 |
+
'tags': '(none)', 'pricelist': '(none)',
|
| 755 |
'ar_open': 0.0, 'ar_overdue': 0.0, 'ar_outstanding': 0.0, 'ar_exposure': 0.0,
|
| 756 |
'days_to_pay': None,
|
| 757 |
**{k: 0.0 for k in AR_BUCKET_FIELDS.values()},
|
platform/modules/inventory.py
CHANGED
|
@@ -14,11 +14,29 @@ import core.periods as P
|
|
| 14 |
|
| 15 |
|
| 16 |
def _cat_main_map():
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 17 |
cats = O.search_read('product.category', [], ['id', 'complete_name'])
|
| 18 |
out = {}
|
| 19 |
for c in cats:
|
| 20 |
parts = [x.strip() for x in (c['complete_name'] or '').split('/')]
|
| 21 |
-
out[c['id']] = parts[1] if len(parts) >= 2 else
|
| 22 |
return out
|
| 23 |
|
| 24 |
|
|
@@ -220,8 +238,33 @@ def _bucket(dos_raw, on_hand, qty_ltm):
|
|
| 220 |
return _COVERAGE_BUCKETS[-1][0]
|
| 221 |
|
| 222 |
|
| 223 |
-
#
|
| 224 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 225 |
|
| 226 |
|
| 227 |
def sku_inventory(target_days=180, carry_pct=_CARRY_PCT, t=None):
|
|
|
|
| 14 |
|
| 15 |
|
| 16 |
def _cat_main_map():
|
| 17 |
+
"""{category id: MAIN category name}, the SECOND segment of Odoo's `complete_name` path.
|
| 18 |
+
|
| 19 |
+
THE ROOT MAPS TO `None`, NOT TO ITS OWN NAME (owner instruction 23, wave 40). Odoo roots the
|
| 20 |
+
whole category tree at one node whose `complete_name` is the bare word "All", and the old
|
| 21 |
+
`parts[0]` fallback handed that word out as though it were a category. It is not one: it is
|
| 22 |
+
the tree's root, and a product filed directly on it is UNCATEGORISED. Exactly one of the 74
|
| 23 |
+
categories is single segment, so the root is the only value that could ever reach this branch.
|
| 24 |
+
|
| 25 |
+
MEASURED live 2026-08-23: 3,334 of 5,841 coded products (57.1%) sit directly on the root, so
|
| 26 |
+
this is the MAJORITY of the catalogue and not an edge case.
|
| 27 |
+
|
| 28 |
+
`None` IS THE CONTRACT, and all three callers already honour it. `inventory._build`,
|
| 29 |
+
`financial._product_cat` and `sales._product_cat` each read this map through
|
| 30 |
+
`... or '(uncategorized)'`, which is the sentinel the product grid's own field description
|
| 31 |
+
already promises: "Product category; '(uncategorized)' when Odoo carries none". So the root's
|
| 32 |
+
products land on the DECLARED blank value instead of on an invented label, and no caller has
|
| 33 |
+
to learn a new convention.
|
| 34 |
+
"""
|
| 35 |
cats = O.search_read('product.category', [], ['id', 'complete_name'])
|
| 36 |
out = {}
|
| 37 |
for c in cats:
|
| 38 |
parts = [x.strip() for x in (c['complete_name'] or '').split('/')]
|
| 39 |
+
out[c['id']] = parts[1] if len(parts) >= 2 else None
|
| 40 |
return out
|
| 41 |
|
| 42 |
|
|
|
|
| 238 |
return _COVERAGE_BUCKETS[-1][0]
|
| 239 |
|
| 240 |
|
| 241 |
+
#: β AM-4 (2026-08-23), BRANCH (c) β WHAT A SKU WITH NO INVENTORY ROW SAYS FOR ITSELF.
|
| 242 |
+
#: `_bucket` never returns this and never can: it is `product_data._dos_with_inbound`'s answer for
|
| 243 |
+
#: `on_hand is None`, a case that returns before `_bucket` is reached. It lives here, named, rather
|
| 244 |
+
#: than as a literal there, because two places must spell it identically β the product row that
|
| 245 |
+
#: carries it, and the permission editor's dropdown, which `routes_admin::
|
| 246 |
+
#: _server_side_vocabularies` fills from the list below.
|
| 247 |
+
#:
|
| 248 |
+
#: β THE WORDING IS LOAD-BEARING, NOT DECORATION, and AM-4 is explicit about why.
|
| 249 |
+
#: `product_data._inventory_by_code` degrades to `{}` on ANY failure, so during an inventory-read
|
| 250 |
+
#: outage EVERY product in the catalogue renders this label at once. "Stock not tracked" would
|
| 251 |
+
#: then be a catalogue-wide false claim about the warehouse, and "never sold" is false for most of
|
| 252 |
+
#: these rows even on a good day. What is genuinely absent in BOTH cases β the ~33 products with
|
| 253 |
+
#: no `default_code`, and an outage β is the RECORD, so that is what the label names.
|
| 254 |
+
NO_STOCK_RECORD = 'No stock record'
|
| 255 |
+
|
| 256 |
+
# Every value a `stock_bucket` cell can hold, and the vocabulary the permission editor offers for
|
| 257 |
+
# that column (`routes_admin::_server_side_vocabularies` imports this rather than restating it).
|
| 258 |
+
# The coverage BANDS run worstβbest between the two ends; the last two are not on that axis at all
|
| 259 |
+
# β 'No recent sales' is a full shelf nobody is buying from, and `NO_STOCK_RECORD` means there is
|
| 260 |
+
# no reading of the shelf to band in the first place.
|
| 261 |
+
# β THE ORDER IS FOR A READER OF THIS FILE, NOT A CONTRACT ANY SURFACE HONOURS. Measured
|
| 262 |
+
# 2026-08-24: `routes_admin.py:868` re-sorts every supplied vocabulary alphabetically, and the
|
| 263 |
+
# grid's own dropdown (`types.ts::choiceVocabulary`) discovers values from loaded ROWS and sorts
|
| 264 |
+
# them too. Same SET on both, never this sequence. Do not add a label here expecting it to land in
|
| 265 |
+
# a particular slot on screen.
|
| 266 |
+
COVERAGE_LABELS = (['Out of stock'] + [b[0] for b in _COVERAGE_BUCKETS]
|
| 267 |
+
+ ['No recent sales', NO_STOCK_RECORD])
|
| 268 |
|
| 269 |
|
| 270 |
def sku_inventory(target_days=180, carry_pct=_CARRY_PCT, t=None):
|
platform/modules/product_data.py
CHANGED
|
@@ -340,11 +340,27 @@ def _inventory_by_code(t):
|
|
| 340 |
Degrades to empty rather than raising, matching `customer_data._pool_build`'s treatment of
|
| 341 |
its own slow families: a product table that will not render because inventory is momentarily
|
| 342 |
unreachable is a worse failure than one with blank stock columns.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 343 |
"""
|
| 344 |
try:
|
| 345 |
import modules.inventory as inventory
|
| 346 |
return inventory.sku_inventory(t=t) or {}
|
| 347 |
-
except Exception:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 348 |
return {}
|
| 349 |
|
| 350 |
|
|
@@ -405,7 +421,20 @@ def _bu_ltm_share(t, team_id):
|
|
| 405 |
for code, r in (products._sku_rev(f, to, None, all_channels=True) or {}).items()}
|
| 406 |
buq = {code: (r.get('qty') or 0.0)
|
| 407 |
for code, r in (products._sku_rev(f, to, team_id) or {}).items()}
|
| 408 |
-
except Exception:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 409 |
return {}
|
| 410 |
out = {}
|
| 411 |
for code, total in allq.items():
|
|
@@ -442,9 +471,30 @@ def _dos_with_inbound(on_hand, incoming, qty_ltm):
|
|
| 442 |
|
| 443 |
β `on_hand is None` means no inventory row for this SKU: blank, never zero. Inbound alone
|
| 444 |
cannot manufacture a days-of-supply for a SKU the warehouse has never heard of.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 445 |
"""
|
| 446 |
if on_hand is None:
|
| 447 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 448 |
effective = float(on_hand) + float(incoming or 0.0)
|
| 449 |
qty = float(qty_ltm or 0.0)
|
| 450 |
daily = qty / 365.0
|
|
@@ -475,7 +525,13 @@ def _rescope_inventory(e, share, incoming=None):
|
|
| 475 |
"""
|
| 476 |
on_hand = e.get("on_hand")
|
| 477 |
if on_hand is None:
|
| 478 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 479 |
qty = float(e.get("qty_ltm") or 0.0) * float(share or 0.0)
|
| 480 |
# β THE FORMULA MOVED TO `_dos_with_inbound` (owner 2026-08-19) so the scoped and consolidated
|
| 481 |
# paths cannot answer days-of-supply differently. Only the NUMERATOR is BU-shaped: `qty` is
|
|
@@ -587,6 +643,24 @@ def pool(team_id=None, t=None):
|
|
| 587 |
# it and it has to be carried from `products.catalogue()`.
|
| 588 |
# β `None`, never 0, when the catalogue somehow has no id β 0 is a real Odoo id.
|
| 589 |
"product_id": meta.get("id"),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 590 |
# β R12 β BLANK, NEVER $0, on a SKU no revenue read ever saw. A row that IS in `rev`
|
| 591 |
# keeps its measured numbers including a real 0.0 (it sold last year, not this one).
|
| 592 |
"rev_ytd": r.get("rev_ytd", 0.0) if r else None,
|
|
@@ -621,6 +695,27 @@ def pool(team_id=None, t=None):
|
|
| 621 |
_tier = _tiers[_n - 1] if len(_tiers) >= _n else None
|
| 622 |
row[f"price_{_n}"] = _tier.get("unit_price") if _tier else None
|
| 623 |
row[f"unit_{_n}"] = _tier.get("unit") if _tier else None
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 624 |
# W39-T14: these are open customer promises, not sales velocity. A missing code is an
|
| 625 |
# observed zero in the grouped backlog read, so 0.0 is the honest cell rather than blank.
|
| 626 |
row["pre_book_qty"] = pre_book.get(code, 0.0)
|
|
@@ -1329,14 +1424,76 @@ def validate_price_and_unit_cells(rows, sample=6):
|
|
| 1329 |
"detail": {"two_or_more_prices": sum(1 for r in rows if r.get("price_2") is not None),
|
| 1330 |
"three_prices": sum(1 for r in rows if r.get("price_3") is not None)},
|
| 1331 |
})
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1332 |
if not priced:
|
| 1333 |
return checks
|
| 1334 |
o = O.get_odoo()
|
| 1335 |
today = P.today().isoformat()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1336 |
# Prefer SKUs that carry more than one price, the ticket's own subject.
|
| 1337 |
cand = sorted(priced,
|
| 1338 |
key=lambda r: -sum(r.get(f"price_{n}") is not None for n in range(1, 4)))[:sample]
|
| 1339 |
bad = []
|
|
|
|
| 1340 |
for r in cand:
|
| 1341 |
mine = sorted((round(float(r[f"price_{n}"]), 2), str(r.get(f"unit_{n}") or "").strip())
|
| 1342 |
for n in range(1, 4) if r.get(f"price_{n}") is not None)
|
|
@@ -1370,6 +1527,38 @@ def validate_price_and_unit_cells(rows, sample=6):
|
|
| 1370 |
# product's rules (D-309 / `2112-12`), so ours is a SUPERSET, never an equality.
|
| 1371 |
if not set(theirs) <= set(mine):
|
| 1372 |
bad.append({"sku": r.get("code"), "ours": mine, "odoo": theirs})
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1373 |
checks.append({
|
| 1374 |
"check": f"each sampled SKU's typed Price/Unit pairs contain every live Odoo pair "
|
| 1375 |
f"({len(cand)} SKUs, chosen for the most prices)",
|
|
@@ -1377,6 +1566,19 @@ def validate_price_and_unit_cells(rows, sample=6):
|
|
| 1377 |
"detail": {"mismatches": bad[:3],
|
| 1378 |
"sampled": [r.get("code") for r in cand]},
|
| 1379 |
})
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1380 |
return checks
|
| 1381 |
|
| 1382 |
|
|
|
|
| 340 |
Degrades to empty rather than raising, matching `customer_data._pool_build`'s treatment of
|
| 341 |
its own slow families: a product table that will not render because inventory is momentarily
|
| 342 |
unreachable is a worse failure than one with blank stock columns.
|
| 343 |
+
|
| 344 |
+
β AM-4 (2026-08-23) β THE DEGRADE STAYS, THE SILENCE DOES NOT. `{}` here makes EVERY code miss
|
| 345 |
+
the inventory join, so every row takes `_dos_with_inbound`'s `on_hand is None` branch and the
|
| 346 |
+
whole 5,873-row catalogue renders as branch (c) β indistinguishable, on screen, from the 33
|
| 347 |
+
products that genuinely have no `default_code`. That is the exact reason branch (c)'s label
|
| 348 |
+
says 'No stock record' rather than "stock is not tracked": the copy has to stay true when this
|
| 349 |
+
swallow is the cause. The label makes the outage HONEST; this line makes it FINDABLE.
|
| 350 |
"""
|
| 351 |
try:
|
| 352 |
import modules.inventory as inventory
|
| 353 |
return inventory.sku_inventory(t=t) or {}
|
| 354 |
+
except Exception as e: # noqa: BLE001
|
| 355 |
+
# Owner rule 2026-07-23, in `telemetry.error`'s own docstring: call it from EVERY except
|
| 356 |
+
# block that swallows or downgrades. NOT nested in a second try, and the degrade contract
|
| 357 |
+
# above survives that: `telemetry.error`'s entire body is wrapped and it never raises, and
|
| 358 |
+
# `harness` is a sibling package of the `core` this module already imports at line 62, so
|
| 359 |
+
# an import failure here would mean a `platform` on no importable path β a state in which
|
| 360 |
+
# `product_data` itself could not have loaded. Same shape as `customer_data._book_pids`.
|
| 361 |
+
import harness.telemetry as _tel
|
| 362 |
+
_tel.error('product_data:_inventory_by_code', e,
|
| 363 |
+
fallback="blank stock cells on every product row; all render 'No stock record'")
|
| 364 |
return {}
|
| 365 |
|
| 366 |
|
|
|
|
| 421 |
for code, r in (products._sku_rev(f, to, None, all_channels=True) or {}).items()}
|
| 422 |
buq = {code: (r.get('qty') or 0.0)
|
| 423 |
for code, r in (products._sku_rev(f, to, team_id) or {}).items()}
|
| 424 |
+
except Exception as e: # noqa: BLE001
|
| 425 |
+
# β THE SIBLING OF `_inventory_by_code`'s SWALLOW, AND THE SAME FAILURE IN THE OTHER
|
| 426 |
+
# COLUMN. `{}` here sends every code to `_DEFAULT_SHARE` = 0.0, so a BU-scoped pull gives
|
| 427 |
+
# every SKU `qty_ltm` 0 and the whole scoped catalogue reads 'No recent sales' β branch
|
| 428 |
+
# (a) manufactured wholesale, exactly as an inventory outage manufactures branch (c). AM-4
|
| 429 |
+
# names only the inventory swallow; this one is logged for the same reason and by the same
|
| 430 |
+
# owner rule, because a branch label is only honest if the way it can be faked is findable.
|
| 431 |
+
# The other eight swallows in this module are left alone: they blank a column that reads
|
| 432 |
+
# visibly empty, or already return a `report` dict naming the error.
|
| 433 |
+
import harness.telemetry as _tel
|
| 434 |
+
_tel.error('product_data:_bu_ltm_share', e,
|
| 435 |
+
team_id=team_id,
|
| 436 |
+
fallback="every BU share defaults to 0.0; a scoped pull reads "
|
| 437 |
+
"'No recent sales' on every row")
|
| 438 |
return {}
|
| 439 |
out = {}
|
| 440 |
for code, total in allq.items():
|
|
|
|
| 471 |
|
| 472 |
β `on_hand is None` means no inventory row for this SKU: blank, never zero. Inbound alone
|
| 473 |
cannot manufacture a days-of-supply for a SKU the warehouse has never heard of.
|
| 474 |
+
|
| 475 |
+
β AM-4 (2026-08-23) β AND THAT BLANK NOW SAYS WHY. The three no-sales branches are three
|
| 476 |
+
different sentences and used to render as two: (a) stock on hand, nothing sold in the window,
|
| 477 |
+
a blank `dos` beside **'No recent sales'** β R3's ruling, already true; (b) nothing sold AND
|
| 478 |
+
nothing on the shelf, `0.0` beside 'Out of stock' β LEFT AS IT IS and BOOKED by AM-4, because
|
| 479 |
+
changing it blind would make a second number ambiguous; (c) `on_hand is None`, which returned
|
| 480 |
+
`(None, None)` β a blank `dos` beside a blank bucket, a row that said nothing at all about
|
| 481 |
+
itself. It now carries `inventory.NO_STOCK_RECORD`. MEASURED live 2026-08-24 over the 5,873
|
| 482 |
+
catalogue codes: (a) 528, (b) 2,521, (c) 33, normally selling 2,791.
|
| 483 |
+
|
| 484 |
+
β (c) AND THE TOTAL REPRODUCE; THE (a)/(b) SPLIT DID NOT, AND THE CAUSE IS NOT ESTABLISHED.
|
| 485 |
+
An earlier census the same day read 562/2,487 where this one reads 528/2,521. The no-sales
|
| 486 |
+
COHORT is 3,049 in both, (c) is 33 in both and the catalogue is 5,873 in both, so 34 codes
|
| 487 |
+
crossed the on-hand-zero line inside a cohort that did not otherwise move. Do not quote a
|
| 488 |
+
reason for that here: none was measured. What IS established is that nothing on this function's
|
| 489 |
+
changed path can move it β the split is read from `sku_inventory`'s `on_hand` and `qty_ltm`,
|
| 490 |
+
and only the `on_hand is None` branch below was touched.
|
| 491 |
"""
|
| 492 |
if on_hand is None:
|
| 493 |
+
try:
|
| 494 |
+
import modules.inventory as inventory
|
| 495 |
+
return None, inventory.NO_STOCK_RECORD
|
| 496 |
+
except Exception: # noqa: BLE001
|
| 497 |
+
return None, None
|
| 498 |
effective = float(on_hand) + float(incoming or 0.0)
|
| 499 |
qty = float(qty_ltm or 0.0)
|
| 500 |
daily = qty / 365.0
|
|
|
|
| 525 |
"""
|
| 526 |
on_hand = e.get("on_hand")
|
| 527 |
if on_hand is None:
|
| 528 |
+
# No inventory row for this SKU: both numbers stay blank, never a fabricated zero.
|
| 529 |
+
# β THE LABEL COMES THROUGH `_dos_with_inbound`, NOT FROM A LITERAL HERE. AM-4's branch (c)
|
| 530 |
+
# copy has to be the SAME SENTENCE on a consolidated and a BU-scoped pull; spelling it
|
| 531 |
+
# twice is precisely how these two functions were drifting apart before the 2026-08-19
|
| 532 |
+
# ruling merged their arithmetic ([[one-question-two-normalizers]]).
|
| 533 |
+
_dos, _bucket = _dos_with_inbound(None, incoming, 0.0)
|
| 534 |
+
return None, _dos, _bucket
|
| 535 |
qty = float(e.get("qty_ltm") or 0.0) * float(share or 0.0)
|
| 536 |
# β THE FORMULA MOVED TO `_dos_with_inbound` (owner 2026-08-19) so the scoped and consolidated
|
| 537 |
# paths cannot answer days-of-supply differently. Only the NUMERATOR is BU-shaped: `qty` is
|
|
|
|
| 643 |
# it and it has to be carried from `products.catalogue()`.
|
| 644 |
# β `None`, never 0, when the catalogue somehow has no id β 0 is a real Odoo id.
|
| 645 |
"product_id": meta.get("id"),
|
| 646 |
+
# ββ W40-T08 (owner I24, "a records created date on all of our databases") β the
|
| 647 |
+
# record's birth date, in BOTH of the two shapes the grid reads, because they are two
|
| 648 |
+
# different things and only one of them is a column:
|
| 649 |
+
# `_created` is the ROW-LEVEL datum, like `pid` and `lat`/`lon`. `rows_from_pool`
|
| 650 |
+
# copies it onto every row and the `created_time` FIELD TYPE renders it whatever
|
| 651 |
+
# that field's own key is. Until this line it was never set here, so a
|
| 652 |
+
# `created_time` column a user created on the SKU grid rendered blank for all
|
| 653 |
+
# 5,873 of them while the same column on the customer grid worked.
|
| 654 |
+
# `created_on` is the declared pre-set DATE column. It is a real cell under its own
|
| 655 |
+
# key, which is what makes it exportable, filterable and visible in the semantic
|
| 656 |
+
# topic; a `created_time` column is none of those things server-side, because its
|
| 657 |
+
# value never lives at its own key.
|
| 658 |
+
# β Truncated to 10 chars for the DATE column and kept whole for `_created`, matching
|
| 659 |
+
# the `customer_since` / `created_at` split `customers._partner_attrs` already makes:
|
| 660 |
+
# the grid compares dates ISO-LEXICALLY, so a trailing time on a date-typed column
|
| 661 |
+
# drifts every anchor and `is within` comparison by the time component.
|
| 662 |
+
"_created": meta.get("created_at") or "",
|
| 663 |
+
"created_on": (meta.get("created_at") or "")[:10],
|
| 664 |
# β R12 β BLANK, NEVER $0, on a SKU no revenue read ever saw. A row that IS in `rev`
|
| 665 |
# keeps its measured numbers including a real 0.0 (it sold last year, not this one).
|
| 666 |
"rev_ytd": r.get("rev_ytd", 0.0) if r else None,
|
|
|
|
| 695 |
_tier = _tiers[_n - 1] if len(_tiers) >= _n else None
|
| 696 |
row[f"price_{_n}"] = _tier.get("unit_price") if _tier else None
|
| 697 |
row[f"unit_{_n}"] = _tier.get("unit") if _tier else None
|
| 698 |
+
# ββ W40-T09 / RULING R6 (owner I25) β THE SAME PRICES, ATTRIBUTED TO THE LIST THAT
|
| 699 |
+
# CHARGES THEM: three (price, unit) pairs each for Fisch, Royal 1 and Royal 2.
|
| 700 |
+
#
|
| 701 |
+
# β THIS SUPERSEDES THE SIX LINES ABOVE RATHER THAN EXTENDING THEM, and the difference
|
| 702 |
+
# is the whole ticket. `price_1..3` are the cheapest three POOLED ACROSS EVERY LIST and
|
| 703 |
+
# carry no attribution, so on the 1,854 SKUs priced on all three lists they answer a
|
| 704 |
+
# question nobody asked: not "what does Fisch charge" but "what are the three lowest
|
| 705 |
+
# numbers anyone charges". The pooled six stay DECLARED and stay WRITTEN β a saved view
|
| 706 |
+
# or a stored permission wall naming one must keep working β but they are demoted to
|
| 707 |
+
# `default: false` in the contract so the default view stops offering the approximation.
|
| 708 |
+
#
|
| 709 |
+
# β NO SECOND ODOO READ. `tiers` already carries the pricelist name on every entry;
|
| 710 |
+
# `per_list_tier_cells` is a group-by over the list this loop is already holding.
|
| 711 |
+
row.update(products.per_list_tier_cells(_tiers))
|
| 712 |
+
# β The cap's own receipt, and it is SET ONLY WHEN NON-EMPTY. `rows_from_pool` projects
|
| 713 |
+
# strictly by the declared contract, so this rides the pool row for `validate()` and can
|
| 714 |
+
# never reach a grid cell; writing `{}` on all 5,873 rows to say "nothing dropped" would
|
| 715 |
+
# cost 5,873 dicts to carry one fact (MEASURED: exactly one SKU/list pair is over depth).
|
| 716 |
+
_ovf = products.tier_cap_overflow(_tiers)
|
| 717 |
+
if _ovf:
|
| 718 |
+
row["_tier_overflow"] = _ovf
|
| 719 |
# W39-T14: these are open customer promises, not sales velocity. A missing code is an
|
| 720 |
# observed zero in the grouped backlog read, so 0.0 is the honest cell rather than blank.
|
| 721 |
row["pre_book_qty"] = pre_book.get(code, 0.0)
|
|
|
|
| 1424 |
"detail": {"two_or_more_prices": sum(1 for r in rows if r.get("price_2") is not None),
|
| 1425 |
"three_prices": sum(1 for r in rows if r.get("price_3") is not None)},
|
| 1426 |
})
|
| 1427 |
+
|
| 1428 |
+
# ββ W40-T09 / R6 β the PER-LIST cells, which is what the pooled three above are not ββββββ
|
| 1429 |
+
_tier_keys = [k for t in products.PRICELIST_TIER_COLUMNS for k in t[:2]]
|
| 1430 |
+
_typed = [r for r in rows if all(k in r for k in _tier_keys)]
|
| 1431 |
+
_per_list = {}
|
| 1432 |
+
for _p, _u, _name, _n in products.PRICELIST_TIER_COLUMNS:
|
| 1433 |
+
_per_list.setdefault(_name, {})[f"t{_n}"] = sum(1 for r in rows if r.get(_p) is not None)
|
| 1434 |
+
checks.append({
|
| 1435 |
+
"check": "the product grid serves all 18 per-list tier cells (price and unit 1..3 for "
|
| 1436 |
+
"each declared pricelist), typed and on every row",
|
| 1437 |
+
"ours": {"rows_with_all_18": len(_typed), "rows": len(rows), "cells": len(_tier_keys)},
|
| 1438 |
+
"theirs": {"rows_with_all_18": len(rows), "cells": 18},
|
| 1439 |
+
"ok": len(_typed) == len(rows) and len(_tier_keys) == 18,
|
| 1440 |
+
"detail": {"skus_priced_per_list": _per_list},
|
| 1441 |
+
})
|
| 1442 |
+
# β CHEAPEST-FIRST PACKS FROM THE TOP, so a hole is the signature of a misaligned write:
|
| 1443 |
+
# tier 2 present with tier 1 empty would mean the cells no longer mean "the nth cheapest".
|
| 1444 |
+
_price_key = {(_name, _n): _p
|
| 1445 |
+
for _p, _u, _name, _n in products.PRICELIST_TIER_COLUMNS}
|
| 1446 |
+
_unit_key = {(_name, _n): _u
|
| 1447 |
+
for _p, _u, _name, _n in products.PRICELIST_TIER_COLUMNS}
|
| 1448 |
+
_declared_names = list(dict.fromkeys(_n2 for _p, _u, _n2, _n in
|
| 1449 |
+
products.PRICELIST_TIER_COLUMNS))
|
| 1450 |
+
_holes = [r.get("code") for r in rows
|
| 1451 |
+
for (_name, _n), _p in _price_key.items()
|
| 1452 |
+
if _n > 1 and r.get(_p) is not None
|
| 1453 |
+
and r.get(_price_key[(_name, _n - 1)]) is None]
|
| 1454 |
+
checks.append({
|
| 1455 |
+
"check": "β no per-list tier has a HOLE beneath it: tier n is filled only when tier n-1 "
|
| 1456 |
+
"is, so the cells keep meaning 'the nth cheapest on THIS list'",
|
| 1457 |
+
"ours": len(_holes), "theirs": 0, "ok": not _holes,
|
| 1458 |
+
"detail": {"examples": sorted(set(_holes))[:5]},
|
| 1459 |
+
})
|
| 1460 |
+
# β STANDING RULE 1's SECOND SENTENCE β the cap is REPORTED, never silently enforced.
|
| 1461 |
+
_over = {}
|
| 1462 |
+
for r in rows:
|
| 1463 |
+
for _name, _dropped in (r.get("_tier_overflow") or {}).items():
|
| 1464 |
+
_over.setdefault(_name, []).append((r.get("code"), _dropped))
|
| 1465 |
+
checks.append({
|
| 1466 |
+
"check": f"REPORT (not a failure): tiers hidden by PRICELIST_TIER_DEPTH="
|
| 1467 |
+
f"{products.PRICELIST_TIER_DEPTH}. R6 declares three pairs per list; a SKU with "
|
| 1468 |
+
f"more carries the cheapest three and the rest are counted here. RECOMMENDED "
|
| 1469 |
+
f"FIX if the owner wants them: raise that ONE named constant in "
|
| 1470 |
+
f"modules/products.py. The reader already returns every tier, only the write "
|
| 1471 |
+
f"is capped, so nothing else changes.",
|
| 1472 |
+
"ours": {n: sorted(v) for n, v in _over.items()},
|
| 1473 |
+
"theirs": "counted, not dropped silently", "ok": True,
|
| 1474 |
+
"detail": {"sku_list_pairs_over_cap": sum(len(v) for v in _over.values())},
|
| 1475 |
+
})
|
| 1476 |
+
|
| 1477 |
if not priced:
|
| 1478 |
return checks
|
| 1479 |
o = O.get_odoo()
|
| 1480 |
today = P.today().isoformat()
|
| 1481 |
+
# ββ THE PRICELIST NAME IS THE `name` FIELD, NEVER THE m2o DISPLAY NAME, and this cost a
|
| 1482 |
+
# red gate on a correct build before it was written down. MEASURED 2026-08-24:
|
| 1483 |
+
# `product.pricelist.name` is 'Fisch', but the m2o that arrives on a `product.pricelist.item`
|
| 1484 |
+
# renders **'Fisch (USD)'** β Odoo appends the currency to the display name. Keying this
|
| 1485 |
+
# oracle on `m2o_name(pricelist_id)` therefore matches NOTHING in `PRICELIST_COLUMNS`, every
|
| 1486 |
+
# declared list reads as "this SKU is not priced here", and the no-borrow NC below reports
|
| 1487 |
+
# all 18 sampled SKU/list pairs as violations while the shipped cells are perfect.
|
| 1488 |
+
# `products.tier_prices_by_code` reads the field by id for exactly this reason, which is why
|
| 1489 |
+
# the DATA was right and only the check was wrong.
|
| 1490 |
+
_plname = {p["id"]: str(p.get("name") or "").strip()
|
| 1491 |
+
for p in o.search_read("product.pricelist", [], ["id", "name"])}
|
| 1492 |
# Prefer SKUs that carry more than one price, the ticket's own subject.
|
| 1493 |
cand = sorted(priced,
|
| 1494 |
key=lambda r: -sum(r.get(f"price_{n}") is not None for n in range(1, 4)))[:sample]
|
| 1495 |
bad = []
|
| 1496 |
+
bad_list, borrowed = [], [] # W40-T09: the per-list oracle and its no-borrow NC
|
| 1497 |
for r in cand:
|
| 1498 |
mine = sorted((round(float(r[f"price_{n}"]), 2), str(r.get(f"unit_{n}") or "").strip())
|
| 1499 |
for n in range(1, 4) if r.get(f"price_{n}") is not None)
|
|
|
|
| 1527 |
# product's rules (D-309 / `2112-12`), so ours is a SUPERSET, never an equality.
|
| 1528 |
if not set(theirs) <= set(mine):
|
| 1529 |
bad.append({"sku": r.get("code"), "ours": mine, "odoo": theirs})
|
| 1530 |
+
|
| 1531 |
+
# ββ W40-T09 / R6 β the SAME oracle, now asked PER LIST ββββββββββββββββββββββββββββββ
|
| 1532 |
+
# β SUPERSET, NOT EQUALITY, for the same D-309 reason as the pooled leg above: a code
|
| 1533 |
+
# carried by two active products merges here, so one list can legitimately hold more
|
| 1534 |
+
# pairs than a single product's rules. Equality would go red on a working build.
|
| 1535 |
+
theirs_by_list = {}
|
| 1536 |
+
for it in picked:
|
| 1537 |
+
theirs_by_list.setdefault(
|
| 1538 |
+
_plname.get(O.m2o_id(it.get("pricelist_id")), ""), []).append(
|
| 1539 |
+
(round(float(it.get("packaging_price") or it.get("fixed_price") or 0.0), 2),
|
| 1540 |
+
str(O.m2o_name(it.get("packaging_id")) or "").strip()))
|
| 1541 |
+
# β AN EMPTY ORACLE IS NOT EVIDENCE OF BORROWING. If the per-SKU read came back with no
|
| 1542 |
+
# rules at all, there is nothing to compare and firing the NC would report a broken
|
| 1543 |
+
# oracle as a data defect β the failure mode the display-name bug above actually
|
| 1544 |
+
# produced. The pooled leg is immune by construction (`set() <= set(mine)` passes); this
|
| 1545 |
+
# one has to say so.
|
| 1546 |
+
for _name in (_declared_names if picked else []):
|
| 1547 |
+
mine_l = sorted(
|
| 1548 |
+
(round(float(r[_price_key[(_name, n)]]), 2),
|
| 1549 |
+
str(r.get(_unit_key[(_name, n)]) or "").strip())
|
| 1550 |
+
for n in range(1, products.PRICELIST_TIER_DEPTH + 1)
|
| 1551 |
+
if r.get(_price_key[(_name, n)]) is not None)
|
| 1552 |
+
theirs_l = sorted(theirs_by_list.get(_name) or [])[:products.PRICELIST_TIER_DEPTH]
|
| 1553 |
+
if not set(theirs_l) <= set(mine_l):
|
| 1554 |
+
bad_list.append({"sku": r.get("code"), "list": _name,
|
| 1555 |
+
"ours": mine_l, "odoo": theirs_l})
|
| 1556 |
+
# β THE NO-BORROWING NEGATIVE CONTROL, at the grain that can actually fail it: a
|
| 1557 |
+
# list Odoo prices this SKU on NOWHERE must leave all six of its cells empty. The
|
| 1558 |
+
# failure being guarded is a group-by that falls through to the pooled cheapest and
|
| 1559 |
+
# prints another list's price under this list's heading.
|
| 1560 |
+
if not theirs_by_list.get(_name) and mine_l:
|
| 1561 |
+
borrowed.append({"sku": r.get("code"), "list": _name, "ours": mine_l})
|
| 1562 |
checks.append({
|
| 1563 |
"check": f"each sampled SKU's typed Price/Unit pairs contain every live Odoo pair "
|
| 1564 |
f"({len(cand)} SKUs, chosen for the most prices)",
|
|
|
|
| 1566 |
"detail": {"mismatches": bad[:3],
|
| 1567 |
"sampled": [r.get("code") for r in cand]},
|
| 1568 |
})
|
| 1569 |
+
checks.append({
|
| 1570 |
+
"check": f"each sampled SKU's PER-LIST tier cells contain every live Odoo pair ON THAT "
|
| 1571 |
+
f"LIST ({len(cand)} SKUs x {len(_declared_names)} declared pricelists)",
|
| 1572 |
+
"ours": len(bad_list), "theirs": 0, "ok": not bad_list,
|
| 1573 |
+
"detail": {"mismatches": bad_list[:3], "lists": _declared_names,
|
| 1574 |
+
"sampled": [r.get("code") for r in cand]},
|
| 1575 |
+
})
|
| 1576 |
+
checks.append({
|
| 1577 |
+
"check": "β NC: a list a SKU is not priced on leaves ALL SIX of its cells empty rather "
|
| 1578 |
+
"than borrowing another list's price",
|
| 1579 |
+
"ours": len(borrowed), "theirs": 0, "ok": not borrowed,
|
| 1580 |
+
"detail": {"borrowed": borrowed[:3]},
|
| 1581 |
+
})
|
| 1582 |
return checks
|
| 1583 |
|
| 1584 |
|
platform/modules/products.py
CHANGED
|
@@ -289,8 +289,13 @@ def catalogue():
|
|
| 289 |
# to aggregate it (`Fault 2: Cannot aggregate field 'incoming_qty'`), so nothing downstream
|
| 290 |
# may push a filter or a read_group on it back to Odoo. It is materialised into the pool here
|
| 291 |
# and summed on our side; `validate()` reconciles that sum against purchase-order lines.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 292 |
prods = O.search_read('product.product', dom,
|
| 293 |
-
['id', 'default_code', 'display_name', 'name',
|
| 294 |
'product_tag_ids', 'incoming_qty'],
|
| 295 |
limit=50000)
|
| 296 |
n = O.get_odoo().search_count('product.product', dom)
|
|
@@ -323,13 +328,23 @@ def catalogue():
|
|
| 323 |
# downstream in `aios_grid.py` and has to be carried from the source read.
|
| 324 |
row = out.setdefault(code, {'product': p.get('display_name') or p.get('name') or code,
|
| 325 |
'category': code_cat.get(code, '(uncategorized)'),
|
| 326 |
-
'id': p['id'],
|
| 327 |
'discontinued': 'No', 'incoming': 0.0})
|
| 328 |
# β ACROSS EVERY RECORD SHARING THE CODE, not just the first one that won above. A SKU
|
| 329 |
# whose variants are separate records carries its inbound on whichever record the PO named,
|
| 330 |
# and 'first record wins' would drop the rest β a buy list that under-counts what is
|
| 331 |
# already on the water tells you to re-order stock you have already bought.
|
| 332 |
row['incoming'] += float(p.get('incoming_qty') or 0.0)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 333 |
if disc_tag is not None and disc_tag in (p.get('product_tag_ids') or ()):
|
| 334 |
row['discontinued'] = 'Yes'
|
| 335 |
return out
|
|
@@ -432,6 +447,98 @@ PRICELIST_COLUMNS = (
|
|
| 432 |
("price_royal_2", "Royal 2"),
|
| 433 |
)
|
| 434 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 435 |
|
| 436 |
def pricelist_by_code():
|
| 437 |
"""`({code: {column_key: price}}, report)` β the date-valid FIXED base-tier price for each
|
|
|
|
| 289 |
# to aggregate it (`Fault 2: Cannot aggregate field 'incoming_qty'`), so nothing downstream
|
| 290 |
# may push a filter or a read_group on it back to Odoo. It is materialised into the pool here
|
| 291 |
# and summed on our side; `validate()` reconciles that sum against purchase-order lines.
|
| 292 |
+
# ββ W40-T08 (owner I24) β `create_date` RIDES THIS READ TOO, for the same reason the two
|
| 293 |
+
# above do. It has to come from the LIVE record: the DuckDB mirror's `product_product` carries
|
| 294 |
+
# `write_date` and NO `create_date`, so there is no cheaper source, and this read already pulls
|
| 295 |
+
# every active product once. MEASURED 2026-08-23 against live Odoo: 5,874 active products, of
|
| 296 |
+
# which 0 have a null `create_date`, so the column is populated for the whole catalogue.
|
| 297 |
prods = O.search_read('product.product', dom,
|
| 298 |
+
['id', 'default_code', 'display_name', 'name', 'create_date',
|
| 299 |
'product_tag_ids', 'incoming_qty'],
|
| 300 |
limit=50000)
|
| 301 |
n = O.get_odoo().search_count('product.product', dom)
|
|
|
|
| 328 |
# downstream in `aios_grid.py` and has to be carried from the source read.
|
| 329 |
row = out.setdefault(code, {'product': p.get('display_name') or p.get('name') or code,
|
| 330 |
'category': code_cat.get(code, '(uncategorized)'),
|
| 331 |
+
'id': p['id'], 'created_at': '',
|
| 332 |
'discontinued': 'No', 'incoming': 0.0})
|
| 333 |
# β ACROSS EVERY RECORD SHARING THE CODE, not just the first one that won above. A SKU
|
| 334 |
# whose variants are separate records carries its inbound on whichever record the PO named,
|
| 335 |
# and 'first record wins' would drop the rest β a buy list that under-counts what is
|
| 336 |
# already on the water tells you to re-order stock you have already bought.
|
| 337 |
row['incoming'] += float(p.get('incoming_qty') or 0.0)
|
| 338 |
+
# β W40-T08 β the EARLIEST create_date across the records sharing this code, not the
|
| 339 |
+
# first record's. A row here is a SKU, and the honest answer to "when was this record
|
| 340 |
+
# created" for a merged SKU is when the earliest of its records appeared. Only `2112-12`
|
| 341 |
+
# is affected today (5,873 active products, 5,872 distinct codes), so this is a one-row
|
| 342 |
+
# policy call rather than a measurable difference; it is written down because the
|
| 343 |
+
# first-wins convention above would otherwise read as covering this key too.
|
| 344 |
+
# β Lexical `<` is a real date comparison here: Odoo datetimes are fixed-width ISO.
|
| 345 |
+
_cd = str(p.get('create_date') or '')
|
| 346 |
+
if _cd and (not row['created_at'] or _cd < row['created_at']):
|
| 347 |
+
row['created_at'] = _cd
|
| 348 |
if disc_tag is not None and disc_tag in (p.get('product_tag_ids') or ()):
|
| 349 |
row['discontinued'] = 'Yes'
|
| 350 |
return out
|
|
|
|
| 447 |
("price_royal_2", "Royal 2"),
|
| 448 |
)
|
| 449 |
|
| 450 |
+
#: ββ W40-T09 / RULING R6 (owner I25: *"Fisch price and Royal price each have 3 units and 3
|
| 451 |
+
#: prices. Separate them and put all of them in the Odoo fields."*) β HOW MANY (price, unit)
|
| 452 |
+
#: PAIRS EACH DECLARED LIST SHOWS.
|
| 453 |
+
#:
|
| 454 |
+
#: β THIS CONSTANT IS THE CAP, AND NAMING IT IS THE POINT. `tier_prices_by_code` below returns
|
| 455 |
+
#: EVERY live tier a SKU has; only the WRITE into the grid is limited, and it is limited here in
|
| 456 |
+
#: one place rather than by a `range(1, 4)` inlined at the call site the way the pooled
|
| 457 |
+
#: `price_1..3` block was. MEASURED on the live book 2026-08-24 over 3,996 priced codes: exactly
|
| 458 |
+
#: ONE SKU/list pair exceeds this depth β `6AB` on Fisch, which carries FOUR tiers β so raising
|
| 459 |
+
#: this number to 4 is the whole of the fix if the owner ever wants that fourth cell. Max tiers
|
| 460 |
+
#: observed per list: Fisch 4, Royal 1 3, Royal 2 3, Public Pricelist 1.
|
| 461 |
+
PRICELIST_TIER_DEPTH = 3
|
| 462 |
+
|
| 463 |
+
|
| 464 |
+
def _pricelist_slug(col):
|
| 465 |
+
"""`price_royal_1` -> `royal1`, the token the per-list tier keys are built on.
|
| 466 |
+
|
| 467 |
+
β THE UNDERSCORE IS REMOVED DELIBERATELY, and it is not cosmetic. `price_royal_1` ALREADY
|
| 468 |
+
EXISTS and means "the Royal 1 list's base price", so a tier key of `price_royal_1_t1` shares
|
| 469 |
+
a prefix with a different column and is ambiguous to anyone diffing the contract by eye.
|
| 470 |
+
`price_royal1_t1` cannot be mistaken for a suffix of it.
|
| 471 |
+
"""
|
| 472 |
+
return col[len("price_"):].replace("_", "")
|
| 473 |
+
|
| 474 |
+
|
| 475 |
+
#: `[(price_key, unit_key, pricelist_name, tier_no)]` β the 18 columns R6 declares, DERIVED from
|
| 476 |
+
#: `PRICELIST_COLUMNS` so this tenant's list names live in exactly one place. A fourth pricelist
|
| 477 |
+
#: added above becomes six more tier columns here with no second edit.
|
| 478 |
+
PRICELIST_TIER_COLUMNS = tuple(
|
| 479 |
+
(f"price_{_pricelist_slug(col)}_t{n}", f"unit_{_pricelist_slug(col)}_t{n}", name, n)
|
| 480 |
+
for col, name in PRICELIST_COLUMNS
|
| 481 |
+
for n in range(1, PRICELIST_TIER_DEPTH + 1)
|
| 482 |
+
)
|
| 483 |
+
|
| 484 |
+
|
| 485 |
+
def per_list_tier_cells(tiers):
|
| 486 |
+
"""One SKU's `tier_prices_by_code` entry -> `{column_key: value}` for all 18 R6 cells.
|
| 487 |
+
|
| 488 |
+
ββ THE WHOLE OF W40-T09, and it is a GROUP-BY, not a new read. `tier_prices_by_code`
|
| 489 |
+
already carries the pricelist NAME on every entry, so attributing prices to the list that
|
| 490 |
+
charges them costs nothing beyond this loop.
|
| 491 |
+
|
| 492 |
+
β **IT NEVER BORROWS.** A list this SKU is not priced on gets `None` in all six of its
|
| 493 |
+
cells β never the cheapest price from another list, never a fallback. That is R6's negative
|
| 494 |
+
control and it is the reason the pooled `price_1..3` block could not simply be relabelled:
|
| 495 |
+
those three are the cheapest three POOLED ACROSS ALL LISTS and unattributed, so on a SKU
|
| 496 |
+
priced only on Fisch they would put a Fisch price under a Royal heading.
|
| 497 |
+
MEASURED: `BOUT-WH` has three tiers, all Fisch, on NEITHER Royal list β one SKU that is
|
| 498 |
+
simultaneously the cheapest-first case and this negative control.
|
| 499 |
+
|
| 500 |
+
β CHEAPEST-FIRST IS GUARANTEED HERE, not inherited. `tier_prices_by_code` does sort its
|
| 501 |
+
lists globally by price, and a stable group-by would preserve that within each list β but a
|
| 502 |
+
caller handing in a fixture, or a future change to that sort key, would silently reorder the
|
| 503 |
+
cells. Sorting the group is one line and makes the guarantee local to the function that
|
| 504 |
+
makes it. The tiebreak matches the reader's: unit name, then list name.
|
| 505 |
+
|
| 506 |
+
β A LIST NOT IN `PRICELIST_COLUMNS` IS INVISIBLE HERE BY DESIGN β the columns are named
|
| 507 |
+
after the three lists the contract declares. MEASURED: 3 active SKUs are priced ONLY on
|
| 508 |
+
Public Pricelist, so they carry all eighteen cells empty. `tier_prices_by_code` still sees
|
| 509 |
+
those prices; nothing is lost from the honest set, only from these named columns.
|
| 510 |
+
"""
|
| 511 |
+
grouped = {}
|
| 512 |
+
for tier in tiers or ():
|
| 513 |
+
grouped.setdefault(tier.get("pricelist"), []).append(tier)
|
| 514 |
+
for got in grouped.values():
|
| 515 |
+
got.sort(key=lambda t: (t.get("unit_price") or 0.0,
|
| 516 |
+
str(t.get("unit") or "").lower(),
|
| 517 |
+
str(t.get("pricelist") or "").lower()))
|
| 518 |
+
cells = {}
|
| 519 |
+
for price_key, unit_key, name, n in PRICELIST_TIER_COLUMNS:
|
| 520 |
+
got = grouped.get(name) or []
|
| 521 |
+
tier = got[n - 1] if len(got) >= n else None
|
| 522 |
+
cells[price_key] = tier.get("unit_price") if tier else None
|
| 523 |
+
cells[unit_key] = tier.get("unit") if tier else None
|
| 524 |
+
return cells
|
| 525 |
+
|
| 526 |
+
|
| 527 |
+
def tier_cap_overflow(tiers):
|
| 528 |
+
"""`{pricelist_name: how many tiers PRICELIST_TIER_DEPTH hides}` for one SKU, `{}` when none.
|
| 529 |
+
|
| 530 |
+
β STANDING RULE 1's SECOND SENTENCE, in code: *"if there is lag or it can't be done, you
|
| 531 |
+
need to explicitly tell me why and recommend a fix."* R6 declares three pairs per list, so a
|
| 532 |
+
fourth tier is dropped β and a dropped tier that nobody counts is the silent cap the rule
|
| 533 |
+
forbids. `validate_price_and_unit_cells` turns this into a named, reported figure.
|
| 534 |
+
"""
|
| 535 |
+
counts = {}
|
| 536 |
+
for tier in tiers or ():
|
| 537 |
+
counts[tier.get("pricelist")] = counts.get(tier.get("pricelist"), 0) + 1
|
| 538 |
+
declared = {name for _p, _u, name, _n in PRICELIST_TIER_COLUMNS}
|
| 539 |
+
return {name: n - PRICELIST_TIER_DEPTH for name, n in counts.items()
|
| 540 |
+
if name in declared and n > PRICELIST_TIER_DEPTH}
|
| 541 |
+
|
| 542 |
|
| 543 |
def pricelist_by_code():
|
| 544 |
"""`({code: {column_key: price}}, report)` β the date-valid FIXED base-tier price for each
|
web/public/sample_customers.json
CHANGED
|
@@ -33,7 +33,7 @@
|
|
| 33 |
{
|
| 34 |
"key": "agent",
|
| 35 |
"label": "Agent",
|
| 36 |
-
"type": "
|
| 37 |
"source": "odoo",
|
| 38 |
"default": true,
|
| 39 |
"description": "The sales agent who owns this account."
|
|
@@ -54,7 +54,7 @@
|
|
| 54 |
{
|
| 55 |
"key": "salesperson",
|
| 56 |
"label": "Salesperson",
|
| 57 |
-
"type": "
|
| 58 |
"source": "odoo",
|
| 59 |
"default": false,
|
| 60 |
"description": "Who keyed in most of this customer's orders β not the Agent, who owns the account."
|
|
@@ -78,7 +78,7 @@
|
|
| 78 |
{
|
| 79 |
"key": "city",
|
| 80 |
"label": "City",
|
| 81 |
-
"type": "
|
| 82 |
"source": "odoo",
|
| 83 |
"default": true,
|
| 84 |
"description": "City on the customer's Odoo address."
|
|
@@ -86,7 +86,7 @@
|
|
| 86 |
{
|
| 87 |
"key": "state",
|
| 88 |
"label": "State",
|
| 89 |
-
"type": "
|
| 90 |
"source": "odoo",
|
| 91 |
"default": true,
|
| 92 |
"description": "State or province on the customer's Odoo address."
|
|
@@ -94,7 +94,7 @@
|
|
| 94 |
{
|
| 95 |
"key": "country",
|
| 96 |
"label": "Country",
|
| 97 |
-
"type": "
|
| 98 |
"source": "odoo",
|
| 99 |
"default": false,
|
| 100 |
"description": "Country on the customer's Odoo address."
|
|
@@ -107,6 +107,14 @@
|
|
| 107 |
"default": false,
|
| 108 |
"description": "Postal code on the customer's Odoo address."
|
| 109 |
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 110 |
{
|
| 111 |
"key": "customer_since",
|
| 112 |
"label": "Customer since",
|
|
@@ -118,15 +126,15 @@
|
|
| 118 |
{
|
| 119 |
"key": "tags",
|
| 120 |
"label": "Tags",
|
| 121 |
-
"type": "
|
| 122 |
"source": "odoo",
|
| 123 |
"default": false,
|
| 124 |
"description": "Odoo labels on this customer, comma-separated."
|
| 125 |
},
|
| 126 |
{
|
| 127 |
"key": "pricelist",
|
| 128 |
-
"label": "
|
| 129 |
-
"type": "
|
| 130 |
"source": "odoo",
|
| 131 |
"default": false,
|
| 132 |
"description": "The price list this customer buys on."
|
|
@@ -134,7 +142,7 @@
|
|
| 134 |
{
|
| 135 |
"key": "payment_terms",
|
| 136 |
"label": "Payment terms",
|
| 137 |
-
"type": "
|
| 138 |
"source": "odoo",
|
| 139 |
"default": false,
|
| 140 |
"description": "Payment terms on this customer's account β Net 30, for example."
|
|
@@ -243,7 +251,7 @@
|
|
| 243 |
{
|
| 244 |
"key": "top_category",
|
| 245 |
"label": "Top category",
|
| 246 |
-
"type": "
|
| 247 |
"source": "odoo",
|
| 248 |
"default": false,
|
| 249 |
"description": "The category this customer spent the most on in the last 12 months."
|
|
@@ -288,6 +296,14 @@
|
|
| 288 |
"default": false,
|
| 289 |
"description": "Days this customer usually goes between orders, from their own history."
|
| 290 |
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 291 |
{
|
| 292 |
"key": "notes",
|
| 293 |
"label": "Notes",
|
|
|
|
| 33 |
{
|
| 34 |
"key": "agent",
|
| 35 |
"label": "Agent",
|
| 36 |
+
"type": "select",
|
| 37 |
"source": "odoo",
|
| 38 |
"default": true,
|
| 39 |
"description": "The sales agent who owns this account."
|
|
|
|
| 54 |
{
|
| 55 |
"key": "salesperson",
|
| 56 |
"label": "Salesperson",
|
| 57 |
+
"type": "select",
|
| 58 |
"source": "odoo",
|
| 59 |
"default": false,
|
| 60 |
"description": "Who keyed in most of this customer's orders β not the Agent, who owns the account."
|
|
|
|
| 78 |
{
|
| 79 |
"key": "city",
|
| 80 |
"label": "City",
|
| 81 |
+
"type": "select",
|
| 82 |
"source": "odoo",
|
| 83 |
"default": true,
|
| 84 |
"description": "City on the customer's Odoo address."
|
|
|
|
| 86 |
{
|
| 87 |
"key": "state",
|
| 88 |
"label": "State",
|
| 89 |
+
"type": "select",
|
| 90 |
"source": "odoo",
|
| 91 |
"default": true,
|
| 92 |
"description": "State or province on the customer's Odoo address."
|
|
|
|
| 94 |
{
|
| 95 |
"key": "country",
|
| 96 |
"label": "Country",
|
| 97 |
+
"type": "select",
|
| 98 |
"source": "odoo",
|
| 99 |
"default": false,
|
| 100 |
"description": "Country on the customer's Odoo address."
|
|
|
|
| 107 |
"default": false,
|
| 108 |
"description": "Postal code on the customer's Odoo address."
|
| 109 |
},
|
| 110 |
+
{
|
| 111 |
+
"key": "maps_url",
|
| 112 |
+
"label": "Google Maps",
|
| 113 |
+
"type": "url",
|
| 114 |
+
"source": "odoo",
|
| 115 |
+
"default": true,
|
| 116 |
+
"description": "A Google Maps link to this customer's address."
|
| 117 |
+
},
|
| 118 |
{
|
| 119 |
"key": "customer_since",
|
| 120 |
"label": "Customer since",
|
|
|
|
| 126 |
{
|
| 127 |
"key": "tags",
|
| 128 |
"label": "Tags",
|
| 129 |
+
"type": "multiselect",
|
| 130 |
"source": "odoo",
|
| 131 |
"default": false,
|
| 132 |
"description": "Odoo labels on this customer, comma-separated."
|
| 133 |
},
|
| 134 |
{
|
| 135 |
"key": "pricelist",
|
| 136 |
+
"label": "Customer price list",
|
| 137 |
+
"type": "select",
|
| 138 |
"source": "odoo",
|
| 139 |
"default": false,
|
| 140 |
"description": "The price list this customer buys on."
|
|
|
|
| 142 |
{
|
| 143 |
"key": "payment_terms",
|
| 144 |
"label": "Payment terms",
|
| 145 |
+
"type": "select",
|
| 146 |
"source": "odoo",
|
| 147 |
"default": false,
|
| 148 |
"description": "Payment terms on this customer's account β Net 30, for example."
|
|
|
|
| 251 |
{
|
| 252 |
"key": "top_category",
|
| 253 |
"label": "Top category",
|
| 254 |
+
"type": "select",
|
| 255 |
"source": "odoo",
|
| 256 |
"default": false,
|
| 257 |
"description": "The category this customer spent the most on in the last 12 months."
|
|
|
|
| 296 |
"default": false,
|
| 297 |
"description": "Days this customer usually goes between orders, from their own history."
|
| 298 |
},
|
| 299 |
+
{
|
| 300 |
+
"key": "created_on",
|
| 301 |
+
"label": "Record created",
|
| 302 |
+
"type": "date",
|
| 303 |
+
"source": "odoo",
|
| 304 |
+
"default": false,
|
| 305 |
+
"description": "The date this customer record was created in Odoo."
|
| 306 |
+
},
|
| 307 |
{
|
| 308 |
"key": "notes",
|
| 309 |
"label": "Notes",
|
web/src/customer-grid/ColumnMenu.tsx
CHANGED
|
@@ -1,4 +1,4 @@
|
|
| 1 |
-
import { useMemo, useRef, useState } from "react";
|
| 2 |
// β W36-T07 (owner item 10) β the field agent. Its own module for `ColumnMenu`'s own reason:
|
| 3 |
// this file pulls the whole grid and cannot load under a node gate, so the chat had to sit
|
| 4 |
// where a test can render it.
|
|
@@ -8,8 +8,16 @@ import { AnchoredOverlay } from "./OverlaySurface";
|
|
| 8 |
import type { AnchorRect } from "./OverlaySurface";
|
| 9 |
import { FieldTypeIcon, MenuLabel } from "./icons";
|
| 10 |
import { FieldSelectButton } from "./FieldSelect";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 11 |
import { CODE_LANGUAGE_LABELS, CODE_LANGUAGES, CREATABLE_TYPES, choiceOptions, choiceRenames,
|
| 12 |
-
codeLanguageOf, directionLabel, isDerivedLink, isMachineOwned,
|
| 13 |
isProfileField, parseOptions, ratingMax, ROLLUP_FN_LABELS, ROLLUP_FNS,
|
| 14 |
ROLLUP_REF_OPS, mayEditFieldDefinition } from "./types";
|
| 15 |
import type { AggName, Field, FieldFormat, FieldScope, FieldType, Measure, RollupCondition, RollupFn,
|
|
@@ -18,7 +26,7 @@ import type { LinkTarget, RollupSourceOffer } from "./apiBridge";
|
|
| 18 |
import type { WindowSpec } from "./windows";
|
| 19 |
import { normalizeWindow, windowLabel } from "./windows";
|
| 20 |
import { WindowPicker } from "../filter-kit";
|
| 21 |
-
import { TYPE_LABELS } from "./iconShapes";
|
| 22 |
import { AGG_LABELS, aggOptions } from "./aggregations";
|
| 23 |
import { validateFormula } from "./formulaEngine";
|
| 24 |
import { BRAND_SWATCHES, defaultOptionColor, nearestSwatch, normalizeOptionColor,
|
|
@@ -135,6 +143,16 @@ interface ColumnMenuProps {
|
|
| 135 |
locked: boolean;
|
| 136 |
/** Product-owned preset fields may still drive view actions, but their schema is immutable. */
|
| 137 |
schemaLocked?: boolean;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 138 |
/** Wave-5 item 1 β who is looking. Gates the permissions entry (creator-or-admin). */
|
| 139 |
viewer?: Viewer;
|
| 140 |
/** Wave-5 item 3 β what the CURRENT VIEW does with this field, so the conditional
|
|
@@ -879,8 +897,18 @@ type CreateKind = FieldType | "measure" | "geocode";
|
|
| 879 |
* of them end up disagreeing about what is offered.
|
| 880 |
* β NO DASH of any kind in the label β it reaches the screen, and `web_prose` cannot see a
|
| 881 |
* wrapped JSX sentence, so this one is on the author.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 882 |
*/
|
| 883 |
-
const GEOCODE_LABEL = "Coordinates
|
| 884 |
const GEOCODE_ADDRESS_TYPES: readonly FieldType[] = ["text", "url", "email", "phone"];
|
| 885 |
|
| 886 |
/**
|
|
@@ -941,6 +969,11 @@ function TypePicker({
|
|
| 941 |
? [{ value: "geocode" as CreateKind, label: GEOCODE_LABEL }]
|
| 942 |
: []),
|
| 943 |
].filter((r) => !needle || r.label.toLowerCase().includes(needle));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 944 |
return (
|
| 945 |
<div className="cg-type-picker">
|
| 946 |
<div className="cg-type-search">
|
|
@@ -962,44 +995,64 @@ function TypePicker({
|
|
| 962 |
/>
|
| 963 |
</div>
|
| 964 |
<div className="cg-type-list" role="listbox" aria-label="Field type">
|
| 965 |
-
{
|
| 966 |
-
|
| 967 |
-
|
| 968 |
-
|
| 969 |
-
|
| 970 |
-
|
| 971 |
-
|
| 972 |
-
|
| 973 |
-
|
| 974 |
-
|
| 975 |
-
|
| 976 |
-
|
| 977 |
-
|
| 978 |
-
|
| 979 |
-
|
| 980 |
-
|
| 981 |
-
|
| 982 |
-
|
| 983 |
-
|
| 984 |
-
|
| 985 |
-
|
| 986 |
-
|
| 987 |
-
|
| 988 |
-
|
| 989 |
-
|
| 990 |
-
|
| 991 |
-
aria-hidden="true"
|
| 992 |
>
|
| 993 |
-
|
| 994 |
-
|
| 995 |
-
|
| 996 |
-
|
| 997 |
-
|
| 998 |
-
|
|
|
|
|
|
|
| 999 |
/>
|
| 1000 |
-
|
| 1001 |
-
|
| 1002 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1003 |
))}
|
| 1004 |
{rows.length === 0 && <div className="cg-pop-note">No matching type.</div>}
|
| 1005 |
</div>
|
|
@@ -2000,6 +2053,7 @@ export default function ColumnMenu({
|
|
| 2000 |
geocodable,
|
| 2001 |
locked,
|
| 2002 |
schemaLocked = false,
|
|
|
|
| 2003 |
viewer,
|
| 2004 |
sortedDir,
|
| 2005 |
isFiltered,
|
|
@@ -2038,6 +2092,18 @@ export default function ColumnMenu({
|
|
| 2038 |
measures = [],
|
| 2039 |
tableKey,
|
| 2040 |
}: ColumnMenuProps) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2041 |
const canEditDefinition = !schemaLocked && mayEditFieldDefinition(field, viewer);
|
| 2042 |
const [pane, setPane] = useState<MenuPane>(
|
| 2043 |
schemaLocked || (initialPane === "edit" && !canEditDefinition)
|
|
@@ -2600,6 +2666,23 @@ export default function ColumnMenu({
|
|
| 2600 |
*/
|
| 2601 |
const editingRelational =
|
| 2602 |
!!onFieldConfig && (field.type === "rollup" || field.type === "link");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2603 |
const editRollupValid =
|
| 2604 |
field.type !== "rollup" ||
|
| 2605 |
(editRollup.source
|
|
@@ -2729,10 +2812,15 @@ export default function ColumnMenu({
|
|
| 2729 |
* the overlay stratum and user-created columns. Hidden fields included in both: "change this
|
| 2730 |
* to Notes" is the whole point, and swapping BACK to a hidden custom field is the documented
|
| 2731 |
* restore path. The locked primary column cannot be swapped.
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2732 |
*/
|
| 2733 |
const swapOptions = fields.filter((f) => f.key !== field.key);
|
| 2734 |
const presetSwap = swapOptions.filter((f) => f.source === "odoo" && !f.custom);
|
| 2735 |
const yourSwap = swapOptions.filter((f) => !(f.source === "odoo" && !f.custom));
|
|
|
|
| 2736 |
|
| 2737 |
// Item 8c β the period draft is valid when it normalizes and differs from what the field
|
| 2738 |
// already has. Compared through normalizeWindow so `{kind:'ltm'}` and `{kind:'ltm', n:undefined}`
|
|
@@ -3099,7 +3187,7 @@ export default function ColumnMenu({
|
|
| 3099 |
>
|
| 3100 |
<PaneHead title="Edit field" sub={typeLine} onClose={onClose} />
|
| 3101 |
<div className="cg-column-create cg-field-edit">
|
| 3102 |
-
{
|
| 3103 |
<label>
|
| 3104 |
<span>Name</span>
|
| 3105 |
<input
|
|
@@ -3132,9 +3220,19 @@ export default function ColumnMenu({
|
|
| 3132 |
Default description: {field.description}
|
| 3133 |
</span>
|
| 3134 |
)}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3135 |
<textarea
|
| 3136 |
className="cg-input"
|
| 3137 |
rows={3}
|
|
|
|
|
|
|
|
|
|
| 3138 |
value={note}
|
| 3139 |
placeholder={
|
| 3140 |
field.description
|
|
@@ -3441,8 +3539,18 @@ export default function ColumnMenu({
|
|
| 3441 |
Back
|
| 3442 |
</button>
|
| 3443 |
</div>
|
| 3444 |
-
{/* -------- Change field (owner item 9, folded in here by owner item 8) --------
|
| 3445 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3446 |
<div className="cg-edit-swap">
|
| 3447 |
<span className="cg-type-title">Change field</span>
|
| 3448 |
<div className="cg-field-hint">
|
|
@@ -3459,8 +3567,10 @@ export default function ColumnMenu({
|
|
| 3459 |
ariaLabel="Change this column to another field"
|
| 3460 |
placeholder="Choose a fieldβ¦"
|
| 3461 |
// Focus falls here when the pane has no editable Name (a read-only source
|
| 3462 |
-
// field): the swap picker is then the pane's first live control.
|
| 3463 |
-
|
|
|
|
|
|
|
| 3464 |
value={swapTo || undefined}
|
| 3465 |
onChange={setSwapTo}
|
| 3466 |
fields={[
|
|
@@ -3880,21 +3990,37 @@ export default function ColumnMenu({
|
|
| 3880 |
{/* β AN INLINE NODE, NOT A `MenuIcon` NAME, and that is forced rather than chosen.
|
| 3881 |
`MenuLabel`'s prop is `MenuIconName | ReactNode` and `ReactNode` admits any
|
| 3882 |
string, so `icon="share"` would COMPILE and paint an empty 16px box forever
|
| 3883 |
-
(`MENU_ICONS` has no such key, and `icons.tsx` is not this ticket's file).
|
| 3884 |
-
|
| 3885 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3886 |
<MenuLabel
|
| 3887 |
icon={
|
| 3888 |
-
<svg width={16} height={16} viewBox="0 0 16 16"
|
| 3889 |
-
|
| 3890 |
-
|
| 3891 |
-
|
| 3892 |
-
|
| 3893 |
-
|
| 3894 |
-
|
| 3895 |
-
|
| 3896 |
-
|
| 3897 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3898 |
</svg>
|
| 3899 |
}
|
| 3900 |
text="Share field"
|
|
@@ -4051,7 +4177,18 @@ export default function ColumnMenu({
|
|
| 4051 |
</button>
|
| 4052 |
</>
|
| 4053 |
)}
|
| 4054 |
-
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 4055 |
<button
|
| 4056 |
type="button"
|
| 4057 |
className="is-danger"
|
|
|
|
| 1 |
+
import { Fragment, useMemo, useRef, useState } from "react";
|
| 2 |
// β W36-T07 (owner item 10) β the field agent. Its own module for `ColumnMenu`'s own reason:
|
| 3 |
// this file pulls the whole grid and cannot load under a node gate, so the chat had to sit
|
| 4 |
// where a test can render it.
|
|
|
|
| 8 |
import type { AnchorRect } from "./OverlaySurface";
|
| 9 |
import { FieldTypeIcon, MenuLabel } from "./icons";
|
| 10 |
import { FieldSelectButton } from "./FieldSelect";
|
| 11 |
+
// ββ W40-T24 β the pre-set definition lock. It lives in `display.ts` rather than here because a
|
| 12 |
+
// rule stated inside JSX cannot be LOADED by a node gate; `display.ts`'s header carries the full
|
| 13 |
+
// argument, and `_test/gridUx.test.ts` is what runs it.
|
| 14 |
+
import { columnDefinitionOffer } from "./display";
|
| 15 |
+
// ββ W40-T29 β the ADVANCED grouping is a pure function in `types.ts` for the reason
|
| 16 |
+
// `columnDefinitionOffer` sits in `display.ts`: this file imports React, so nothing stated inside
|
| 17 |
+
// it can be LOADED by a node gate, and "which types are advanced" is exactly the kind of decision
|
| 18 |
+
// that must be runnable rather than read back to itself as source text.
|
| 19 |
import { CODE_LANGUAGE_LABELS, CODE_LANGUAGES, CREATABLE_TYPES, choiceOptions, choiceRenames,
|
| 20 |
+
codeLanguageOf, directionLabel, groupTypePickerRows, isDerivedLink, isMachineOwned,
|
| 21 |
isProfileField, parseOptions, ratingMax, ROLLUP_FN_LABELS, ROLLUP_FNS,
|
| 22 |
ROLLUP_REF_OPS, mayEditFieldDefinition } from "./types";
|
| 23 |
import type { AggName, Field, FieldFormat, FieldScope, FieldType, Measure, RollupCondition, RollupFn,
|
|
|
|
| 26 |
import type { WindowSpec } from "./windows";
|
| 27 |
import { normalizeWindow, windowLabel } from "./windows";
|
| 28 |
import { WindowPicker } from "../filter-kit";
|
| 29 |
+
import { SHARE_SHAPE, TYPE_LABELS } from "./iconShapes";
|
| 30 |
import { AGG_LABELS, aggOptions } from "./aggregations";
|
| 31 |
import { validateFormula } from "./formulaEngine";
|
| 32 |
import { BRAND_SWATCHES, defaultOptionColor, nearestSwatch, normalizeOptionColor,
|
|
|
|
| 143 |
locked: boolean;
|
| 144 |
/** Product-owned preset fields may still drive view actions, but their schema is immutable. */
|
| 145 |
schemaLocked?: boolean;
|
| 146 |
+
/**
|
| 147 |
+
* ββ W40-T24 β the grid is a `ut_*` runtime database rather than an Odoo-backed topic. It
|
| 148 |
+
* feeds `columnDefinitionOffer` (display.ts), which is this menu's ONE statement of the pre-set
|
| 149 |
+
* definition lock, and EVERY verdict reads it: a shared-definition column on a user database is
|
| 150 |
+
* the user's to reshape, and the identical shape on an Odoo-backed topic is not.
|
| 151 |
+
* β OPTIONAL and false by default only for the "+" create instance, which has no real subject
|
| 152 |
+
* column β it passes `locked`, so its verdicts are the closed ones either way. A real column
|
| 153 |
+
* menu must pass it; defaulting is a convenience for the create door, not a shrug.
|
| 154 |
+
*/
|
| 155 |
+
isUserTable?: boolean;
|
| 156 |
/** Wave-5 item 1 β who is looking. Gates the permissions entry (creator-or-admin). */
|
| 157 |
viewer?: Viewer;
|
| 158 |
/** Wave-5 item 3 β what the CURRENT VIEW does with this field, so the conditional
|
|
|
|
| 897 |
* of them end up disagreeing about what is offered.
|
| 898 |
* β NO DASH of any kind in the label β it reaches the screen, and `web_prose` cannot see a
|
| 899 |
* wrapped JSX sentence, so this one is on the author.
|
| 900 |
+
*
|
| 901 |
+
* ββ W40-T29 (owner instruction 31) β SHORTENED TO ONE NOUN. The label used to carry a trailing
|
| 902 |
+
* clause naming where the numbers come from, which is the IMPLEMENTATION read out at someone
|
| 903 |
+
* scanning a list of nouns; every other row in that list is the thing you get, not how it is got,
|
| 904 |
+
* and the source column is picked one control later anyway. The old wording is not repeated here:
|
| 905 |
+
* a rename that leaves its own before-picture in a doc block is how the next reader reinstates it,
|
| 906 |
+
* and `_test/gridUx.test.ts` asserts the whole file is free of it.
|
| 907 |
+
* β THE IDENTIFIER STAYS. One producer, one consumer, and `verify_grid_ux.py`'s geocode-door scan
|
| 908 |
+
* matches `label: GEOCODE_LABEL` BY NAME, so inlining the string here would blind the gate rather
|
| 909 |
+
* than satisfy it.
|
| 910 |
*/
|
| 911 |
+
const GEOCODE_LABEL = "Coordinates";
|
| 912 |
const GEOCODE_ADDRESS_TYPES: readonly FieldType[] = ["text", "url", "email", "phone"];
|
| 913 |
|
| 914 |
/**
|
|
|
|
| 969 |
? [{ value: "geocode" as CreateKind, label: GEOCODE_LABEL }]
|
| 970 |
: []),
|
| 971 |
].filter((r) => !needle || r.label.toLowerCase().includes(needle));
|
| 972 |
+
// ββ W40-T29 (owner instruction 31) β the list stopped being a wall of 22 nouns here, and the
|
| 973 |
+
// grouping is applied to the ALREADY-FILTERED rows on purpose: one find box still reaches both
|
| 974 |
+
// groups, and a group the needle empties is dropped by `groupTypePickerRows` heading and all
|
| 975 |
+
// rather than leaving a label with nothing behind it (R8).
|
| 976 |
+
const groups = groupTypePickerRows(rows);
|
| 977 |
return (
|
| 978 |
<div className="cg-type-picker">
|
| 979 |
<div className="cg-type-search">
|
|
|
|
| 995 |
/>
|
| 996 |
</div>
|
| 997 |
<div className="cg-type-list" role="listbox" aria-label="Field type">
|
| 998 |
+
{groups.map((group) => (
|
| 999 |
+
// β A FRAGMENT, NOT A WRAPPER, and the reason is an accessibility one rather than a
|
| 1000 |
+
// layout one. `.cg-type-list` is the flex column that lays the rows out, so a wrapping
|
| 1001 |
+
// div would need `display: contents` to stay out of the way β which DROPS the element
|
| 1002 |
+
// from the accessibility tree, inside the one container that is claiming to be a
|
| 1003 |
+
// listbox. `FieldSelect.tsx` reached this conclusion first for its own grouped list
|
| 1004 |
+
// ("Pre-set fields" / "Your fields" / "New field"); this follows it rather than
|
| 1005 |
+
// inventing a second answer to a question the codebase already settled.
|
| 1006 |
+
// β The heading is `role="presentation"` for the same reason: a listbox's children are
|
| 1007 |
+
// options, and a bare div claiming nothing is what keeps the heading out of the option
|
| 1008 |
+
// set while leaving it visible. Arrow-key navigation elsewhere collects
|
| 1009 |
+
// `button.cg-type-row`, so a non-button child is invisible to it by construction.
|
| 1010 |
+
<Fragment key={group.heading ?? "ordinary"}>
|
| 1011 |
+
{group.heading && (
|
| 1012 |
+
<div className="cg-type-group" role="presentation">
|
| 1013 |
+
{group.heading}
|
| 1014 |
+
</div>
|
| 1015 |
+
)}
|
| 1016 |
+
{group.rows.map((r) => (
|
| 1017 |
+
<button
|
| 1018 |
+
key={r.value}
|
| 1019 |
+
type="button"
|
| 1020 |
+
role="option"
|
| 1021 |
+
aria-selected={value === r.value}
|
| 1022 |
+
className={"cg-type-row" + (value === r.value ? " is-on" : "")}
|
| 1023 |
+
onClick={() => onPick(r.value)}
|
|
|
|
| 1024 |
>
|
| 1025 |
+
{/* Each row wears the mark its COLUMN will wear. A measure column's real type is
|
| 1026 |
+
currency/int/pct and a geocode column's is `text`, so both pseudo-kinds borrow
|
| 1027 |
+
rather than inventing a glyph no column ever shows (the iconShapes ruling). */}
|
| 1028 |
+
<FieldTypeIcon
|
| 1029 |
+
type={
|
| 1030 |
+
r.value === "measure" ? "currency" : r.value === "geocode" ? "text" : r.value
|
| 1031 |
+
}
|
| 1032 |
+
size={16}
|
| 1033 |
/>
|
| 1034 |
+
<span className="cg-type-label">{r.label}</span>
|
| 1035 |
+
{value === r.value && (
|
| 1036 |
+
<svg
|
| 1037 |
+
className="cg-type-check"
|
| 1038 |
+
width="14"
|
| 1039 |
+
height="14"
|
| 1040 |
+
viewBox="0 0 16 16"
|
| 1041 |
+
fill="none"
|
| 1042 |
+
aria-hidden="true"
|
| 1043 |
+
>
|
| 1044 |
+
<path
|
| 1045 |
+
d="m3.5 8.5 3 3 6-6.5"
|
| 1046 |
+
stroke="currentColor"
|
| 1047 |
+
strokeWidth="1.6"
|
| 1048 |
+
strokeLinecap="round"
|
| 1049 |
+
strokeLinejoin="round"
|
| 1050 |
+
/>
|
| 1051 |
+
</svg>
|
| 1052 |
+
)}
|
| 1053 |
+
</button>
|
| 1054 |
+
))}
|
| 1055 |
+
</Fragment>
|
| 1056 |
))}
|
| 1057 |
{rows.length === 0 && <div className="cg-pop-note">No matching type.</div>}
|
| 1058 |
</div>
|
|
|
|
| 2053 |
geocodable,
|
| 2054 |
locked,
|
| 2055 |
schemaLocked = false,
|
| 2056 |
+
isUserTable = false,
|
| 2057 |
viewer,
|
| 2058 |
sortedDir,
|
| 2059 |
isFiltered,
|
|
|
|
| 2092 |
measures = [],
|
| 2093 |
tableKey,
|
| 2094 |
}: ColumnMenuProps) {
|
| 2095 |
+
/**
|
| 2096 |
+
* ββ W40-T24 (owner instruction 18, contract C2) β the pre-set DEFINITION lock, read from the
|
| 2097 |
+
* one place that states it. `display.ts` carries the whole argument, including the measured
|
| 2098 |
+
* reason the lock is spelt `isUserSchemaField` and NOT `isPresetField` (nine product_data
|
| 2099 |
+
* contract columns, Supplier among them, are declared `source: "overlay"` so that their cells
|
| 2100 |
+
* stay typeable, and `isPresetField` answers false for every one).
|
| 2101 |
+
*
|
| 2102 |
+
* β ONLY `swap` AND `remove` ARE READ HERE, and that is the design, not an omission: `rename`
|
| 2103 |
+
* and `retype` are already enforced at the host by withholding their handlers, and a second
|
| 2104 |
+
* refusal in this file could only subtract from a door the host deliberately opened.
|
| 2105 |
+
*/
|
| 2106 |
+
const offer = columnDefinitionOffer(field, { isUserTable, isPrimary: locked });
|
| 2107 |
const canEditDefinition = !schemaLocked && mayEditFieldDefinition(field, viewer);
|
| 2108 |
const [pane, setPane] = useState<MenuPane>(
|
| 2109 |
schemaLocked || (initialPane === "edit" && !canEditDefinition)
|
|
|
|
| 2666 |
*/
|
| 2667 |
const editingRelational =
|
| 2668 |
!!onFieldConfig && (field.type === "rollup" || field.type === "link");
|
| 2669 |
+
/**
|
| 2670 |
+
* ββ W40-T24 β WHERE THE EDIT PANE'S OPENING FOCUS LANDS, decided ONCE.
|
| 2671 |
+
*
|
| 2672 |
+
* `AnchoredOverlay`'s `initialFocus` is the selector `[data-overlay-autofocus]` and it does
|
| 2673 |
+
* `querySelector(...)?.focus()` β a MISS is silent, and focus then stays on the grid header
|
| 2674 |
+
* button behind the overlay. That is what removing the swap picker from a pre-set column would
|
| 2675 |
+
* have caused: the picker carried `overlayAutofocus={!onRename}`, so on Supplier it WAS the
|
| 2676 |
+
* pane's focus target, and taking it away leaves a dialog nobody's keyboard is inside. The
|
| 2677 |
+
* defect would not show in a screenshot of the fix.
|
| 2678 |
+
*
|
| 2679 |
+
* Precedence, first match wins, exactly as `querySelector` reads the DOM: the editable Name box
|
| 2680 |
+
* Β· the swap picker Β· the Description box, which is the one control a pre-set column still owns.
|
| 2681 |
+
* β It also settles a latent double-marking: an `editingRelational` column with no `onRename`
|
| 2682 |
+
* put the attribute on the Name box AND the picker, and which one won was document order rather
|
| 2683 |
+
* than a decision.
|
| 2684 |
+
*/
|
| 2685 |
+
const nameIsFocusTarget = !!onRename || editingRelational;
|
| 2686 |
const editRollupValid =
|
| 2687 |
field.type !== "rollup" ||
|
| 2688 |
(editRollup.source
|
|
|
|
| 2812 |
* the overlay stratum and user-created columns. Hidden fields included in both: "change this
|
| 2813 |
* to Notes" is the whole point, and swapping BACK to a hidden custom field is the documented
|
| 2814 |
* restore path. The locked primary column cannot be swapped.
|
| 2815 |
+
*
|
| 2816 |
+
* ββ W40-T24 β NOR CAN A PRE-SET ONE, which is `offer.swap`. This list is what the picker
|
| 2817 |
+
* would contain; `swapOffered` is whether the picker exists at all, and it is read twice (the
|
| 2818 |
+
* control itself, and the focus fallback that has to know whether the control is there).
|
| 2819 |
*/
|
| 2820 |
const swapOptions = fields.filter((f) => f.key !== field.key);
|
| 2821 |
const presetSwap = swapOptions.filter((f) => f.source === "odoo" && !f.custom);
|
| 2822 |
const yourSwap = swapOptions.filter((f) => !(f.source === "odoo" && !f.custom));
|
| 2823 |
+
const swapOffered = offer.swap && swapOptions.length > 0;
|
| 2824 |
|
| 2825 |
// Item 8c β the period draft is valid when it normalizes and differs from what the field
|
| 2826 |
// already has. Compared through normalizeWindow so `{kind:'ltm'}` and `{kind:'ltm', n:undefined}`
|
|
|
|
| 3187 |
>
|
| 3188 |
<PaneHead title="Edit field" sub={typeLine} onClose={onClose} />
|
| 3189 |
<div className="cg-column-create cg-field-edit">
|
| 3190 |
+
{nameIsFocusTarget ? (
|
| 3191 |
<label>
|
| 3192 |
<span>Name</span>
|
| 3193 |
<input
|
|
|
|
| 3220 |
Default description: {field.description}
|
| 3221 |
</span>
|
| 3222 |
)}
|
| 3223 |
+
{/* ββ W40-T24 β LAST IN THE FOCUS PRECEDENCE, and the only reason it is marked at
|
| 3224 |
+
all: on a pre-set column the Name box is disabled and the swap picker is now
|
| 3225 |
+
gone, so without this the pane would open with `[data-overlay-autofocus]` matching
|
| 3226 |
+
nothing and the keyboard left outside the dialog. The Description is the one
|
| 3227 |
+
control a pre-set column still owns, which makes it the honest landing spot as
|
| 3228 |
+
well as the available one. `undefined` REMOVES the attribute (React drops it), so
|
| 3229 |
+
exactly one element in the pane ever carries it. */}
|
| 3230 |
<textarea
|
| 3231 |
className="cg-input"
|
| 3232 |
rows={3}
|
| 3233 |
+
data-overlay-autofocus={
|
| 3234 |
+
!nameIsFocusTarget && !swapOffered ? true : undefined
|
| 3235 |
+
}
|
| 3236 |
value={note}
|
| 3237 |
placeholder={
|
| 3238 |
field.description
|
|
|
|
| 3539 |
Back
|
| 3540 |
</button>
|
| 3541 |
</div>
|
| 3542 |
+
{/* -------- Change field (owner item 9, folded in here by owner item 8) --------
|
| 3543 |
+
ββ W40-T24 (owner instruction 18, contract C2) β GATED ON THE PRE-SET LOCK, which
|
| 3544 |
+
it never was. The condition here used to be `!locked` alone, and `locked` means
|
| 3545 |
+
"is the pinned primary column" β so every contract column on every grid offered to
|
| 3546 |
+
be redefined into something else, which is the "choose a field dropdown that makes
|
| 3547 |
+
no sense" the owner reported about Supplier and was never only about Supplier.
|
| 3548 |
+
It is the SAME predicate that already withholds the Field-type picker and the
|
| 3549 |
+
editable Name box, which is what makes this pane say one thing about the column
|
| 3550 |
+
instead of three. `offer.swap` carries the `!locked` half (the primary column is the
|
| 3551 |
+
row identity and can never be swapped away); `swapOptions.length > 0` stays because
|
| 3552 |
+
an empty picker is its own fake affordance. */}
|
| 3553 |
+
{swapOffered && (
|
| 3554 |
<div className="cg-edit-swap">
|
| 3555 |
<span className="cg-type-title">Change field</span>
|
| 3556 |
<div className="cg-field-hint">
|
|
|
|
| 3567 |
ariaLabel="Change this column to another field"
|
| 3568 |
placeholder="Choose a fieldβ¦"
|
| 3569 |
// Focus falls here when the pane has no editable Name (a read-only source
|
| 3570 |
+
// field): the swap picker is then the pane's first live control. Second in the
|
| 3571 |
+
// precedence `nameIsFocusTarget` documents, and reading THAT rather than
|
| 3572 |
+
// `!onRename` is what keeps the attribute on exactly one element.
|
| 3573 |
+
overlayAutofocus={!nameIsFocusTarget}
|
| 3574 |
value={swapTo || undefined}
|
| 3575 |
onChange={setSwapTo}
|
| 3576 |
fields={[
|
|
|
|
| 3990 |
{/* β AN INLINE NODE, NOT A `MenuIcon` NAME, and that is forced rather than chosen.
|
| 3991 |
`MenuLabel`'s prop is `MenuIconName | ReactNode` and `ReactNode` admits any
|
| 3992 |
string, so `icon="share"` would COMPILE and paint an empty 16px box forever
|
| 3993 |
+
(`MENU_ICONS` has no such key, and `icons.tsx` is not this ticket's file).
|
| 3994 |
+
ββ W40-T24 β THE GEOMETRY IS `SHARE_SHAPE`, NOT A THREE-NODE GRAPH ANY MORE.
|
| 3995 |
+
The argument that stood here β that the graph is "the mark every product uses for
|
| 3996 |
+
this verb" β was true of a product where it was the only share drawing. It is not
|
| 3997 |
+
any more: W40-T20 put `SHARE_SHAPE` (two people) on the grid header's shared-field
|
| 3998 |
+
sprite and W40-T21 put it on Share view and Share folder, so this row was the last
|
| 3999 |
+
place one verb spoke in a second drawing β a field whose HEADER wears two people,
|
| 4000 |
+
shared from a row wearing a graph. DESIGN.md Β§4's "one mark, one meaning" is the
|
| 4001 |
+
rule and `iconShapes.ts` is the vocabulary; paths as DATA is what stops the two
|
| 4002 |
+
painters drifting, which is exactly what a hand-written copy here would restart.
|
| 4003 |
+
β Rendered the way `ViewSidebar.ShareMark` renders it β same viewBox, same 1.35
|
| 4004 |
+
stroke, same round caps β so the rail's share and this one are one mark and not
|
| 4005 |
+
two readings of one array. */}
|
| 4006 |
<MenuLabel
|
| 4007 |
icon={
|
| 4008 |
+
<svg width={16} height={16} viewBox="0 0 16 16" aria-hidden>
|
| 4009 |
+
{SHARE_SHAPE.map((s) =>
|
| 4010 |
+
s.fill ? (
|
| 4011 |
+
<path key={s.d} d={s.d} fill="currentColor" />
|
| 4012 |
+
) : (
|
| 4013 |
+
<path
|
| 4014 |
+
key={s.d}
|
| 4015 |
+
d={s.d}
|
| 4016 |
+
fill="none"
|
| 4017 |
+
stroke="currentColor"
|
| 4018 |
+
strokeWidth={1.35}
|
| 4019 |
+
strokeLinecap="round"
|
| 4020 |
+
strokeLinejoin="round"
|
| 4021 |
+
/>
|
| 4022 |
+
)
|
| 4023 |
+
)}
|
| 4024 |
</svg>
|
| 4025 |
}
|
| 4026 |
text="Share field"
|
|
|
|
| 4177 |
</button>
|
| 4178 |
</>
|
| 4179 |
)}
|
| 4180 |
+
{/* ββ W40-T24 (contract C2) β `offer.remove` IS THE PRE-SET LOCK, ADDED BESIDE the two
|
| 4181 |
+
conditions that were already here rather than replacing either. `onDelete` asks
|
| 4182 |
+
whether the host wired a delete DOOR at all (it has three, one per stratum) and
|
| 4183 |
+
`schemaLocked` is `CustomerGrid.isSchemaLocked`; AND-ing a third refusal can only
|
| 4184 |
+
subtract, so nothing is duplicated and no working delete is widened.
|
| 4185 |
+
β On the Odoo grids this is behaviour-neutral: a pre-set column already had no door,
|
| 4186 |
+
so Delete never rendered. What changes is that the absence is now the LOCK's answer
|
| 4187 |
+
rather than a coincidence of wiring, which is the half of D-413 the client can settle.
|
| 4188 |
+
β The pre-set ROLLUP keeps its Delete, by the 2026-08-09 owner ruling `isSchemaLocked`
|
| 4189 |
+
already carries. `columnDefinitionOffer` restates that exception rather than dropping
|
| 4190 |
+
it β see its note. */}
|
| 4191 |
+
{!schemaLocked && offer.remove && onDelete && (
|
| 4192 |
<button
|
| 4193 |
type="button"
|
| 4194 |
className="is-danger"
|
web/src/customer-grid/CustomerGrid.tsx
CHANGED
|
@@ -12,8 +12,6 @@ import type {
|
|
| 12 |
CellClickedEventArgs,
|
| 13 |
DataEditorRef,
|
| 14 |
EditableGridCell,
|
| 15 |
-
GridCell,
|
| 16 |
-
GridColumn,
|
| 17 |
GridKeyEventArgs,
|
| 18 |
GridMouseEventArgs,
|
| 19 |
GridSelection,
|
|
@@ -71,7 +69,7 @@ import {
|
|
| 71 |
saveScriptView,
|
| 72 |
} from "./scriptViews";
|
| 73 |
import type { ScriptRun, ScriptView as ScriptViewRecord, ScriptViewRow } from "./scriptViews";
|
| 74 |
-
import { defaultViewConfig, useGridColumns } from "./useGridColumns";
|
| 75 |
import { activeMeasureRuleIds, pendingMeasures, runPipeline, sliceForDisplay,
|
| 76 |
unresolvedConditions, useVisibleRows } from "./useVisibleRows";
|
| 77 |
import { computeAggs } from "./aggregations";
|
|
@@ -105,8 +103,8 @@ import type { FormSpec } from "./FormInterface";
|
|
| 105 |
// Owner item 16 / R4 / C-UNDO β the stack and every inverse. Pure, so a node gate can run it.
|
| 106 |
import { describe, directed, popRedo, popUndo, pushUndo, stackFor } from "./undoStack";
|
| 107 |
import type { CellChange, UndoBook, UndoEntry, UndoRow, UndoValue } from "./undoStack";
|
| 108 |
-
import { exportFilename, runExport, triggerDownload } from "./export";
|
| 109 |
-
import type { ExportFormat } from "./export";
|
| 110 |
// owner item 3 (2026-08-03) β a time-series view exports its SHEET, not the rows under it.
|
| 111 |
import { buildTsCsv, tsSheetToTable } from "./timeSeriesData";
|
| 112 |
import type { TsSheet } from "./timeSeriesData";
|
|
@@ -134,7 +132,6 @@ import { DashboardView } from "../viz/DashboardView";
|
|
| 134 |
import { cleanCharts } from "../viz/chartData";
|
| 135 |
import type { ChartSpec } from "../viz/chartData";
|
| 136 |
import { MapView } from "./MapView";
|
| 137 |
-
import { googleDirectionsUrl, isPlottable } from "./mapProjection";
|
| 138 |
/* βββ W18-C CATALOG βββ (owner item 4, contract C6) */
|
| 139 |
import { CatalogView } from "./CatalogView";
|
| 140 |
import { CATALOG_CODE_FIELD } from "./catalogData";
|
|
@@ -142,8 +139,8 @@ import type { CatalogSpec } from "./types";
|
|
| 142 |
/* βββ end W18-C CATALOG βββ */
|
| 143 |
import { lightTheme, STATUS_ROW_THEME, HOVER_ROW_THEME, HOVER_NEUTRAL,
|
| 144 |
ACTIVE_ROW_NEUTRAL, CUSTOM_FIELD_MARK } from "./theme";
|
| 145 |
-
import { avatarInitials, formatDisplay, imageCellRenderer,
|
| 146 |
-
userCellRenderer } from "./cells";
|
| 147 |
import { optionTint, pickTint } from "./choiceColors";
|
| 148 |
import {
|
| 149 |
EMPTY_GRID_COPY_PROVENANCE,
|
|
@@ -153,15 +150,15 @@ import {
|
|
| 153 |
pasteRowCount,
|
| 154 |
} from "./clipboard";
|
| 155 |
import { cellTipText, expandButtonRect, starButtonRect,
|
| 156 |
-
GROUP_HEADER_FONT, GROUP_LABEL_PAD,
|
| 157 |
-
|
| 158 |
import { AnchoredOverlay, BodyPortal, useOverlayLayer } from "./OverlaySurface";
|
| 159 |
import type { AnchorRect } from "./OverlaySurface";
|
| 160 |
import { StarIcon } from "./Stars";
|
| 161 |
import { ALL_VIEW_ID, MAX_CALENDAR_METRICS, allViewName,
|
| 162 |
MAX_FROZEN, choiceOptions, choiceVocabulary, clampFrozenCount, cleanDisplay, formulaOf,
|
| 163 |
topicForScope,
|
| 164 |
-
isDateFamilyType, isFilterGroup, isGroupableField,
|
| 165 |
isDerivedLink, isUserSchemaField, isBlankValue, TOTAL_GROUP_KEY,
|
| 166 |
isNumericFieldType,
|
| 167 |
machineFoundRows, reFindConsequences,
|
|
@@ -217,22 +214,22 @@ export const GRID_CHAT_OPEN_EVENT = "aios:grid-chat-open";
|
|
| 217 |
const ROW_PX: Record<RowHeightMode, number> = { short: 28, medium: 34, tall: 48 };
|
| 218 |
|
| 219 |
/**
|
| 220 |
-
*
|
| 221 |
-
*
|
| 222 |
-
*
|
| 223 |
-
*
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 224 |
*/
|
| 225 |
-
const DIRECTIONS_COLUMN_ID = "__directions__";
|
| 226 |
-
const DIRECTIONS_COLUMN: GridColumn = { id: DIRECTIONS_COLUMN_ID, title: "Go", width: 46 };
|
| 227 |
-
|
| 228 |
-
/** `null` means there is no honest Google destination, including a blank-address row. */
|
| 229 |
-
function directionsFor(row: Row): { lat: number; lon: number } | null {
|
| 230 |
-
const lat = row.lat;
|
| 231 |
-
const lon = row.lon;
|
| 232 |
-
return typeof lat === "number" && typeof lon === "number" && isPlottable(lat, lon)
|
| 233 |
-
? { lat, lon }
|
| 234 |
-
: null;
|
| 235 |
-
}
|
| 236 |
|
| 237 |
/**
|
| 238 |
* Wave-14 R7 β **a button label is ONE LINE.** Every button row in this file is a flex row with
|
|
@@ -329,6 +326,31 @@ const DISPLAY_STEP = 250;
|
|
| 329 |
* when a COLUMN carries a `group` β `useGridColumns` never sets one (scrolling-data-grid.js:13). */
|
| 330 |
const HEADER_PX = 36;
|
| 331 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 332 |
/** glide's own row-marker width ladder, `data-editor.js:103`, verbatim.
|
| 333 |
*
|
| 334 |
* β It is passed BACK to glide as `rowMarkerWidth` rather than merely predicted here. The
|
|
@@ -1157,11 +1179,28 @@ function CustomerGridSurface({
|
|
| 1157 |
pid: number;
|
| 1158 |
fieldKey: string;
|
| 1159 |
anchor: AnchorRect;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1160 |
} | null>(null);
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1161 |
/** Owner item 5 (2026-07-31) β closing a picker RETURNS FOCUS TO THE GRID, so Enter keeps
|
| 1162 |
* navigating (pick β Enter β next record) instead of stranding focus on a dead overlay. */
|
| 1163 |
const closePicker = useCallback(() => {
|
| 1164 |
setPicker(null);
|
|
|
|
| 1165 |
requestAnimationFrame(() => gridRef.current?.focus());
|
| 1166 |
}, []);
|
| 1167 |
/** β Wave-23 C7 β which `json` cell the big viewer is open on. NOT anchored like the picker
|
|
@@ -1711,12 +1750,10 @@ function CustomerGridSurface({
|
|
| 1711 |
pendingRouteRevealRef.current = null;
|
| 1712 |
insertColumn(key, lockedKey, "right");
|
| 1713 |
}, [fieldByKey, insertColumn, lockedKey]);
|
| 1714 |
-
//
|
| 1715 |
-
//
|
| 1716 |
-
|
| 1717 |
-
|
| 1718 |
-
[scope, visibleCols]
|
| 1719 |
-
);
|
| 1720 |
|
| 1721 |
/**
|
| 1722 |
* β Wave-20 owner item 4 (ruling R8, contract C-ADDROW) β **THE GHOST ROW.**
|
|
@@ -2737,7 +2774,7 @@ function CustomerGridSurface({
|
|
| 2737 |
return () => window.clearInterval(id);
|
| 2738 |
}, [pendingMeasureKeys]);
|
| 2739 |
const activePendingKeys = pendingGaveUp ? NO_PENDING_KEYS : pendingMeasureKeys;
|
| 2740 |
-
const
|
| 2741 |
displayRows,
|
| 2742 |
visibleCols,
|
| 2743 |
fieldByKey,
|
|
@@ -2750,39 +2787,16 @@ function CustomerGridSurface({
|
|
| 2750 |
activePendingKeys,
|
| 2751 |
pulse
|
| 2752 |
);
|
| 2753 |
-
|
| 2754 |
-
|
| 2755 |
-
|
| 2756 |
-
|
| 2757 |
-
const at = row?.kind === "data" ? directionsFor(row.record) : null;
|
| 2758 |
-
// A blank cell is deliberately not a disabled-looking `Go`: there is no destination to
|
| 2759 |
-
// offer, and a row whose address is blank must not acquire a plausible link to nowhere.
|
| 2760 |
-
if (!at) {
|
| 2761 |
-
return {
|
| 2762 |
-
kind: GridCellKind.Text,
|
| 2763 |
-
data: "",
|
| 2764 |
-
displayData: "",
|
| 2765 |
-
allowOverlay: false,
|
| 2766 |
-
readonly: true,
|
| 2767 |
-
};
|
| 2768 |
-
}
|
| 2769 |
-
return {
|
| 2770 |
-
kind: GridCellKind.Uri,
|
| 2771 |
-
data: googleDirectionsUrl(at.lat, at.lon),
|
| 2772 |
-
displayData: "Go",
|
| 2773 |
-
allowOverlay: false,
|
| 2774 |
-
readonly: true,
|
| 2775 |
-
hoverEffect: true,
|
| 2776 |
-
};
|
| 2777 |
-
},
|
| 2778 |
-
[baseGetCellContent, displayRows, scope, visibleCols.length]
|
| 2779 |
-
);
|
| 2780 |
const { gridSelection, selectedPids, onGridSelectionChange, selectPids, togglePid,
|
| 2781 |
setActiveCell, clearSelection } =
|
| 2782 |
useGridSelection(
|
| 2783 |
displayRows,
|
| 2784 |
displayPidToIndex,
|
| 2785 |
-
|
| 2786 |
embeddedSelectable ? embeddedSelectedIds : [],
|
| 2787 |
!embedded ? `aios:grid-selection:${scope}` : undefined
|
| 2788 |
);
|
|
@@ -3516,9 +3530,16 @@ function CustomerGridSurface({
|
|
| 3516 |
// narrower than the frozen strip) rather than the everyday case.
|
| 3517 |
const boxRect = gridBoxRef.current?.getBoundingClientRect();
|
| 3518 |
const at = b ? expandButtonRect(b, boxRect) : null;
|
| 3519 |
-
//
|
| 3520 |
-
//
|
| 3521 |
-
//
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3522 |
const starAt = b ? starButtonRect(b, boxRect) : null;
|
| 3523 |
setStarHover((prev) =>
|
| 3524 |
!starAt
|
|
@@ -3552,7 +3573,18 @@ function CustomerGridSurface({
|
|
| 3552 |
// returns the label by identity when it fits, so this asks the renderer what it did
|
| 3553 |
// rather than re-running the measurement and hoping the two agree.
|
| 3554 |
const cut = !!field && !!colDef && colDef.title !== field.label;
|
| 3555 |
-
const
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3556 |
const bounds = args.bounds;
|
| 3557 |
if (text && bounds) {
|
| 3558 |
setHeaderTip((prev) =>
|
|
@@ -3767,26 +3799,38 @@ function CustomerGridSurface({
|
|
| 3767 |
args.ctx.font = `${args.theme.headerFontStyle} ${args.theme.fontFamily}`;
|
| 3768 |
drawContent();
|
| 3769 |
if (!field) return;
|
| 3770 |
-
|
| 3771 |
-
//
|
| 3772 |
-
//
|
| 3773 |
-
//
|
| 3774 |
-
//
|
| 3775 |
-
//
|
| 3776 |
-
//
|
| 3777 |
-
|
| 3778 |
-
//
|
| 3779 |
-
//
|
| 3780 |
-
//
|
| 3781 |
-
//
|
| 3782 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3783 |
args.rect,
|
| 3784 |
args.menuBounds.width,
|
| 3785 |
-
|
|
|
|
| 3786 |
);
|
| 3787 |
-
if (!
|
|
|
|
| 3788 |
let slot = 0;
|
| 3789 |
-
if (
|
| 3790 |
const at = marks[slot++];
|
| 3791 |
args.spriteManager.drawSprite(
|
| 3792 |
"aiosInfo",
|
|
@@ -3798,7 +3842,7 @@ function CustomerGridSurface({
|
|
| 3798 |
args.theme
|
| 3799 |
);
|
| 3800 |
}
|
| 3801 |
-
if (
|
| 3802 |
// Wave-14 item 1 / R11 β the user-created-field marker that REPLACES the yellow header
|
| 3803 |
// wash. A muted dot: quiet enough to ignore while reading, present enough to answer
|
| 3804 |
// "which of these columns are mine?" at a glance. Never a background β the owner killed
|
|
@@ -3812,6 +3856,28 @@ function CustomerGridSurface({
|
|
| 3812 |
ctx.fill();
|
| 3813 |
ctx.restore();
|
| 3814 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3815 |
},
|
| 3816 |
[fieldByKey]
|
| 3817 |
);
|
|
@@ -3833,16 +3899,10 @@ function CustomerGridSurface({
|
|
| 3833 |
});
|
| 3834 |
return;
|
| 3835 |
}
|
| 3836 |
-
//
|
| 3837 |
-
//
|
| 3838 |
-
//
|
| 3839 |
-
|
| 3840 |
-
const at = directionsFor(row.record);
|
| 3841 |
-
if (!at) return;
|
| 3842 |
-
event.preventDefault();
|
| 3843 |
-
window.open(googleDirectionsUrl(at.lat, at.lon), "_blank", "noopener,noreferrer");
|
| 3844 |
-
return;
|
| 3845 |
-
}
|
| 3846 |
const column = visibleCols[cell[0]];
|
| 3847 |
const field = column ? fieldByKey.get(column.id!) : undefined;
|
| 3848 |
// A picked field (select / assignee) opens its choices where the cell is. It cannot use
|
|
@@ -3860,6 +3920,9 @@ function CustomerGridSurface({
|
|
| 3860 |
// like a typed edit does.
|
| 3861 |
setActiveCell(cell[0], cell[1]);
|
| 3862 |
const b = event.bounds;
|
|
|
|
|
|
|
|
|
|
| 3863 |
setPicker({
|
| 3864 |
pid: row.record.pid,
|
| 3865 |
fieldKey: field.key,
|
|
@@ -4053,13 +4116,11 @@ function CustomerGridSurface({
|
|
| 4053 |
},
|
| 4054 |
[embedded, visibleCols]
|
| 4055 |
);
|
| 4056 |
-
|
| 4057 |
-
|
| 4058 |
-
|
| 4059 |
-
|
| 4060 |
-
|
| 4061 |
-
[onColumnResize]
|
| 4062 |
-
);
|
| 4063 |
const onGridColumnMoved = useCallback(
|
| 4064 |
(from: number, to: number) => {
|
| 4065 |
if (from >= visibleCols.length || to >= visibleCols.length) return;
|
|
@@ -4080,6 +4141,47 @@ function CustomerGridSurface({
|
|
| 4080 |
},
|
| 4081 |
[openHeaderMenu]
|
| 4082 |
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 4083 |
const onGridKeyDown = useCallback(
|
| 4084 |
(event: GridKeyEventArgs) => {
|
| 4085 |
if (
|
|
@@ -4111,29 +4213,10 @@ function CustomerGridSurface({
|
|
| 4111 |
// had. glide's text overlay cannot serve these types (validateCell refuses them),
|
| 4112 |
// so without this the keyboard run down a column dead-ends at every picked field.
|
| 4113 |
// Shift+Enter stays pure navigation, so walking UP past picked cells still works.
|
| 4114 |
-
|
| 4115 |
-
|
| 4116 |
-
|
| 4117 |
-
if (
|
| 4118 |
-
!event.shiftKey &&
|
| 4119 |
-
curRow?.kind === "data" &&
|
| 4120 |
-
curField &&
|
| 4121 |
-
canEditField(curField) &&
|
| 4122 |
-
(isPickType(curField.type) || curField.type === "rating")
|
| 4123 |
-
) {
|
| 4124 |
-
const b = gridRef.current?.getBounds(cur[0], cur[1]);
|
| 4125 |
-
if (b) {
|
| 4126 |
-
setPicker({
|
| 4127 |
-
pid: curRow.record.pid,
|
| 4128 |
-
fieldKey: curField.key,
|
| 4129 |
-
anchor: {
|
| 4130 |
-
left: b.x, top: b.y, right: b.x + b.width, bottom: b.y + b.height,
|
| 4131 |
-
width: b.width, height: b.height,
|
| 4132 |
-
},
|
| 4133 |
-
});
|
| 4134 |
-
return;
|
| 4135 |
-
}
|
| 4136 |
-
}
|
| 4137 |
const dir = event.shiftKey ? -1 : 1;
|
| 4138 |
let row = cur[1] + dir;
|
| 4139 |
while (row >= 0 && row < displayRows.length && displayRows[row]?.kind !== "data")
|
|
@@ -4145,6 +4228,34 @@ function CustomerGridSurface({
|
|
| 4145 |
return;
|
| 4146 |
}
|
| 4147 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 4148 |
const contextMenu =
|
| 4149 |
event.key === "ContextMenu" || (event.key === "F10" && event.shiftKey);
|
| 4150 |
// DataEditor exposes public controlled selection without the row marker,
|
|
@@ -4169,7 +4280,7 @@ function CustomerGridSurface({
|
|
| 4169 |
});
|
| 4170 |
},
|
| 4171 |
[gridSelection.current, openHeaderMenu, displayRows, setActiveCell,
|
| 4172 |
-
visibleCols, fieldByKey, canEditField]
|
| 4173 |
);
|
| 4174 |
|
| 4175 |
/**
|
|
@@ -4927,6 +5038,23 @@ function CustomerGridSurface({
|
|
| 4927 |
* PENDING measure condition currently matches nothing β an export taken then would be
|
| 4928 |
* an empty/narrower file wearing the view's name. Both windows self-resolve; the
|
| 4929 |
* refusal is silent no-op for one round trip.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 4930 |
*/
|
| 4931 |
const exportRows = useCallback(
|
| 4932 |
(name: string, cfg: ViewConfig, poolRows: Row[], format: ExportFormat) => {
|
|
@@ -4953,6 +5081,40 @@ function CustomerGridSurface({
|
|
| 4953 |
? { ...r.record, ...overlayEdits[r.record.pid] }
|
| 4954 |
: r.record
|
| 4955 |
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 4956 |
// Columns = the view's VISIBLE fields in display order (the reconciled order:
|
| 4957 |
// every key present, config order first β the same shape useGridColumns paints).
|
| 4958 |
const inOrder = new Set(cfg.order);
|
|
@@ -4965,7 +5127,7 @@ function CustomerGridSurface({
|
|
| 4965 |
.filter((k) => vis.has(k))
|
| 4966 |
.map((k) => fieldByKey.get(k))
|
| 4967 |
.filter((f): f is Field => !!f);
|
| 4968 |
-
runExport(format, name, today, cols, records);
|
| 4969 |
},
|
| 4970 |
[serverWindowed, fields, fieldByKey, measureSets, cohortSets, today, overlayEdits]
|
| 4971 |
);
|
|
@@ -6583,15 +6745,46 @@ function CustomerGridSurface({
|
|
| 6583 |
// (item 5). Single select/user keep pick-and-close.
|
| 6584 |
const pickerMulti = pickerField?.type === "multiselect";
|
| 6585 |
const pickerParts = pickerMulti ? splitMulti(pickerValue) : [];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 6586 |
/** Item 6 β which choice receives focus when the picker opens: the current value where it
|
| 6587 |
-
* still exists in the list, else the first choice. Keyboard-only editing starts HERE.
|
| 6588 |
-
|
|
|
|
|
|
|
| 6589 |
? null
|
| 6590 |
: pickerMulti
|
| 6591 |
-
? pickerParts.find((p) =>
|
| 6592 |
-
:
|
| 6593 |
? pickerValue
|
| 6594 |
-
:
|
| 6595 |
|
| 6596 |
return (
|
| 6597 |
// `data-today` is the TENANT'S day, exactly as the payload delivered it. It is here so the
|
|
@@ -7049,7 +7242,7 @@ function CustomerGridSurface({
|
|
| 7049 |
<>
|
| 7050 |
<DataEditor
|
| 7051 |
ref={gridRef}
|
| 7052 |
-
columns={
|
| 7053 |
getCellContent={getCellContent}
|
| 7054 |
rows={displayRows.length}
|
| 7055 |
theme={lightTheme}
|
|
@@ -7110,7 +7303,7 @@ function CustomerGridSurface({
|
|
| 7110 |
// `false` from here takes the write over from glide's per-cell path.
|
| 7111 |
onDelete={onGridDelete}
|
| 7112 |
validateCell={validateCell}
|
| 7113 |
-
onColumnResize={
|
| 7114 |
onColumnMoved={onGridColumnMoved}
|
| 7115 |
onColumnProposeMove={onGridColumnProposeMove}
|
| 7116 |
drawHeader={drawGridHeader}
|
|
@@ -7579,10 +7772,19 @@ function CustomerGridSurface({
|
|
| 7579 |
</svg>
|
| 7580 |
</button>
|
| 7581 |
)}
|
| 7582 |
-
{/* ββ
|
| 7583 |
-
|
| 7584 |
-
glide's own bounds, so the rect IS the hit
|
| 7585 |
-
whose click target can drift from its
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 7586 |
|
| 7587 |
β HOVER-SCOPED, AND THAT IS STATED RATHER THAN IMPLIED. This is how you SET a star
|
| 7588 |
and it reports whether the row under the pointer has one. "Which records are
|
|
@@ -7830,6 +8032,11 @@ function CustomerGridSurface({
|
|
| 7830 |
rollupSourceOffer={rollupSourceOffer}
|
| 7831 |
locked={menuField.key === lockedKey}
|
| 7832 |
schemaLocked={isSchemaLocked(menuField)}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 7833 |
viewer={viewer}
|
| 7834 |
sortedDir={menuSortedDir}
|
| 7835 |
isFiltered={menuIsFiltered}
|
|
@@ -8416,7 +8623,15 @@ function CustomerGridSurface({
|
|
| 8416 |
anchor={picker.anchor}
|
| 8417 |
className="cg-pop cg-pick-pop"
|
| 8418 |
placement="bottom-start"
|
| 8419 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 8420 |
ariaLabel={`Choose ${pickerField.label}`}
|
| 8421 |
onDismiss={closePicker}
|
| 8422 |
dataKind="cell-picker"
|
|
@@ -8424,8 +8639,27 @@ function CustomerGridSurface({
|
|
| 8424 |
// the current choice (fallback: the first), arrows move between choices, Enter picks
|
| 8425 |
// (native button activation), Escape closes, and closePicker hands focus back to the
|
| 8426 |
// grid so the next Enter keeps walking the column.
|
| 8427 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 8428 |
onKeyDown={(e) => {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 8429 |
const fwd = e.key === "ArrowDown" || e.key === "ArrowRight";
|
| 8430 |
const back = e.key === "ArrowUp" || e.key === "ArrowLeft";
|
| 8431 |
if (!fwd && !back) return;
|
|
@@ -8437,9 +8671,17 @@ function CustomerGridSurface({
|
|
| 8437 |
if (!items.length) return;
|
| 8438 |
e.preventDefault();
|
| 8439 |
const at = items.indexOf(document.activeElement as HTMLButtonElement);
|
| 8440 |
-
|
| 8441 |
-
|
| 8442 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 8443 |
items[next]?.focus();
|
| 8444 |
}}
|
| 8445 |
>
|
|
@@ -8482,8 +8724,37 @@ function CustomerGridSurface({
|
|
| 8482 |
: "This field has no choices yet. Add them from the column menu."}
|
| 8483 |
</div>
|
| 8484 |
)}
|
| 8485 |
-
|
| 8486 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 8487 |
const tint = optionTint(pickerField, choice);
|
| 8488 |
const on = pickerMulti
|
| 8489 |
? pickerParts.includes(choice)
|
|
@@ -8575,6 +8846,13 @@ function CustomerGridSurface({
|
|
| 8575 |
);
|
| 8576 |
})}
|
| 8577 |
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 8578 |
{pickerMulti && (
|
| 8579 |
<div className="cg-form-actions">
|
| 8580 |
<button
|
|
|
|
| 12 |
CellClickedEventArgs,
|
| 13 |
DataEditorRef,
|
| 14 |
EditableGridCell,
|
|
|
|
|
|
|
| 15 |
GridKeyEventArgs,
|
| 16 |
GridMouseEventArgs,
|
| 17 |
GridSelection,
|
|
|
|
| 69 |
saveScriptView,
|
| 70 |
} from "./scriptViews";
|
| 71 |
import type { ScriptRun, ScriptView as ScriptViewRecord, ScriptViewRow } from "./scriptViews";
|
| 72 |
+
import { defaultViewConfig, headerMarksFor, useGridColumns } from "./useGridColumns";
|
| 73 |
import { activeMeasureRuleIds, pendingMeasures, runPipeline, sliceForDisplay,
|
| 74 |
unresolvedConditions, useVisibleRows } from "./useVisibleRows";
|
| 75 |
import { computeAggs } from "./aggregations";
|
|
|
|
| 103 |
// Owner item 16 / R4 / C-UNDO β the stack and every inverse. Pure, so a node gate can run it.
|
| 104 |
import { describe, directed, popRedo, popUndo, pushUndo, stackFor } from "./undoStack";
|
| 105 |
import type { CellChange, UndoBook, UndoEntry, UndoRow, UndoValue } from "./undoStack";
|
| 106 |
+
import { exportFilename, groupingApplies, runExport, toExportGroups, triggerDownload } from "./export";
|
| 107 |
+
import type { ExportFormat, ExportGrouping } from "./export";
|
| 108 |
// owner item 3 (2026-08-03) β a time-series view exports its SHEET, not the rows under it.
|
| 109 |
import { buildTsCsv, tsSheetToTable } from "./timeSeriesData";
|
| 110 |
import type { TsSheet } from "./timeSeriesData";
|
|
|
|
| 132 |
import { cleanCharts } from "../viz/chartData";
|
| 133 |
import type { ChartSpec } from "../viz/chartData";
|
| 134 |
import { MapView } from "./MapView";
|
|
|
|
| 135 |
/* βββ W18-C CATALOG βββ (owner item 4, contract C6) */
|
| 136 |
import { CatalogView } from "./CatalogView";
|
| 137 |
import { CATALOG_CODE_FIELD } from "./catalogData";
|
|
|
|
| 139 |
/* βββ end W18-C CATALOG βββ */
|
| 140 |
import { lightTheme, STATUS_ROW_THEME, HOVER_ROW_THEME, HOVER_NEUTRAL,
|
| 141 |
ACTIVE_ROW_NEUTRAL, CUSTOM_FIELD_MARK } from "./theme";
|
| 142 |
+
import { avatarInitials, formatDisplay, imageCellRenderer, matchChoices, pickerTypeSeed,
|
| 143 |
+
ratingCellRenderer, setAvatarRepaint, userCellRenderer } from "./cells";
|
| 144 |
import { optionTint, pickTint } from "./choiceColors";
|
| 145 |
import {
|
| 146 |
EMPTY_GRID_COPY_PROVENANCE,
|
|
|
|
| 150 |
pasteRowCount,
|
| 151 |
} from "./clipboard";
|
| 152 |
import { cellTipText, expandButtonRect, starButtonRect,
|
| 153 |
+
GROUP_HEADER_FONT, GROUP_LABEL_PAD, hasShareMark, headerMarkFit,
|
| 154 |
+
tipLeft } from "./overlayPlacement";
|
| 155 |
import { AnchoredOverlay, BodyPortal, useOverlayLayer } from "./OverlaySurface";
|
| 156 |
import type { AnchorRect } from "./OverlaySurface";
|
| 157 |
import { StarIcon } from "./Stars";
|
| 158 |
import { ALL_VIEW_ID, MAX_CALENDAR_METRICS, allViewName,
|
| 159 |
MAX_FROZEN, choiceOptions, choiceVocabulary, clampFrozenCount, cleanDisplay, formulaOf,
|
| 160 |
topicForScope,
|
| 161 |
+
isDateFamilyType, isFilterGroup, isGroupableField,
|
| 162 |
isDerivedLink, isUserSchemaField, isBlankValue, TOTAL_GROUP_KEY,
|
| 163 |
isNumericFieldType,
|
| 164 |
machineFoundRows, reFindConsequences,
|
|
|
|
| 214 |
const ROW_PX: Record<RowHeightMode, number> = { short: 28, medium: 34, tall: 48 };
|
| 215 |
|
| 216 |
/**
|
| 217 |
+
* W40-T30, 2026-08-24 β W39-T22's virtual "Go" directions column is GONE, removed on owner
|
| 218 |
+
* instruction 27: "Remove the 'Go' field for Google Maps. Use the URL field we already have,
|
| 219 |
+
* with the Google link derived from the address by Formula, or make it editable so you can put
|
| 220 |
+
* it there. It is a pre-set field."
|
| 221 |
+
*
|
| 222 |
+
* It was a synthetic `GridColumn` appended after the real ones and resolved by POSITION
|
| 223 |
+
* (`cell[0] === visibleCols.length`), which is why its removal touches the cell resolver, the
|
| 224 |
+
* click door and the column-count handed to `useGridSelection` rather than one block. The
|
| 225 |
+
* transit link is now an ordinary PRE-SET URL FIELD on the customer database, whose value is
|
| 226 |
+
* computed server side (W40-T08), so it exports, permissions, reorders and hides like every
|
| 227 |
+
* other field instead of living outside the field system.
|
| 228 |
+
*
|
| 229 |
+
* Nothing replaces it HERE by design: a normal field simply occupies that place. The
|
| 230 |
+
* no-dead-link rule the old blank-cell branch enforced now belongs to the field's value, which
|
| 231 |
+
* is absent when the address is.
|
| 232 |
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 233 |
|
| 234 |
/**
|
| 235 |
* Wave-14 R7 β **a button label is ONE LINE.** Every button row in this file is a flex row with
|
|
|
|
| 326 |
* when a COLUMN carries a `group` β `useGridColumns` never sets one (scrolling-data-grid.js:13). */
|
| 327 |
const HEADER_PX = 36;
|
| 328 |
|
| 329 |
+
/**
|
| 330 |
+
* β W40-T20 β WHAT THE SHARE MARK MEANS, in words, because a canvas sprite cannot carry a
|
| 331 |
+
* `title` or an `aria-label` of its own.
|
| 332 |
+
*
|
| 333 |
+
* DESIGN.md Β§4 "one mark, one meaning": whatever carries a mark must name what the mark applies
|
| 334 |
+
* to, or two marks are indistinguishable. In the view rail that is an attribute on the element;
|
| 335 |
+
* on this surface the header is painted pixels, so the header TIP is the only place the meaning
|
| 336 |
+
* can live, and hovering the column is how a reader gets it.
|
| 337 |
+
*
|
| 338 |
+
* β NOT the rail's receiver wording. Contract C1: `shared` says the field HAS grants, and the
|
| 339 |
+
* server stamps it on the owner's own copy too, so "shared with you by ..." would be a lie for
|
| 340 |
+
* the person who shared it out. One sentence that is true on both legs is the answer.
|
| 341 |
+
*
|
| 342 |
+
* ββ AND IT MUST NOT NAME AN AUDIENCE. The first draft of this line read "Everyone with access
|
| 343 |
+
* to this table sees it", which is FALSE in exactly the case W40-T03 (owner instruction 21) exists
|
| 344 |
+
* to fix: `routes_customers._merge_shared_fields` merges a shared definition for EVERY user and
|
| 345 |
+
* `core.perm_scope.field_grant_hidden` then hides it again from anyone the grant does not name, so
|
| 346 |
+
* a field shared with one person is not a field everyone sees. Nothing on this side of the wire can
|
| 347 |
+
* tell a wildcard grant from a one-person grant β `Field.shared` says only THAT there are grants β
|
| 348 |
+
* so a tooltip claiming the audience would ship the same mislabel one surface over. It names the
|
| 349 |
+
* mark and points at the control that owns the answer, which is where the DECISION is made
|
| 350 |
+
* (DESIGN.md Β§4, "explanation lives where the decision is").
|
| 351 |
+
*/
|
| 352 |
+
const SHARE_MARK_MEANING = "Shared field. Access is set in Share field.";
|
| 353 |
+
|
| 354 |
/** glide's own row-marker width ladder, `data-editor.js:103`, verbatim.
|
| 355 |
*
|
| 356 |
* β It is passed BACK to glide as `rowMarkerWidth` rather than merely predicted here. The
|
|
|
|
| 1179 |
pid: number;
|
| 1180 |
fieldKey: string;
|
| 1181 |
anchor: AnchorRect;
|
| 1182 |
+
/**
|
| 1183 |
+
* β W40-T23 β the character that OPENED this picker, when a keystroke did. It is the
|
| 1184 |
+
* find box's starting text, and it is what tells the overlay to focus the box instead of
|
| 1185 |
+
* the current choice.
|
| 1186 |
+
*
|
| 1187 |
+
* β IMMUTABLE WHILE THE PICKER IS OPEN, and the live query is separate state BECAUSE of
|
| 1188 |
+
* that. `AnchoredOverlay`'s focus effect is keyed on `initialFocus`, and its cleanup calls
|
| 1189 |
+
* `previous.focus()` β so a selector derived from the live query would, on every
|
| 1190 |
+
* keystroke, throw focus back to the grid and then re-grab it. The seed never changes, so
|
| 1191 |
+
* the selector never changes.
|
| 1192 |
+
*/
|
| 1193 |
+
seed?: string;
|
| 1194 |
} | null>(null);
|
| 1195 |
+
/** W40-T23 β what is typed in the picker's find box. Seeded by the keystroke that opened it
|
| 1196 |
+
* (see `seed`), reset by every open and by `closePicker`, so a picker never inherits the
|
| 1197 |
+
* previous one's query. */
|
| 1198 |
+
const [pickQuery, setPickQuery] = useState("");
|
| 1199 |
/** Owner item 5 (2026-07-31) β closing a picker RETURNS FOCUS TO THE GRID, so Enter keeps
|
| 1200 |
* navigating (pick β Enter β next record) instead of stranding focus on a dead overlay. */
|
| 1201 |
const closePicker = useCallback(() => {
|
| 1202 |
setPicker(null);
|
| 1203 |
+
setPickQuery("");
|
| 1204 |
requestAnimationFrame(() => gridRef.current?.focus());
|
| 1205 |
}, []);
|
| 1206 |
/** β Wave-23 C7 β which `json` cell the big viewer is open on. NOT anchored like the picker
|
|
|
|
| 1750 |
pendingRouteRevealRef.current = null;
|
| 1751 |
insertColumn(key, lockedKey, "right");
|
| 1752 |
}, [fieldByKey, insertColumn, lockedKey]);
|
| 1753 |
+
// W40-T30 β what Glide paints IS the visible column list now. The memo that appended a
|
| 1754 |
+
// virtual "Go" column on the customer scope went with owner instruction 27 (see the tombstone
|
| 1755 |
+
// at the top of this file), so there is no longer a trailing column outside the field system
|
| 1756 |
+
// and no index beyond the real ones to special-case.
|
|
|
|
|
|
|
| 1757 |
|
| 1758 |
/**
|
| 1759 |
* β Wave-20 owner item 4 (ruling R8, contract C-ADDROW) β **THE GHOST ROW.**
|
|
|
|
| 2774 |
return () => window.clearInterval(id);
|
| 2775 |
}, [pendingMeasureKeys]);
|
| 2776 |
const activePendingKeys = pendingGaveUp ? NO_PENDING_KEYS : pendingMeasureKeys;
|
| 2777 |
+
const getCellContent = useGetCellContent(
|
| 2778 |
displayRows,
|
| 2779 |
visibleCols,
|
| 2780 |
fieldByKey,
|
|
|
|
| 2787 |
activePendingKeys,
|
| 2788 |
pulse
|
| 2789 |
);
|
| 2790 |
+
// W40-T30 β the wrapper that sat here intercepted `cell[0] === visibleCols.length` (the one
|
| 2791 |
+
// index past the real columns) to paint the virtual "Go" Uri cell. Owner instruction 27
|
| 2792 |
+
// removed the feature, so every index glide asks for is a real column again and the hook's
|
| 2793 |
+
// own result is handed straight to the grid.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2794 |
const { gridSelection, selectedPids, onGridSelectionChange, selectPids, togglePid,
|
| 2795 |
setActiveCell, clearSelection } =
|
| 2796 |
useGridSelection(
|
| 2797 |
displayRows,
|
| 2798 |
displayPidToIndex,
|
| 2799 |
+
visibleCols.length,
|
| 2800 |
embeddedSelectable ? embeddedSelectedIds : [],
|
| 2801 |
!embedded ? `aios:grid-selection:${scope}` : undefined
|
| 2802 |
);
|
|
|
|
| 3530 |
// narrower than the frozen strip) rather than the everyday case.
|
| 3531 |
const boxRect = gridBoxRef.current?.getBoundingClientRect();
|
| 3532 |
const at = b ? expandButtonRect(b, boxRect) : null;
|
| 3533 |
+
// β OWNER INSTRUCTION 29 (wave 40, 2026-08-24) β the star sits IMMEDIATELY LEFT OF THE
|
| 3534 |
+
// EXPAND, and this call is what guarantees it: `starButtonRect` derives its rect from
|
| 3535 |
+
// `expandButtonRect`'s, off the SAME `b`. So there is one row-height gate, one box
|
| 3536 |
+
// clamp and one vertical centre between the two controls, and no `starAt` can exist
|
| 3537 |
+
// on a row where `at` is null.
|
| 3538 |
+
// β THIS REVERSES W35-T29 (R5, R6), whose comment stood here and said the opposite:
|
| 3539 |
+
// the star book-ended the cell from the LEFT and kept its own LOWER minima, so "a
|
| 3540 |
+
// compact row that cannot carry the Expand can still carry this one". That was
|
| 3541 |
+
// deliberate then and it is reversed now. The band it protected (rows under 26px) is
|
| 3542 |
+
// empty anyway: `ROW_PX` is the whole set of data-row heights, 28 / 34 / 48.
|
| 3543 |
const starAt = b ? starButtonRect(b, boxRect) : null;
|
| 3544 |
setStarHover((prev) =>
|
| 3545 |
!starAt
|
|
|
|
| 3573 |
// returns the label by identity when it fits, so this asks the renderer what it did
|
| 3574 |
// rather than re-running the measurement and hoping the two agree.
|
| 3575 |
const cut = !!field && !!colDef && colDef.title !== field.label;
|
| 3576 |
+
const body = cut && field ? (note ? `${field.label}: ${note}` : field.label) : note;
|
| 3577 |
+
// β W40-T20 β the share mark's MEANING, appended to whatever the tip already said. It is
|
| 3578 |
+
// the same predicate the drawer paints from, so the words and the glyph can never
|
| 3579 |
+
// disagree about which columns are shared; and it is appended rather than substituted
|
| 3580 |
+
// because a shared column with a description needs to say both.
|
| 3581 |
+
//
|
| 3582 |
+
// β It also OPENS the tip on a column that would otherwise have none. That is the point:
|
| 3583 |
+
// an unexplained glyph on a canvas is exactly the mark DESIGN.md Β§4 forbids, and it is the
|
| 3584 |
+
// one state in which the mark can be dropped for width and the fact still reach the reader.
|
| 3585 |
+
const shareNote =
|
| 3586 |
+
field && hasShareMark(field) ? SHARE_MARK_MEANING : undefined;
|
| 3587 |
+
const text = shareNote ? (body ? `${body} ${shareNote}` : shareNote) : body;
|
| 3588 |
const bounds = args.bounds;
|
| 3589 |
if (text && bounds) {
|
| 3590 |
setHeaderTip((prev) =>
|
|
|
|
| 3799 |
args.ctx.font = `${args.theme.headerFontStyle} ${args.theme.fontFamily}`;
|
| 3800 |
drawContent();
|
| 3801 |
if (!field) return;
|
| 3802 |
+
// β W40-T20, INSTRUCTION 1: *"A field that has been shared should show the shared icon next
|
| 3803 |
+
// to it so people know it is a shared Field."*
|
| 3804 |
+
//
|
| 3805 |
+
// β THE STRIP IS RESOLVED BY `headerMarksFor`, NOT DECIDED HERE. This callback used to
|
| 3806 |
+
// re-derive each mark's condition from the field, and `useGridColumns` re-derived them
|
| 3807 |
+
// again for the title's truncation reserve β two copies that had ALREADY drifted on the
|
| 3808 |
+
// user-created dot before this ticket added a third mark. The drawer and the reserve now
|
| 3809 |
+
// call one function, so "the marks drawn and the marks reserved for cannot disagree" is a
|
| 3810 |
+
// property of the code rather than a comment asking two files to stay in step.
|
| 3811 |
+
//
|
| 3812 |
+
// β `shared` means "this field HAS grants", not "granted to me" (contract C1). The server
|
| 3813 |
+
// stamps it on the owner's own copy too, so the mark appears for whoever shared the column
|
| 3814 |
+
// out, not only for whoever received it.
|
| 3815 |
+
const strip = headerMarksFor(field);
|
| 3816 |
+
// null = the column is too narrow to carry the strip without covering its own label, and
|
| 3817 |
+
// then NOTHING is drawn.
|
| 3818 |
+
//
|
| 3819 |
+
// β `headerMarkFit`, NOT `headerMarkLayout`, and `droppable` is the whole reason: the strip
|
| 3820 |
+
// is all-or-nothing, so simply appending a third mark would have made a column with room
|
| 3821 |
+
// for two draw ZERO. The share mark is the one slot allowed to give way, so a tight column
|
| 3822 |
+
// loses the new mark and keeps the (i) and the user-created dot behaving exactly as they
|
| 3823 |
+
// did before it existed.
|
| 3824 |
+
const fit = headerMarkFit(
|
| 3825 |
args.rect,
|
| 3826 |
args.menuBounds.width,
|
| 3827 |
+
strip.sizes,
|
| 3828 |
+
strip.droppable
|
| 3829 |
);
|
| 3830 |
+
if (!fit) return;
|
| 3831 |
+
const marks = fit.layout;
|
| 3832 |
let slot = 0;
|
| 3833 |
+
if (strip.info) {
|
| 3834 |
const at = marks[slot++];
|
| 3835 |
args.spriteManager.drawSprite(
|
| 3836 |
"aiosInfo",
|
|
|
|
| 3842 |
args.theme
|
| 3843 |
);
|
| 3844 |
}
|
| 3845 |
+
if (strip.custom) {
|
| 3846 |
// Wave-14 item 1 / R11 β the user-created-field marker that REPLACES the yellow header
|
| 3847 |
// wash. A muted dot: quiet enough to ignore while reading, present enough to answer
|
| 3848 |
// "which of these columns are mine?" at a glance. Never a background β the owner killed
|
|
|
|
| 3856 |
ctx.fill();
|
| 3857 |
ctx.restore();
|
| 3858 |
}
|
| 3859 |
+
if (strip.shared) {
|
| 3860 |
+
// β W40-T20 β the two-people mark (`SHARE_SHAPE`, iconShapes.ts), drawn the same way the
|
| 3861 |
+
// (i) is: a canvas SPRITE through glide's sprite manager, because a header mark on this
|
| 3862 |
+
// surface is painted onto the canvas and the React `LockMark` the view rail uses cannot
|
| 3863 |
+
// reach it.
|
| 3864 |
+
//
|
| 3865 |
+
// β THE ONLY MARK THAT MAY BE ABSENT WHILE ITS FIELD STILL HAS THE PROPERTY. `fit` drops
|
| 3866 |
+
// this slot on a column too tight for three, so `at` is legitimately undefined β the
|
| 3867 |
+
// strip degrades from the inside rather than dropping the two older marks with it. The
|
| 3868 |
+
// header tip still names the sharing in that state, so the fact stays reachable.
|
| 3869 |
+
const at = marks[slot++];
|
| 3870 |
+
if (at)
|
| 3871 |
+
args.spriteManager.drawSprite(
|
| 3872 |
+
"aiosShared",
|
| 3873 |
+
"normal",
|
| 3874 |
+
args.ctx,
|
| 3875 |
+
at.x,
|
| 3876 |
+
at.y,
|
| 3877 |
+
at.size,
|
| 3878 |
+
args.theme
|
| 3879 |
+
);
|
| 3880 |
+
}
|
| 3881 |
},
|
| 3882 |
[fieldByKey]
|
| 3883 |
);
|
|
|
|
| 3899 |
});
|
| 3900 |
return;
|
| 3901 |
}
|
| 3902 |
+
// W40-T30 β the virtual "Go" cell's tap door stood here, matched by POSITION on the index
|
| 3903 |
+
// one past the persisted columns. Owner instruction 27 removed it; the transit link is a
|
| 3904 |
+
// pre-set URL field now, so it opens through the ordinary url-cell branch below, which is
|
| 3905 |
+
// also where the noreferrer rule that protects every URL cell lives.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3906 |
const column = visibleCols[cell[0]];
|
| 3907 |
const field = column ? fieldByKey.get(column.id!) : undefined;
|
| 3908 |
// A picked field (select / assignee) opens its choices where the cell is. It cannot use
|
|
|
|
| 3920 |
// like a typed edit does.
|
| 3921 |
setActiveCell(cell[0], cell[1]);
|
| 3922 |
const b = event.bounds;
|
| 3923 |
+
// W40-T23 β a MOUSE-opened picker carries no seed: it shows every choice, focused on
|
| 3924 |
+
// the current one, exactly as it did before the typing door existed.
|
| 3925 |
+
setPickQuery("");
|
| 3926 |
setPicker({
|
| 3927 |
pid: row.record.pid,
|
| 3928 |
fieldKey: field.key,
|
|
|
|
| 4116 |
},
|
| 4117 |
[embedded, visibleCols]
|
| 4118 |
);
|
| 4119 |
+
// W40-T30 β the resize wrapper here existed for one reason: to swallow a drag on the virtual
|
| 4120 |
+
// "Go" column, which had no field to persist a width to. With that column gone (owner
|
| 4121 |
+
// instruction 27) every resizable column is a real one, so `onColumnResize` is handed to the
|
| 4122 |
+
// grid unwrapped. The two move guards below are kept as plain bounds checks: they never
|
| 4123 |
+
// depended on the virtual column, and they still refuse an out-of-range index.
|
|
|
|
|
|
|
| 4124 |
const onGridColumnMoved = useCallback(
|
| 4125 |
(from: number, to: number) => {
|
| 4126 |
if (from >= visibleCols.length || to >= visibleCols.length) return;
|
|
|
|
| 4141 |
},
|
| 4142 |
[openHeaderMenu]
|
| 4143 |
);
|
| 4144 |
+
/**
|
| 4145 |
+
* β W40-T23 / owner item 6 β ONE door for "open the picker on the cell the keyboard is on".
|
| 4146 |
+
*
|
| 4147 |
+
* Enter has opened a picked cell's choices since 2026-07-31; a typed character now opens the
|
| 4148 |
+
* same picker, seeded with that character. Both need the identical lookup β row, column,
|
| 4149 |
+
* field, permission verdict, glide's bounds β and a second copy of it is how two doors onto
|
| 4150 |
+
* one surface drift apart the day the verdict changes.
|
| 4151 |
+
*
|
| 4152 |
+
* `seed === undefined` means "opened by Enter" and `seed === "v"` means "opened by typing v";
|
| 4153 |
+
* the difference is one type test, below. Returns whether a picker was actually opened, so
|
| 4154 |
+
* Enter knows whether to fall through to walking the column.
|
| 4155 |
+
*/
|
| 4156 |
+
const openPickerAtCursor = useCallback(
|
| 4157 |
+
(seed?: string): boolean => {
|
| 4158 |
+
const cur = gridSelection.current?.cell;
|
| 4159 |
+
if (!cur) return false;
|
| 4160 |
+
const curRow = displayRows[cur[1]];
|
| 4161 |
+
const curColumn = visibleCols[cur[0]];
|
| 4162 |
+
const curField = curColumn ? fieldByKey.get(curColumn.id!) : undefined;
|
| 4163 |
+
if (curRow?.kind !== "data" || !curField || !canEditField(curField)) return false;
|
| 4164 |
+
// β A TYPED CHARACTER IS FOR A CHOICE LIST ONLY. A `rating` cell's picker is the star
|
| 4165 |
+
// row: it has no choices to filter, so a find box over it would be a control that can
|
| 4166 |
+
// only refuse. Enter still opens it β the two doors differ by exactly this test.
|
| 4167 |
+
const typed = seed !== undefined;
|
| 4168 |
+
if (!(isPickType(curField.type) || (!typed && curField.type === "rating"))) return false;
|
| 4169 |
+
const b = gridRef.current?.getBounds(cur[0], cur[1]);
|
| 4170 |
+
if (!b) return false;
|
| 4171 |
+
setPickQuery(seed ?? "");
|
| 4172 |
+
setPicker({
|
| 4173 |
+
pid: curRow.record.pid,
|
| 4174 |
+
fieldKey: curField.key,
|
| 4175 |
+
anchor: {
|
| 4176 |
+
left: b.x, top: b.y, right: b.x + b.width, bottom: b.y + b.height,
|
| 4177 |
+
width: b.width, height: b.height,
|
| 4178 |
+
},
|
| 4179 |
+
seed,
|
| 4180 |
+
});
|
| 4181 |
+
return true;
|
| 4182 |
+
},
|
| 4183 |
+
[gridSelection.current, displayRows, visibleCols, fieldByKey, canEditField]
|
| 4184 |
+
);
|
| 4185 |
const onGridKeyDown = useCallback(
|
| 4186 |
(event: GridKeyEventArgs) => {
|
| 4187 |
if (
|
|
|
|
| 4213 |
// had. glide's text overlay cannot serve these types (validateCell refuses them),
|
| 4214 |
// so without this the keyboard run down a column dead-ends at every picked field.
|
| 4215 |
// Shift+Enter stays pure navigation, so walking UP past picked cells still works.
|
| 4216 |
+
// β W40-T23 moved the body of this branch into `openPickerAtCursor` unchanged β the
|
| 4217 |
+
// typed-letter door needed the same lookup, and Enter passing NO seed is what keeps
|
| 4218 |
+
// it opening on the current choice rather than on a find box.
|
| 4219 |
+
if (!event.shiftKey && openPickerAtCursor()) return;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 4220 |
const dir = event.shiftKey ? -1 : 1;
|
| 4221 |
let row = cur[1] + dir;
|
| 4222 |
while (row >= 0 && row < displayRows.length && displayRows[row]?.kind !== "data")
|
|
|
|
| 4228 |
return;
|
| 4229 |
}
|
| 4230 |
}
|
| 4231 |
+
/**
|
| 4232 |
+
* β W40-T23 (owner instruction 14) β TYPING A LETTER OPENS THE PICKER, FILTERED.
|
| 4233 |
+
*
|
| 4234 |
+
* A picked cell carries `allowOverlay:false` (cells.ts: "the value is PICKED, never
|
| 4235 |
+
* typed"), and this handler answered exactly three keys, so a letter on a single- or
|
| 4236 |
+
* multi-select cell was a NO-OP β the one keystroke every spreadsheet answers. It now
|
| 4237 |
+
* opens the same choice list Enter opens, already narrowed to the choices containing
|
| 4238 |
+
* that character.
|
| 4239 |
+
*
|
| 4240 |
+
* β NOTHING IS WRITTEN. The keystroke opens a door; the value still changes only when a
|
| 4241 |
+
* choice is clicked or activated, which is what keeps a constrained column from growing
|
| 4242 |
+
* "Done", "done" and "DONE" the way a free-text editor here would.
|
| 4243 |
+
*
|
| 4244 |
+
* β AND IT MUST NOT RE-ENTER. `initialFocus` is applied inside a requestAnimationFrame,
|
| 4245 |
+
* so for one frame after this branch fires the canvas still holds focus β a fast second
|
| 4246 |
+
* character would arrive HERE rather than in the find box and reset the query to that
|
| 4247 |
+
* one letter. The open-picker test closes that window explicitly instead of resting on
|
| 4248 |
+
* focus timing.
|
| 4249 |
+
*/
|
| 4250 |
+
if (!picker) {
|
| 4251 |
+
const seed = pickerTypeSeed(event.key, event);
|
| 4252 |
+
if (seed !== null && openPickerAtCursor(seed)) {
|
| 4253 |
+
event.preventDefault();
|
| 4254 |
+
event.stopPropagation();
|
| 4255 |
+
event.cancel();
|
| 4256 |
+
return;
|
| 4257 |
+
}
|
| 4258 |
+
}
|
| 4259 |
const contextMenu =
|
| 4260 |
event.key === "ContextMenu" || (event.key === "F10" && event.shiftKey);
|
| 4261 |
// DataEditor exposes public controlled selection without the row marker,
|
|
|
|
| 4280 |
});
|
| 4281 |
},
|
| 4282 |
[gridSelection.current, openHeaderMenu, displayRows, setActiveCell,
|
| 4283 |
+
visibleCols, fieldByKey, canEditField, openPickerAtCursor, picker]
|
| 4284 |
);
|
| 4285 |
|
| 4286 |
/**
|
|
|
|
| 5038 |
* PENDING measure condition currently matches nothing β an export taken then would be
|
| 5039 |
* an empty/narrower file wearing the view's name. Both windows self-resolve; the
|
| 5040 |
* refusal is silent no-op for one round trip.
|
| 5041 |
+
*
|
| 5042 |
+
* ββ W40-T26 / OWNER INSTRUCTION 22 β A GROUPED VIEW EXPORTS GROUPED, and it is TWO
|
| 5043 |
+
* PIPELINE PASSES rather than one, deliberately.
|
| 5044 |
+
*
|
| 5045 |
+
* The FIRST pass below still runs with `groupBy: null`, and that is not the hardcoding
|
| 5046 |
+
* the ticket names β it is what makes `records` the same list it has always been: the
|
| 5047 |
+
* view's matches in the view's SORT order, one entry per record, identical for all four
|
| 5048 |
+
* formats. The SECOND pass (further down, and only when the view is actually grouped)
|
| 5049 |
+
* re-runs the same engine over that finished list with `filters: []` / `search: ""` /
|
| 5050 |
+
* `sorts: []`, so it cannot narrow or reorder anything β it exists purely to BUCKET.
|
| 5051 |
+
*
|
| 5052 |
+
* β WHY NOT ONE PASS. Grouping inside the first call would make `records` the flattened
|
| 5053 |
+
* bucket walk, which reorders every format's rows and β for a MULTI group field, where a
|
| 5054 |
+
* record genuinely belongs to every member of its cell β repeats records. `buildJson`
|
| 5055 |
+
* promises one row per record with a stable pid; duplicate pids in a machine-readable
|
| 5056 |
+
* file is a data defect. The xlsx is the only surface AM-3 asked to change, so it is the
|
| 5057 |
+
* only one that sees the bucketed shape.
|
| 5058 |
*/
|
| 5059 |
const exportRows = useCallback(
|
| 5060 |
(name: string, cfg: ViewConfig, poolRows: Row[], format: ExportFormat) => {
|
|
|
|
| 5081 |
? { ...r.record, ...overlayEdits[r.record.pid] }
|
| 5082 |
: r.record
|
| 5083 |
);
|
| 5084 |
+
|
| 5085 |
+
/* β W40-T26 β THE BUCKETING PASS. Only for a grouped view, and only for the format
|
| 5086 |
+
that renders bands (`groupingApplies` β Excel). `rawRows` is `records`, so the
|
| 5087 |
+
buckets are formed over the OVERLAID values a reader sees rather than the pre-edit
|
| 5088 |
+
ones, and `filters`/`search`/`sorts` are empty so this pass is incapable of
|
| 5089 |
+
narrowing or reordering: with no `memberPids` the pipeline's `curated` set is null,
|
| 5090 |
+
which is what leaves its membership branch unreachable here.
|
| 5091 |
+
β `collapsed` stays EMPTY on purpose. A file has no fold, so a group the reader
|
| 5092 |
+
happens to have folded on screen must still export its rows β and it is what makes
|
| 5093 |
+
each band's `count` equal to the rows actually printed under it. */
|
| 5094 |
+
let grouping: ExportGrouping | undefined;
|
| 5095 |
+
if (cfg.groupBy && groupingApplies(format)) {
|
| 5096 |
+
const { visibleRows: bucketed } = runPipeline({
|
| 5097 |
+
rawRows: records,
|
| 5098 |
+
fields,
|
| 5099 |
+
filters: [],
|
| 5100 |
+
search: "",
|
| 5101 |
+
sorts: [],
|
| 5102 |
+
groupBy: cfg.groupBy,
|
| 5103 |
+
collapsed: new Set<string>(),
|
| 5104 |
+
memberPids: [],
|
| 5105 |
+
filterConj: "and",
|
| 5106 |
+
measureSets,
|
| 5107 |
+
cohortSets,
|
| 5108 |
+
today,
|
| 5109 |
+
});
|
| 5110 |
+
/* β THE SENTINEL WALK lives in `export.ts::toExportGroups`, not here β it is the
|
| 5111 |
+
half of this ticket that is easy to miss (the `.filter(kind === "data")` above
|
| 5112 |
+
drops every sentinel, which is why unhardcoding a `groupBy` on its own would have
|
| 5113 |
+
changed nothing at all), and putting it in a pure module is what lets a node gate
|
| 5114 |
+
observe it. */
|
| 5115 |
+
grouping = { field: fieldByKey.get(cfg.groupBy), blocks: toExportGroups(bucketed) };
|
| 5116 |
+
}
|
| 5117 |
+
|
| 5118 |
// Columns = the view's VISIBLE fields in display order (the reconciled order:
|
| 5119 |
// every key present, config order first β the same shape useGridColumns paints).
|
| 5120 |
const inOrder = new Set(cfg.order);
|
|
|
|
| 5127 |
.filter((k) => vis.has(k))
|
| 5128 |
.map((k) => fieldByKey.get(k))
|
| 5129 |
.filter((f): f is Field => !!f);
|
| 5130 |
+
runExport(format, name, today, cols, records, grouping);
|
| 5131 |
},
|
| 5132 |
[serverWindowed, fields, fieldByKey, measureSets, cohortSets, today, overlayEdits]
|
| 5133 |
);
|
|
|
|
| 6745 |
// (item 5). Single select/user keep pick-and-close.
|
| 6746 |
const pickerMulti = pickerField?.type === "multiselect";
|
| 6747 |
const pickerParts = pickerMulti ? splitMulti(pickerValue) : [];
|
| 6748 |
+
/**
|
| 6749 |
+
* β W40-T23 β the choices this picker is SHOWING, which is the whole list until somebody
|
| 6750 |
+
* types. `matchChoices` is the same function the record drawer's chip row runs, so "which
|
| 6751 |
+
* choices survive this query" has one definition rather than one per surface.
|
| 6752 |
+
*/
|
| 6753 |
+
const pickerShown = matchChoices(pickerChoices, pickQuery);
|
| 6754 |
+
/**
|
| 6755 |
+
* β W40-T23 β WHETHER THE FIND BOX IS THERE: only when a KEYSTROKE opened this picker.
|
| 6756 |
+
*
|
| 6757 |
+
* β THE ABSENT CASE IS THE DESIGN, not a threshold somebody forgot. A picker opened by mouse
|
| 6758 |
+
* or by Enter looks and behaves exactly as it did before this ticket β and it must, because
|
| 6759 |
+
* owner item 6 (2026-07-31) opens an Enter-picker focused ON THE CURRENT CHOICE so that Enter
|
| 6760 |
+
* picks it and the keyboard run continues down the column. Focus the box instead and that run
|
| 6761 |
+
* dead-ends on every field, which is the defect item 6 exists to prevent.
|
| 6762 |
+
*
|
| 6763 |
+
* The rejected alternative was `FieldSelect`'s "show it above 8 choices" threshold. It would
|
| 6764 |
+
* paint a box on a mouse-opened picker that the keyboard cannot reach without a click, since
|
| 6765 |
+
* focus is on a row β a control you can see and cannot type into, which is nearer R8's fake
|
| 6766 |
+
* affordance than a help to anyone. A seeded box is focused, typed into and filtering the
|
| 6767 |
+
* moment it appears; that is ONE control shape (DESIGN.md Β§4), where two would have been two.
|
| 6768 |
+
*
|
| 6769 |
+
* β FROZEN while the picker is open β `seed` is immutable and `pickerChoices` is the field's β
|
| 6770 |
+
* so the box cannot appear or vanish under the user as they type.
|
| 6771 |
+
* β The rating test is a belt: `openPickerAtCursor` already refuses a seed on a star row.
|
| 6772 |
+
*/
|
| 6773 |
+
const pickerSearchOn =
|
| 6774 |
+
pickerField?.type !== "rating" &&
|
| 6775 |
+
pickerChoices.length > 0 &&
|
| 6776 |
+
picker?.seed !== undefined;
|
| 6777 |
/** Item 6 β which choice receives focus when the picker opens: the current value where it
|
| 6778 |
+
* still exists in the list, else the first choice. Keyboard-only editing starts HERE.
|
| 6779 |
+
* β W40-T23 resolves it against the SHOWN list: an autofocus target the filter has removed
|
| 6780 |
+
* is a selector matching nothing, and the overlay would open focused on the popover itself. */
|
| 6781 |
+
const pickerFocusChoice = !pickerShown.length
|
| 6782 |
? null
|
| 6783 |
: pickerMulti
|
| 6784 |
+
? pickerParts.find((p) => pickerShown.includes(p)) ?? pickerShown[0]
|
| 6785 |
+
: pickerShown.includes(pickerValue)
|
| 6786 |
? pickerValue
|
| 6787 |
+
: pickerShown[0];
|
| 6788 |
|
| 6789 |
return (
|
| 6790 |
// `data-today` is the TENANT'S day, exactly as the payload delivered it. It is here so the
|
|
|
|
| 7242 |
<>
|
| 7243 |
<DataEditor
|
| 7244 |
ref={gridRef}
|
| 7245 |
+
columns={visibleCols}
|
| 7246 |
getCellContent={getCellContent}
|
| 7247 |
rows={displayRows.length}
|
| 7248 |
theme={lightTheme}
|
|
|
|
| 7303 |
// `false` from here takes the write over from glide's per-cell path.
|
| 7304 |
onDelete={onGridDelete}
|
| 7305 |
validateCell={validateCell}
|
| 7306 |
+
onColumnResize={onColumnResize}
|
| 7307 |
onColumnMoved={onGridColumnMoved}
|
| 7308 |
onColumnProposeMove={onGridColumnProposeMove}
|
| 7309 |
drawHeader={drawGridHeader}
|
|
|
|
| 7772 |
</svg>
|
| 7773 |
</button>
|
| 7774 |
)}
|
| 7775 |
+
{/* ββ THE RECORD STAR, IMMEDIATELY TO THE LEFT OF THE EXPAND at the right end of the
|
| 7776 |
+
row's primary cell, level with it β owner instruction 29 (wave 40, 2026-08-24).
|
| 7777 |
+
A real DOM button over the canvas, at glide's own bounds, so the rect IS the hit
|
| 7778 |
+
test and there is no drawn affordance whose click target can drift from its
|
| 7779 |
+
paint ([[ui-invisible-to-assertions]]).
|
| 7780 |
+
|
| 7781 |
+
β IT REVERSES W35-T29 (R5, R6), AND THE OLD ARGUMENT IS RECORDED RATHER THAN
|
| 7782 |
+
DROPPED. R5 put this mark at the LEFT end of the cell so it BOOK-ENDED the
|
| 7783 |
+
Expand at the right, on Airtable's gutter convention and so neither control
|
| 7784 |
+
could ever land on the other. The owner has ruled the other way: the star must
|
| 7785 |
+
sit exactly beside and to the left of the Expand, on every database. The pair
|
| 7786 |
+
is now one cluster, and `starButtonRect` derives its position from the Expand's
|
| 7787 |
+
so the two can never disagree about where "beside" is.
|
| 7788 |
|
| 7789 |
β HOVER-SCOPED, AND THAT IS STATED RATHER THAN IMPLIED. This is how you SET a star
|
| 7790 |
and it reports whether the row under the pointer has one. "Which records are
|
|
|
|
| 8032 |
rollupSourceOffer={rollupSourceOffer}
|
| 8033 |
locked={menuField.key === lockedKey}
|
| 8034 |
schemaLocked={isSchemaLocked(menuField)}
|
| 8035 |
+
/* ββ W40-T24 β the menu's `columnDefinitionOffer` (display.ts) needs the same stratum
|
| 8036 |
+
answer this file already computes for `onRetype`/`onRename` below. Passed rather than
|
| 8037 |
+
re-derived: two readings of "is this a user database" is how the pane and the props
|
| 8038 |
+
that feed it come to disagree about the same column. */
|
| 8039 |
+
isUserTable={isUserTable}
|
| 8040 |
viewer={viewer}
|
| 8041 |
sortedDir={menuSortedDir}
|
| 8042 |
isFiltered={menuIsFiltered}
|
|
|
|
| 8623 |
anchor={picker.anchor}
|
| 8624 |
className="cg-pop cg-pick-pop"
|
| 8625 |
placement="bottom-start"
|
| 8626 |
+
/**
|
| 8627 |
+
* β W40-T23 moved `listbox` DOWN onto `.cg-pick-list`, where the options actually
|
| 8628 |
+
* live, and the popover became the dialog that contains it β `FieldSelect`'s
|
| 8629 |
+
* arrangement, and the only one that survives a find box: a text input is not a
|
| 8630 |
+
* legal child of a listbox. It also repairs two things that were already crooked
|
| 8631 |
+
* here: `aria-multiselectable` sat on a plain div where it announced nothing, and a
|
| 8632 |
+
* rating cell's `role="radiogroup"` sat inside a listbox that owned no options.
|
| 8633 |
+
*/
|
| 8634 |
+
role="dialog"
|
| 8635 |
ariaLabel={`Choose ${pickerField.label}`}
|
| 8636 |
onDismiss={closePicker}
|
| 8637 |
dataKind="cell-picker"
|
|
|
|
| 8639 |
// the current choice (fallback: the first), arrows move between choices, Enter picks
|
| 8640 |
// (native button activation), Escape closes, and closePicker hands focus back to the
|
| 8641 |
// grid so the next Enter keeps walking the column.
|
| 8642 |
+
/**
|
| 8643 |
+
* β W40-T23 β a picker OPENED BY TYPING opens focused on its find box, so the second
|
| 8644 |
+
* character lands where the first one went. Every other way in is unchanged.
|
| 8645 |
+
*
|
| 8646 |
+
* β DERIVED FROM `pickerSearchOn`, NEVER FROM THE LIVE QUERY. `AnchoredOverlay`'s
|
| 8647 |
+
* focus effect lists `initialFocus` among its dependencies and its cleanup calls
|
| 8648 |
+
* `previous.focus()` β a selector that changed per keystroke would throw focus back to
|
| 8649 |
+
* the grid and re-grab it on every letter. `pickerSearchOn` is frozen for the life of
|
| 8650 |
+
* the picker, and it is the SAME predicate that renders the box, so the selector can
|
| 8651 |
+
* never name a control that is not there (a choiceless field seeded by a keystroke
|
| 8652 |
+
* would otherwise focus nothing at all).
|
| 8653 |
+
*/
|
| 8654 |
+
initialFocus={pickerSearchOn ? ".cg-pick-search input" : "[data-overlay-autofocus]"}
|
| 8655 |
onKeyDown={(e) => {
|
| 8656 |
+
// β W40-T23 β INSIDE THE FIND BOX, LEFT AND RIGHT BELONG TO THE CARET. This walk
|
| 8657 |
+
// reads them as list movement and preventDefaults them, which over a text input is
|
| 8658 |
+
// a caret the user cannot move. Up and Down still walk out of the box into the
|
| 8659 |
+
// rows, which is how a seeded picker is driven.
|
| 8660 |
+
const inSearch = (e.target as HTMLElement | null)?.tagName === "INPUT";
|
| 8661 |
+
const vertical = e.key === "ArrowDown" || e.key === "ArrowUp";
|
| 8662 |
+
if (inSearch && !vertical) return;
|
| 8663 |
const fwd = e.key === "ArrowDown" || e.key === "ArrowRight";
|
| 8664 |
const back = e.key === "ArrowUp" || e.key === "ArrowLeft";
|
| 8665 |
if (!fwd && !back) return;
|
|
|
|
| 8671 |
if (!items.length) return;
|
| 8672 |
e.preventDefault();
|
| 8673 |
const at = items.indexOf(document.activeElement as HTMLButtonElement);
|
| 8674 |
+
// From OUTSIDE the rows β the find box β Down enters at the TOP and Up at the
|
| 8675 |
+
// BOTTOM, which is `FieldSelect`'s rule. Without the branch, `at === -1` sends Up
|
| 8676 |
+
// to the second-to-last row: a skipped item rather than a wrap.
|
| 8677 |
+
const next =
|
| 8678 |
+
at < 0
|
| 8679 |
+
? fwd
|
| 8680 |
+
? 0
|
| 8681 |
+
: items.length - 1
|
| 8682 |
+
: fwd
|
| 8683 |
+
? (at + 1) % items.length
|
| 8684 |
+
: (at - 1 + items.length) % items.length;
|
| 8685 |
items[next]?.focus();
|
| 8686 |
}}
|
| 8687 |
>
|
|
|
|
| 8724 |
: "This field has no choices yet. Add them from the column menu."}
|
| 8725 |
</div>
|
| 8726 |
)}
|
| 8727 |
+
{/* β W40-T23 β the find box, in the house search shape (`.cg-type-search`, the same
|
| 8728 |
+
markup `FieldSelect` and the type picker wear) rather than a fifth control of its
|
| 8729 |
+
own. DESIGN.md Β§4: one control shape. It is deliberately unexplained β no line
|
| 8730 |
+
telling the reader they may type, because they got here BY typing. */}
|
| 8731 |
+
{pickerSearchOn && (
|
| 8732 |
+
<div className="cg-type-search cg-pick-search">
|
| 8733 |
+
<svg width="13" height="13" viewBox="0 0 16 16" fill="none" aria-hidden>
|
| 8734 |
+
<circle cx="7" cy="7" r="4.4" stroke="currentColor" strokeWidth="1.35" />
|
| 8735 |
+
<path
|
| 8736 |
+
d="m10.4 10.4 3.1 3.1"
|
| 8737 |
+
stroke="currentColor"
|
| 8738 |
+
strokeWidth="1.35"
|
| 8739 |
+
strokeLinecap="round"
|
| 8740 |
+
/>
|
| 8741 |
+
</svg>
|
| 8742 |
+
<input
|
| 8743 |
+
type="text"
|
| 8744 |
+
value={pickQuery}
|
| 8745 |
+
placeholder="Find a choiceβ¦"
|
| 8746 |
+
aria-label="Find a choice"
|
| 8747 |
+
onChange={(event) => setPickQuery(event.target.value)}
|
| 8748 |
+
/>
|
| 8749 |
+
</div>
|
| 8750 |
+
)}
|
| 8751 |
+
<div
|
| 8752 |
+
className="cg-pick-list"
|
| 8753 |
+
role="listbox"
|
| 8754 |
+
aria-label={pickerField.label}
|
| 8755 |
+
aria-multiselectable={pickerMulti || undefined}
|
| 8756 |
+
>
|
| 8757 |
+
{pickerShown.map((choice) => {
|
| 8758 |
const tint = optionTint(pickerField, choice);
|
| 8759 |
const on = pickerMulti
|
| 8760 |
? pickerParts.includes(choice)
|
|
|
|
| 8846 |
);
|
| 8847 |
})}
|
| 8848 |
</div>
|
| 8849 |
+
{/* β W40-T23 β a query nothing answers. ONE line, in the slot the "no choices yet"
|
| 8850 |
+
note already uses, and no advice about what to try instead: an empty result is a
|
| 8851 |
+
fact, not something to apologise for. `pickerSearchOn` already implies the field
|
| 8852 |
+
HAS choices, so this can never stand in for the empty-field note above. */}
|
| 8853 |
+
{pickerSearchOn && pickerShown.length === 0 && (
|
| 8854 |
+
<div className="cg-pop-note">No choice matches.</div>
|
| 8855 |
+
)}
|
| 8856 |
{pickerMulti && (
|
| 8857 |
<div className="cg-form-actions">
|
| 8858 |
<button
|
web/src/customer-grid/RecordDetail.tsx
CHANGED
|
@@ -23,6 +23,12 @@ import {
|
|
| 23 |
formatDisplay,
|
| 24 |
codePreview,
|
| 25 |
jsonPreview,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 26 |
} from "./cells";
|
| 27 |
// The ONE scheme guard, shared with the kanban card since wave 26 (item 11). From `display`
|
| 28 |
// rather than `cells` because `cells` re-exports only the handful the canvas needed.
|
|
@@ -871,7 +877,41 @@ export default function RecordDetail({
|
|
| 871 |
No choices yet. Add them from the column menu.
|
| 872 |
</span>
|
| 873 |
) : (
|
| 874 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 875 |
{entries.map((entry) => {
|
| 876 |
const on = held.includes(entry.value);
|
| 877 |
// T24: the HELD chips wear the option's own colour; an unheld one stays neutral,
|
|
|
|
| 23 |
formatDisplay,
|
| 24 |
codePreview,
|
| 25 |
jsonPreview,
|
| 26 |
+
// β W40-T23 β the SAME two rules the grid's picker runs. The drawer's multiselect is a
|
| 27 |
+
// different control (a chip row, not a popover), so what it shares with the grid is the
|
| 28 |
+
// decision, not the markup: which keystroke counts as typing, and which choices a query
|
| 29 |
+
// keeps. Two copies of either is how the two surfaces answer "v" differently.
|
| 30 |
+
matchChoices,
|
| 31 |
+
pickerTypeSeed,
|
| 32 |
} from "./cells";
|
| 33 |
// The ONE scheme guard, shared with the kanban card since wave 26 (item 11). From `display`
|
| 34 |
// rather than `cells` because `cells` re-exports only the handful the canvas needed.
|
|
|
|
| 877 |
No choices yet. Add them from the column menu.
|
| 878 |
</span>
|
| 879 |
) : (
|
| 880 |
+
/**
|
| 881 |
+
* β W40-T23 (owner instruction 14) β TYPE-AHEAD ON THE CHIP ROW.
|
| 882 |
+
*
|
| 883 |
+
* The instruction is "typing a letter opens and filters the dropdown", and this
|
| 884 |
+
* surface has no dropdown to open: every choice is already on screen, which is why
|
| 885 |
+
* a chip row replaced `<select multiple>` in the first place. So the FELT behaviour
|
| 886 |
+
* the drawer owes is the other half β a letter takes you to the choices that
|
| 887 |
+
* contain it β and here that is MOVING FOCUS to the first match. Single-select in
|
| 888 |
+
* this drawer is a native `<select>` and gets the browser's own type-ahead free;
|
| 889 |
+
* this was the only picked type in the drawer a letter did nothing on.
|
| 890 |
+
*
|
| 891 |
+
* β IT MOVES FOCUS AND NOTHING ELSE. Toggling here would let a bare keystroke
|
| 892 |
+
* write a value, which is exactly what the grid's side of this ticket refuses to
|
| 893 |
+
* do β and it is why `pickerTypeSeed` declines Space: Space is the key that
|
| 894 |
+
* ACTIVATES the chip focus has just landed on.
|
| 895 |
+
*/
|
| 896 |
+
<span
|
| 897 |
+
className="cg-detail-chips"
|
| 898 |
+
onKeyDown={(event) => {
|
| 899 |
+
const seed = pickerTypeSeed(event.key, event);
|
| 900 |
+
if (seed === null) return;
|
| 901 |
+
const labels = entries.map((entry) => entry.label);
|
| 902 |
+
const hit = matchChoices(labels, seed)[0];
|
| 903 |
+
if (hit === undefined) return;
|
| 904 |
+
const chips = Array.from(
|
| 905 |
+
event.currentTarget.querySelectorAll<HTMLButtonElement>(
|
| 906 |
+
"button.cg-detail-chip"
|
| 907 |
+
)
|
| 908 |
+
);
|
| 909 |
+
const target = chips[labels.indexOf(hit)];
|
| 910 |
+
if (!target) return;
|
| 911 |
+
event.preventDefault();
|
| 912 |
+
target.focus();
|
| 913 |
+
}}
|
| 914 |
+
>
|
| 915 |
{entries.map((entry) => {
|
| 916 |
const on = held.includes(entry.value);
|
| 917 |
// T24: the HELD chips wear the option's own colour; an unheld one stays neutral,
|
web/src/customer-grid/ViewSidebar.tsx
CHANGED
|
@@ -23,6 +23,7 @@ import {
|
|
| 23 |
mayEditView,
|
| 24 |
mayToggleViewLock,
|
| 25 |
viewDisplayMode,
|
|
|
|
| 26 |
} from "./types";
|
| 27 |
import {
|
| 28 |
CREATABLE_MODES,
|
|
@@ -30,6 +31,7 @@ import {
|
|
| 30 |
FOLDER_TONE_LABELS,
|
| 31 |
MODE_LABELS,
|
| 32 |
MODE_TONE,
|
|
|
|
| 33 |
} from "./iconShapes";
|
| 34 |
import { FolderMark, LockMark, MenuLabel, ModeIcon, ToneModeIcon } from "./icons";
|
| 35 |
import { ROOT_FOLDER_ID } from "./folders";
|
|
@@ -79,6 +81,131 @@ import {
|
|
| 79 |
produces it β a component-local copy of a contract id is a copy that can drift from the
|
| 80 |
rule, and the rule is the half a gate can run. */
|
| 81 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 82 |
interface ViewSidebarProps {
|
| 83 |
views: SavedView[];
|
| 84 |
activeViewId: string;
|
|
@@ -400,7 +527,9 @@ export default function ViewSidebar({
|
|
| 400 |
});
|
| 401 |
const viewNeedle = viewQuery.trim().toLowerCase();
|
| 402 |
const shownViews = viewNeedle
|
| 403 |
-
|
|
|
|
|
|
|
| 404 |
: views;
|
| 405 |
// ββ WAVE 20 item 19 (C-FOLDER-REORDER) β dragging a FOLDER to reorder the rail ββββββ
|
| 406 |
//
|
|
@@ -500,8 +629,17 @@ export default function ViewSidebar({
|
|
| 500 |
* folder machinery is an opt-in feature of the views rail and "who shared this with me"
|
| 501 |
* is not: a surface with folders switched off must still be able to show you somebody
|
| 502 |
* else's view under a heading that says whose it is.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 503 |
*/
|
| 504 |
-
(v) => v.shared === true,
|
| 505 |
/**
|
| 506 |
* ββ WAVE 34 Β· T25 (ruling R11) β WHICH shared folder this view arrived through.
|
| 507 |
*
|
|
@@ -523,7 +661,23 @@ export default function ViewSidebar({
|
|
| 523 |
// view in it to whichever of them happens to sort first. `owner` is already stamped on
|
| 524 |
// every projected view by `_granted_views`, so this costs nothing on the wire.
|
| 525 |
return name && owner ? { name, owner } : null;
|
| 526 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 527 |
);
|
| 528 |
const folderMenuF = folderMenu ? folders?.find((f) => f.id === folderMenu.id) : undefined;
|
| 529 |
const addPreview = addTarget && folderAddPreview ? folderAddPreview(addTarget) : null;
|
|
@@ -780,8 +934,22 @@ export default function ViewSidebar({
|
|
| 780 |
)}
|
| 781 |
{/* ββ OWNER 2026-08-19 β the chat launcher. AFTER the toggle, same rule as the robot.
|
| 782 |
Rationale is on the `onToggleChat` prop; kept short here because this row's source
|
| 783 |
-
region carries a
|
| 784 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 785 |
<button
|
| 786 |
type="button"
|
| 787 |
className={"cg-chat-toggle" + (chatOpen ? " is-on" : "")}
|
|
@@ -1085,7 +1253,25 @@ export default function ViewSidebar({
|
|
| 1085 |
const gid = group.folder?.id ?? null;
|
| 1086 |
// Item 9 β while a search is live, a folder with no matches is noise, not a target.
|
| 1087 |
if (viewNeedle && group.folder && group.items.length === 0) return null;
|
| 1088 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1089 |
/**
|
| 1090 |
* β WAVE 21 item 9 (R12/C1) β "Shared with me" IS NOT A STORED FOLDER, and every
|
| 1091 |
* folder affordance below has to know it.
|
|
@@ -1105,13 +1291,20 @@ export default function ViewSidebar({
|
|
| 1105 |
const shut = gid != null && collapsed.has(gid);
|
| 1106 |
return (
|
| 1107 |
<div
|
| 1108 |
-
key
|
|
|
|
|
|
|
|
|
|
| 1109 |
className={
|
| 1110 |
-
|
| 1111 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1112 |
// Item 19 β the insertion rule reads "the folder you are dragging lands HERE":
|
| 1113 |
// above this folder, or above the ungrouped section, which is after them all.
|
| 1114 |
-
(foldOver === (gid ?? "__root__") && foldDrag && foldDrag !== gid
|
| 1115 |
? " is-drop-above"
|
| 1116 |
: "") +
|
| 1117 |
// β `foldDrag !== null` FIRST. `gid` is null for the UNGROUPED section and
|
|
@@ -1123,7 +1316,7 @@ export default function ViewSidebar({
|
|
| 1123 |
//
|
| 1124 |
// The `is-drop-above` line above got this right (`&& foldDrag &&`), which is the
|
| 1125 |
// tell: two conditions written minutes apart, one guarded and one not.
|
| 1126 |
-
(foldDrag !== null && foldDrag === gid ? " is-folddrag" : "") +
|
| 1127 |
// ββ WAVE 34 Β· T22 (ruling R4) β THE ROOT SECTION IS A DROP TARGET WITH NO PIXELS.
|
| 1128 |
//
|
| 1129 |
// β THIS IS THE HALF `D-249` DOES NOT NAME, and on its own it reproduces the owner's
|
|
@@ -1146,8 +1339,13 @@ export default function ViewSidebar({
|
|
| 1146 |
(isRoot && viewDrag !== null ? " is-viewdrop" : "")
|
| 1147 |
}
|
| 1148 |
{/* No drop handlers on the synthetic group β see `isSynthetic`. Spreading `{}`
|
| 1149 |
-
rather than branching the element keeps ONE render path for every group.
|
| 1150 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1151 |
>
|
| 1152 |
{group.folder && (
|
| 1153 |
<div
|
|
@@ -1286,6 +1484,10 @@ export default function ViewSidebar({
|
|
| 1286 |
const active = view.id === activeViewId;
|
| 1287 |
const renaming = renamingId === view.id;
|
| 1288 |
const mode = viewDisplayMode(view);
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1289 |
return (
|
| 1290 |
<div
|
| 1291 |
// Item 12 (C-LOCK) β `cg-view-lockset` marks a view locked to a cohort. The
|
|
@@ -1336,10 +1538,17 @@ export default function ViewSidebar({
|
|
| 1336 |
<input
|
| 1337 |
className="cg-view-rename cg-input"
|
| 1338 |
autoFocus
|
| 1339 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1340 |
onBlur={(event) => {
|
| 1341 |
const next = event.target.value.trim();
|
| 1342 |
-
if (next && next !== view
|
| 1343 |
setRenamingId(null);
|
| 1344 |
}}
|
| 1345 |
onKeyDown={(event) => {
|
|
@@ -1356,7 +1565,7 @@ export default function ViewSidebar({
|
|
| 1356 |
// ellipsis at 188px, so the hover is now the only way to read either one in
|
| 1357 |
// full. It used to show the note INSTEAD of the name, which meant a
|
| 1358 |
// described view could not have its own truncated name revealed at all.
|
| 1359 |
-
title={view.note ? `${view
|
| 1360 |
>
|
| 1361 |
{/* I12 β the row wears the view's CURRENT display mode, not a kind dot.
|
| 1362 |
Same geometry the mode switcher and the create flyout use, so "what
|
|
@@ -1378,7 +1587,7 @@ export default function ViewSidebar({
|
|
| 1378 |
than wrap: a rail this narrow turns a wrapped sentence into a
|
| 1379 |
four-line row and the list stops being scannable. */}
|
| 1380 |
<span className="cg-view-text">
|
| 1381 |
-
<span className="cg-view-name">{view
|
| 1382 |
{view.note && (
|
| 1383 |
<span className="cg-view-desc">{view.note}</span>
|
| 1384 |
)}
|
|
@@ -1471,35 +1680,23 @@ export default function ViewSidebar({
|
|
| 1471 |
and the server now projects them. The mark also says WHICH GRANT: a
|
| 1472 |
read-only share and an editable one look identical in the rail
|
| 1473 |
otherwise, and the reader's first question on finding a menu with no
|
| 1474 |
-
Rename in it is why.
|
| 1475 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1476 |
<span
|
| 1477 |
className="cg-view-shared"
|
| 1478 |
role="img"
|
| 1479 |
-
aria-label={
|
| 1480 |
-
|
| 1481 |
-
? `${view.name}, shared with you by ${view.owner}`
|
| 1482 |
-
: `${view.name}, shared with you`
|
| 1483 |
-
}
|
| 1484 |
-
title={
|
| 1485 |
-
(view.owner
|
| 1486 |
-
? `Shared with you by ${view.owner}.`
|
| 1487 |
-
: "Shared with you. Someone gave you access to this view.") +
|
| 1488 |
-
(view.sharedRole === "edit"
|
| 1489 |
-
? " You can edit it."
|
| 1490 |
-
: " You can view it, not change it.")
|
| 1491 |
-
}
|
| 1492 |
>
|
| 1493 |
-
<
|
| 1494 |
-
<circle cx="5.6" cy="5.6" r="2.2" fill="none" stroke="currentColor"
|
| 1495 |
-
strokeWidth="1.3" />
|
| 1496 |
-
<path d="M1.9 12.6c0-2 1.7-3.2 3.7-3.2s3.7 1.2 3.7 3.2"
|
| 1497 |
-
fill="none" stroke="currentColor" strokeWidth="1.3"
|
| 1498 |
-
strokeLinecap="round" />
|
| 1499 |
-
<path d="M10.6 4.1a2.2 2.2 0 0 1 0 4.2M11.4 9.7c1.6.3 2.7 1.4 2.7 2.9"
|
| 1500 |
-
fill="none" stroke="currentColor" strokeWidth="1.3"
|
| 1501 |
-
strokeLinecap="round" />
|
| 1502 |
-
</svg>
|
| 1503 |
</span>
|
| 1504 |
) : null}
|
| 1505 |
{(view.kind === "locked" || isModeFrozen(view)) && (
|
|
@@ -1510,7 +1707,7 @@ export default function ViewSidebar({
|
|
| 1510 |
role="img"
|
| 1511 |
aria-label={
|
| 1512 |
view.kind === "locked"
|
| 1513 |
-
? `${view
|
| 1514 |
: `${MODE_LABELS[mode]} view, locked`
|
| 1515 |
}
|
| 1516 |
title={
|
|
@@ -1533,7 +1730,7 @@ export default function ViewSidebar({
|
|
| 1533 |
<button
|
| 1534 |
type="button"
|
| 1535 |
className="cg-view-more"
|
| 1536 |
-
aria-label={`Actions for ${view
|
| 1537 |
aria-haspopup="menu"
|
| 1538 |
aria-expanded={menu?.viewId === view.id}
|
| 1539 |
onClick={(event) => {
|
|
@@ -1648,7 +1845,16 @@ export default function ViewSidebar({
|
|
| 1648 |
</button>
|
| 1649 |
)}
|
| 1650 |
{/* WAVE 20 item 18 (R10) β a folder shares, and its views ride along
|
| 1651 |
-
(the server's rule, stated in C-SHARE; this row only opens the editor).
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1652 |
<button
|
| 1653 |
type="button"
|
| 1654 |
role="menuitem"
|
|
@@ -1658,7 +1864,7 @@ export default function ViewSidebar({
|
|
| 1658 |
setFolderMenu(null);
|
| 1659 |
}}
|
| 1660 |
>
|
| 1661 |
-
<MenuLabel icon=
|
| 1662 |
</button>
|
| 1663 |
{onFolderDelete && (
|
| 1664 |
<button
|
|
@@ -1824,7 +2030,7 @@ export default function ViewSidebar({
|
|
| 1824 |
className="cg-view-menu"
|
| 1825 |
placement="bottom-end"
|
| 1826 |
role="menu"
|
| 1827 |
-
ariaLabel={`Actions for ${menuView
|
| 1828 |
onDismiss={() => setMenu(null)}
|
| 1829 |
onKeyDown={onMenuKeyDown}
|
| 1830 |
dataKind="saved-view-menu"
|
|
@@ -1958,16 +2164,30 @@ export default function ViewSidebar({
|
|
| 1958 |
`canEditMenuView`: the server decides who may administer (owner or
|
| 1959 |
admin) and says so in the dialog, and hiding the row from everyone else
|
| 1960 |
would hide the ANSWER too β "who has this?" is a fair question for
|
| 1961 |
-
anyone the view was shared with.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1962 |
<button
|
| 1963 |
type="button"
|
| 1964 |
role="menuitem"
|
| 1965 |
onClick={() => {
|
| 1966 |
-
openShare("view", menuView.id, menuView
|
| 1967 |
setMenu(null);
|
| 1968 |
}}
|
| 1969 |
>
|
| 1970 |
-
<MenuLabel icon=
|
| 1971 |
</button>
|
| 1972 |
{/* WAVE 20 item 25 (C-ALERT) β the door that MAKES an alert, on the view it
|
| 1973 |
watches. It belongs here and nowhere else: an alert IS "tell me when a
|
|
@@ -2007,11 +2227,15 @@ export default function ViewSidebar({
|
|
| 2007 |
>
|
| 2008 |
{/* β WAVE 33 Β· T15 (D-206) β A STAR, NOT A PADLOCK.
|
| 2009 |
β This row shipped wearing MenuIcon `permissions` / `unlock` β a padlock that
|
| 2010 |
-
|
| 2011 |
-
|
| 2012 |
-
|
| 2013 |
-
|
| 2014 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2015 |
β Passed as a NODE, exactly the way the alert row below passes `<BellIcon/>`:
|
| 2016 |
`MenuLabel` takes `MenuIconName | ReactNode`, so a glyph no other menu row needs
|
| 2017 |
costs the shared `MENU_ICONS` vocabulary nothing.
|
|
@@ -2030,7 +2254,7 @@ export default function ViewSidebar({
|
|
| 2030 |
onClick={() => {
|
| 2031 |
window.dispatchEvent(
|
| 2032 |
new CustomEvent("aios:alert-create", {
|
| 2033 |
-
detail: { viewId: menuView.id, label: menuView
|
| 2034 |
})
|
| 2035 |
);
|
| 2036 |
setMenu(null);
|
|
@@ -2068,7 +2292,8 @@ export default function ViewSidebar({
|
|
| 2068 |
onClick={() => {
|
| 2069 |
// Item 4: `<view name> Β· <today>`, today from the PAYLOAD verbatim. No date
|
| 2070 |
// when the host sent none β never the browser clock.
|
| 2071 |
-
setNewListName(today ? `${menuView
|
|
|
|
| 2072 |
setAddFor({ viewId: menuView.id, anchor: menu.anchor });
|
| 2073 |
setMenu(null);
|
| 2074 |
}}
|
|
@@ -2092,12 +2317,20 @@ export default function ViewSidebar({
|
|
| 2092 |
would be accepted by the UI, sent, and then silently overwritten by the host on the
|
| 2093 |
next payload. The rail would show no change and nothing would go red β the
|
| 2094 |
present-and-silently-inert affordance this file's own posture forbids. An action
|
| 2095 |
-
the server will not honour must be ABSENT, not merely ineffective.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2096 |
{onCohortLock && lists.length > 0 && canEditMenuView &&
|
| 2097 |
menuView.kind !== "locked" && (
|
| 2098 |
<button
|
| 2099 |
type="button"
|
| 2100 |
role="menuitem"
|
|
|
|
| 2101 |
onClick={() => {
|
| 2102 |
setLockFor({ viewId: menuView.id, anchor: menu.anchor });
|
| 2103 |
setMenu(null);
|
|
@@ -2167,12 +2400,12 @@ export default function ViewSidebar({
|
|
| 2167 |
className="cg-view-menu"
|
| 2168 |
placement="bottom-end"
|
| 2169 |
role="menu"
|
| 2170 |
-
ariaLabel={`Export ${exportView
|
| 2171 |
onDismiss={() => setExportFor(null)}
|
| 2172 |
onKeyDown={onMenuKeyDown}
|
| 2173 |
dataKind="view-export"
|
| 2174 |
>
|
| 2175 |
-
<div className="cg-pop-title cg-export-title">Export {exportView
|
| 2176 |
{EXPORT_FORMATS.map((format) => (
|
| 2177 |
<button
|
| 2178 |
key={format}
|
|
@@ -2199,13 +2432,13 @@ export default function ViewSidebar({
|
|
| 2199 |
className="cg-pop cg-add-list-pop"
|
| 2200 |
placement="bottom-end"
|
| 2201 |
role="dialog"
|
| 2202 |
-
ariaLabel={`Add ${addView
|
| 2203 |
onDismiss={() => setAddFor(null)}
|
| 2204 |
dataKind="add-to-list"
|
| 2205 |
>
|
| 2206 |
<div className="cg-pop-title">Add to cohort</div>
|
| 2207 |
<div className="cg-pop-note">
|
| 2208 |
-
Adds the customers <strong>{addView
|
| 2209 |
stays fixed as the data changes.
|
| 2210 |
</div>
|
| 2211 |
{lists.map((l) => (
|
|
@@ -2262,7 +2495,7 @@ export default function ViewSidebar({
|
|
| 2262 |
className="cg-pop cg-view-note-pop"
|
| 2263 |
placement="bottom-end"
|
| 2264 |
role="dialog"
|
| 2265 |
-
ariaLabel={`Description for ${noteView
|
| 2266 |
onDismiss={() => setNoteFor(null)}
|
| 2267 |
dataKind="saved-view-note"
|
| 2268 |
>
|
|
|
|
| 23 |
mayEditView,
|
| 24 |
mayToggleViewLock,
|
| 25 |
viewDisplayMode,
|
| 26 |
+
viewDisplayName,
|
| 27 |
} from "./types";
|
| 28 |
import {
|
| 29 |
CREATABLE_MODES,
|
|
|
|
| 31 |
FOLDER_TONE_LABELS,
|
| 32 |
MODE_LABELS,
|
| 33 |
MODE_TONE,
|
| 34 |
+
SHARE_SHAPE,
|
| 35 |
} from "./iconShapes";
|
| 36 |
import { FolderMark, LockMark, MenuLabel, ModeIcon, ToneModeIcon } from "./icons";
|
| 37 |
import { ROOT_FOLDER_ID } from "./folders";
|
|
|
|
| 81 |
produces it β a component-local copy of a contract id is a copy that can drift from the
|
| 82 |
rule, and the rule is the half a gate can run. */
|
| 83 |
|
| 84 |
+
/**
|
| 85 |
+
* β W40-T21 β THE SHARE GLYPH, drawn from `SHARE_SHAPE` rather than from a second copy of the
|
| 86 |
+
* same paths.
|
| 87 |
+
*
|
| 88 |
+
* This component used to be three hand-written `<path>`s inline in the row below, and W40-T20
|
| 89 |
+
* lifted that exact geometry into `iconShapes.ts` so the grid header's `aiosShared` canvas sprite
|
| 90 |
+
* could paint it too. Leaving the copy here would mean the product carried TWO drawings of one
|
| 91 |
+
* idea, one of which nothing forces to stay in step β the precise failure `iconShapes.ts`'s own
|
| 92 |
+
* header calls out ("hand-copying every path into a template literal guarantees the header and
|
| 93 |
+
* the panel eventually disagree"). Same viewBox, same 1.35 stroke as `shapeSource` paints the
|
| 94 |
+
* canvas twin at, so a shared VIEW in this rail and a shared FIELD in a header are one mark.
|
| 95 |
+
*
|
| 96 |
+
* β NOT `LockMark`. A share is not one of DESIGN.md Β§4's three locks, and the padlock means a
|
| 97 |
+
* lock (D-254 is the register row for what happens when one glyph carries both ideas).
|
| 98 |
+
*/
|
| 99 |
+
function ShareMark({ size = 13 }: { size?: number }) {
|
| 100 |
+
return (
|
| 101 |
+
<svg width={size} height={size} viewBox="0 0 16 16" aria-hidden>
|
| 102 |
+
{SHARE_SHAPE.map((s) =>
|
| 103 |
+
s.fill ? (
|
| 104 |
+
<path key={s.d} d={s.d} fill="currentColor" />
|
| 105 |
+
) : (
|
| 106 |
+
<path
|
| 107 |
+
key={s.d}
|
| 108 |
+
d={s.d}
|
| 109 |
+
fill="none"
|
| 110 |
+
stroke="currentColor"
|
| 111 |
+
strokeWidth={1.35}
|
| 112 |
+
strokeLinecap="round"
|
| 113 |
+
strokeLinejoin="round"
|
| 114 |
+
/>
|
| 115 |
+
)
|
| 116 |
+
)}
|
| 117 |
+
</svg>
|
| 118 |
+
);
|
| 119 |
+
}
|
| 120 |
+
|
| 121 |
+
/** What the rail's share mark says, once it has been decided that there is one to show. */
|
| 122 |
+
export interface ViewShareMark {
|
| 123 |
+
title: string;
|
| 124 |
+
ariaLabel: string;
|
| 125 |
+
}
|
| 126 |
+
|
| 127 |
+
/**
|
| 128 |
+
* ββ W40-T21 (owner instruction 2, contract C1) β DOES THIS VIEW WEAR THE SHARE MARK, AND WHAT
|
| 129 |
+
* DOES IT SAY?
|
| 130 |
+
*
|
| 131 |
+
* Owner, verbatim: *"A shared View must show the shared/collaborative icon in EVERY account, not
|
| 132 |
+
* only the recipient's. Normalize it regardless of who shares."* So the GLYPH is one glyph in both
|
| 133 |
+
* accounts and the WORDS are what differ, which is why this returns copy rather than a boolean.
|
| 134 |
+
*
|
| 135 |
+
* β THE DISCRIMINATOR IS `owner`, AND IT IS AN EXISTING WIRE FIELD, not a new one.
|
| 136 |
+
* `SavedView.owner` is declared as "whose view this is, WHEN IT IS NOT MINE", and
|
| 137 |
+
* `grid_events.py::_granted_views` is its only producer β it stamps `shared` / `sharedRole` /
|
| 138 |
+
* `owner` together on the RECIPIENT's leg of `table_workspace`'s merge and on nothing else. C1
|
| 139 |
+
* adds the marker to the caller's OWN leg, where there is no `owner` to stamp because the view is
|
| 140 |
+
* the caller's. So:
|
| 141 |
+
*
|
| 142 |
+
* Β· `shared` + `owner` β it reached me by grant. Somebody shared it WITH me.
|
| 143 |
+
* Β· `shared`, no `owner` β it is mine and I have shared it OUT.
|
| 144 |
+
* Β· no `shared` β no mark at all, in either account.
|
| 145 |
+
*
|
| 146 |
+
* β THE RECEIVER'S SENTENCE IS NOT REUSED FOR THE OWNER, and that is the trap this ticket exists
|
| 147 |
+
* to avoid: `cg-view-shared`'s shipped copy reads "Shared with you by {owner}", so pointing it at
|
| 148 |
+
* the owner's own leg ships "Shared with you by Farhan" to Farhan. The owner's string is written
|
| 149 |
+
* fresh and reads as sharing OUT.
|
| 150 |
+
*
|
| 151 |
+
* β NO ROLE SENTENCE ON THE OWNER'S SIDE. `sharedRole` describes a GRANT β what somebody else let
|
| 152 |
+
* me do with their object β and it is absent and meaningless on a view I own (`SavedView`'s own
|
| 153 |
+
* note: "on a view that is MINE this is absent and means nothing at all"). Appending "You can edit
|
| 154 |
+
* it." to my own view would be the product telling me something it does not know.
|
| 155 |
+
*
|
| 156 |
+
* ββ WAVE 40 QA β THIS FUNCTION SHIPPED READING THE WRONG KEY, AND THAT MADE OWNER
|
| 157 |
+
* INSTRUCTION 2 A NO-OP. It was written expecting C1 to REDEFINE `shared` to mean "this view
|
| 158 |
+
* has grants", and its own note here said it was "safe to ship ahead of the server half" because
|
| 159 |
+
* "nothing stamps `shared` without `owner` today". The server half then landed differently:
|
| 160 |
+
* AM-5 keeps `shared` meaning "granted TO me" and introduces `hasShares` / `sharedOut` as new
|
| 161 |
+
* keys. `platform/core/grid_events.py` writes `shared` on exactly two lines, both inside
|
| 162 |
+
* `_granted_views`, both after `if owner == uname: continue`. So the owner branch below stayed
|
| 163 |
+
* unreachable, a whole-tree grep for `hasShares` returned ZERO hits in `src/`, and the person
|
| 164 |
+
* who shared a view saw no mark and no tooltip. Both lanes passed their own ticket.
|
| 165 |
+
*
|
| 166 |
+
* β THREE BRANCHES NOW, AND THE THIRD IS NOT A TIDY-UP. `hasShares` does NOT imply
|
| 167 |
+
* `sharedRole`: a view living both in the legacy `__shared__` bucket and in the grant registry
|
| 168 |
+
* reaches its recipient with `hasShares` alone, because the bucket leg outranks the stamped
|
| 169 |
+
* copy. Lane A wrote that warning down against this very function. Without the neutral branch
|
| 170 |
+
* that reader would be told "You shared this view", which they did not.
|
| 171 |
+
*
|
| 172 |
+
* Pure, exported and total, so the decision can be executed rather than eyeballed: the JSX below
|
| 173 |
+
* consumes it and holds no second copy of the rule.
|
| 174 |
+
*/
|
| 175 |
+
export function viewShareMark(
|
| 176 |
+
view: Pick<
|
| 177 |
+
SavedView,
|
| 178 |
+
"shared" | "owner" | "sharedRole" | "name" | "hasShares" | "sharedOut"
|
| 179 |
+
>
|
| 180 |
+
): ViewShareMark | null {
|
| 181 |
+
// The MARK is `hasShares`, the viewer-independent fact. `shared` is kept in the test so a
|
| 182 |
+
// recipient still gets a mark on any leg that stamps the grant without the marker.
|
| 183 |
+
if (!view.hasShares && !view.shared) return null;
|
| 184 |
+
if (view.shared && view.owner) {
|
| 185 |
+
return {
|
| 186 |
+
title:
|
| 187 |
+
`Shared with you by ${view.owner}.` +
|
| 188 |
+
(view.sharedRole === "edit"
|
| 189 |
+
? " You can edit it."
|
| 190 |
+
: " You can view it, not change it."),
|
| 191 |
+
ariaLabel: `${view.name}, shared with you by ${view.owner}`,
|
| 192 |
+
};
|
| 193 |
+
}
|
| 194 |
+
if (view.sharedOut) {
|
| 195 |
+
return {
|
| 196 |
+
title: "You shared this view. Anyone you gave access to can open it.",
|
| 197 |
+
ariaLabel: `${view.name}, shared by you`,
|
| 198 |
+
};
|
| 199 |
+
}
|
| 200 |
+
// `hasShares` with nothing beside it: this view has grants and this payload does not say
|
| 201 |
+
// whose or on what terms. Say only what is known. Claiming either of the two sentences
|
| 202 |
+
// above would tell somebody something false about their own access.
|
| 203 |
+
return {
|
| 204 |
+
title: "This view is shared.",
|
| 205 |
+
ariaLabel: `${view.name}, shared`,
|
| 206 |
+
};
|
| 207 |
+
}
|
| 208 |
+
|
| 209 |
interface ViewSidebarProps {
|
| 210 |
views: SavedView[];
|
| 211 |
activeViewId: string;
|
|
|
|
| 527 |
});
|
| 528 |
const viewNeedle = viewQuery.trim().toLowerCase();
|
| 529 |
const shownViews = viewNeedle
|
| 530 |
+
// β W40-T28 β searched by what the row SAYS. Filtering on the stored name would leave the
|
| 531 |
+
// default view unfindable by the only name the user has ever seen it under.
|
| 532 |
+
? views.filter((v) => (viewDisplayName(v) || "").toLowerCase().includes(viewNeedle))
|
| 533 |
: views;
|
| 534 |
// ββ WAVE 20 item 19 (C-FOLDER-REORDER) β dragging a FOLDER to reorder the rail ββββββ
|
| 535 |
//
|
|
|
|
| 629 |
* folder machinery is an opt-in feature of the views rail and "who shared this with me"
|
| 630 |
* is not: a surface with folders switched off must still be able to show you somebody
|
| 631 |
* else's view under a heading that says whose it is.
|
| 632 |
+
*
|
| 633 |
+
* ββ W40-T21 (contract C1) β `owner` IS PART OF THE TEST NOW, AND WITHOUT IT THIS GROUP
|
| 634 |
+
* SWALLOWS YOUR OWN VIEWS. C1 widens `shared` from "granted to me" to "this view has
|
| 635 |
+
* grants", which means the caller's own shared-out views arrive carrying it. This group is
|
| 636 |
+
* headed **Shared with me**, so the bare flag would file every view I share OUT under a
|
| 637 |
+
* heading saying somebody shared it with me, and move it out of the folder I put it in.
|
| 638 |
+
* `owner` is stamped only on the recipient's leg (`_granted_views`), so it is exactly the
|
| 639 |
+
* half of `shared` that still means "not mine" β the same reading `viewShareMark` above is
|
| 640 |
+
* built on, so the mark and the grouping cannot disagree about who shared what.
|
| 641 |
*/
|
| 642 |
+
(v) => v.shared === true && !!v.owner,
|
| 643 |
/**
|
| 644 |
* ββ WAVE 34 Β· T25 (ruling R11) β WHICH shared folder this view arrived through.
|
| 645 |
*
|
|
|
|
| 661 |
// view in it to whichever of them happens to sort first. `owner` is already stamped on
|
| 662 |
// every projected view by `_granted_views`, so this costs nothing on the wire.
|
| 663 |
return name && owner ? { name, owner } : null;
|
| 664 |
+
},
|
| 665 |
+
/**
|
| 666 |
+
* ββ WAVE 40 Β· T28 (owner instruction 30) β THE VIEWS THAT PIN ABOVE EVERY FOLDER.
|
| 667 |
+
*
|
| 668 |
+
* Owner: *"when it is not in a folder it must sit at the very top above all folders unless
|
| 669 |
+
* the user moves it down."* `isUndeletableView` is the set, not a fresh id list, because it
|
| 670 |
+
* is already THE answer to "which views are facts about this table rather than the user's
|
| 671 |
+
* own arrangement of it" β the per-database default, Starred, and the IG Overview. A second
|
| 672 |
+
* spelling here would be a second place to update the day a fourth pinned view exists.
|
| 673 |
+
*
|
| 674 |
+
* β THE YIELD IS INSIDE `groupByFolder`, NOT HERE: it lifts only views with NO stored
|
| 675 |
+
* placement, so filing one into a folder β or dropping it onto the ungrouped section below,
|
| 676 |
+
* which stores W32-T27's root sentinel β takes it back out of the pin. Passing the predicate
|
| 677 |
+
* unconditionally (not gated on `foldersOn`) matches the shared predicate above: the pin is
|
| 678 |
+
* about the rail's reading order, not about the folder feature being switched on.
|
| 679 |
+
*/
|
| 680 |
+
(v) => isUndeletableView(v)
|
| 681 |
);
|
| 682 |
const folderMenuF = folderMenu ? folders?.find((f) => f.id === folderMenu.id) : undefined;
|
| 683 |
const addPreview = addTarget && folderAddPreview ? folderAddPreview(addTarget) : null;
|
|
|
|
| 934 |
)}
|
| 935 |
{/* ββ OWNER 2026-08-19 β the chat launcher. AFTER the toggle, same rule as the robot.
|
| 936 |
Rationale is on the `onToggleChat` prop; kept short here because this row's source
|
| 937 |
+
region carries a 3,000-char cap that `verify_grid_ux.py`'s views-rail scan enforces.
|
| 938 |
+
ββ W40-T22 (owner instruction 5, 2026-08-23) β `!railShut` IS THE THIRD CLAUSE OF THAT
|
| 939 |
+
INSTRUCTION, NOT A TIDY-UP: *"when the Database navigation is minimized it must
|
| 940 |
+
disappear from the secondary navigation too."* This is now the app's ONLY chat launcher
|
| 941 |
+
(the shell rail's `.shell-rail-chat` twin was deleted in the same ticket), so folding
|
| 942 |
+
this rail closes the last door onto `<GridChat>` until it is unfolded β which is what
|
| 943 |
+
the owner asked for, and the reason the minimize toggle beside it stays unguarded.
|
| 944 |
+
β A RENDER GUARD, NOT A CSS HIDE, for two reasons that agree. `index.css`'s
|
| 945 |
+
`.cg-views.is-collapsed > :not(.cg-views-top)` deliberately SPARES this row's children,
|
| 946 |
+
so a CSS answer would mean carving an exception into a rule written to protect them;
|
| 947 |
+
and `verify_wiring.py`'s W37 C6 row is a TEXT-PRESENCE check on the `className` literal
|
| 948 |
+
two lines below, which a CSS hide sails straight past. Guarding here keeps that literal
|
| 949 |
+
in the file and still removes the control. β The `className` expression three lines
|
| 950 |
+
below is PINNED CHARACTER FOR CHARACTER by that row, opening brace and quote included;
|
| 951 |
+
rename or reformat it and `web_wiring` reds. */}
|
| 952 |
+
{onToggleChat && !railShut && (
|
| 953 |
<button
|
| 954 |
type="button"
|
| 955 |
className={"cg-chat-toggle" + (chatOpen ? " is-on" : "")}
|
|
|
|
| 1253 |
const gid = group.folder?.id ?? null;
|
| 1254 |
// Item 9 β while a search is live, a folder with no matches is noise, not a target.
|
| 1255 |
if (viewNeedle && group.folder && group.items.length === 0) return null;
|
| 1256 |
+
/**
|
| 1257 |
+
* ββ WAVE 40 Β· T28 (owner instruction 30) β THE PIN GROUP: the unfiled default views,
|
| 1258 |
+
* rendered above every folder.
|
| 1259 |
+
*
|
| 1260 |
+
* β IT IS A SECOND `folder: null` GROUP, so every expression below that reads
|
| 1261 |
+
* `gid ?? "__root__"` now has TWO groups answering to it and each one has to be told
|
| 1262 |
+
* which it is. That is not cosmetic: `dropTarget`, `foldOver` and `viewDrag` all
|
| 1263 |
+
* compare against that same fallback string, so leaving them alone would paint the
|
| 1264 |
+
* drop fill and the folder insertion rule on THIS section every time the user hovered
|
| 1265 |
+
* the real ungrouped section below it β one hover, two highlights, and only one of them
|
| 1266 |
+
* is where the item would land.
|
| 1267 |
+
*
|
| 1268 |
+
* β SO `isRoot` EXCLUDES IT, and that is the load-bearing line. `isRoot` is what grants
|
| 1269 |
+
* the drag-time drop AREA (`is-viewdrop`), and there must be exactly ONE of those: it is
|
| 1270 |
+
* the surface a user drops the default view onto to move it down, and a second one that
|
| 1271 |
+
* files it right back where it started would make the gesture unreachable.
|
| 1272 |
+
*/
|
| 1273 |
+
const isPinnedGroup = group.pinned === true;
|
| 1274 |
+
const isRoot = gid === null && !isPinnedGroup;
|
| 1275 |
/**
|
| 1276 |
* β WAVE 21 item 9 (R12/C1) β "Shared with me" IS NOT A STORED FOLDER, and every
|
| 1277 |
* folder affordance below has to know it.
|
|
|
|
| 1291 |
const shut = gid != null && collapsed.has(gid);
|
| 1292 |
return (
|
| 1293 |
<div
|
| 1294 |
+
/* β W40-T28 β a key of its own. Both this group and the ungrouped section have a null
|
| 1295 |
+
folder, so the old `gid ?? "__root__"` would give React two children with the same
|
| 1296 |
+
key and it would reconcile one over the other. */
|
| 1297 |
+
key={isPinnedGroup ? "__pinned__" : gid ?? "__root__"}
|
| 1298 |
className={
|
| 1299 |
+
/* β W40-T28 β `gid === null`, not `isRoot`: the pin group wears the SAME class as
|
| 1300 |
+
the ungrouped section (no head, the rail's measured root indent) because it is the
|
| 1301 |
+
same shape of thing rendered in a different place. DESIGN.md Β§4 β this is an
|
| 1302 |
+
existing element joining the existing rhythm, not a new control shape. */
|
| 1303 |
+
(gid === null ? "cg-fold-root" : "cg-fold") +
|
| 1304 |
+
(!isPinnedGroup && dropTarget === (gid ?? "__root__") ? " is-drop" : "") +
|
| 1305 |
// Item 19 β the insertion rule reads "the folder you are dragging lands HERE":
|
| 1306 |
// above this folder, or above the ungrouped section, which is after them all.
|
| 1307 |
+
(!isPinnedGroup && foldOver === (gid ?? "__root__") && foldDrag && foldDrag !== gid
|
| 1308 |
? " is-drop-above"
|
| 1309 |
: "") +
|
| 1310 |
// β `foldDrag !== null` FIRST. `gid` is null for the UNGROUPED section and
|
|
|
|
| 1316 |
//
|
| 1317 |
// The `is-drop-above` line above got this right (`&& foldDrag &&`), which is the
|
| 1318 |
// tell: two conditions written minutes apart, one guarded and one not.
|
| 1319 |
+
(!isPinnedGroup && foldDrag !== null && foldDrag === gid ? " is-folddrag" : "") +
|
| 1320 |
// ββ WAVE 34 Β· T22 (ruling R4) β THE ROOT SECTION IS A DROP TARGET WITH NO PIXELS.
|
| 1321 |
//
|
| 1322 |
// β THIS IS THE HALF `D-249` DOES NOT NAME, and on its own it reproduces the owner's
|
|
|
|
| 1339 |
(isRoot && viewDrag !== null ? " is-viewdrop" : "")
|
| 1340 |
}
|
| 1341 |
{/* No drop handlers on the synthetic group β see `isSynthetic`. Spreading `{}`
|
| 1342 |
+
rather than branching the element keeps ONE render path for every group.
|
| 1343 |
+
β W40-T28 β nor on the pin group, for a different reason: it is a READING of the
|
| 1344 |
+
view list ("these have no placement"), so a drop on it would emit
|
| 1345 |
+
`item_move(id, ROOT_FOLDER_ID)` β a stored placement, which is the very thing that
|
| 1346 |
+
takes a view OUT of this group. The drop would file the view and then move it
|
| 1347 |
+
somewhere else on screen. The ungrouped section below is the one root target. */
|
| 1348 |
+
...(isSynthetic || isPinnedGroup ? {} : dropHandlers(gid))}
|
| 1349 |
>
|
| 1350 |
{group.folder && (
|
| 1351 |
<div
|
|
|
|
| 1484 |
const active = view.id === activeViewId;
|
| 1485 |
const renaming = renamingId === view.id;
|
| 1486 |
const mode = viewDisplayMode(view);
|
| 1487 |
+
// W40-T21 β resolved ONCE, here rather than inside the row's JSX. The badge slice below
|
| 1488 |
+
// is a bounded scan subject in `verify_grid_ux.py`, and a rule inlined there would grow
|
| 1489 |
+
// it for no benefit; the decision itself lives in `viewShareMark`.
|
| 1490 |
+
const shareMark = viewShareMark(view);
|
| 1491 |
return (
|
| 1492 |
<div
|
| 1493 |
// Item 12 (C-LOCK) β `cg-view-lockset` marks a view locked to a cohort. The
|
|
|
|
| 1538 |
<input
|
| 1539 |
className="cg-view-rename cg-input"
|
| 1540 |
autoFocus
|
| 1541 |
+
/* ββ W40-T28 β THE BOX OPENS ON WHAT THE ROW SAYS, AND THE NO-OP TEST READS
|
| 1542 |
+
THE SAME STRING. Seeding this from `view.name` while the row reads "Default
|
| 1543 |
+
view" would show the user a name they have never seen; worse, the guard
|
| 1544 |
+
below would then compare their untouched "Default view" against the stored
|
| 1545 |
+
"All customers", call it a change, and PERSIST it β after which the name is
|
| 1546 |
+
no longer the host's mint and `viewDisplayName` stops resolving it. Opening
|
| 1547 |
+
rename and pressing Enter would permanently defeat the display rule. */
|
| 1548 |
+
defaultValue={viewDisplayName(view)}
|
| 1549 |
onBlur={(event) => {
|
| 1550 |
const next = event.target.value.trim();
|
| 1551 |
+
if (next && next !== viewDisplayName(view)) onRename(view.id, next);
|
| 1552 |
setRenamingId(null);
|
| 1553 |
}}
|
| 1554 |
onKeyDown={(event) => {
|
|
|
|
| 1565 |
// ellipsis at 188px, so the hover is now the only way to read either one in
|
| 1566 |
// full. It used to show the note INSTEAD of the name, which meant a
|
| 1567 |
// described view could not have its own truncated name revealed at all.
|
| 1568 |
+
title={view.note ? `${viewDisplayName(view)}: ${view.note}` : viewDisplayName(view)}
|
| 1569 |
>
|
| 1570 |
{/* I12 β the row wears the view's CURRENT display mode, not a kind dot.
|
| 1571 |
Same geometry the mode switcher and the create flyout use, so "what
|
|
|
|
| 1587 |
than wrap: a rail this narrow turns a wrapped sentence into a
|
| 1588 |
four-line row and the list stops being scannable. */}
|
| 1589 |
<span className="cg-view-text">
|
| 1590 |
+
<span className="cg-view-name">{viewDisplayName(view)}</span>
|
| 1591 |
{view.note && (
|
| 1592 |
<span className="cg-view-desc">{view.note}</span>
|
| 1593 |
)}
|
|
|
|
| 1680 |
and the server now projects them. The mark also says WHICH GRANT: a
|
| 1681 |
read-only share and an editable one look identical in the rail
|
| 1682 |
otherwise, and the reader's first question on finding a menu with no
|
| 1683 |
+
Rename in it is why.
|
| 1684 |
+
ββ W40-T21 (owner instruction 2 / C1) β AND IT IS THE SAME MARK IN BOTH
|
| 1685 |
+
ACCOUNTS NOW. Owner: *"A shared View must show the shared/collaborative icon
|
| 1686 |
+
in EVERY account, not only the recipient's."* One glyph, two sentences: the
|
| 1687 |
+
recipient's still names who shared it, the owner's reads as sharing OUT.
|
| 1688 |
+
Which one, and whether there is a mark at all, is `viewShareMark` β a pure
|
| 1689 |
+
exported function, so the rule can be executed rather than read off JSX.
|
| 1690 |
+
The geometry is `SHARE_SHAPE`, the ONE share drawing the grid header's
|
| 1691 |
+
canvas sprite paints too; this row used to hold a second copy of it. */}
|
| 1692 |
+
{shareMark ? (
|
| 1693 |
<span
|
| 1694 |
className="cg-view-shared"
|
| 1695 |
role="img"
|
| 1696 |
+
aria-label={shareMark.ariaLabel}
|
| 1697 |
+
title={shareMark.title}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1698 |
>
|
| 1699 |
+
<ShareMark />
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1700 |
</span>
|
| 1701 |
) : null}
|
| 1702 |
{(view.kind === "locked" || isModeFrozen(view)) && (
|
|
|
|
| 1707 |
role="img"
|
| 1708 |
aria-label={
|
| 1709 |
view.kind === "locked"
|
| 1710 |
+
? `${viewDisplayName(view)}, a locked view`
|
| 1711 |
: `${MODE_LABELS[mode]} view, locked`
|
| 1712 |
}
|
| 1713 |
title={
|
|
|
|
| 1730 |
<button
|
| 1731 |
type="button"
|
| 1732 |
className="cg-view-more"
|
| 1733 |
+
aria-label={`Actions for ${viewDisplayName(view)}`}
|
| 1734 |
aria-haspopup="menu"
|
| 1735 |
aria-expanded={menu?.viewId === view.id}
|
| 1736 |
onClick={(event) => {
|
|
|
|
| 1845 |
</button>
|
| 1846 |
)}
|
| 1847 |
{/* WAVE 20 item 18 (R10) β a folder shares, and its views ride along
|
| 1848 |
+
(the server's rule, stated in C-SHARE; this row only opens the editor).
|
| 1849 |
+
β W40-T21 (D-254) β THE PADLOCK IS GONE FROM THIS ROW. Sharing is not one of
|
| 1850 |
+
DESIGN.md Β§4's three locks, and Β§4 is explicit that "a surface painting one lock
|
| 1851 |
+
where another applies tells the user something false" β so the mark was false, not
|
| 1852 |
+
merely ambiguous. A `title` reading "this is access, not a lock" would have existed
|
| 1853 |
+
only to correct its own icon, which Β§4's "never over-explain" forbids: fix the mark
|
| 1854 |
+
and the sentence is unnecessary. Now it wears `SHARE_SHAPE`, the same drawing as the
|
| 1855 |
+
rail's share mark and the grid header's `aiosShared` sprite. Passed as a NODE, the
|
| 1856 |
+
way the Star and alert rows pass theirs, so a glyph no other menu row needs costs
|
| 1857 |
+
the shared `MENU_ICONS` vocabulary nothing. */}
|
| 1858 |
<button
|
| 1859 |
type="button"
|
| 1860 |
role="menuitem"
|
|
|
|
| 1864 |
setFolderMenu(null);
|
| 1865 |
}}
|
| 1866 |
>
|
| 1867 |
+
<MenuLabel icon={<ShareMark size={16} />} text="Share folder" />
|
| 1868 |
</button>
|
| 1869 |
{onFolderDelete && (
|
| 1870 |
<button
|
|
|
|
| 2030 |
className="cg-view-menu"
|
| 2031 |
placement="bottom-end"
|
| 2032 |
role="menu"
|
| 2033 |
+
ariaLabel={`Actions for ${viewDisplayName(menuView)}`}
|
| 2034 |
onDismiss={() => setMenu(null)}
|
| 2035 |
onKeyDown={onMenuKeyDown}
|
| 2036 |
dataKind="saved-view-menu"
|
|
|
|
| 2164 |
`canEditMenuView`: the server decides who may administer (owner or
|
| 2165 |
admin) and says so in the dialog, and hiding the row from everyone else
|
| 2166 |
would hide the ANSWER too β "who has this?" is a fair question for
|
| 2167 |
+
anyone the view was shared with.
|
| 2168 |
+
β W40-T21 (D-254) β THE PADLOCK IS GONE FROM THIS ROW TOO, for the reason spelled
|
| 2169 |
+
out on the Share folder row: sharing is none of DESIGN.md Β§4's three locks, so the
|
| 2170 |
+
padlock was a false mark rather than an ambiguous one, and correcting it in a
|
| 2171 |
+
`title` would have been Β§4's "never over-explain" instead of a fix.
|
| 2172 |
+
β `verify_wiring.py` (W39-T29) used to IDENTIFY this row by the whole `MenuLabel`
|
| 2173 |
+
literal, `icon=` included, while checking that this row is offered outside the
|
| 2174 |
+
edit-only predicate. That pinned the GLYPH as part of a row identity rather than as
|
| 2175 |
+
the claim; it is retargeted at the row's label alone in the same change
|
| 2176 |
+
[[a-gate-that-pins-a-spelling-not-a-claim]]. The label below must therefore keep its
|
| 2177 |
+
exact spelling, which `verify_icons`'s T23 leg pins as well.
|
| 2178 |
+
β AND IT IS NOT SPELLED OUT IN THIS COMMENT ON PURPOSE. Both gates read the row
|
| 2179 |
+
through `code_only`, which strips comments precisely so prose cannot answer a
|
| 2180 |
+
question asked about code; a note repeating the row's own identity verbatim is the
|
| 2181 |
+
string that would satisfy the scan if that stripping were ever weakened. */}
|
| 2182 |
<button
|
| 2183 |
type="button"
|
| 2184 |
role="menuitem"
|
| 2185 |
onClick={() => {
|
| 2186 |
+
openShare("view", menuView.id, viewDisplayName(menuView));
|
| 2187 |
setMenu(null);
|
| 2188 |
}}
|
| 2189 |
>
|
| 2190 |
+
<MenuLabel icon={<ShareMark size={16} />} text="Share view" />
|
| 2191 |
</button>
|
| 2192 |
{/* WAVE 20 item 25 (C-ALERT) β the door that MAKES an alert, on the view it
|
| 2193 |
watches. It belongs here and nowhere else: an alert IS "tell me when a
|
|
|
|
| 2227 |
>
|
| 2228 |
{/* β WAVE 33 Β· T15 (D-206) β A STAR, NOT A PADLOCK.
|
| 2229 |
β This row shipped wearing MenuIcon `permissions` / `unlock` β a padlock that
|
| 2230 |
+
three other rows in these same menus ALSO wore, untitled. Marking a view
|
| 2231 |
+
important is none of the three locks (DESIGN.md Β§4): it freezes no record, no
|
| 2232 |
+
column and no row set. So the answer is to drop the lock, not to title it β a
|
| 2233 |
+
title naming a lock that does not exist would be believed.
|
| 2234 |
+
β W40-T21 (D-254) finished the job this row started: the two SHARE rows took
|
| 2235 |
+
the same treatment (sharing is not a lock either, so they wear the share glyph
|
| 2236 |
+
now), and "Lock to a locked view" β the one row of the four that really is a
|
| 2237 |
+
lock β keeps the padlock and names WHICH lock in its title. So the count in the
|
| 2238 |
+
sentence above is history, not a description of these menus today.
|
| 2239 |
β Passed as a NODE, exactly the way the alert row below passes `<BellIcon/>`:
|
| 2240 |
`MenuLabel` takes `MenuIconName | ReactNode`, so a glyph no other menu row needs
|
| 2241 |
costs the shared `MENU_ICONS` vocabulary nothing.
|
|
|
|
| 2254 |
onClick={() => {
|
| 2255 |
window.dispatchEvent(
|
| 2256 |
new CustomEvent("aios:alert-create", {
|
| 2257 |
+
detail: { viewId: menuView.id, label: viewDisplayName(menuView) },
|
| 2258 |
})
|
| 2259 |
);
|
| 2260 |
setMenu(null);
|
|
|
|
| 2292 |
onClick={() => {
|
| 2293 |
// Item 4: `<view name> Β· <today>`, today from the PAYLOAD verbatim. No date
|
| 2294 |
// when the host sent none β never the browser clock.
|
| 2295 |
+
setNewListName(today ? `${viewDisplayName(menuView)} Β· ${today}`
|
| 2296 |
+
: viewDisplayName(menuView));
|
| 2297 |
setAddFor({ viewId: menuView.id, anchor: menu.anchor });
|
| 2298 |
setMenu(null);
|
| 2299 |
}}
|
|
|
|
| 2317 |
would be accepted by the UI, sent, and then silently overwritten by the host on the
|
| 2318 |
next payload. The rail would show no change and nothing would go red β the
|
| 2319 |
present-and-silently-inert affordance this file's own posture forbids. An action
|
| 2320 |
+
the server will not honour must be ABSENT, not merely ineffective.
|
| 2321 |
+
|
| 2322 |
+
β W40-T21 (D-254) β THE ONE ROW OF THE THREE THAT REALLY IS A LOCK, so it KEEPS the
|
| 2323 |
+
padlock and gains the title Β§4 asks of anything wearing the shared mark: it names
|
| 2324 |
+
WHICH of the three locks it means. The locked-view kind, the row set, and not the
|
| 2325 |
+
other two β a locked database forbids adding, deleting and editing RECORDS, a
|
| 2326 |
+
pre-set field freezes one COLUMN, and painting either meaning here would tell the
|
| 2327 |
+
user something false. */}
|
| 2328 |
{onCohortLock && lists.length > 0 && canEditMenuView &&
|
| 2329 |
menuView.kind !== "locked" && (
|
| 2330 |
<button
|
| 2331 |
type="button"
|
| 2332 |
role="menuitem"
|
| 2333 |
+
title="Locked view: the records in it become a fixed set. Fields and other views are untouched."
|
| 2334 |
onClick={() => {
|
| 2335 |
setLockFor({ viewId: menuView.id, anchor: menu.anchor });
|
| 2336 |
setMenu(null);
|
|
|
|
| 2400 |
className="cg-view-menu"
|
| 2401 |
placement="bottom-end"
|
| 2402 |
role="menu"
|
| 2403 |
+
ariaLabel={`Export ${viewDisplayName(exportView)}`}
|
| 2404 |
onDismiss={() => setExportFor(null)}
|
| 2405 |
onKeyDown={onMenuKeyDown}
|
| 2406 |
dataKind="view-export"
|
| 2407 |
>
|
| 2408 |
+
<div className="cg-pop-title cg-export-title">Export {viewDisplayName(exportView)}</div>
|
| 2409 |
{EXPORT_FORMATS.map((format) => (
|
| 2410 |
<button
|
| 2411 |
key={format}
|
|
|
|
| 2432 |
className="cg-pop cg-add-list-pop"
|
| 2433 |
placement="bottom-end"
|
| 2434 |
role="dialog"
|
| 2435 |
+
ariaLabel={`Add ${viewDisplayName(addView)} to a locked view`}
|
| 2436 |
onDismiss={() => setAddFor(null)}
|
| 2437 |
dataKind="add-to-list"
|
| 2438 |
>
|
| 2439 |
<div className="cg-pop-title">Add to cohort</div>
|
| 2440 |
<div className="cg-pop-note">
|
| 2441 |
+
Adds the customers <strong>{viewDisplayName(addView)}</strong> matches right now. The cohort
|
| 2442 |
stays fixed as the data changes.
|
| 2443 |
</div>
|
| 2444 |
{lists.map((l) => (
|
|
|
|
| 2495 |
className="cg-pop cg-view-note-pop"
|
| 2496 |
placement="bottom-end"
|
| 2497 |
role="dialog"
|
| 2498 |
+
ariaLabel={`Description for ${viewDisplayName(noteView)}`}
|
| 2499 |
onDismiss={() => setNoteFor(null)}
|
| 2500 |
dataKind="saved-view-note"
|
| 2501 |
>
|
web/src/customer-grid/cells.ts
CHANGED
|
@@ -71,6 +71,14 @@ export type { AutomationState } from "./display";
|
|
| 71 |
// (`verify_grid_ux` drives them under node); only the canvas cell below needs this module.
|
| 72 |
export { codePreview, jsonParse, jsonPretty, jsonPreview, MAX_JSON_BYTES } from "./display";
|
| 73 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 74 |
/**
|
| 75 |
* Wave-18 C5-AUTOFIELD β the cell tint per automation state.
|
| 76 |
*
|
|
|
|
| 71 |
// (`verify_grid_ux` drives them under node); only the canvas cell below needs this module.
|
| 72 |
export { codePreview, jsonParse, jsonPretty, jsonPreview, MAX_JSON_BYTES } from "./display";
|
| 73 |
|
| 74 |
+
// β W40-T23 (owner instruction 14) β "typing a letter opens the picker" rests on two pure
|
| 75 |
+
// decisions: which keystroke counts as typing, and which choices a query keeps. Same arrangement
|
| 76 |
+
// as every block above β they live in display.ts so a node gate can EXECUTE them (this file
|
| 77 |
+
// imports `GridCellKind` as a value, so nothing in it is node-reachable), and are re-exported
|
| 78 |
+
// here so callers keep importing "the cell module". Their second consumer is the record
|
| 79 |
+
// drawer's chip row, which is a different control answering the same instruction.
|
| 80 |
+
export { matchChoices, pickerTypeSeed } from "./display";
|
| 81 |
+
|
| 82 |
/**
|
| 83 |
* Wave-18 C5-AUTOFIELD β the cell tint per automation state.
|
| 84 |
*
|
web/src/customer-grid/display.ts
CHANGED
|
@@ -6,10 +6,20 @@
|
|
| 6 |
// script. Everything here depends only on types.ts. cells.ts re-exports these
|
| 7 |
// names, so every existing import keeps working; the formatting is the same
|
| 8 |
// bytes it was β this is a move, not a change.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 9 |
// ---------------------------------------------------------------------------
|
| 10 |
|
| 11 |
import type { Field, FieldFormat } from "./types";
|
| 12 |
-
import { ratingMax } from "./types";
|
| 13 |
|
| 14 |
export type CellValue = string | number | null | undefined;
|
| 15 |
|
|
@@ -775,3 +785,166 @@ export function formatDisplay(field: Field, v: CellValue): string {
|
|
| 775 |
return String(v ?? "");
|
| 776 |
}
|
| 777 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 6 |
// script. Everything here depends only on types.ts. cells.ts re-exports these
|
| 7 |
// names, so every existing import keeps working; the formatting is the same
|
| 8 |
// bytes it was β this is a move, not a change.
|
| 9 |
+
//
|
| 10 |
+
// β W40-T24 β `columnDefinitionOffer` at the foot of this file is NOT a display
|
| 11 |
+
// string, and it is here on purpose rather than by drift. It is a decision the
|
| 12 |
+
// Edit-field pane takes, and the pane lives in `ColumnMenu.tsx`, which imports
|
| 13 |
+
// React and therefore cannot be LOADED by the node gates β a rule stated only
|
| 14 |
+
// inside JSX is a rule no gate can run. Its natural home is `types.ts` beside
|
| 15 |
+
// the two predicates it composes; that file belongs to another lane this wave,
|
| 16 |
+
// so it lives in the nearest module that is both node-reachable and already
|
| 17 |
+
// imported by `_test/gridUx.test.ts`. If types.ts is ever free, move it there
|
| 18 |
+
// and leave a re-export: what must not happen is a second copy.
|
| 19 |
// ---------------------------------------------------------------------------
|
| 20 |
|
| 21 |
import type { Field, FieldFormat } from "./types";
|
| 22 |
+
import { isUserSchemaField, ratingMax } from "./types";
|
| 23 |
|
| 24 |
export type CellValue = string | number | null | undefined;
|
| 25 |
|
|
|
|
| 785 |
return String(v ?? "");
|
| 786 |
}
|
| 787 |
}
|
| 788 |
+
|
| 789 |
+
// --- W40-T23: the two rules behind "typing a letter opens the picker" ---------
|
| 790 |
+
// MOVED here from cells.ts, for this module's founding reason and no other: cells.ts imports
|
| 791 |
+
// `GridCellKind` as a VALUE, so nothing in it can be reached by a node gate, and these two are
|
| 792 |
+
// exactly the kind of decision that can be wrong in ways a screenshot will never show β which
|
| 793 |
+
// keystroke counts as typing, and which choices a query keeps. cells.ts re-exports both, so
|
| 794 |
+
// every existing import keeps working; the bodies are the same bytes they were β this is a
|
| 795 |
+
// move, not a change.
|
| 796 |
+
//
|
| 797 |
+
// Their consumers are two DIFFERENT controls β the grid's anchored picker and the record
|
| 798 |
+
// drawer's chip row β which is the whole reason they are functions rather than expressions
|
| 799 |
+
// inside one handler. One rule, two surfaces, no second copy to drift.
|
| 800 |
+
|
| 801 |
+
/**
|
| 802 |
+
* The character a keystroke should SEED a choice picker with, or `null` when the keystroke is
|
| 803 |
+
* not somebody typing.
|
| 804 |
+
*
|
| 805 |
+
* β THE `null` CASES ARE THE CONTRACT, not the leftovers. `Ctrl+C` must still copy, `Enter`
|
| 806 |
+
* must still walk the column, `ContextMenu` must still open the header menu β each of those is
|
| 807 |
+
* a live branch of `onGridKeyDown` that this predicate has to decline before it runs.
|
| 808 |
+
*
|
| 809 |
+
* Β· one code point only, so every named key (`Enter`, `ArrowDown`, `Tab`, `F2`, `ContextMenu`)
|
| 810 |
+
* is rejected by LENGTH rather than by a list somebody has to keep complete;
|
| 811 |
+
* Β· no Ctrl / Meta / Alt, which is what keeps `Ctrl+C` a copy and `Alt+F` a menu;
|
| 812 |
+
* Β· SHIFT IS DELIBERATELY NOT TESTED β `Shift+V` is a capital V, and a guard copied from the
|
| 813 |
+
* Enter branch (where Shift means "go up") would ship a feature that works on `v` and not on
|
| 814 |
+
* `V`;
|
| 815 |
+
* Β· a SPACE is refused. It reads as "no filter" anyway once trimmed, and in the record drawer
|
| 816 |
+
* Space is the key that ACTIVATES the focused chip β a bare keystroke must never write a
|
| 817 |
+
* value.
|
| 818 |
+
*/
|
| 819 |
+
export function pickerTypeSeed(
|
| 820 |
+
key: string,
|
| 821 |
+
mods: { ctrlKey?: boolean; metaKey?: boolean; altKey?: boolean }
|
| 822 |
+
): string | null {
|
| 823 |
+
if (mods.ctrlKey || mods.metaKey || mods.altKey) return null;
|
| 824 |
+
// `[...key]` counts CODE POINTS, not UTF-16 units: an astral character arrives as a
|
| 825 |
+
// length-2 string and is one keystroke, so `key.length === 1` would silently refuse it.
|
| 826 |
+
const chars = [...key];
|
| 827 |
+
if (chars.length !== 1) return null;
|
| 828 |
+
if (key === " ") return null;
|
| 829 |
+
return key;
|
| 830 |
+
}
|
| 831 |
+
|
| 832 |
+
/**
|
| 833 |
+
* Which choices survive a query. The house rule, verbatim from `FieldSelect.tsx`: trimmed,
|
| 834 |
+
* case-insensitive, SUBSTRING (not prefix) β so "v" finds "Delivered" as well as "Void", which
|
| 835 |
+
* is what a person means by "filter to options containing v".
|
| 836 |
+
*
|
| 837 |
+
* An empty (or all-whitespace) query returns the list unchanged, so the seeded and unseeded
|
| 838 |
+
* pickers are the same component in the same state rather than two code paths.
|
| 839 |
+
*
|
| 840 |
+
* β Returns a COPY, never the input array: the grid maps over the result every render, and a
|
| 841 |
+
* caller that sorted or spliced an alias of the field's own choice list would be editing the
|
| 842 |
+
* column definition through a filter.
|
| 843 |
+
*/
|
| 844 |
+
export function matchChoices(
|
| 845 |
+
choices: readonly string[],
|
| 846 |
+
query: string
|
| 847 |
+
): string[] {
|
| 848 |
+
const needle = query.trim().toLowerCase();
|
| 849 |
+
if (!needle) return [...choices];
|
| 850 |
+
return choices.filter((choice) => choice.toLowerCase().includes(needle));
|
| 851 |
+
}
|
| 852 |
+
|
| 853 |
+
// ---------------------------------------------------------------------------
|
| 854 |
+
// ββ W40-T24 β THE PRE-SET COLUMN'S DEFINITION LOCK, STATED ONCE
|
| 855 |
+
// ---------------------------------------------------------------------------
|
| 856 |
+
|
| 857 |
+
/** The four definition verbs the Edit-field pane and the column menu can offer. */
|
| 858 |
+
export interface ColumnDefinitionOffer {
|
| 859 |
+
/** "Change field" β point this column slot at a different field, or at a new one. */
|
| 860 |
+
swap: boolean;
|
| 861 |
+
/** The editable Name box in the Edit-field pane. */
|
| 862 |
+
rename: boolean;
|
| 863 |
+
/** The Field-type picker in the Edit-field pane. */
|
| 864 |
+
retype: boolean;
|
| 865 |
+
/** The "Delete field" row. Spelt `remove` only because `delete` reads as the operator. */
|
| 866 |
+
remove: boolean;
|
| 867 |
+
}
|
| 868 |
+
|
| 869 |
+
/**
|
| 870 |
+
* ββ W40-T24 (owner instruction 18, contract C2) β **WHICH DEFINITION CONTROLS DOES THIS
|
| 871 |
+
* COLUMN OFFER?** One function, one answer, so the four verbs cannot drift apart.
|
| 872 |
+
*
|
| 873 |
+
* Owner, verbatim: *"the Supplier field is wrong. Editable at record level, yes, but 'Edit
|
| 874 |
+
* field' offers a 'Choose field' dropdown that makes no sense. Audit every pre-set field so the
|
| 875 |
+
* structure is standard: a pre-set field's definition is not editable and shows no 'choose a
|
| 876 |
+
* field' dropdown."* The complaint arrived about Supplier and was never about Supplier: the swap
|
| 877 |
+
* picker was gated on `!locked` alone, and `locked` means "is the pinned primary column". Zero
|
| 878 |
+
* pre-set awareness, so EVERY contract column on every grid carried the same exposure, and a fix
|
| 879 |
+
* written for Supplier would have been the wrong shape of fix.
|
| 880 |
+
*
|
| 881 |
+
* ββ **THE LOCK IS `isUserSchemaField`, AND `isPresetField` CANNOT DO THIS JOB β MEASURED, NOT
|
| 882 |
+
* ASSUMED.** The obvious reach is for the predicate that carries the word, and it is wrong here.
|
| 883 |
+
* `platform/aios_grid_fields.json` declares NINE product_data contract columns β
|
| 884 |
+
* `supplier`, `origin_country`, `lead_days`, `first_cost`, `needs_pricing`, `march_pricelist`,
|
| 885 |
+
* `price_changes`, `closeouts`, `notes` β as `{"source": "overlay", "shared": true}` with no
|
| 886 |
+
* `custom` and no `preset` key. That is deliberate and it is what makes their CELLS typeable
|
| 887 |
+
* (`mayEditField` requires `source === "overlay"`), which is the owner's *"editable at record
|
| 888 |
+
* level, yes"*. Run `isPresetField` over any of them and it answers **false**: it recognises the
|
| 889 |
+
* Odoo-sourced stratum and the machine-owned one, and the overlay-stratum contract columns are
|
| 890 |
+
* neither. Gate the swap picker on it and Supplier β the column the instruction names β keeps
|
| 891 |
+
* the dropdown. β So the two predicates are NOT complements and the choice is not a matter of
|
| 892 |
+
* taste: one of them is false for the subject of the ticket.
|
| 893 |
+
*
|
| 894 |
+
* Β· `isUserSchemaField` β *is this column's shape THIS user's to change?* False for all nine
|
| 895 |
+
* of those, false for the Odoo-sourced columns (Category, Agent), false for a machine-owned
|
| 896 |
+
* automation column, and TRUE for a `custom_` overlay column the user made and for every
|
| 897 |
+
* `ut_*` shared-definition column. That is the pre-set line drawn exactly where C2 draws it.
|
| 898 |
+
* Β· `isPresetField` β *is this column filled FOR you?* Still the right predicate for the
|
| 899 |
+
* PRE-SET CHIP and the custom-field dot, which is what it was written for. It answers a
|
| 900 |
+
* question about where the VALUES come from; this lock is about who owns the DEFINITION, and
|
| 901 |
+
* the nine columns above are the proof that those are different sets.
|
| 902 |
+
*
|
| 903 |
+
* β **THE SWAP TAKES THE SAME PREDICATE AS RETYPE, WHICH IS THE POINT.** `CustomerGrid.
|
| 904 |
+
* changeField` only rewrites `config.order`/`config.visible`, so the swap is mechanically a view
|
| 905 |
+
* edit β but it sits INSIDE the Edit-field pane, and a pane whose Name box is disabled and whose
|
| 906 |
+
* type picker is absent while a third control offers to make this column something else is
|
| 907 |
+
* incoherent whatever the plumbing does. One predicate for all of the pane's definition verbs is
|
| 908 |
+
* what makes the pane say one thing.
|
| 909 |
+
*
|
| 910 |
+
* β **`rename` AND `retype` ARE REPORTED HERE, ENFORCED AT THE HOST β DELIBERATELY.** The host
|
| 911 |
+
* withholds the `onRename`/`onRetype` PROPS (`CustomerGrid.tsx`, the `onRetype=` and `onRename=`
|
| 912 |
+
* prop chains at the `<ColumnMenu>` render), and a control whose handler is undefined is not
|
| 913 |
+
* rendered at all. Enforcing the same refusal a second time inside the menu could only SUBTRACT
|
| 914 |
+
* from columns that work today β the Destination column's rename (owner item 3/6, 2026-08-23)
|
| 915 |
+
* reaches the pane through the route branch, not through the stratum β and two enforcement
|
| 916 |
+
* points that agree today are how one silently becomes the other's contradiction. So these two
|
| 917 |
+
* fields mirror the host's real rule, route carve-out included, and exist so a node gate can
|
| 918 |
+
* assert what the JSX does. If the host chain changes, this changes with it.
|
| 919 |
+
*
|
| 920 |
+
* β **`remove` IS THE LOCK'S VERDICT ONLY.** Whether a delete DOOR exists at all is a separate
|
| 921 |
+
* question the host answers three different ways (per-user overlay, `ut_*` shared definition,
|
| 922 |
+
* route order), and `ColumnMenu` keeps `onDelete &&` plus its `schemaLocked` prop beside this.
|
| 923 |
+
* AND-ing can only subtract, so nothing here duplicates `CustomerGrid.isSchemaLocked` β which is
|
| 924 |
+
* not exported, and copying it out would be D-413's disease in a fresh location.
|
| 925 |
+
* β THE ROLLUP CLAUSE IS AN OWNER RULING, NOT A HACK (2026-08-09): *"No rollup field should be
|
| 926 |
+
* uneditable, everything is custom and changeable always."* A rollup holds no data of its own β
|
| 927 |
+
* it is a question asked of other rows, and re-asking it costs nothing β so deleting a pre-set
|
| 928 |
+
* one destroys no measurement. `isSchemaLocked` carries the SAME exception in the same words
|
| 929 |
+
* (`&& field.type !== "rollup"`); dropping it here would revoke a live ruling by accident.
|
| 930 |
+
*
|
| 931 |
+
* @param opts.isUserTable the grid is a `ut_*` runtime database, not an Odoo-backed topic.
|
| 932 |
+
* @param opts.isPrimary this is the pinned primary column (the menu's `locked` prop) β the row
|
| 933 |
+
* identity, which can never be swapped away whatever else is true of it.
|
| 934 |
+
*/
|
| 935 |
+
export function columnDefinitionOffer(
|
| 936 |
+
field: Field,
|
| 937 |
+
opts: { isUserTable: boolean; isPrimary: boolean }
|
| 938 |
+
): ColumnDefinitionOffer {
|
| 939 |
+
const ownShape = isUserSchemaField(field, opts.isUserTable);
|
| 940 |
+
// The route order column's own rename and delete doors. Matched on the DECLARED `kind`, never
|
| 941 |
+
// on the `route_` key prefix β the server declares the kind precisely so nobody has to read a
|
| 942 |
+
// key as a type, and the host's own chain matches it the same way.
|
| 943 |
+
const routeOrder = field.shared === true && field.kind === "route_order" && !opts.isPrimary;
|
| 944 |
+
return {
|
| 945 |
+
swap: !opts.isPrimary && ownShape,
|
| 946 |
+
rename: ownShape || routeOrder,
|
| 947 |
+
retype: ownShape,
|
| 948 |
+
remove: ownShape || routeOrder || field.type === "rollup",
|
| 949 |
+
};
|
| 950 |
+
}
|
web/src/customer-grid/export.ts
CHANGED
|
@@ -27,7 +27,7 @@
|
|
| 27 |
// the installed build) β so a Blob URL + a[download] click works in the embed.
|
| 28 |
// ---------------------------------------------------------------------------
|
| 29 |
|
| 30 |
-
import type { Field, Row } from "./types";
|
| 31 |
import {
|
| 32 |
formatDisplay,
|
| 33 |
formulaIsBlank,
|
|
@@ -47,6 +47,108 @@ export const EXPORT_LABELS: Record<ExportFormat, string> = {
|
|
| 47 |
json: "JSON",
|
| 48 |
};
|
| 49 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 50 |
// ------------------------------------------------------------------ filename
|
| 51 |
|
| 52 |
/** `<view or cohort name> - <today>.<ext>` β `today` is the PAYLOAD's string
|
|
@@ -319,12 +421,18 @@ function buildStyles(codes: string[]): string {
|
|
| 319 |
/** A minimal SpreadsheetML workbook: one sheet, NUMERIC kinds written as real
|
| 320 |
* numbers with a number format that reproduces the grid's rendering, everything
|
| 321 |
* else an inline string carrying the DISPLAY value (contract C2 β what the grid
|
| 322 |
-
* shows is what the file says).
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 323 |
export function buildXlsx(
|
| 324 |
fields: Field[],
|
| 325 |
rows: Row[],
|
| 326 |
name: string,
|
| 327 |
-
today: string | undefined
|
|
|
|
| 328 |
): Uint8Array {
|
| 329 |
const enc = new TextEncoder();
|
| 330 |
const styles = styleTable();
|
|
@@ -378,11 +486,45 @@ export function buildXlsx(
|
|
| 378 |
}
|
| 379 |
|
| 380 |
const rowXml = (cells: string[]) => `<row>${cells.join("")}</row>`;
|
| 381 |
-
const
|
| 382 |
-
|
| 383 |
-
|
| 384 |
-
|
| 385 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 386 |
const sheet =
|
| 387 |
`<?xml version="1.0" encoding="UTF-8" standalone="yes"?>` +
|
| 388 |
`<worksheet xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main">` +
|
|
@@ -590,13 +732,20 @@ export function triggerDownload(filename: string, blob: Blob): void {
|
|
| 590 |
window.setTimeout(() => URL.revokeObjectURL(url), 4000);
|
| 591 |
}
|
| 592 |
|
| 593 |
-
/** One door for all four formats: build, wrap, download.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 594 |
export function runExport(
|
| 595 |
format: ExportFormat,
|
| 596 |
name: string,
|
| 597 |
today: string | undefined,
|
| 598 |
fields: Field[],
|
| 599 |
-
rows: Row[]
|
|
|
|
| 600 |
): void {
|
| 601 |
const filename = exportFilename(name, today, format);
|
| 602 |
if (format === "csv") {
|
|
@@ -617,7 +766,7 @@ export function runExport(
|
|
| 617 |
if (format === "xlsx") {
|
| 618 |
triggerDownload(
|
| 619 |
filename,
|
| 620 |
-
new Blob([buildXlsx(fields, rows, name, today).buffer as ArrayBuffer], {
|
| 621 |
type: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
|
| 622 |
})
|
| 623 |
);
|
|
|
|
| 27 |
// the installed build) β so a Blob URL + a[download] click works in the embed.
|
| 28 |
// ---------------------------------------------------------------------------
|
| 29 |
|
| 30 |
+
import type { Field, Row, VisibleRow } from "./types";
|
| 31 |
import {
|
| 32 |
formatDisplay,
|
| 33 |
formulaIsBlank,
|
|
|
|
| 47 |
json: "JSON",
|
| 48 |
};
|
| 49 |
|
| 50 |
+
// --------------------------------------------------------------- grouping
|
| 51 |
+
//
|
| 52 |
+
// β WAVE 40, OWNER INSTRUCTION 22 (W40-T26) β *"A grouped View exported to Excel
|
| 53 |
+
// must show the grouping in the Excel file."* Until now the export ran its
|
| 54 |
+
// pipeline with `groupBy` hardcoded to null, so a view grouped by City exported
|
| 55 |
+
// as one undifferentiated block and the file said nothing the screen said.
|
| 56 |
+
//
|
| 57 |
+
// β AMENDMENT AM-3 (2026-08-23) IS THE CONTRACT: this ships VISIBLE grouping,
|
| 58 |
+
// not COLLAPSIBLE grouping. A labelled band row carrying the group value and its
|
| 59 |
+
// count precedes each block. Excel's +/- outline gutter needs `sheetFormatPr`,
|
| 60 |
+
// `outlineLevel` and friends in a strict `CT_Worksheet` element order; that is
|
| 61 |
+
// booked as a follow-up rather than built here, and NOTHING below invents a new
|
| 62 |
+
// OOXML element β the bands are ordinary text rows through the existing
|
| 63 |
+
// `rowXml()`/`cell()` helpers, which is why the container's invariants hold.
|
| 64 |
+
|
| 65 |
+
/** One VISIBLE group block: the bucket the pipeline formed, its band text and
|
| 66 |
+
* the rows that belong to it, in the order the grid paints them. */
|
| 67 |
+
export interface ExportGroup {
|
| 68 |
+
/** The bucket key exactly as `groupRows` formed it (the trimmed cell text; ""
|
| 69 |
+
* for the blank bucket, "1"/"" for a checkbox, ONE member of a multi cell). */
|
| 70 |
+
key: string;
|
| 71 |
+
/** The grid's own group-bar label for that key β "(empty)", "Checked",
|
| 72 |
+
* "Unchecked" or the cell text. Used verbatim when the key has no display
|
| 73 |
+
* rendering of its own, so the file never shows a nameless band. */
|
| 74 |
+
label: string;
|
| 75 |
+
/** The bucket's size, from the pipeline. Equal to `rows.length` here: the
|
| 76 |
+
* export always runs with an EMPTY collapsed set, so no bucket is folded. */
|
| 77 |
+
count: number;
|
| 78 |
+
rows: Row[];
|
| 79 |
+
}
|
| 80 |
+
|
| 81 |
+
/** The grouped shape handed to a builder. `field` is the column the view is
|
| 82 |
+
* grouped BY, so a band renders its value the same way that value renders in
|
| 83 |
+
* its own column (see `bandText`); absent if the field has gone missing. */
|
| 84 |
+
export interface ExportGrouping {
|
| 85 |
+
field?: Field;
|
| 86 |
+
blocks: ExportGroup[];
|
| 87 |
+
}
|
| 88 |
+
|
| 89 |
+
/**
|
| 90 |
+
* β WHICH FORMATS CARRY GROUPING, and it is a DECISION rather than an accident.
|
| 91 |
+
*
|
| 92 |
+
* EXCEL ONLY. The owner's words are "exported to Excel" and the ticket's
|
| 93 |
+
* `done-when` names the xlsx; the other three are left exactly as they are, in
|
| 94 |
+
* both the grouped and ungrouped case:
|
| 95 |
+
*
|
| 96 |
+
* Β· JSON is a RAW-VALUE contract β `{ fields, rows }` where every row is a
|
| 97 |
+
* record carrying its stable pid. A band has no pid, and grouping a MULTI
|
| 98 |
+
* field lists one record under EVERY member of its cell, so feeding the
|
| 99 |
+
* bucketed walk into this builder would put duplicate pids into a
|
| 100 |
+
* machine-readable file. That is a data defect, not a feature.
|
| 101 |
+
* Β· PDF is a paginated table: a band row is a layout change (band fill, page
|
| 102 |
+
* breaks, the repeated header) of exactly the kind AM-3 defers.
|
| 103 |
+
* Β· CSV has no band vocabulary and its rows would silently REORDER.
|
| 104 |
+
*
|
| 105 |
+
* β It selects which BUILDER receives the grouped structure. It must never
|
| 106 |
+
* decide which ROWS were matched: `exportRows` runs its record pipeline
|
| 107 |
+
* identically for all four formats, so the same view exported twice always
|
| 108 |
+
* carries the same records.
|
| 109 |
+
*/
|
| 110 |
+
export function groupingApplies(format: ExportFormat): boolean {
|
| 111 |
+
return format === "xlsx";
|
| 112 |
+
}
|
| 113 |
+
|
| 114 |
+
/**
|
| 115 |
+
* ββ THE SENTINEL WALK β the half of instruction 22 that is invisible from the
|
| 116 |
+
* outside, and the reason unhardcoding a `groupBy` on its own changes NOTHING.
|
| 117 |
+
*
|
| 118 |
+
* A grouped pipeline result is not a tree. It is a FLAT `VisibleRow[]`
|
| 119 |
+
* interleaving `data` rows with `group-header` / `group-footer` sentinels, and
|
| 120 |
+
* every caller in the grid narrows it with a `kind === "data"` filter that
|
| 121 |
+
* throws all of them away. The export did the same. So: a header OPENS a block,
|
| 122 |
+
* a footer CLOSES it, and a data row joins whichever block is open.
|
| 123 |
+
*
|
| 124 |
+
* β A data row arriving with NO open block is skipped rather than inventing an
|
| 125 |
+
* unnamed bucket for it. `groupRows` always emits a header first, so this is a
|
| 126 |
+
* defensive branch and not a case in the product β but a nameless band is worse
|
| 127 |
+
* than a missing one, because it looks deliberate.
|
| 128 |
+
*
|
| 129 |
+
* β A footer only ever ENDS a block, so the table-wide total footer the grid
|
| 130 |
+
* appends under `TOTAL_GROUP_KEY` cannot open a phantom group here.
|
| 131 |
+
*
|
| 132 |
+
* Lives in `export.ts` rather than inline at the call site so a node gate can
|
| 133 |
+
* reach it: this walk is exactly the kind of thing that is wrong in a way no
|
| 134 |
+
* screenshot shows.
|
| 135 |
+
*/
|
| 136 |
+
export function toExportGroups(bucketed: VisibleRow[]): ExportGroup[] {
|
| 137 |
+
const blocks: ExportGroup[] = [];
|
| 138 |
+
let block: ExportGroup | null = null;
|
| 139 |
+
for (const vr of bucketed) {
|
| 140 |
+
if (vr.kind === "group-header") {
|
| 141 |
+
block = { key: vr.groupKey, label: vr.label, count: vr.count, rows: [] };
|
| 142 |
+
blocks.push(block);
|
| 143 |
+
} else if (vr.kind === "group-footer") {
|
| 144 |
+
block = null;
|
| 145 |
+
} else if (block) {
|
| 146 |
+
block.rows.push(vr.record);
|
| 147 |
+
}
|
| 148 |
+
}
|
| 149 |
+
return blocks;
|
| 150 |
+
}
|
| 151 |
+
|
| 152 |
// ------------------------------------------------------------------ filename
|
| 153 |
|
| 154 |
/** `<view or cohort name> - <today>.<ext>` β `today` is the PAYLOAD's string
|
|
|
|
| 421 |
/** A minimal SpreadsheetML workbook: one sheet, NUMERIC kinds written as real
|
| 422 |
* numbers with a number format that reproduces the grid's rendering, everything
|
| 423 |
* else an inline string carrying the DISPLAY value (contract C2 β what the grid
|
| 424 |
+
* shows is what the file says).
|
| 425 |
+
*
|
| 426 |
+
* β W40-T26. `grouping` is OPTIONAL and absent means UNGROUPED: the body is
|
| 427 |
+
* then built from `rows` by the same expression as before, so an ungrouped
|
| 428 |
+
* export is byte-identical to the pre-grouping writer. Present, it replaces the
|
| 429 |
+
* flat body with band-then-block, and `rows` is not read. */
|
| 430 |
export function buildXlsx(
|
| 431 |
fields: Field[],
|
| 432 |
rows: Row[],
|
| 433 |
name: string,
|
| 434 |
+
today: string | undefined,
|
| 435 |
+
grouping?: ExportGrouping
|
| 436 |
): Uint8Array {
|
| 437 |
const enc = new TextEncoder();
|
| 438 |
const styles = styleTable();
|
|
|
|
| 486 |
}
|
| 487 |
|
| 488 |
const rowXml = (cells: string[]) => `<row>${cells.join("")}</row>`;
|
| 489 |
+
const dataRow = (r: Row) => rowXml(fields.map((f) => dataCell(f, r[f.key])));
|
| 490 |
+
|
| 491 |
+
/**
|
| 492 |
+
* β W40-T26 / AM-3 β THE BAND'S TEXT: the group's VALUE and its COUNT, and
|
| 493 |
+
* nothing else. Not a sentence about grouping (DESIGN.md Β§4), not the canvas's
|
| 494 |
+
* βΌ/βΆ marker (there is nothing to collapse in a file), no dash of any kind.
|
| 495 |
+
*
|
| 496 |
+
* β THE VALUE GOES THROUGH `formatDisplay`, THE SAME FUNCTION EVERY OTHER
|
| 497 |
+
* EXPORTED VALUE GOES THROUGH. A date bucket's key is the raw "2026-07-28" and
|
| 498 |
+
* that column's own cells arrive in Excel as serials rendered "Jul 28, 2026";
|
| 499 |
+
* printing the key verbatim would make one file say the same value two ways.
|
| 500 |
+
*
|
| 501 |
+
* β AND IT FALLS BACK, because `formatDisplay` returns "" for exactly the
|
| 502 |
+
* buckets that most need a name: the blank bucket ("" -> "(empty)") and an
|
| 503 |
+
* unchecked checkbox ("" -> "Unchecked"). The pipeline's own label is the
|
| 504 |
+
* grid's group-bar wording, so the fallback is the screen's answer rather than
|
| 505 |
+
* a second one invented here.
|
| 506 |
+
*/
|
| 507 |
+
const bandText = (g: ExportGroup): string => {
|
| 508 |
+
const shown = grouping?.field ? formatDisplay(grouping.field, g.key) : "";
|
| 509 |
+
return `${shown || g.label} (${g.count.toLocaleString()})`;
|
| 510 |
+
};
|
| 511 |
+
|
| 512 |
+
// The header row is LABELS β text, and it stays text.
|
| 513 |
+
const bodyRows = [rowXml(fields.map((f) => cell(f.label)))];
|
| 514 |
+
if (grouping) {
|
| 515 |
+
// A band is ONE text cell. Cells carry no `r` attribute in this writer, so
|
| 516 |
+
// position is order and a one-cell row lands in column A β the same
|
| 517 |
+
// mechanism every other row here already relies on. No merge, no span:
|
| 518 |
+
// `mergeCells` is a new CT_Worksheet element and AM-3 defers that class of
|
| 519 |
+
// change.
|
| 520 |
+
for (const g of grouping.blocks) {
|
| 521 |
+
bodyRows.push(rowXml([cell(bandText(g))]));
|
| 522 |
+
for (const r of g.rows) bodyRows.push(dataRow(r));
|
| 523 |
+
}
|
| 524 |
+
} else {
|
| 525 |
+
for (const r of rows) bodyRows.push(dataRow(r));
|
| 526 |
+
}
|
| 527 |
+
const body = bodyRows.join("");
|
| 528 |
const sheet =
|
| 529 |
`<?xml version="1.0" encoding="UTF-8" standalone="yes"?>` +
|
| 530 |
`<worksheet xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main">` +
|
|
|
|
| 732 |
window.setTimeout(() => URL.revokeObjectURL(url), 4000);
|
| 733 |
}
|
| 734 |
|
| 735 |
+
/** One door for all four formats: build, wrap, download.
|
| 736 |
+
*
|
| 737 |
+
* β W40-T26. `grouping` reaches the xlsx builder and nothing else β see
|
| 738 |
+
* `groupingApplies` for why, and note that the CALLER has already decided: it
|
| 739 |
+
* passes `undefined` for every format that does not carry bands, so the three
|
| 740 |
+
* other builders are called with exactly the arguments they were called with
|
| 741 |
+
* before this ticket existed. */
|
| 742 |
export function runExport(
|
| 743 |
format: ExportFormat,
|
| 744 |
name: string,
|
| 745 |
today: string | undefined,
|
| 746 |
fields: Field[],
|
| 747 |
+
rows: Row[],
|
| 748 |
+
grouping?: ExportGrouping
|
| 749 |
): void {
|
| 750 |
const filename = exportFilename(name, today, format);
|
| 751 |
if (format === "csv") {
|
|
|
|
| 766 |
if (format === "xlsx") {
|
| 767 |
triggerDownload(
|
| 768 |
filename,
|
| 769 |
+
new Blob([buildXlsx(fields, rows, name, today, grouping).buffer as ArrayBuffer], {
|
| 770 |
type: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
|
| 771 |
})
|
| 772 |
);
|
web/src/customer-grid/folders.ts
CHANGED
|
@@ -219,6 +219,22 @@ export function resolveFolderId(
|
|
| 219 |
export interface FolderGroup<T> {
|
| 220 |
folder: GridFolder | null; // null = the root group
|
| 221 |
items: T[];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 222 |
}
|
| 223 |
|
| 224 |
/**
|
|
@@ -330,6 +346,13 @@ export const ROOT_FOLDER_ID = "__root__";
|
|
| 330 |
* the user made; ungrouped items are the leftovers. Every item appears exactly
|
| 331 |
* once β a grouping that can drop an item would make a view look deleted.
|
| 332 |
*
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 333 |
* β WAVE 21 item 9 (R12/C1) β `isShared` adds the synthetic "Shared with me" group,
|
| 334 |
* AFTER root, and three things about it are deliberate:
|
| 335 |
*
|
|
@@ -362,17 +385,69 @@ export function groupByFolder<T>(
|
|
| 362 |
* group exactly as before. Supplied, the shared views SPLIT by the folder that carried them,
|
| 363 |
* and the folder finally appears on the receiver's screen.
|
| 364 |
*/
|
| 365 |
-
sharedFolderOf?: (item: T) => { name: string; owner: string } | null
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 366 |
): FolderGroup<T>[] {
|
| 367 |
const buckets = new Map<string, T[]>(folders.map((f) => [f.id, []]));
|
| 368 |
const root: T[] = [];
|
| 369 |
const shared: T[] = [];
|
|
|
|
|
|
|
| 370 |
/** synthetic group id -> {name, views}. Keyed by OWNER+NAME; see `SHARED_FOLDER_PREFIX`. */
|
| 371 |
const sharedFolders = new Map<string, { name: string; items: T[] }>();
|
| 372 |
for (const item of items) {
|
| 373 |
const id = folderIdOf(item);
|
| 374 |
const bucket = id == null ? undefined : buckets.get(id);
|
| 375 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 376 |
// ββ W32-T27 (owner item 20) β THE ROOT BUCKET IS REACHABLE FOR A SHARED VIEW NOW.
|
| 377 |
// `ROOT_FOLDER_ID` is the receiver saying "I filed this at the top level"; absence still
|
| 378 |
// means "this arrived by grant and I have not filed it". Before this line the two were one
|
|
@@ -399,6 +474,11 @@ export function groupByFolder<T>(
|
|
| 399 |
else root.push(item);
|
| 400 |
}
|
| 401 |
const out: FolderGroup<T>[] = folders.map((f) => ({ folder: f, items: buckets.get(f.id) ?? [] }));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 402 |
out.push({ folder: null, items: root });
|
| 403 |
if (shared.length)
|
| 404 |
out.push({ folder: { id: SHARED_FOLDER_ID, name: SHARED_FOLDER_NAME }, items: shared });
|
|
|
|
| 219 |
export interface FolderGroup<T> {
|
| 220 |
folder: GridFolder | null; // null = the root group
|
| 221 |
items: T[];
|
| 222 |
+
/**
|
| 223 |
+
* ββ WAVE 40 Β· T28 (owner instruction 30) β THE PIN GROUP: unfiled default views, ABOVE
|
| 224 |
+
* every folder.
|
| 225 |
+
*
|
| 226 |
+
* β IT IS A SECOND `folder: null` GROUP, and that is why this flag exists rather than a
|
| 227 |
+
* reserved folder id. The pin group and the ungrouped section are both "views in no folder",
|
| 228 |
+
* so neither can carry a heading and neither may be given a synthetic id β an id would be
|
| 229 |
+
* emitted by the rail's own drag surfaces (`item_move`, `folder_reorder`) against a folder
|
| 230 |
+
* that exists in nobody's store, which is the failure {@link isSyntheticFolderId} was
|
| 231 |
+
* introduced to stop. A flag says "this bucket renders first" and says nothing else, so the
|
| 232 |
+
* rail can key, class and drop-guard the two apart without either becoming a place.
|
| 233 |
+
*
|
| 234 |
+
* β ABSENT on every other group, never `false`, so a caller that does not pass `isPinned`
|
| 235 |
+
* gets output that is byte-identical (JSON included) to the pre-T28 shape.
|
| 236 |
+
*/
|
| 237 |
+
pinned?: true;
|
| 238 |
}
|
| 239 |
|
| 240 |
/**
|
|
|
|
| 346 |
* the user made; ungrouped items are the leftovers. Every item appears exactly
|
| 347 |
* once β a grouping that can drop an item would make a view look deleted.
|
| 348 |
*
|
| 349 |
+
* ββ WAVE 40 Β· T28 (owner instruction 30) β WITH ONE BUCKET IN FRONT OF THE FOLDERS. The
|
| 350 |
+
* unfiled DEFAULT views lift out of the leftovers and render first, because they are not
|
| 351 |
+
* leftovers: they are the row every user lands on. See `isPinned` below for the whole rule,
|
| 352 |
+
* including the stored value that makes "unless the user moves it down" answerable. Omitting
|
| 353 |
+
* that predicate leaves this function byte-identical to the pre-T28 one, root LAST included,
|
| 354 |
+
* which is what the cohort rail and every existing test still get.
|
| 355 |
+
*
|
| 356 |
* β WAVE 21 item 9 (R12/C1) β `isShared` adds the synthetic "Shared with me" group,
|
| 357 |
* AFTER root, and three things about it are deliberate:
|
| 358 |
*
|
|
|
|
| 385 |
* group exactly as before. Supplied, the shared views SPLIT by the folder that carried them,
|
| 386 |
* and the folder finally appears on the receiver's screen.
|
| 387 |
*/
|
| 388 |
+
sharedFolderOf?: (item: T) => { name: string; owner: string } | null,
|
| 389 |
+
/**
|
| 390 |
+
* ββ WAVE 40 Β· T28 (owner instruction 30) β IS THIS VIEW A DEFAULT THAT PINS TO THE TOP?
|
| 391 |
+
*
|
| 392 |
+
* Owner: *"when it is not in a folder it must sit at the very top above all folders unless
|
| 393 |
+
* the user moves it down."* The rail passes `isUndeletableView`, so the three ids nobody can
|
| 394 |
+
* delete β the per-database default, Starred, and the IG Overview β are the pinned set. A
|
| 395 |
+
* PREDICATE rather than an id list for the same reason `mayFileView` takes a verdict: this
|
| 396 |
+
* module is "pure and React-free so verify_folders.py can run it under node" (see the header)
|
| 397 |
+
* and its only imports are one constant and one type. Importing the id set would point this
|
| 398 |
+
* file at `types.ts` for a decision the caller already knows the answer to.
|
| 399 |
+
*
|
| 400 |
+
* ββ THE PIN ASKS FOR **ABSENCE**, NOT FOR THE ROOT SENTINEL, AND THAT IS WHERE "UNLESS THE
|
| 401 |
+
* USER MOVES IT DOWN" LIVES. W32-T27 split the one meaning of "root" into two stored values
|
| 402 |
+
* precisely so this question could be asked: `folderId == null` is *"nobody has ever placed
|
| 403 |
+
* this"*, and {@link ROOT_FOLDER_ID} is *"the user dragged it here on purpose"*. So the pin
|
| 404 |
+
* engages on the first and YIELDS on the second β drag the default view down onto the
|
| 405 |
+
* ungrouped section and `item_move` stores the sentinel, the lift stops applying, and it
|
| 406 |
+
* renders among the ordinary loose views where it was dropped. Filing it into a folder is the
|
| 407 |
+
* same yield by the instruction's own words. Both are DURABLE: the sentinel survives
|
| 408 |
+
* `aios_grid.clean_item_folders`, so the placement outlives the session that made it.
|
| 409 |
+
*
|
| 410 |
+
* β Deleting the folder a pinned view was filed into DROPS the placement (contents fall to
|
| 411 |
+
* root by absence, not by sentinel β `grid_events.py`'s `folder_delete`), so the pin
|
| 412 |
+
* re-engages. That is the only path back to the top, and it is a consequence rather than a
|
| 413 |
+
* feature: nothing in the rail today clears a placement to absence.
|
| 414 |
+
*/
|
| 415 |
+
isPinned?: (item: T) => boolean
|
| 416 |
): FolderGroup<T>[] {
|
| 417 |
const buckets = new Map<string, T[]>(folders.map((f) => [f.id, []]));
|
| 418 |
const root: T[] = [];
|
| 419 |
const shared: T[] = [];
|
| 420 |
+
/** W40-T28 β unfiled pinned views, in the order they arrived, rendered above every folder. */
|
| 421 |
+
const pinned: T[] = [];
|
| 422 |
/** synthetic group id -> {name, views}. Keyed by OWNER+NAME; see `SHARED_FOLDER_PREFIX`. */
|
| 423 |
const sharedFolders = new Map<string, { name: string; items: T[] }>();
|
| 424 |
for (const item of items) {
|
| 425 |
const id = folderIdOf(item);
|
| 426 |
const bucket = id == null ? undefined : buckets.get(id);
|
| 427 |
+
// ββ W40-T28 (owner instruction 30) β AN UNFILED DEFAULT LIFTS OUT OF THE ROOT BUCKET.
|
| 428 |
+
//
|
| 429 |
+
// ββ `id == null` IS THE WHOLE OF "UNLESS THE USER MOVES IT DOWN", AND IT IS TESTED HERE
|
| 430 |
+
// β FIRST β RATHER THAN INHERITED FROM THE CHAIN BELOW. Placed after the other branches this
|
| 431 |
+
// clause reads identically and DOES NOTHING: a folder id is taken by `buckets`, the root
|
| 432 |
+
// sentinel by its own branch, and a dangling ref was nulled by `resolveFolderId` long before
|
| 433 |
+
// this line, so `id` is already absent by the time control arrives and the test can be
|
| 434 |
+
// deleted with no observable change. A rule no mutation can break is a rule no gate is
|
| 435 |
+
// checking ([[a-declared-gate-is-an-unchecked-claim]]) β so the placement question is asked
|
| 436 |
+
// where its answer still decides something, and `verify_folders.py` can red it on its own leg.
|
| 437 |
+
//
|
| 438 |
+
// β WHAT ABSENCE MEANS IS W32-T27's SPLIT, reused rather than reinvented: `folderId == null`
|
| 439 |
+
// is "nobody has ever placed this", {@link ROOT_FOLDER_ID} is "the user dragged it here on
|
| 440 |
+
// purpose". So the pin engages on the first and yields to the second β drop the default view
|
| 441 |
+
// onto the ungrouped section and `item_move` stores the sentinel, the lift stops applying,
|
| 442 |
+
// and it renders among the loose views where it was dropped. Filing it into a folder is the
|
| 443 |
+
// same yield by the instruction's own words.
|
| 444 |
+
//
|
| 445 |
+
// β `!isShared` KEEPS THE GRANT BRANCH UNTOUCHED. A pinned view is per-user system state and
|
| 446 |
+
// can never BE a grant, so the two cannot collide in practice β the guard is what makes that
|
| 447 |
+
// a structural fact rather than an assumption, and it is why every shared-grouping leg stays
|
| 448 |
+
// byte-identical to the pre-T28 one.
|
| 449 |
+
if (id == null && !isShared?.(item) && isPinned?.(item)) pinned.push(item);
|
| 450 |
+
else if (bucket) bucket.push(item);
|
| 451 |
// ββ W32-T27 (owner item 20) β THE ROOT BUCKET IS REACHABLE FOR A SHARED VIEW NOW.
|
| 452 |
// `ROOT_FOLDER_ID` is the receiver saying "I filed this at the top level"; absence still
|
| 453 |
// means "this arrived by grant and I have not filed it". Before this line the two were one
|
|
|
|
| 474 |
else root.push(item);
|
| 475 |
}
|
| 476 |
const out: FolderGroup<T>[] = folders.map((f) => ({ folder: f, items: buckets.get(f.id) ?? [] }));
|
| 477 |
+
// ββ W40-T28 β IN FRONT OF EVERY FOLDER, which is the half of instruction 30 this module owns.
|
| 478 |
+
// β An EMPTY pin group is never emitted, the same rule the shared group carries: a bucket with
|
| 479 |
+
// nothing in it is a section the user cannot reach, and here it would also be a phantom second
|
| 480 |
+
// root the rail would have to render around.
|
| 481 |
+
if (pinned.length) out.unshift({ folder: null, items: pinned, pinned: true });
|
| 482 |
out.push({ folder: null, items: root });
|
| 483 |
if (shared.length)
|
| 484 |
out.push({ folder: { id: SHARED_FOLDER_ID, name: SHARED_FOLDER_NAME }, items: shared });
|
web/src/customer-grid/iconShapes.ts
CHANGED
|
@@ -811,8 +811,43 @@ export const TYPE_SPRITES: Record<string, ({ fgColor }: { fgColor: string }) =>
|
|
| 811 |
* aligned. It is now painted by CustomerGrid's `drawHeader`
|
| 812 |
* callback at `infoMarkRect()` - see overlayPlacement.ts.
|
| 813 |
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 814 |
export const HEADER_ICONS: Record<string, (c: { fgColor: string; bgColor: string }) => string> = {
|
| 815 |
...TYPE_SPRITES,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 816 |
aiosInfo: () =>
|
| 817 |
`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16">` +
|
| 818 |
`<circle cx="8" cy="8" r="6.1" fill="none" stroke="${LP_MUTED}" stroke-width="1.25"/>` +
|
|
|
|
| 811 |
* aligned. It is now painted by CustomerGrid's `drawHeader`
|
| 812 |
* callback at `infoMarkRect()` - see overlayPlacement.ts.
|
| 813 |
*/
|
| 814 |
+
/**
|
| 815 |
+
* β W40-T20 β THE share glyph: two people, one behind the other. The ONE geometry for "this is
|
| 816 |
+
* shared", as data, so the canvas sprite below and any React consumer paint the same shape
|
| 817 |
+
* instead of two hand-copied SVGs that drift.
|
| 818 |
+
*
|
| 819 |
+
* β NOT A PADLOCK. `LockMark` (icons.tsx) is a padlock body plus a shackle and it means a LOCK
|
| 820 |
+
* (DESIGN.md Β§4, THE THREE LOCKS). A share is a different fact about a column and wears a
|
| 821 |
+
* different mark, which is the whole of "one mark, one meaning" β D-254 is what happens when it
|
| 822 |
+
* does not.
|
| 823 |
+
*
|
| 824 |
+
* Traced off the rail's `.cg-view-shared` mark (ViewSidebar.tsx) at the same viewBox, so a shared
|
| 825 |
+
* VIEW in the rail and a shared FIELD in a header say "shared" with the same drawing. The head is
|
| 826 |
+
* an arc path rather than a `<circle>` because `IconShape` is path data and one serializer
|
| 827 |
+
* (`shapeSource`) paints the entire vocabulary.
|
| 828 |
+
*/
|
| 829 |
+
export const SHARE_SHAPE: IconShape[] = [
|
| 830 |
+
// The near figure: head, then shoulders.
|
| 831 |
+
{ d: "M5.6 3.4a2.2 2.2 0 1 1 0 4.4 2.2 2.2 0 1 1 0-4.4" },
|
| 832 |
+
{ d: "M1.9 12.6c0-2 1.7-3.2 3.7-3.2s3.7 1.2 3.7 3.2" },
|
| 833 |
+
// The far figure, cropped by the near one: half a head and a shoulder.
|
| 834 |
+
{ d: "M10.6 4.1a2.2 2.2 0 0 1 0 4.2M11.4 9.7c1.6.3 2.7 1.4 2.7 2.9" },
|
| 835 |
+
];
|
| 836 |
+
|
| 837 |
export const HEADER_ICONS: Record<string, (c: { fgColor: string; bgColor: string }) => string> = {
|
| 838 |
...TYPE_SPRITES,
|
| 839 |
+
/**
|
| 840 |
+
* β W40-T20 β the shared-field mark, drawn by `CustomerGrid.drawGridHeader` on the innermost
|
| 841 |
+
* slot of `headerMarkFit`'s strip.
|
| 842 |
+
*
|
| 843 |
+
* It IGNORES the colours glide hands it, for exactly the reason `aiosInfo` does and recorded in
|
| 844 |
+
* that entry's note: glide's variants resolve to the accent behind `bgHeader`, which under the
|
| 845 |
+
* C1 pastels is a pale glyph on a pale disc. LP_MUTED keeps it legible on every header state.
|
| 846 |
+
*/
|
| 847 |
+
aiosShared: () =>
|
| 848 |
+
`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16">` +
|
| 849 |
+
SHARE_SHAPE.map((s) => shapeSource(s, LP_MUTED)).join("") +
|
| 850 |
+
`</svg>`,
|
| 851 |
aiosInfo: () =>
|
| 852 |
`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16">` +
|
| 853 |
`<circle cx="8" cy="8" r="6.1" fill="none" stroke="${LP_MUTED}" stroke-width="1.25"/>` +
|
web/src/customer-grid/overlayPlacement.ts
CHANGED
|
@@ -213,6 +213,18 @@ export function fitGroupLabel(
|
|
| 213 |
export const CUSTOM_MARK_SIZE = 6;
|
| 214 |
/** Clearance BETWEEN two marks in the strip. */
|
| 215 |
export const HEADER_MARK_GAP = 6;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 216 |
|
| 217 |
/**
|
| 218 |
* R11 β where the header's right-hand marks go, laid out from the OUTSIDE IN.
|
|
@@ -257,16 +269,83 @@ export function headerMarkLayout(
|
|
| 257 |
return out;
|
| 258 |
}
|
| 259 |
|
| 260 |
-
/** The strip's ORDER, in one place: (i) outermost, the user-created dot inboard of it
|
| 261 |
-
* truncation reserve and the drawing path read this, so they cannot
|
| 262 |
-
* marks a column carries or which is which.
|
| 263 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 264 |
const out: number[] = [];
|
| 265 |
if (hasInfoMark) out.push(INFO_MARK_SIZE);
|
| 266 |
if (isCustomField) out.push(CUSTOM_MARK_SIZE);
|
|
|
|
| 267 |
return out;
|
| 268 |
}
|
| 269 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 270 |
// ------------------------------------------------- owner item 16: the header title vs the (i)
|
| 271 |
|
| 272 |
/**
|
|
@@ -310,13 +389,22 @@ export function headerLabelSpace(
|
|
| 310 |
* the label gets reserved room for only one of them.
|
| 311 |
*/
|
| 312 |
marks: boolean | readonly number[],
|
| 313 |
-
menuSlotWidth = HEADER_MENU_SLOT
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 314 |
): number | null {
|
| 315 |
const sizes = marks === true ? [INFO_MARK_SIZE] : marks === false ? [] : marks;
|
| 316 |
-
// The INNERMOST mark is the one the label must clear, and
|
| 317 |
-
//
|
| 318 |
-
|
| 319 |
-
|
|
|
|
|
|
|
| 320 |
return Math.max(0, layout[layout.length - 1].x - HEADER_LABEL_X - HEADER_LABEL_GAP);
|
| 321 |
}
|
| 322 |
|
|
@@ -423,45 +511,76 @@ export function expandButtonRect(
|
|
| 423 |
return { x, y, size };
|
| 424 |
}
|
| 425 |
|
| 426 |
-
// --------------------------------
|
| 427 |
|
| 428 |
/** Smaller than the Expand button: a mark, not an action with a destination. */
|
| 429 |
export const STAR_BTN_SIZE = 18;
|
| 430 |
-
/**
|
| 431 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 432 |
|
| 433 |
/**
|
| 434 |
-
* ββ
|
| 435 |
-
* the
|
| 436 |
-
*
|
| 437 |
-
*
|
| 438 |
-
*
|
| 439 |
-
*
|
| 440 |
-
*
|
| 441 |
-
*
|
| 442 |
-
*
|
| 443 |
-
*
|
| 444 |
-
*
|
| 445 |
-
*
|
| 446 |
-
*
|
| 447 |
-
*
|
| 448 |
-
*
|
| 449 |
-
*
|
| 450 |
-
*
|
| 451 |
-
*
|
| 452 |
-
*
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 453 |
*/
|
| 454 |
export function starButtonRect(
|
| 455 |
primary: { x: number; y: number; width: number; height: number },
|
| 456 |
box?: { x: number; y: number; width: number; height: number },
|
| 457 |
size = STAR_BTN_SIZE,
|
| 458 |
-
|
| 459 |
): { x: number; y: number; size: number } | null {
|
| 460 |
-
|
| 461 |
-
//
|
| 462 |
-
|
| 463 |
-
|
| 464 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 465 |
if (box) {
|
| 466 |
if (x < box.x || x + size > box.x + box.width) return null;
|
| 467 |
if (y < box.y || y + size > box.y + box.height) return null;
|
|
|
|
| 213 |
export const CUSTOM_MARK_SIZE = 6;
|
| 214 |
/** Clearance BETWEEN two marks in the strip. */
|
| 215 |
export const HEADER_MARK_GAP = 6;
|
| 216 |
+
/**
|
| 217 |
+
* β W40-T20 β the SHARE mark, the strip's third slot: "this field is shared, so what you type
|
| 218 |
+
* here is what everyone with access to this table reads".
|
| 219 |
+
*
|
| 220 |
+
* 13px is the size `ViewSidebar` renders the same two-people glyph at, so one concept reads at
|
| 221 |
+
* one weight wherever the product says it.
|
| 222 |
+
*
|
| 223 |
+
* β IT IS NOT A PADLOCK AND IT IS NOT `LockMark`. A share and a lock are different facts about a
|
| 224 |
+
* column (DESIGN.md Β§4, THE THREE LOCKS: a share says who else can see the column, a lock says
|
| 225 |
+
* what may be changed), and one glyph carrying both meanings is D-254 in a second surface.
|
| 226 |
+
*/
|
| 227 |
+
export const SHARE_MARK_SIZE = 13;
|
| 228 |
|
| 229 |
/**
|
| 230 |
* R11 β where the header's right-hand marks go, laid out from the OUTSIDE IN.
|
|
|
|
| 269 |
return out;
|
| 270 |
}
|
| 271 |
|
| 272 |
+
/** The strip's ORDER, in one place: (i) outermost, the user-created dot inboard of it, the share
|
| 273 |
+
* mark innermost. Both the truncation reserve and the drawing path read this, so they cannot
|
| 274 |
+
* disagree about how many marks a column carries or which is which.
|
| 275 |
+
*
|
| 276 |
+
* β W40-T20 β `isSharedField` is OPTIONAL and defaults to false, deliberately: every pre-T20
|
| 277 |
+
* call site asks the two-boolean question and must keep getting the two-boolean answer. The
|
| 278 |
+
* share mark goes LAST because last is INNERMOST, and innermost is the slot `headerMarkFit`
|
| 279 |
+
* gives up first β so a column too tight for three marks loses the new one rather than the two
|
| 280 |
+
* that shipped before it. */
|
| 281 |
+
export function headerMarkSizes(
|
| 282 |
+
hasInfoMark: boolean,
|
| 283 |
+
isCustomField: boolean,
|
| 284 |
+
isSharedField = false
|
| 285 |
+
): number[] {
|
| 286 |
const out: number[] = [];
|
| 287 |
if (hasInfoMark) out.push(INFO_MARK_SIZE);
|
| 288 |
if (isCustomField) out.push(CUSTOM_MARK_SIZE);
|
| 289 |
+
if (isSharedField) out.push(SHARE_MARK_SIZE);
|
| 290 |
return out;
|
| 291 |
}
|
| 292 |
|
| 293 |
+
/**
|
| 294 |
+
* β W40-T20 β does this field's header carry a share mark? THE rule, in one exported place.
|
| 295 |
+
*
|
| 296 |
+
* It lives here rather than inside `CustomerGrid.drawGridHeader` for the reason the rest of this
|
| 297 |
+
* module exists: a decision buried in a React canvas callback is unobservable to anything but a
|
| 298 |
+
* screenshot, and this one has two consumers (the drawer, and the label reserve) that must never
|
| 299 |
+
* answer it differently.
|
| 300 |
+
*
|
| 301 |
+
* β STRUCTURALLY TYPED ON PURPOSE. This module imports nothing β that is what lets a gate compile
|
| 302 |
+
* it with tsc and run it under node β so it takes the one property it reads rather than `Field`.
|
| 303 |
+
*
|
| 304 |
+
* β `shared` means "this definition lives in the tenant-wide field stratum", i.e. THIS FIELD HAS
|
| 305 |
+
* BEEN SHARED β not "somebody shared it WITH ME" (contract C1). The server stamps it on the
|
| 306 |
+
* owner's own copy too (`routes_customers._merge_shared_fields`, `shares.role_for` returning
|
| 307 |
+
* `"owner"`), so the mark reads as "this column is shared" for everyone who can see it, and the
|
| 308 |
+
* copy that explains it must not be worded as though the reader were only ever the receiver.
|
| 309 |
+
*/
|
| 310 |
+
export function hasShareMark(field: { shared?: boolean }): boolean {
|
| 311 |
+
return field.shared === true;
|
| 312 |
+
}
|
| 313 |
+
|
| 314 |
+
/**
|
| 315 |
+
* β W40-T20 β the strip that DEGRADES, and the ONE function both the drawer and the label
|
| 316 |
+
* reserve go through.
|
| 317 |
+
*
|
| 318 |
+
* Why it had to exist. `headerMarkLayout` is ALL-OR-NOTHING by contract, and that contract is
|
| 319 |
+
* what stops the reserve and the drawer disagreeing (see its note). It is also why a third mark
|
| 320 |
+
* could not simply be appended: on a column with room for exactly two, asking for three returns
|
| 321 |
+
* `null`, and the (i) and the user-created dot β both shipped, both gated β would have vanished
|
| 322 |
+
* to make room for a mark that was then not drawn either. Adding a feature by deleting two is
|
| 323 |
+
* not adding a feature.
|
| 324 |
+
*
|
| 325 |
+
* So the strip gives way from the INSIDE, one droppable slot at a time. `droppable` is how many
|
| 326 |
+
* TRAILING slots may be surrendered; everything ahead of them keeps the all-or-nothing behaviour
|
| 327 |
+
* it shipped with. **`droppable = 0` is exactly `headerMarkLayout`** β which is why every
|
| 328 |
+
* pre-T20 caller, and every negative control aimed at that function, is untouched by this.
|
| 329 |
+
*
|
| 330 |
+
* Returns the surviving layout AND how many slots survived, because a drawer needs to know which
|
| 331 |
+
* marks it may paint, not merely where they would have gone.
|
| 332 |
+
*/
|
| 333 |
+
export function headerMarkFit(
|
| 334 |
+
header: { x: number; y: number; width: number; height: number },
|
| 335 |
+
menuSlotWidth: number,
|
| 336 |
+
sizes: readonly number[],
|
| 337 |
+
droppable = 0
|
| 338 |
+
): { layout: { x: number; y: number; size: number }[]; kept: number } | null {
|
| 339 |
+
// Never below one mark: a strip that "degrades" to nothing is the all-or-nothing answer, and
|
| 340 |
+
// `headerMarkLayout` already gives that by returning null.
|
| 341 |
+
const floor = Math.max(1, sizes.length - Math.max(0, droppable));
|
| 342 |
+
for (let kept = sizes.length; kept >= floor; kept--) {
|
| 343 |
+
const layout = headerMarkLayout(header, menuSlotWidth, sizes.slice(0, kept));
|
| 344 |
+
if (layout) return { layout, kept };
|
| 345 |
+
}
|
| 346 |
+
return null;
|
| 347 |
+
}
|
| 348 |
+
|
| 349 |
// ------------------------------------------------- owner item 16: the header title vs the (i)
|
| 350 |
|
| 351 |
/**
|
|
|
|
| 389 |
* the label gets reserved room for only one of them.
|
| 390 |
*/
|
| 391 |
marks: boolean | readonly number[],
|
| 392 |
+
menuSlotWidth = HEADER_MENU_SLOT,
|
| 393 |
+
/**
|
| 394 |
+
* β W40-T20 β how many TRAILING marks this column is willing to give up, passed straight to
|
| 395 |
+
* `headerMarkFit`. It defaults to 0, so every pre-T20 caller keeps the all-or-nothing reserve
|
| 396 |
+
* it had; a caller that asks for a droppable share mark must say so here too, or it reserves
|
| 397 |
+
* room for a strip the drawer will not paint.
|
| 398 |
+
*/
|
| 399 |
+
droppable = 0
|
| 400 |
): number | null {
|
| 401 |
const sizes = marks === true ? [INFO_MARK_SIZE] : marks === false ? [] : marks;
|
| 402 |
+
// The INNERMOST mark is the one the label must clear, and the strip is fitted through
|
| 403 |
+
// `headerMarkFit` β the SAME function the drawer uses β so the reserve is taken against the
|
| 404 |
+
// marks that actually SURVIVE the column's width, never against the ones merely asked for.
|
| 405 |
+
const fit = headerMarkFit({ x: 0, y: 0, width, height: 32 }, menuSlotWidth, sizes, droppable);
|
| 406 |
+
if (!fit) return null;
|
| 407 |
+
const layout = fit.layout;
|
| 408 |
return Math.max(0, layout[layout.length - 1].x - HEADER_LABEL_X - HEADER_LABEL_GAP);
|
| 409 |
}
|
| 410 |
|
|
|
|
| 511 |
return { x, y, size };
|
| 512 |
}
|
| 513 |
|
| 514 |
+
// -------------------------------- the record star, BESIDE the Expand (owner instruction 29)
|
| 515 |
|
| 516 |
/** Smaller than the Expand button: a mark, not an action with a destination. */
|
| 517 |
export const STAR_BTN_SIZE = 18;
|
| 518 |
+
/**
|
| 519 |
+
* The clear space between the star and the Expand it now sits against.
|
| 520 |
+
*
|
| 521 |
+
* 4px is not a taste call: it is `.cg-detail-nav`'s own `gap`, which is what a group of adjacent
|
| 522 |
+
* icon buttons already measures elsewhere in this grid, and it is on `DESIGN.md` Β§4's 4/8 grid.
|
| 523 |
+
*/
|
| 524 |
+
export const STAR_BTN_GAP = 4;
|
| 525 |
|
| 526 |
/**
|
| 527 |
+
* ββ OWNER INSTRUCTION 29 (wave 40, 2026-08-24) β where the row's star sits: **immediately to
|
| 528 |
+
* the LEFT of the Expand button**, at the right end of the primary cell, level with it.
|
| 529 |
+
*
|
| 530 |
+
* β THIS REVERSES W35-T29 (R5, R6), AND THE OLD ARGUMENT IS RECORDED HERE RATHER THAN DELETED,
|
| 531 |
+
* because a reversed ruling whose reasoning is left standing is how the next session restores it.
|
| 532 |
+
* R5 put the star at the LEFT end of the primary cell and the Expand at the right, deliberately:
|
| 533 |
+
* Airtable keeps a row's own marks in the gutter, and book-ending the cell meant neither control
|
| 534 |
+
* could ever land on the other. That was a real design, it shipped, and the owner has now ruled
|
| 535 |
+
* against it: *"The star label on a record must sit exactly beside and to the LEFT of the record
|
| 536 |
+
* expand icon, on every database."* Beside beats book-ended. The two are now ONE CLUSTER at the
|
| 537 |
+
* right end, and everything below follows from that single fact.
|
| 538 |
+
*
|
| 539 |
+
* β DERIVED FROM THE EXPAND, NOT COMPUTED ALONGSIDE IT. This function asks `expandButtonRect`
|
| 540 |
+
* where its neighbour is and steps left from the answer. That is what makes "beside" a property
|
| 541 |
+
* rather than a coincidence: two independent copies of the same arithmetic drift, and this file
|
| 542 |
+
* exists because that drift is invisible to tsc, to the build and to a screenshot taken at one
|
| 543 |
+
* size ([[ui-invisible-to-assertions]]).
|
| 544 |
+
*
|
| 545 |
+
* β ITS MINIMA ARE THE EXPAND'S NOW, AND THAT REPLACES THE OPPOSITE CLAIM R5 MADE HERE. The old
|
| 546 |
+
* comment argued the star should keep LOWER minima than the Expand, so "a row that cannot carry
|
| 547 |
+
* the Expand can still carry this", and warned that sharing `EXPAND_BTN_MIN_ROW` would hide the
|
| 548 |
+
* star "on exactly the compact row heights a long list is read at". That protection was sound for
|
| 549 |
+
* a mark living at the far end of the cell and is incoherent for one anchored to the Expand: a
|
| 550 |
+
* star placed beside a button that is not there is a mark floating where its neighbour should be.
|
| 551 |
+
* It also protected a case this product cannot produce. `CustomerGrid.ROW_PX` is the whole set of
|
| 552 |
+
* data-row heights and it is `{ short: 28, medium: 34, tall: 48 }` β every one of them clears
|
| 553 |
+
* `EXPAND_BTN_MIN_ROW` (26), so the band the old minima defended (20..25px) is empty. Deleting
|
| 554 |
+
* the second height gate rather than re-tuning it is what makes "both or neither" structural.
|
| 555 |
+
*
|
| 556 |
+
* β THE WIDTH GATE IS THIS FUNCTION'S OWN, AND IT IS DELIBERATELY STRICTER THAN THE EXPAND'S.
|
| 557 |
+
* Two controls plus a readable name need more of the cell than one did, so the star refuses at a
|
| 558 |
+
* width the Expand still accepts. The asymmetry is on purpose and runs only in this direction:
|
| 559 |
+
* item 17 removed the click that used to open a record, so the Expand is the ONLY pointer route
|
| 560 |
+
* to one and must not disappear from a narrow primary column to keep a mark company.
|
| 561 |
+
*
|
| 562 |
+
* `null` when the Expand is absent for any reason, when the cell is too narrow for the pair, or
|
| 563 |
+
* when the star's own rect would fall outside the grid's box β absent rather than clamped, for
|
| 564 |
+
* the reason the Expand is: a clamped `position: fixed` button sits at the edge pointing at a row
|
| 565 |
+
* whose cell is somewhere else.
|
| 566 |
*/
|
| 567 |
export function starButtonRect(
|
| 568 |
primary: { x: number; y: number; width: number; height: number },
|
| 569 |
box?: { x: number; y: number; width: number; height: number },
|
| 570 |
size = STAR_BTN_SIZE,
|
| 571 |
+
gap = STAR_BTN_GAP
|
| 572 |
): { x: number; y: number; size: number } | null {
|
| 573 |
+
// No Expand, no star. The row height gate, the label gate and the box clamp are all inherited
|
| 574 |
+
// from this one call, so the two controls cannot disagree about whether the row carries them.
|
| 575 |
+
const expand = expandButtonRect(primary, box);
|
| 576 |
+
if (!expand) return null;
|
| 577 |
+
// Room for BOTH controls, their gap, the gutter at either side, and a name still worth reading.
|
| 578 |
+
if (primary.width < EXPAND_BTN_SIZE + EXPAND_BTN_INSET * 2 + gap + size + EXPAND_BTN_MIN_LABEL)
|
| 579 |
+
return null;
|
| 580 |
+
const x = expand.x - gap - size;
|
| 581 |
+
// Level with its neighbour BY CONSTRUCTION: the same centre whatever the two sizes are, so
|
| 582 |
+
// "beside" means level and not merely adjacent, and no second centring rule can drift.
|
| 583 |
+
const y = expand.y + Math.round((expand.size - size) / 2);
|
| 584 |
if (box) {
|
| 585 |
if (x < box.x || x + size > box.x + box.width) return null;
|
| 586 |
if (y < box.y || y + size > box.y + box.height) return null;
|
web/src/customer-grid/rowStar.css
CHANGED
|
@@ -12,9 +12,16 @@
|
|
| 12 |
chunk, so the rail painted unstyled for a network round trip.
|
| 13 |
--------------------------------------------------------------------------- */
|
| 14 |
|
| 15 |
-
/* The hover control
|
| 16 |
-
|
| 17 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 18 |
.cg-row-star {
|
| 19 |
position: fixed;
|
| 20 |
z-index: 55;
|
|
|
|
| 12 |
chunk, so the rail painted unstyled for a network round trip.
|
| 13 |
--------------------------------------------------------------------------- */
|
| 14 |
|
| 15 |
+
/* β The hover control IMMEDIATELY TO THE LEFT OF THE EXPAND BUTTON, at the right end of the
|
| 16 |
+
primary cell and level with it β owner instruction 29 (wave 40, 2026-08-24). It REVERSES
|
| 17 |
+
W35-T29 (R5, R6), which deliberately put this mark at the LEFT end so the two book-ended
|
| 18 |
+
the cell; that line stood right here and is gone because the code no longer does it.
|
| 19 |
+
Both are real DOM buttons laid over the canvas at glide's own bounds, so the rect IS the
|
| 20 |
+
hit test and there is no second copy of the geometry to drift from the drawing.
|
| 21 |
+
|
| 22 |
+
β NO GEOMETRY LIVES IN THIS SHEET. `left`/`top`/`width`/`height` are written inline from
|
| 23 |
+
`starButtonRect`, which now derives them from `expandButtonRect` β so the reversal is a
|
| 24 |
+
change of arithmetic, not of style, and nothing here had to move with it. */
|
| 25 |
.cg-row-star {
|
| 26 |
position: fixed;
|
| 27 |
z-index: 55;
|
web/src/customer-grid/types.ts
CHANGED
|
@@ -201,6 +201,81 @@ export const CREATABLE_TYPES: readonly FieldType[] = [
|
|
| 201 |
"ai_enrich",
|
| 202 |
];
|
| 203 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 204 |
/**
|
| 205 |
* β Wave-19 R7 / C5 β THE THREE THINGS AN `image` CELL MAY HOLD, and how each resolves.
|
| 206 |
*
|
|
@@ -3397,6 +3472,35 @@ export interface SavedView {
|
|
| 3397 |
/** C1 β whose view this is, when it is not mine. The username, so it matches what every
|
| 3398 |
* grant is stored against (see `shareModel.parsePeople`'s note on the two shapes). */
|
| 3399 |
owner?: string;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3400 |
/** C4 β the folder this view sits in; null/absent = root. */
|
| 3401 |
folderId?: string | null;
|
| 3402 |
id: string;
|
|
@@ -3477,6 +3581,62 @@ export function allViewName(scope: string): string {
|
|
| 3477 |
return scope === "product" ? "All products" : "All customers";
|
| 3478 |
}
|
| 3479 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3480 |
/**
|
| 3481 |
* The ONE rule for "this view cannot be deleted", mirroring what the host actually enforces
|
| 3482 |
* (`app.py:5410` refuses `view_delete` for `all-customers`). The client hides exactly what
|
|
@@ -3746,7 +3906,10 @@ export function viewEditMode(view: Pick<SavedView, "permissions">): ViewEditMode
|
|
| 3746 |
* at the host, not merely hidden here.
|
| 3747 |
*/
|
| 3748 |
export function mayEditView(
|
| 3749 |
-
|
|
|
|
|
|
|
|
|
|
| 3750 |
viewer: Viewer | undefined
|
| 3751 |
): boolean {
|
| 3752 |
/**
|
|
@@ -3772,6 +3935,31 @@ export function mayEditView(
|
|
| 3772 |
* ONE place, three consumers: the rail's row menu, the rail's drag, and the grid's own
|
| 3773 |
* delete/config-write guards all ask this function. Putting the rule in any one of them
|
| 3774 |
* would leave the other two offering an edit the server refuses.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3775 |
*/
|
| 3776 |
if (view.shared && (view.sharedRole ?? "view") !== "edit") return false;
|
| 3777 |
const mode = viewEditMode(view);
|
|
|
|
| 201 |
"ai_enrich",
|
| 202 |
];
|
| 203 |
|
| 204 |
+
/**
|
| 205 |
+
* ββ W40-T29 (owner instruction 31) β WHICH CREATE KINDS READ AS ADVANCED. Three of them, and
|
| 206 |
+
* the whole discipline of this block is that the answer is a PRESENTATION grouping and nothing
|
| 207 |
+
* else.
|
| 208 |
+
*
|
| 209 |
+
* β THE LIST ABOVE IS NOT PARTITIONED, AND MUST NEVER BE. `CREATABLE_TYPES` is one half of a
|
| 210 |
+
* cross-language contract `verify_fields_contract.py` diffs against `aios_grid.CUSTOM_FIELD_TYPES`,
|
| 211 |
+
* and the `json` scar recorded in its own comment is exactly what happens when a type reaches every
|
| 212 |
+
* table except that one: real, documented, unreachable, with every individual file internally
|
| 213 |
+
* consistent. Lifting `automation` and `json` out of it into an "advanced list" would reproduce
|
| 214 |
+
* that failure deliberately. So the grouping is applied to the ROWS the picker has already built,
|
| 215 |
+
* at render time, and the contract array is READ, never rewritten.
|
| 216 |
+
*
|
| 217 |
+
* β `automation` and `json` are typed `FieldType`, so a typo fails `tsc`. `geocode` cannot be:
|
| 218 |
+
* it is a PSEUDO-KIND (see `Field.geocode` for why five vocabularies stay untouched by it) and no
|
| 219 |
+
* compiler can hold it. The asymmetry is honest rather than an oversight, and it is the reason the
|
| 220 |
+
* exported set below is `string[]` while its first half is not.
|
| 221 |
+
*/
|
| 222 |
+
const ADVANCED_FIELD_KINDS: readonly FieldType[] = ["automation", "json"];
|
| 223 |
+
|
| 224 |
+
/** The advanced set the picker groups on: the two real types above plus the geocode pseudo-kind,
|
| 225 |
+
* which joins by VALUE because it cannot join by type. */
|
| 226 |
+
export const ADVANCED_CREATE_KINDS: readonly string[] = [...ADVANCED_FIELD_KINDS, "geocode"];
|
| 227 |
+
|
| 228 |
+
/**
|
| 229 |
+
* The group's heading. ONE WORD: `DESIGN.md` Β§4 forbids over-explaining, so the list does not get
|
| 230 |
+
* a sentence about what makes a type advanced.
|
| 231 |
+
* β Not "ADVANCED" β `CLAUDE.md` bans ALL-CAPS app chrome. The owner spelled it in capitals in
|
| 232 |
+
* instruction 31; that is emphasis in prose, not a label.
|
| 233 |
+
*/
|
| 234 |
+
export const ADVANCED_TYPES_HEADING = "Advanced";
|
| 235 |
+
|
| 236 |
+
/** A run of field-type picker rows under an optional heading. `heading: null` is the ordinary
|
| 237 |
+
* group, deliberately unlabelled: naming the majority case is chrome nobody reads, and the
|
| 238 |
+
* divider under it already says where the ordinary list ends. */
|
| 239 |
+
export interface TypePickerGroup<T> {
|
| 240 |
+
heading: string | null;
|
| 241 |
+
rows: T[];
|
| 242 |
+
}
|
| 243 |
+
|
| 244 |
+
/**
|
| 245 |
+
* ββ W40-T29 β split a flat field-type picker list into the ordinary rows and the advanced ones.
|
| 246 |
+
*
|
| 247 |
+
* It lives in this file, and not in `ColumnMenu.tsx` where it is rendered, for the reason
|
| 248 |
+
* `display.ts`'s header states at length: `ColumnMenu.tsx` imports React and therefore cannot be
|
| 249 |
+
* LOADED by the node gates, so a rule stated inside JSX is a rule no gate can run. `columnDefinitionOffer`
|
| 250 |
+
* had to settle for `display.ts` because this file was held by another lane that wave; the two
|
| 251 |
+
* belong together and this one made it home.
|
| 252 |
+
*
|
| 253 |
+
* β A STABLE PARTITION, NEVER A SORT. Each group keeps the order it was handed, so the ordinary
|
| 254 |
+
* group reads in `CREATABLE_TYPES`' own order and the advanced group in the order those three
|
| 255 |
+
* happen to sit in the caller's list. Re-ordering here would be a second opinion about a
|
| 256 |
+
* vocabulary that already has an owner, and the day someone reorders the contract array the
|
| 257 |
+
* picker would silently disagree with it.
|
| 258 |
+
*
|
| 259 |
+
* β AN EMPTY GROUP IS OMITTED ENTIRELY, and that is R8's fake-affordance rule rather than
|
| 260 |
+
* tidiness: the caller filters this list through a find box, so typing "text" empties the advanced
|
| 261 |
+
* group, and a heading left standing over nothing is a label with nothing behind it. Deciding it
|
| 262 |
+
* here rather than in JSX is also what makes the behaviour runnable by a node gate instead of
|
| 263 |
+
* being an accident of a CSS `:empty` selector.
|
| 264 |
+
*/
|
| 265 |
+
export function groupTypePickerRows<T extends { value: string }>(
|
| 266 |
+
rows: readonly T[]
|
| 267 |
+
): TypePickerGroup<T>[] {
|
| 268 |
+
const ordinary: T[] = [];
|
| 269 |
+
const advanced: T[] = [];
|
| 270 |
+
for (const row of rows) {
|
| 271 |
+
(ADVANCED_CREATE_KINDS.includes(row.value) ? advanced : ordinary).push(row);
|
| 272 |
+
}
|
| 273 |
+
const out: TypePickerGroup<T>[] = [];
|
| 274 |
+
if (ordinary.length) out.push({ heading: null, rows: ordinary });
|
| 275 |
+
if (advanced.length) out.push({ heading: ADVANCED_TYPES_HEADING, rows: advanced });
|
| 276 |
+
return out;
|
| 277 |
+
}
|
| 278 |
+
|
| 279 |
/**
|
| 280 |
* β Wave-19 R7 / C5 β THE THREE THINGS AN `image` CELL MAY HOLD, and how each resolves.
|
| 281 |
*
|
|
|
|
| 3472 |
/** C1 β whose view this is, when it is not mine. The username, so it matches what every
|
| 3473 |
* grant is stored against (see `shareModel.parsePeople`'s note on the two shapes). */
|
| 3474 |
owner?: string;
|
| 3475 |
+
/**
|
| 3476 |
+
* ββ WAVE 40 Β· AM-5 (owner instruction 2) β THIS VIEW HAS GRANTS, WHOEVER IS ASKING.
|
| 3477 |
+
*
|
| 3478 |
+
* Viewer-INDEPENDENT, and it is what draws the share mark. C1 was written as "redefine
|
| 3479 |
+
* `shared` to mean this view has grants"; AM-5 settles it as a NEW key instead, because
|
| 3480 |
+
* redefining `shared` would have locked an owner out of their own view through
|
| 3481 |
+
* `mayEditView` and moved it into the recipient's "Shared with me" group. So `shared`
|
| 3482 |
+
* keeps meaning "granted TO me" and this means "somebody can see this".
|
| 3483 |
+
*
|
| 3484 |
+
* β ABSENCE IS THE NEGATIVE. Nothing is ever stamped `false`; a view with no grants
|
| 3485 |
+
* simply carries neither key. Produced by `platform/core/grid_events.py::_grant_marker`
|
| 3486 |
+
* on all three merge legs from one predicate, and derived on every read from the grant
|
| 3487 |
+
* registry rather than stored.
|
| 3488 |
+
*
|
| 3489 |
+
* β IT DOES NOT IMPLY `sharedRole`. A view living BOTH in the legacy `__shared__` bucket
|
| 3490 |
+
* and in the grant registry reaches the recipient with `hasShares` and no role stamp,
|
| 3491 |
+
* because the bucket leg outranks the granted copy. `viewShareMark` has a third branch
|
| 3492 |
+
* for exactly that, and it must not be collapsed into the other two.
|
| 3493 |
+
*/
|
| 3494 |
+
hasShares?: boolean;
|
| 3495 |
+
/**
|
| 3496 |
+
* β WAVE 40 Β· AM-5 β THIS ACCOUNT IS THE ONE SHARING IT OUT.
|
| 3497 |
+
*
|
| 3498 |
+
* Only ever on the sharer's copy, which is how the owner's tooltip can read as sharing OUT
|
| 3499 |
+
* without reusing the receiver wording C1 forbids. Unconditional on the caller's own
|
| 3500 |
+
* stratum, `createdBy == uname` on the `__shared__` leg, and NEVER on a view arriving
|
| 3501 |
+
* through `_granted_views`.
|
| 3502 |
+
*/
|
| 3503 |
+
sharedOut?: boolean;
|
| 3504 |
/** C4 β the folder this view sits in; null/absent = root. */
|
| 3505 |
folderId?: string | null;
|
| 3506 |
id: string;
|
|
|
|
| 3581 |
return scope === "product" ? "All products" : "All customers";
|
| 3582 |
}
|
| 3583 |
|
| 3584 |
+
/**
|
| 3585 |
+
* ββ WAVE 40 Β· T28 (owner instruction 30) β WHAT THE PINNED SYSTEM VIEW IS CALLED ON SCREEN.
|
| 3586 |
+
*
|
| 3587 |
+
* Owner: *"Rename 'All customers' and every other undeletable default view to 'Default view'."*
|
| 3588 |
+
* Per assumption A2 that is the PER-DATABASE default ONLY. `UNDELETABLE_VIEW_IDS` holds three
|
| 3589 |
+
* ids, and renaming all three would put three rows reading "Default view" in one rail, which is
|
| 3590 |
+
* a worse rail than the one the instruction is fixing. Starred and IG Overview keep the names
|
| 3591 |
+
* their own servers mint; they pin to the top beside this one and are told apart by their names.
|
| 3592 |
+
*/
|
| 3593 |
+
export const DEFAULT_VIEW_NAME = "Default view";
|
| 3594 |
+
|
| 3595 |
+
/**
|
| 3596 |
+
* β THE HOST'S OWN MINTS, DERIVED RATHER THAN RE-SPELLED, so the three nouns keep exactly one
|
| 3597 |
+
* home on this side of the wire. `aios_grid.views_from_defs(system_name=β¦)` produces the same
|
| 3598 |
+
* three strings; this set is what {@link viewDisplayName} recognises as "still the mint, nobody
|
| 3599 |
+
* has renamed it".
|
| 3600 |
+
*/
|
| 3601 |
+
const SYSTEM_VIEW_MINTS = new Set([
|
| 3602 |
+
allViewName("customer"),
|
| 3603 |
+
allViewName("product"),
|
| 3604 |
+
allViewName("ut_"),
|
| 3605 |
+
]);
|
| 3606 |
+
|
| 3607 |
+
/**
|
| 3608 |
+
* ββ WAVE 40 Β· T28 β the name to PAINT for a view, which is not always the name stored on it.
|
| 3609 |
+
*
|
| 3610 |
+
* β A DISPLAY RULE, NOT A RENAME, and that distinction is the whole reason this function exists
|
| 3611 |
+
* instead of a changed `allViewName`. `views_from_defs` still mints the system view as "All
|
| 3612 |
+
* customers" / "All products" / "All records", and that host half is in NO lane's fence this
|
| 3613 |
+
* wave. A client that minted a different string would disagree with the echo and repaint the
|
| 3614 |
+
* rail on every workspace arrival β the flicker `allViewName`'s own note refuses one paragraph
|
| 3615 |
+
* up. Resolving at the point of PAINT collapses both spellings onto ONE output, so the rail
|
| 3616 |
+
* shows the same characters whether the name came from this browser's mint or from the host's
|
| 3617 |
+
* echo, and there is no frame in which the two differ. When the host half lands, "Default view"
|
| 3618 |
+
* is not in the mint set and passes through verbatim, so the two stay in step through the change.
|
| 3619 |
+
*
|
| 3620 |
+
* β IT MUST NOT CLOBBER A USER'S RENAME, and `all-customers` really IS renamable β this was
|
| 3621 |
+
* checked rather than assumed. `grid_events.py`'s `view_upsert` exempts it from the reserved-name
|
| 3622 |
+
* list by id (`if view_id != 'all-customers'`), and a saved record under the pinned id REPLACES
|
| 3623 |
+
* the projection through the ordinary saved-config overlay, so a rename of the default view
|
| 3624 |
+
* persists and means what it says. The override therefore fires only while the stored name is
|
| 3625 |
+
* STILL one of the mints β or empty, which is what a half-assembled workspace carries. Anything
|
| 3626 |
+
* a person typed passes through unchanged.
|
| 3627 |
+
*
|
| 3628 |
+
* β SCOPE-FREE, deliberately. The rail has no `scope` prop, and threading one in would give this
|
| 3629 |
+
* decision two homes; more importantly a stale echo carrying another topic's noun must still
|
| 3630 |
+
* resolve, rather than leaking "All records" onto a customer rail for one round trip.
|
| 3631 |
+
*
|
| 3632 |
+
* β ONLY `ALL_VIEW_ID`. A2 in one line: every other id, undeletable or not, keeps its own name.
|
| 3633 |
+
*/
|
| 3634 |
+
export function viewDisplayName(view: Pick<SavedView, "id" | "name">): string {
|
| 3635 |
+
if (view.id !== ALL_VIEW_ID) return view.name;
|
| 3636 |
+
const stored = view.name ?? "";
|
| 3637 |
+
return stored === "" || SYSTEM_VIEW_MINTS.has(stored) ? DEFAULT_VIEW_NAME : stored;
|
| 3638 |
+
}
|
| 3639 |
+
|
| 3640 |
/**
|
| 3641 |
* The ONE rule for "this view cannot be deleted", mirroring what the host actually enforces
|
| 3642 |
* (`app.py:5410` refuses `view_delete` for `all-customers`). The client hides exactly what
|
|
|
|
| 3906 |
* at the host, not merely hidden here.
|
| 3907 |
*/
|
| 3908 |
export function mayEditView(
|
| 3909 |
+
// `owner` joined this Pick with wave 40's C1 and STAYS, although the guard below no longer
|
| 3910 |
+
// reads it: the field is part of what a caller must be able to hand this function, and
|
| 3911 |
+
// narrowing the type back would be a second change with its own blast radius.
|
| 3912 |
+
view: Pick<SavedView, "permissions" | "createdBy" | "shared" | "sharedRole" | "owner">,
|
| 3913 |
viewer: Viewer | undefined
|
| 3914 |
): boolean {
|
| 3915 |
/**
|
|
|
|
| 3935 |
* ONE place, three consumers: the rail's row menu, the rail's drag, and the grid's own
|
| 3936 |
* delete/config-write guards all ask this function. Putting the rule in any one of them
|
| 3937 |
* would leave the other two offering an edit the server refuses.
|
| 3938 |
+
*
|
| 3939 |
+
* ββ WAVE 40 Β· CONTRACT C1 (owner instruction 2) β THIS GUARD BRIEFLY READ
|
| 3940 |
+
* `view.shared && view.owner && β¦`, AND THE `&& view.owner` IS GONE AGAIN. Recorded rather
|
| 3941 |
+
* than quietly reverted, because the reasoning that added it was sound and only its PREMISE
|
| 3942 |
+
* was wrong, and the next person reading C1 will reach for it again.
|
| 3943 |
+
*
|
| 3944 |
+
* The premise was that C1 would REDEFINE `shared` to mean "this view has grants" and stamp it
|
| 3945 |
+
* on the sharer's own leg too. On such a leg there is no `sharedRole` (ownership is not a
|
| 3946 |
+
* grant), `?? "view"` would read read-only, and this line would have locked an owner out of
|
| 3947 |
+
* every view they had ever shared. `owner` was added as the discriminator, since it already
|
| 3948 |
+
* means "whose view this is, WHEN IT IS NOT MINE".
|
| 3949 |
+
*
|
| 3950 |
+
* β BUT `shared` WAS NEVER REDEFINED. AM-5 settles C1 the other way: the marker is a NEW
|
| 3951 |
+
* key, `hasShares`, and `shared` / `sharedRole` / `owner` keep meaning "granted TO me, and on
|
| 3952 |
+
* what terms". Verified in the server, not inferred: `core/grid_events.py` writes `shared` on
|
| 3953 |
+
* exactly two lines, both inside `_granted_views`, both after `if owner == uname: continue`,
|
| 3954 |
+
* and both stamping `sharedRole` and `owner` in the same three statements. The sharer's own
|
| 3955 |
+
* leg gets `hasShares` and `sharedOut` and NEVER `shared`.
|
| 3956 |
+
*
|
| 3957 |
+
* β SO THE EXTRA CONDITION PROTECTED AGAINST NOTHING AND COST A FAIL-CLOSED CHECK. With it,
|
| 3958 |
+
* any `shared` view reaching the client without an `owner` fell through and read as EDITABLE.
|
| 3959 |
+
* `folders.test` had asserted the opposite since wave 21 and went red on all four of its C1
|
| 3960 |
+
* legs β "a view-role share is NOT editable", "β¦not by an ADMIN either", "β¦and not via the
|
| 3961 |
+
* unstamped-createdBy escape hatch", "a shared view with NO role reads as read-only". The
|
| 3962 |
+
* gate was right. Read those four names as this line's negative control.
|
| 3963 |
*/
|
| 3964 |
if (view.shared && (view.sharedRole ?? "view") !== "edit") return false;
|
| 3965 |
const mode = viewEditMode(view);
|
web/src/customer-grid/useGridColumns.ts
CHANGED
|
@@ -1,9 +1,11 @@
|
|
| 1 |
import { useCallback, useMemo } from "react";
|
| 2 |
import type { GridColumn, Theme } from "@glideapps/glide-data-grid";
|
| 3 |
import type { Field, FilterNode, ViewConfig } from "./types";
|
| 4 |
-
import { isFilterGroup, isRuleActive, measureColumnIndex,
|
|
|
|
| 5 |
import { typeIconName } from "./iconShapes";
|
| 6 |
-
import { fitHeaderTitle,
|
|
|
|
| 7 |
import { COLUMN_TONE_THEME, INVOLVED_HEADER_FONT, lightTheme } from "./theme";
|
| 8 |
import type { ControlTone } from "./theme";
|
| 9 |
|
|
@@ -54,12 +56,66 @@ function measureHeaderText(text: string, bold = false): number {
|
|
| 54 |
return ctx ? ctx.measureText(text).width : 0;
|
| 55 |
}
|
| 56 |
|
| 57 |
-
/** The (i) is drawn for exactly this condition
|
| 58 |
-
* same one from the same field, so the reserve and the mark can never disagree. */
|
| 59 |
function hasInfoMark(field: Field): boolean {
|
| 60 |
return !!(field.note || field.description);
|
| 61 |
}
|
| 62 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 63 |
/** Every column key an ACTIVE filter rule names, anywhere in the tree. Inactive (half-typed)
|
| 64 |
* rules are skipped: a rule that is not narrowing anything must not tint a column as though
|
| 65 |
* it were β that is the same "it looks like it is working" lie the engine refuses to tell.
|
|
@@ -297,10 +353,11 @@ export function useGridColumns(
|
|
| 297 |
// Wave-14 item 2 β an INVOLVED column's header paints at 700, so it must be MEASURED
|
| 298 |
// at 700. `tones` is already a dep of this memo, so this costs nothing.
|
| 299 |
const involved = tones.has(key);
|
| 300 |
-
// R11 β the marks this header carries, in the strip's canonical order.
|
| 301 |
-
// reserve and `CustomerGrid.drawGridHeader`'s painting
|
| 302 |
-
// column
|
| 303 |
-
|
|
|
|
| 304 |
return {
|
| 305 |
id: key,
|
| 306 |
// Owner item 16 β ELLIPSISED so the title can never run under the (i). Glide
|
|
@@ -310,9 +367,13 @@ export function useGridColumns(
|
|
| 310 |
// clipping inside `drawHeader`, cuts mid-glyph with no ellipsis to say it did.
|
| 311 |
// The FULL name stays reachable: CustomerGrid's header tip leads with it whenever
|
| 312 |
// this returns something shorter than `field.label`.
|
|
|
|
|
|
|
|
|
|
|
|
|
| 313 |
title: fitHeaderTitle(
|
| 314 |
field.label,
|
| 315 |
-
headerLabelSpace(width, marks),
|
| 316 |
(text) => measureHeaderText(text, involved)
|
| 317 |
),
|
| 318 |
width,
|
|
|
|
| 1 |
import { useCallback, useMemo } from "react";
|
| 2 |
import type { GridColumn, Theme } from "@glideapps/glide-data-grid";
|
| 3 |
import type { Field, FilterNode, ViewConfig } from "./types";
|
| 4 |
+
import { isFilterGroup, isMachineOwned, isRuleActive, measureColumnIndex,
|
| 5 |
+
ruleColumnKeys } from "./types";
|
| 6 |
import { typeIconName } from "./iconShapes";
|
| 7 |
+
import { fitHeaderTitle, hasShareMark, HEADER_MENU_SLOT, headerLabelSpace,
|
| 8 |
+
headerMarkSizes } from "./overlayPlacement";
|
| 9 |
import { COLUMN_TONE_THEME, INVOLVED_HEADER_FONT, lightTheme } from "./theme";
|
| 10 |
import type { ControlTone } from "./theme";
|
| 11 |
|
|
|
|
| 56 |
return ctx ? ctx.measureText(text).width : 0;
|
| 57 |
}
|
| 58 |
|
| 59 |
+
/** The (i) is drawn for exactly this condition. */
|
|
|
|
| 60 |
function hasInfoMark(field: Field): boolean {
|
| 61 |
return !!(field.note || field.description);
|
| 62 |
}
|
| 63 |
|
| 64 |
+
/**
|
| 65 |
+
* The user-created-field DOT's condition β owner item 4 (2026-08-06): *"why is the Field still
|
| 66 |
+
* have the Dot at the header to mark its a custom editable field?"*
|
| 67 |
+
*
|
| 68 |
+
* β `!isMachineOwned` is half of the rule, and it is the half that USED TO BE MISSING FROM THIS
|
| 69 |
+
* FILE. `source === "overlay"` alone is true of every column in a `ut_*` database, including the
|
| 70 |
+
* ones an automation spawns and fills, so the reserve kept room for a dot the drawer refused to
|
| 71 |
+
* paint. Nothing went red: over-reserving only shortens a title slightly, which is why it sat
|
| 72 |
+
* here through two waves. It is fixed by DELETION of the second copy, not by a second correction
|
| 73 |
+
* that could drift again β see `headerMarksFor`.
|
| 74 |
+
*/
|
| 75 |
+
function hasCustomMark(field: Field): boolean {
|
| 76 |
+
return field.source === "overlay" && !isMachineOwned(field);
|
| 77 |
+
}
|
| 78 |
+
|
| 79 |
+
/**
|
| 80 |
+
* β W40-T20 β THE header mark strip a field carries, resolved ONCE for both of its readers: this
|
| 81 |
+
* module's truncation RESERVE and `CustomerGrid.drawGridHeader`'s PAINTING.
|
| 82 |
+
*
|
| 83 |
+
* β WHY IT IS A FUNCTION AND NOT A COMMENT. What stood here before was the claim *"both this
|
| 84 |
+
* reserve and drawGridHeader's painting read `headerMarkSizes`, so a column can never reserve
|
| 85 |
+
* room for one mark and then be given two"* β and it was FALSE IN TWO WAYS at once. The two call
|
| 86 |
+
* sites each resolved the booleans themselves, and they had already diverged on the dot
|
| 87 |
+
* (`hasCustomMark` above); adding the share mark would have diverged them a second time, on the
|
| 88 |
+
* mark whose whole purpose is to sit INNERMOST, i.e. exactly where a wrong reserve lets a title
|
| 89 |
+
* paint through a glyph. A shared resolver is the only version of that sentence that stays true
|
| 90 |
+
* when the next mark is added.
|
| 91 |
+
*
|
| 92 |
+
* β `droppable` TRAVELS WITH `sizes` for the same reason. They are two halves of one answer:
|
| 93 |
+
* reserving for a strip of three while the drawer paints two puts the label's right edge in the
|
| 94 |
+
* wrong place, and reserving for three while the drawer ALSO refuses all three (the `droppable`
|
| 95 |
+
* mismatch) returns `null`, which means "do not truncate at all" and paints the full label
|
| 96 |
+
* straight through both surviving marks. Passing one without the other is worse than passing
|
| 97 |
+
* neither, so neither is passed alone.
|
| 98 |
+
*/
|
| 99 |
+
export function headerMarksFor(field: Field): {
|
| 100 |
+
info: boolean;
|
| 101 |
+
custom: boolean;
|
| 102 |
+
shared: boolean;
|
| 103 |
+
sizes: number[];
|
| 104 |
+
droppable: number;
|
| 105 |
+
} {
|
| 106 |
+
const info = hasInfoMark(field);
|
| 107 |
+
const custom = hasCustomMark(field);
|
| 108 |
+
const shared = hasShareMark(field);
|
| 109 |
+
return {
|
| 110 |
+
info,
|
| 111 |
+
custom,
|
| 112 |
+
shared,
|
| 113 |
+
sizes: headerMarkSizes(info, custom, shared),
|
| 114 |
+
// Only the share mark may be given up, and only because it is innermost. See `headerMarkFit`.
|
| 115 |
+
droppable: shared ? 1 : 0,
|
| 116 |
+
};
|
| 117 |
+
}
|
| 118 |
+
|
| 119 |
/** Every column key an ACTIVE filter rule names, anywhere in the tree. Inactive (half-typed)
|
| 120 |
* rules are skipped: a rule that is not narrowing anything must not tint a column as though
|
| 121 |
* it were β that is the same "it looks like it is working" lie the engine refuses to tell.
|
|
|
|
| 353 |
// Wave-14 item 2 β an INVOLVED column's header paints at 700, so it must be MEASURED
|
| 354 |
// at 700. `tones` is already a dep of this memo, so this costs nothing.
|
| 355 |
const involved = tones.has(key);
|
| 356 |
+
// R11 / W40-T20 β the marks this header carries, in the strip's canonical order. This
|
| 357 |
+
// reserve and `CustomerGrid.drawGridHeader`'s painting call the SAME resolver, so a
|
| 358 |
+
// column cannot reserve room for one strip and then be given a different one. That is
|
| 359 |
+
// a property of `headerMarksFor` being one function, not of two call sites agreeing.
|
| 360 |
+
const marks = headerMarksFor(field);
|
| 361 |
return {
|
| 362 |
id: key,
|
| 363 |
// Owner item 16 β ELLIPSISED so the title can never run under the (i). Glide
|
|
|
|
| 367 |
// clipping inside `drawHeader`, cuts mid-glyph with no ellipsis to say it did.
|
| 368 |
// The FULL name stays reachable: CustomerGrid's header tip leads with it whenever
|
| 369 |
// this returns something shorter than `field.label`.
|
| 370 |
+
// β W40-T20 β `menuSlotWidth` is passed EXPLICITLY so `droppable` can be. It is the
|
| 371 |
+
// constant that was already defaulting here, so the number is unchanged; what changes
|
| 372 |
+
// is that the reserve now clears the marks the drawer actually paints rather than the
|
| 373 |
+
// ones it was asked for.
|
| 374 |
title: fitHeaderTitle(
|
| 375 |
field.label,
|
| 376 |
+
headerLabelSpace(width, marks.sizes, HEADER_MENU_SLOT, marks.droppable),
|
| 377 |
(text) => measureHeaderText(text, involved)
|
| 378 |
),
|
| 379 |
width,
|
web/src/filter-kit/FieldsHidePanel.tsx
CHANGED
|
@@ -14,7 +14,9 @@
|
|
| 14 |
// ---------------------------------------------------------------------------
|
| 15 |
|
| 16 |
import { useState } from "react";
|
| 17 |
-
|
|
|
|
|
|
|
| 18 |
// β WAVE 30 item 2 (R5) β `fieldLabel` is the ONE resolver for a field's NAME, and every read
|
| 19 |
// of `f.label` in this file goes through it. `Field.label` is declared `string` and arrives
|
| 20 |
// over the WIRE, where nothing enforces that; the search filter below did
|
|
@@ -28,12 +30,25 @@ import type { Field } from "../customer-grid/types";
|
|
| 28 |
import { fieldEditMode, fieldLabel, isPresetField } from "../customer-grid/types";
|
| 29 |
import { FieldTypeIcon } from "../customer-grid/icons";
|
| 30 |
import { TYPE_LABELS } from "../customer-grid/iconShapes";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 31 |
|
| 32 |
export interface FieldsHidePanelProps {
|
| 33 |
/** Owner item 23 β in the view's COLUMN ORDER, not definition order. Dragging a row here
|
| 34 |
* rewrites `config.order`, so a list showing a different sequence from the one it edits
|
| 35 |
-
* would move a field to a position the user never pointed at.
|
| 36 |
-
|
|
|
|
|
|
|
|
|
|
| 37 |
/** The keys that are HIDDEN. Every field not named here renders as shown. */
|
| 38 |
hidden: ReadonlySet<string>;
|
| 39 |
onToggle: (key: string) => void;
|
|
@@ -52,6 +67,27 @@ export interface FieldsHidePanelProps {
|
|
| 52 |
* affordance renders for them at all. */
|
| 53 |
deletableKeys?: ReadonlySet<string>;
|
| 54 |
onDeleteField?: (key: string) => void;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 55 |
}
|
| 56 |
|
| 57 |
/**
|
|
@@ -72,6 +108,10 @@ export function FieldsHidePanel({
|
|
| 72 |
onFieldOrder,
|
| 73 |
deletableKeys,
|
| 74 |
onDeleteField,
|
|
|
|
|
|
|
|
|
|
|
|
|
| 75 |
}: FieldsHidePanelProps) {
|
| 76 |
const [query, setQuery] = useState("");
|
| 77 |
/** W9 β destructive, so the trash arms first (the grid's confirm pattern): first
|
|
@@ -83,16 +123,52 @@ export function FieldsHidePanel({
|
|
| 83 |
* that slot. */
|
| 84 |
const [dragKey, setDragKey] = useState<string | null>(null);
|
| 85 |
const [overKey, setOverKey] = useState<string | null>(null);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 86 |
const q = query.trim().toLowerCase();
|
| 87 |
-
const shown = q ? fields.filter((f) =>
|
| 88 |
-
|
| 89 |
-
|
| 90 |
-
|
| 91 |
-
|
| 92 |
-
|
| 93 |
-
|
| 94 |
-
|
| 95 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 96 |
/**
|
| 97 |
* Item 23 β reorder is OFF while a search is narrowing the list. Dropping "City" above
|
| 98 |
* "State" in a list that is hiding the eight fields between them means nothing the user can
|
|
@@ -209,10 +285,10 @@ export function FieldsHidePanel({
|
|
| 209 |
draggable={canReorder && !locked}
|
| 210 |
aria-label={
|
| 211 |
locked
|
| 212 |
-
? `${
|
| 213 |
: canReorder
|
| 214 |
-
? `Reorder ${
|
| 215 |
-
: `Reorder ${
|
| 216 |
}
|
| 217 |
title={
|
| 218 |
canReorder && !locked
|
|
@@ -262,7 +338,7 @@ export function FieldsHidePanel({
|
|
| 262 |
draws (icons.tsx). Titled, because this list is where the icon
|
| 263 |
vocabulary is learned. */}
|
| 264 |
<FieldTypeIcon type={f.type} title={TYPE_LABELS[f.type]} />
|
| 265 |
-
<span className="cg-check-label">{
|
| 266 |
{/* β OWNER ITEM 3 (2026-08-06): *"it doesn't show pre-set when I hide fields just
|
| 267 |
like how Odoo fields are. This is always the standard label."* Right β the chip
|
| 268 |
asked `source === "odoo"`, so a column an AUTOMATION fills (source `overlay`)
|
|
@@ -283,7 +359,7 @@ export function FieldsHidePanel({
|
|
| 283 |
type="button"
|
| 284 |
className={"cg-check-del" + (armed ? " is-armed" : "")}
|
| 285 |
aria-label={
|
| 286 |
-
armed ? `Permanently delete ${
|
| 287 |
}
|
| 288 |
title={armed ? undefined : "Removes this field and its values on every row."}
|
| 289 |
onClick={(e) => {
|
|
@@ -317,7 +393,24 @@ export function FieldsHidePanel({
|
|
| 317 |
})}
|
| 318 |
</div>
|
| 319 |
))}
|
| 320 |
-
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 321 |
<div className="cg-builder-empty">No field matches your search.</div>
|
| 322 |
)}
|
| 323 |
</div>
|
|
|
|
| 14 |
// ---------------------------------------------------------------------------
|
| 15 |
|
| 16 |
import { useState } from "react";
|
| 17 |
+
// β W40-T16 β the bare `Field` type import is GONE, not misplaced: the prop below is
|
| 18 |
+
// `PermsField[]` now, which extends it, so importing both would leave one unread and
|
| 19 |
+
// `tsconfig.app.json`'s `noUnusedLocals` reds the build on exactly that.
|
| 20 |
// β WAVE 30 item 2 (R5) β `fieldLabel` is the ONE resolver for a field's NAME, and every read
|
| 21 |
// of `f.label` in this file goes through it. `Field.label` is declared `string` and arrives
|
| 22 |
// over the WIRE, where nothing enforces that; the search filter below did
|
|
|
|
| 30 |
import { fieldEditMode, fieldLabel, isPresetField } from "../customer-grid/types";
|
| 31 |
import { FieldTypeIcon } from "../customer-grid/icons";
|
| 32 |
import { TYPE_LABELS } from "../customer-grid/iconShapes";
|
| 33 |
+
// ββ W40-T16 (owner instruction 13) β A METRIC IS A ROW LIKE ANY OTHER, and the ONE thing that
|
| 34 |
+
// makes it read differently is its NAME. `metricLabel` is that rule, declared once beside the
|
| 35 |
+
// flag it depends on, and it is a pure string function so this panel does not acquire a runtime
|
| 36 |
+
// dependency on anything the permission editor fetches or holds.
|
| 37 |
+
// β THE FIRST IMPORT FROM `settings/**` INTO THE KIT, and it is deliberately the leaf:
|
| 38 |
+
// `permsModel.ts` imports nothing at runtime (its only import is `import type`), so the module
|
| 39 |
+
// graph stays acyclic and `verify_ui.py`'s render smoke β which mounts `PermsEditor` and reaches
|
| 40 |
+
// this file through it β still resolves under bare node.
|
| 41 |
+
import type { PermsField } from "../settings/permsModel";
|
| 42 |
+
import { metricLabel, presetHideFields } from "../settings/permsModel";
|
| 43 |
|
| 44 |
export interface FieldsHidePanelProps {
|
| 45 |
/** Owner item 23 β in the view's COLUMN ORDER, not definition order. Dragging a row here
|
| 46 |
* rewrites `config.order`, so a list showing a different sequence from the one it edits
|
| 47 |
+
* would move a field to a position the user never pointed at.
|
| 48 |
+
* β W40-T16 β `PermsField[]`, which is `Field` plus an OPTIONAL metric flag. The grid
|
| 49 |
+
* toolbar keeps passing `Field[]` and keeps compiling, because an optional extra key makes
|
| 50 |
+
* the two assignable; its fields never carry the flag, so no metric row can appear there. */
|
| 51 |
+
fields: PermsField[];
|
| 52 |
/** The keys that are HIDDEN. Every field not named here renders as shown. */
|
| 53 |
hidden: ReadonlySet<string>;
|
| 54 |
onToggle: (key: string) => void;
|
|
|
|
| 67 |
* affordance renders for them at all. */
|
| 68 |
deletableKeys?: ReadonlySet<string>;
|
| 69 |
onDeleteField?: (key: string) => void;
|
| 70 |
+
/**
|
| 71 |
+
* ββ W40-T17 (owner instruction 15) β DOES THIS MOUNT FILE ROWS UNDER "Shared with me" AND
|
| 72 |
+
* "Shared with everyone"? Absent means YES, which is the grid's behaviour and every behaviour
|
| 73 |
+
* this panel has ever had. The manage-user permission editor passes `false`, because a
|
| 74 |
+
* permission is set on the database's own pre-set columns and on nothing else: owner, verbatim,
|
| 75 |
+
* *"stop displaying 'Shared with me' / 'Shared with everyone' fields under Hide Fields -
|
| 76 |
+
* permission on pre-set Fields only."*
|
| 77 |
+
*
|
| 78 |
+
* β A PROP WITH A SAFE DEFAULT, NEVER AN UNCONDITIONAL REMOVAL, AND THE REASON IS THAT THIS
|
| 79 |
+
* PANEL SERVES TWO MOUNTS. `customer-grid/Toolbar.tsx` mounts it for the grid, where the two
|
| 80 |
+
* sections were ADDED on purpose by the 2026-08-21 hotfix and are what a user reads to tell
|
| 81 |
+
* their own columns from the tenant's. Deleting them here would silently take a shipped
|
| 82 |
+
* affordance off a surface this ticket never looked at, and no diff of the permission editor
|
| 83 |
+
* would show it. The grid passes nothing and is therefore untouched, byte for byte.
|
| 84 |
+
*
|
| 85 |
+
* β `false` DOES NOT MERELY DROP TWO SECTIONS. It swaps the whole membership question for
|
| 86 |
+
* AM-2's: `permsModel::presetHideFields`, i.e. `metric || !custom`. Filing the same rows under
|
| 87 |
+
* one untitled heading would still list somebody's personal column as a thing an admin can
|
| 88 |
+
* permission, which is the half of instruction 15 the section titles only made visible.
|
| 89 |
+
*/
|
| 90 |
+
sharedSections?: boolean;
|
| 91 |
}
|
| 92 |
|
| 93 |
/**
|
|
|
|
| 108 |
onFieldOrder,
|
| 109 |
deletableKeys,
|
| 110 |
onDeleteField,
|
| 111 |
+
// ββ W40-T17 β THE DEFAULT IS THE WHOLE SAFETY PROPERTY. `true` here is what makes the grid's
|
| 112 |
+
// mount need no edit at all: `customer-grid/Toolbar.tsx` passes no `sharedSections`, so it
|
| 113 |
+
// renders the three sections below exactly as it did before this ticket.
|
| 114 |
+
sharedSections = true,
|
| 115 |
}: FieldsHidePanelProps) {
|
| 116 |
const [query, setQuery] = useState("");
|
| 117 |
/** W9 β destructive, so the trash arms first (the grid's confirm pattern): first
|
|
|
|
| 123 |
* that slot. */
|
| 124 |
const [dragKey, setDragKey] = useState<string | null>(null);
|
| 125 |
const [overKey, setOverKey] = useState<string | null>(null);
|
| 126 |
+
/**
|
| 127 |
+
* ββ W40-T16 (owner instruction 13) β HOW A ROW IS NAMED, in one place, for the same reason
|
| 128 |
+
* wave 30's R5 put `fieldLabel` in one place: this panel reads a field's name at SIX sites (the
|
| 129 |
+
* search filter, three grip aria-labels, the visible label and two delete aria-labels), and a
|
| 130 |
+
* name resolved differently at any one of them means what a user SEARCHES and what they READ
|
| 131 |
+
* answer the same question differently.
|
| 132 |
+
*
|
| 133 |
+
* β `fieldLabel` STAYS THE RESOLVER. This adds the metric prefix on top of it and nothing else,
|
| 134 |
+
* so a label-less definition arriving over the wire is still guarded exactly as before.
|
| 135 |
+
* A field with no metric flag comes back byte-identical to `fieldLabel(f)` β which is what
|
| 136 |
+
* keeps the GRID's mount of this panel unchanged, since grid fields never carry the flag.
|
| 137 |
+
*/
|
| 138 |
+
const rowLabel = (f: PermsField): string =>
|
| 139 |
+
f.isMetric ? metricLabel(fieldLabel(f)) : fieldLabel(f);
|
| 140 |
const q = query.trim().toLowerCase();
|
| 141 |
+
const shown = q ? fields.filter((f) => rowLabel(f).toLowerCase().includes(q)) : fields;
|
| 142 |
+
/**
|
| 143 |
+
* ββ W40-T17 (owner instruction 15) β TWO MOUNTS, TWO QUESTIONS, ONE PANEL.
|
| 144 |
+
*
|
| 145 |
+
* The GRID asks "whose column is this?" and answers it with three sections, because a person
|
| 146 |
+
* looking at their own table needs to tell their columns from the tenant's. The PERMISSION
|
| 147 |
+
* EDITOR asks "which columns may an admin set a rule on?", and AM-2 answers that with
|
| 148 |
+
* `metric || !custom` β the database's own pre-set columns, plus every bound measure. They are
|
| 149 |
+
* not the same list narrowed; they are different questions with different answers.
|
| 150 |
+
*
|
| 151 |
+
* β THE THREE-SECTION ARM IS UNCHANGED AND MUST STAY SPELLED EXACTLY THIS WAY.
|
| 152 |
+
* `verify_map.py`'s `private-by-default-is-anchored` leg reads this file for the literal
|
| 153 |
+
* `fieldEditMode(field) === "collaborative"`: it is what pins "Shared with everyone" to the
|
| 154 |
+
* `collaborative` answer, so a route column stamped `edit: personal` is filed as private by
|
| 155 |
+
* rule rather than by luck. Rename the parameter or move the predicate and that gate reports a
|
| 156 |
+
* fact about route columns going stale, one surface away from here.
|
| 157 |
+
*
|
| 158 |
+
* β THE NARROW ARM RENDERS ONE UNTITLED SECTION, which is what the first section has always
|
| 159 |
+
* been. No heading appears and no heading disappears: `section.title` is falsy, so the rows sit
|
| 160 |
+
* directly under the search box exactly as the personal rows do on the grid today.
|
| 161 |
+
*/
|
| 162 |
+
const sections = sharedSections
|
| 163 |
+
? [
|
| 164 |
+
{ key: "personal", title: "", fields: shown.filter((field) =>
|
| 165 |
+
(!field.custom && !field.shared) || fieldEditMode(field) === "personal") },
|
| 166 |
+
{ key: "me", title: "Shared with me", fields: shown.filter((field) =>
|
| 167 |
+
(field.custom || field.shared) && fieldEditMode(field) === "users") },
|
| 168 |
+
{ key: "everyone", title: "Shared with everyone", fields: shown.filter((field) =>
|
| 169 |
+
(field.custom || field.shared) && fieldEditMode(field) === "collaborative") },
|
| 170 |
+
]
|
| 171 |
+
: [{ key: "personal", title: "", fields: presetHideFields(shown) }];
|
| 172 |
/**
|
| 173 |
* Item 23 β reorder is OFF while a search is narrowing the list. Dropping "City" above
|
| 174 |
* "State" in a list that is hiding the eight fields between them means nothing the user can
|
|
|
|
| 285 |
draggable={canReorder && !locked}
|
| 286 |
aria-label={
|
| 287 |
locked
|
| 288 |
+
? `${rowLabel(f)} is always first`
|
| 289 |
: canReorder
|
| 290 |
+
? `Reorder ${rowLabel(f)}: drag, or use the arrow keys`
|
| 291 |
+
: `Reorder ${rowLabel(f)} (clear the search first)`
|
| 292 |
}
|
| 293 |
title={
|
| 294 |
canReorder && !locked
|
|
|
|
| 338 |
draws (icons.tsx). Titled, because this list is where the icon
|
| 339 |
vocabulary is learned. */}
|
| 340 |
<FieldTypeIcon type={f.type} title={TYPE_LABELS[f.type]} />
|
| 341 |
+
<span className="cg-check-label">{rowLabel(f)}</span>
|
| 342 |
{/* β OWNER ITEM 3 (2026-08-06): *"it doesn't show pre-set when I hide fields just
|
| 343 |
like how Odoo fields are. This is always the standard label."* Right β the chip
|
| 344 |
asked `source === "odoo"`, so a column an AUTOMATION fills (source `overlay`)
|
|
|
|
| 359 |
type="button"
|
| 360 |
className={"cg-check-del" + (armed ? " is-armed" : "")}
|
| 361 |
aria-label={
|
| 362 |
+
armed ? `Permanently delete ${rowLabel(f)}?` : `Delete ${rowLabel(f)}`
|
| 363 |
}
|
| 364 |
title={armed ? undefined : "Removes this field and its values on every row."}
|
| 365 |
onClick={(e) => {
|
|
|
|
| 393 |
})}
|
| 394 |
</div>
|
| 395 |
))}
|
| 396 |
+
{/* ββ W40-T17 β GATED ON WHAT THE SECTIONS ACTUALLY HOLD, not on `shown`, and the two
|
| 397 |
+
stopped being the same question the moment a mount could narrow the vocabulary. On the
|
| 398 |
+
narrow arm a query matching only somebody's own columns leaves `shown` non-empty and
|
| 399 |
+
every section EMPTY: a search box with nothing under it and no sentence saying why,
|
| 400 |
+
which reads as a broken panel rather than as a search that found nothing.
|
| 401 |
+
β THE GRID IS UNAFFECTED, BY PARTITION RATHER THAN BY LUCK. `fieldEditMode` answers
|
| 402 |
+
exactly one of `personal` / `users` / `collaborative` (`types.ts::FIELD_EDIT_MODES`),
|
| 403 |
+
and the three predicates above split on that answer, so every field lands in exactly
|
| 404 |
+
one section and `sections.every(empty)` is TRUE precisely when `shown` is empty. Same
|
| 405 |
+
render, same condition, one fewer way to paint a blank.
|
| 406 |
+
β THE SENTENCE IS UNCHANGED, AND THE ONE CASE IT WOULD NOT FIT IS NAMED RATHER THAN
|
| 407 |
+
ASSUMED AWAY. With no query at all, this branch needs a module whose EVERY field is
|
| 408 |
+
`custom` and none a metric. No such module exists: an Odoo topic's columns are the
|
| 409 |
+
contract in `aios_grid.FIELDS`, and a `ut_*` database's are stamped `source: overlay`
|
| 410 |
+
by `core.user_tables._clean_field`, which never writes `custom`. A new copy for a
|
| 411 |
+
state nothing can reach would be a paragraph the empty-state rule (DESIGN.md Β§4)
|
| 412 |
+
exists to refuse; if a wire ever makes it reachable, that is when it earns a line. */}
|
| 413 |
+
{sections.every((section) => section.fields.length === 0) && (
|
| 414 |
<div className="cg-builder-empty">No field matches your search.</div>
|
| 415 |
)}
|
| 416 |
</div>
|
web/src/filter-kit/FilterBuilderPanel.tsx
CHANGED
|
@@ -36,6 +36,14 @@ import type { AnchorMode } from "../customer-grid/windows";
|
|
| 36 |
import { ANCHOR_LABELS, ANCHOR_MODES, MAX_N } from "../customer-grid/windows";
|
| 37 |
import { FieldSelectButton } from "../customer-grid/FieldSelect";
|
| 38 |
import type { FieldSelectItem } from "../customer-grid/FieldSelect";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 39 |
import { WindowPicker } from "./WindowPicker";
|
| 40 |
import {
|
| 41 |
COHORT_OP_LIST, DEFAULT_DATE_WINDOW, DEFAULT_WINDOW, MEASURE_MARK, MEASURE_OP_LIST,
|
|
@@ -543,6 +551,18 @@ function LeafRow({
|
|
| 543 |
// C4 β the view-membership leaf, on exactly the terms the cohort leaf above it runs.
|
| 544 |
const isView = rule.colId === VIEW_FIELD;
|
| 545 |
const hasViews = viewChoices.length > 0;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 546 |
const t = isMeasure
|
| 547 |
? measureByKey.get(rule.colId)?.type ?? "currency"
|
| 548 |
: fieldByKey.get(rule.colId)?.type ?? "text";
|
|
@@ -639,6 +659,27 @@ function LeafRow({
|
|
| 639 |
const offeredOps = withCurrent(canRank ? [...opList, ...RANK_OPS] : opList, opValue);
|
| 640 |
const plainOps = offeredOps.filter((op) => !isRankOp(op));
|
| 641 |
const rankedOps = offeredOps.filter((op) => isRankOp(op));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 642 |
|
| 643 |
return (
|
| 644 |
<span className={"cg-cond-row" + (isMeasure ? " is-measure" : "")
|
|
@@ -650,12 +691,13 @@ function LeafRow({
|
|
| 650 |
adds the type MARK to each row and takes NO grouping with it: the marks are what the
|
| 651 |
optgroup was reaching for, and they say it per row instead of splitting the list. */}
|
| 652 |
<FieldSelectButton
|
| 653 |
-
className=
|
| 654 |
-
ariaLabel=
|
|
|
|
| 655 |
value={rule.colId}
|
| 656 |
onChange={onField}
|
| 657 |
fields={[
|
| 658 |
-
...
|
| 659 |
...measures.map((m) => ({ key: m.key, label: m.label, type: MEASURE_MARK })),
|
| 660 |
// A cohort leaf asks about membership of a SET, which is the multiselect mark's
|
| 661 |
// own meaning β the vocabulary already had the right glyph for it.
|
|
|
|
| 36 |
import { ANCHOR_LABELS, ANCHOR_MODES, MAX_N } from "../customer-grid/windows";
|
| 37 |
import { FieldSelectButton } from "../customer-grid/FieldSelect";
|
| 38 |
import type { FieldSelectItem } from "../customer-grid/FieldSelect";
|
| 39 |
+
// β W40-T18 β the deleted-column vocabulary. Same direction `filter-kit/FieldsHidePanel.tsx`
|
| 40 |
+
// already imports `metricLabel` / `presetHideFields` from: `settings/permsModel` is a PURE model
|
| 41 |
+
// module with no runtime import of its own, it is already in the grid bundle because that panel
|
| 42 |
+
// mounts in the grid toolbar, and putting these three beside it is what lets `perms.test.ts`
|
| 43 |
+
// assert them under bare node β nothing in this file can be imported by that harness.
|
| 44 |
+
import {
|
| 45 |
+
DELETED_FIELD_NOTE, isDeletedFieldRef, withDeletedFieldLabel,
|
| 46 |
+
} from "../settings/permsModel";
|
| 47 |
import { WindowPicker } from "./WindowPicker";
|
| 48 |
import {
|
| 49 |
COHORT_OP_LIST, DEFAULT_DATE_WINDOW, DEFAULT_WINDOW, MEASURE_MARK, MEASURE_OP_LIST,
|
|
|
|
| 551 |
// C4 β the view-membership leaf, on exactly the terms the cohort leaf above it runs.
|
| 552 |
const isView = rule.colId === VIEW_FIELD;
|
| 553 |
const hasViews = viewChoices.length > 0;
|
| 554 |
+
// ββ W40-T18 (owner instruction 16) β THE CONDITION WHOSE COLUMN IS GONE.
|
| 555 |
+
//
|
| 556 |
+
// `withCurrentField` resolves the current key against `fieldByKey`, the COMPLETE list, and
|
| 557 |
+
// appends whatever it finds so a narrowed picker never orphans history. When it finds nothing
|
| 558 |
+
// it appends the RAW KEY as the label. That row is the defect: `custom_1723489` reads as a
|
| 559 |
+
// field name, and an admin cannot tell a deleted column from a badly named one.
|
| 560 |
+
//
|
| 561 |
+
// β MEASURE-SHAPED RULES ARE EXCLUDED. `isMeasureRule` is a test of the rule's SHAPE (it
|
| 562 |
+
// carries a window), so a measure whose key has gone would otherwise be named a deleted
|
| 563 |
+
// COLUMN, which it is not. It keeps today's rendering; see the handoff.
|
| 564 |
+
const goneColumn = !isMeasure
|
| 565 |
+
&& isDeletedFieldRef(rule.colId, fieldByKey, measureByKey, [COHORT_FIELD, VIEW_FIELD]);
|
| 566 |
const t = isMeasure
|
| 567 |
? measureByKey.get(rule.colId)?.type ?? "currency"
|
| 568 |
: fieldByKey.get(rule.colId)?.type ?? "text";
|
|
|
|
| 659 |
const offeredOps = withCurrent(canRank ? [...opList, ...RANK_OPS] : opList, opValue);
|
| 660 |
const plainOps = offeredOps.filter((op) => !isRankOp(op));
|
| 661 |
const rankedOps = offeredOps.filter((op) => isRankOp(op));
|
| 662 |
+
// ββ W40-T18 β HOW A GONE COLUMN READS, in three parts and no new CSS.
|
| 663 |
+
//
|
| 664 |
+
// (1) THE ROW. `withCurrentField` has already synthesised a picker row labelled with the raw
|
| 665 |
+
// key; `withDeletedFieldLabel` rewrites that one row to the word and moves the key into
|
| 666 |
+
// the muted `hint` line `FieldSelect` paints under a label. Nothing is removed from the
|
| 667 |
+
// list and no condition is dropped: this panel edits live permission records, and a rule
|
| 668 |
+
// that vanishes on render is a rule nobody decided to delete.
|
| 669 |
+
const offeredFields = goneColumn
|
| 670 |
+
? withDeletedFieldLabel(
|
| 671 |
+
withCurrentField(fields, rule.colId, fieldByKey, measureByKey, hasCohorts), rule.colId)
|
| 672 |
+
: withCurrentField(fields, rule.colId, fieldByKey, measureByKey, hasCohorts);
|
| 673 |
+
// (2) THE MARK. `is-missing` is index.css's OWN state for "set to something this table cannot
|
| 674 |
+
// offer" β amber border, amber label β and it is APPENDED rather than written fresh
|
| 675 |
+
// because this panel also mounts in the grid toolbar, while every lane-G stylesheet loads
|
| 676 |
+
// with the settings modal alone. The button paints that state unaided when a value
|
| 677 |
+
// resolves to no row; it cannot here, precisely because a row was synthesised for it, so
|
| 678 |
+
// the caller says it instead.
|
| 679 |
+
const fieldClass = "cg-cond-field" + (goneColumn ? " is-missing" : "");
|
| 680 |
+
// (3) THE NAME A SCREEN READER HEARS, which `aria-label` supplies INSTEAD of the visible
|
| 681 |
+
// label β so the state and the key both belong in it or neither is announced at all.
|
| 682 |
+
const fieldAria = goneColumn ? `Field, deleted column ${rule.colId}` : "Field";
|
| 683 |
|
| 684 |
return (
|
| 685 |
<span className={"cg-cond-row" + (isMeasure ? " is-measure" : "")
|
|
|
|
| 691 |
adds the type MARK to each row and takes NO grouping with it: the marks are what the
|
| 692 |
optgroup was reaching for, and they say it per row instead of splitting the list. */}
|
| 693 |
<FieldSelectButton
|
| 694 |
+
className={fieldClass}
|
| 695 |
+
ariaLabel={fieldAria}
|
| 696 |
+
title={goneColumn ? DELETED_FIELD_NOTE : undefined}
|
| 697 |
value={rule.colId}
|
| 698 |
onChange={onField}
|
| 699 |
fields={[
|
| 700 |
+
...offeredFields,
|
| 701 |
...measures.map((m) => ({ key: m.key, label: m.label, type: MEASURE_MARK })),
|
| 702 |
// A cohort leaf asks about membership of a SET, which is the multiselect mark's
|
| 703 |
// own meaning β the vocabulary already had the right glyph for it.
|
web/src/filter-kit/ops.ts
CHANGED
|
@@ -117,10 +117,15 @@ export function opsForType(t: FieldType): FilterOp[] {
|
|
| 117 |
* β AND THEY ARE SHORT ON PURPOSE. A 136px `.cg-select` has ~97.9px of readable width (see
|
| 118 |
* `cohortOpLabel` below, and `withCurrentField` below) β about 15 characters of 12.5px Inter.
|
| 119 |
* "is in the bottom N%" is 19 and would have shipped CLIPPED, which no assertion here can see
|
| 120 |
-
* and no screenshot in this session could catch. Dropping the "is " costs nothing
|
| 121 |
-
*
|
| 122 |
-
*
|
| 123 |
-
*
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 124 |
*/
|
| 125 |
export const RANK_OP_LABELS: Record<string, string> = {
|
| 126 |
topN: "top N",
|
|
@@ -170,7 +175,28 @@ export function rankDefault(op: FilterOp): string {
|
|
| 170 |
calls a symbol was wrong within a minute of writing it. The habit worth keeping is not "be more
|
| 171 |
careful"; it is that the compiler answers this question for free, so ask it before asserting. */
|
| 172 |
|
| 173 |
-
/**
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 174 |
export function opLabel(op: FilterOp, t: FieldType): string {
|
| 175 |
// Rank first and type-independently: a rank op means the same thing on every numeric
|
| 176 |
// family, and a view whose column has since changed type must still SAY what it holds
|
|
@@ -208,17 +234,17 @@ export function opLabel(op: FilterOp, t: FieldType): string {
|
|
| 208 |
if (isNumericType(t)) {
|
| 209 |
switch (op) {
|
| 210 |
case "gte":
|
| 211 |
-
return "
|
| 212 |
case "gt":
|
| 213 |
-
return "
|
| 214 |
case "lte":
|
| 215 |
-
return "
|
| 216 |
case "lt":
|
| 217 |
-
return "
|
| 218 |
case "eq":
|
| 219 |
-
return "
|
| 220 |
case "neq":
|
| 221 |
-
return "
|
| 222 |
case "between":
|
| 223 |
return "is between";
|
| 224 |
default:
|
|
|
|
| 117 |
* β AND THEY ARE SHORT ON PURPOSE. A 136px `.cg-select` has ~97.9px of readable width (see
|
| 118 |
* `cohortOpLabel` below, and `withCurrentField` below) β about 15 characters of 12.5px Inter.
|
| 119 |
* "is in the bottom N%" is 19 and would have shipped CLIPPED, which no assertion here can see
|
| 120 |
+
* and no screenshot in this session could catch. Dropping the "is " still costs nothing, and
|
| 121 |
+
* instruction 19 SHARPENED that argument rather than refuting it: the four numeric comparisons
|
| 122 |
+
* beside these were bare glyphs (`β₯ > β€ <`) and are now prefix-free WORDS ("more than",
|
| 123 |
+
* "less than or equal to"), so the row still reads without an "is " β and those words are
|
| 124 |
+
* longer than the glyphs they replaced, so this control has LESS spare room than when the
|
| 125 |
+
* width above was measured, not more. (Only those four are prefix-free; `eq` / `neq` /
|
| 126 |
+
* `between` still read "is" / "is not" / "is between", and the rank ops sit beside all of
|
| 127 |
+
* them.) The `Ranked` divider carries the "these are a different kind of question" signal.
|
| 128 |
+
* Fifth time this control has outgrown a label; the label gives way, never the control.
|
| 129 |
*/
|
| 130 |
export const RANK_OP_LABELS: Record<string, string> = {
|
| 131 |
topN: "top N",
|
|
|
|
| 175 |
calls a symbol was wrong within a minute of writing it. The habit worth keeping is not "be more
|
| 176 |
careful"; it is that the compiler answers this question for free, so ask it before asserting. */
|
| 177 |
|
| 178 |
+
/**
|
| 179 |
+
* Human label for an operator, read naturally per field type.
|
| 180 |
+
*
|
| 181 |
+
* β Instruction 19 (wave 40) β a numeric comparison reads as WORDS, never as a symbol, because
|
| 182 |
+
* "non-mathematical people get them confused". C5 makes this the ONE operator-label map, so the
|
| 183 |
+
* grid filter builder, the permission filter builder, view filters and measure conditions all
|
| 184 |
+
* changed together and no surface hand-writes an operator string of its own. (A measure
|
| 185 |
+
* condition needs no separate map: `FilterBuilderPanel` resolves its type from the measure
|
| 186 |
+
* itself and falls back to `currency`, and `MEASURE_OPS` offers exactly the six comparisons
|
| 187 |
+
* below, so a measure row reads its label off this same numeric branch.)
|
| 188 |
+
*
|
| 189 |
+
* β NO leading "is " on the four comparisons, unlike `automation/CondBuilder.tsx::OP_WORDS`
|
| 190 |
+
* whose voice otherwise sets the house standard here. These labels already outrun the control
|
| 191 |
+
* that renders them; W40-T30 widens `.cg-select` in `index.css` for "less than or equal to"
|
| 192 |
+
* exactly, and an "is " prefix would outrun the wider control too. This file does not own that
|
| 193 |
+
* width, and it must not buy itself slack by abbreviating: "at least" / "at most" are shorter
|
| 194 |
+
* and are precisely the shorthand instruction 19 exists to remove.
|
| 195 |
+
*
|
| 196 |
+
* `gte` is "more than or equal to", not "greater than or equal to", so one axis carries one
|
| 197 |
+
* vocabulary. "more than" and "less than" are the owner's own two examples; a set learned once
|
| 198 |
+
* beats two synonyms for the same direction, which is the whole point of the instruction.
|
| 199 |
+
*/
|
| 200 |
export function opLabel(op: FilterOp, t: FieldType): string {
|
| 201 |
// Rank first and type-independently: a rank op means the same thing on every numeric
|
| 202 |
// family, and a view whose column has since changed type must still SAY what it holds
|
|
|
|
| 234 |
if (isNumericType(t)) {
|
| 235 |
switch (op) {
|
| 236 |
case "gte":
|
| 237 |
+
return "more than or equal to";
|
| 238 |
case "gt":
|
| 239 |
+
return "more than";
|
| 240 |
case "lte":
|
| 241 |
+
return "less than or equal to";
|
| 242 |
case "lt":
|
| 243 |
+
return "less than";
|
| 244 |
case "eq":
|
| 245 |
+
return "is";
|
| 246 |
case "neq":
|
| 247 |
+
return "is not";
|
| 248 |
case "between":
|
| 249 |
return "is between";
|
| 250 |
default:
|
web/src/index.css
CHANGED
|
@@ -584,6 +584,24 @@ body {
|
|
| 584 |
white-space: nowrap;
|
| 585 |
}
|
| 586 |
.cg-type-check { color: var(--lp-blue-deep); flex: 0 0 auto; }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 587 |
|
| 588 |
/* ---- item 20 (C-FLDSEL): the field picker that can show a mark ---------------------------
|
| 589 |
The BUTTON keeps `.cg-select`'s box verbatim, so every sizing class already written for a
|
|
@@ -1521,6 +1539,18 @@ body > .cg-overlay {
|
|
| 1521 |
max-height: 280px;
|
| 1522 |
overflow-y: auto;
|
| 1523 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1524 |
.cg-pick-row {
|
| 1525 |
display: flex;
|
| 1526 |
align-items: center;
|
|
@@ -1955,6 +1985,44 @@ body > .cg-overlay {
|
|
| 1955 |
white-space: nowrap;
|
| 1956 |
cursor: pointer;
|
| 1957 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1958 |
.cg-link-btn:hover {
|
| 1959 |
background: var(--lp-blue-tint);
|
| 1960 |
}
|
|
@@ -2100,10 +2168,14 @@ body > .cg-overlay {
|
|
| 2100 |
/* ------------------------------------------------------------------------- */
|
| 2101 |
.cg-pop--wide {
|
| 2102 |
/* 620px. Derived, not taste: the OPERATOR select must never clip its label
|
| 2103 |
-
(see .cg-cond-op)
|
| 2104 |
-
row needs 620
|
| 2105 |
-
|
| 2106 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2107 |
width: 620px;
|
| 2108 |
min-width: min(620px, calc(100vw - 16px));
|
| 2109 |
}
|
|
@@ -2251,11 +2323,42 @@ body > .cg-overlay {
|
|
| 2251 |
min-width: 112px;
|
| 2252 |
}
|
| 2253 |
.cg-cond-op {
|
| 2254 |
-
/*
|
| 2255 |
-
there is no smaller nested override. Unreadable
|
| 2256 |
-
filter does.
|
| 2257 |
-
|
| 2258 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2259 |
}
|
| 2260 |
/* basis 0 (not auto) so the value box GROWS from the row's surplus instead of
|
| 2261 |
contributing a large auto base that drags every sibling into shrink. */
|
|
@@ -2288,7 +2391,9 @@ body > .cg-overlay {
|
|
| 2288 |
unrelated controls.
|
| 2289 |
The popover widens instead, and only when the builder actually offers measures β the 620px
|
| 2290 |
above stays exactly as derived for every table that does not. 780 = the 620 case plus the
|
| 2291 |
-
146px window select plus its gap, so the level-3 value box keeps the same
|
|
|
|
|
|
|
| 2292 |
The wrap stays as a floor for the deepest nesting, where nothing else can save it. */
|
| 2293 |
.cg-pop--measures {
|
| 2294 |
width: 780px;
|
|
@@ -2298,19 +2403,30 @@ body > .cg-overlay {
|
|
| 2298 |
flex-wrap: wrap;
|
| 2299 |
row-gap: 6px;
|
| 2300 |
}
|
| 2301 |
-
/*
|
| 2302 |
-
|
| 2303 |
-
|
| 2304 |
-
|
| 2305 |
-
|
| 2306 |
-
|
| 2307 |
-
|
| 2308 |
-
|
| 2309 |
-
|
| 2310 |
-
.
|
| 2311 |
-
|
| 2312 |
-
|
| 2313 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2314 |
/* CG-9 (owner item 4): comparing against ANOTHER ATTRIBUTE adds three controls to the sentence
|
| 2315 |
β the value/field switch, the comparand, and (for a measure) the comparand's OWN window. The
|
| 2316 |
780 above cannot hold them: measured at 1280 the remove button alone wrapped onto a second
|
|
@@ -3463,37 +3579,16 @@ body > .cg-overlay {
|
|
| 3463 |
gap: 0;
|
| 3464 |
}
|
| 3465 |
|
| 3466 |
-
/*
|
| 3467 |
-
|
| 3468 |
-
|
| 3469 |
-
|
| 3470 |
-
`
|
| 3471 |
-
|
| 3472 |
-
|
| 3473 |
-
|
| 3474 |
-
|
| 3475 |
-
|
| 3476 |
-
`.shell-nav`, so the collapsed rail's 6px gutter is already `.shell-nav`'s own `padding: 8px 6px
|
| 3477 |
-
0`; `padding: 7px 10px` then lands the 16px glyph at x = 6 + 10 = 16 = (48-16)/2, the strip's
|
| 3478 |
-
centre and the exact x every `.shell-nav-item` icon takes (the geometry note on the fold rules
|
| 3479 |
-
above states that sum). The first draft copied `.shell-nav-templates`' `margin: 0 6px` and would
|
| 3480 |
-
have sat 6px right of every other icon: that row is a SIBLING of `.shell-nav` and has to supply
|
| 3481 |
-
its own gutter, which is precisely the difference. Height, radius and hover are the rail row's,
|
| 3482 |
-
so the column reads as one column whatever tag each control happens to be. */
|
| 3483 |
-
.shell-rail-chat {
|
| 3484 |
-
display: flex;
|
| 3485 |
-
align-items: center;
|
| 3486 |
-
margin: 0 0 2px;
|
| 3487 |
-
padding: 7px 10px;
|
| 3488 |
-
min-height: 34px;
|
| 3489 |
-
border: 0;
|
| 3490 |
-
border-radius: var(--lp-r-sm);
|
| 3491 |
-
background: transparent;
|
| 3492 |
-
color: var(--lp-ink);
|
| 3493 |
-
cursor: pointer;
|
| 3494 |
-
}
|
| 3495 |
-
.shell-rail-chat:hover { background: var(--lp-surface-2); }
|
| 3496 |
-
.shell-rail-chat:focus-visible { outline: 2px solid var(--lp-blue-deep); outline-offset: -2px; }
|
| 3497 |
|
| 3498 |
/* β WAVE 35 Β· T02 β `.shell-brand-btn` IS DELETED, and it is the wave-20 R9 decision being
|
| 3499 |
retired rather than a style being tidied. The brand was a `<button>` at all only so it could be
|
|
|
|
| 584 |
white-space: nowrap;
|
| 585 |
}
|
| 586 |
.cg-type-check { color: var(--lp-blue-deep); flex: 0 0 auto; }
|
| 587 |
+
/* W40-T29 (owner instruction 31) - the create picker's Advanced group: a hairline, then a quiet
|
| 588 |
+
one-word heading, then the three kinds most people never want. Same typographic weight as
|
| 589 |
+
.cg-fsel-group, the other grouped listbox in this file, so the two read as one pattern. The
|
| 590 |
+
hairline is the part the field picker does not need and this one does, because the group above
|
| 591 |
+
it carries no heading of its own to separate it. Inset by the list's own 4px padding rather
|
| 592 |
+
than bled full width: a negative margin inside an overflow-y container buys a horizontal
|
| 593 |
+
scrollbar, and the rule reads better aligned to the rows it divides. */
|
| 594 |
+
.cg-type-group {
|
| 595 |
+
margin-top: 4px;
|
| 596 |
+
padding: 8px 8px 4px;
|
| 597 |
+
border-top: 1px solid var(--lp-line);
|
| 598 |
+
font-size: var(--lp-fs-3xs);
|
| 599 |
+
font-weight: 600;
|
| 600 |
+
color: var(--lp-muted);
|
| 601 |
+
}
|
| 602 |
+
/* Searching for something only an advanced kind matches makes this the FIRST row of the list,
|
| 603 |
+
where a rule with nothing above it reads as a stray line instead of a separator. */
|
| 604 |
+
.cg-type-group:first-child { border-top: none; margin-top: 0; }
|
| 605 |
|
| 606 |
/* ---- item 20 (C-FLDSEL): the field picker that can show a mark ---------------------------
|
| 607 |
The BUTTON keeps `.cg-select`'s box verbatim, so every sizing class already written for a
|
|
|
|
| 1539 |
max-height: 280px;
|
| 1540 |
overflow-y: auto;
|
| 1541 |
}
|
| 1542 |
+
/* β W40-T23 β the cell picker's find box. It wears `.cg-type-search` (the house search shape,
|
| 1543 |
+
shared with the field and type pickers), and this rule changes exactly one thing about it:
|
| 1544 |
+
`.cg-type-search`'s divider is a full-bleed `border-bottom`, which inside `.cg-pick-pop`'s
|
| 1545 |
+
6px padding would stop short of both edges and read as a stray line. So it is BOXED instead
|
| 1546 |
+
β the same border + radius `.cg-fsel-search` gives `FieldSelect`'s copy of this control.
|
| 1547 |
+
β Must stay BELOW `.cg-type-search` in this file: both are single-class selectors, so source
|
| 1548 |
+
order is what decides that this `border` beats that `border-bottom`. */
|
| 1549 |
+
.cg-pick-search {
|
| 1550 |
+
border: 1px solid var(--lp-line);
|
| 1551 |
+
border-radius: var(--lp-r-md);
|
| 1552 |
+
margin-bottom: 4px;
|
| 1553 |
+
}
|
| 1554 |
.cg-pick-row {
|
| 1555 |
display: flex;
|
| 1556 |
align-items: center;
|
|
|
|
| 1985 |
white-space: nowrap;
|
| 1986 |
cursor: pointer;
|
| 1987 |
}
|
| 1988 |
+
/* W40-T25 (owner instruction 20): "See more" and "Show all" did not look clickable. The base
|
| 1989 |
+
rule above is transparent on transparent, so at rest those doors painted as bare text beside
|
| 1990 |
+
the notes they sit next to. This gives the three sites that carry them the house control
|
| 1991 |
+
shape, the one already shared by .cg-select, .cg-input and .cg-map-route-toggle: the single
|
| 1992 |
+
hairline token at rest, the shared radius, the unchanged 28px height. Border WIDTH is not
|
| 1993 |
+
touched (the base already reserves 1px of transparent border), so no control moves off its
|
| 1994 |
+
row baseline and no sibling reflows.
|
| 1995 |
+
The FILL splits by ground, not by shape. On the grid strip and the kanban lane the door sits
|
| 1996 |
+
on a wash, so the surface token lifts it. In the Hide-fields tray the ground is already
|
| 1997 |
+
surface-2 AND the hover there is the white surface, so filling at rest would leave that pair
|
| 1998 |
+
with a dead hover; the tray keeps the hairline alone and its white hover stays a real state
|
| 1999 |
+
change. Every hover in the group is left exactly as it was.
|
| 2000 |
+
ORDER IS LOAD-BEARING: these selectors are equal in specificity to the base hover below, so
|
| 2001 |
+
they sit ABOVE it and the hover still wins. */
|
| 2002 |
+
.cg-more .cg-link-btn,
|
| 2003 |
+
.cg-link-btn.cg-kb-more {
|
| 2004 |
+
border-color: var(--lp-line);
|
| 2005 |
+
background: var(--lp-surface);
|
| 2006 |
+
}
|
| 2007 |
+
/* The kanban door is display:block inside a NON-flex container, so it spans the whole lane.
|
| 2008 |
+
Given a white fill and a hairline at that width it stops being a button and becomes a fourth
|
| 2009 |
+
CARD: .cg-kb-card is white, hairline, same radius, same full width. Content width is what
|
| 2010 |
+
makes it read as a button, and it is the same correction .cg-more already records one screen
|
| 2011 |
+
over, where flex:0 0 auto stopped "See more" stretching into a bar. Outranks the later
|
| 2012 |
+
.cg-kb-more display rule on specificity, so this one lands.
|
| 2013 |
+
inline-FLEX, not inline-block: nothing in this file sets a line-height for .cg-link-btn, so
|
| 2014 |
+
at a fixed 28px the label is centred only by the button's own internal box. That was
|
| 2015 |
+
invisible while the control was transparent and would be plain to see inside a hairline.
|
| 2016 |
+
The centred 28px pairing is the house one, carried by .cg-icon-btn and .cg-rail-toggle. */
|
| 2017 |
+
.cg-link-btn.cg-kb-more {
|
| 2018 |
+
display: inline-flex;
|
| 2019 |
+
align-items: center;
|
| 2020 |
+
justify-content: center;
|
| 2021 |
+
padding: 0 10px;
|
| 2022 |
+
}
|
| 2023 |
+
.cg-fields-footer .cg-link-btn {
|
| 2024 |
+
border-color: var(--lp-line);
|
| 2025 |
+
}
|
| 2026 |
.cg-link-btn:hover {
|
| 2027 |
background: var(--lp-blue-tint);
|
| 2028 |
}
|
|
|
|
| 2168 |
/* ------------------------------------------------------------------------- */
|
| 2169 |
.cg-pop--wide {
|
| 2170 |
/* 620px. Derived, not taste: the OPERATOR select must never clip its label
|
| 2171 |
+
(see .cg-cond-op), so it is a fixed cost at every level and the deepest
|
| 2172 |
+
(level-3) row needs 620 for the value box left over. 560 left only 48px
|
| 2173 |
+
there. Collision-clamped to the viewport by OverlaySurface.
|
| 2174 |
+
W40-T30, 2026-08-24: instruction 19 turned the comparisons into words and
|
| 2175 |
+
the operator went 136px to 176px, so that level-3 value box went from about
|
| 2176 |
+
104px to about 64px. Still clear of the 48px min-width on .cg-cond-val, so
|
| 2177 |
+
620 STANDS. It is the operator passing 192px, not this width, that would
|
| 2178 |
+
break the floor. */
|
| 2179 |
width: 620px;
|
| 2180 |
min-width: min(620px, calc(100vw - 16px));
|
| 2181 |
}
|
|
|
|
| 2323 |
min-width: 112px;
|
| 2324 |
}
|
| 2325 |
.cg-cond-op {
|
| 2326 |
+
/* Operators are a CLOSED vocabulary, so they are sized to stay READABLE rather than to fit:
|
| 2327 |
+
shrink is 0 and there is deliberately no smaller nested override. Unreadable means you
|
| 2328 |
+
cannot tell what the filter does.
|
| 2329 |
+
|
| 2330 |
+
W40-T30, owner instruction 19, 2026-08-24: WIDENED from 136px to 176px, because the
|
| 2331 |
+
comparisons stopped being symbols and became words. Instruction 19, verbatim: use words
|
| 2332 |
+
("less than or equal to", "more than") instead of the symbols, because non-mathematical
|
| 2333 |
+
people confuse them. 136px was derived for a 92.9px glyph-and-phrase set and clips a word
|
| 2334 |
+
form badly.
|
| 2335 |
+
|
| 2336 |
+
THE OLD DERIVATION ALSO CARRIED A STALE FONT BASIS, so it is re-done rather than nudged.
|
| 2337 |
+
It sized "does not contain" at 92.9px and labelled that "12.5px Inter", but html sets
|
| 2338 |
+
font-size 17px and lp-fs-xs is 0.8125rem, so this control actually renders at 13.81px.
|
| 2339 |
+
That number is not a guess: it is measured and recorded in the comment above the html
|
| 2340 |
+
rule near the top of this file. Back-solving the recorded 92.9px against Inter advance
|
| 2341 |
+
widths puts the original measurement at about 12.41px, so every width derived in this
|
| 2342 |
+
block is roughly 11 percent under what it now needs.
|
| 2343 |
+
|
| 2344 |
+
RE-DERIVED at the real 13.81px by SCALING the recorded measurement, not by trusting its
|
| 2345 |
+
label. The widest word form in the closed set is "more than or equal to". By Inter advance
|
| 2346 |
+
widths it is 1.2896 times the width of "does not contain", and the font basis adds a
|
| 2347 |
+
further 1.1128 times, so 92.9 x 1.2896 x 1.1128 = 133.3px of text. Then the same box
|
| 2348 |
+
arithmetic every control in this block uses: 133.3 text + 20.1 arrow + 16 padding + 2
|
| 2349 |
+
border = 171.4, rounded up to 176 for fallback-font slack and the 4px grid.
|
| 2350 |
+
|
| 2351 |
+
WHY THAT STRING. Instruction 19 gives "less than or equal to" and "more than"; the numeric
|
| 2352 |
+
operator list carries gte, so the owner's own two words complete to "more than or equal
|
| 2353 |
+
to", which is WIDER than the instruction's own example because m is a wide glyph. If the
|
| 2354 |
+
label map ever says "greater than or equal to" instead, that string needs 188px.
|
| 2355 |
+
|
| 2356 |
+
WHAT IT COSTS, and it is inside budget: cg-cond-val is the row's only grower, so all 40px
|
| 2357 |
+
come straight off the value box. The deepest (level-3) nesting had about 104px there and
|
| 2358 |
+
now has about 64px, against the 48px min-width on cg-cond-val. The floor is only reached
|
| 2359 |
+
at 192px. */
|
| 2360 |
+
flex: 0 0 176px;
|
| 2361 |
+
min-width: 176px;
|
| 2362 |
}
|
| 2363 |
/* basis 0 (not auto) so the value box GROWS from the row's surplus instead of
|
| 2364 |
contributing a large auto base that drags every sibling into shrink. */
|
|
|
|
| 2391 |
unrelated controls.
|
| 2392 |
The popover widens instead, and only when the builder actually offers measures β the 620px
|
| 2393 |
above stays exactly as derived for every table that does not. 780 = the 620 case plus the
|
| 2394 |
+
146px window select plus its gap, so the level-3 value box keeps the same value the 620 case
|
| 2395 |
+
leaves (about 104px when this was written; about 64px since W40-T30 widened the operator to
|
| 2396 |
+
176px for instruction 19's word forms, and still clear of the 48px floor).
|
| 2397 |
The wrap stays as a floor for the deepest nesting, where nothing else can save it. */
|
| 2398 |
.cg-pop--measures {
|
| 2399 |
width: 780px;
|
|
|
|
| 2403 |
flex-wrap: wrap;
|
| 2404 |
row-gap: 6px;
|
| 2405 |
}
|
| 2406 |
+
/* W40-T30, owner instruction 19, 2026-08-24: THE 64px NARROWING THAT STOOD HERE IS DELETED,
|
| 2407 |
+
PREMISE AND ALL, rather than re-tuned.
|
| 2408 |
+
|
| 2409 |
+
It read: on a COMPARAND row (has-rhs, the value box replaced by another attribute) the
|
| 2410 |
+
operator vocabulary is four comparison GLYPHS, so the 136px the op select reserves for
|
| 2411 |
+
"does not contain" is dead space there, and it is what forced the measure-vs-measure
|
| 2412 |
+
sentence to wrap once Inter's real metrics loaded in the embed (2026-07-27). It was sized
|
| 2413 |
+
like every other closed vocabulary: widest GLYPH + 20.1px arrow + 16 padding + 2 border.
|
| 2414 |
+
|
| 2415 |
+
Instruction 19 abolishes exactly that premise. A comparand row runs on the numeric operator
|
| 2416 |
+
family, so its labels are now the same WORDS as everywhere else, and 64px leaves only
|
| 2417 |
+
64 - 20.1 - 16 - 2 = 25.9px of readable text. "less than or equal to" would paint as about
|
| 2418 |
+
two characters. That is the loudest instance of the very failure this block exists to
|
| 2419 |
+
prevent, so the base 176px now applies here too and there is no nested override left.
|
| 2420 |
+
|
| 2421 |
+
NOT A FREE CHANGE, and the reviewer should look at it on screen. The comparand row grows by
|
| 2422 |
+
112px inside cg-pop--pair, which is 950px and was derived with the operator at 136. It may
|
| 2423 |
+
now wrap onto a second line. That is accepted on this block's own stated priority, that an
|
| 2424 |
+
operator is a CLOSED vocabulary sized to stay READABLE rather than to fit, and that
|
| 2425 |
+
unreadable means you cannot tell what the filter does. A row that reads on two lines still
|
| 2426 |
+
says what it filters; a two-character operator does not. If the wrap proves unacceptable,
|
| 2427 |
+
the lever is cg-pop--pair (about 1062px would restore a single line), NOT re-narrowing the
|
| 2428 |
+
operator. Note also that _qa_grid_measures, the sameLine instrument the old comment cites,
|
| 2429 |
+
is no longer in the tree, so nothing gates either side of this. */
|
| 2430 |
/* CG-9 (owner item 4): comparing against ANOTHER ATTRIBUTE adds three controls to the sentence
|
| 2431 |
β the value/field switch, the comparand, and (for a measure) the comparand's OWN window. The
|
| 2432 |
780 above cannot hold them: measured at 1280 the remove button alone wrapped onto a second
|
|
|
|
| 3579 |
gap: 0;
|
| 3580 |
}
|
| 3581 |
|
| 3582 |
+
/* ββ W40-T22 (owner instruction 5, 2026-08-23) β `.shell-rail-chat` AND ITS `:hover` /
|
| 3583 |
+
`:focus-visible` STOOD HERE AND ARE DELETED, with the button in `shell/Shell.tsx` they styled.
|
| 3584 |
+
Owner: *"remove [the 'Ask about this data' icon] from the MAIN navigation entirely so it lives
|
| 3585 |
+
only in the secondary navigation"*. The chat launcher now exists once, in the views rail
|
| 3586 |
+
(`chatDock.css`'s `.cg-chat-toggle`), so there is nothing left in `.shell-side` for these rules
|
| 3587 |
+
to reach and a rule styling nothing is how a deleted control gets rebuilt.
|
| 3588 |
+
β NOTHING ELSE KEYED ON THEM, checked rather than assumed: no `.shell-nav >`, `:first-child` or
|
| 3589 |
+
`:nth-child` selector exists in this file or in `shell/navExtras.css`, so `.shell-nav` losing a
|
| 3590 |
+
child changes no other rule's match, and the rail's remaining rows keep their own
|
| 3591 |
+
`margin: 0 0 2px` rhythm with no gap where this sat (it was a flow child, not a spacer). */
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3592 |
|
| 3593 |
/* β WAVE 35 Β· T02 β `.shell-brand-btn` IS DELETED, and it is the wave-20 R9 decision being
|
| 3594 |
retired rather than a style being tidied. The brand was a `<button>` at all only so it could be
|
web/src/settings/DatabasePermsPane.tsx
ADDED
|
@@ -0,0 +1,174 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// ---------------------------------------------------------------------------
|
| 2 |
+
// settings / DatabasePermsPane.tsx β ONE DATABASE'S RULE, given the whole pane.
|
| 3 |
+
// (wave 40, owner instruction 7 Β· W40-T14.)
|
| 4 |
+
//
|
| 5 |
+
// β WHY IT EXISTS, IN THE OWNER'S OWN WORDS: *"Manage user, Access section: show
|
| 6 |
+
// only the Database, with just a checkbox and an Edit button (put the Metrics
|
| 7 |
+
// field toggle under there). Edit opens the whole database's Fields and Filters
|
| 8 |
+
// to toggle, with a Back button to return."*
|
| 9 |
+
//
|
| 10 |
+
// β THE PARENTHESIS IN THAT QUOTE IS SUPERSEDED, AND ONLY THE PARENTHESIS. Owner instruction 13
|
| 11 |
+
// (W40-T16) folded the Metrics toggle one level further in: it is no longer a box "under there"
|
| 12 |
+
// but one CHECKBOX PER METRIC inside this pane's Hide-fields list. The room, the Back button and
|
| 13 |
+
// the Fields/Filters pairing are instruction 7's and are unchanged. Read the quote as the reason
|
| 14 |
+
// this file exists, never as a description of the controls it draws today.
|
| 15 |
+
//
|
| 16 |
+
// What it replaces is a single-row INLINE ACCORDION. That shape was right when
|
| 17 |
+
// the list was two databases and the panels were the only thing under them; it
|
| 18 |
+
// is wrong now, because a filter builder and a field list opened inside a row of
|
| 19 |
+
// a list of every database the tenant has are two menus that failed to close.
|
| 20 |
+
// A rule about one database gets a room, and the room says which database.
|
| 21 |
+
//
|
| 22 |
+
// β IT OWNS NO STATE AND WRITES NOTHING. Every value comes from the caller's
|
| 23 |
+
// DRAFT and every change goes back out as a callback, exactly as
|
| 24 |
+
// `ModulePermsList` does β `PermsEditor` holds the draft, the confirm and the
|
| 25 |
+
// PUT. This component is a layout and a set of handlers, so the account page
|
| 26 |
+
// keeps one source of truth for what is about to be saved.
|
| 27 |
+
//
|
| 28 |
+
// ββ THE `lockedKey` / `hideableKeys` PAIR BELOW IS LOAD-BEARING AND ITS
|
| 29 |
+
// FAILURE IS SILENT. Drop either and one click on "Hide all" hides the database's
|
| 30 |
+
// own identity column: a record whose faithful enforcement is a table of blank
|
| 31 |
+
// rows, which the server's PUT validation ACCEPTS because the identity column is
|
| 32 |
+
// a perfectly known field key. Both halves ship together or the pane is a defect.
|
| 33 |
+
// ---------------------------------------------------------------------------
|
| 34 |
+
|
| 35 |
+
import { FilterBuilderPanel, FieldsHidePanel } from "../filter-kit";
|
| 36 |
+
import type { FilterTree } from "../customer-grid/types";
|
| 37 |
+
import type { PermsModule, PermsRecord } from "./permsModel";
|
| 38 |
+
import { filterOf, hiddenSetFor, hideAllKeys, identityKey, showAllKeys } from "./permsModel";
|
| 39 |
+
import "./perms.css";
|
| 40 |
+
|
| 41 |
+
export interface DatabasePermsPaneProps {
|
| 42 |
+
/** The database being edited: its label titles the pane, its fields feed both panels. */
|
| 43 |
+
module: PermsModule;
|
| 44 |
+
/**
|
| 45 |
+
* β THE WHOLE DRAFT, keyed by module, NOT this module's entry. `filterOf` and `hiddenSetFor`
|
| 46 |
+
* are where "an absent filter is an empty tree" and "absent hidden fields is an empty set" are
|
| 47 |
+
* spelled, once; taking a bare entry would make this file spell them a second time, and two
|
| 48 |
+
* spellings of one default are what those helpers exist to prevent.
|
| 49 |
+
*/
|
| 50 |
+
entries: PermsRecord;
|
| 51 |
+
/** Return to the account page. The SAME function the account page's Escape handler calls. */
|
| 52 |
+
onBack: () => void;
|
| 53 |
+
onFilter: (next: FilterTree | null) => void;
|
| 54 |
+
onToggleHidden: (fieldKey: string) => void;
|
| 55 |
+
onSetHidden: (keys: string[]) => void;
|
| 56 |
+
/*
|
| 57 |
+
* ββ W40-T16 (OWNER INSTRUCTION 13) β `onMetrics` IS GONE FROM THIS PANE, AND SO IS THE BOX
|
| 58 |
+
* IT DREW. Owner, verbatim: *"Fold 'Metrics fields (lookback measures over this database)' into
|
| 59 |
+
* the 'Hide fields' checkboxes, one row per metric, named 'Metric - Revenue', 'Metric - Order'
|
| 60 |
+
* and so on, so a user can check the ones the permissioning is limited to."*
|
| 61 |
+
*
|
| 62 |
+
* β A DELETION RATHER THAN A HIDE, because the control it replaces answered a COARSER
|
| 63 |
+
* question. One box said "this account may build measures over this database, or may not";
|
| 64 |
+
* the Hide-fields list below now carries one checkbox per bound measure, so the same admin
|
| 65 |
+
* decides WHICH ones. Leaving the blanket box beside them would put two controls on one screen
|
| 66 |
+
* that can contradict each other, and the record has no way to express the contradiction.
|
| 67 |
+
*
|
| 68 |
+
* β THE CAPABILITY ITSELF IS UNTOUCHED. `PermsEntry.metrics` still rides the wire, still parses
|
| 69 |
+
* (`parseEntry`) and is still emitted (`toPutBody`), because a record written before this
|
| 70 |
+
* ticket may carry an explicit revocation. What honours it here is `hiddenSetFor` below, on the
|
| 71 |
+
* READ side: a blanket `metrics: false` paints every metric row as hidden without rewriting
|
| 72 |
+
* anybody's stored rule. See the note at that call.
|
| 73 |
+
*/
|
| 74 |
+
/** People this tenant can name in a `user` condition. Absent β the panel says so. */
|
| 75 |
+
userOptions?: string[];
|
| 76 |
+
}
|
| 77 |
+
|
| 78 |
+
export function DatabasePermsPane({
|
| 79 |
+
module,
|
| 80 |
+
entries,
|
| 81 |
+
onBack,
|
| 82 |
+
onFilter,
|
| 83 |
+
onToggleHidden,
|
| 84 |
+
onSetHidden,
|
| 85 |
+
userOptions,
|
| 86 |
+
}: DatabasePermsPaneProps) {
|
| 87 |
+
return (
|
| 88 |
+
<div className="set-dbperm">
|
| 89 |
+
<div className="set-dbperm-head">
|
| 90 |
+
{/* β ONE WORD, AND THE SHORTNESS IS FORCED RATHER THAN CHOSEN. The account's own exit,
|
| 91 |
+
"Back to accounts", is rendered by `PermsEditor` DIRECTLY ABOVE this pane and stays
|
| 92 |
+
there while the room is open. Spelling this one "Back to account" would put two
|
| 93 |
+
controls one letter apart on one screen, going to different places, which is a worse
|
| 94 |
+
room than either label is a good one. Position already says where this one goes: it
|
| 95 |
+
sits on the database title's line, so it leaves the database. `DESIGN.md` Β§4 asks for
|
| 96 |
+
the shorter label wherever the longer one is narration, and here it also happens to
|
| 97 |
+
be the only unambiguous one. */}
|
| 98 |
+
<button type="button" className="set-secondary set-dbperm-back" onClick={onBack}>
|
| 99 |
+
<svg width="14" height="14" viewBox="0 0 16 16" fill="none" aria-hidden focusable="false">
|
| 100 |
+
<path
|
| 101 |
+
d="M9.5 4 5.5 8l4 4"
|
| 102 |
+
stroke="currentColor"
|
| 103 |
+
strokeWidth={1.3}
|
| 104 |
+
strokeLinecap="round"
|
| 105 |
+
strokeLinejoin="round"
|
| 106 |
+
/>
|
| 107 |
+
</svg>
|
| 108 |
+
Back
|
| 109 |
+
</button>
|
| 110 |
+
{/* The pane says which database it is about. Without it every one of these rooms looks
|
| 111 |
+
identical, and the reader's only clue is what they clicked a scroll ago. */}
|
| 112 |
+
<h4 className="set-h4 set-dbperm-title">{module.label}</h4>
|
| 113 |
+
</div>
|
| 114 |
+
|
| 115 |
+
{/* THE KIT'S OWN PANELS (contract C-KIT), not lookalikes: the same two the grid toolbar
|
| 116 |
+
mounts, so an admin writes a condition with the control they already know and there is
|
| 117 |
+
one condition grammar in the product rather than two that drift within a wave.
|
| 118 |
+
They STACK here rather than sitting side by side: the pane is theirs alone now, and a
|
| 119 |
+
filter and a field list read as two decisions taken in order, not one wide row. */}
|
| 120 |
+
<div className="set-dbperm-panels">
|
| 121 |
+
<div className="cg-pop set-perm-pop">
|
| 122 |
+
<FilterBuilderPanel
|
| 123 |
+
fields={module.fields}
|
| 124 |
+
filters={filterOf(entries, module.key)}
|
| 125 |
+
onChange={onFilter}
|
| 126 |
+
userOptions={userOptions}
|
| 127 |
+
/>
|
| 128 |
+
</div>
|
| 129 |
+
<div className="cg-pop set-perm-pop">
|
| 130 |
+
{/* ββ W40-T16 β THIS LIST IS WHERE THE METRICS RULE NOW LIVES. `module.fields` carries
|
| 131 |
+
C3's `measure_`-namespaced pseudo-fields, `permsModel::parseField` marks each one,
|
| 132 |
+
and the panel draws it as an ordinary checkbox named "Metric - Revenue". Checking it
|
| 133 |
+
puts that field's key into `hiddenFields` through the same `onToggle` every other
|
| 134 |
+
row uses, so there is no second write path for a metric and no second record shape.
|
| 135 |
+
β `hiddenSetFor`, NOT `hiddenSet`, AND THE DIFFERENCE IS THE MIGRATION. A record
|
| 136 |
+
written before this ticket can carry a blanket `metrics: false` (W38-T19's box), and
|
| 137 |
+
the control that wrote it is gone from this pane. The union paints every metric row
|
| 138 |
+
as hidden for such a record, so the old revocation is HONOURED on screen rather than
|
| 139 |
+
silently reading as a grant. It is a read-side union on purpose: folding it into
|
| 140 |
+
`hiddenFields` would edit somebody's stored rule as a side effect of opening a page. */}
|
| 141 |
+
<FieldsHidePanel
|
| 142 |
+
fields={module.fields}
|
| 143 |
+
hidden={hiddenSetFor(entries, module.key, module.fields)}
|
| 144 |
+
onToggle={onToggleHidden}
|
| 145 |
+
/* ββ W40-T17 (OWNER INSTRUCTION 15) β THE ONE PROP THAT MAKES THIS MOUNT DIFFER
|
| 146 |
+
FROM THE GRID'S. Owner, verbatim: *"stop displaying 'Shared with me' / 'Shared
|
| 147 |
+
with everyone' fields under Hide Fields - permission on pre-set Fields only."*
|
| 148 |
+
`false` drops both sections AND swaps the membership rule for AM-2's
|
| 149 |
+
`metric || !custom`, so this list is the database's own columns plus its bound
|
| 150 |
+
measures and nothing else.
|
| 151 |
+
β IT IS PASSED HERE AND NOWHERE ELSE. `customer-grid/Toolbar.tsx` mounts the same
|
| 152 |
+
panel and passes no `sharedSections`, so the grid keeps all three sections exactly
|
| 153 |
+
as the 2026-08-21 hotfix left them. That is the whole reason this is a prop rather
|
| 154 |
+
than a deletion: the two surfaces are supposed to differ now. */
|
| 155 |
+
sharedSections={false}
|
| 156 |
+
// ββ BOTH HALVES OF THE TRAP, and neither is decoration. `lockedKey` disables the
|
| 157 |
+
// identity column's own checkbox; `hideableKeys` is what keeps "Hide all" from
|
| 158 |
+
// including it anyway. One without the other still ships blank rows.
|
| 159 |
+
lockedKey={identityKey(module.fields)}
|
| 160 |
+
/* ββ W40-T17 β THE BULK ACTIONS REACH EXACTLY WHAT THIS ROOM LISTS, and the
|
| 161 |
+
narrowing above is what owes them the change: a list showing four rows whose
|
| 162 |
+
"Show all" clears hidden state for seven fields would WIDEN a permission through
|
| 163 |
+
a control that never displayed the columns it just revealed. `showAllKeys`
|
| 164 |
+
subtracts the governed keys instead of emptying the record; `hideAllKeys` adds
|
| 165 |
+
them without disturbing what the record hides elsewhere. Both strip the identity
|
| 166 |
+
key, so the trap above stays closed from this side too. */
|
| 167 |
+
onHideAll={() => onSetHidden(hideAllKeys(entries, module.key, module.fields))}
|
| 168 |
+
onShowAll={() => onSetHidden(showAllKeys(entries, module.key, module.fields))}
|
| 169 |
+
/>
|
| 170 |
+
</div>
|
| 171 |
+
</div>
|
| 172 |
+
</div>
|
| 173 |
+
);
|
| 174 |
+
}
|
web/src/settings/ModulePermsList.tsx
CHANGED
|
@@ -30,7 +30,8 @@ import type { ReactNode } from "react";
|
|
| 30 |
import { FilterBuilderPanel, FieldsHidePanel } from "../filter-kit";
|
| 31 |
import type { FilterTree } from "../customer-grid/types";
|
| 32 |
import type { PermsModule, PermsRecord } from "./permsModel";
|
| 33 |
-
import { filterOf,
|
|
|
|
| 34 |
import "./perms.css";
|
| 35 |
|
| 36 |
export interface ModulePermsListProps {
|
|
@@ -54,10 +55,32 @@ export interface ModulePermsListProps {
|
|
| 54 |
* reds `web_ui` on a build break in a file that ticket may not repair.
|
| 55 |
*/
|
| 56 |
onMetrics?: (key: string, on: boolean) => void;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 57 |
/** People this tenant can name in a `user` condition. Absent β the panel says so. */
|
| 58 |
userOptions?: string[];
|
| 59 |
-
/**
|
| 60 |
-
*
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 61 |
headExtra?: (m: PermsModule) => ReactNode;
|
| 62 |
/** Shown when the tenant governs nothing at all. */
|
| 63 |
emptyNote?: string;
|
|
@@ -71,10 +94,15 @@ export function ModulePermsList({
|
|
| 71 |
onToggleHidden,
|
| 72 |
onSetHidden,
|
| 73 |
onMetrics,
|
|
|
|
| 74 |
userOptions,
|
| 75 |
headExtra,
|
| 76 |
emptyNote,
|
| 77 |
}: ModulePermsListProps) {
|
|
|
|
|
|
|
|
|
|
|
|
|
| 78 |
// β Owner item 11: *"the database should not show all immediately the detail
|
| 79 |
// (for filter or hide fields)"*. Single-valued rather than a Set, deliberately
|
| 80 |
// β the complaint was a wall of panels, and an accordion cannot become one by
|
|
@@ -127,8 +155,25 @@ export function ModulePermsList({
|
|
| 127 |
controls keeps every new one off that rule β one flex child in,
|
| 128 |
one flex child out. */}
|
| 129 |
<span className="set-perm-headend">
|
| 130 |
-
|
| 131 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 132 |
<button
|
| 133 |
type="button"
|
| 134 |
className="set-secondary set-perm-disclose"
|
|
@@ -138,7 +183,7 @@ export function ModulePermsList({
|
|
| 138 |
{shown ? "Hide detail" : "Conditions and fields"}
|
| 139 |
</button>
|
| 140 |
) : null}
|
| 141 |
-
{headExtra?.(m) ?? null}
|
| 142 |
</span>
|
| 143 |
</div>
|
| 144 |
|
|
@@ -154,7 +199,28 @@ export function ModulePermsList({
|
|
| 154 |
`space-between` and lives in `index.css`, which this ticket's fence
|
| 155 |
does not contain; a new flex child there would need CSS that cannot
|
| 156 |
be written, so the box takes its own line under the head. */}
|
| 157 |
-
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 158 |
<label className="set-check">
|
| 159 |
<input
|
| 160 |
type="checkbox"
|
|
@@ -179,7 +245,10 @@ export function ModulePermsList({
|
|
| 179 |
</p>
|
| 180 |
) : null}
|
| 181 |
|
| 182 |
-
{
|
|
|
|
|
|
|
|
|
|
| 183 |
<div className="set-perm-panels">
|
| 184 |
<div className="cg-pop set-perm-pop">
|
| 185 |
<FilterBuilderPanel
|
|
@@ -190,9 +259,15 @@ export function ModulePermsList({
|
|
| 190 |
/>
|
| 191 |
</div>
|
| 192 |
<div className="cg-pop set-perm-pop">
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 193 |
<FieldsHidePanel
|
| 194 |
fields={m.fields}
|
| 195 |
-
hidden={
|
| 196 |
onToggle={(key) => onToggleHidden(m.key, key)}
|
| 197 |
// β `lockedKey` IS NOT OPTIONAL HERE, whatever the prop says.
|
| 198 |
// Absent, the panel locks nothing and one click on "Hide all"
|
|
@@ -201,8 +276,23 @@ export function ModulePermsList({
|
|
| 201 |
// validation would accept because the identity column is a
|
| 202 |
// perfectly KNOWN field key.
|
| 203 |
lockedKey={identityKey(m.fields)}
|
| 204 |
-
|
| 205 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 206 |
/>
|
| 207 |
</div>
|
| 208 |
</div>
|
|
|
|
| 30 |
import { FilterBuilderPanel, FieldsHidePanel } from "../filter-kit";
|
| 31 |
import type { FilterTree } from "../customer-grid/types";
|
| 32 |
import type { PermsModule, PermsRecord } from "./permsModel";
|
| 33 |
+
import { filterOf, hiddenSetFor, hideAllKeys, identityKey, moduleSummary,
|
| 34 |
+
showAllKeys } from "./permsModel";
|
| 35 |
import "./perms.css";
|
| 36 |
|
| 37 |
export interface ModulePermsListProps {
|
|
|
|
| 55 |
* reds `web_ui` on a build break in a file that ticket may not repair.
|
| 56 |
*/
|
| 57 |
onMetrics?: (key: string, on: boolean) => void;
|
| 58 |
+
/**
|
| 59 |
+
* ββ W40-T14 (owner instruction 7) β THE DRILL-IN. When supplied, the row is a checkbox and
|
| 60 |
+
* ONE way in: this opens a full-pane editor of that database's Fields and Filters, and the row
|
| 61 |
+
* renders no summary, no accordion, no inline panels, no Metrics box and no `headExtra`. Owner,
|
| 62 |
+
* verbatim: *"show only the Database, with just a checkbox and an Edit button (put the Metrics
|
| 63 |
+
* field toggle under there)"*.
|
| 64 |
+
*
|
| 65 |
+
* β OPTIONAL FOR THE SAME FORCED REASON `onMetrics` IS. `manage-agent/ManageAgentPane.tsx`
|
| 66 |
+
* mounts this component and is outside W40-T14's fence; a required prop stops it compiling in a
|
| 67 |
+
* file this ticket may not repair. Absent β every branch below is the accordion this file has
|
| 68 |
+
* always rendered, byte for byte.
|
| 69 |
+
*/
|
| 70 |
+
onEdit?: (key: string) => void;
|
| 71 |
/** People this tenant can name in a `user` condition. Absent β the panel says so. */
|
| 72 |
userOptions?: string[];
|
| 73 |
+
/**
|
| 74 |
+
* Anything the CALLER wants in a row's head. Returning null is the normal case and costs the
|
| 75 |
+
* row nothing.
|
| 76 |
+
*
|
| 77 |
+
* β NO CALLER SUPPLIES IT TODAY, AND THE PROP IS KEPT ANYWAY. It carried the account editor's
|
| 78 |
+
* per-row "Copy to" door, which owner instruction 7 DELETED (W40-T14) β the account-level
|
| 79 |
+
* "Apply this access toβ¦" survives and is the whole copy affordance now. What is left here is
|
| 80 |
+
* a seam, declared because `manage-agent/ManageAgentPane.tsx` mounts this same component from
|
| 81 |
+
* outside that ticket's fence and removing a prop is a breaking change to a file it may not
|
| 82 |
+
* repair. A drilled row ignores it regardless: `onEdit` means "a checkbox and one way in".
|
| 83 |
+
*/
|
| 84 |
headExtra?: (m: PermsModule) => ReactNode;
|
| 85 |
/** Shown when the tenant governs nothing at all. */
|
| 86 |
emptyNote?: string;
|
|
|
|
| 94 |
onToggleHidden,
|
| 95 |
onSetHidden,
|
| 96 |
onMetrics,
|
| 97 |
+
onEdit,
|
| 98 |
userOptions,
|
| 99 |
headExtra,
|
| 100 |
emptyNote,
|
| 101 |
}: ModulePermsListProps) {
|
| 102 |
+
// β W40-T14 β WHICH MODE, read ONCE. Every branch below asks this same question, and a second
|
| 103 |
+
// spelling of it (`onEdit !== undefined` here, `!!onEdit` there) is how two of them come to
|
| 104 |
+
// disagree about which room they are in.
|
| 105 |
+
const drilled = onEdit !== undefined;
|
| 106 |
// β Owner item 11: *"the database should not show all immediately the detail
|
| 107 |
// (for filter or hide fields)"*. Single-valued rather than a Set, deliberately
|
| 108 |
// β the complaint was a wall of panels, and an accordion cannot become one by
|
|
|
|
| 155 |
controls keeps every new one off that rule β one flex child in,
|
| 156 |
one flex child out. */}
|
| 157 |
<span className="set-perm-headend">
|
| 158 |
+
{/* β W40-T14 β the summary, the accordion and `headExtra` are the ACCORDION
|
| 159 |
+
room's furniture. The drill-in row is "a checkbox and one way in", so it
|
| 160 |
+
renders the Edit button in their place and nothing else. */}
|
| 161 |
+
{drilled ? null : (
|
| 162 |
+
<span className="set-perm-sum">{moduleSummary(entry, schemaless)}</span>
|
| 163 |
+
)}
|
| 164 |
+
{canDetail && drilled ? (
|
| 165 |
+
// β `canDetail` (= `on && !schemaless`), NOT unconditional: a database nobody
|
| 166 |
+
// may open has no rule to edit, and a schemaless surface has no fields and no
|
| 167 |
+
// filter β the help paragraph below already says so for that second case.
|
| 168 |
+
<button
|
| 169 |
+
type="button"
|
| 170 |
+
className="set-secondary set-perm-edit"
|
| 171 |
+
onClick={() => onEdit(m.key)}
|
| 172 |
+
>
|
| 173 |
+
Edit
|
| 174 |
+
</button>
|
| 175 |
+
) : null}
|
| 176 |
+
{canDetail && !drilled ? (
|
| 177 |
<button
|
| 178 |
type="button"
|
| 179 |
className="set-secondary set-perm-disclose"
|
|
|
|
| 183 |
{shown ? "Hide detail" : "Conditions and fields"}
|
| 184 |
</button>
|
| 185 |
) : null}
|
| 186 |
+
{drilled ? null : headExtra?.(m) ?? null}
|
| 187 |
</span>
|
| 188 |
</div>
|
| 189 |
|
|
|
|
| 199 |
`space-between` and lives in `index.css`, which this ticket's fence
|
| 200 |
does not contain; a new flex child there would need CSS that cannot
|
| 201 |
be written, so the box takes its own line under the head. */}
|
| 202 |
+
{/* β W40-T14 β `!drilled &&` is the whole change here. Owner instruction 7 moved this
|
| 203 |
+
box INTO the database's own pane ("put the Metrics field toggle under there"), so
|
| 204 |
+
the drill-in row must not draw a second one.
|
| 205 |
+
ββ W40-T16 β AND AFTER THIS TICKET THE BOX BELOW RENDERS NOWHERE AT ALL. Owner
|
| 206 |
+
instruction 13 folded the blanket toggle into the HIDE-FIELDS list, one checkbox
|
| 207 |
+
per metric, and `DatabasePermsPane`'s copy is deleted; `PermsEditor` passes
|
| 208 |
+
`onEdit` for every account row, so `!drilled` suppresses this one. β AND THE
|
| 209 |
+
OTHER CALLER DOES NOT MOUNT IT EITHER β MEASURED, not assumed:
|
| 210 |
+
`manage-agent/ManageAgentPane.tsx` passes exactly `modules, entries, onAccess,
|
| 211 |
+
onFilter, onToggleHidden, onSetHidden, userOptions, emptyNote`, and no
|
| 212 |
+
`onMetrics`. So nothing in the UI writes `PermsEntry.metrics` any more.
|
| 213 |
+
β THAT IS INSTRUCTION 13, NOT A DEFECT: a blanket control REPLACED by finer ones
|
| 214 |
+
is the whole ask. The boolean survives as a legacy value β read by `parseEntry`,
|
| 215 |
+
emitted by `toPutBody`, honoured on screen by `hiddenSetFor` β and every record
|
| 216 |
+
written from here on carries it GRANTED.
|
| 217 |
+
β THE JSX IS KEPT AS A SEAM, DELIBERATELY AND WITH ITS COST NAMED. It is what
|
| 218 |
+
lets a future room govern the capability without re-deriving the prop, and it
|
| 219 |
+
carries `verify_ui.py`'s `t19-unmounted` / `t19-control-gone` controls, the only
|
| 220 |
+
two in that file built from code that actually shipped broken. Deleting it is
|
| 221 |
+
legal β nothing passes the prop, so `tsc` would not notice β but it is a decision
|
| 222 |
+
to take out loud, in the same change as those two gate blocks, never a tidy-up. */}
|
| 223 |
+
{!drilled && on && !schemaless && onMetrics ? (
|
| 224 |
<label className="set-check">
|
| 225 |
<input
|
| 226 |
type="checkbox"
|
|
|
|
| 245 |
</p>
|
| 246 |
) : null}
|
| 247 |
|
| 248 |
+
{/* β `!drilled` is written even though `openDetail` can never leave `null` in that
|
| 249 |
+
mode (nothing renders the disclosure that sets it). An invariant held by an absent
|
| 250 |
+
button is one refactor away from being false; the gate on the thing itself is not. */}
|
| 251 |
+
{!drilled && canDetail && shown ? (
|
| 252 |
<div className="set-perm-panels">
|
| 253 |
<div className="cg-pop set-perm-pop">
|
| 254 |
<FilterBuilderPanel
|
|
|
|
| 259 |
/>
|
| 260 |
</div>
|
| 261 |
<div className="cg-pop set-perm-pop">
|
| 262 |
+
{/* β W40-T16 β `hiddenSetFor`, the same resolver the manage-user pane uses.
|
| 263 |
+
ONE spelling of "which keys read as hidden": this room's fields carry no
|
| 264 |
+
metric flag today (the agent editor's payload has no `measure_` pseudo-
|
| 265 |
+
fields), so the union adds nothing here and the accordion is unchanged.
|
| 266 |
+
It is written anyway because the alternative is two answers to one question
|
| 267 |
+
in two files, which is the drift this component was extracted to prevent. */}
|
| 268 |
<FieldsHidePanel
|
| 269 |
fields={m.fields}
|
| 270 |
+
hidden={hiddenSetFor(entries, m.key, m.fields)}
|
| 271 |
onToggle={(key) => onToggleHidden(m.key, key)}
|
| 272 |
// β `lockedKey` IS NOT OPTIONAL HERE, whatever the prop says.
|
| 273 |
// Absent, the panel locks nothing and one click on "Hide all"
|
|
|
|
| 276 |
// validation would accept because the identity column is a
|
| 277 |
// perfectly KNOWN field key.
|
| 278 |
lockedKey={identityKey(m.fields)}
|
| 279 |
+
/* ββ W40-T17 (owner instruction 15) β UNCONDITIONAL HERE, NOT A SECOND
|
| 280 |
+
PROP, AND THAT IS WHAT THIS COMPONENT IS. `ModulePermsList` IS the
|
| 281 |
+
permissioning list: every mount of it β the account editor's Access
|
| 282 |
+
section and `manage-agent/ManageAgentPane` alike β is editing the same
|
| 283 |
+
`perms` record through the same wall, so its panel is always a
|
| 284 |
+
permissioning panel and there is no caller for whom the shared sections
|
| 285 |
+
would be right. Owner: *"stop displaying 'Shared with me' / 'Shared with
|
| 286 |
+
everyone' fields under Hide Fields - permission on pre-set Fields only."*
|
| 287 |
+
That is a sentence about permissioning, not about one screen.
|
| 288 |
+
β IT IS ALSO WHAT KEEPS THE TWO ROOMS IDENTICAL. This file exists because
|
| 289 |
+
the owner ruled manage-agent is *"the same exact layout"* as manage user
|
| 290 |
+
(wave 33); gating one room and not the other would put the divergence
|
| 291 |
+
inside the very component extracted to prevent it β and LATENTLY, since
|
| 292 |
+
neither section fills up until the server ships `custom`/`shared`. */
|
| 293 |
+
sharedSections={false}
|
| 294 |
+
onHideAll={() => onSetHidden(m.key, hideAllKeys(entries, m.key, m.fields))}
|
| 295 |
+
onShowAll={() => onSetHidden(m.key, showAllKeys(entries, m.key, m.fields))}
|
| 296 |
/>
|
| 297 |
</div>
|
| 298 |
</div>
|
web/src/settings/PermsEditor.tsx
CHANGED
|
@@ -64,6 +64,9 @@ import { Busy } from "../ui/Busy";
|
|
| 64 |
// item 10: "the same exact layout"). The filter/hide panels are mounted THERE
|
| 65 |
// now, which is why `filter-kit` is no longer imported here.
|
| 66 |
import { ModulePermsList } from "./ModulePermsList";
|
|
|
|
|
|
|
|
|
|
| 67 |
// C4: this lane's own stylesheet. `index.css` is B's and nothing here touches it.
|
| 68 |
import "./perms.css";
|
| 69 |
import {
|
|
@@ -73,13 +76,14 @@ import {
|
|
| 73 |
setPassword,
|
| 74 |
} from "./settingsApi";
|
| 75 |
import type { AdminUser } from "./settingsApi";
|
| 76 |
-
import type { CopyScope, PermsPayload, PermsRecord } from "./permsModel";
|
| 77 |
import {
|
| 78 |
accessSummary,
|
| 79 |
copyDropped,
|
| 80 |
copyTargetRecord,
|
| 81 |
isDirty,
|
| 82 |
moduleSummary,
|
|
|
|
| 83 |
parsePermsPayload,
|
| 84 |
setAccess,
|
| 85 |
setFilter,
|
|
@@ -193,6 +197,17 @@ export function PermsEditor({
|
|
| 193 |
* accounts LIST, which the admin is no longer sent back to on save β so
|
| 194 |
* without this a successful write would land in an empty room. */
|
| 195 |
const [said, setSaid] = useState("");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 196 |
// β The disclosure state MOVED to `ModulePermsList` with the list itself: it is
|
| 197 |
// a property of that list and of nothing else, and leaving a copy here would be
|
| 198 |
// a second source of truth for which row is open, in the one room that renders
|
|
@@ -233,6 +248,32 @@ export function PermsEditor({
|
|
| 233 |
}, [username]);
|
| 234 |
|
| 235 |
const payload = load.phase === "ready" ? load.payload : null;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 236 |
const dirty = payload ? isDirty(payload, saved, draft) : false;
|
| 237 |
/**
|
| 238 |
* β `payload.isAdmin` ALONE GOES STALE THE MOMENT THIS PAGE CAN CHANGE THE
|
|
@@ -272,6 +313,18 @@ export function PermsEditor({
|
|
| 272 |
else onBack();
|
| 273 |
}, [anyDirty, onBack]);
|
| 274 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 275 |
// β CAPTURE PHASE, ON PURPOSE. The settings modal binds its own window
|
| 276 |
// `keydown` and closes the WHOLE dialog on Escape β which, on this page,
|
| 277 |
// would throw away an admin's unsaved edits with no prompt and no undo. A
|
|
@@ -283,6 +336,10 @@ export function PermsEditor({
|
|
| 283 |
askRef.current = ask;
|
| 284 |
const copyRef = useRef(copy);
|
| 285 |
copyRef.current = copy;
|
|
|
|
|
|
|
|
|
|
|
|
|
| 286 |
useEffect(() => {
|
| 287 |
const onKey = (e: KeyboardEvent) => {
|
| 288 |
if (e.key !== "Escape") return;
|
|
@@ -298,6 +355,16 @@ export function PermsEditor({
|
|
| 298 |
setAsk(null);
|
| 299 |
return;
|
| 300 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 301 |
if (dirtyRef.current) {
|
| 302 |
e.stopPropagation();
|
| 303 |
setAsk({ kind: "discard" });
|
|
@@ -305,7 +372,10 @@ export function PermsEditor({
|
|
| 305 |
};
|
| 306 |
window.addEventListener("keydown", onKey, true);
|
| 307 |
return () => window.removeEventListener("keydown", onKey, true);
|
| 308 |
-
|
|
|
|
|
|
|
|
|
|
| 309 |
|
| 310 |
// β THE CONFIRM MUST BE BROUGHT INTO VIEW, and this is not polish. Its scrim
|
| 311 |
// is scoped to THIS PANE rather than the viewport (a second full-screen scrim
|
|
@@ -519,24 +589,188 @@ export function PermsEditor({
|
|
| 519 |
setCopy({ phase: "pick", scope, picked: new Set<string>() });
|
| 520 |
}, []);
|
| 521 |
|
| 522 |
-
|
| 523 |
-
|
| 524 |
-
|
| 525 |
-
|
| 526 |
-
|
| 527 |
-
|
| 528 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 529 |
<h3 className="set-h set-perm-title">{displayName}</h3>
|
| 530 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 531 |
</div>
|
| 532 |
-
<span className=
|
| 533 |
-
{role === "admin" ? "Admin" : "Member"}
|
| 534 |
-
</span>
|
| 535 |
-
{user.active ? null : <span className="set-chip set-chip--off">Deactivated</span>}
|
| 536 |
</div>
|
| 537 |
|
| 538 |
{error ? <p className="set-error">{error}</p> : null}
|
| 539 |
{said ? <p className="set-notice">{said}</p> : null}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 540 |
|
| 541 |
{/* ββ the account (R7) βββββββββββββββββββββββββββββββββββββββββββββββ */}
|
| 542 |
<section className="set-card">
|
|
@@ -598,30 +832,37 @@ export function PermsEditor({
|
|
| 598 |
</button>
|
| 599 |
</div>
|
| 600 |
|
| 601 |
-
{/*
|
| 602 |
-
|
| 603 |
-
|
| 604 |
-
|
| 605 |
-
|
| 606 |
-
|
| 607 |
-
|
| 608 |
-
|
| 609 |
-
|
| 610 |
-
|
| 611 |
-
|
| 612 |
-
|
| 613 |
-
|
| 614 |
-
|
| 615 |
-
|
| 616 |
-
|
| 617 |
-
|
| 618 |
-
|
| 619 |
-
|
| 620 |
-
|
| 621 |
-
|
| 622 |
-
|
| 623 |
-
|
| 624 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 625 |
<button
|
| 626 |
type="button"
|
| 627 |
className="set-secondary"
|
|
@@ -641,6 +882,18 @@ export function PermsEditor({
|
|
| 641 |
<Busy busy={busy} idle="Reset password" doing="Resetting" />
|
| 642 |
</button>
|
| 643 |
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 644 |
</div>
|
| 645 |
</section>
|
| 646 |
|
|
@@ -656,29 +909,24 @@ export function PermsEditor({
|
|
| 656 |
|
| 657 |
{payload ? (
|
| 658 |
<>
|
| 659 |
-
{/* β
|
| 660 |
-
|
| 661 |
-
|
| 662 |
-
|
| 663 |
-
a
|
| 664 |
-
|
| 665 |
-
|
| 666 |
-
|
| 667 |
-
|
| 668 |
-
This is an administrator account. Administrators see everything, so
|
| 669 |
-
nothing set here applies to them β these rules take effect only if
|
| 670 |
-
the account is changed to Member.
|
| 671 |
-
</p>
|
| 672 |
-
) : null}
|
| 673 |
|
| 674 |
-
|
| 675 |
PREVIOUS wall, so its empty perms mean "not written yet", not "no
|
| 676 |
access". Saying so is the difference between an admin reading this
|
| 677 |
page correctly and one who thinks the account is locked out. */}
|
| 678 |
{!payload.migrated && !subjectIsAdmin ? (
|
| 679 |
<p className="set-notice set-perm-banner">
|
| 680 |
This account still uses the previous access model, so the rules below
|
| 681 |
-
are not in force yet. Saving moves it to the per-module model
|
| 682 |
every module deliberately before you do.
|
| 683 |
</p>
|
| 684 |
) : null}
|
|
@@ -693,100 +941,124 @@ export function PermsEditor({
|
|
| 693 |
</p>
|
| 694 |
) : null}
|
| 695 |
|
| 696 |
-
|
| 697 |
-
|
| 698 |
-
|
| 699 |
-
|
| 700 |
-
|
| 701 |
-
|
| 702 |
-
|
| 703 |
-
|
| 704 |
-
|
| 705 |
-
|
| 706 |
-
|
| 707 |
-
|
| 708 |
-
|
| 709 |
-
|
| 710 |
-
|
| 711 |
-
|
| 712 |
-
|
| 713 |
-
|
| 714 |
-
|
| 715 |
-
|
| 716 |
-
|
| 717 |
-
|
| 718 |
-
|
| 719 |
-
|
| 720 |
-
|
| 721 |
-
|
| 722 |
-
|
| 723 |
-
|
| 724 |
-
|
| 725 |
-
|
| 726 |
-
|
| 727 |
-
|
| 728 |
-
|
| 729 |
-
|
| 730 |
-
|
| 731 |
-
|
| 732 |
-
|
| 733 |
-
|
| 734 |
-
|
| 735 |
-
|
| 736 |
-
|
| 737 |
-
|
| 738 |
-
|
| 739 |
-
|
| 740 |
-
|
| 741 |
-
|
| 742 |
-
|
| 743 |
-
|
| 744 |
-
wave-38 QA on the deployed build, by opening the screen and looking.
|
| 745 |
-
β THE PROP IS OPTIONAL AND THAT IS PRECISELY WHAT LET IT SHIP: `tsc` cannot name a
|
| 746 |
-
call site that forgot an optional prop. It STAYS optional because `manage-agent`
|
| 747 |
-
legitimately does not want it (an agent's reads never open a grid door, so the rule
|
| 748 |
-
would be stored and never applied) β so what pins this line is `verify_ui.py`'s
|
| 749 |
-
`metrics_toggle_has_a_mount_site`, not the type system.
|
| 750 |
-
β AND THIS COMMENT SITS HERE, NOT BETWEEN THE ATTRIBUTES, because a JSX comment in
|
| 751 |
-
the attribute list TYPE-CHECKS under `tsc --noEmit` and then EMITS a bare `...` into
|
| 752 |
-
the props object β invalid JS that only the render smoke catches. */}
|
| 753 |
-
<ModulePermsList
|
| 754 |
-
modules={payload.modules}
|
| 755 |
-
entries={draft}
|
| 756 |
-
onAccess={(key, on) => setDraft((d) => setAccess(d, key, on))}
|
| 757 |
-
onFilter={(key, next) => setDraft((d) => setFilter(d, key, next))}
|
| 758 |
-
onToggleHidden={(key, fk) => setDraft((d) => toggleHidden(d, key, fk))}
|
| 759 |
-
onSetHidden={(key, keys) => setDraft((d) => setHidden(d, key, keys))}
|
| 760 |
-
onMetrics={(key, on) => setDraft((d) => setMetrics(d, key, on))}
|
| 761 |
-
userOptions={userOptions}
|
| 762 |
-
emptyNote="This deployment declares no modules that can be restricted."
|
| 763 |
-
headExtra={(m) =>
|
| 764 |
-
copyTargets?.length ? (
|
| 765 |
<button
|
| 766 |
type="button"
|
| 767 |
-
className="set-
|
| 768 |
-
disabled={
|
| 769 |
-
onClick={() =>
|
| 770 |
>
|
| 771 |
-
|
| 772 |
</button>
|
| 773 |
-
|
| 774 |
-
|
| 775 |
-
/>
|
| 776 |
|
| 777 |
-
|
| 778 |
-
|
| 779 |
-
|
| 780 |
-
|
| 781 |
-
|
| 782 |
-
|
| 783 |
-
|
| 784 |
-
|
| 785 |
-
|
| 786 |
-
|
| 787 |
-
|
| 788 |
-
|
| 789 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 790 |
</div>
|
| 791 |
</>
|
| 792 |
) : null}
|
|
|
|
| 64 |
// item 10: "the same exact layout"). The filter/hide panels are mounted THERE
|
| 65 |
// now, which is why `filter-kit` is no longer imported here.
|
| 66 |
import { ModulePermsList } from "./ModulePermsList";
|
| 67 |
+
// β W40-T14 (owner instruction 7) β the row's accordion became a ROOM. The list above offers a
|
| 68 |
+
// checkbox and one way in; this is what the way in opens.
|
| 69 |
+
import { DatabasePermsPane } from "./DatabasePermsPane";
|
| 70 |
// C4: this lane's own stylesheet. `index.css` is B's and nothing here touches it.
|
| 71 |
import "./perms.css";
|
| 72 |
import {
|
|
|
|
| 76 |
setPassword,
|
| 77 |
} from "./settingsApi";
|
| 78 |
import type { AdminUser } from "./settingsApi";
|
| 79 |
+
import type { CopyScope, PermsModule, PermsPayload, PermsRecord } from "./permsModel";
|
| 80 |
import {
|
| 81 |
accessSummary,
|
| 82 |
copyDropped,
|
| 83 |
copyTargetRecord,
|
| 84 |
isDirty,
|
| 85 |
moduleSummary,
|
| 86 |
+
normalizeMetrics,
|
| 87 |
parsePermsPayload,
|
| 88 |
setAccess,
|
| 89 |
setFilter,
|
|
|
|
| 197 |
* accounts LIST, which the admin is no longer sent back to on save β so
|
| 198 |
* without this a successful write would land in an empty room. */
|
| 199 |
const [said, setSaid] = useState("");
|
| 200 |
+
/**
|
| 201 |
+
* ββ W40-T14 (owner instruction 7) β WHICH DATABASE'S RULE IS OPEN, or `null` for the account
|
| 202 |
+
* page. A KEY rather than the module object: the module list is re-derived from the payload on
|
| 203 |
+
* every load, and a held object would be a stale second copy of a row the page can no longer
|
| 204 |
+
* find. Resolving the key against `payload.modules` below is also what makes a stale key
|
| 205 |
+
* harmless β it falls back to the account page instead of drawing an empty room.
|
| 206 |
+
*
|
| 207 |
+
* β IT DOES NOT FORK THE DRAFT. The pane edits the SAME `draft`, so leaving it loses nothing
|
| 208 |
+
* and there is exactly one thing on this page that "Save access" commits.
|
| 209 |
+
*/
|
| 210 |
+
const [editing, setEditing] = useState<string | null>(null);
|
| 211 |
// β The disclosure state MOVED to `ModulePermsList` with the list itself: it is
|
| 212 |
// a property of that list and of nothing else, and leaving a copy here would be
|
| 213 |
// a second source of truth for which row is open, in the one room that renders
|
|
|
|
| 248 |
}, [username]);
|
| 249 |
|
| 250 |
const payload = load.phase === "ready" ? load.payload : null;
|
| 251 |
+
/**
|
| 252 |
+
* β W40-T14 β the drill-in RESOLVED, which is the only form the render is allowed to trust.
|
| 253 |
+
* `editing` alone can name a module this deployment no longer declares (a payload reload, an
|
| 254 |
+
* orphaned key), and a pane drawn from that would be a room with no fields, no filter and no
|
| 255 |
+
* title. Resolving to `null` sends the reader back to the account page instead.
|
| 256 |
+
*
|
| 257 |
+
* β IT ALSO CANNOT RESOLVE BEFORE THE RECORD LOADS, and that is load-bearing: `payload` is
|
| 258 |
+
* null while the GET is in flight, so no checkbox of this pane's can paint over an unloaded
|
| 259 |
+
* record β the property `pages/_test/render.test.tsx` pins.
|
| 260 |
+
*/
|
| 261 |
+
const editModule = editing ? payload?.modules.find((m) => m.key === editing) ?? null : null;
|
| 262 |
+
/**
|
| 263 |
+
* ββ W40-T15 (owner instruction 8) β THE TWO KINDS OF THING THIS PAGE GOVERNS, split in the
|
| 264 |
+
* CLIENT. Owner, verbatim: *"put 'Agents' and 'Assistants' access under a 'Module' section, so
|
| 265 |
+
* Database-level access has its own 'Database' section."* A `surface` module is an app SURFACE
|
| 266 |
+
* (Assistant, Agents) and everything else is a database; the flag is the server's own, parsed
|
| 267 |
+
* by `permsModel.parsePermsPayload` from `modules[].surface`.
|
| 268 |
+
*
|
| 269 |
+
* β THE SERVER ORDER IS PRESERVED INSIDE EACH GROUP AND NOTHING IS SORTED. The order comes
|
| 270 |
+
* from `core/perms.py::tenant_governable_modules` (customer_data, product_data, analyst,
|
| 271 |
+
* automation, then `ut_*`), which today puts the two surfaces BETWEEN the Odoo topics and the
|
| 272 |
+
* user databases. A filter keeps relative order, so grouping is the whole change: re-sorting
|
| 273 |
+
* here would make this page disagree with every other reading of the same list.
|
| 274 |
+
*/
|
| 275 |
+
const databases = payload ? payload.modules.filter((m) => !m.surface) : [];
|
| 276 |
+
const surfaces = payload ? payload.modules.filter((m) => m.surface) : [];
|
| 277 |
const dirty = payload ? isDirty(payload, saved, draft) : false;
|
| 278 |
/**
|
| 279 |
* β `payload.isAdmin` ALONE GOES STALE THE MOMENT THIS PAGE CAN CHANGE THE
|
|
|
|
| 313 |
else onBack();
|
| 314 |
}, [anyDirty, onBack]);
|
| 315 |
|
| 316 |
+
/**
|
| 317 |
+
* β W40-T14 β LEAVING THE DRILL-IN, as ONE function. The Back control in the pane and the
|
| 318 |
+
* Escape key both call this, because a keyboard and a pointer disagreeing about where "back"
|
| 319 |
+
* goes is the whole class of bug an arbitrated Escape handler exists to prevent.
|
| 320 |
+
*
|
| 321 |
+
* β IT ASKS NOTHING, unlike `goBack`. The pane edits the same draft as the page under it, so
|
| 322 |
+
* nothing is discarded by returning β a "discard changes?" prompt here would be warning about
|
| 323 |
+
* a loss that is not happening, which is exactly how a real prompt gets clicked through.
|
| 324 |
+
* Stable (`[]`), so the once-bound capture listener below can call it.
|
| 325 |
+
*/
|
| 326 |
+
const leaveEditing = useCallback(() => setEditing(null), []);
|
| 327 |
+
|
| 328 |
// β CAPTURE PHASE, ON PURPOSE. The settings modal binds its own window
|
| 329 |
// `keydown` and closes the WHOLE dialog on Escape β which, on this page,
|
| 330 |
// would throw away an admin's unsaved edits with no prompt and no undo. A
|
|
|
|
| 336 |
askRef.current = ask;
|
| 337 |
const copyRef = useRef(copy);
|
| 338 |
copyRef.current = copy;
|
| 339 |
+
// β W40-T14 β the FOURTH state Escape arbitrates. It tracks the RESOLVED drill-in, not the raw
|
| 340 |
+
// key: a stale key draws nothing, so Escape must not act as though a room were open over one.
|
| 341 |
+
const editingRef = useRef(false);
|
| 342 |
+
editingRef.current = editModule !== null;
|
| 343 |
useEffect(() => {
|
| 344 |
const onKey = (e: KeyboardEvent) => {
|
| 345 |
if (e.key !== "Escape") return;
|
|
|
|
| 355 |
setAsk(null);
|
| 356 |
return;
|
| 357 |
}
|
| 358 |
+
// ββ W40-T14 β THE DRILL-IN OUTRANKS `dirty`, AND THE ORDER IS THE WHOLE POINT. The pane
|
| 359 |
+
// edits the same draft as the page beneath it, so leaving it discards nothing; falling
|
| 360 |
+
// through to the `discard` question would ask about a data loss that is not happening, on
|
| 361 |
+
// the one keystroke a reader presses to back out of a room. Escape here does exactly what
|
| 362 |
+
// the pane's Back control does, through the same function.
|
| 363 |
+
if (editingRef.current) {
|
| 364 |
+
e.stopPropagation();
|
| 365 |
+
leaveEditing();
|
| 366 |
+
return;
|
| 367 |
+
}
|
| 368 |
if (dirtyRef.current) {
|
| 369 |
e.stopPropagation();
|
| 370 |
setAsk({ kind: "discard" });
|
|
|
|
| 372 |
};
|
| 373 |
window.addEventListener("keydown", onKey, true);
|
| 374 |
return () => window.removeEventListener("keydown", onKey, true);
|
| 375 |
+
// β STILL BOUND ONCE. `leaveEditing` is `useCallback(..., [])`, so its identity never
|
| 376 |
+
// changes and naming it here re-binds nothing; every state the handler reads still comes
|
| 377 |
+
// through a ref for exactly that reason.
|
| 378 |
+
}, [leaveEditing]);
|
| 379 |
|
| 380 |
// β THE CONFIRM MUST BE BROUGHT INTO VIEW, and this is not polish. Its scrim
|
| 381 |
// is scoped to THIS PANE rather than the viewport (a second full-screen scrim
|
|
|
|
| 589 |
setCopy({ phase: "pick", scope, picked: new Set<string>() });
|
| 590 |
}, []);
|
| 591 |
|
| 592 |
+
/**
|
| 593 |
+
* β W40-T14 β WHO THIS PAGE IS ABOUT, plus whatever just happened, held ONCE. Both returns
|
| 594 |
+
* below render it: the account page and the per-database room are the same room with a
|
| 595 |
+
* different body, and a second copy of this markup is how the two come to disagree about which
|
| 596 |
+
* account the reader is looking at (the `ModulePermsList` extraction, one level up).
|
| 597 |
+
*/
|
| 598 |
+
const head = (
|
| 599 |
+
<>
|
| 600 |
+
{/* ββ W40-T15 (owner instruction 9) β THE WAY OUT AND THE PAGE TITLE STOPPED SHARING A
|
| 601 |
+
LINE. Owner, verbatim: *"'Back to accounts' with the username to its right is ugly, make
|
| 602 |
+
it sleeker."* They were three unequal things on one `space-between`-free flex row β an
|
| 603 |
+
exit, a person, and two status chips β so the eye met a button first and the name of the
|
| 604 |
+
account it had just opened second, at the same weight.
|
| 605 |
+
Now the exit is page chrome on its own line, quiet the way `.shell-newfolder` is quiet
|
| 606 |
+
(muted ink, wash on hover, no border), and the identity is the page TITLE underneath it
|
| 607 |
+
with the chips beside the name exactly as before.
|
| 608 |
+
β THE LITERAL "Back to accounts" IS PINNED TWICE: `pages/_test/render.test.tsx` asserts
|
| 609 |
+
the way out paints before the record arrives, and `verify_ui.py`'s compiled control
|
| 610 |
+
`perms-editor-loses-its-way-out-while-loading` blanks this very string and demands that
|
| 611 |
+
leg go red. It stays one JSX text node, and the chevron is a sibling of it. */}
|
| 612 |
+
<button type="button" className="set-perm-back" onClick={goBack}>
|
| 613 |
+
{/* The chevron `DatabasePermsPane` already draws, at the same geometry: extending the
|
| 614 |
+
house vocabulary rather than importing a second icon language (`DESIGN.md` Β§4). */}
|
| 615 |
+
<svg width="14" height="14" viewBox="0 0 16 16" fill="none" aria-hidden focusable="false">
|
| 616 |
+
<path
|
| 617 |
+
d="M9.5 4 5.5 8l4 4"
|
| 618 |
+
stroke="currentColor"
|
| 619 |
+
strokeWidth={1.3}
|
| 620 |
+
strokeLinecap="round"
|
| 621 |
+
strokeLinejoin="round"
|
| 622 |
+
/>
|
| 623 |
+
</svg>
|
| 624 |
+
Back to accounts
|
| 625 |
+
</button>
|
| 626 |
+
<div className="set-perm-ident">
|
| 627 |
+
<div className="set-perm-nameline">
|
| 628 |
<h3 className="set-h set-perm-title">{displayName}</h3>
|
| 629 |
+
{/* β THE CHIPS STAY BESIDE THE NAME, and the reason index.css records for it still
|
| 630 |
+
holds: pushed to the far end they read as a status of the DIALOG rather than of the
|
| 631 |
+
person. All that changed is which line the name sits on. */}
|
| 632 |
+
<span className={role === "admin" ? "set-chip set-chip--admin" : "set-chip"}>
|
| 633 |
+
{role === "admin" ? "Admin" : "Member"}
|
| 634 |
+
</span>
|
| 635 |
+
{user.active ? null : <span className="set-chip set-chip--off">Deactivated</span>}
|
| 636 |
</div>
|
| 637 |
+
<span className="set-username">{username}</span>
|
|
|
|
|
|
|
|
|
|
| 638 |
</div>
|
| 639 |
|
| 640 |
{error ? <p className="set-error">{error}</p> : null}
|
| 641 |
{said ? <p className="set-notice">{said}</p> : null}
|
| 642 |
+
</>
|
| 643 |
+
);
|
| 644 |
+
|
| 645 |
+
/**
|
| 646 |
+
* β W40-T15 (owner instruction 8) β ONE MOUNT OF `ModulePermsList`, CALLED TWICE. The page now
|
| 647 |
+
* draws a "Database" list and a "Module" list, and the ticket asks for both to get the same
|
| 648 |
+
* handlers, the same `onEdit`, the same `onMetrics` and the same `userOptions`. Two literal
|
| 649 |
+
* copies of that ten-prop element would be the `ManageAgentPane` mistake this component was
|
| 650 |
+
* extracted to prevent, one file down: the copies drift, and each reads correct on its own.
|
| 651 |
+
*
|
| 652 |
+
* β `onMetrics=` STAYS ON ONE LINE WITH ITS CLOSING BRACE. `verify_ui.py`'s
|
| 653 |
+
* `metrics_toggle_has_a_mount_site` NC deletes every `\n\s*onMetrics=\{[^\n]*\}` from this file
|
| 654 |
+
* and requires the check to go RED; split the prop across lines and the mutation matches
|
| 655 |
+
* nothing, the NC no-ops, and the gate fails on a control that tested nothing.
|
| 656 |
+
*
|
| 657 |
+
* β ONE RENDERER FOR BOTH ROOMS (owner item 10: *"manage agent too since its the same exact
|
| 658 |
+
* layout"*). The list used to be ~70 lines of JSX in the render below; it is
|
| 659 |
+
* `settings/ModulePermsList.tsx`, and `manage-agent/ManageAgentPane` mounts the SAME component.
|
| 660 |
+
* Nothing about the list is duplicated, so nothing about it can drift.
|
| 661 |
+
*
|
| 662 |
+
* ββ `onMetrics` ABOVE IS THE LINE W38-T19 SHIPPED WITHOUT, AND EVERY GATE WAS GREEN OVER ITS
|
| 663 |
+
* ABSENCE. The capability was complete on both sides β `perm_scope.may_metrics`, four gated
|
| 664 |
+
* read doors, `_clean_perms`'s fourth entry field, `parseEntry`/`toPutBody`, and the checkbox
|
| 665 |
+
* itself in `ModulePermsList` β with 39 new gate checks across `api_scopes`, `web_login` and
|
| 666 |
+
* `web_ui`. What did not exist was this prop, so the component's own
|
| 667 |
+
* `{on && !schemaless && onMetrics}` render gate never fired and the toggle the `done-when`
|
| 668 |
+
* names had NO MOUNT SITE anywhere in the product. Found by wave-38 QA on the deployed build,
|
| 669 |
+
* by opening the screen and looking.
|
| 670 |
+
* β THE PROP IS OPTIONAL AND THAT IS PRECISELY WHAT LET IT SHIP: `tsc` cannot name a call site
|
| 671 |
+
* that forgot an optional prop. It STAYS optional because `manage-agent` legitimately does not
|
| 672 |
+
* want it (an agent's reads never open a grid door, so the rule would be stored and never
|
| 673 |
+
* applied) β so what pins this line is `verify_ui.py`'s `metrics_toggle_has_a_mount_site`, not
|
| 674 |
+
* the type system.
|
| 675 |
+
* ββ W40-T14 MOVED THE MOUNT SITE AND W40-T16 RETIRED IT. Owner instruction 7 put the blanket
|
| 676 |
+
* Metrics toggle inside the database's own pane, so `onEdit` here also suppresses the row's
|
| 677 |
+
* copy of the box (`!drilled` in `ModulePermsList`); owner instruction 13 then folded that
|
| 678 |
+
* blanket box into the pane's Hide-fields list, one checkbox per metric, and the pane's control
|
| 679 |
+
* is deleted. β SO `onMetrics` ABOVE NOW FEEDS A BRANCH THAT NEVER RENDERS, and the other
|
| 680 |
+
* caller does not render it either β `manage-agent/ManageAgentPane.tsx` passes exactly
|
| 681 |
+
* `modules, entries, onAccess, onFilter, onToggleHidden, onSetHidden, userOptions, emptyNote`
|
| 682 |
+
* and no `onMetrics` (measured, not assumed). Nothing in the UI writes `PermsEntry.metrics` any
|
| 683 |
+
* more, which is instruction 13 replacing a blanket control rather than keeping it beside its
|
| 684 |
+
* replacement; the boolean lives on as a legacy value that `hiddenSetFor` honours on read.
|
| 685 |
+
* β THE LINE STAYS because it keeps the seam and its two gate controls exercised β see the
|
| 686 |
+
* note on the box itself in `ModulePermsList.tsx`, where the cost of keeping it is spelled out.
|
| 687 |
+
* β THE CHECK MOVED WITH THE CONTROL, TWICE. `verify_ui.py::metrics_toggle_has_a_mount_site`
|
| 688 |
+
* grew clauses over `DatabasePermsPane.tsx` in W40-T14 because clauses 3 and 4 would have
|
| 689 |
+
* stayed GREEN over a pane that dropped the checkbox; W40-T16 replaced those clauses with ones
|
| 690 |
+
* over the PER-METRIC ROWS that took its place, so the check still has a live subject rather
|
| 691 |
+
* than going green on a deletion.
|
| 692 |
+
* β AND THE WHOLE BLOCK IS A DOC COMMENT ON THE HELPER, NEVER A JSX COMMENT BETWEEN THE
|
| 693 |
+
* ATTRIBUTES: a JSX comment in an attribute list TYPE-CHECKS under the app's own tsc and then
|
| 694 |
+
* EMITS a bare `...` into the props object, invalid JS that only the render smoke catches.
|
| 695 |
+
*/
|
| 696 |
+
/**
|
| 697 |
+
* ββ W40-T16 β EVERY HIDDEN-FIELD WRITE GOES THROUGH HERE FIRST, and this composition is the
|
| 698 |
+
* ONE spelling of it rather than four hand-copies. Four callbacks write `hiddenFields` (the
|
| 699 |
+
* list's toggle and set-all, the pane's toggle and set-all); a copy that forgot the wrapper
|
| 700 |
+
* would be a DOOR LEFT BEHIND β one route by which a record keeps its blanket `metrics: false`
|
| 701 |
+
* while the other three convert it, which is the class of bug this file's own history is full
|
| 702 |
+
* of. `verify_ui.py::metrics_toggle_has_a_mount_site` refuses a raw-draft hidden write here for
|
| 703 |
+
* exactly that reason.
|
| 704 |
+
*
|
| 705 |
+
* β WHY A WRITE NEEDS NORMALISING AT ALL: `hiddenSetFor` paints every metric row hidden while
|
| 706 |
+
* the blanket revocation stands, so without this the row could never be made visible again β
|
| 707 |
+
* unticking it writes the key, the union re-hides it, and the blanket has no control left to
|
| 708 |
+
* lift it. `normalizeMetrics` converts the blanket into the explicit per-metric list, LOSSLESSLY
|
| 709 |
+
* (the union preserves what it meant), at the moment the admin is already deciding.
|
| 710 |
+
*
|
| 711 |
+
* β THE FIELD LIST COMES FROM `payload`, NOT FROM THE CALLER'S SUBSET. `accessList` is invoked
|
| 712 |
+
* twice, over `databases` and over `surfaces`; resolving against the whole declared list is
|
| 713 |
+
* what keeps one answer for "which fields does this database have" no matter which section the
|
| 714 |
+
* click came from. An unknown key yields an empty list, which makes this a no-op rather than a
|
| 715 |
+
* guess.
|
| 716 |
+
*/
|
| 717 |
+
const metricNormalized = (d: PermsRecord, key: string): PermsRecord =>
|
| 718 |
+
normalizeMetrics(d, key, payload?.modules.find((m) => m.key === key)?.fields ?? []);
|
| 719 |
+
|
| 720 |
+
const accessList = (mods: PermsModule[], emptyNote?: string) => (
|
| 721 |
+
<ModulePermsList
|
| 722 |
+
modules={mods}
|
| 723 |
+
entries={draft}
|
| 724 |
+
onAccess={(key, on) => setDraft((d) => setAccess(d, key, on))}
|
| 725 |
+
onFilter={(key, next) => setDraft((d) => setFilter(d, key, next))}
|
| 726 |
+
onToggleHidden={(key, fk) => setDraft((d) => toggleHidden(metricNormalized(d, key), key, fk))}
|
| 727 |
+
onSetHidden={(key, keys) => setDraft((d) => setHidden(metricNormalized(d, key), key, keys))}
|
| 728 |
+
onMetrics={(key, on) => setDraft((d) => setMetrics(d, key, on))}
|
| 729 |
+
onEdit={(key) => setEditing(key)}
|
| 730 |
+
userOptions={userOptions}
|
| 731 |
+
emptyNote={emptyNote}
|
| 732 |
+
/>
|
| 733 |
+
);
|
| 734 |
+
|
| 735 |
+
/**
|
| 736 |
+
* ββ W40-T14 (owner instruction 7) β THE DRILL-IN IS A FULL-PANE TAKEOVER, not a panel beside
|
| 737 |
+
* the list: *"Edit opens the whole database's Fields and Filters to toggle, with a Back button
|
| 738 |
+
* to return."* So the account card, the notices, the Access section, the module list and the
|
| 739 |
+
* bottom actions are all REPLACED while it is open, and the reader has one thing to read.
|
| 740 |
+
*
|
| 741 |
+
* β IT CANNOT OPEN OVER AN UNLOADED RECORD: `editModule` resolves against `payload.modules`,
|
| 742 |
+
* which is null until the GET answers.
|
| 743 |
+
*
|
| 744 |
+
* ββ W40-T16 (OWNER INSTRUCTION 13) β THE PANE NO LONGER TAKES `onMetrics`, AND THE MISSING
|
| 745 |
+
* PROP BELOW IS THE TICKET RATHER THAN AN OVERSIGHT. The blanket box ("Metric fields (lookback
|
| 746 |
+
* measures over this database)") is folded into that pane's Hide-fields list as one checkbox
|
| 747 |
+
* per metric, so `DatabasePermsPane` stopped declaring the prop and passing it would not
|
| 748 |
+
* compile. `setMetrics` is still imported and still wired β by `accessList` above, to the ROW's
|
| 749 |
+
* box, which `manage-agent/ManageAgentPane.tsx` still needs and which has no Hide-fields list
|
| 750 |
+
* of metric rows to be folded into.
|
| 751 |
+
*/
|
| 752 |
+
if (editModule) {
|
| 753 |
+
return (
|
| 754 |
+
<div className="set-pane set-perms">
|
| 755 |
+
{head}
|
| 756 |
+
<DatabasePermsPane
|
| 757 |
+
module={editModule}
|
| 758 |
+
entries={draft}
|
| 759 |
+
onBack={leaveEditing}
|
| 760 |
+
onFilter={(next) => setDraft((d) => setFilter(d, editModule.key, next))}
|
| 761 |
+
onToggleHidden={(fk) =>
|
| 762 |
+
setDraft((d) => toggleHidden(metricNormalized(d, editModule.key), editModule.key, fk))}
|
| 763 |
+
onSetHidden={(keys) =>
|
| 764 |
+
setDraft((d) => setHidden(metricNormalized(d, editModule.key), editModule.key, keys))}
|
| 765 |
+
userOptions={userOptions}
|
| 766 |
+
/>
|
| 767 |
+
</div>
|
| 768 |
+
);
|
| 769 |
+
}
|
| 770 |
+
|
| 771 |
+
return (
|
| 772 |
+
<div className="set-pane set-perms">
|
| 773 |
+
{head}
|
| 774 |
|
| 775 |
{/* ββ the account (R7) βββββββββββββββββββββββββββββββββββββββββββββββ */}
|
| 776 |
<section className="set-card">
|
|
|
|
| 832 |
</button>
|
| 833 |
</div>
|
| 834 |
|
| 835 |
+
{/* ββ W40-T15 (owner instruction 9) β ONE DELIBERATE GROUP, READ TOP TO BOTTOM. Owner,
|
| 836 |
+
verbatim: *"move the 'This signs <email> out everywhere immediately.' notice one line
|
| 837 |
+
below. The reset password control is misplaced."*
|
| 838 |
+
|
| 839 |
+
β WHAT WAS WRONG WITH THE TWO-COLUMN GRID IT REPLACES, and it is not taste. The
|
| 840 |
+
field sat in column one and the button in column two under a sentence, so the three
|
| 841 |
+
parts of ONE action were split across a column boundary: the reader met the
|
| 842 |
+
consequence before the control that causes it, and the button lined up with a
|
| 843 |
+
sentence rather than with the box it acts on. The old note here defended the grid on
|
| 844 |
+
the grounds that it made the password box the same width as the display-name box β
|
| 845 |
+
true, and the wrong thing to optimise, because the two boxes are not the same kind of
|
| 846 |
+
thing and never wanted the same row.
|
| 847 |
+
Now: label, box and button share ONE line and one baseline (`DESIGN.md` Β§4, "controls
|
| 848 |
+
in a row share height and baseline"), and the consequence sits a line under them,
|
| 849 |
+
which is both the owner's move and the order a person acts in.
|
| 850 |
+
β IT IS STILL THE SAME `.set-danger` BLOCK under the same red hairline. No new card:
|
| 851 |
+
a destructive-ish action inside the Account card is one containment layer, and a
|
| 852 |
+
second box around it would be the card-in-card `DESIGN.md` Β§4 forbids. */}
|
| 853 |
+
<div className="set-danger set-pw-group">
|
| 854 |
+
<div className="set-pw-row">
|
| 855 |
+
<div className="set-field set-pw-field">
|
| 856 |
+
<label className="set-label" htmlFor="set-pw">Set a new password</label>
|
| 857 |
+
<input
|
| 858 |
+
id="set-pw"
|
| 859 |
+
className="set-input"
|
| 860 |
+
type="password"
|
| 861 |
+
value={pw}
|
| 862 |
+
autoComplete="new-password"
|
| 863 |
+
onChange={(e) => setPw(e.target.value)}
|
| 864 |
+
/>
|
| 865 |
+
</div>
|
| 866 |
<button
|
| 867 |
type="button"
|
| 868 |
className="set-secondary"
|
|
|
|
| 882 |
<Busy busy={busy} idle="Reset password" doing="Resetting" />
|
| 883 |
</button>
|
| 884 |
</div>
|
| 885 |
+
{/* Still said plainly BEFORE the click, only now under the control rather than over
|
| 886 |
+
it. Resetting a password bumps the session epoch, which signs the person out of
|
| 887 |
+
every device they are using, and an admin should not discover that from a support
|
| 888 |
+
ticket.
|
| 889 |
+
β `.set-pw-note` EXISTS BECAUSE THE OLD SPACING WAS UPSIDE DOWN: index.css puts
|
| 890 |
+
`margin: 0 0 7px` on `.set-pw-side .set-help`, a gap UNDER a sentence that used to
|
| 891 |
+
be first. That rule is lane I's and is not edited; the wrapper it keyed off is gone
|
| 892 |
+
from this markup, so it matches nothing here and the new class sets the gap ABOVE
|
| 893 |
+
the sentence where this arrangement wants it. */}
|
| 894 |
+
<p className="set-help set-pw-note">
|
| 895 |
+
This signs {username} out everywhere immediately.
|
| 896 |
+
</p>
|
| 897 |
</div>
|
| 898 |
</section>
|
| 899 |
|
|
|
|
| 909 |
|
| 910 |
{payload ? (
|
| 911 |
<>
|
| 912 |
+
{/* ββ W40-T14 (owner instruction 7: *"Remove the ugly administrator note."*) β THE
|
| 913 |
+
`subjectIsAdmin` BANNER IS DELETED, NOT SHORTENED. `DESIGN.md` Β§4, "never
|
| 914 |
+
over-explain": the app does not narrate itself. That paragraph was STANDING
|
| 915 |
+
narration β it said the same three sentences on every admin account, every visit,
|
| 916 |
+
about a fact the header already states: the role chip beside the name reads "Admin",
|
| 917 |
+
and the Role select in the card above is the control that changes it. A shorter
|
| 918 |
+
paragraph in its place would be the same defect in fewer words.
|
| 919 |
+
β `subjectIsAdmin` SURVIVES: the `!payload.migrated` notice below still reads it,
|
| 920 |
+
and that one is a conditional warning about THIS record rather than standing prose.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 921 |
|
| 922 |
+
C-PERM amendment 4 β an un-migrated record still runs under the
|
| 923 |
PREVIOUS wall, so its empty perms mean "not written yet", not "no
|
| 924 |
access". Saying so is the difference between an admin reading this
|
| 925 |
page correctly and one who thinks the account is locked out. */}
|
| 926 |
{!payload.migrated && !subjectIsAdmin ? (
|
| 927 |
<p className="set-notice set-perm-banner">
|
| 928 |
This account still uses the previous access model, so the rules below
|
| 929 |
+
are not in force yet. Saving moves it to the per-module model, so set
|
| 930 |
every module deliberately before you do.
|
| 931 |
</p>
|
| 932 |
) : null}
|
|
|
|
| 941 |
</p>
|
| 942 |
) : null}
|
| 943 |
|
| 944 |
+
{/* β W40-T15 (owner instruction 10) β ONE NAMED GROUP HOLDING BOTH ENDS OF THE SAME
|
| 945 |
+
COMMAND. "Save access" is now offered at the top of this section and at the bottom
|
| 946 |
+
of it, deliberately, and two controls reading the same words is exactly the thing a
|
| 947 |
+
screen reader has no way to tell apart on its own. So neither button carries an
|
| 948 |
+
`aria-label`: their accessible name comes from the visible label, which makes the
|
| 949 |
+
two names IDENTICAL β the standard signal for one command offered twice, and the
|
| 950 |
+
only spelling that keeps saying the truth while `<Busy>` swaps both labels to
|
| 951 |
+
"Saving". The structure is what supplies the context an `aria-label` would have to
|
| 952 |
+
invent: `role="group"` named by the "Access" heading itself, so either button is
|
| 953 |
+
reached inside a region a reader has already been told the name of.
|
| 954 |
+
β `aria-labelledby` RATHER THAN A SECOND "Access" STRING: the heading is the name,
|
| 955 |
+
so there is one copy of the word and it cannot drift. */}
|
| 956 |
+
<div role="group" aria-labelledby="set-access-h">
|
| 957 |
+
<div className="set-perm-sect">
|
| 958 |
+
<h4 className="set-h4" id="set-access-h">Access</h4>
|
| 959 |
+
{/* β WRAPPED, NOT LEFT AS SIBLINGS β the same reason `.set-perm-headend` exists one
|
| 960 |
+
file over. `.set-perm-sect` is `space-between` and lives in index.css, which this
|
| 961 |
+
lane does not write; two trailing controls as bare children would be three flex
|
| 962 |
+
items pushed to the corners of the row. One flex child in, one flex child out. */}
|
| 963 |
+
<span className="set-perm-sectend">
|
| 964 |
+
{copyTargets?.length ? (
|
| 965 |
+
<button
|
| 966 |
+
type="button"
|
| 967 |
+
className="set-secondary set-copy-door"
|
| 968 |
+
disabled={!canCopy || busy}
|
| 969 |
+
title={
|
| 970 |
+
dirty
|
| 971 |
+
? "Save this account's access first. A copy sends what is stored, not what is on screen."
|
| 972 |
+
: undefined
|
| 973 |
+
}
|
| 974 |
+
onClick={() => openCopy({ kind: "all" })}
|
| 975 |
+
>
|
| 976 |
+
Apply this access toβ¦
|
| 977 |
+
</button>
|
| 978 |
+
) : null}
|
| 979 |
+
{/* ββ THE SAME HANDLER, NOT A COPY OF THE SAVE. It calls `setAsk({ kind: "save" })`
|
| 980 |
+
exactly as the bottom button does, so both open the one confirm and both commit
|
| 981 |
+
through the one `save()` β which is also the whole of the ticket's negative
|
| 982 |
+
control, "the top button must also navigate back exactly as the bottom one
|
| 983 |
+
does". It navigates back because `save()` is what passes `true` to `onSaved`,
|
| 984 |
+
and `verify_ui.py::saves_show_they_are_working` counts that call site and
|
| 985 |
+
demands there be EXACTLY ONE (wave 17's R7 removed the blanket return on
|
| 986 |
+
purpose). A second call passing `true` from here would undo a ruling nobody
|
| 987 |
+
revisited, and the count is a REGEX over this file's RAW text: writing that
|
| 988 |
+
call out even in a comment is enough to red the gate. Measured, here.
|
| 989 |
+
β AND IT RENDERS `<Busy>`: leg 1 of that same check reds any `set-primary`
|
| 990 |
+
gated on `busy` that shows no in-flight state, because greying out is
|
| 991 |
+
indistinguishable from having nothing to save. */}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 992 |
<button
|
| 993 |
type="button"
|
| 994 |
+
className="set-primary set-perm-savetop"
|
| 995 |
+
disabled={busy || !dirty}
|
| 996 |
+
onClick={() => setAsk({ kind: "save" })}
|
| 997 |
>
|
| 998 |
+
<Busy busy={busy} idle="Save access" doing="Saving" />
|
| 999 |
</button>
|
| 1000 |
+
</span>
|
| 1001 |
+
</div>
|
|
|
|
| 1002 |
|
| 1003 |
+
{/* β W40-T14 β WHAT THIS ACCOUNT CAN SEE, and nothing else. `DESIGN.md` Β§4 "never
|
| 1004 |
+
over-explain": the three clauses that used to follow were a feature tour of the
|
| 1005 |
+
controls sitting directly underneath, restated on every visit. The sentence that
|
| 1006 |
+
stays is STATE β it changes as the draft changes, and it is the one line here a
|
| 1007 |
+
reader cannot get by looking. */}
|
| 1008 |
+
<p className="set-help set-perm-intro">{accessSummary(payload, draft)}.</p>
|
| 1009 |
+
|
| 1010 |
+
{/* β NOT A DISABLED BUTTON'S TOOLTIP ALONE. A control that is refused
|
| 1011 |
+
has to say why where the eye already is; a `title` only answers the
|
| 1012 |
+
reader who thought to hover. */}
|
| 1013 |
+
{dirty && copyTargets?.length ? (
|
| 1014 |
+
<p className="set-help set-copy-why">
|
| 1015 |
+
Copying is unavailable while there are unsaved changes. A copy sends
|
| 1016 |
+
what is stored, not what is on screen.
|
| 1017 |
+
</p>
|
| 1018 |
+
) : null}
|
| 1019 |
+
|
| 1020 |
+
{/* ββ W40-T15 (owner instruction 8) β TWO ROOMS, AND NEITHER OF THEM IS EMPTY.
|
| 1021 |
+
β A GROUP WITH NO MEMBERS RENDERS NO HEADING, which is the whole reason this is a
|
| 1022 |
+
branch rather than two unconditional blocks: a tenant with no `ut_*` databases and
|
| 1023 |
+
no surfaces would otherwise read as two labelled empty rooms, which says the
|
| 1024 |
+
deployment lost something rather than that it never had it.
|
| 1025 |
+
β AND THE "governs NOTHING at all" MESSAGE STAYS REACHABLE. When there is not one
|
| 1026 |
+
module of either kind, one HEADLESS list is rendered so `ModulePermsList`'s own
|
| 1027 |
+
empty branch still speaks β the note belongs to the list, and a heading over it
|
| 1028 |
+
would be labelling an absence. */}
|
| 1029 |
+
{payload.modules.length === 0
|
| 1030 |
+
? accessList([], "This deployment declares no modules that can be restricted.")
|
| 1031 |
+
: (
|
| 1032 |
+
<>
|
| 1033 |
+
{databases.length ? (
|
| 1034 |
+
<>
|
| 1035 |
+
<h5 className="set-h4 set-perm-group">Database</h5>
|
| 1036 |
+
{accessList(databases)}
|
| 1037 |
+
</>
|
| 1038 |
+
) : null}
|
| 1039 |
+
{surfaces.length ? (
|
| 1040 |
+
<>
|
| 1041 |
+
<h5 className="set-h4 set-perm-group">Module</h5>
|
| 1042 |
+
{accessList(surfaces)}
|
| 1043 |
+
</>
|
| 1044 |
+
) : null}
|
| 1045 |
+
</>
|
| 1046 |
+
)}
|
| 1047 |
+
|
| 1048 |
+
<div className="set-actions set-perm-actions">
|
| 1049 |
+
<button
|
| 1050 |
+
type="button"
|
| 1051 |
+
className="set-primary"
|
| 1052 |
+
disabled={busy || !dirty}
|
| 1053 |
+
onClick={() => setAsk({ kind: "save" })}
|
| 1054 |
+
>
|
| 1055 |
+
<Busy busy={busy} idle="Save access" doing="Saving" />
|
| 1056 |
+
</button>
|
| 1057 |
+
<button type="button" className="set-secondary" disabled={busy} onClick={goBack}>
|
| 1058 |
+
Cancel
|
| 1059 |
+
</button>
|
| 1060 |
+
{dirty ? <span className="set-help set-perm-dirty">Unsaved changes</span> : null}
|
| 1061 |
+
</div>
|
| 1062 |
</div>
|
| 1063 |
</>
|
| 1064 |
) : null}
|
web/src/settings/perms.css
CHANGED
|
@@ -23,10 +23,13 @@
|
|
| 23 |
flex: none;
|
| 24 |
}
|
| 25 |
|
| 26 |
-
/* Smaller
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
|
|
|
|
|
|
|
|
|
| 30 |
.set-perm-disclose {
|
| 31 |
font-size: var(--lp-fs-2xs);
|
| 32 |
padding: 3px 9px;
|
|
@@ -40,8 +43,174 @@
|
|
| 40 |
color: var(--lp-blue-deep);
|
| 41 |
}
|
| 42 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 43 |
@media (max-width: 640px) {
|
| 44 |
/* The head wraps before the label truncates: a database name is the one thing
|
| 45 |
in this row that cannot be guessed from context. */
|
| 46 |
.set-perm-headend { flex-wrap: wrap; justify-content: flex-end; }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 47 |
}
|
|
|
|
| 23 |
flex: none;
|
| 24 |
}
|
| 25 |
|
| 26 |
+
/* Smaller and quieter than a primary action: this button reveals detail, it does
|
| 27 |
+
not commit anything. It borrows `.set-secondary`'s border, surface and focus
|
| 28 |
+
ring rather than restating them β a second definition of the button chrome is a
|
| 29 |
+
second place for the focus ring to go missing.
|
| 30 |
+
β STILL LIVE, and only in the agent editor. Wave 40 replaced the account
|
| 31 |
+
editor's accordion with a full-pane room (`.set-perm-edit` below); the agent
|
| 32 |
+
editor mounts the same list without `onEdit` and keeps this disclosure. */
|
| 33 |
.set-perm-disclose {
|
| 34 |
font-size: var(--lp-fs-2xs);
|
| 35 |
padding: 3px 9px;
|
|
|
|
| 43 |
color: var(--lp-blue-deep);
|
| 44 |
}
|
| 45 |
|
| 46 |
+
/* ββ wave 40, owner instruction 7 (W40-T14): the row's ONE way in, and the room
|
| 47 |
+
it opens ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 48 |
+
*
|
| 49 |
+
* WHY THE ACCORDION BECAME A ROOM. Wave 33's disclosure answered "show every
|
| 50 |
+
* database, not every panel", and it did β while the list was two rows. It is now
|
| 51 |
+
* every database the tenant has, and a filter builder unfolded inside one row of
|
| 52 |
+
* that list reads as a menu that failed to close. Owner: *"Edit opens the whole
|
| 53 |
+
* database's Fields and Filters to toggle, with a Back button to return."*
|
| 54 |
+
*/
|
| 55 |
+
|
| 56 |
+
/* Sized and quietened like the disclosure it replaces, and borrowing
|
| 57 |
+
`.set-secondary`'s border, surface and focus ring for the same reason that one
|
| 58 |
+
does: a second definition of the button chrome is a second place for the focus
|
| 59 |
+
ring to go missing. */
|
| 60 |
+
.set-perm-edit {
|
| 61 |
+
font-size: var(--lp-fs-2xs);
|
| 62 |
+
padding: 3px 9px;
|
| 63 |
+
white-space: nowrap;
|
| 64 |
+
}
|
| 65 |
+
|
| 66 |
+
/* The way out and the name of the room share one line, so the reader learns
|
| 67 |
+
where they are and how to leave in a single glance. `baseline` rather than
|
| 68 |
+
`center`: the title's cap height should sit on the button's label, which is
|
| 69 |
+
the alignment every other head on this page uses. */
|
| 70 |
+
.set-dbperm-head {
|
| 71 |
+
display: flex;
|
| 72 |
+
align-items: baseline;
|
| 73 |
+
gap: 12px;
|
| 74 |
+
margin-bottom: 16px;
|
| 75 |
+
}
|
| 76 |
+
/* The chevron rides with the words rather than beside them. */
|
| 77 |
+
.set-dbperm-back { display: inline-flex; align-items: center; gap: 6px; flex: none; }
|
| 78 |
+
/* `.set-h4` carries block margins meant for a heading that starts a section; here
|
| 79 |
+
it is a flex item on the head's own line. */
|
| 80 |
+
.set-dbperm-title { margin: 0; min-width: 0; }
|
| 81 |
+
/* β W40-T16 β `.set-dbperm-metrics` IS DELETED WITH THE BOX IT SPACED. Owner instruction 13
|
| 82 |
+
folded the blanket Metrics checkbox into the Hide-fields list as one row per metric, so the
|
| 83 |
+
rule had no element left to apply to. A rule that matches nothing is how a stylesheet ends up
|
| 84 |
+
describing a screen that no longer exists. */
|
| 85 |
+
|
| 86 |
+
/* THE PANELS STACK, one decision per eye level. A grid rather than a column flex
|
| 87 |
+
box on purpose: `.set-perm-pop` carries `flex: 1 1 320px` for the side-by-side
|
| 88 |
+
accordion, and flex properties are inert on a GRID item, so this container gets
|
| 89 |
+
the stacking it wants without redefining a rule that belongs to `index.css`. */
|
| 90 |
+
.set-dbperm-panels {
|
| 91 |
+
display: grid;
|
| 92 |
+
grid-template-columns: minmax(0, 1fr);
|
| 93 |
+
gap: 14px;
|
| 94 |
+
}
|
| 95 |
+
|
| 96 |
+
/* ββ wave 40, owner instructions 8 + 9 + 10 (W40-T15): the account page stops
|
| 97 |
+
shouting, and Save sits where the hand is ββββββββββββββββββββββββββββββββββ
|
| 98 |
+
*
|
| 99 |
+
* Three complaints, one page. The header put an exit, a person and two chips on
|
| 100 |
+
* one flex row; the reset-password control was split across a two-column grid
|
| 101 |
+
* with its consequence read BEFORE the button that causes it; and a long access
|
| 102 |
+
* list had its only Save at the bottom.
|
| 103 |
+
*
|
| 104 |
+
* β EVERY SELECTOR BELOW THAT OVERRIDES AN `index.css` DEFAULT CARRIES TWO
|
| 105 |
+
* CLASSES ON PURPOSE. A single-class rule here would tie at 0-1-0 with the rule
|
| 106 |
+
* it means to beat, and the winner would then be vite's import order across two
|
| 107 |
+
* stylesheets β a thing no reader of either file can see. Nothing in `index.css`
|
| 108 |
+
* is edited or restated; these only bound the new arrangement.
|
| 109 |
+
*/
|
| 110 |
+
|
| 111 |
+
/* --- instruction 9c: the way out is page chrome, on its own line ----------- */
|
| 112 |
+
/* The quiet-button register this system already uses (`.shell-newfolder`: muted
|
| 113 |
+
ink, wash on hover, nothing else), with the native chrome reset in the BASE
|
| 114 |
+
rule as `DESIGN.md` Β§4 requires. β `font: inherit` FIRST and the size after
|
| 115 |
+
it: a shorthand declared below its own longhands re-expands and undoes them,
|
| 116 |
+
which is the Alerts-button scar `verify_ui.py`'s R5b cascade check exists to
|
| 117 |
+
catch. The negative left margin is optical, not spacing β it pulls the
|
| 118 |
+
chevron out to the page's text edge so the label starts where the title does. */
|
| 119 |
+
.set-perm-back {
|
| 120 |
+
display: inline-flex;
|
| 121 |
+
align-items: center;
|
| 122 |
+
gap: 6px;
|
| 123 |
+
border: 0;
|
| 124 |
+
background: transparent;
|
| 125 |
+
font: inherit;
|
| 126 |
+
font-size: var(--lp-fs-2xs);
|
| 127 |
+
color: var(--lp-muted);
|
| 128 |
+
padding: 4px 8px;
|
| 129 |
+
margin: 0 0 10px -8px;
|
| 130 |
+
border-radius: var(--lp-r-sm);
|
| 131 |
+
cursor: pointer;
|
| 132 |
+
}
|
| 133 |
+
.set-perm-back:hover { background: var(--lp-wash); color: var(--lp-ink); }
|
| 134 |
+
.set-perm-back:focus-visible { outline: 2px solid var(--lp-blue-deep); outline-offset: 1px; }
|
| 135 |
+
|
| 136 |
+
/* The identity is the page TITLE now, so it owns the space under the head
|
| 137 |
+
rather than sharing a row with the exit. */
|
| 138 |
+
.set-perm-ident { margin-bottom: 16px; }
|
| 139 |
+
/* The chips sit beside the name, which is where `index.css` already argued they
|
| 140 |
+
belong: pushed to the far end they read as a status of the dialog rather than
|
| 141 |
+
of the person.
|
| 142 |
+
β `baseline`, NOT the `center` the old head used, and the difference is which
|
| 143 |
+
sibling the chip is beside. On that row the chip sat next to a TWO-LINE block
|
| 144 |
+
(name over username) and index.css records the reason for centring it: a chip
|
| 145 |
+
top-aligned against two lines looks dropped. Here its sibling is the one-line
|
| 146 |
+
title, so the chip's text sits on the title's baseline, which is the alignment
|
| 147 |
+
`.set-perm-modhead` and `.set-dbperm-head` already use for a heading and a
|
| 148 |
+
smaller control on one line. The username moved out of this row entirely. */
|
| 149 |
+
.set-perm-nameline {
|
| 150 |
+
display: flex;
|
| 151 |
+
align-items: baseline;
|
| 152 |
+
flex-wrap: wrap;
|
| 153 |
+
gap: 10px;
|
| 154 |
+
}
|
| 155 |
+
|
| 156 |
+
/* --- instruction 9a + 9b: the password group reads top to bottom ----------- */
|
| 157 |
+
/* Label, box and button on one line and one baseline; the consequence under
|
| 158 |
+
them. `flex-end` rather than `baseline` because the label sits ABOVE the box:
|
| 159 |
+
what has to line up is the bottom of the input and the bottom of the button,
|
| 160 |
+
which are both 32px tall. */
|
| 161 |
+
.set-pw-row {
|
| 162 |
+
display: flex;
|
| 163 |
+
align-items: flex-end;
|
| 164 |
+
flex-wrap: wrap;
|
| 165 |
+
gap: 12px;
|
| 166 |
+
}
|
| 167 |
+
/* `.set-field` carries 13px of bottom margin meant for stacked form rows; here
|
| 168 |
+
it would lift the box off the button's baseline. The width keeps the box the
|
| 169 |
+
size a password is, instead of letting it stretch the whole card. */
|
| 170 |
+
.set-pw-group .set-pw-field { flex: 1 1 220px; max-width: 320px; margin-bottom: 0; }
|
| 171 |
+
/* The gap goes ABOVE the sentence now that the sentence is last. */
|
| 172 |
+
.set-perms .set-pw-note { margin: 8px 0 0; }
|
| 173 |
+
|
| 174 |
+
/* --- instruction 10: Save access at the head of the section too ------------ */
|
| 175 |
+
/* The trailing controls of the Access head, grouped as ONE flex child so
|
| 176 |
+
`index.css`'s `space-between` on `.set-perm-sect` still sees exactly two. */
|
| 177 |
+
.set-perm-sectend {
|
| 178 |
+
display: flex;
|
| 179 |
+
align-items: center;
|
| 180 |
+
gap: 8px;
|
| 181 |
+
flex: none;
|
| 182 |
+
}
|
| 183 |
+
/* Sized to the copy door beside it rather than to the 32px action row at the
|
| 184 |
+
bottom of the page: controls sharing a row share a height (`DESIGN.md` Β§4),
|
| 185 |
+
and this one is riding a heading's line. It stays `.set-primary` in colour,
|
| 186 |
+
because it commits the same write the bottom button commits. */
|
| 187 |
+
.set-perms .set-perm-savetop {
|
| 188 |
+
height: 28px;
|
| 189 |
+
padding: 0 12px;
|
| 190 |
+
font-size: var(--lp-fs-2xs);
|
| 191 |
+
}
|
| 192 |
+
|
| 193 |
+
/* --- instruction 8: "Database" and "Module" ------------------------------- */
|
| 194 |
+
/* A label for a group of cards, one step quieter than the `Access` heading it
|
| 195 |
+
sits under, so the reader gets the hierarchy from weight rather than from
|
| 196 |
+
indentation. Sentence case: the product has no ALL-CAPS chrome.
|
| 197 |
+
β The bottom margin is deliberately small because `.set-perm-mod` brings 14px
|
| 198 |
+
of its own top margin and adjacent margins collapse to the larger β anything
|
| 199 |
+
under 14px here has no effect at all, so 4px says "as tight as the card
|
| 200 |
+
allows" rather than pretending to a number the layout cannot honour. */
|
| 201 |
+
.set-perms .set-perm-group {
|
| 202 |
+
margin: 22px 0 4px;
|
| 203 |
+
font-size: var(--lp-fs-2xs);
|
| 204 |
+
color: var(--lp-muted);
|
| 205 |
+
}
|
| 206 |
+
|
| 207 |
@media (max-width: 640px) {
|
| 208 |
/* The head wraps before the label truncates: a database name is the one thing
|
| 209 |
in this row that cannot be guessed from context. */
|
| 210 |
.set-perm-headend { flex-wrap: wrap; justify-content: flex-end; }
|
| 211 |
+
.set-dbperm-head { flex-wrap: wrap; }
|
| 212 |
+
/* The Access heading keeps its own line and the two controls take the next
|
| 213 |
+
one, rather than the copy door and Save being crushed into a strip beside
|
| 214 |
+
the word. */
|
| 215 |
+
.set-perm-sectend { flex-wrap: wrap; justify-content: flex-end; }
|
| 216 |
}
|
web/src/settings/permsModel.ts
CHANGED
|
@@ -193,12 +193,178 @@ export interface PermsEntry {
|
|
| 193 |
|
| 194 |
export type PermsRecord = Record<string, PermsEntry>;
|
| 195 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 196 |
/** A module the editor can draw a full rule for: it came with a field list. */
|
| 197 |
export interface PermsModule {
|
| 198 |
key: string;
|
| 199 |
label: string;
|
| 200 |
-
/** Empty β no readable schema β access toggle only (rule 1 above).
|
| 201 |
-
|
|
|
|
|
|
|
|
|
|
| 202 |
/** An app surface (Assistant, Agents): access is the whole rule, by construction and
|
| 203 |
* not by a missing schema, so the row can say so instead of apologising. */
|
| 204 |
surface?: boolean;
|
|
@@ -303,7 +469,7 @@ function asStringArray(raw: unknown): string[] {
|
|
| 303 |
* `key` and `label` are the minimum that makes a row renderable β a field
|
| 304 |
* without them cannot be shown OR named in a rule, so it is skipped rather
|
| 305 |
* than rendered as a blank the admin might tick. */
|
| 306 |
-
export function parseField(raw: unknown):
|
| 307 |
if (!raw || typeof raw !== "object") return null;
|
| 308 |
const r = raw as Record<string, unknown>;
|
| 309 |
if (typeof r.key !== "string" || r.key === "") return null;
|
|
@@ -313,6 +479,35 @@ export function parseField(raw: unknown): Field | null {
|
|
| 313 |
key: r.key,
|
| 314 |
label,
|
| 315 |
type: fieldType(r.type),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 316 |
// Anything not explicitly the overlay stratum is treated as source data.
|
| 317 |
// Consequence in this editor: nothing here offers to EDIT a field, so the
|
| 318 |
// only thing `source` drives is the "Pre-set" chip in the hide list.
|
|
@@ -337,7 +532,7 @@ export function parseField(raw: unknown): Field | null {
|
|
| 337 |
* list, which R9 already has a defined rendering for (access toggle only). */
|
| 338 |
export function parseModule(key: string, label: string, raw: unknown,
|
| 339 |
surface = false): PermsModule {
|
| 340 |
-
const fields:
|
| 341 |
for (const f of Array.isArray(raw) ? raw : []) {
|
| 342 |
const parsed = parseField(f);
|
| 343 |
if (parsed) fields.push(parsed);
|
|
@@ -421,6 +616,88 @@ export function hideableKeys(fields: readonly Field[]): string[] {
|
|
| 421 |
return fields.filter((f) => f.key !== locked).map((f) => f.key);
|
| 422 |
}
|
| 423 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 424 |
/** `{perms, fields_by_module}` β everything the editor renders. Returns `null`
|
| 425 |
* only for a body that is not an object at all; a body missing either half
|
| 426 |
* parses to an editor with nothing to offer, which is the honest rendering of
|
|
@@ -520,6 +797,97 @@ export function hiddenSet(rec: PermsRecord, key: string): ReadonlySet<string> {
|
|
| 520 |
return new Set(rec[key]?.hiddenFields ?? []);
|
| 521 |
}
|
| 522 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 523 |
export function filterOf(rec: PermsRecord, key: string): FilterTree {
|
| 524 |
// The panel takes a tree, never null β an absent filter is an EMPTY tree to
|
| 525 |
// edit, which is what "add your first condition" has to render against.
|
|
|
|
| 193 |
|
| 194 |
export type PermsRecord = Record<string, PermsEntry>;
|
| 195 |
|
| 196 |
+
/**
|
| 197 |
+
* ββ W40-T16 (owner instruction 13 / contract C3) β ONE FIELD OF THE PERMISSIONING LIST: a
|
| 198 |
+
* `Field` plus the one thing only this list knows, which is whether the row stands for a bound
|
| 199 |
+
* MEASURE rather than for a stored column.
|
| 200 |
+
*
|
| 201 |
+
* β THE FLAG CANNOT BE CALLED `metric`, AND THAT IS A COLLISION RATHER THAN A PREFERENCE.
|
| 202 |
+
* `customer-grid/types.ts::Field` already declares `metric?: {source?, measure, window, agg?}` β
|
| 203 |
+
* an OBJECT, the definition of a Metric COLUMN. C3's wire flag is a BOOLEAN meaning "this
|
| 204 |
+
* pseudo-field stands for a measure". Two types under one name on one interface do not compile,
|
| 205 |
+
* and `types.ts` belongs to another fence, so the translation happens HERE at `parseField` β
|
| 206 |
+
* the boundary whose entire job is translating the wire into what this editor renders.
|
| 207 |
+
*
|
| 208 |
+
* β OPTIONAL, WHICH IS LOAD-BEARING RATHER THAN CAUTIOUS. A plain `Field[]` stays assignable to
|
| 209 |
+
* `PermsField[]` only while the added key is optional, and the grid toolbar's own hide panel
|
| 210 |
+
* passes exactly that. A required flag would red the build in a file this ticket may not repair.
|
| 211 |
+
*/
|
| 212 |
+
export interface PermsField extends Field {
|
| 213 |
+
/** C3's `metric: true`. `=== true`, so ABSENCE MEANS NO β the exact opposite of `filterable`,
|
| 214 |
+
* where absence means yes. That asymmetry is why the two are parsed in different tickets. */
|
| 215 |
+
isMetric?: boolean;
|
| 216 |
+
}
|
| 217 |
+
|
| 218 |
+
/**
|
| 219 |
+
* ββ W40-T16 β HOW A METRIC ROW READS. Owner instruction 13, verbatim: *"one row per metric,
|
| 220 |
+
* named 'Metric - Revenue', 'Metric - Order' and so on, so a user can check the ones the
|
| 221 |
+
* permissioning is limited to"*.
|
| 222 |
+
*
|
| 223 |
+
* β THE SEPARATOR IS AN ASCII HYPHEN-MINUS AND THAT IS DELIBERATE. CLAUDE.md rule 2 bans the EM
|
| 224 |
+
* dash (U+2014) and the EN dash (U+2013) from anything that reaches a screen. `-` is neither,
|
| 225 |
+
* and it is the character the instruction itself is written with.
|
| 226 |
+
*
|
| 227 |
+
* β THE GUARD IS THE WHOLE REASON THIS IS A FUNCTION. `_module_fields` is free to label its
|
| 228 |
+
* `measure_`-namespaced pseudo-fields fully, so the word may already be on the wire; prefixing
|
| 229 |
+
* one that carries it ships "Metric - Metric - Revenue". A label that already begins with the
|
| 230 |
+
* word is therefore taken AS IT STANDS.
|
| 231 |
+
*
|
| 232 |
+
* β IT TAKES THE RESOLVED NAME, NOT THE FIELD, and that is forced rather than tidy. The ONE name
|
| 233 |
+
* resolver is `customer-grid/types.ts::fieldLabel` (wave 30 R5); `types.ts` imports `./windows`
|
| 234 |
+
* at RUNTIME, and `verify_login.py` runs THIS module's compiled artifact under bare node. A value
|
| 235 |
+
* import from there would drag that graph into the harness for the sake of one string, so the
|
| 236 |
+
* caller resolves the name with the house resolver and this function decides only the prefix.
|
| 237 |
+
*/
|
| 238 |
+
export function metricLabel(name: string): string {
|
| 239 |
+
return name.toLowerCase().startsWith("metric") ? name : `Metric - ${name}`;
|
| 240 |
+
}
|
| 241 |
+
|
| 242 |
+
/**
|
| 243 |
+
* ββ W40-T17 (owner instruction 15 / contract C3, amendment AM-2) β WHICH FIELDS THE
|
| 244 |
+
* PERMISSION EDITOR'S HIDE LIST IS ABOUT. Owner, verbatim: *"stop displaying 'Shared with me' /
|
| 245 |
+
* 'Shared with everyone' fields under Hide Fields - permission on pre-set Fields only."*
|
| 246 |
+
*
|
| 247 |
+
* β AM-2 IS WHY THIS IS A SEPARATE VOCABULARY RATHER THAN A NARROWING OF THE PANEL'S SECTIONS.
|
| 248 |
+
* One payload carries two memberships because instructions 15 and 16 pull `_module_fields` in
|
| 249 |
+
* opposite directions: *"THE HIDE PANEL TAKES `metric || !custom`, the Filter builder takes
|
| 250 |
+
* everything with `filterable`."* Two consumers, two readings, one wire. A single list narrowed
|
| 251 |
+
* to satisfy both would satisfy neither.
|
| 252 |
+
*
|
| 253 |
+
* β THE `metric ||` HALF IS LOAD-BEARING AND IT IS NOT SYMMETRY. A measure column created on an
|
| 254 |
+
* Odoo grid is stored `source: "odoo", custom: true, derived: true` (`core/grid_events.py:1374`),
|
| 255 |
+
* so `!custom` alone would delete every per-metric checkbox W40-T16 shipped β the control owner
|
| 256 |
+
* instruction 13 asked for, gone, with every gate on it still green. A row that stands for a
|
| 257 |
+
* measure is in this list BECAUSE it is a measure, whatever stratum it was minted in.
|
| 258 |
+
*
|
| 259 |
+
* β IT DOES NOT READ `shared`, AND THAT IS DELIBERATE. `shared` decides which SECTION the grid's
|
| 260 |
+
* panel files a row under; `custom` decides whether the column is the database's own or somebody's
|
| 261 |
+
* addition to it, which is the question instruction 15 asks. A shared PRE-SET column (a route
|
| 262 |
+
* order is one: `shared: true` with no `custom`) is still the database's own column and stays.
|
| 263 |
+
*/
|
| 264 |
+
export function presetHideFields(fields: readonly PermsField[]): PermsField[] {
|
| 265 |
+
return fields.filter((f) => f.isMetric || !f.custom);
|
| 266 |
+
}
|
| 267 |
+
|
| 268 |
+
/**
|
| 269 |
+
* ββ W40-T18 (owner instruction 16) β THE STORED CONDITION WHOSE COLUMN IS GONE.
|
| 270 |
+
*
|
| 271 |
+
* Owner, verbatim: *"If the field is deleted, its permission filter goes with it."* The half
|
| 272 |
+
* that lives on the client is what the admin SEES in the meantime, and today it is a lie of
|
| 273 |
+
* omission: `filter-kit/ops.ts::withCurrentField` appends the unresolved key as its own picker
|
| 274 |
+
* row with `label: current` and no type mark, so a rule left over from a deleted column renders
|
| 275 |
+
* as `custom_1723489` sitting in the sentence looking like a field name.
|
| 276 |
+
*
|
| 277 |
+
* β THE CONDITION IS NOT DROPPED, AND THAT IS THE RULE RATHER THAN A CHOICE. This panel edits
|
| 278 |
+
* LIVE permission records at `settings/ModulePermsList`, and a rule that vanishes on render is a
|
| 279 |
+
* rule the admin never decided to delete β the same law `orphanModules` states one layer up
|
| 280 |
+
* (rule 3 in this file's header). It is MARKED and left removable instead.
|
| 281 |
+
*
|
| 282 |
+
* β THREE EXCLUSIONS, EACH LOAD-BEARING:
|
| 283 |
+
* - a key the module still declares but no longer OFFERS (`filterable: false`) is NOT this. It
|
| 284 |
+
* resolves through `fieldByKey`, keeps its own label, and `withCurrentField` appends it on
|
| 285 |
+
* purpose so narrowing the picker never orphans history.
|
| 286 |
+
* - `COHORT_FIELD` / `VIEW_FIELD` are leaves, not columns; they are passed IN rather than
|
| 287 |
+
* imported, because reading them from `customer-grid/types` would be a VALUE import that
|
| 288 |
+
* drags `./windows` into the bare-node harness `verify_login.py` runs this module under.
|
| 289 |
+
* - AN EMPTY FIELD MAP MEANS "not answered yet", NEVER "all deleted". A schema-less module and
|
| 290 |
+
* a payload still in flight both present as zero fields, and without `size` this would accuse
|
| 291 |
+
* every condition in the record at once.
|
| 292 |
+
*/
|
| 293 |
+
export function isDeletedFieldRef(
|
| 294 |
+
colId: string,
|
| 295 |
+
fields: { has(key: string): boolean; size: number },
|
| 296 |
+
measures: { has(key: string): boolean },
|
| 297 |
+
leafKeys: readonly string[]
|
| 298 |
+
): boolean {
|
| 299 |
+
if (colId === "" || fields.size === 0) return false;
|
| 300 |
+
if (leafKeys.includes(colId)) return false;
|
| 301 |
+
return !fields.has(colId) && !measures.has(colId);
|
| 302 |
+
}
|
| 303 |
+
|
| 304 |
+
/**
|
| 305 |
+
* What that row READS as at rest. One word, and the width is why.
|
| 306 |
+
*
|
| 307 |
+
* β THE ARITHMETIC, so the choice is arguable rather than a preference: `.cg-cond-field` is
|
| 308 |
+
* `flex: 0 1 136px`, and `96px` once the condition sits inside a group; index.css derives the
|
| 309 |
+
* readable text width as `clientWidth - padding - border - caret - mark`, leaving roughly 82px
|
| 310 |
+
* at the wide end, where "Days since order" (91.0px at 12.5px Inter) already runs over.
|
| 311 |
+
*
|
| 312 |
+
* β IT WOULD NOT CLIP, THOUGH, AND THE DISTINCTION MATTERS. `ops.ts`'s "about 15 characters"
|
| 313 |
+
* note was written about a NATIVE `<select>`, which truncates mid-glyph. This control is a
|
| 314 |
+
* button whose `.cg-fsel-label` carries `text-overflow: ellipsis`, so a longer label degrades to
|
| 315 |
+
* "Deleted coluβ¦" rather than breaking. One word is therefore a craft call, not a constraint:
|
| 316 |
+
* the slot reads COMPLETE at every nesting depth, which is what `ops.ts` means by "the label
|
| 317 |
+
* gives way, never the control".
|
| 318 |
+
*
|
| 319 |
+
* β SO THE RESTING ROW SAYS ONE WORD, IN AMBER, AND NOTHING MORE. The sentence below and the
|
| 320 |
+
* raw key both live on the picker's LIST, which the admin sees on opening the control to act.
|
| 321 |
+
* At rest the key is in the button's accessible name only. State it that way; do not claim the
|
| 322 |
+
* row explains itself standing still.
|
| 323 |
+
*
|
| 324 |
+
* β NO EM DASH AND NO EN DASH (CLAUDE.md rule 2) β both of these reach a screen.
|
| 325 |
+
*/
|
| 326 |
+
export const DELETED_FIELD_LABEL = "Deleted";
|
| 327 |
+
|
| 328 |
+
/** The sentence across the top of the picker list (`FieldSelectButton`'s `title`, which paints
|
| 329 |
+
* `.cg-pop-title`). One line, per DESIGN.md "never over-explain". */
|
| 330 |
+
export const DELETED_FIELD_NOTE = "This column no longer exists.";
|
| 331 |
+
|
| 332 |
+
/** The three members of `customer-grid/FieldSelect.tsx::FieldSelectItem` this rewrite touches.
|
| 333 |
+
* RESTATED rather than imported: that file is a `.tsx`, and `verify_login.py` compiles this
|
| 334 |
+
* module with no `--jsx`, so even a type-only import from it would put a JSX file in the
|
| 335 |
+
* harness's compilation. Every other member of the real interface rides through untouched
|
| 336 |
+
* because the rewrite spreads the row it replaces. */
|
| 337 |
+
export interface DeletableFieldRow {
|
| 338 |
+
key: string;
|
| 339 |
+
label: string;
|
| 340 |
+
hint?: string;
|
| 341 |
+
}
|
| 342 |
+
|
| 343 |
+
/**
|
| 344 |
+
* Re-label the one picker row `withCurrentField` synthesised for a key nothing resolves.
|
| 345 |
+
*
|
| 346 |
+
* β THE RAW KEY IS NOT THROWN AWAY, it MOVES: out of the label, where it impersonated a field
|
| 347 |
+
* name, and into `hint` β the muted second line `FieldSelect` already paints under a row's
|
| 348 |
+
* label. Support can still read it, and it reads as evidence rather than as a column.
|
| 349 |
+
*/
|
| 350 |
+
export function withDeletedFieldLabel<T extends DeletableFieldRow>(
|
| 351 |
+
rows: readonly T[],
|
| 352 |
+
colId: string
|
| 353 |
+
): T[] {
|
| 354 |
+
return rows.map((row) =>
|
| 355 |
+
row.key === colId ? { ...row, label: DELETED_FIELD_LABEL, hint: colId } : row
|
| 356 |
+
);
|
| 357 |
+
}
|
| 358 |
+
|
| 359 |
/** A module the editor can draw a full rule for: it came with a field list. */
|
| 360 |
export interface PermsModule {
|
| 361 |
key: string;
|
| 362 |
label: string;
|
| 363 |
+
/** Empty β no readable schema β access toggle only (rule 1 above).
|
| 364 |
+
* β W40-T16 β `PermsField[]`, so C3's per-metric rows survive the parse into what the hide
|
| 365 |
+
* panel renders. Every consumer that wanted `Field[]` still compiles: the added key is
|
| 366 |
+
* optional, so the two array types are assignable in both directions. */
|
| 367 |
+
fields: PermsField[];
|
| 368 |
/** An app surface (Assistant, Agents): access is the whole rule, by construction and
|
| 369 |
* not by a missing schema, so the row can say so instead of apologising. */
|
| 370 |
surface?: boolean;
|
|
|
|
| 469 |
* `key` and `label` are the minimum that makes a row renderable β a field
|
| 470 |
* without them cannot be shown OR named in a rule, so it is skipped rather
|
| 471 |
* than rendered as a blank the admin might tick. */
|
| 472 |
+
export function parseField(raw: unknown): PermsField | null {
|
| 473 |
if (!raw || typeof raw !== "object") return null;
|
| 474 |
const r = raw as Record<string, unknown>;
|
| 475 |
if (typeof r.key !== "string" || r.key === "") return null;
|
|
|
|
| 479 |
key: r.key,
|
| 480 |
label,
|
| 481 |
type: fieldType(r.type),
|
| 482 |
+
// ββ W40-T16 (owner instruction 13 / C3) β THE METRIC FLAG.
|
| 483 |
+
// β `=== true`, so an absent key means NO. `filterable` is the opposite (absent means yes),
|
| 484 |
+
// which is exactly why the two cannot be added in one careless sweep.
|
| 485 |
+
...(r.metric === true ? { isMetric: true } : {}),
|
| 486 |
+
// ββ W40-T17 (owner instruction 15 / C3) β THE TWO MEMBERSHIP FLAGS, AND THEY COULD NOT
|
| 487 |
+
// LAND ON THEIR OWN. `FieldsHidePanel` files a field under "Shared with me" or "Shared with
|
| 488 |
+
// everyone" from `custom || shared`, and `customer-grid/types.ts::fieldEditMode` answers
|
| 489 |
+
// "collaborative" whenever a definition carries no `permissions` bag β which every field on
|
| 490 |
+
// THIS wire does, because `_module_fields` sends none. So the instant these two parse, every
|
| 491 |
+
// custom or shared column in the manage-user room lands under "Shared with everyone": the
|
| 492 |
+
// exact list owner instruction 15 asks us to stop drawing. The gate that stops it is
|
| 493 |
+
// `sharedSections={false}` on the manage-user mount, and it ships in this same change. Land
|
| 494 |
+
// either half alone and the product holds the defect between them.
|
| 495 |
+
// β `=== true` FOR BOTH, matching the metric flag one line up and OPPOSING `filterable`
|
| 496 |
+
// (W40-T18), where absence means yes. That asymmetry lives inside this one function on
|
| 497 |
+
// purpose: it is the shape a careless sweep gets wrong.
|
| 498 |
+
...(r.custom === true ? { custom: true } : {}),
|
| 499 |
+
...(r.shared === true ? { shared: true } : {}),
|
| 500 |
+
// ββ W40-T18 (owner instruction 16 / C3) β THE FILTER FLAG, AND IT IS READ BACKWARDS FROM
|
| 501 |
+
// THE THREE ABOVE ON PURPOSE. `customer-grid/types.ts::filterableFields` is
|
| 502 |
+
// `fields.filter((f) => f.filterable !== false)`: ABSENCE MEANS FILTERABLE. So the property
|
| 503 |
+
// is emitted ONLY when the wire says `false` outright, and a payload that never mentions it
|
| 504 |
+
// parses WITHOUT the key β which is what leaves every such column offered.
|
| 505 |
+
// β `filterable: r.filterable === true` is the shape this ships broken in: every field on
|
| 506 |
+
// today's server lacks the key, so all of them would parse `false` and the permission filter
|
| 507 |
+
// builder would offer NOTHING AT ALL, with the parse looking symmetrical and correct.
|
| 508 |
+
// Three flags one way, one flag the other, inside one function. Read the predicate, not the
|
| 509 |
+
// neighbours.
|
| 510 |
+
...(r.filterable === false ? { filterable: false } : {}),
|
| 511 |
// Anything not explicitly the overlay stratum is treated as source data.
|
| 512 |
// Consequence in this editor: nothing here offers to EDIT a field, so the
|
| 513 |
// only thing `source` drives is the "Pre-set" chip in the hide list.
|
|
|
|
| 532 |
* list, which R9 already has a defined rendering for (access toggle only). */
|
| 533 |
export function parseModule(key: string, label: string, raw: unknown,
|
| 534 |
surface = false): PermsModule {
|
| 535 |
+
const fields: PermsField[] = [];
|
| 536 |
for (const f of Array.isArray(raw) ? raw : []) {
|
| 537 |
const parsed = parseField(f);
|
| 538 |
if (parsed) fields.push(parsed);
|
|
|
|
| 616 |
return fields.filter((f) => f.key !== locked).map((f) => f.key);
|
| 617 |
}
|
| 618 |
|
| 619 |
+
/**
|
| 620 |
+
* ββ W40-T17 β THE KEYS THE PERMISSION EDITOR'S HIDE LIST ACTUALLY GOVERNS: what it LISTS
|
| 621 |
+
* (`presetHideFields`, AM-2's `metric || !custom`) minus the one row it can never hide.
|
| 622 |
+
*
|
| 623 |
+
* ββ THE LOCKED KEY IS RESOLVED FROM THE **FULL** LIST, AND SWAPPING THAT IS A SILENT
|
| 624 |
+
* MIS-LOCK. `identityKey` is "the pinned field, else THE FIRST", so
|
| 625 |
+
* `identityKey(presetHideFields(fields))` would answer with whatever survives the narrowing
|
| 626 |
+
* first β on any module whose identity column were ever filtered out, a perfectly ordinary
|
| 627 |
+
* column would be treated as the one that cannot be hidden, while the real identity column
|
| 628 |
+
* became hideable. The panel's own `lockedKey={identityKey(module.fields)}` reads the full list
|
| 629 |
+
* for exactly this reason, and these two must agree or the row that is disabled on screen is not
|
| 630 |
+
* the row the bulk action protects.
|
| 631 |
+
*/
|
| 632 |
+
export function governedFieldKeys(fields: readonly PermsField[]): string[] {
|
| 633 |
+
const locked = identityKey(fields);
|
| 634 |
+
return presetHideFields(fields).map((f) => f.key).filter((k) => k !== locked);
|
| 635 |
+
}
|
| 636 |
+
|
| 637 |
+
/**
|
| 638 |
+
* ββ W40-T17 β "Hide all", SCOPED TO WHAT THE ROOM SHOWS.
|
| 639 |
+
*
|
| 640 |
+
* β WHY THIS IS NOT `hideableKeys(fields)` ANY MORE, AND WHY W40-T17 IS THE TICKET THAT OWES
|
| 641 |
+
* THE CHANGE. Before the narrowing, the permission editor LISTED every field a module had, so a
|
| 642 |
+
* whole-list replace and the list on screen named the same set. This ticket narrows the list to
|
| 643 |
+
* the database's own pre-set columns plus its bound measures, and a bulk action that kept
|
| 644 |
+
* replacing the WHOLE list would then write hidden keys for columns the admin cannot see in the
|
| 645 |
+
* room they clicked in β a restriction nobody was shown, which is the one thing this file's
|
| 646 |
+
* header forbids.
|
| 647 |
+
*
|
| 648 |
+
* β SO IT REPLACES A SLICE, NOT THE RECORD: the stored list minus the governed keys, plus the
|
| 649 |
+
* governed keys. Anything the record already hid that this room does not govern is carried
|
| 650 |
+
* through untouched, exactly as `copyTargetRecord`'s module scope carries the target's other
|
| 651 |
+
* modules.
|
| 652 |
+
*
|
| 653 |
+
* β AND THE IDENTITY KEY IS STRIPPED ON THE WAY OUT even though `governedFieldKeys` already
|
| 654 |
+
* excludes it. A record written elsewhere could name it, and a "carry the ungoverned keys
|
| 655 |
+
* through" rule would faithfully carry THAT one through as well β re-creating the table of blank
|
| 656 |
+
* rows this file's `identityKey` header exists to prevent, through the very control that used to
|
| 657 |
+
* be immune to it because it replaced the list wholesale. `toPutBody` strips it again at the PUT
|
| 658 |
+
* boundary; two layers, for the reason stated there.
|
| 659 |
+
*/
|
| 660 |
+
export function hideAllKeys(
|
| 661 |
+
rec: PermsRecord,
|
| 662 |
+
key: string,
|
| 663 |
+
fields: readonly PermsField[],
|
| 664 |
+
): string[] {
|
| 665 |
+
const governed = governedFieldKeys(fields);
|
| 666 |
+
const governedSet = new Set(governed);
|
| 667 |
+
const locked = identityKey(fields);
|
| 668 |
+
const stored = rec[key]?.hiddenFields ?? [];
|
| 669 |
+
return normalizeHidden(
|
| 670 |
+
[...stored.filter((k) => !governedSet.has(k)), ...governed].filter((k) => k !== locked));
|
| 671 |
+
}
|
| 672 |
+
|
| 673 |
+
/**
|
| 674 |
+
* ββ W40-T17 β "Show all", SCOPED THE SAME WAY, AND THIS IS THE HALF THAT MATTERS MOST.
|
| 675 |
+
*
|
| 676 |
+
* ββ IT SUBTRACTS, IT DOES NOT CLEAR. The old spelling was `onSetHidden([])`: an empty list,
|
| 677 |
+
* i.e. nothing is hidden on this database at all. Under a narrowed list that control REVEALS
|
| 678 |
+
* columns the admin was never shown β it WIDENS a permission through a button whose own list did
|
| 679 |
+
* not contain the fields it just un-hid. "Hide all" over-reaching is dishonest and fails safe;
|
| 680 |
+
* "Show all" over-reaching fails OPEN, and a permissions screen is not allowed to get that
|
| 681 |
+
* direction wrong.
|
| 682 |
+
*
|
| 683 |
+
* β IT READS THE **STORED** `hiddenFields`, NEVER `hiddenSetFor`. That union is a READ-SIDE view
|
| 684 |
+
* that paints every metric row hidden while a legacy blanket `metrics: false` stands; feeding it
|
| 685 |
+
* into a write would persist the blanket as explicit keys from a control that is supposed to be
|
| 686 |
+
* clearing them. The blanket's conversion has exactly one door β `normalizeMetrics`, which
|
| 687 |
+
* `PermsEditor` already runs in front of every hidden-field write β and adding a second here is
|
| 688 |
+
* how two normalisers come to disagree.
|
| 689 |
+
*/
|
| 690 |
+
export function showAllKeys(
|
| 691 |
+
rec: PermsRecord,
|
| 692 |
+
key: string,
|
| 693 |
+
fields: readonly PermsField[],
|
| 694 |
+
): string[] {
|
| 695 |
+
const governedSet = new Set(governedFieldKeys(fields));
|
| 696 |
+
const locked = identityKey(fields);
|
| 697 |
+
const stored = rec[key]?.hiddenFields ?? [];
|
| 698 |
+
return normalizeHidden(stored.filter((k) => !governedSet.has(k) && k !== locked));
|
| 699 |
+
}
|
| 700 |
+
|
| 701 |
/** `{perms, fields_by_module}` β everything the editor renders. Returns `null`
|
| 702 |
* only for a body that is not an object at all; a body missing either half
|
| 703 |
* parses to an editor with nothing to offer, which is the honest rendering of
|
|
|
|
| 797 |
return new Set(rec[key]?.hiddenFields ?? []);
|
| 798 |
}
|
| 799 |
|
| 800 |
+
/**
|
| 801 |
+
* ββ W40-T16 β WHAT THE HIDE PANEL ACTUALLY DRAWS AS HIDDEN: the stored list, UNION every
|
| 802 |
+
* metric row when a legacy blanket revocation stands.
|
| 803 |
+
*
|
| 804 |
+
* β THE CASE IT EXISTS FOR IS THE TICKET'S OWN NEGATIVE CONTROL: *"a user whose saved record
|
| 805 |
+
* predates this still has their old blanket metrics setting honoured"*. `PermsEntry.metrics` is
|
| 806 |
+
* one boolean over the whole database (W38-T19), and this ticket replaces the control that wrote
|
| 807 |
+
* it with one checkbox per metric. A record already carrying `metrics: false` therefore has a
|
| 808 |
+
* revocation with nothing on screen expressing it β the panel would paint every metric row as
|
| 809 |
+
* granted while `perm_scope.may_metrics` refuses the lot.
|
| 810 |
+
*
|
| 811 |
+
* β A READ-SIDE UNION, NEVER A REWRITE ON LOAD. Folding the blanket into `hiddenFields` when the
|
| 812 |
+
* record parses would edit somebody's stored rule as a side effect of an admin OPENING the page,
|
| 813 |
+
* and the first unrelated Save would persist it. `metrics` stays on the wire, in `parseEntry` and
|
| 814 |
+
* in `toPutBody`, exactly as W38-T19 left it; this function only decides how it READS.
|
| 815 |
+
*
|
| 816 |
+
* β A NEW EXPORT RATHER THAN A WIDER `hiddenSet`. `verify_login.py` compiles
|
| 817 |
+
* `shell/_test/shell.test.ts` in the same tsc call as this file's own suite, and re-signing an
|
| 818 |
+
* existing export reds a gate in a file this ticket may not repair. `hiddenSet` is still the base
|
| 819 |
+
* and is called below, so there is ONE spelling of "the keys the record hides".
|
| 820 |
+
*/
|
| 821 |
+
export function hiddenSetFor(
|
| 822 |
+
rec: PermsRecord,
|
| 823 |
+
key: string,
|
| 824 |
+
fields: readonly PermsField[],
|
| 825 |
+
): ReadonlySet<string> {
|
| 826 |
+
const keys = new Set(hiddenSet(rec, key));
|
| 827 |
+
if (rec[key]?.metrics === false) {
|
| 828 |
+
for (const f of fields) if (f.isMetric) keys.add(f.key);
|
| 829 |
+
}
|
| 830 |
+
return keys;
|
| 831 |
+
}
|
| 832 |
+
|
| 833 |
+
/**
|
| 834 |
+
* ββ W40-T16 β THE WRITE-SIDE HALF OF `hiddenSetFor`, AND WITHOUT IT THE READ-SIDE HALF IS A
|
| 835 |
+
* TRAP. Called at the top of every hidden-field write: a blanket `metrics: false` becomes the
|
| 836 |
+
* EXPLICIT per-metric state instruction 13 asks for, exactly once, at the moment an admin edits.
|
| 837 |
+
*
|
| 838 |
+
* ββ THE DEFECT IT CLOSES, STATED AS THE STATE IT WOULD OTHERWISE LEAVE. `hiddenSetFor` unions
|
| 839 |
+
* every metric key while `metrics === false`, so on such a record a metric row reads hidden and
|
| 840 |
+
* CANNOT BE MADE VISIBLE AGAIN: unticking it writes the key into `hiddenFields`, the union
|
| 841 |
+
* re-hides it, "Show all" is inert for it, and β because W40-T16 retires the blanket box and
|
| 842 |
+
* nothing else in the UI writes `PermsEntry.metrics` β the revocation is permanent and has no
|
| 843 |
+
* exit. That makes this ticket's own `done-when` ("checking one hides exactly that metric")
|
| 844 |
+
* FALSE for those records. A read-side union alone is half a feature.
|
| 845 |
+
*
|
| 846 |
+
* β ON EDIT, NEVER ON LOAD, AND THE TWO ARE DIFFERENT IN KIND. Rewriting when the record parses
|
| 847 |
+
* would edit somebody's stored rule as a side effect of an admin OPENING a page, and the first
|
| 848 |
+
* unrelated Save would persist a decision nobody made. An edit is a decision: the admin is
|
| 849 |
+
* already changing this database's hidden fields.
|
| 850 |
+
*
|
| 851 |
+
* β THE UNION IS WHAT MAKES IT LOSSLESS. What the blanket MEANT (every metric hidden) becomes
|
| 852 |
+
* what the record SAYS, so effective permissions do not move by a single field at the moment of
|
| 853 |
+
* normalisation β only their spelling does. A rewrite that dropped the metrics would silently
|
| 854 |
+
* GRANT them; one that kept `metrics: false` would change nothing.
|
| 855 |
+
*
|
| 856 |
+
* β A NO-OP OTHERWISE, RETURNING `rec` ITSELF rather than a copy. Every setter here is immutable
|
| 857 |
+
* so that `isDirty` compares against an unmutated snapshot; a fresh object on every keystroke of
|
| 858 |
+
* an ordinary edit would be churn with no meaning, and reference identity is what lets a caller
|
| 859 |
+
* compose this in front of any write without paying for it.
|
| 860 |
+
*/
|
| 861 |
+
export function normalizeMetrics(
|
| 862 |
+
rec: PermsRecord,
|
| 863 |
+
key: string,
|
| 864 |
+
fields: readonly PermsField[],
|
| 865 |
+
): PermsRecord {
|
| 866 |
+
const cur = rec[key];
|
| 867 |
+
if (!cur || cur.metrics !== false) return rec;
|
| 868 |
+
const metricKeys = fields.filter((f) => f.isMetric).map((f) => f.key);
|
| 869 |
+
// ββ THE EMPTY CASE IS THE ONE THE PARAGRAPH ABOVE RULES OUT, AND IT IS REACHABLE TODAY.
|
| 870 |
+
// "THE UNION IS WHAT MAKES IT LOSSLESS ... a rewrite that DROPPED the metrics would silently
|
| 871 |
+
// GRANT them" is exactly what happens when `metricKeys` is empty: `metrics` flips to `true`,
|
| 872 |
+
// nothing is added to `hiddenFields`, and an explicit revocation an admin once made is gone.
|
| 873 |
+
//
|
| 874 |
+
// Not hypothetical. `customer_data` binds NO measures at all: `model/topics/odoo_customers.yml`
|
| 875 |
+
// declares no `measures:` key, so `routes_admin::_metric_fields('customer_data')` returns `[]`
|
| 876 |
+
// and every field arrives `isMetric: false`. Any legacy `customer_data` record carrying
|
| 877 |
+
// `metrics: false` therefore had its revocation erased by the admin's next unrelated
|
| 878 |
+
// hidden-field edit, with `isDirty` lighting up Save on a change nobody made.
|
| 879 |
+
//
|
| 880 |
+
// β AND RETURNING EARLY REINTRODUCES NOTHING. The trap this function exists to close is
|
| 881 |
+
// `hiddenSetFor` unioning metric keys into the hidden set so a metric ROW cannot be un-hidden.
|
| 882 |
+
// With no metric fields there is no such row, so there is nothing to be trapped by and nothing
|
| 883 |
+
// to normalise. Found by wave 40 QA; the mechanism itself is correct wherever metrics exist.
|
| 884 |
+
if (!metricKeys.length) return rec;
|
| 885 |
+
return withEntry(rec, key, {
|
| 886 |
+
metrics: true,
|
| 887 |
+
hiddenFields: normalizeHidden([...cur.hiddenFields, ...metricKeys]),
|
| 888 |
+
});
|
| 889 |
+
}
|
| 890 |
+
|
| 891 |
export function filterOf(rec: PermsRecord, key: string): FilterTree {
|
| 892 |
// The panel takes a tree, never null β an absent filter is an EMPTY tree to
|
| 893 |
// edit, which is what "add your first condition" has to render against.
|
web/src/shell/Shell.tsx
CHANGED
|
@@ -235,28 +235,19 @@ const NAV_DRAG_TYPE = "application/x-loopable-nav";
|
|
| 235 |
/** A stable identity for "no nav yet" β see its use below. */
|
| 236 |
const NO_ENTRIES: NavEntry[] = [];
|
| 237 |
|
| 238 |
-
/*
|
| 239 |
-
|
| 240 |
-
|
| 241 |
-
* The
|
| 242 |
-
|
| 243 |
-
|
| 244 |
-
|
| 245 |
-
|
| 246 |
-
|
| 247 |
-
|
| 248 |
-
|
| 249 |
-
|
| 250 |
-
|
| 251 |
-
* which is what lets the grid run inside another host), and a STATIC import of a constant out of
|
| 252 |
-
* `CustomerGrid.tsx` would drag the whole spreadsheet engine into the shell's entry chunk, undoing
|
| 253 |
-
* the `lazy()` at :60 that keeps it out. So the canonical declaration is
|
| 254 |
-
* `CustomerGrid.tsx::GRID_CHAT_OPEN_EVENT`, this is its twin, and the divergence they invite is
|
| 255 |
-
* closed by a control rather than by a comment: `verify_wiring.py`'s W38-T06 row matches the
|
| 256 |
-
* LITERAL `aios:grid-chat-open` on both sides, so a typo in either spelling reds `web_wiring`.
|
| 257 |
-
* β Move both to `apiContract.ts` the next time a ticket owns that file. See PENDING.
|
| 258 |
-
*/
|
| 259 |
-
const GRID_CHAT_OPEN_EVENT = "aios:grid-chat-open";
|
| 260 |
|
| 261 |
/**
|
| 262 |
* WAVE 23 C10 β the Database flyout's anchor, CLAMPED to the viewport.
|
|
@@ -2175,55 +2166,22 @@ function ShellFrame() {
|
|
| 2175 |
the tooltips and the account menu all hang off this subtree, and unmounting them for
|
| 2176 |
the length of a fetch would tear down state that has nothing to do with the nav. */}
|
| 2177 |
{railLoading ? <RailSkeleton /> : null}
|
| 2178 |
-
{/*
|
| 2179 |
-
|
| 2180 |
-
|
| 2181 |
-
|
| 2182 |
-
|
| 2183 |
-
|
| 2184 |
-
the
|
| 2185 |
-
|
| 2186 |
-
|
| 2187 |
-
|
| 2188 |
-
|
| 2189 |
-
|
| 2190 |
-
|
| 2191 |
-
|
| 2192 |
-
|
| 2193 |
-
|
| 2194 |
-
name β `.shell-side-bottom` next door had to become a sibling for the mirror-image
|
| 2195 |
-
reason, and its comment records the cost.
|
| 2196 |
-
β THE TIP IS NOT DECORATION. Collapsed, `.shell-nav-label` folds to zero width, so
|
| 2197 |
-
every rail row buys its name back through `tipEnter`; a glyph without one is the
|
| 2198 |
-
unlabelled-icon trap the Templates row's comment names. Unconditional here rather than
|
| 2199 |
-
ternary, because this control exists only in the state that needs it.
|
| 2200 |
-
β Clicking it with no grid mounted is a NO-OP BY CONSTRUCTION, twice over: `signal()`
|
| 2201 |
-
dispatches into a window with no listener, and the grid's listener is itself absent on
|
| 2202 |
-
an embedded or Query surface, matching the `!embedded && !queryBinding` guard that
|
| 2203 |
-
decides whether `<GridChat>` can mount at all (`CustomerGrid.tsx`, the chat dock). */}
|
| 2204 |
-
{navCollapsed ? (
|
| 2205 |
-
<button
|
| 2206 |
-
type="button"
|
| 2207 |
-
className="shell-rail-chat"
|
| 2208 |
-
aria-label="Ask about this data"
|
| 2209 |
-
title="Ask about this data"
|
| 2210 |
-
onClick={() => signal(GRID_CHAT_OPEN_EVENT)}
|
| 2211 |
-
onMouseEnter={tipEnter("Ask about this data")}
|
| 2212 |
-
onMouseLeave={tipLeave}
|
| 2213 |
-
>
|
| 2214 |
-
{/* The views rail's own chat glyph, redrawn identically. One mark, one meaning
|
| 2215 |
-
(DESIGN.md Β§4) β two doors onto one panel must not wear two different icons. */}
|
| 2216 |
-
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" aria-hidden="true">
|
| 2217 |
-
<path
|
| 2218 |
-
d="M13.4 9.2c0 1.5-1.3 2.7-2.9 2.7H6.9l-3 2.1v-2.3a2.8 2.8 0 0 1-1.3-2.3V5.1c0-1.5 1.3-2.7 2.9-2.7h5c1.6 0 2.9 1.2 2.9 2.7z"
|
| 2219 |
-
stroke="currentColor"
|
| 2220 |
-
strokeWidth="1.3"
|
| 2221 |
-
strokeLinejoin="round"
|
| 2222 |
-
/>
|
| 2223 |
-
<path d="M5.9 7.2h4.2" stroke="currentColor" strokeWidth="1.3" strokeLinecap="round" />
|
| 2224 |
-
</svg>
|
| 2225 |
-
</button>
|
| 2226 |
-
) : null}
|
| 2227 |
{/* β WAVE 23 item 9 (R7, contract C10) β HOME, the new landing, at the top of the rail.
|
| 2228 |
An `<a>` to a CHROME route: it needs no grant because it renders nothing the server
|
| 2229 |
did not already send (nav.ts' `CHROME_ROUTES` note carries the full argument, and
|
|
|
|
| 235 |
/** A stable identity for "no nav yet" β see its use below. */
|
| 236 |
const NO_ENTRIES: NavEntry[] = [];
|
| 237 |
|
| 238 |
+
/* ββ W40-T22 (owner instruction 5, 2026-08-23) β `const GRID_CHAT_OPEN_EVENT` STOOD HERE, WITH A
|
| 239 |
+
long argument for the shellβgrid "open the chat" channel, AND IT IS DELETED. The owner: *"remove
|
| 240 |
+
[the 'Ask about this data' icon] from the MAIN navigation entirely so it lives only in the
|
| 241 |
+
secondary navigation"*. The twin constant existed for exactly ONE raiser β the minimised rail's
|
| 242 |
+
launcher, deleted in the same ticket β so the argument it carried (why the literal is typed twice
|
| 243 |
+
rather than imported) is an argument for a control that no longer exists, and leaving it standing
|
| 244 |
+
is how the control comes back.
|
| 245 |
+
β THE GRID SIDE IS UNTOUCHED AND THAT IS DELIBERATE: `CustomerGrid.tsx` still exports the same
|
| 246 |
+
constant and still listens on it, and `ViewSidebar.tsx`'s `cg-chat-toggle` opens the panel
|
| 247 |
+
directly through `onToggleChat` rather than through the event. The listener is now dormant, not
|
| 248 |
+
broken; removing it is a separate decision and `CustomerGrid.tsx` was outside this ticket.
|
| 249 |
+
β `verify_wiring.py`'s two W38-T06 rows, which asserted this constant and its click, are deleted
|
| 250 |
+
with it and carry their own tombstone there. */
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 251 |
|
| 252 |
/**
|
| 253 |
* WAVE 23 C10 β the Database flyout's anchor, CLAMPED to the viewport.
|
|
|
|
| 2166 |
the tooltips and the account menu all hang off this subtree, and unmounting them for
|
| 2167 |
the length of a fetch would tear down state that has nothing to do with the nav. */}
|
| 2168 |
{railLoading ? <RailSkeleton /> : null}
|
| 2169 |
+
{/* ββ W40-T22 (owner instruction 5, 2026-08-23) β WAVE 38 Β· T06's CHAT LAUNCHER STOOD
|
| 2170 |
+
HERE β a `navCollapsed`-only `<button>` wearing the `shell-rail-chat` class β AND IS
|
| 2171 |
+
DELETED, WITH ITS RULE IN `index.css` AND ITS TWO `verify_wiring.py` ROWS. Owner:
|
| 2172 |
+
*"remove it from the MAIN navigation entirely so it lives only in the secondary
|
| 2173 |
+
navigation"*.
|
| 2174 |
+
β IT WAS NOT A LEFTOVER AND THE COMMENT THAT STOOD HERE ARGUED WELL FOR IT: two doors
|
| 2175 |
+
onto one panel, the collapsed rail's and the views rail's, wearing one glyph. The owner
|
| 2176 |
+
has ruled that one door is right and it is the views rail's (`ViewSidebar.tsx`'s
|
| 2177 |
+
`cg-chat-toggle`), which sits beside the data the chat is about instead of on a frame
|
| 2178 |
+
that is often looking at no grid at all. That also settles what the argument here never
|
| 2179 |
+
could: collapsed, this control sat under the rail's own divider (`ERROR 9.png`), and a
|
| 2180 |
+
control with nowhere clean to sit in the one state it exists in is a control in the
|
| 2181 |
+
wrong rail.
|
| 2182 |
+
β DO NOT RESTORE IT AS A SECOND DOOR. `signal()`, `tipEnter`/`tipLeave` and
|
| 2183 |
+
`navCollapsed` all survive here for other rows; what is gone is the launcher, its
|
| 2184 |
+
`GRID_CHAT_OPEN_EVENT` twin (tombstoned at the top of this file) and nothing else. */}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2185 |
{/* β WAVE 23 item 9 (R7, contract C10) β HOME, the new landing, at the top of the rail.
|
| 2186 |
An `<a>` to a CHROME route: it needs no grant because it renders nothing the server
|
| 2187 |
did not already send (nav.ts' `CHROME_ROUTES` note carries the full argument, and
|