Deploy AIOS web (React glide grid + FastAPI slice)
Browse files- api/routes_grid.py +176 -9
- royalimports_os/aios_grid.py +106 -13
- royalimports_os/aios_grid_fields.json +84 -0
- royalimports_os/core/grid_events.py +36 -1
- royalimports_os/core/perms.py +40 -1
- royalimports_os/core/registry.py +30 -5
- royalimports_os/modules/ar.py +34 -1
- royalimports_os/modules/customer_data.py +13 -0
- royalimports_os/modules/product_data.py +100 -2
- web/dist-embed/index.html +0 -0
- web/dist-embed/sample_customers.json +511 -479
- web/public/sample_customers.json +511 -479
- web/src/customer-grid/ColumnMenu.tsx +12 -1
- web/src/customer-grid/CustomerGrid.tsx +78 -266
- web/src/customer-grid/RecordComments.tsx +7 -1
- web/src/customer-grid/RecordDetail.tsx +6 -0
- web/src/customer-grid/TimeSeriesPanel.tsx +201 -40
- web/src/customer-grid/Toolbar.tsx +43 -15
- web/src/customer-grid/ViewSidebar.tsx +72 -88
- web/src/customer-grid/apiBridge.ts +51 -0
- web/src/customer-grid/iconShapes.ts +13 -4
- web/src/customer-grid/theme.ts +10 -18
- web/src/customer-grid/timeSeriesData.ts +213 -4
- web/src/customer-grid/types.ts +26 -3
- web/src/customer-grid/useGridColumns.ts +6 -16
- web/src/customer-grid/viewModes.tsx +189 -25
- web/src/index.css +404 -25
- web/src/pages/PageSurface.tsx +7 -1
- web/src/settings/PermsEditor.tsx +625 -29
- web/src/settings/SettingsModal.tsx +273 -299
- web/src/settings/permsModel.ts +66 -0
- web/src/shell/NavExtras.tsx +6 -1
- web/src/shell/Shell.tsx +39 -12
- web/src/shell/navExtras.css +53 -2
- web/src/viz/DashboardView.tsx +26 -8
- web/src/viz/chartData.ts +10 -0
api/routes_grid.py
CHANGED
|
@@ -376,10 +376,21 @@ def grid_timeseries(body: dict = Body(default=None), scope: str = "customer",
|
|
| 376 |
dropped.append({"field": k, "reason": "not_a_measure_field"})
|
| 377 |
continue
|
| 378 |
keys.append(k)
|
| 379 |
-
|
| 380 |
-
|
| 381 |
-
|
| 382 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 383 |
mfields, slid_keys = [], []
|
| 384 |
for k in keys:
|
| 385 |
m = dict(fdefs[k]["measure"])
|
|
@@ -390,10 +401,8 @@ def grid_timeseries(body: dict = Body(default=None), scope: str = "customer",
|
|
| 390 |
continue
|
| 391 |
mfields.append({"key": k, "measure": m})
|
| 392 |
slid_keys.append(k)
|
| 393 |
-
|
| 394 |
-
|
| 395 |
-
"every requested metric has a fixed date range - a fixed range cannot "
|
| 396 |
-
"slide across buckets")
|
| 397 |
if len(starts) * len(mfields) > _TS_MAX_CELLS:
|
| 398 |
raise err(400, "bad_timeseries",
|
| 399 |
"that ask is too wide - narrow the span or pick fewer metrics")
|
|
@@ -402,10 +411,12 @@ def grid_timeseries(body: dict = Body(default=None), scope: str = "customer",
|
|
| 402 |
stamp = _pool_stamp(rt, team_id, agent)
|
| 403 |
problems = []
|
| 404 |
bucket_bounds = [(s.isoformat(), e.isoformat()) for s, e in zip(starts, ends)]
|
|
|
|
|
|
|
| 405 |
answers = measure_resolve.series_values(
|
| 406 |
mfields, bucket, bucket_bounds,
|
| 407 |
team_id, frozenset(pool), today, stamp, rt.series_memo,
|
| 408 |
-
on_error=lambda tag, e: problems.append(str(e)[:200]))
|
| 409 |
|
| 410 |
columns = []
|
| 411 |
for s, e in zip(starts, ends):
|
|
@@ -445,6 +456,162 @@ def grid_timeseries(body: dict = Body(default=None), scope: str = "customer",
|
|
| 445 |
return {"columns": columns, "rows": rows, "meta": meta}
|
| 446 |
|
| 447 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 448 |
@router.post("/grid/events")
|
| 449 |
def grid_events_route(body: dict = Body(default=None),
|
| 450 |
session: Session = Depends(module_gate(MODULE))):
|
|
|
|
| 376 |
dropped.append({"field": k, "reason": "not_a_measure_field"})
|
| 377 |
continue
|
| 378 |
keys.append(k)
|
| 379 |
+
# β‘ WAVE 17 R9 (amendment 2026-08-03, GRID's cross-fence ask) β A SHEET WITH NO MEASURE
|
| 380 |
+
# FIELDS IS NO LONGER A 400. It answers with the BUCKET GRID and no rows.
|
| 381 |
+
#
|
| 382 |
+
# Why this is the honest direction and not a loosening: the bucket starts and their labels
|
| 383 |
+
# are SERVER math (`_ts_start_of` / `_ts_next` / `_ts_label`), and R9 has the client
|
| 384 |
+
# synthesizing snapshot rows for preset columns that have no window to slide. Those rows
|
| 385 |
+
# must be painted under the SAME headings as everything else, so the client needs the
|
| 386 |
+
# columns even when the server has no series to put in them. Refusing the whole request
|
| 387 |
+
# meant the panel could offer nothing at all on this tenant β the shipped contract has zero
|
| 388 |
+
# measure-backed presets (`aios_grid.py`: "this branch is currently MEMBERLESS"), which is
|
| 389 |
+
# what item 5 is actually about.
|
| 390 |
+
#
|
| 391 |
+
# Nothing is invented by this: `rows` is empty and `meta.dropped` NAMES every field and why.
|
| 392 |
+
# A 400 is still returned for a request that is malformed (bad bucket, bad span, no fields
|
| 393 |
+
# at all) β this only stops treating "I asked about columns you cannot serve" as an error.
|
| 394 |
mfields, slid_keys = [], []
|
| 395 |
for k in keys:
|
| 396 |
m = dict(fdefs[k]["measure"])
|
|
|
|
| 401 |
continue
|
| 402 |
mfields.append({"key": k, "measure": m})
|
| 403 |
slid_keys.append(k)
|
| 404 |
+
# Same amendment as above: every metric being fixed-range is a sheet with no SERIES, not a
|
| 405 |
+
# broken request. The columns still stand, and `window_fixed` still names each refusal.
|
|
|
|
|
|
|
| 406 |
if len(starts) * len(mfields) > _TS_MAX_CELLS:
|
| 407 |
raise err(400, "bad_timeseries",
|
| 408 |
"that ask is too wide - narrow the span or pick fewer metrics")
|
|
|
|
| 411 |
stamp = _pool_stamp(rt, team_id, agent)
|
| 412 |
problems = []
|
| 413 |
bucket_bounds = [(s.isoformat(), e.isoformat()) for s, e in zip(starts, ends)]
|
| 414 |
+
# No slidable metrics = nothing to resolve. Skipping the call rather than asking the
|
| 415 |
+
# resolver about an empty list keeps the memo free of a meaningless key.
|
| 416 |
answers = measure_resolve.series_values(
|
| 417 |
mfields, bucket, bucket_bounds,
|
| 418 |
team_id, frozenset(pool), today, stamp, rt.series_memo,
|
| 419 |
+
on_error=lambda tag, e: problems.append(str(e)[:200])) if mfields else {}
|
| 420 |
|
| 421 |
columns = []
|
| 422 |
for s, e in zip(starts, ends):
|
|
|
|
| 456 |
return {"columns": columns, "rows": rows, "meta": meta}
|
| 457 |
|
| 458 |
|
| 459 |
+
#: C-CAL caps (wave 17, owner item 9 / ruling R4). A month of days, a handful of metrics.
|
| 460 |
+
#: Every one of these is a 400 WITH ITS REASON, never a silent trim: a calendar that quietly
|
| 461 |
+
#: answered 20 of the 31 days asked about would paint eleven blank cells that look like days
|
| 462 |
+
#: with no activity.
|
| 463 |
+
_CAL_MAX_GROUPS = 31
|
| 464 |
+
_CAL_MAX_FIELDS = 6
|
| 465 |
+
_CAL_MAX_CELLS = 186
|
| 466 |
+
|
| 467 |
+
|
| 468 |
+
@router.post("/grid/calendar_metrics")
|
| 469 |
+
def grid_calendar_metrics(body: dict = Body(default=None), scope: str = "customer",
|
| 470 |
+
session: Session = Depends(module_gate(MODULE))):
|
| 471 |
+
"""Per-DAY measure values with each metric's own window slid to that day (C-CAL / R4).
|
| 472 |
+
|
| 473 |
+
β WHY THIS EXISTS AT ALL. The calendar's summary cells used to aggregate the row VALUES the
|
| 474 |
+
grid already held β which for a measure column means "every member's YTD **as of today**",
|
| 475 |
+
summed and printed under a date in March. The number was arithmetically fine and semantically
|
| 476 |
+
a lie: it answered a question about today while sitting in a cell labelled with another day.
|
| 477 |
+
R4: a metric in a day cell is computed AS OF THAT DAY.
|
| 478 |
+
|
| 479 |
+
The shape differs from the time-series channel in exactly one way, and it is the reason this
|
| 480 |
+
is a separate route rather than a parameter: **every group carries its OWN pid set**. A
|
| 481 |
+
calendar day holds the records the date field placed there, so day-to-day the subject
|
| 482 |
+
changes. One `allowed_pids` for the whole request β the TS channel's shape β would compute
|
| 483 |
+
each day over everybody, which is a different question again.
|
| 484 |
+
|
| 485 |
+
Static (non-measure) fields are NOT served here. They have no window to slide, so the
|
| 486 |
+
client's own per-day aggregation over row values stays correct for them; sending them would
|
| 487 |
+
invite a second implementation of arithmetic that already works.
|
| 488 |
+
"""
|
| 489 |
+
from core import measure_resolve
|
| 490 |
+
from harness import windows as _wn
|
| 491 |
+
from routes_customers import _pool_stamp, _team_agent, allowed_pids
|
| 492 |
+
|
| 493 |
+
# The same refusal the TS channel makes, for the same reason: measures are customer-grain
|
| 494 |
+
# and product pids are CRC32 hashes of SKU codes. "Mostly outside the book" is not a wall.
|
| 495 |
+
if _scope_or_400(scope) == "product":
|
| 496 |
+
raise err(400, "bad_calendar_metrics",
|
| 497 |
+
"the product surface has no measure channel yet β measures are customer-grain")
|
| 498 |
+
|
| 499 |
+
body = body or {}
|
| 500 |
+
raw_groups = body.get("groups")
|
| 501 |
+
if not isinstance(raw_groups, list) or not raw_groups:
|
| 502 |
+
raise err(400, "bad_calendar_metrics",
|
| 503 |
+
"groups must be a non-empty list of {key: 'YYYY-MM-DD', pids: [...]}")
|
| 504 |
+
if len(raw_groups) > _CAL_MAX_GROUPS:
|
| 505 |
+
raise err(400, "bad_calendar_metrics",
|
| 506 |
+
f"at most {_CAL_MAX_GROUPS} days per request (one month)")
|
| 507 |
+
raw_fields = body.get("fields")
|
| 508 |
+
if not isinstance(raw_fields, list) or not raw_fields:
|
| 509 |
+
raise err(400, "bad_calendar_metrics", "fields must be a non-empty list of field keys")
|
| 510 |
+
if len(raw_fields) > _CAL_MAX_FIELDS:
|
| 511 |
+
raise err(400, "bad_calendar_metrics", f"at most {_CAL_MAX_FIELDS} metrics per request")
|
| 512 |
+
if len(raw_groups) * len(raw_fields) > _CAL_MAX_CELLS:
|
| 513 |
+
raise err(400, "bad_calendar_metrics",
|
| 514 |
+
"that ask is too wide - fewer days or fewer metrics")
|
| 515 |
+
|
| 516 |
+
book = {int(p) for p in allowed_pids(session)}
|
| 517 |
+
groups, seen_days = [], set()
|
| 518 |
+
for g in raw_groups:
|
| 519 |
+
if not isinstance(g, dict):
|
| 520 |
+
raise err(400, "bad_calendar_metrics", "every group must be an object")
|
| 521 |
+
day = str(g.get("key") or "")
|
| 522 |
+
try:
|
| 523 |
+
d = dt.date.fromisoformat(day)
|
| 524 |
+
except (TypeError, ValueError):
|
| 525 |
+
raise err(400, "bad_calendar_metrics",
|
| 526 |
+
"every group key must be an ISO date (YYYY-MM-DD)")
|
| 527 |
+
if day in seen_days:
|
| 528 |
+
raise err(400, "bad_calendar_metrics", f"day {day} appears twice")
|
| 529 |
+
seen_days.add(day)
|
| 530 |
+
raw_pids = g.get("pids")
|
| 531 |
+
if not isinstance(raw_pids, list):
|
| 532 |
+
raise err(400, "bad_calendar_metrics", "every group needs a pids list")
|
| 533 |
+
try:
|
| 534 |
+
wanted = {int(p) for p in raw_pids}
|
| 535 |
+
except (TypeError, ValueError):
|
| 536 |
+
raise err(400, "bad_calendar_metrics", "pids must be integers")
|
| 537 |
+
# NARROW-ONLY, per group. The client sends what its calendar placed; the server can
|
| 538 |
+
# only ever remove from that, never add.
|
| 539 |
+
groups.append((day, d, frozenset(wanted & book)))
|
| 540 |
+
if sum(len(p) for _, _, p in groups) > _TS_MAX_PIDS:
|
| 541 |
+
raise err(400, "bad_calendar_metrics",
|
| 542 |
+
f"at most {_TS_MAX_PIDS} customer references per request")
|
| 543 |
+
|
| 544 |
+
rt = session.runtime
|
| 545 |
+
if not rt.available():
|
| 546 |
+
raise err(503, "store_unavailable", "the tenant store is unavailable")
|
| 547 |
+
import modules.customer_data as cl_mod
|
| 548 |
+
ws = cl_mod.table_workspace(session.uname, consume_corrections=False)
|
| 549 |
+
fdefs = ws.get("fields") or {}
|
| 550 |
+
keys, dropped, seen = [], [], set()
|
| 551 |
+
for k in raw_fields:
|
| 552 |
+
k = str(k or "")
|
| 553 |
+
if not k or k in seen:
|
| 554 |
+
continue
|
| 555 |
+
seen.add(k)
|
| 556 |
+
fd = fdefs.get(k)
|
| 557 |
+
if not isinstance(fd, dict) or not isinstance(fd.get("measure"), dict):
|
| 558 |
+
# The TS channel's vocabulary, deliberately reused rather than re-coined: the client
|
| 559 |
+
# already knows how to say these three words to a reader.
|
| 560 |
+
dropped.append({"field": k, "reason": "not_a_measure_field"})
|
| 561 |
+
continue
|
| 562 |
+
if ((fd["measure"].get("window") or {}).get("kind") == "custom"):
|
| 563 |
+
dropped.append({"field": k, "reason": "window_fixed"})
|
| 564 |
+
continue
|
| 565 |
+
keys.append(k)
|
| 566 |
+
if not keys:
|
| 567 |
+
raise err(400, "bad_calendar_metrics",
|
| 568 |
+
"none of the requested fields are measure fields with a window that can "
|
| 569 |
+
"slide to a day")
|
| 570 |
+
|
| 571 |
+
today = time.strftime("%Y-%m-%d")
|
| 572 |
+
t = dt.date.fromisoformat(today)
|
| 573 |
+
team_id, agent = _team_agent(session)
|
| 574 |
+
stamp = _pool_stamp(rt, team_id, agent)
|
| 575 |
+
problems = []
|
| 576 |
+
values = {k: {} for k in keys}
|
| 577 |
+
for day, d, pids in groups:
|
| 578 |
+
# A day that has not happened is unanswered for EVERY aggregate kind β the unstarted
|
| 579 |
+
# bucket law at day grain. Answering 0 would say "we sold nothing", which is a claim
|
| 580 |
+
# about a day nobody has lived through yet.
|
| 581 |
+
if d > t or not pids:
|
| 582 |
+
for k in keys:
|
| 583 |
+
values[k][day] = None
|
| 584 |
+
continue
|
| 585 |
+
answers = measure_resolve.series_values(
|
| 586 |
+
[{"key": k, "measure": dict(fdefs[k]["measure"])} for k in keys],
|
| 587 |
+
"day", [(day, day)], team_id, pids, today, stamp, rt.series_memo,
|
| 588 |
+
on_error=lambda tag, e: problems.append(str(e)[:200]))
|
| 589 |
+
for k in keys:
|
| 590 |
+
ans = answers.get(k)
|
| 591 |
+
if ans is None:
|
| 592 |
+
values[k][day] = None
|
| 593 |
+
continue
|
| 594 |
+
vals_by = ans.get("values") or {}
|
| 595 |
+
zero_fill = str(ans.get("agg") or "sum") in ("sum", "count")
|
| 596 |
+
values[k][day] = vals_by.get(day, 0 if zero_fill else None)
|
| 597 |
+
|
| 598 |
+
for k in keys:
|
| 599 |
+
if all(v is None for v in values[k].values()):
|
| 600 |
+
# Every day unanswerable is a FIELD-level failure, and saying so is the difference
|
| 601 |
+
# between "no activity that month" and "this metric could not be computed".
|
| 602 |
+
dropped.append({"field": k, "reason": "unresolvable"})
|
| 603 |
+
out = {"values": values, "today": today,
|
| 604 |
+
"windows": {k: {"kind": str((_wn.normalize(
|
| 605 |
+
(fdefs[k].get("measure") or {}).get("window")) or {}).get("kind") or ""),
|
| 606 |
+
"label": _wn.label((fdefs[k].get("measure") or {}).get("window"))}
|
| 607 |
+
for k in keys}}
|
| 608 |
+
if dropped:
|
| 609 |
+
out["dropped"] = dropped
|
| 610 |
+
if problems:
|
| 611 |
+
out["problems"] = problems[:5]
|
| 612 |
+
return out
|
| 613 |
+
|
| 614 |
+
|
| 615 |
@router.post("/grid/events")
|
| 616 |
def grid_events_route(body: dict = Body(default=None),
|
| 617 |
session: Session = Depends(module_gate(MODULE))):
|
royalimports_os/aios_grid.py
CHANGED
|
@@ -301,8 +301,15 @@ def _field_extras(saved, ftype):
|
|
| 301 |
COHORT_COLUMN = 'cohorts'
|
| 302 |
|
| 303 |
|
| 304 |
-
def cohort_field(label='
|
| 305 |
-
"""The derived
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 306 |
|
| 307 |
`source: 'odoo'` is doing ONE job here and it is not provenance: the client keys editability
|
| 308 |
off `source == 'overlay'`, and `_cl_handle_grid_event` accepts cell writes only for overlay
|
|
@@ -317,11 +324,11 @@ def cohort_field(label='Cohorts'):
|
|
| 317 |
return {
|
| 318 |
'key': COHORT_COLUMN, 'label': label, 'type': 'text', 'source': 'odoo',
|
| 319 |
'default': False, 'filterable': False, 'derived': True, 'multi': True,
|
| 320 |
-
'note': 'The
|
| 321 |
-
'
|
| 322 |
-
'
|
| 323 |
-
'
|
| 324 |
-
'
|
| 325 |
}
|
| 326 |
|
| 327 |
|
|
@@ -1284,13 +1291,48 @@ def _default_view_config(fields):
|
|
| 1284 |
}
|
| 1285 |
|
| 1286 |
|
| 1287 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1288 |
"""Convert legacy list formulas into the shared serializable SavedView contract.
|
| 1289 |
|
| 1290 |
`system_name` (wave 16 C-TOPIC) labels the system view per TOPIC ("All products" on the
|
| 1291 |
product surface). The ID stays "all-customers" on every topic β the client pins it
|
| 1292 |
(UNDELETABLE_VIEW_IDS, the landing default), and an id that varies by surface would fork
|
| 1293 |
-
that contract for a label's sake.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1294 |
base = _default_view_config(fields)
|
| 1295 |
views = [{
|
| 1296 |
"id": "all-customers", "name": system_name, "kind": "system",
|
|
@@ -1323,6 +1365,12 @@ def views_from_defs(defs, saved_views, fields, system_name="All customers"):
|
|
| 1323 |
if isinstance(pid, int) or str(pid).isdigit()],
|
| 1324 |
},
|
| 1325 |
})
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1326 |
index = {view["id"]: i for i, view in enumerate(views)}
|
| 1327 |
for view_id, saved in (saved_views or {}).items():
|
| 1328 |
if not isinstance(saved, dict) or not isinstance(saved.get("config"), dict):
|
|
@@ -1333,6 +1381,24 @@ def views_from_defs(defs, saved_views, fields, system_name="All customers"):
|
|
| 1333 |
views[index[view_id]] = clean
|
| 1334 |
else:
|
| 1335 |
views.append(clean)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1336 |
return views
|
| 1337 |
|
| 1338 |
|
|
@@ -1379,7 +1445,8 @@ def workspace_wire(ws, uname, pool_pids, defs=None, scope_key='customer', storag
|
|
| 1379 |
fields_base=fields_base)
|
| 1380 |
views = views_from_defs(defs or {}, ws.get('views'), fields,
|
| 1381 |
system_name=("All products" if scope_key == 'product'
|
| 1382 |
-
else "All customers")
|
|
|
|
| 1383 |
workspace = {'storageKey': storage_key, 'views': views, 'lists': cohort_lists}
|
| 1384 |
# Owner item 3 (2026-07-31): where this user left off. The client's own localStorage copy
|
| 1385 |
# wins when present; this is the server's answer for a FRESH browser, which used to fall
|
|
@@ -1392,13 +1459,39 @@ def workspace_wire(ws, uname, pool_pids, defs=None, scope_key='customer', storag
|
|
| 1392 |
# the thing it points at.
|
| 1393 |
_folders = clean_folders(ws.get('folders'))
|
| 1394 |
_view_ids = {v['id'] for v in (views or []) if isinstance(v, dict) and v.get('id')}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1395 |
_placed = clean_item_folders(
|
| 1396 |
-
|
| 1397 |
{'views': _view_ids, 'cohorts': {c['id'] for c in cohort_lists}})
|
| 1398 |
if _folders.get('views'):
|
| 1399 |
workspace['folders'] = _folders['views']
|
| 1400 |
-
|
| 1401 |
-
|
| 1402 |
_vplaced = _placed.get('views') or {}
|
| 1403 |
for _v in (views or []):
|
| 1404 |
if isinstance(_v, dict) and _v.get('id') in _vplaced:
|
|
|
|
| 301 |
COHORT_COLUMN = 'cohorts'
|
| 302 |
|
| 303 |
|
| 304 |
+
def cohort_field(label='Locked views'):
|
| 305 |
+
"""The derived membership column's descriptor.
|
| 306 |
+
|
| 307 |
+
β WAVE 17 item 14 / C-STR β THE LABEL AND THE NOTE SPEAK THE NEW VOCABULARY; THE KEY DOES
|
| 308 |
+
NOT. `COHORT_COLUMN` is still `'cohorts'` and the function is still `cohort_field`, because
|
| 309 |
+
every stored view that shows or groups by this column names it by KEY, and every gate in
|
| 310 |
+
two runtimes names the function. The owner renamed a CONCEPT ("we should stop calling it
|
| 311 |
+
Cohort, but locked instead"), which is a change to what a reader sees β renaming the
|
| 312 |
+
identifiers would break saved views to change a word nobody reads.
|
| 313 |
|
| 314 |
`source: 'odoo'` is doing ONE job here and it is not provenance: the client keys editability
|
| 315 |
off `source == 'overlay'`, and `_cl_handle_grid_event` accepts cell writes only for overlay
|
|
|
|
| 324 |
return {
|
| 325 |
'key': COHORT_COLUMN, 'label': label, 'type': 'text', 'source': 'odoo',
|
| 326 |
'default': False, 'filterable': False, 'derived': True, 'multi': True,
|
| 327 |
+
'note': 'The locked views this customer is in, newest first. A locked view holds a SET, '
|
| 328 |
+
'so grouping by this column puts a customer under EVERY view they are in β the '
|
| 329 |
+
'group counts therefore add up to more than the record count, which stays the '
|
| 330 |
+
'number of distinct customers. Read-only: membership changes only by adding or '
|
| 331 |
+
'removing customers on the locked view itself.',
|
| 332 |
}
|
| 333 |
|
| 334 |
|
|
|
|
| 1291 |
}
|
| 1292 |
|
| 1293 |
|
| 1294 |
+
#: Wave 17 R1 / C-LOCKV β the `kind` a PROJECTED locked view wears. A cohort is not a separate
|
| 1295 |
+
#: kind of object any more: it is a saved view whose rows are a hand-curated set.
|
| 1296 |
+
LOCKED_VIEW_KIND = 'locked'
|
| 1297 |
+
|
| 1298 |
+
|
| 1299 |
+
def locked_view_projection(entry, base_config):
|
| 1300 |
+
"""One cohort -> the saved-view row that IS it (wave 17 R1, contract C-LOCKV).
|
| 1301 |
+
|
| 1302 |
+
β THE LOCK IS THE VIEW'S IDENTITY, NOT ITS CONFIGURATION. `config.cohortLock` names the
|
| 1303 |
+
view's OWN id, which is what makes the shipped engine law (`useVisibleRows`: intersect the
|
| 1304 |
+
named set FIRST, unconditionally, and match NOTHING when the membership is unresolvable) do
|
| 1305 |
+
all the work with no second mechanism. Membership itself is NEVER copied in here β it stays
|
| 1306 |
+
in `customer_cohorts` and travels as `workspace.lists`, because a per-reader-scoped
|
| 1307 |
+
collection inside a client-writable `config` is deleted by the next autosave (see the
|
| 1308 |
+
contract's reason 2).
|
| 1309 |
+
|
| 1310 |
+
β `locked: True` is the LEGACY "undeletable/mode-frozen" flag and is deliberately NOT set:
|
| 1311 |
+
these views are ordinary in every respect the owner asked for β reorder, folder, sort,
|
| 1312 |
+
filter, change display mode. The lock mark in the rail is driven by `kind`.
|
| 1313 |
+
"""
|
| 1314 |
+
return {
|
| 1315 |
+
'id': entry['id'],
|
| 1316 |
+
'name': entry.get('name') or entry['id'],
|
| 1317 |
+
'kind': LOCKED_VIEW_KIND,
|
| 1318 |
+
'config': {**base_config, 'cohortLock': entry['id']},
|
| 1319 |
+
}
|
| 1320 |
+
|
| 1321 |
+
|
| 1322 |
+
def views_from_defs(defs, saved_views, fields, system_name="All customers", locked_lists=None):
|
| 1323 |
"""Convert legacy list formulas into the shared serializable SavedView contract.
|
| 1324 |
|
| 1325 |
`system_name` (wave 16 C-TOPIC) labels the system view per TOPIC ("All products" on the
|
| 1326 |
product surface). The ID stays "all-customers" on every topic β the client pins it
|
| 1327 |
(UNDELETABLE_VIEW_IDS, the landing default), and an id that varies by surface would fork
|
| 1328 |
+
that contract for a label's sake.
|
| 1329 |
+
|
| 1330 |
+
`locked_lists` (wave 17 R1) are the caller's cohorts, each PROJECTED as a saved view whose
|
| 1331 |
+
id IS the cohort id β so every stored reference to that id (a `cohortLock` on another view,
|
| 1332 |
+
an `is part of` condition, a folder placement) keeps pointing at the same thing and no
|
| 1333 |
+
rewrite map is needed. Saved config OVERLAYS the projection through the same mechanism the
|
| 1334 |
+
`list:` views have always used, which is what gives a locked view its own sort, filter,
|
| 1335 |
+
columns and display mode with no new storage."""
|
| 1336 |
base = _default_view_config(fields)
|
| 1337 |
views = [{
|
| 1338 |
"id": "all-customers", "name": system_name, "kind": "system",
|
|
|
|
| 1365 |
if isinstance(pid, int) or str(pid).isdigit()],
|
| 1366 |
},
|
| 1367 |
})
|
| 1368 |
+
# Wave 17 R1 β the cohorts, as ordinary views. Appended BEFORE the saved-config overlay
|
| 1369 |
+
# below so a user's own edits to a locked view (its sort, its columns, its display mode)
|
| 1370 |
+
# land on the projection instead of creating a second row with the same id.
|
| 1371 |
+
for _entry in (locked_lists or []):
|
| 1372 |
+
if isinstance(_entry, dict) and _entry.get('id'):
|
| 1373 |
+
views.append(locked_view_projection(_entry, base))
|
| 1374 |
index = {view["id"]: i for i, view in enumerate(views)}
|
| 1375 |
for view_id, saved in (saved_views or {}).items():
|
| 1376 |
if not isinstance(saved, dict) or not isinstance(saved.get("config"), dict):
|
|
|
|
| 1381 |
views[index[view_id]] = clean
|
| 1382 |
else:
|
| 1383 |
views.append(clean)
|
| 1384 |
+
# β WAVE 17 R1 β RE-STAMP THE LOCK AFTER THE OVERLAY. The loop above REPLACES a projected
|
| 1385 |
+
# view with its saved record, and a saved record that omits `cohortLock` would hand back a
|
| 1386 |
+
# view that shows the WHOLE BOOK under a locked view's name. That is not hypothetical: the
|
| 1387 |
+
# client rebuilds `config` on every autosave (a column resize is enough), and the lock is
|
| 1388 |
+
# identity here, not something the browser is the source of truth for. Read-side rather than
|
| 1389 |
+
# write-side-only on purpose β this also repairs any record already written by another path.
|
| 1390 |
+
_locked_ids = {e['id']: e for e in (locked_lists or [])
|
| 1391 |
+
if isinstance(e, dict) and e.get('id')}
|
| 1392 |
+
if _locked_ids:
|
| 1393 |
+
for _v in views:
|
| 1394 |
+
_entry = _locked_ids.get(_v.get('id'))
|
| 1395 |
+
if not _entry:
|
| 1396 |
+
continue
|
| 1397 |
+
_v['kind'] = LOCKED_VIEW_KIND
|
| 1398 |
+
_v['config'] = {**(_v.get('config') or {}), 'cohortLock': _v['id']}
|
| 1399 |
+
# One thing, one name: the cohort store owns it (the rename event routes there), so
|
| 1400 |
+
# a stale `name` on the saved record can never fork into a second title.
|
| 1401 |
+
_v['name'] = _entry.get('name') or _v['id']
|
| 1402 |
return views
|
| 1403 |
|
| 1404 |
|
|
|
|
| 1445 |
fields_base=fields_base)
|
| 1446 |
views = views_from_defs(defs or {}, ws.get('views'), fields,
|
| 1447 |
system_name=("All products" if scope_key == 'product'
|
| 1448 |
+
else "All customers"),
|
| 1449 |
+
locked_lists=cohort_lists)
|
| 1450 |
workspace = {'storageKey': storage_key, 'views': views, 'lists': cohort_lists}
|
| 1451 |
# Owner item 3 (2026-07-31): where this user left off. The client's own localStorage copy
|
| 1452 |
# wins when present; this is the server's answer for a FRESH browser, which used to fall
|
|
|
|
| 1459 |
# the thing it points at.
|
| 1460 |
_folders = clean_folders(ws.get('folders'))
|
| 1461 |
_view_ids = {v['id'] for v in (views or []) if isinstance(v, dict) and v.get('id')}
|
| 1462 |
+
# ββ WAVE 17 R1 (C-LOCKV amendment 2026-08-03): the two folder surfaces become ONE, AT
|
| 1463 |
+
# SERVE TIME rather than by a store migration. A locked view is an ordinary view now, so
|
| 1464 |
+
# its folder has to be an ordinary view folder β but rewriting the stored map would be a
|
| 1465 |
+
# one-shot write that has to be got right once, while this is a projection that is right
|
| 1466 |
+
# every time it runs. New drags write to `views` anyway (the client only knows that
|
| 1467 |
+
# surface), so `cohorts` drains on its own and never needs a second pass.
|
| 1468 |
+
# β A cohorts-surface folder whose id ALREADY names a views folder is DROPPED, not merged:
|
| 1469 |
+
# re-parenting somebody's list into a folder that merely shares an id is a worse outcome
|
| 1470 |
+
# than the list appearing at the root, where it is visible and one drag from home.
|
| 1471 |
+
_cf = list(_folders.get('cohorts') or [])
|
| 1472 |
+
if _cf:
|
| 1473 |
+
_vf = list(_folders.get('views') or [])
|
| 1474 |
+
_taken = {f['id'] for f in _vf}
|
| 1475 |
+
_order = len(_vf)
|
| 1476 |
+
for _f in _cf:
|
| 1477 |
+
if _f['id'] in _taken:
|
| 1478 |
+
continue
|
| 1479 |
+
_vf.append({**_f, 'order': _order})
|
| 1480 |
+
_order += 1
|
| 1481 |
+
_folders['views'] = _vf
|
| 1482 |
+
_raw_item_folders = dict(ws.get('itemFolders') or {})
|
| 1483 |
+
if _raw_item_folders.get('cohorts'):
|
| 1484 |
+
# Cohort placements now describe VIEWS (same ids β that is the point of preserving them).
|
| 1485 |
+
# A placement already stored on the views surface WINS: it is the more recent act.
|
| 1486 |
+
_raw_item_folders['views'] = {**dict(_raw_item_folders.get('cohorts') or {}),
|
| 1487 |
+
**dict(_raw_item_folders.get('views') or {})}
|
| 1488 |
_placed = clean_item_folders(
|
| 1489 |
+
_raw_item_folders, _folders,
|
| 1490 |
{'views': _view_ids, 'cohorts': {c['id'] for c in cohort_lists}})
|
| 1491 |
if _folders.get('views'):
|
| 1492 |
workspace['folders'] = _folders['views']
|
| 1493 |
+
# β `cohortFolders` IS NO LONGER EMITTED. The rail has no cohorts section to fold, and a
|
| 1494 |
+
# wire that still described one would invite a second rendering of rows that are now views.
|
| 1495 |
_vplaced = _placed.get('views') or {}
|
| 1496 |
for _v in (views or []):
|
| 1497 |
if isinstance(_v, dict) and _v.get('id') in _vplaced:
|
royalimports_os/aios_grid_fields.json
CHANGED
|
@@ -162,6 +162,38 @@
|
|
| 162 |
"default": false,
|
| 163 |
"description": "The most you could be out if they stopped paying today: open, overdue, draft and not-yet-invoiced."
|
| 164 |
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 165 |
{
|
| 166 |
"key": "days_to_pay",
|
| 167 |
"label": "Days to pay",
|
|
@@ -257,6 +289,38 @@
|
|
| 257 |
"default": true,
|
| 258 |
"description": "Product category; '(uncategorized)' when Odoo carries none."
|
| 259 |
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 260 |
{
|
| 261 |
"key": "rev_ytd",
|
| 262 |
"label": "Revenue YTD",
|
|
@@ -328,6 +392,26 @@
|
|
| 328 |
"source": "odoo",
|
| 329 |
"description": "Days of supply at the LTM rate; null means it never sells through. Consolidated; absent for a BU-scoped caller."
|
| 330 |
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 331 |
{
|
| 332 |
"key": "stock_bucket",
|
| 333 |
"label": "Stock status",
|
|
|
|
| 162 |
"default": false,
|
| 163 |
"description": "The most you could be out if they stopped paying today: open, overdue, draft and not-yet-invoiced."
|
| 164 |
},
|
| 165 |
+
{
|
| 166 |
+
"key": "ar_aged_1_30",
|
| 167 |
+
"label": "1-30 days $",
|
| 168 |
+
"type": "currency",
|
| 169 |
+
"source": "odoo",
|
| 170 |
+
"default": false,
|
| 171 |
+
"description": "Overdue between 1 and 30 days. The four aging buckets sum to AR overdue $."
|
| 172 |
+
},
|
| 173 |
+
{
|
| 174 |
+
"key": "ar_aged_31_60",
|
| 175 |
+
"label": "31-60 days $",
|
| 176 |
+
"type": "currency",
|
| 177 |
+
"source": "odoo",
|
| 178 |
+
"default": false,
|
| 179 |
+
"description": "Overdue between 31 and 60 days. The four aging buckets sum to AR overdue $."
|
| 180 |
+
},
|
| 181 |
+
{
|
| 182 |
+
"key": "ar_aged_61_90",
|
| 183 |
+
"label": "61-90 days $",
|
| 184 |
+
"type": "currency",
|
| 185 |
+
"source": "odoo",
|
| 186 |
+
"default": false,
|
| 187 |
+
"description": "Overdue between 61 and 90 days. The four aging buckets sum to AR overdue $."
|
| 188 |
+
},
|
| 189 |
+
{
|
| 190 |
+
"key": "ar_aged_90_plus",
|
| 191 |
+
"label": "90+ days $",
|
| 192 |
+
"type": "currency",
|
| 193 |
+
"source": "odoo",
|
| 194 |
+
"default": false,
|
| 195 |
+
"description": "Overdue by more than 90 days. The four aging buckets sum to AR overdue $."
|
| 196 |
+
},
|
| 197 |
{
|
| 198 |
"key": "days_to_pay",
|
| 199 |
"label": "Days to pay",
|
|
|
|
| 289 |
"default": true,
|
| 290 |
"description": "Product category; '(uncategorized)' when Odoo carries none."
|
| 291 |
},
|
| 292 |
+
{
|
| 293 |
+
"key": "supplier",
|
| 294 |
+
"label": "Supplier",
|
| 295 |
+
"type": "text",
|
| 296 |
+
"source": "odoo",
|
| 297 |
+
"default": true,
|
| 298 |
+
"description": "Who makes it, from the inventory mastersheet. Not an Odoo field."
|
| 299 |
+
},
|
| 300 |
+
{
|
| 301 |
+
"key": "origin_country",
|
| 302 |
+
"label": "Country",
|
| 303 |
+
"type": "text",
|
| 304 |
+
"source": "odoo",
|
| 305 |
+
"default": false,
|
| 306 |
+
"description": "Country of origin, from the inventory mastersheet."
|
| 307 |
+
},
|
| 308 |
+
{
|
| 309 |
+
"key": "lead_days",
|
| 310 |
+
"label": "Lead time (days)",
|
| 311 |
+
"type": "int",
|
| 312 |
+
"source": "odoo",
|
| 313 |
+
"default": true,
|
| 314 |
+
"description": "Order-to-arrival days for this supplier. Drives the buy signal."
|
| 315 |
+
},
|
| 316 |
+
{
|
| 317 |
+
"key": "first_cost",
|
| 318 |
+
"label": "First cost",
|
| 319 |
+
"type": "currency",
|
| 320 |
+
"source": "odoo",
|
| 321 |
+
"default": false,
|
| 322 |
+
"description": "Quoted unit cost at origin, before freight and duty."
|
| 323 |
+
},
|
| 324 |
{
|
| 325 |
"key": "rev_ytd",
|
| 326 |
"label": "Revenue YTD",
|
|
|
|
| 392 |
"source": "odoo",
|
| 393 |
"description": "Days of supply at the LTM rate; null means it never sells through. Consolidated; absent for a BU-scoped caller."
|
| 394 |
},
|
| 395 |
+
{
|
| 396 |
+
"key": "cover_gap_d",
|
| 397 |
+
"label": "Cover gap (days)",
|
| 398 |
+
"type": "int",
|
| 399 |
+
"source": "odoo",
|
| 400 |
+
"default": false,
|
| 401 |
+
"description": "Days of supply minus lead time. Negative means it runs out before a reorder lands."
|
| 402 |
+
},
|
| 403 |
+
{
|
| 404 |
+
"key": "buy_now",
|
| 405 |
+
"label": "Buy signal",
|
| 406 |
+
"type": "select",
|
| 407 |
+
"source": "odoo",
|
| 408 |
+
"default": true,
|
| 409 |
+
"description": "Buy now when cover is already shorter than lead time. Blank if either is unknown.",
|
| 410 |
+
"options": [
|
| 411 |
+
"Buy now",
|
| 412 |
+
"OK"
|
| 413 |
+
]
|
| 414 |
+
},
|
| 415 |
{
|
| 416 |
"key": "stock_bucket",
|
| 417 |
"label": "Stock status",
|
royalimports_os/core/grid_events.py
CHANGED
|
@@ -510,6 +510,16 @@ def handle_one(event, ctx):
|
|
| 510 |
# (Readers of a SHARED locked view resolve the id against their OWN visible sets; an
|
| 511 |
# unresolvable lock matches NOTHING client-side β the cohort-leaf law, never a widen.)
|
| 512 |
cohort_lock = str(cfg.get('cohortLock') or '').strip()[:120]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 513 |
config = {
|
| 514 |
'filters': filters,
|
| 515 |
# conjunction joining the ROOT-level conditions; anything but an
|
|
@@ -622,8 +632,22 @@ def handle_one(event, ctx):
|
|
| 622 |
config['display'] = was
|
| 623 |
else:
|
| 624 |
config.pop('display', None)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 625 |
view = {'id': view_id, 'name': name,
|
| 626 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 627 |
else 'custom',
|
| 628 |
'locked': locked,
|
| 629 |
'createdBy': creator,
|
|
@@ -682,6 +706,17 @@ def handle_one(event, ctx):
|
|
| 682 |
view_id = str(event.get('viewId') or '')[:120]
|
| 683 |
if not view_id or view_id == 'all-customers':
|
| 684 |
return False
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 685 |
# Wave-9 I17: deleting a SHARED view is narrower than editing it β creator or admin
|
| 686 |
# only. A collaborator can change what a shared view shows; they cannot destroy
|
| 687 |
# everybody else's copy of it, because there is only one copy.
|
|
|
|
| 510 |
# (Readers of a SHARED locked view resolve the id against their OWN visible sets; an
|
| 511 |
# unresolvable lock matches NOTHING client-side β the cohort-leaf law, never a widen.)
|
| 512 |
cohort_lock = str(cfg.get('cohortLock') or '').strip()[:120]
|
| 513 |
+
# β WAVE 17 R1 (C-LOCKV guard a) β A PROJECTED LOCKED VIEW RE-STAMPS ITS OWN LOCK.
|
| 514 |
+
# A locked view IS its set: its id and its lock are the same fact. The client rebuilds
|
| 515 |
+
# `config` from scratch on every autosave (a column resize is enough), so taking the
|
| 516 |
+
# lock from the browser would mean one omitted key turns "the 40 accounts we agreed to
|
| 517 |
+
# call" into the whole book, under the same name, with nothing going red. The read side
|
| 518 |
+
# re-stamps too (aios_grid.views_from_defs) β this keeps the STORE from accumulating the
|
| 519 |
+
# wrong record in the first place.
|
| 520 |
+
_is_locked_view = view_id in set(cohort_ids)
|
| 521 |
+
if _is_locked_view:
|
| 522 |
+
cohort_lock = view_id
|
| 523 |
config = {
|
| 524 |
'filters': filters,
|
| 525 |
# conjunction joining the ROOT-level conditions; anything but an
|
|
|
|
| 632 |
config['display'] = was
|
| 633 |
else:
|
| 634 |
config.pop('display', None)
|
| 635 |
+
# WAVE 17 R1 (C-LOCKV guard b) β ONE THING, ONE NAME. Renaming a locked view renames
|
| 636 |
+
# the SET it is, in the store that owns it; the view record must not grow a second title
|
| 637 |
+
# that the read side would then have to arbitrate. Routed rather than duplicated.
|
| 638 |
+
if _is_locked_view and store.available():
|
| 639 |
+
_cur = (cohort_mod.all_for(uname).get(view_id) or {}).get('name')
|
| 640 |
+
if name and name != _cur:
|
| 641 |
+
try:
|
| 642 |
+
cohort_mod.rename(uname, view_id, name)
|
| 643 |
+
except ValueError as _e:
|
| 644 |
+
_tel.error('cohort:rename-via-view', _e)
|
| 645 |
view = {'id': view_id, 'name': name,
|
| 646 |
+
# β DERIVED FROM THE ID, never taken from the browser: `kind` is what paints the
|
| 647 |
+
# lock mark, so a client claiming it for an ordinary view would be claiming a
|
| 648 |
+
# guarantee the engine is not making about that view's rows.
|
| 649 |
+
'kind': _ag.LOCKED_VIEW_KIND if _is_locked_view
|
| 650 |
+
else raw.get('kind') if raw.get('kind') in ('system', 'list', 'custom')
|
| 651 |
else 'custom',
|
| 652 |
'locked': locked,
|
| 653 |
'createdBy': creator,
|
|
|
|
| 706 |
view_id = str(event.get('viewId') or '')[:120]
|
| 707 |
if not view_id or view_id == 'all-customers':
|
| 708 |
return False
|
| 709 |
+
# WAVE 17 R1 (C-LOCKV guard c) β deleting a LOCKED view deletes the set it is. Without
|
| 710 |
+
# this the store would drop the saved config and the projection would rebuild the view
|
| 711 |
+
# on the very next render: the row would come back, minus the user's sort and columns,
|
| 712 |
+
# which reads as a corruption rather than as a refusal. Own sets only (`all_for`), the
|
| 713 |
+
# same wall `cohort_delete` rides.
|
| 714 |
+
if store.available() and view_id in cohort_mod.all_for(uname):
|
| 715 |
+
cohort_mod.delete(uname, view_id)
|
| 716 |
+
_tops(ctx).delete_view(uname, view_id)
|
| 717 |
+
# True, unlike an ordinary view_delete: the lists payload IS server truth and the
|
| 718 |
+
# client cannot know the membership channel changed.
|
| 719 |
+
return True
|
| 720 |
# Wave-9 I17: deleting a SHARED view is narrower than editing it β creator or admin
|
| 721 |
# only. A collaborator can change what a shared view shows; they cannot destroy
|
| 722 |
# everybody else's copy of it, because there is only one copy.
|
royalimports_os/core/perms.py
CHANGED
|
@@ -41,7 +41,16 @@ _LEGACY_KEYS = {'myday': 'customer_data', 'customer_list': 'customer_data',
|
|
| 41 |
# migration deliberately SKIPS agent-linked records: `agent is X` cannot
|
| 42 |
# express m2m membership (a shared customer displays its primary agent),
|
| 43 |
# so their wall stays legacy until a membership predicate exists.
|
| 44 |
-
'agent': 'customer_data'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 45 |
|
| 46 |
|
| 47 |
def is_admin(user):
|
|
@@ -150,6 +159,36 @@ def nav_pages(user):
|
|
| 150 |
for m in registry.REGISTRY:
|
| 151 |
if m.get('archived') or m.get('group_only'):
|
| 152 |
continue
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 153 |
if not may_open(user, m['key']):
|
| 154 |
continue
|
| 155 |
row = {'key': m['key'], 'label': m['label'],
|
|
|
|
| 41 |
# migration deliberately SKIPS agent-linked records: `agent is X` cannot
|
| 42 |
# express m2m membership (a shared customer displays its primary agent),
|
| 43 |
# so their wall stays legacy until a membership predicate exists.
|
| 44 |
+
'agent': 'customer_data',
|
| 45 |
+
# wave 17 (item 15, R2): the Collections PAGE is gone β its worklist is the
|
| 46 |
+
# shared "Collections" view on the Customer grid. An `ar` grant (or an
|
| 47 |
+
# ?page=ar deep link) lands on the surface that now does the job. The registry
|
| 48 |
+
# row survives as `validate_only`, so this is a grant migration, not a deletion:
|
| 49 |
+
# nobody loses access, they arrive somewhere that still exists.
|
| 50 |
+
'ar': 'customer_data',
|
| 51 |
+
# wave 17 (item 13, R3): Procurement folded into the Product grid β the buy
|
| 52 |
+
# list is a view over formula fields there.
|
| 53 |
+
'procurement': 'product_data'}
|
| 54 |
|
| 55 |
|
| 56 |
def is_admin(user):
|
|
|
|
| 159 |
for m in registry.REGISTRY:
|
| 160 |
if m.get('archived') or m.get('group_only'):
|
| 161 |
continue
|
| 162 |
+
# WAVE 17 (R2 + R8) β `validate_only` rows have NO SURFACE ANYWHERE. Not the module
|
| 163 |
+
# list, not the utility group behind the account menu, not a page. They exist so
|
| 164 |
+
# `validate.py` keeps proving contracts that a LIVE surface depends on:
|
| 165 |
+
# Β· `ar` β the Collections page is gone (its worklist is a saved view on the
|
| 166 |
+
# Customer grid now), but `ar.validate()` is what reconciles the
|
| 167 |
+
# AR columns that view is built from. Archiving the row would have
|
| 168 |
+
# skipped it (validate.py skips archived), deleting the proof while
|
| 169 |
+
# keeping the numbers β the worst of both.
|
| 170 |
+
# Β· `dictionary` β the semantic-layer contracts, the Analyst's grounding proof.
|
| 171 |
+
# `api_surface: False` is the NARROWER neighbour: the row still has a Streamlit page,
|
| 172 |
+
# but it is not a surface of the PRODUCT. `ar` is the case β its Collections worklist
|
| 173 |
+
# is a saved view on the Customer grid now, while the admin-only Statements sender
|
| 174 |
+
# (the one sanctioned Odoo writer) keeps its host page.
|
| 175 |
+
# β This is NOT `nav: False`. That flag means "a live surface the HOST renders outside
|
| 176 |
+
# the module list" and ships as `chrome: 'utility'`, which is exactly the account-menu
|
| 177 |
+
# row R8 says to delete.
|
| 178 |
+
if m.get('validate_only') or m.get('api_surface') is False:
|
| 179 |
+
continue
|
| 180 |
+
# WAVE 17 R8, the other half β `settings` STOPS being offered to the API's clients.
|
| 181 |
+
# It shipped as `chrome: 'utility'`, which the React shell rendered as "App settings":
|
| 182 |
+
# a hand-off that opens the STREAMLIT settings page in a new tab, beside the shell's
|
| 183 |
+
# own Profile modal that does the same job better. Two doors to one room, one of them
|
| 184 |
+
# leading out of the application. The owner's words were "I don't even know what it
|
| 185 |
+
# does β delete them".
|
| 186 |
+
# β The ROW STAYS, and so does the Streamlit page behind it: this host's own account
|
| 187 |
+
# menu still opens it, and the dispatch guard uses `settings` as its always-renderable
|
| 188 |
+
# last resort for a user whose whole grant has been retired. What changes is that the
|
| 189 |
+
# API no longer advertises it as a surface of the PRODUCT.
|
| 190 |
+
if m['key'] == 'settings':
|
| 191 |
+
continue
|
| 192 |
if not may_open(user, m['key']):
|
| 193 |
continue
|
| 194 |
row = {'key': m['key'], 'label': m['label'],
|
royalimports_os/core/registry.py
CHANGED
|
@@ -118,14 +118,35 @@ REGISTRY = [
|
|
| 118 |
{'key': 'inventory', 'label': 'Inventory', 'brand': False, 'hq': False, 'validate': True, 'archived': True,
|
| 119 |
'note': 'On-hand stock is physically consolidated (shared warehouse); not DBA-split.'},
|
| 120 |
{'key': 'procurement', 'label': 'Procurement', 'brand': False, 'hq': False, 'validate': True, 'source': 'Odoo',
|
| 121 |
-
'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 122 |
{'key': 'vendor', 'label': 'Vendors', 'brand': False, 'hq': False, 'validate': False, 'archived': True,
|
| 123 |
'note': 'Vendor master data + the SKUs each supplies; multiple-vendor / cheapest-price view.'},
|
| 124 |
{'key': 'warehouse', 'label': 'Warehouse', 'brand': False, 'hq': False, 'validate': True, 'archived': True,
|
| 125 |
'note': 'Movement & efficiency: on-time ship, Pick-Pack-Ship cycle times, throughput, backlog age, shrinkage. Physical ops (consolidated).'},
|
| 126 |
{'key': 'ar', 'label': 'Collections', 'brand': False, 'hq': True, 'validate': True,
|
| 127 |
-
'source': 'Odoo',
|
| 128 |
-
'note': '
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 129 |
{'key': 'returns', 'label': 'Returns', 'brand': False, 'hq': True, 'validate': True, 'archived': True,
|
| 130 |
'note': 'Credit-note lens: refund concentration by SKU (quality) and customer (behavior). Company-level.'},
|
| 131 |
{'key': 'outreach', 'label': 'Outreach', 'brand': True, 'hq': False, 'validate': False, 'archived': True,
|
|
@@ -150,8 +171,12 @@ REGISTRY = [
|
|
| 150 |
'procurement mapping gaps, count-trust (unverified on-hand counts), untracked-on-'
|
| 151 |
'order β so operational workflows stay clean for doing the work.'},
|
| 152 |
{'key': 'dictionary', 'label': 'Metric Dictionary', 'brand': False, 'hq': True, 'validate': True,
|
| 153 |
-
'nav': False,
|
| 154 |
-
'note': 'PAGE RETIRED 2026-07-23 (owner: broken/not customer-facing) β row kept ONLY so
|
|
|
|
|
|
|
|
|
|
|
|
|
| 155 |
{'key': 'settings', 'label': 'Settings', 'brand': False, 'hq': True, 'validate': False,
|
| 156 |
'nav': False, # sidebar sentinel (account group) β owner IA 2026-07-12
|
| 157 |
'note': 'User scope settings: the Business Unit toggle (strict isolation) and the Data basis '
|
|
|
|
| 118 |
{'key': 'inventory', 'label': 'Inventory', 'brand': False, 'hq': False, 'validate': True, 'archived': True,
|
| 119 |
'note': 'On-hand stock is physically consolidated (shared warehouse); not DBA-split.'},
|
| 120 |
{'key': 'procurement', 'label': 'Procurement', 'brand': False, 'hq': False, 'validate': True, 'source': 'Odoo',
|
| 121 |
+
'validate_only': True,
|
| 122 |
+
'note': 'PAGE RETIRED 2026-08-03 (owner wave-17 item 13: "We should be able to replace '
|
| 123 |
+
'Procurement completely, and add it as part of the Product database"). The buy '
|
| 124 |
+
'list is now a saved VIEW on the Product grid, filtered on a FORMULA field over '
|
| 125 |
+
'the supplier/lead-time columns and the demand measure β the owner\'s ruling R3: '
|
| 126 |
+
'"Buy list is just a View, with a Filter from a Formula field that taps into '
|
| 127 |
+
'Metrics Fields... the 8-month demand baseline etc. is just math in a Formula '
|
| 128 |
+
'field." The ROW STAYS validate_only: `modules/procurement.py` still owns the '
|
| 129 |
+
'supplier master map (procurement_suppliers.json, 3,963 SKUs) that seeds those '
|
| 130 |
+
'columns, and its validate() is the proof they reconcile.'},
|
| 131 |
{'key': 'vendor', 'label': 'Vendors', 'brand': False, 'hq': False, 'validate': False, 'archived': True,
|
| 132 |
'note': 'Vendor master data + the SKUs each supplies; multiple-vendor / cheapest-price view.'},
|
| 133 |
{'key': 'warehouse', 'label': 'Warehouse', 'brand': False, 'hq': False, 'validate': True, 'archived': True,
|
| 134 |
'note': 'Movement & efficiency: on-time ship, Pick-Pack-Ship cycle times, throughput, backlog age, shrinkage. Physical ops (consolidated).'},
|
| 135 |
{'key': 'ar', 'label': 'Collections', 'brand': False, 'hq': True, 'validate': True,
|
| 136 |
+
'source': 'Odoo', 'api_surface': False, 'admin_only': True,
|
| 137 |
+
'note': 'PAGE RETIRED 2026-08-03 (owner wave-17 item 15: "Collections should also be '
|
| 138 |
+
'entirely replicable as just a View under Customer"). The worklist is the shared '
|
| 139 |
+
'"Collections" view on the Customer grid β same numbers, from this module\'s own '
|
| 140 |
+
'reconciled blocks (ar_open/ar_overdue/ar_exposure/days_to_pay + the four aging '
|
| 141 |
+
'buckets). The ROW STAYS validate_only so validate.py keeps running ar.validate(), '
|
| 142 |
+
'which is the proof those columns rest on; archiving it would have skipped the '
|
| 143 |
+
'reconciliation while the numbers kept shipping. β NOT `validate_only`, and the '
|
| 144 |
+
'difference is a LIVE WORKFLOW: this page also mounts the admin-gated STATEMENTS '
|
| 145 |
+
'sender (app._collections_statements -> modules/collections_send), the ONE '
|
| 146 |
+
'sanctioned Odoo writer, which the same ruling says stays untouched. So the row '
|
| 147 |
+
'keeps a Streamlit page for ADMINS ONLY (`admin_only`) and leaves the API payload '
|
| 148 |
+
'entirely (`api_surface: False`) β no "Collections" in the React nav, no second '
|
| 149 |
+
'worklist, and the biweekly send keeps its door.'},
|
| 150 |
{'key': 'returns', 'label': 'Returns', 'brand': False, 'hq': True, 'validate': True, 'archived': True,
|
| 151 |
'note': 'Credit-note lens: refund concentration by SKU (quality) and customer (behavior). Company-level.'},
|
| 152 |
{'key': 'outreach', 'label': 'Outreach', 'brand': True, 'hq': False, 'validate': False, 'archived': True,
|
|
|
|
| 171 |
'procurement mapping gaps, count-trust (unverified on-hand counts), untracked-on-'
|
| 172 |
'order β so operational workflows stay clean for doing the work.'},
|
| 173 |
{'key': 'dictionary', 'label': 'Metric Dictionary', 'brand': False, 'hq': True, 'validate': True,
|
| 174 |
+
'nav': False, 'validate_only': True,
|
| 175 |
+
'note': 'PAGE RETIRED 2026-07-23 (owner: broken/not customer-facing) β row kept ONLY so '
|
| 176 |
+
'validate.py keeps running the semantic-layer contracts (the Analyst grounding '
|
| 177 |
+
'proof). No nav, no page. Wave 17 R8 ("I don\'t even know what it does β delete '
|
| 178 |
+
'them") made that literal: `validate_only` takes it out of the account menu too, '
|
| 179 |
+
'which is the last place it was still visible. The proof survives; the door does not.'},
|
| 180 |
{'key': 'settings', 'label': 'Settings', 'brand': False, 'hq': True, 'validate': False,
|
| 181 |
'nav': False, # sidebar sentinel (account group) β owner IA 2026-07-12
|
| 182 |
'note': 'User scope settings: the Business Unit toggle (strict isolation) and the Data basis '
|
royalimports_os/modules/ar.py
CHANGED
|
@@ -93,6 +93,13 @@ def refresh_days_to_pay_snapshot(max_age_hours=DTP_MAX_AGE_HOURS, t=None, force=
|
|
| 93 |
return {'error': str(e)[:200]}
|
| 94 |
|
| 95 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 96 |
def _bucket(days):
|
| 97 |
if days <= 0:
|
| 98 |
return 'Current'
|
|
@@ -237,12 +244,22 @@ def credit_exposure(t=None, grace_days=5, limit=40):
|
|
| 237 |
|
| 238 |
def _e(pid, name):
|
| 239 |
return per.setdefault(pid, {'pid': pid, 'customer': name, 'draft': 0.0, 'open': 0.0,
|
| 240 |
-
'overdue': 0.0, 'uninvoiced': 0.0, 'credit_limit': 0.0
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 241 |
|
| 242 |
for d in docs:
|
| 243 |
e = _e(O.m2o_id(d['partner_id']), O.m2o_name(d['partner_id']))
|
| 244 |
if d['days_overdue'] > grace_days:
|
| 245 |
e['overdue'] += d['open']
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 246 |
else:
|
| 247 |
e['open'] += d['open']
|
| 248 |
|
|
@@ -476,6 +493,22 @@ def validate(t=None, exposure=None, behavior=None):
|
|
| 476 |
'gap': round(bucket_sum - total, 2),
|
| 477 |
'ok': abs(bucket_sum - total) <= 1.0})
|
| 478 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 479 |
exp_sum = sum(e['open'] for e in top_exposures(t, limit=10**9))
|
| 480 |
checks.append({
|
| 481 |
'check': 'AR: Ξ£(per-customer open) == total open AR',
|
|
|
|
| 93 |
return {'error': str(e)[:200]}
|
| 94 |
|
| 95 |
|
| 96 |
+
#: The OVERDUE buckets, in order β `BUCKETS` minus 'Current'. Wave 17 R2 gives each of these a
|
| 97 |
+
#: column on the Customer grid, so the vocabulary must have exactly one home: a second list
|
| 98 |
+
#: spelled '31_60' somewhere else is how two surfaces start disagreeing about what "60 days"
|
| 99 |
+
#: means. Derived from BUCKETS rather than retyped.
|
| 100 |
+
OVERDUE_BUCKETS = [b for b in BUCKETS if b != 'Current']
|
| 101 |
+
|
| 102 |
+
|
| 103 |
def _bucket(days):
|
| 104 |
if days <= 0:
|
| 105 |
return 'Current'
|
|
|
|
| 244 |
|
| 245 |
def _e(pid, name):
|
| 246 |
return per.setdefault(pid, {'pid': pid, 'customer': name, 'draft': 0.0, 'open': 0.0,
|
| 247 |
+
'overdue': 0.0, 'uninvoiced': 0.0, 'credit_limit': 0.0,
|
| 248 |
+
# Wave 17 R2 β the AGING SPLIT of `overdue`, per partner.
|
| 249 |
+
# Same loop, same documents, no extra Odoo call: this is the
|
| 250 |
+
# decomposition the Customer grid needs to REPLACE the
|
| 251 |
+
# Collections page ("who has money in 90+" is the whole job).
|
| 252 |
+
**{f'aged_{b}': 0.0 for b in OVERDUE_BUCKETS}})
|
| 253 |
|
| 254 |
for d in docs:
|
| 255 |
e = _e(O.m2o_id(d['partner_id']), O.m2o_name(d['partner_id']))
|
| 256 |
if d['days_overdue'] > grace_days:
|
| 257 |
e['overdue'] += d['open']
|
| 258 |
+
# β BUCKETED ONLY PAST THE GRACE PERIOD, deliberately β so the four buckets SUM
|
| 259 |
+
# EXACTLY to `overdue` and the grid's columns reconcile to its own total. Using
|
| 260 |
+
# `_bucket` on every doc instead would file days 1..grace under '1-30' while
|
| 261 |
+
# `overdue` excluded them, and the decomposition would be quietly short.
|
| 262 |
+
e[f'aged_{_bucket(d["days_overdue"])}'] += d['open']
|
| 263 |
else:
|
| 264 |
e['open'] += d['open']
|
| 265 |
|
|
|
|
| 493 |
'gap': round(bucket_sum - total, 2),
|
| 494 |
'ok': abs(bucket_sum - total) <= 1.0})
|
| 495 |
|
| 496 |
+
# WAVE 17 R2 β the aging SPLIT must decompose the overdue total exactly. These four numbers
|
| 497 |
+
# became COLUMNS on the Customer grid this wave (the Collections view is built on them), so
|
| 498 |
+
# a bucket that drifted from `overdue` would be a wrong number on a worklist somebody works
|
| 499 |
+
# from. Ξ£(buckets) == Ξ£(overdue) is exact by construction (same loop, same documents) and is
|
| 500 |
+
# asserted rather than assumed, because "by construction" is what every drift was before it
|
| 501 |
+
# happened.
|
| 502 |
+
ce_buckets = exposure or credit_exposure(t)
|
| 503 |
+
bkt = sum(r.get(f'aged_{b}', 0.0) for r in ce_buckets['_all_rows']
|
| 504 |
+
for b in OVERDUE_BUCKETS)
|
| 505 |
+
od = sum(r['overdue'] for r in ce_buckets['_all_rows'])
|
| 506 |
+
checks.append({
|
| 507 |
+
'check': 'AR aging split: Ξ£(1-30, 31-60, 61-90, 90+) == Ξ£(overdue)',
|
| 508 |
+
'a': round(bkt, 2), 'b': round(od, 2),
|
| 509 |
+
'gap': round(bkt - od, 2),
|
| 510 |
+
'ok': abs(bkt - od) <= 0.01})
|
| 511 |
+
|
| 512 |
exp_sum = sum(e['open'] for e in top_exposures(t, limit=10**9))
|
| 513 |
checks.append({
|
| 514 |
'check': 'AR: Ξ£(per-customer open) == total open AR',
|
royalimports_os/modules/customer_data.py
CHANGED
|
@@ -58,6 +58,12 @@ def agent_pids(agent_name):
|
|
| 58 |
return cust.agent_partner_ids(agent_name) if agent_name else None
|
| 59 |
|
| 60 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 61 |
def _ar_attrs(t=None):
|
| 62 |
"""{pid: {ar_open, ar_overdue, ar_exposure}} β the AR / credit-exposure family.
|
| 63 |
|
|
@@ -86,6 +92,11 @@ def _ar_attrs(t=None):
|
|
| 86 |
'ar_open': r.get('open', 0.0) or 0.0,
|
| 87 |
'ar_overdue': r.get('overdue', 0.0) or 0.0,
|
| 88 |
'ar_exposure': r.get('exposure', 0.0) or 0.0,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 89 |
}
|
| 90 |
except Exception:
|
| 91 |
pass
|
|
@@ -348,6 +359,7 @@ def _pool_build(agent_name, team_id, limit, fast=False):
|
|
| 348 |
'ar_overdue': (ar_a.get(pid) or {}).get('ar_overdue', 0.0),
|
| 349 |
'ar_exposure': (ar_a.get(pid) or {}).get('ar_exposure', 0.0),
|
| 350 |
'days_to_pay': (ar_a.get(pid) or {}).get('days_to_pay'),
|
|
|
|
| 351 |
# Product mix, LTM, line grain, ALL-channel.
|
| 352 |
'top_category': (mix_a.get(pid) or {}).get('top_category', '(none)'),
|
| 353 |
'top_category_pct': (mix_a.get(pid) or {}).get('top_category_pct'),
|
|
@@ -437,6 +449,7 @@ def _reconcile_ledger(rows, total, agent_name, team_id):
|
|
| 437 |
'zip': '(none)', 'payment_terms': '(none)', 'customer_since': '',
|
| 438 |
'_created': '', 'tags': '(none)', 'pricelist': '(none)',
|
| 439 |
'ar_open': 0.0, 'ar_overdue': 0.0, 'ar_exposure': 0.0, 'days_to_pay': None,
|
|
|
|
| 440 |
'top_category': '(none)', 'top_category_pct': None, 'sku_count': 0,
|
| 441 |
'top_sku': '(none)', 'salesperson': '(none)', 'lat': None, 'lon': None,
|
| 442 |
'revenue_ytd': 0.0, 'revenue_ly': 0.0, 'yoy_pct': None, 'at_risk': 0.0,
|
|
|
|
| 58 |
return cust.agent_partner_ids(agent_name) if agent_name else None
|
| 59 |
|
| 60 |
|
| 61 |
+
#: Wave 17 R2 β `ar` bucket label -> the grid's column key. ONE mapping, read by the attribute
|
| 62 |
+
#: builder, the empty-row default and validate(), so a bucket cannot exist under two spellings.
|
| 63 |
+
AR_BUCKET_FIELDS = {'1-30': 'ar_aged_1_30', '31-60': 'ar_aged_31_60',
|
| 64 |
+
'61-90': 'ar_aged_61_90', '90+': 'ar_aged_90_plus'}
|
| 65 |
+
|
| 66 |
+
|
| 67 |
def _ar_attrs(t=None):
|
| 68 |
"""{pid: {ar_open, ar_overdue, ar_exposure}} β the AR / credit-exposure family.
|
| 69 |
|
|
|
|
| 92 |
'ar_open': r.get('open', 0.0) or 0.0,
|
| 93 |
'ar_overdue': r.get('overdue', 0.0) or 0.0,
|
| 94 |
'ar_exposure': r.get('exposure', 0.0) or 0.0,
|
| 95 |
+
# Wave 17 R2 β the aging split, so a saved VIEW can be the collections
|
| 96 |
+
# worklist. Keys mirror `ar.OVERDUE_BUCKETS` through AR_BUCKET_FIELDS; the four
|
| 97 |
+
# sum EXACTLY to `ar_overdue` (gated in validate()).
|
| 98 |
+
**{k: r.get(f'aged_{b}', 0.0) or 0.0
|
| 99 |
+
for b, k in AR_BUCKET_FIELDS.items()},
|
| 100 |
}
|
| 101 |
except Exception:
|
| 102 |
pass
|
|
|
|
| 359 |
'ar_overdue': (ar_a.get(pid) or {}).get('ar_overdue', 0.0),
|
| 360 |
'ar_exposure': (ar_a.get(pid) or {}).get('ar_exposure', 0.0),
|
| 361 |
'days_to_pay': (ar_a.get(pid) or {}).get('days_to_pay'),
|
| 362 |
+
**{k: (ar_a.get(pid) or {}).get(k, 0.0) for k in AR_BUCKET_FIELDS.values()},
|
| 363 |
# Product mix, LTM, line grain, ALL-channel.
|
| 364 |
'top_category': (mix_a.get(pid) or {}).get('top_category', '(none)'),
|
| 365 |
'top_category_pct': (mix_a.get(pid) or {}).get('top_category_pct'),
|
|
|
|
| 449 |
'zip': '(none)', 'payment_terms': '(none)', 'customer_since': '',
|
| 450 |
'_created': '', 'tags': '(none)', 'pricelist': '(none)',
|
| 451 |
'ar_open': 0.0, 'ar_overdue': 0.0, 'ar_exposure': 0.0, 'days_to_pay': None,
|
| 452 |
+
**{k: 0.0 for k in AR_BUCKET_FIELDS.values()},
|
| 453 |
'top_category': '(none)', 'top_category_pct': None, 'sku_count': 0,
|
| 454 |
'top_sku': '(none)', 'salesperson': '(none)', 'lat': None, 'lon': None,
|
| 455 |
'revenue_ytd': 0.0, 'revenue_ly': 0.0, 'yoy_pct': None, 'at_risk': 0.0,
|
royalimports_os/modules/product_data.py
CHANGED
|
@@ -31,14 +31,66 @@ template and this deliberately mirrors its signature and its row shape.
|
|
| 31 |
allocation) and is left for the wave that needs it. `validate()` reconciles what SHIPS; it
|
| 32 |
does not pretend to cover columns that are absent.
|
| 33 |
"""
|
|
|
|
| 34 |
import zlib
|
|
|
|
| 35 |
|
| 36 |
import core.periods as P
|
| 37 |
import core.table_store as table_store
|
| 38 |
import modules.products as products
|
| 39 |
|
| 40 |
#: Columns that exist ONLY on a consolidated pull. See decision 2.
|
| 41 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 42 |
|
| 43 |
#: Wave 16 C-TOPIC β the PRODUCT table's OWN workspace bucket. β Never the customer one:
|
| 44 |
#: product pids are CRC32 hashes of SKU codes and customer pids are Odoo partner ids, so in a
|
|
@@ -94,6 +146,7 @@ def pool(team_id=None, t=None):
|
|
| 94 |
t = t or P.today()
|
| 95 |
consolidated = team_id is None
|
| 96 |
inv = _inventory_by_code(t) if consolidated else {}
|
|
|
|
| 97 |
|
| 98 |
rows = []
|
| 99 |
for r in products.directory(t=t, team_id=team_id):
|
|
@@ -109,6 +162,14 @@ def pool(team_id=None, t=None):
|
|
| 109 |
"qty_ytd": r.get("qty_ytd", 0.0),
|
| 110 |
"orders_ytd": r.get("orders_ytd", 0),
|
| 111 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 112 |
if consolidated:
|
| 113 |
e = inv.get(code) or {}
|
| 114 |
row.update({
|
|
@@ -119,6 +180,20 @@ def pool(team_id=None, t=None):
|
|
| 119 |
"dos": e.get("dos"),
|
| 120 |
"stock_bucket": e.get("bucket"),
|
| 121 |
})
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 122 |
rows.append(row)
|
| 123 |
|
| 124 |
rows.sort(key=lambda r: -(r["rev_ytd"] or 0.0))
|
|
@@ -140,7 +215,30 @@ def validate(team_id=None, t=None):
|
|
| 140 |
yf, yt = P.ytd(t)
|
| 141 |
theirs = round(sum(v.get("rev", 0.0)
|
| 142 |
for v in (products._sku_rev(yf, yt, team_id) or {}).values()), 2)
|
| 143 |
-
|
| 144 |
"check": "Ξ£ per-SKU YTD revenue == modules.products._sku_rev over the same window",
|
| 145 |
"ours": ours, "theirs": theirs, "ok": abs(ours - theirs) < 0.01,
|
| 146 |
}]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 31 |
allocation) and is left for the wave that needs it. `validate()` reconciles what SHIPS; it
|
| 32 |
does not pretend to cover columns that are absent.
|
| 33 |
"""
|
| 34 |
+
import json
|
| 35 |
import zlib
|
| 36 |
+
from pathlib import Path
|
| 37 |
|
| 38 |
import core.periods as P
|
| 39 |
import core.table_store as table_store
|
| 40 |
import modules.products as products
|
| 41 |
|
| 42 |
#: Columns that exist ONLY on a consolidated pull. See decision 2.
|
| 43 |
+
#: `cover_gap_d` / `buy_now` (wave 17) join it because both are computed FROM `dos`, and a buy
|
| 44 |
+
#: signal built on a stock number the caller cannot see would be a recommendation nobody could
|
| 45 |
+
#: check ([[no-unverifiable-aggregates]]).
|
| 46 |
+
CONSOLIDATED_ONLY = ("on_hand", "unit_cost", "inv_value", "qty_ltm", "dos", "stock_bucket",
|
| 47 |
+
"cover_gap_d", "buy_now")
|
| 48 |
+
|
| 49 |
+
#: Wave 17 (owner item 13, ruling R3) β the SUPPLIER MASTER, from the curated mastersheet map
|
| 50 |
+
#: `procurement_suppliers.json` (3,963 SKUs; supplier on 3,624, lead time on 3,563). NOT Odoo:
|
| 51 |
+
#: the owner confirmed this data came from the Inventory System Mastersheet, which is why
|
| 52 |
+
#: `modules/product_data`'s header said Vendor/Country were "NOT HERE, named rather than
|
| 53 |
+
#: quietly missing" and needed "a loader this module deliberately does not invent". This is
|
| 54 |
+
#: that loader.
|
| 55 |
+
#:
|
| 56 |
+
#: β THESE ARE CONTRACT COLUMNS, NOT USER-CREATED FIELDS, AND THE REASON IS A PERMISSION FACT.
|
| 57 |
+
#: A user-created field and its values live in the PER-USER strata (`table_store.workspace`
|
| 58 |
+
#: reads `store.get(key)[username]`); only VIEWS are shared. So a shared "Buy list" view that
|
| 59 |
+
#: filtered on a user-created column would, for every OTHER account, name a column that does not
|
| 60 |
+
#: exist β and an unknown column is an INACTIVE condition in the tri-state engine, which IGNORES
|
| 61 |
+
#: it and therefore WIDENS. The buy list would silently show the whole catalogue to everyone but
|
| 62 |
+
#: its author. Contract columns are identical for every reader, so the view means one thing.
|
| 63 |
+
#: β’ The owner asked for these to be EDITABLE ("turn this Excel sheet into a User created Field
|
| 64 |
+
#: that we can edit"). That needs a SHARED field/overlay stratum, which the platform does not
|
| 65 |
+
#: have yet β booked as the named gap in the wave-17 doc rather than faked per-user.
|
| 66 |
+
_SUPPLIER_MAP_PATH = Path(__file__).resolve().parent.parent / "procurement_suppliers.json"
|
| 67 |
+
_SUPPLIER_CACHE = {}
|
| 68 |
+
|
| 69 |
+
|
| 70 |
+
def supplier_master():
|
| 71 |
+
"""`{code: {supplier, lead_days, origin_country, first_cost}}`, read once per process.
|
| 72 |
+
|
| 73 |
+
Degrades to `{}` when the file is unreadable, matching `_inventory_by_code`: a product table
|
| 74 |
+
that will not render because a master map is missing is a worse failure than one with blank
|
| 75 |
+
supplier columns.
|
| 76 |
+
"""
|
| 77 |
+
if _SUPPLIER_CACHE:
|
| 78 |
+
return _SUPPLIER_CACHE
|
| 79 |
+
try:
|
| 80 |
+
raw = json.loads(_SUPPLIER_MAP_PATH.read_text(encoding="utf-8"))
|
| 81 |
+
except Exception:
|
| 82 |
+
return {}
|
| 83 |
+
for code, meta in (raw or {}).items():
|
| 84 |
+
if not isinstance(meta, dict):
|
| 85 |
+
continue
|
| 86 |
+
lead = meta.get("lead")
|
| 87 |
+
_SUPPLIER_CACHE[str(code)] = {
|
| 88 |
+
"supplier": (meta.get("vendor") or "") or None,
|
| 89 |
+
"lead_days": int(lead) if isinstance(lead, (int, float)) else None,
|
| 90 |
+
"origin_country": (meta.get("country") or "") or None,
|
| 91 |
+
"first_cost": meta.get("first_cost"),
|
| 92 |
+
}
|
| 93 |
+
return _SUPPLIER_CACHE
|
| 94 |
|
| 95 |
#: Wave 16 C-TOPIC β the PRODUCT table's OWN workspace bucket. β Never the customer one:
|
| 96 |
#: product pids are CRC32 hashes of SKU codes and customer pids are Odoo partner ids, so in a
|
|
|
|
| 146 |
t = t or P.today()
|
| 147 |
consolidated = team_id is None
|
| 148 |
inv = _inventory_by_code(t) if consolidated else {}
|
| 149 |
+
sup = supplier_master()
|
| 150 |
|
| 151 |
rows = []
|
| 152 |
for r in products.directory(t=t, team_id=team_id):
|
|
|
|
| 162 |
"qty_ytd": r.get("qty_ytd", 0.0),
|
| 163 |
"orders_ytd": r.get("orders_ytd", 0),
|
| 164 |
}
|
| 165 |
+
# Wave 17 R3 β the supplier master, on every pull (it is catalogue data, not stock).
|
| 166 |
+
s = sup.get(code) or {}
|
| 167 |
+
row.update({
|
| 168 |
+
"supplier": s.get("supplier") or "(none)",
|
| 169 |
+
"lead_days": s.get("lead_days"),
|
| 170 |
+
"origin_country": s.get("origin_country") or "(none)",
|
| 171 |
+
"first_cost": s.get("first_cost"),
|
| 172 |
+
})
|
| 173 |
if consolidated:
|
| 174 |
e = inv.get(code) or {}
|
| 175 |
row.update({
|
|
|
|
| 180 |
"dos": e.get("dos"),
|
| 181 |
"stock_bucket": e.get("bucket"),
|
| 182 |
})
|
| 183 |
+
# THE BUY TRIGGER (R3), ported from `modules/procurement`'s lead-time-cover rule:
|
| 184 |
+
# buy when the shelf runs out before a reorder could land.
|
| 185 |
+
#
|
| 186 |
+
# β BLANK, NOT "OK", WHEN EITHER INPUT IS MISSING. 339 SKUs have no supplier and 400
|
| 187 |
+
# no lead time; `dos` is null for anything that never sells through. "We don't know"
|
| 188 |
+
# and "you're fine" are different sentences, and only one of them is safe to print
|
| 189 |
+
# beside a purchasing decision.
|
| 190 |
+
dos, lead = e.get("dos"), s.get("lead_days")
|
| 191 |
+
if isinstance(dos, (int, float)) and isinstance(lead, (int, float)) and lead > 0:
|
| 192 |
+
row["cover_gap_d"] = int(round(dos - lead))
|
| 193 |
+
row["buy_now"] = "Buy now" if dos < lead else "OK"
|
| 194 |
+
else:
|
| 195 |
+
row["cover_gap_d"] = None
|
| 196 |
+
row["buy_now"] = None
|
| 197 |
rows.append(row)
|
| 198 |
|
| 199 |
rows.sort(key=lambda r: -(r["rev_ytd"] or 0.0))
|
|
|
|
| 215 |
yf, yt = P.ytd(t)
|
| 216 |
theirs = round(sum(v.get("rev", 0.0)
|
| 217 |
for v in (products._sku_rev(yf, yt, team_id) or {}).values()), 2)
|
| 218 |
+
checks = [{
|
| 219 |
"check": "Ξ£ per-SKU YTD revenue == modules.products._sku_rev over the same window",
|
| 220 |
"ours": ours, "theirs": theirs, "ok": abs(ours - theirs) < 0.01,
|
| 221 |
}]
|
| 222 |
+
# WAVE 17 R3 β the BUY SIGNAL must be a total, exact partition of the catalogue, and every
|
| 223 |
+
# member of it must be re-derivable from the two columns beside it. A signal somebody buys
|
| 224 |
+
# stock on cannot be "mostly right": the failure that matters is a row that says OK because
|
| 225 |
+
# an input was missing, so the blank leg is checked as hard as the other two.
|
| 226 |
+
if team_id is None: # consolidated only β the inputs exist only there
|
| 227 |
+
buy = [r for r in rows if r.get("buy_now") == "Buy now"]
|
| 228 |
+
ok_rows = [r for r in rows if r.get("buy_now") == "OK"]
|
| 229 |
+
blank = [r for r in rows if r.get("buy_now") is None]
|
| 230 |
+
mis = sum(1 for r in buy if not (r["dos"] < r["lead_days"]))
|
| 231 |
+
mis += sum(1 for r in ok_rows if not (r["dos"] >= r["lead_days"]))
|
| 232 |
+
# A blank must be UNKNOWN β never a row we could have answered and quietly did not.
|
| 233 |
+
mis += sum(1 for r in blank
|
| 234 |
+
if isinstance(r.get("dos"), (int, float))
|
| 235 |
+
and isinstance(r.get("lead_days"), (int, float)) and r["lead_days"] > 0)
|
| 236 |
+
checks.append({
|
| 237 |
+
"check": "Buy signal partitions the catalogue (buy + ok + unknown == rows, none "
|
| 238 |
+
"misclassified)",
|
| 239 |
+
"ours": len(buy) + len(ok_rows) + len(blank) - mis, "theirs": len(rows),
|
| 240 |
+
"ok": mis == 0 and len(buy) + len(ok_rows) + len(blank) == len(rows),
|
| 241 |
+
"detail": {"buy_now": len(buy), "ok": len(ok_rows), "unknown": len(blank),
|
| 242 |
+
"misclassified": mis},
|
| 243 |
+
})
|
| 244 |
+
return checks
|
web/dist-embed/index.html
CHANGED
|
The diff for this file is too large to render.
See raw diff
|
|
|
web/dist-embed/sample_customers.json
CHANGED
|
@@ -1,479 +1,511 @@
|
|
| 1 |
-
{
|
| 2 |
-
"fields": [
|
| 3 |
-
{
|
| 4 |
-
"key": "customer",
|
| 5 |
-
"label": "Customer",
|
| 6 |
-
"type": "text",
|
| 7 |
-
"source": "odoo",
|
| 8 |
-
"pinned": true,
|
| 9 |
-
"default": true,
|
| 10 |
-
"description": "The customer's name in Odoo. One row per customer who ordered in the last 24 months."
|
| 11 |
-
},
|
| 12 |
-
{
|
| 13 |
-
"key": "odoo_status",
|
| 14 |
-
"label": "Odoo record",
|
| 15 |
-
"type": "status",
|
| 16 |
-
"source": "odoo",
|
| 17 |
-
"default": false,
|
| 18 |
-
"description": "Whether this customer still exists in Odoo. Archived means deleted there."
|
| 19 |
-
},
|
| 20 |
-
{
|
| 21 |
-
"key": "agent",
|
| 22 |
-
"label": "Agent",
|
| 23 |
-
"type": "text",
|
| 24 |
-
"source": "odoo",
|
| 25 |
-
"default": true,
|
| 26 |
-
"description": "The sales agent who owns this account."
|
| 27 |
-
},
|
| 28 |
-
{
|
| 29 |
-
"key": "dba",
|
| 30 |
-
"label": "DBA",
|
| 31 |
-
"type": "select",
|
| 32 |
-
"source": "odoo",
|
| 33 |
-
"default": false,
|
| 34 |
-
"options": [
|
| 35 |
-
"Fisch",
|
| 36 |
-
"Royal",
|
| 37 |
-
"Both"
|
| 38 |
-
],
|
| 39 |
-
"description": "The brand this customer buys from - Fisch, Royal, or both. Amazon-channel orders are not a DBA."
|
| 40 |
-
},
|
| 41 |
-
{
|
| 42 |
-
"key": "salesperson",
|
| 43 |
-
"label": "Salesperson",
|
| 44 |
-
"type": "text",
|
| 45 |
-
"source": "odoo",
|
| 46 |
-
"default": false,
|
| 47 |
-
"description": "Who keyed in most of this customer's orders
|
| 48 |
-
},
|
| 49 |
-
{
|
| 50 |
-
"key": "city",
|
| 51 |
-
"label": "City",
|
| 52 |
-
"type": "text",
|
| 53 |
-
"source": "odoo",
|
| 54 |
-
"default": true,
|
| 55 |
-
"description": "City on the customer's Odoo address."
|
| 56 |
-
},
|
| 57 |
-
{
|
| 58 |
-
"key": "state",
|
| 59 |
-
"label": "State",
|
| 60 |
-
"type": "text",
|
| 61 |
-
"source": "odoo",
|
| 62 |
-
"default": true,
|
| 63 |
-
"description": "State or province on the customer's Odoo address."
|
| 64 |
-
},
|
| 65 |
-
{
|
| 66 |
-
"key": "country",
|
| 67 |
-
"label": "Country",
|
| 68 |
-
"type": "text",
|
| 69 |
-
"source": "odoo",
|
| 70 |
-
"default": false,
|
| 71 |
-
"description": "Country on the customer's Odoo address."
|
| 72 |
-
},
|
| 73 |
-
{
|
| 74 |
-
"key": "zip",
|
| 75 |
-
"label": "ZIP",
|
| 76 |
-
"type": "text",
|
| 77 |
-
"source": "odoo",
|
| 78 |
-
"default": false,
|
| 79 |
-
"description": "Postal code on the customer's Odoo address."
|
| 80 |
-
},
|
| 81 |
-
{
|
| 82 |
-
"key": "customer_since",
|
| 83 |
-
"label": "Customer since",
|
| 84 |
-
"type": "date",
|
| 85 |
-
"source": "odoo",
|
| 86 |
-
"default": false,
|
| 87 |
-
"description": "When this customer was first set up in Odoo."
|
| 88 |
-
},
|
| 89 |
-
{
|
| 90 |
-
"key": "tags",
|
| 91 |
-
"label": "Tags",
|
| 92 |
-
"type": "text",
|
| 93 |
-
"source": "odoo",
|
| 94 |
-
"default": false,
|
| 95 |
-
"description": "Odoo labels on this customer, comma-separated."
|
| 96 |
-
},
|
| 97 |
-
{
|
| 98 |
-
"key": "pricelist",
|
| 99 |
-
"label": "Price list",
|
| 100 |
-
"type": "text",
|
| 101 |
-
"source": "odoo",
|
| 102 |
-
"default": false,
|
| 103 |
-
"description": "The price list this customer buys on."
|
| 104 |
-
},
|
| 105 |
-
{
|
| 106 |
-
"key": "payment_terms",
|
| 107 |
-
"label": "Payment terms",
|
| 108 |
-
"type": "text",
|
| 109 |
-
"source": "odoo",
|
| 110 |
-
"default": false,
|
| 111 |
-
"description": "Payment terms on this customer's account
|
| 112 |
-
},
|
| 113 |
-
{
|
| 114 |
-
"key": "last_order",
|
| 115 |
-
"label": "Last order",
|
| 116 |
-
"type": "date",
|
| 117 |
-
"source": "odoo",
|
| 118 |
-
"default": true,
|
| 119 |
-
"description": "Date of the most recent confirmed order."
|
| 120 |
-
},
|
| 121 |
-
{
|
| 122 |
-
"key": "overdue_days",
|
| 123 |
-
"label": "Overdue days",
|
| 124 |
-
"type": "int",
|
| 125 |
-
"source": "odoo",
|
| 126 |
-
"default": true,
|
| 127 |
-
"description": "How many days late this customer is running against their own usual ordering rhythm."
|
| 128 |
-
},
|
| 129 |
-
{
|
| 130 |
-
"_note": "filterable:false
|
| 131 |
-
"key": "est_missed",
|
| 132 |
-
"label": "Est. missed $",
|
| 133 |
-
"type": "currency",
|
| 134 |
-
"source": "odoo",
|
| 135 |
-
"default": true,
|
| 136 |
-
"agg": "sum",
|
| 137 |
-
"filterable": false,
|
| 138 |
-
"description": "Estimated sales missed while quiet: missed orders (capped at 3) times average order value. An estimate, not money owed."
|
| 139 |
-
},
|
| 140 |
-
{
|
| 141 |
-
"key": "ar_open",
|
| 142 |
-
"label": "AR open $",
|
| 143 |
-
"type": "currency",
|
| 144 |
-
"source": "odoo",
|
| 145 |
-
"default": false,
|
| 146 |
-
"description": "Invoiced money owed, not yet overdue."
|
| 147 |
-
},
|
| 148 |
-
{
|
| 149 |
-
"key": "ar_overdue",
|
| 150 |
-
"label": "AR overdue $",
|
| 151 |
-
"type": "currency",
|
| 152 |
-
"source": "odoo",
|
| 153 |
-
"default": false,
|
| 154 |
-
"description": "Invoiced money past due
|
| 155 |
-
},
|
| 156 |
-
{
|
| 157 |
-
"key": "ar_exposure",
|
| 158 |
-
"label": "Credit exposure $",
|
| 159 |
-
"type": "currency",
|
| 160 |
-
"source": "odoo",
|
| 161 |
-
"default": false,
|
| 162 |
-
"description": "The most you could be out if they stopped paying today: open, overdue, draft and not-yet-invoiced."
|
| 163 |
-
},
|
| 164 |
-
{
|
| 165 |
-
"key": "
|
| 166 |
-
"label": "
|
| 167 |
-
"type": "
|
| 168 |
-
"source": "odoo",
|
| 169 |
-
"default": false,
|
| 170 |
-
"description": "
|
| 171 |
-
},
|
| 172 |
-
{
|
| 173 |
-
"key": "
|
| 174 |
-
"label": "
|
| 175 |
-
"type": "
|
| 176 |
-
"source": "odoo",
|
| 177 |
-
"default": false,
|
| 178 |
-
"description": "
|
| 179 |
-
},
|
| 180 |
-
{
|
| 181 |
-
"key": "
|
| 182 |
-
"label": "
|
| 183 |
-
"type": "
|
| 184 |
-
"source": "odoo",
|
| 185 |
-
"default": false,
|
| 186 |
-
"description": "
|
| 187 |
-
},
|
| 188 |
-
{
|
| 189 |
-
"key": "
|
| 190 |
-
"label": "
|
| 191 |
-
"type": "
|
| 192 |
-
"source": "odoo",
|
| 193 |
-
"default": false,
|
| 194 |
-
"description": "
|
| 195 |
-
},
|
| 196 |
-
{
|
| 197 |
-
"key": "
|
| 198 |
-
"label": "
|
| 199 |
-
"type": "
|
| 200 |
-
"source": "odoo",
|
| 201 |
-
"default": false,
|
| 202 |
-
"description": "
|
| 203 |
-
},
|
| 204 |
-
{
|
| 205 |
-
"key": "
|
| 206 |
-
"label": "
|
| 207 |
-
"type": "
|
| 208 |
-
"source": "odoo",
|
| 209 |
-
"default": false,
|
| 210 |
-
"description": "
|
| 211 |
-
},
|
| 212 |
-
{
|
| 213 |
-
"key": "
|
| 214 |
-
"label": "
|
| 215 |
-
"type": "
|
| 216 |
-
"source": "odoo",
|
| 217 |
-
"default": false,
|
| 218 |
-
"description": "
|
| 219 |
-
},
|
| 220 |
-
{
|
| 221 |
-
"key": "
|
| 222 |
-
"label": "
|
| 223 |
-
"type": "
|
| 224 |
-
"source": "
|
| 225 |
-
"default": false,
|
| 226 |
-
"description": "
|
| 227 |
-
}
|
| 228 |
-
|
| 229 |
-
|
| 230 |
-
|
| 231 |
-
"
|
| 232 |
-
"
|
| 233 |
-
"
|
| 234 |
-
"
|
| 235 |
-
|
| 236 |
-
|
| 237 |
-
"
|
| 238 |
-
"
|
| 239 |
-
"
|
| 240 |
-
"
|
| 241 |
-
"
|
| 242 |
-
"
|
| 243 |
-
|
| 244 |
-
|
| 245 |
-
"
|
| 246 |
-
"
|
| 247 |
-
"
|
| 248 |
-
"
|
| 249 |
-
"
|
| 250 |
-
"
|
| 251 |
-
|
| 252 |
-
|
| 253 |
-
"
|
| 254 |
-
"
|
| 255 |
-
"
|
| 256 |
-
"
|
| 257 |
-
"
|
| 258 |
-
"
|
| 259 |
-
|
| 260 |
-
|
| 261 |
-
|
| 262 |
-
|
| 263 |
-
"
|
| 264 |
-
"
|
| 265 |
-
"
|
| 266 |
-
"
|
| 267 |
-
"
|
| 268 |
-
"
|
| 269 |
-
"
|
| 270 |
-
"
|
| 271 |
-
"
|
| 272 |
-
"
|
| 273 |
-
"
|
| 274 |
-
"
|
| 275 |
-
"
|
| 276 |
-
"
|
| 277 |
-
"
|
| 278 |
-
"
|
| 279 |
-
"
|
| 280 |
-
"
|
| 281 |
-
"
|
| 282 |
-
"
|
| 283 |
-
"
|
| 284 |
-
"
|
| 285 |
-
"
|
| 286 |
-
"
|
| 287 |
-
"
|
| 288 |
-
"
|
| 289 |
-
"
|
| 290 |
-
"
|
| 291 |
-
|
| 292 |
-
|
| 293 |
-
|
| 294 |
-
"
|
| 295 |
-
"
|
| 296 |
-
"
|
| 297 |
-
"
|
| 298 |
-
"
|
| 299 |
-
"
|
| 300 |
-
"
|
| 301 |
-
"
|
| 302 |
-
"
|
| 303 |
-
"
|
| 304 |
-
"
|
| 305 |
-
"
|
| 306 |
-
"
|
| 307 |
-
"
|
| 308 |
-
"
|
| 309 |
-
"
|
| 310 |
-
"
|
| 311 |
-
"
|
| 312 |
-
"
|
| 313 |
-
"
|
| 314 |
-
"
|
| 315 |
-
"
|
| 316 |
-
"
|
| 317 |
-
"
|
| 318 |
-
"
|
| 319 |
-
"
|
| 320 |
-
"
|
| 321 |
-
"
|
| 322 |
-
|
| 323 |
-
|
| 324 |
-
|
| 325 |
-
"
|
| 326 |
-
"
|
| 327 |
-
"
|
| 328 |
-
"
|
| 329 |
-
"
|
| 330 |
-
"
|
| 331 |
-
"
|
| 332 |
-
"
|
| 333 |
-
"
|
| 334 |
-
"
|
| 335 |
-
"
|
| 336 |
-
"
|
| 337 |
-
"
|
| 338 |
-
"
|
| 339 |
-
"
|
| 340 |
-
"
|
| 341 |
-
"
|
| 342 |
-
"
|
| 343 |
-
"
|
| 344 |
-
"
|
| 345 |
-
"
|
| 346 |
-
"
|
| 347 |
-
"
|
| 348 |
-
"
|
| 349 |
-
"
|
| 350 |
-
"
|
| 351 |
-
"
|
| 352 |
-
"
|
| 353 |
-
|
| 354 |
-
|
| 355 |
-
|
| 356 |
-
"
|
| 357 |
-
"
|
| 358 |
-
"
|
| 359 |
-
"
|
| 360 |
-
"
|
| 361 |
-
"
|
| 362 |
-
"
|
| 363 |
-
"
|
| 364 |
-
"
|
| 365 |
-
"
|
| 366 |
-
"
|
| 367 |
-
"
|
| 368 |
-
"
|
| 369 |
-
"
|
| 370 |
-
"
|
| 371 |
-
"
|
| 372 |
-
"
|
| 373 |
-
"
|
| 374 |
-
"
|
| 375 |
-
"
|
| 376 |
-
"
|
| 377 |
-
"
|
| 378 |
-
"
|
| 379 |
-
"
|
| 380 |
-
"
|
| 381 |
-
"
|
| 382 |
-
"
|
| 383 |
-
"
|
| 384 |
-
|
| 385 |
-
|
| 386 |
-
|
| 387 |
-
"
|
| 388 |
-
"
|
| 389 |
-
"
|
| 390 |
-
"
|
| 391 |
-
"
|
| 392 |
-
"
|
| 393 |
-
"
|
| 394 |
-
"
|
| 395 |
-
"
|
| 396 |
-
"
|
| 397 |
-
"
|
| 398 |
-
"
|
| 399 |
-
"
|
| 400 |
-
"
|
| 401 |
-
"
|
| 402 |
-
"
|
| 403 |
-
"
|
| 404 |
-
"
|
| 405 |
-
"
|
| 406 |
-
"
|
| 407 |
-
"
|
| 408 |
-
"
|
| 409 |
-
"
|
| 410 |
-
"
|
| 411 |
-
"
|
| 412 |
-
"
|
| 413 |
-
"
|
| 414 |
-
"
|
| 415 |
-
|
| 416 |
-
|
| 417 |
-
|
| 418 |
-
"
|
| 419 |
-
"
|
| 420 |
-
"
|
| 421 |
-
"
|
| 422 |
-
"
|
| 423 |
-
"
|
| 424 |
-
"
|
| 425 |
-
"
|
| 426 |
-
"
|
| 427 |
-
"
|
| 428 |
-
"
|
| 429 |
-
"
|
| 430 |
-
"
|
| 431 |
-
"
|
| 432 |
-
"
|
| 433 |
-
"
|
| 434 |
-
"
|
| 435 |
-
"
|
| 436 |
-
"
|
| 437 |
-
"
|
| 438 |
-
"
|
| 439 |
-
"
|
| 440 |
-
"
|
| 441 |
-
"
|
| 442 |
-
"
|
| 443 |
-
"
|
| 444 |
-
"
|
| 445 |
-
"
|
| 446 |
-
|
| 447 |
-
|
| 448 |
-
|
| 449 |
-
"
|
| 450 |
-
"
|
| 451 |
-
"
|
| 452 |
-
"
|
| 453 |
-
"
|
| 454 |
-
"
|
| 455 |
-
"
|
| 456 |
-
"
|
| 457 |
-
"
|
| 458 |
-
"
|
| 459 |
-
"
|
| 460 |
-
"
|
| 461 |
-
"
|
| 462 |
-
"
|
| 463 |
-
"
|
| 464 |
-
"
|
| 465 |
-
"
|
| 466 |
-
"
|
| 467 |
-
"
|
| 468 |
-
"
|
| 469 |
-
"
|
| 470 |
-
"
|
| 471 |
-
"
|
| 472 |
-
"
|
| 473 |
-
"
|
| 474 |
-
"
|
| 475 |
-
"
|
| 476 |
-
"
|
| 477 |
-
|
| 478 |
-
|
| 479 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"fields": [
|
| 3 |
+
{
|
| 4 |
+
"key": "customer",
|
| 5 |
+
"label": "Customer",
|
| 6 |
+
"type": "text",
|
| 7 |
+
"source": "odoo",
|
| 8 |
+
"pinned": true,
|
| 9 |
+
"default": true,
|
| 10 |
+
"description": "The customer's name in Odoo. One row per customer who ordered in the last 24 months."
|
| 11 |
+
},
|
| 12 |
+
{
|
| 13 |
+
"key": "odoo_status",
|
| 14 |
+
"label": "Odoo record",
|
| 15 |
+
"type": "status",
|
| 16 |
+
"source": "odoo",
|
| 17 |
+
"default": false,
|
| 18 |
+
"description": "Whether this customer still exists in Odoo. Archived means deleted there."
|
| 19 |
+
},
|
| 20 |
+
{
|
| 21 |
+
"key": "agent",
|
| 22 |
+
"label": "Agent",
|
| 23 |
+
"type": "text",
|
| 24 |
+
"source": "odoo",
|
| 25 |
+
"default": true,
|
| 26 |
+
"description": "The sales agent who owns this account."
|
| 27 |
+
},
|
| 28 |
+
{
|
| 29 |
+
"key": "dba",
|
| 30 |
+
"label": "DBA",
|
| 31 |
+
"type": "select",
|
| 32 |
+
"source": "odoo",
|
| 33 |
+
"default": false,
|
| 34 |
+
"options": [
|
| 35 |
+
"Fisch",
|
| 36 |
+
"Royal",
|
| 37 |
+
"Both"
|
| 38 |
+
],
|
| 39 |
+
"description": "The brand this customer buys from - Fisch, Royal, or both. Amazon-channel orders are not a DBA."
|
| 40 |
+
},
|
| 41 |
+
{
|
| 42 |
+
"key": "salesperson",
|
| 43 |
+
"label": "Salesperson",
|
| 44 |
+
"type": "text",
|
| 45 |
+
"source": "odoo",
|
| 46 |
+
"default": false,
|
| 47 |
+
"description": "Who keyed in most of this customer's orders \u2014 not the Agent, who owns the account."
|
| 48 |
+
},
|
| 49 |
+
{
|
| 50 |
+
"key": "city",
|
| 51 |
+
"label": "City",
|
| 52 |
+
"type": "text",
|
| 53 |
+
"source": "odoo",
|
| 54 |
+
"default": true,
|
| 55 |
+
"description": "City on the customer's Odoo address."
|
| 56 |
+
},
|
| 57 |
+
{
|
| 58 |
+
"key": "state",
|
| 59 |
+
"label": "State",
|
| 60 |
+
"type": "text",
|
| 61 |
+
"source": "odoo",
|
| 62 |
+
"default": true,
|
| 63 |
+
"description": "State or province on the customer's Odoo address."
|
| 64 |
+
},
|
| 65 |
+
{
|
| 66 |
+
"key": "country",
|
| 67 |
+
"label": "Country",
|
| 68 |
+
"type": "text",
|
| 69 |
+
"source": "odoo",
|
| 70 |
+
"default": false,
|
| 71 |
+
"description": "Country on the customer's Odoo address."
|
| 72 |
+
},
|
| 73 |
+
{
|
| 74 |
+
"key": "zip",
|
| 75 |
+
"label": "ZIP",
|
| 76 |
+
"type": "text",
|
| 77 |
+
"source": "odoo",
|
| 78 |
+
"default": false,
|
| 79 |
+
"description": "Postal code on the customer's Odoo address."
|
| 80 |
+
},
|
| 81 |
+
{
|
| 82 |
+
"key": "customer_since",
|
| 83 |
+
"label": "Customer since",
|
| 84 |
+
"type": "date",
|
| 85 |
+
"source": "odoo",
|
| 86 |
+
"default": false,
|
| 87 |
+
"description": "When this customer was first set up in Odoo."
|
| 88 |
+
},
|
| 89 |
+
{
|
| 90 |
+
"key": "tags",
|
| 91 |
+
"label": "Tags",
|
| 92 |
+
"type": "text",
|
| 93 |
+
"source": "odoo",
|
| 94 |
+
"default": false,
|
| 95 |
+
"description": "Odoo labels on this customer, comma-separated."
|
| 96 |
+
},
|
| 97 |
+
{
|
| 98 |
+
"key": "pricelist",
|
| 99 |
+
"label": "Price list",
|
| 100 |
+
"type": "text",
|
| 101 |
+
"source": "odoo",
|
| 102 |
+
"default": false,
|
| 103 |
+
"description": "The price list this customer buys on."
|
| 104 |
+
},
|
| 105 |
+
{
|
| 106 |
+
"key": "payment_terms",
|
| 107 |
+
"label": "Payment terms",
|
| 108 |
+
"type": "text",
|
| 109 |
+
"source": "odoo",
|
| 110 |
+
"default": false,
|
| 111 |
+
"description": "Payment terms on this customer's account \u2014 Net 30, for example."
|
| 112 |
+
},
|
| 113 |
+
{
|
| 114 |
+
"key": "last_order",
|
| 115 |
+
"label": "Last order",
|
| 116 |
+
"type": "date",
|
| 117 |
+
"source": "odoo",
|
| 118 |
+
"default": true,
|
| 119 |
+
"description": "Date of the most recent confirmed order."
|
| 120 |
+
},
|
| 121 |
+
{
|
| 122 |
+
"key": "overdue_days",
|
| 123 |
+
"label": "Overdue days",
|
| 124 |
+
"type": "int",
|
| 125 |
+
"source": "odoo",
|
| 126 |
+
"default": true,
|
| 127 |
+
"description": "How many days late this customer is running against their own usual ordering rhythm."
|
| 128 |
+
},
|
| 129 |
+
{
|
| 130 |
+
"_note": "filterable:false \u2014 DERIVED ANALYTIC: est_missed is min(cycles missed, 3) x AOV, a score we compute rather than an object the business has, so a condition on it would read as a fact about the customer when it is a fact about our arithmetic. It still displays and still sorts. Until wave 6 this flag also covered the frozen-window presets (revenue_ytd / revenue_ly / orders_24m / aov / yoy_pct); those are now DELETED outright under the owner's no-buildable-presets rule \u2014 see _comment. est_missed itself STAYS: no creatable measure or formula reproduces the cadence model behind it.",
|
| 131 |
+
"key": "est_missed",
|
| 132 |
+
"label": "Est. missed $",
|
| 133 |
+
"type": "currency",
|
| 134 |
+
"source": "odoo",
|
| 135 |
+
"default": true,
|
| 136 |
+
"agg": "sum",
|
| 137 |
+
"filterable": false,
|
| 138 |
+
"description": "Estimated sales missed while quiet: missed orders (capped at 3) times average order value. An estimate, not money owed."
|
| 139 |
+
},
|
| 140 |
+
{
|
| 141 |
+
"key": "ar_open",
|
| 142 |
+
"label": "AR open $",
|
| 143 |
+
"type": "currency",
|
| 144 |
+
"source": "odoo",
|
| 145 |
+
"default": false,
|
| 146 |
+
"description": "Invoiced money owed, not yet overdue."
|
| 147 |
+
},
|
| 148 |
+
{
|
| 149 |
+
"key": "ar_overdue",
|
| 150 |
+
"label": "AR overdue $",
|
| 151 |
+
"type": "currency",
|
| 152 |
+
"source": "odoo",
|
| 153 |
+
"default": false,
|
| 154 |
+
"description": "Invoiced money past due \u2014 same basis as the Collections page."
|
| 155 |
+
},
|
| 156 |
+
{
|
| 157 |
+
"key": "ar_exposure",
|
| 158 |
+
"label": "Credit exposure $",
|
| 159 |
+
"type": "currency",
|
| 160 |
+
"source": "odoo",
|
| 161 |
+
"default": false,
|
| 162 |
+
"description": "The most you could be out if they stopped paying today: open, overdue, draft and not-yet-invoiced."
|
| 163 |
+
},
|
| 164 |
+
{
|
| 165 |
+
"key": "ar_aged_1_30",
|
| 166 |
+
"label": "1-30 days $",
|
| 167 |
+
"type": "currency",
|
| 168 |
+
"source": "odoo",
|
| 169 |
+
"default": false,
|
| 170 |
+
"description": "Overdue between 1 and 30 days. The four aging buckets sum to AR overdue $."
|
| 171 |
+
},
|
| 172 |
+
{
|
| 173 |
+
"key": "ar_aged_31_60",
|
| 174 |
+
"label": "31-60 days $",
|
| 175 |
+
"type": "currency",
|
| 176 |
+
"source": "odoo",
|
| 177 |
+
"default": false,
|
| 178 |
+
"description": "Overdue between 31 and 60 days. The four aging buckets sum to AR overdue $."
|
| 179 |
+
},
|
| 180 |
+
{
|
| 181 |
+
"key": "ar_aged_61_90",
|
| 182 |
+
"label": "61-90 days $",
|
| 183 |
+
"type": "currency",
|
| 184 |
+
"source": "odoo",
|
| 185 |
+
"default": false,
|
| 186 |
+
"description": "Overdue between 61 and 90 days. The four aging buckets sum to AR overdue $."
|
| 187 |
+
},
|
| 188 |
+
{
|
| 189 |
+
"key": "ar_aged_90_plus",
|
| 190 |
+
"label": "90+ days $",
|
| 191 |
+
"type": "currency",
|
| 192 |
+
"source": "odoo",
|
| 193 |
+
"default": false,
|
| 194 |
+
"description": "Overdue by more than 90 days. The four aging buckets sum to AR overdue $."
|
| 195 |
+
},
|
| 196 |
+
{
|
| 197 |
+
"key": "days_to_pay",
|
| 198 |
+
"label": "Days to pay",
|
| 199 |
+
"type": "int",
|
| 200 |
+
"source": "odoo",
|
| 201 |
+
"default": false,
|
| 202 |
+
"description": "Average days to pay an invoice in full. Blank means no fully paid invoice yet."
|
| 203 |
+
},
|
| 204 |
+
{
|
| 205 |
+
"key": "top_category",
|
| 206 |
+
"label": "Top category",
|
| 207 |
+
"type": "text",
|
| 208 |
+
"source": "odoo",
|
| 209 |
+
"default": false,
|
| 210 |
+
"description": "The category this customer spent the most on in the last 12 months."
|
| 211 |
+
},
|
| 212 |
+
{
|
| 213 |
+
"key": "top_category_pct",
|
| 214 |
+
"label": "Top category %",
|
| 215 |
+
"type": "pct",
|
| 216 |
+
"source": "odoo",
|
| 217 |
+
"default": false,
|
| 218 |
+
"description": "Share of last-12-months spend that went to the top category."
|
| 219 |
+
},
|
| 220 |
+
{
|
| 221 |
+
"key": "sku_count",
|
| 222 |
+
"label": "SKUs bought",
|
| 223 |
+
"type": "int",
|
| 224 |
+
"source": "odoo",
|
| 225 |
+
"default": false,
|
| 226 |
+
"description": "Distinct products bought in the last 12 months."
|
| 227 |
+
},
|
| 228 |
+
{
|
| 229 |
+
"key": "top_sku",
|
| 230 |
+
"label": "Top SKU",
|
| 231 |
+
"type": "text",
|
| 232 |
+
"source": "odoo",
|
| 233 |
+
"default": false,
|
| 234 |
+
"description": "The product this customer spent the most on in the last 12 months."
|
| 235 |
+
},
|
| 236 |
+
{
|
| 237 |
+
"key": "days_since",
|
| 238 |
+
"label": "Days since order",
|
| 239 |
+
"type": "int",
|
| 240 |
+
"source": "odoo",
|
| 241 |
+
"default": false,
|
| 242 |
+
"description": "Days since the last confirmed order."
|
| 243 |
+
},
|
| 244 |
+
{
|
| 245 |
+
"key": "typical_gap_days",
|
| 246 |
+
"label": "Typical gap days",
|
| 247 |
+
"type": "int",
|
| 248 |
+
"source": "odoo",
|
| 249 |
+
"default": false,
|
| 250 |
+
"description": "Days this customer usually goes between orders, from their own history."
|
| 251 |
+
},
|
| 252 |
+
{
|
| 253 |
+
"key": "notes",
|
| 254 |
+
"label": "Notes",
|
| 255 |
+
"type": "text",
|
| 256 |
+
"source": "overlay",
|
| 257 |
+
"default": false,
|
| 258 |
+
"description": "Your notes on this customer. Saved in this app only, visible only to you."
|
| 259 |
+
}
|
| 260 |
+
],
|
| 261 |
+
"rows": [
|
| 262 |
+
{
|
| 263 |
+
"pid": 101,
|
| 264 |
+
"customer": "Poppy Flowers",
|
| 265 |
+
"status": "New",
|
| 266 |
+
"agent": "Naomi Linnell Rivera",
|
| 267 |
+
"city": "Charlottesville",
|
| 268 |
+
"state": "Virginia (US)",
|
| 269 |
+
"last_order": "2026-07-21",
|
| 270 |
+
"est_missed": 0,
|
| 271 |
+
"notes": "",
|
| 272 |
+
"country": "United States",
|
| 273 |
+
"zip": "02720",
|
| 274 |
+
"payment_terms": "30 Days",
|
| 275 |
+
"pricelist": "Fisch 1 (USD)",
|
| 276 |
+
"tags": "Royal",
|
| 277 |
+
"customer_since": "2023-01-10",
|
| 278 |
+
"salesperson": "Jessica",
|
| 279 |
+
"ar_open": 0,
|
| 280 |
+
"ar_overdue": 0,
|
| 281 |
+
"ar_exposure": 0,
|
| 282 |
+
"top_category": "Styrofoam",
|
| 283 |
+
"top_category_pct": 0.47,
|
| 284 |
+
"sku_count": 93,
|
| 285 |
+
"top_sku": "AQUAFOAM FLORAL FOAM BRICK | 48-Piece per Pack",
|
| 286 |
+
"days_to_pay": 34,
|
| 287 |
+
"_created": "2023-01-15 09:10:00",
|
| 288 |
+
"lat": 25.7617,
|
| 289 |
+
"lon": -80.1918,
|
| 290 |
+
"odoo_status": "Archived",
|
| 291 |
+
"dba": "Royal"
|
| 292 |
+
},
|
| 293 |
+
{
|
| 294 |
+
"pid": 102,
|
| 295 |
+
"customer": "Meadow & Vine Wholesale",
|
| 296 |
+
"status": "Growing",
|
| 297 |
+
"agent": "Carla Jimenez",
|
| 298 |
+
"city": "Portland",
|
| 299 |
+
"state": "Oregon (US)",
|
| 300 |
+
"last_order": "2026-07-19",
|
| 301 |
+
"est_missed": 0,
|
| 302 |
+
"notes": "Expanding to a second storefront.",
|
| 303 |
+
"country": "United States",
|
| 304 |
+
"zip": "77041",
|
| 305 |
+
"payment_terms": "Immediate Payment",
|
| 306 |
+
"pricelist": "Royal 1 (USD)",
|
| 307 |
+
"tags": "Royal, Key account",
|
| 308 |
+
"customer_since": "2024-02-11",
|
| 309 |
+
"salesperson": "Naomi",
|
| 310 |
+
"ar_open": 1240.5,
|
| 311 |
+
"ar_overdue": 0,
|
| 312 |
+
"ar_exposure": 1740.5,
|
| 313 |
+
"top_category": "Ribbon",
|
| 314 |
+
"top_category_pct": 0.95,
|
| 315 |
+
"sku_count": 4,
|
| 316 |
+
"top_sku": "2\" X 24\" X 36\" GREEN STYROFOAM BOARD",
|
| 317 |
+
"days_to_pay": null,
|
| 318 |
+
"_created": "2023-02-15 09:11:00",
|
| 319 |
+
"lat": 27.9506,
|
| 320 |
+
"lon": -82.4572,
|
| 321 |
+
"odoo_status": "Active",
|
| 322 |
+
"dba": "Fisch"
|
| 323 |
+
},
|
| 324 |
+
{
|
| 325 |
+
"pid": 103,
|
| 326 |
+
"customer": "Bluestem Floral Supply",
|
| 327 |
+
"status": "Growing",
|
| 328 |
+
"agent": "Naomi Linnell Rivera",
|
| 329 |
+
"city": "Kansas City",
|
| 330 |
+
"state": "Missouri (US)",
|
| 331 |
+
"last_order": "2026-07-17",
|
| 332 |
+
"est_missed": 0,
|
| 333 |
+
"notes": "",
|
| 334 |
+
"country": "United States",
|
| 335 |
+
"zip": "11219",
|
| 336 |
+
"payment_terms": "60 Days",
|
| 337 |
+
"pricelist": "Royal 1 (USD)",
|
| 338 |
+
"tags": "Fisch",
|
| 339 |
+
"customer_since": "2025-03-12",
|
| 340 |
+
"salesperson": "Karen",
|
| 341 |
+
"ar_open": 0,
|
| 342 |
+
"ar_overdue": 5120.25,
|
| 343 |
+
"ar_exposure": 5120.25,
|
| 344 |
+
"top_category": "Foams & Finishes",
|
| 345 |
+
"top_category_pct": 0.31,
|
| 346 |
+
"sku_count": 27,
|
| 347 |
+
"top_sku": "SATIN RIBBON 2IN",
|
| 348 |
+
"days_to_pay": 61,
|
| 349 |
+
"_created": "2023-03-15 09:12:00",
|
| 350 |
+
"lat": 28.5384,
|
| 351 |
+
"lon": -81.3789,
|
| 352 |
+
"odoo_status": "Active",
|
| 353 |
+
"dba": "Both"
|
| 354 |
+
},
|
| 355 |
+
{
|
| 356 |
+
"pid": 104,
|
| 357 |
+
"customer": "Camellia Row Florist",
|
| 358 |
+
"status": "Declining",
|
| 359 |
+
"agent": "Devon Marsh",
|
| 360 |
+
"city": "Savannah",
|
| 361 |
+
"state": "Georgia (US)",
|
| 362 |
+
"last_order": "2026-05-30",
|
| 363 |
+
"est_missed": 41200,
|
| 364 |
+
"notes": "Switched some volume to a local grower.",
|
| 365 |
+
"country": "United States",
|
| 366 |
+
"zip": "07649",
|
| 367 |
+
"payment_terms": "30 Days",
|
| 368 |
+
"pricelist": "Fisch 1 (USD)",
|
| 369 |
+
"tags": "(none)",
|
| 370 |
+
"customer_since": "2026-04-13",
|
| 371 |
+
"salesperson": "(none)",
|
| 372 |
+
"ar_open": 8300,
|
| 373 |
+
"ar_overdue": 940,
|
| 374 |
+
"ar_exposure": 11440,
|
| 375 |
+
"top_category": "All",
|
| 376 |
+
"top_category_pct": 1.0,
|
| 377 |
+
"sku_count": 1,
|
| 378 |
+
"top_sku": "(none)",
|
| 379 |
+
"days_to_pay": 12,
|
| 380 |
+
"_created": "2023-04-15 09:13:00",
|
| 381 |
+
"lat": 30.3322,
|
| 382 |
+
"lon": -81.6557,
|
| 383 |
+
"odoo_status": "Active",
|
| 384 |
+
"dba": "Royal"
|
| 385 |
+
},
|
| 386 |
+
{
|
| 387 |
+
"pid": 105,
|
| 388 |
+
"customer": "Harborlight Wholesale Blooms",
|
| 389 |
+
"status": "Growing",
|
| 390 |
+
"agent": "Carla Jimenez",
|
| 391 |
+
"city": "Seattle",
|
| 392 |
+
"state": "Washington (US)",
|
| 393 |
+
"last_order": "2026-07-22",
|
| 394 |
+
"est_missed": 0,
|
| 395 |
+
"notes": "Top-10 account.",
|
| 396 |
+
"country": "United States",
|
| 397 |
+
"zip": "33125",
|
| 398 |
+
"payment_terms": "Immediate Payment",
|
| 399 |
+
"pricelist": "Royal 1 (USD)",
|
| 400 |
+
"tags": "Royal",
|
| 401 |
+
"customer_since": "2023-05-14",
|
| 402 |
+
"salesperson": "Jessica",
|
| 403 |
+
"ar_open": 0,
|
| 404 |
+
"ar_overdue": 0,
|
| 405 |
+
"ar_exposure": 0,
|
| 406 |
+
"top_category": "Styrofoam",
|
| 407 |
+
"top_category_pct": 0.47,
|
| 408 |
+
"sku_count": 93,
|
| 409 |
+
"top_sku": "AQUAFOAM FLORAL FOAM BRICK | 48-Piece per Pack",
|
| 410 |
+
"days_to_pay": 34,
|
| 411 |
+
"_created": "2023-05-15 09:14:00",
|
| 412 |
+
"lat": 26.1224,
|
| 413 |
+
"lon": -80.1373,
|
| 414 |
+
"odoo_status": "Active",
|
| 415 |
+
"dba": ""
|
| 416 |
+
},
|
| 417 |
+
{
|
| 418 |
+
"pid": 106,
|
| 419 |
+
"customer": "Dogwood & Fern Co.",
|
| 420 |
+
"status": "Dormant",
|
| 421 |
+
"agent": "Devon Marsh",
|
| 422 |
+
"city": "Asheville",
|
| 423 |
+
"state": "North Carolina (US)",
|
| 424 |
+
"last_order": "2026-02-11",
|
| 425 |
+
"est_missed": 52400,
|
| 426 |
+
"notes": "No spring order this year.",
|
| 427 |
+
"country": "United States",
|
| 428 |
+
"zip": "90210",
|
| 429 |
+
"payment_terms": "60 Days",
|
| 430 |
+
"pricelist": "Royal 1 (USD)",
|
| 431 |
+
"tags": "Royal, Key account",
|
| 432 |
+
"customer_since": "2024-06-15",
|
| 433 |
+
"salesperson": "Naomi",
|
| 434 |
+
"ar_open": 1240.5,
|
| 435 |
+
"ar_overdue": 0,
|
| 436 |
+
"ar_exposure": 1740.5,
|
| 437 |
+
"top_category": "Ribbon",
|
| 438 |
+
"top_category_pct": 0.95,
|
| 439 |
+
"sku_count": 4,
|
| 440 |
+
"top_sku": "2\" X 24\" X 36\" GREEN STYROFOAM BOARD",
|
| 441 |
+
"days_to_pay": null,
|
| 442 |
+
"_created": "2023-06-15 09:15:00",
|
| 443 |
+
"lat": 27.3364,
|
| 444 |
+
"lon": -82.5307,
|
| 445 |
+
"odoo_status": "Active",
|
| 446 |
+
"dba": "Fisch"
|
| 447 |
+
},
|
| 448 |
+
{
|
| 449 |
+
"pid": 107,
|
| 450 |
+
"customer": "Verbena Market Florals",
|
| 451 |
+
"status": "Lost",
|
| 452 |
+
"agent": "Naomi Linnell Rivera",
|
| 453 |
+
"city": "Austin",
|
| 454 |
+
"state": "Texas (US)",
|
| 455 |
+
"last_order": "2025-11-04",
|
| 456 |
+
"est_missed": 78300,
|
| 457 |
+
"notes": "Went with a competitor on freight terms.",
|
| 458 |
+
"country": "United States",
|
| 459 |
+
"zip": "08701",
|
| 460 |
+
"payment_terms": "30 Days",
|
| 461 |
+
"pricelist": "Fisch 1 (USD)",
|
| 462 |
+
"tags": "Fisch",
|
| 463 |
+
"customer_since": "2025-07-16",
|
| 464 |
+
"salesperson": "Karen",
|
| 465 |
+
"ar_open": 0,
|
| 466 |
+
"ar_overdue": 5120.25,
|
| 467 |
+
"ar_exposure": 5120.25,
|
| 468 |
+
"top_category": "Foams & Finishes",
|
| 469 |
+
"top_category_pct": 0.31,
|
| 470 |
+
"sku_count": 27,
|
| 471 |
+
"top_sku": "SATIN RIBBON 2IN",
|
| 472 |
+
"days_to_pay": 61,
|
| 473 |
+
"_created": "2023-07-15 09:16:00",
|
| 474 |
+
"lat": null,
|
| 475 |
+
"lon": null,
|
| 476 |
+
"odoo_status": "Active",
|
| 477 |
+
"dba": "Both"
|
| 478 |
+
},
|
| 479 |
+
{
|
| 480 |
+
"pid": 108,
|
| 481 |
+
"customer": "Larkspur Lane Supply",
|
| 482 |
+
"status": "New",
|
| 483 |
+
"agent": "Carla Jimenez",
|
| 484 |
+
"city": "Denver",
|
| 485 |
+
"state": "Colorado (US)",
|
| 486 |
+
"last_order": "2026-07-14",
|
| 487 |
+
"est_missed": 0,
|
| 488 |
+
"notes": "First order in April.",
|
| 489 |
+
"country": "United States",
|
| 490 |
+
"zip": "60614",
|
| 491 |
+
"payment_terms": "Immediate Payment",
|
| 492 |
+
"pricelist": "Royal 1 (USD)",
|
| 493 |
+
"tags": "(none)",
|
| 494 |
+
"customer_since": "2026-08-17",
|
| 495 |
+
"salesperson": "(none)",
|
| 496 |
+
"ar_open": 8300,
|
| 497 |
+
"ar_overdue": 940,
|
| 498 |
+
"ar_exposure": 11440,
|
| 499 |
+
"top_category": "All",
|
| 500 |
+
"top_category_pct": 1.0,
|
| 501 |
+
"sku_count": 1,
|
| 502 |
+
"top_sku": "(none)",
|
| 503 |
+
"days_to_pay": 12,
|
| 504 |
+
"_created": "2023-08-15 09:17:00",
|
| 505 |
+
"lat": 33.749,
|
| 506 |
+
"lon": -84.388,
|
| 507 |
+
"odoo_status": "Active",
|
| 508 |
+
"dba": "Royal"
|
| 509 |
+
}
|
| 510 |
+
]
|
| 511 |
+
}
|
web/public/sample_customers.json
CHANGED
|
@@ -1,479 +1,511 @@
|
|
| 1 |
-
{
|
| 2 |
-
"fields": [
|
| 3 |
-
{
|
| 4 |
-
"key": "customer",
|
| 5 |
-
"label": "Customer",
|
| 6 |
-
"type": "text",
|
| 7 |
-
"source": "odoo",
|
| 8 |
-
"pinned": true,
|
| 9 |
-
"default": true,
|
| 10 |
-
"description": "The customer's name in Odoo. One row per customer who ordered in the last 24 months."
|
| 11 |
-
},
|
| 12 |
-
{
|
| 13 |
-
"key": "odoo_status",
|
| 14 |
-
"label": "Odoo record",
|
| 15 |
-
"type": "status",
|
| 16 |
-
"source": "odoo",
|
| 17 |
-
"default": false,
|
| 18 |
-
"description": "Whether this customer still exists in Odoo. Archived means deleted there."
|
| 19 |
-
},
|
| 20 |
-
{
|
| 21 |
-
"key": "agent",
|
| 22 |
-
"label": "Agent",
|
| 23 |
-
"type": "text",
|
| 24 |
-
"source": "odoo",
|
| 25 |
-
"default": true,
|
| 26 |
-
"description": "The sales agent who owns this account."
|
| 27 |
-
},
|
| 28 |
-
{
|
| 29 |
-
"key": "dba",
|
| 30 |
-
"label": "DBA",
|
| 31 |
-
"type": "select",
|
| 32 |
-
"source": "odoo",
|
| 33 |
-
"default": false,
|
| 34 |
-
"options": [
|
| 35 |
-
"Fisch",
|
| 36 |
-
"Royal",
|
| 37 |
-
"Both"
|
| 38 |
-
],
|
| 39 |
-
"description": "The brand this customer buys from - Fisch, Royal, or both. Amazon-channel orders are not a DBA."
|
| 40 |
-
},
|
| 41 |
-
{
|
| 42 |
-
"key": "salesperson",
|
| 43 |
-
"label": "Salesperson",
|
| 44 |
-
"type": "text",
|
| 45 |
-
"source": "odoo",
|
| 46 |
-
"default": false,
|
| 47 |
-
"description": "Who keyed in most of this customer's orders
|
| 48 |
-
},
|
| 49 |
-
{
|
| 50 |
-
"key": "city",
|
| 51 |
-
"label": "City",
|
| 52 |
-
"type": "text",
|
| 53 |
-
"source": "odoo",
|
| 54 |
-
"default": true,
|
| 55 |
-
"description": "City on the customer's Odoo address."
|
| 56 |
-
},
|
| 57 |
-
{
|
| 58 |
-
"key": "state",
|
| 59 |
-
"label": "State",
|
| 60 |
-
"type": "text",
|
| 61 |
-
"source": "odoo",
|
| 62 |
-
"default": true,
|
| 63 |
-
"description": "State or province on the customer's Odoo address."
|
| 64 |
-
},
|
| 65 |
-
{
|
| 66 |
-
"key": "country",
|
| 67 |
-
"label": "Country",
|
| 68 |
-
"type": "text",
|
| 69 |
-
"source": "odoo",
|
| 70 |
-
"default": false,
|
| 71 |
-
"description": "Country on the customer's Odoo address."
|
| 72 |
-
},
|
| 73 |
-
{
|
| 74 |
-
"key": "zip",
|
| 75 |
-
"label": "ZIP",
|
| 76 |
-
"type": "text",
|
| 77 |
-
"source": "odoo",
|
| 78 |
-
"default": false,
|
| 79 |
-
"description": "Postal code on the customer's Odoo address."
|
| 80 |
-
},
|
| 81 |
-
{
|
| 82 |
-
"key": "customer_since",
|
| 83 |
-
"label": "Customer since",
|
| 84 |
-
"type": "date",
|
| 85 |
-
"source": "odoo",
|
| 86 |
-
"default": false,
|
| 87 |
-
"description": "When this customer was first set up in Odoo."
|
| 88 |
-
},
|
| 89 |
-
{
|
| 90 |
-
"key": "tags",
|
| 91 |
-
"label": "Tags",
|
| 92 |
-
"type": "text",
|
| 93 |
-
"source": "odoo",
|
| 94 |
-
"default": false,
|
| 95 |
-
"description": "Odoo labels on this customer, comma-separated."
|
| 96 |
-
},
|
| 97 |
-
{
|
| 98 |
-
"key": "pricelist",
|
| 99 |
-
"label": "Price list",
|
| 100 |
-
"type": "text",
|
| 101 |
-
"source": "odoo",
|
| 102 |
-
"default": false,
|
| 103 |
-
"description": "The price list this customer buys on."
|
| 104 |
-
},
|
| 105 |
-
{
|
| 106 |
-
"key": "payment_terms",
|
| 107 |
-
"label": "Payment terms",
|
| 108 |
-
"type": "text",
|
| 109 |
-
"source": "odoo",
|
| 110 |
-
"default": false,
|
| 111 |
-
"description": "Payment terms on this customer's account
|
| 112 |
-
},
|
| 113 |
-
{
|
| 114 |
-
"key": "last_order",
|
| 115 |
-
"label": "Last order",
|
| 116 |
-
"type": "date",
|
| 117 |
-
"source": "odoo",
|
| 118 |
-
"default": true,
|
| 119 |
-
"description": "Date of the most recent confirmed order."
|
| 120 |
-
},
|
| 121 |
-
{
|
| 122 |
-
"key": "overdue_days",
|
| 123 |
-
"label": "Overdue days",
|
| 124 |
-
"type": "int",
|
| 125 |
-
"source": "odoo",
|
| 126 |
-
"default": true,
|
| 127 |
-
"description": "How many days late this customer is running against their own usual ordering rhythm."
|
| 128 |
-
},
|
| 129 |
-
{
|
| 130 |
-
"_note": "filterable:false
|
| 131 |
-
"key": "est_missed",
|
| 132 |
-
"label": "Est. missed $",
|
| 133 |
-
"type": "currency",
|
| 134 |
-
"source": "odoo",
|
| 135 |
-
"default": true,
|
| 136 |
-
"agg": "sum",
|
| 137 |
-
"filterable": false,
|
| 138 |
-
"description": "Estimated sales missed while quiet: missed orders (capped at 3) times average order value. An estimate, not money owed."
|
| 139 |
-
},
|
| 140 |
-
{
|
| 141 |
-
"key": "ar_open",
|
| 142 |
-
"label": "AR open $",
|
| 143 |
-
"type": "currency",
|
| 144 |
-
"source": "odoo",
|
| 145 |
-
"default": false,
|
| 146 |
-
"description": "Invoiced money owed, not yet overdue."
|
| 147 |
-
},
|
| 148 |
-
{
|
| 149 |
-
"key": "ar_overdue",
|
| 150 |
-
"label": "AR overdue $",
|
| 151 |
-
"type": "currency",
|
| 152 |
-
"source": "odoo",
|
| 153 |
-
"default": false,
|
| 154 |
-
"description": "Invoiced money past due
|
| 155 |
-
},
|
| 156 |
-
{
|
| 157 |
-
"key": "ar_exposure",
|
| 158 |
-
"label": "Credit exposure $",
|
| 159 |
-
"type": "currency",
|
| 160 |
-
"source": "odoo",
|
| 161 |
-
"default": false,
|
| 162 |
-
"description": "The most you could be out if they stopped paying today: open, overdue, draft and not-yet-invoiced."
|
| 163 |
-
},
|
| 164 |
-
{
|
| 165 |
-
"key": "
|
| 166 |
-
"label": "
|
| 167 |
-
"type": "
|
| 168 |
-
"source": "odoo",
|
| 169 |
-
"default": false,
|
| 170 |
-
"description": "
|
| 171 |
-
},
|
| 172 |
-
{
|
| 173 |
-
"key": "
|
| 174 |
-
"label": "
|
| 175 |
-
"type": "
|
| 176 |
-
"source": "odoo",
|
| 177 |
-
"default": false,
|
| 178 |
-
"description": "
|
| 179 |
-
},
|
| 180 |
-
{
|
| 181 |
-
"key": "
|
| 182 |
-
"label": "
|
| 183 |
-
"type": "
|
| 184 |
-
"source": "odoo",
|
| 185 |
-
"default": false,
|
| 186 |
-
"description": "
|
| 187 |
-
},
|
| 188 |
-
{
|
| 189 |
-
"key": "
|
| 190 |
-
"label": "
|
| 191 |
-
"type": "
|
| 192 |
-
"source": "odoo",
|
| 193 |
-
"default": false,
|
| 194 |
-
"description": "
|
| 195 |
-
},
|
| 196 |
-
{
|
| 197 |
-
"key": "
|
| 198 |
-
"label": "
|
| 199 |
-
"type": "
|
| 200 |
-
"source": "odoo",
|
| 201 |
-
"default": false,
|
| 202 |
-
"description": "
|
| 203 |
-
},
|
| 204 |
-
{
|
| 205 |
-
"key": "
|
| 206 |
-
"label": "
|
| 207 |
-
"type": "
|
| 208 |
-
"source": "odoo",
|
| 209 |
-
"default": false,
|
| 210 |
-
"description": "
|
| 211 |
-
},
|
| 212 |
-
{
|
| 213 |
-
"key": "
|
| 214 |
-
"label": "
|
| 215 |
-
"type": "
|
| 216 |
-
"source": "odoo",
|
| 217 |
-
"default": false,
|
| 218 |
-
"description": "
|
| 219 |
-
},
|
| 220 |
-
{
|
| 221 |
-
"key": "
|
| 222 |
-
"label": "
|
| 223 |
-
"type": "
|
| 224 |
-
"source": "
|
| 225 |
-
"default": false,
|
| 226 |
-
"description": "
|
| 227 |
-
}
|
| 228 |
-
|
| 229 |
-
|
| 230 |
-
|
| 231 |
-
"
|
| 232 |
-
"
|
| 233 |
-
"
|
| 234 |
-
"
|
| 235 |
-
|
| 236 |
-
|
| 237 |
-
"
|
| 238 |
-
"
|
| 239 |
-
"
|
| 240 |
-
"
|
| 241 |
-
"
|
| 242 |
-
"
|
| 243 |
-
|
| 244 |
-
|
| 245 |
-
"
|
| 246 |
-
"
|
| 247 |
-
"
|
| 248 |
-
"
|
| 249 |
-
"
|
| 250 |
-
"
|
| 251 |
-
|
| 252 |
-
|
| 253 |
-
"
|
| 254 |
-
"
|
| 255 |
-
"
|
| 256 |
-
"
|
| 257 |
-
"
|
| 258 |
-
"
|
| 259 |
-
|
| 260 |
-
|
| 261 |
-
|
| 262 |
-
|
| 263 |
-
"
|
| 264 |
-
"
|
| 265 |
-
"
|
| 266 |
-
"
|
| 267 |
-
"
|
| 268 |
-
"
|
| 269 |
-
"
|
| 270 |
-
"
|
| 271 |
-
"
|
| 272 |
-
"
|
| 273 |
-
"
|
| 274 |
-
"
|
| 275 |
-
"
|
| 276 |
-
"
|
| 277 |
-
"
|
| 278 |
-
"
|
| 279 |
-
"
|
| 280 |
-
"
|
| 281 |
-
"
|
| 282 |
-
"
|
| 283 |
-
"
|
| 284 |
-
"
|
| 285 |
-
"
|
| 286 |
-
"
|
| 287 |
-
"
|
| 288 |
-
"
|
| 289 |
-
"
|
| 290 |
-
"
|
| 291 |
-
|
| 292 |
-
|
| 293 |
-
|
| 294 |
-
"
|
| 295 |
-
"
|
| 296 |
-
"
|
| 297 |
-
"
|
| 298 |
-
"
|
| 299 |
-
"
|
| 300 |
-
"
|
| 301 |
-
"
|
| 302 |
-
"
|
| 303 |
-
"
|
| 304 |
-
"
|
| 305 |
-
"
|
| 306 |
-
"
|
| 307 |
-
"
|
| 308 |
-
"
|
| 309 |
-
"
|
| 310 |
-
"
|
| 311 |
-
"
|
| 312 |
-
"
|
| 313 |
-
"
|
| 314 |
-
"
|
| 315 |
-
"
|
| 316 |
-
"
|
| 317 |
-
"
|
| 318 |
-
"
|
| 319 |
-
"
|
| 320 |
-
"
|
| 321 |
-
"
|
| 322 |
-
|
| 323 |
-
|
| 324 |
-
|
| 325 |
-
"
|
| 326 |
-
"
|
| 327 |
-
"
|
| 328 |
-
"
|
| 329 |
-
"
|
| 330 |
-
"
|
| 331 |
-
"
|
| 332 |
-
"
|
| 333 |
-
"
|
| 334 |
-
"
|
| 335 |
-
"
|
| 336 |
-
"
|
| 337 |
-
"
|
| 338 |
-
"
|
| 339 |
-
"
|
| 340 |
-
"
|
| 341 |
-
"
|
| 342 |
-
"
|
| 343 |
-
"
|
| 344 |
-
"
|
| 345 |
-
"
|
| 346 |
-
"
|
| 347 |
-
"
|
| 348 |
-
"
|
| 349 |
-
"
|
| 350 |
-
"
|
| 351 |
-
"
|
| 352 |
-
"
|
| 353 |
-
|
| 354 |
-
|
| 355 |
-
|
| 356 |
-
"
|
| 357 |
-
"
|
| 358 |
-
"
|
| 359 |
-
"
|
| 360 |
-
"
|
| 361 |
-
"
|
| 362 |
-
"
|
| 363 |
-
"
|
| 364 |
-
"
|
| 365 |
-
"
|
| 366 |
-
"
|
| 367 |
-
"
|
| 368 |
-
"
|
| 369 |
-
"
|
| 370 |
-
"
|
| 371 |
-
"
|
| 372 |
-
"
|
| 373 |
-
"
|
| 374 |
-
"
|
| 375 |
-
"
|
| 376 |
-
"
|
| 377 |
-
"
|
| 378 |
-
"
|
| 379 |
-
"
|
| 380 |
-
"
|
| 381 |
-
"
|
| 382 |
-
"
|
| 383 |
-
"
|
| 384 |
-
|
| 385 |
-
|
| 386 |
-
|
| 387 |
-
"
|
| 388 |
-
"
|
| 389 |
-
"
|
| 390 |
-
"
|
| 391 |
-
"
|
| 392 |
-
"
|
| 393 |
-
"
|
| 394 |
-
"
|
| 395 |
-
"
|
| 396 |
-
"
|
| 397 |
-
"
|
| 398 |
-
"
|
| 399 |
-
"
|
| 400 |
-
"
|
| 401 |
-
"
|
| 402 |
-
"
|
| 403 |
-
"
|
| 404 |
-
"
|
| 405 |
-
"
|
| 406 |
-
"
|
| 407 |
-
"
|
| 408 |
-
"
|
| 409 |
-
"
|
| 410 |
-
"
|
| 411 |
-
"
|
| 412 |
-
"
|
| 413 |
-
"
|
| 414 |
-
"
|
| 415 |
-
|
| 416 |
-
|
| 417 |
-
|
| 418 |
-
"
|
| 419 |
-
"
|
| 420 |
-
"
|
| 421 |
-
"
|
| 422 |
-
"
|
| 423 |
-
"
|
| 424 |
-
"
|
| 425 |
-
"
|
| 426 |
-
"
|
| 427 |
-
"
|
| 428 |
-
"
|
| 429 |
-
"
|
| 430 |
-
"
|
| 431 |
-
"
|
| 432 |
-
"
|
| 433 |
-
"
|
| 434 |
-
"
|
| 435 |
-
"
|
| 436 |
-
"
|
| 437 |
-
"
|
| 438 |
-
"
|
| 439 |
-
"
|
| 440 |
-
"
|
| 441 |
-
"
|
| 442 |
-
"
|
| 443 |
-
"
|
| 444 |
-
"
|
| 445 |
-
"
|
| 446 |
-
|
| 447 |
-
|
| 448 |
-
|
| 449 |
-
"
|
| 450 |
-
"
|
| 451 |
-
"
|
| 452 |
-
"
|
| 453 |
-
"
|
| 454 |
-
"
|
| 455 |
-
"
|
| 456 |
-
"
|
| 457 |
-
"
|
| 458 |
-
"
|
| 459 |
-
"
|
| 460 |
-
"
|
| 461 |
-
"
|
| 462 |
-
"
|
| 463 |
-
"
|
| 464 |
-
"
|
| 465 |
-
"
|
| 466 |
-
"
|
| 467 |
-
"
|
| 468 |
-
"
|
| 469 |
-
"
|
| 470 |
-
"
|
| 471 |
-
"
|
| 472 |
-
"
|
| 473 |
-
"
|
| 474 |
-
"
|
| 475 |
-
"
|
| 476 |
-
"
|
| 477 |
-
|
| 478 |
-
|
| 479 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"fields": [
|
| 3 |
+
{
|
| 4 |
+
"key": "customer",
|
| 5 |
+
"label": "Customer",
|
| 6 |
+
"type": "text",
|
| 7 |
+
"source": "odoo",
|
| 8 |
+
"pinned": true,
|
| 9 |
+
"default": true,
|
| 10 |
+
"description": "The customer's name in Odoo. One row per customer who ordered in the last 24 months."
|
| 11 |
+
},
|
| 12 |
+
{
|
| 13 |
+
"key": "odoo_status",
|
| 14 |
+
"label": "Odoo record",
|
| 15 |
+
"type": "status",
|
| 16 |
+
"source": "odoo",
|
| 17 |
+
"default": false,
|
| 18 |
+
"description": "Whether this customer still exists in Odoo. Archived means deleted there."
|
| 19 |
+
},
|
| 20 |
+
{
|
| 21 |
+
"key": "agent",
|
| 22 |
+
"label": "Agent",
|
| 23 |
+
"type": "text",
|
| 24 |
+
"source": "odoo",
|
| 25 |
+
"default": true,
|
| 26 |
+
"description": "The sales agent who owns this account."
|
| 27 |
+
},
|
| 28 |
+
{
|
| 29 |
+
"key": "dba",
|
| 30 |
+
"label": "DBA",
|
| 31 |
+
"type": "select",
|
| 32 |
+
"source": "odoo",
|
| 33 |
+
"default": false,
|
| 34 |
+
"options": [
|
| 35 |
+
"Fisch",
|
| 36 |
+
"Royal",
|
| 37 |
+
"Both"
|
| 38 |
+
],
|
| 39 |
+
"description": "The brand this customer buys from - Fisch, Royal, or both. Amazon-channel orders are not a DBA."
|
| 40 |
+
},
|
| 41 |
+
{
|
| 42 |
+
"key": "salesperson",
|
| 43 |
+
"label": "Salesperson",
|
| 44 |
+
"type": "text",
|
| 45 |
+
"source": "odoo",
|
| 46 |
+
"default": false,
|
| 47 |
+
"description": "Who keyed in most of this customer's orders \u2014 not the Agent, who owns the account."
|
| 48 |
+
},
|
| 49 |
+
{
|
| 50 |
+
"key": "city",
|
| 51 |
+
"label": "City",
|
| 52 |
+
"type": "text",
|
| 53 |
+
"source": "odoo",
|
| 54 |
+
"default": true,
|
| 55 |
+
"description": "City on the customer's Odoo address."
|
| 56 |
+
},
|
| 57 |
+
{
|
| 58 |
+
"key": "state",
|
| 59 |
+
"label": "State",
|
| 60 |
+
"type": "text",
|
| 61 |
+
"source": "odoo",
|
| 62 |
+
"default": true,
|
| 63 |
+
"description": "State or province on the customer's Odoo address."
|
| 64 |
+
},
|
| 65 |
+
{
|
| 66 |
+
"key": "country",
|
| 67 |
+
"label": "Country",
|
| 68 |
+
"type": "text",
|
| 69 |
+
"source": "odoo",
|
| 70 |
+
"default": false,
|
| 71 |
+
"description": "Country on the customer's Odoo address."
|
| 72 |
+
},
|
| 73 |
+
{
|
| 74 |
+
"key": "zip",
|
| 75 |
+
"label": "ZIP",
|
| 76 |
+
"type": "text",
|
| 77 |
+
"source": "odoo",
|
| 78 |
+
"default": false,
|
| 79 |
+
"description": "Postal code on the customer's Odoo address."
|
| 80 |
+
},
|
| 81 |
+
{
|
| 82 |
+
"key": "customer_since",
|
| 83 |
+
"label": "Customer since",
|
| 84 |
+
"type": "date",
|
| 85 |
+
"source": "odoo",
|
| 86 |
+
"default": false,
|
| 87 |
+
"description": "When this customer was first set up in Odoo."
|
| 88 |
+
},
|
| 89 |
+
{
|
| 90 |
+
"key": "tags",
|
| 91 |
+
"label": "Tags",
|
| 92 |
+
"type": "text",
|
| 93 |
+
"source": "odoo",
|
| 94 |
+
"default": false,
|
| 95 |
+
"description": "Odoo labels on this customer, comma-separated."
|
| 96 |
+
},
|
| 97 |
+
{
|
| 98 |
+
"key": "pricelist",
|
| 99 |
+
"label": "Price list",
|
| 100 |
+
"type": "text",
|
| 101 |
+
"source": "odoo",
|
| 102 |
+
"default": false,
|
| 103 |
+
"description": "The price list this customer buys on."
|
| 104 |
+
},
|
| 105 |
+
{
|
| 106 |
+
"key": "payment_terms",
|
| 107 |
+
"label": "Payment terms",
|
| 108 |
+
"type": "text",
|
| 109 |
+
"source": "odoo",
|
| 110 |
+
"default": false,
|
| 111 |
+
"description": "Payment terms on this customer's account \u2014 Net 30, for example."
|
| 112 |
+
},
|
| 113 |
+
{
|
| 114 |
+
"key": "last_order",
|
| 115 |
+
"label": "Last order",
|
| 116 |
+
"type": "date",
|
| 117 |
+
"source": "odoo",
|
| 118 |
+
"default": true,
|
| 119 |
+
"description": "Date of the most recent confirmed order."
|
| 120 |
+
},
|
| 121 |
+
{
|
| 122 |
+
"key": "overdue_days",
|
| 123 |
+
"label": "Overdue days",
|
| 124 |
+
"type": "int",
|
| 125 |
+
"source": "odoo",
|
| 126 |
+
"default": true,
|
| 127 |
+
"description": "How many days late this customer is running against their own usual ordering rhythm."
|
| 128 |
+
},
|
| 129 |
+
{
|
| 130 |
+
"_note": "filterable:false \u2014 DERIVED ANALYTIC: est_missed is min(cycles missed, 3) x AOV, a score we compute rather than an object the business has, so a condition on it would read as a fact about the customer when it is a fact about our arithmetic. It still displays and still sorts. Until wave 6 this flag also covered the frozen-window presets (revenue_ytd / revenue_ly / orders_24m / aov / yoy_pct); those are now DELETED outright under the owner's no-buildable-presets rule \u2014 see _comment. est_missed itself STAYS: no creatable measure or formula reproduces the cadence model behind it.",
|
| 131 |
+
"key": "est_missed",
|
| 132 |
+
"label": "Est. missed $",
|
| 133 |
+
"type": "currency",
|
| 134 |
+
"source": "odoo",
|
| 135 |
+
"default": true,
|
| 136 |
+
"agg": "sum",
|
| 137 |
+
"filterable": false,
|
| 138 |
+
"description": "Estimated sales missed while quiet: missed orders (capped at 3) times average order value. An estimate, not money owed."
|
| 139 |
+
},
|
| 140 |
+
{
|
| 141 |
+
"key": "ar_open",
|
| 142 |
+
"label": "AR open $",
|
| 143 |
+
"type": "currency",
|
| 144 |
+
"source": "odoo",
|
| 145 |
+
"default": false,
|
| 146 |
+
"description": "Invoiced money owed, not yet overdue."
|
| 147 |
+
},
|
| 148 |
+
{
|
| 149 |
+
"key": "ar_overdue",
|
| 150 |
+
"label": "AR overdue $",
|
| 151 |
+
"type": "currency",
|
| 152 |
+
"source": "odoo",
|
| 153 |
+
"default": false,
|
| 154 |
+
"description": "Invoiced money past due \u2014 same basis as the Collections page."
|
| 155 |
+
},
|
| 156 |
+
{
|
| 157 |
+
"key": "ar_exposure",
|
| 158 |
+
"label": "Credit exposure $",
|
| 159 |
+
"type": "currency",
|
| 160 |
+
"source": "odoo",
|
| 161 |
+
"default": false,
|
| 162 |
+
"description": "The most you could be out if they stopped paying today: open, overdue, draft and not-yet-invoiced."
|
| 163 |
+
},
|
| 164 |
+
{
|
| 165 |
+
"key": "ar_aged_1_30",
|
| 166 |
+
"label": "1-30 days $",
|
| 167 |
+
"type": "currency",
|
| 168 |
+
"source": "odoo",
|
| 169 |
+
"default": false,
|
| 170 |
+
"description": "Overdue between 1 and 30 days. The four aging buckets sum to AR overdue $."
|
| 171 |
+
},
|
| 172 |
+
{
|
| 173 |
+
"key": "ar_aged_31_60",
|
| 174 |
+
"label": "31-60 days $",
|
| 175 |
+
"type": "currency",
|
| 176 |
+
"source": "odoo",
|
| 177 |
+
"default": false,
|
| 178 |
+
"description": "Overdue between 31 and 60 days. The four aging buckets sum to AR overdue $."
|
| 179 |
+
},
|
| 180 |
+
{
|
| 181 |
+
"key": "ar_aged_61_90",
|
| 182 |
+
"label": "61-90 days $",
|
| 183 |
+
"type": "currency",
|
| 184 |
+
"source": "odoo",
|
| 185 |
+
"default": false,
|
| 186 |
+
"description": "Overdue between 61 and 90 days. The four aging buckets sum to AR overdue $."
|
| 187 |
+
},
|
| 188 |
+
{
|
| 189 |
+
"key": "ar_aged_90_plus",
|
| 190 |
+
"label": "90+ days $",
|
| 191 |
+
"type": "currency",
|
| 192 |
+
"source": "odoo",
|
| 193 |
+
"default": false,
|
| 194 |
+
"description": "Overdue by more than 90 days. The four aging buckets sum to AR overdue $."
|
| 195 |
+
},
|
| 196 |
+
{
|
| 197 |
+
"key": "days_to_pay",
|
| 198 |
+
"label": "Days to pay",
|
| 199 |
+
"type": "int",
|
| 200 |
+
"source": "odoo",
|
| 201 |
+
"default": false,
|
| 202 |
+
"description": "Average days to pay an invoice in full. Blank means no fully paid invoice yet."
|
| 203 |
+
},
|
| 204 |
+
{
|
| 205 |
+
"key": "top_category",
|
| 206 |
+
"label": "Top category",
|
| 207 |
+
"type": "text",
|
| 208 |
+
"source": "odoo",
|
| 209 |
+
"default": false,
|
| 210 |
+
"description": "The category this customer spent the most on in the last 12 months."
|
| 211 |
+
},
|
| 212 |
+
{
|
| 213 |
+
"key": "top_category_pct",
|
| 214 |
+
"label": "Top category %",
|
| 215 |
+
"type": "pct",
|
| 216 |
+
"source": "odoo",
|
| 217 |
+
"default": false,
|
| 218 |
+
"description": "Share of last-12-months spend that went to the top category."
|
| 219 |
+
},
|
| 220 |
+
{
|
| 221 |
+
"key": "sku_count",
|
| 222 |
+
"label": "SKUs bought",
|
| 223 |
+
"type": "int",
|
| 224 |
+
"source": "odoo",
|
| 225 |
+
"default": false,
|
| 226 |
+
"description": "Distinct products bought in the last 12 months."
|
| 227 |
+
},
|
| 228 |
+
{
|
| 229 |
+
"key": "top_sku",
|
| 230 |
+
"label": "Top SKU",
|
| 231 |
+
"type": "text",
|
| 232 |
+
"source": "odoo",
|
| 233 |
+
"default": false,
|
| 234 |
+
"description": "The product this customer spent the most on in the last 12 months."
|
| 235 |
+
},
|
| 236 |
+
{
|
| 237 |
+
"key": "days_since",
|
| 238 |
+
"label": "Days since order",
|
| 239 |
+
"type": "int",
|
| 240 |
+
"source": "odoo",
|
| 241 |
+
"default": false,
|
| 242 |
+
"description": "Days since the last confirmed order."
|
| 243 |
+
},
|
| 244 |
+
{
|
| 245 |
+
"key": "typical_gap_days",
|
| 246 |
+
"label": "Typical gap days",
|
| 247 |
+
"type": "int",
|
| 248 |
+
"source": "odoo",
|
| 249 |
+
"default": false,
|
| 250 |
+
"description": "Days this customer usually goes between orders, from their own history."
|
| 251 |
+
},
|
| 252 |
+
{
|
| 253 |
+
"key": "notes",
|
| 254 |
+
"label": "Notes",
|
| 255 |
+
"type": "text",
|
| 256 |
+
"source": "overlay",
|
| 257 |
+
"default": false,
|
| 258 |
+
"description": "Your notes on this customer. Saved in this app only, visible only to you."
|
| 259 |
+
}
|
| 260 |
+
],
|
| 261 |
+
"rows": [
|
| 262 |
+
{
|
| 263 |
+
"pid": 101,
|
| 264 |
+
"customer": "Poppy Flowers",
|
| 265 |
+
"status": "New",
|
| 266 |
+
"agent": "Naomi Linnell Rivera",
|
| 267 |
+
"city": "Charlottesville",
|
| 268 |
+
"state": "Virginia (US)",
|
| 269 |
+
"last_order": "2026-07-21",
|
| 270 |
+
"est_missed": 0,
|
| 271 |
+
"notes": "",
|
| 272 |
+
"country": "United States",
|
| 273 |
+
"zip": "02720",
|
| 274 |
+
"payment_terms": "30 Days",
|
| 275 |
+
"pricelist": "Fisch 1 (USD)",
|
| 276 |
+
"tags": "Royal",
|
| 277 |
+
"customer_since": "2023-01-10",
|
| 278 |
+
"salesperson": "Jessica",
|
| 279 |
+
"ar_open": 0,
|
| 280 |
+
"ar_overdue": 0,
|
| 281 |
+
"ar_exposure": 0,
|
| 282 |
+
"top_category": "Styrofoam",
|
| 283 |
+
"top_category_pct": 0.47,
|
| 284 |
+
"sku_count": 93,
|
| 285 |
+
"top_sku": "AQUAFOAM FLORAL FOAM BRICK | 48-Piece per Pack",
|
| 286 |
+
"days_to_pay": 34,
|
| 287 |
+
"_created": "2023-01-15 09:10:00",
|
| 288 |
+
"lat": 25.7617,
|
| 289 |
+
"lon": -80.1918,
|
| 290 |
+
"odoo_status": "Archived",
|
| 291 |
+
"dba": "Royal"
|
| 292 |
+
},
|
| 293 |
+
{
|
| 294 |
+
"pid": 102,
|
| 295 |
+
"customer": "Meadow & Vine Wholesale",
|
| 296 |
+
"status": "Growing",
|
| 297 |
+
"agent": "Carla Jimenez",
|
| 298 |
+
"city": "Portland",
|
| 299 |
+
"state": "Oregon (US)",
|
| 300 |
+
"last_order": "2026-07-19",
|
| 301 |
+
"est_missed": 0,
|
| 302 |
+
"notes": "Expanding to a second storefront.",
|
| 303 |
+
"country": "United States",
|
| 304 |
+
"zip": "77041",
|
| 305 |
+
"payment_terms": "Immediate Payment",
|
| 306 |
+
"pricelist": "Royal 1 (USD)",
|
| 307 |
+
"tags": "Royal, Key account",
|
| 308 |
+
"customer_since": "2024-02-11",
|
| 309 |
+
"salesperson": "Naomi",
|
| 310 |
+
"ar_open": 1240.5,
|
| 311 |
+
"ar_overdue": 0,
|
| 312 |
+
"ar_exposure": 1740.5,
|
| 313 |
+
"top_category": "Ribbon",
|
| 314 |
+
"top_category_pct": 0.95,
|
| 315 |
+
"sku_count": 4,
|
| 316 |
+
"top_sku": "2\" X 24\" X 36\" GREEN STYROFOAM BOARD",
|
| 317 |
+
"days_to_pay": null,
|
| 318 |
+
"_created": "2023-02-15 09:11:00",
|
| 319 |
+
"lat": 27.9506,
|
| 320 |
+
"lon": -82.4572,
|
| 321 |
+
"odoo_status": "Active",
|
| 322 |
+
"dba": "Fisch"
|
| 323 |
+
},
|
| 324 |
+
{
|
| 325 |
+
"pid": 103,
|
| 326 |
+
"customer": "Bluestem Floral Supply",
|
| 327 |
+
"status": "Growing",
|
| 328 |
+
"agent": "Naomi Linnell Rivera",
|
| 329 |
+
"city": "Kansas City",
|
| 330 |
+
"state": "Missouri (US)",
|
| 331 |
+
"last_order": "2026-07-17",
|
| 332 |
+
"est_missed": 0,
|
| 333 |
+
"notes": "",
|
| 334 |
+
"country": "United States",
|
| 335 |
+
"zip": "11219",
|
| 336 |
+
"payment_terms": "60 Days",
|
| 337 |
+
"pricelist": "Royal 1 (USD)",
|
| 338 |
+
"tags": "Fisch",
|
| 339 |
+
"customer_since": "2025-03-12",
|
| 340 |
+
"salesperson": "Karen",
|
| 341 |
+
"ar_open": 0,
|
| 342 |
+
"ar_overdue": 5120.25,
|
| 343 |
+
"ar_exposure": 5120.25,
|
| 344 |
+
"top_category": "Foams & Finishes",
|
| 345 |
+
"top_category_pct": 0.31,
|
| 346 |
+
"sku_count": 27,
|
| 347 |
+
"top_sku": "SATIN RIBBON 2IN",
|
| 348 |
+
"days_to_pay": 61,
|
| 349 |
+
"_created": "2023-03-15 09:12:00",
|
| 350 |
+
"lat": 28.5384,
|
| 351 |
+
"lon": -81.3789,
|
| 352 |
+
"odoo_status": "Active",
|
| 353 |
+
"dba": "Both"
|
| 354 |
+
},
|
| 355 |
+
{
|
| 356 |
+
"pid": 104,
|
| 357 |
+
"customer": "Camellia Row Florist",
|
| 358 |
+
"status": "Declining",
|
| 359 |
+
"agent": "Devon Marsh",
|
| 360 |
+
"city": "Savannah",
|
| 361 |
+
"state": "Georgia (US)",
|
| 362 |
+
"last_order": "2026-05-30",
|
| 363 |
+
"est_missed": 41200,
|
| 364 |
+
"notes": "Switched some volume to a local grower.",
|
| 365 |
+
"country": "United States",
|
| 366 |
+
"zip": "07649",
|
| 367 |
+
"payment_terms": "30 Days",
|
| 368 |
+
"pricelist": "Fisch 1 (USD)",
|
| 369 |
+
"tags": "(none)",
|
| 370 |
+
"customer_since": "2026-04-13",
|
| 371 |
+
"salesperson": "(none)",
|
| 372 |
+
"ar_open": 8300,
|
| 373 |
+
"ar_overdue": 940,
|
| 374 |
+
"ar_exposure": 11440,
|
| 375 |
+
"top_category": "All",
|
| 376 |
+
"top_category_pct": 1.0,
|
| 377 |
+
"sku_count": 1,
|
| 378 |
+
"top_sku": "(none)",
|
| 379 |
+
"days_to_pay": 12,
|
| 380 |
+
"_created": "2023-04-15 09:13:00",
|
| 381 |
+
"lat": 30.3322,
|
| 382 |
+
"lon": -81.6557,
|
| 383 |
+
"odoo_status": "Active",
|
| 384 |
+
"dba": "Royal"
|
| 385 |
+
},
|
| 386 |
+
{
|
| 387 |
+
"pid": 105,
|
| 388 |
+
"customer": "Harborlight Wholesale Blooms",
|
| 389 |
+
"status": "Growing",
|
| 390 |
+
"agent": "Carla Jimenez",
|
| 391 |
+
"city": "Seattle",
|
| 392 |
+
"state": "Washington (US)",
|
| 393 |
+
"last_order": "2026-07-22",
|
| 394 |
+
"est_missed": 0,
|
| 395 |
+
"notes": "Top-10 account.",
|
| 396 |
+
"country": "United States",
|
| 397 |
+
"zip": "33125",
|
| 398 |
+
"payment_terms": "Immediate Payment",
|
| 399 |
+
"pricelist": "Royal 1 (USD)",
|
| 400 |
+
"tags": "Royal",
|
| 401 |
+
"customer_since": "2023-05-14",
|
| 402 |
+
"salesperson": "Jessica",
|
| 403 |
+
"ar_open": 0,
|
| 404 |
+
"ar_overdue": 0,
|
| 405 |
+
"ar_exposure": 0,
|
| 406 |
+
"top_category": "Styrofoam",
|
| 407 |
+
"top_category_pct": 0.47,
|
| 408 |
+
"sku_count": 93,
|
| 409 |
+
"top_sku": "AQUAFOAM FLORAL FOAM BRICK | 48-Piece per Pack",
|
| 410 |
+
"days_to_pay": 34,
|
| 411 |
+
"_created": "2023-05-15 09:14:00",
|
| 412 |
+
"lat": 26.1224,
|
| 413 |
+
"lon": -80.1373,
|
| 414 |
+
"odoo_status": "Active",
|
| 415 |
+
"dba": ""
|
| 416 |
+
},
|
| 417 |
+
{
|
| 418 |
+
"pid": 106,
|
| 419 |
+
"customer": "Dogwood & Fern Co.",
|
| 420 |
+
"status": "Dormant",
|
| 421 |
+
"agent": "Devon Marsh",
|
| 422 |
+
"city": "Asheville",
|
| 423 |
+
"state": "North Carolina (US)",
|
| 424 |
+
"last_order": "2026-02-11",
|
| 425 |
+
"est_missed": 52400,
|
| 426 |
+
"notes": "No spring order this year.",
|
| 427 |
+
"country": "United States",
|
| 428 |
+
"zip": "90210",
|
| 429 |
+
"payment_terms": "60 Days",
|
| 430 |
+
"pricelist": "Royal 1 (USD)",
|
| 431 |
+
"tags": "Royal, Key account",
|
| 432 |
+
"customer_since": "2024-06-15",
|
| 433 |
+
"salesperson": "Naomi",
|
| 434 |
+
"ar_open": 1240.5,
|
| 435 |
+
"ar_overdue": 0,
|
| 436 |
+
"ar_exposure": 1740.5,
|
| 437 |
+
"top_category": "Ribbon",
|
| 438 |
+
"top_category_pct": 0.95,
|
| 439 |
+
"sku_count": 4,
|
| 440 |
+
"top_sku": "2\" X 24\" X 36\" GREEN STYROFOAM BOARD",
|
| 441 |
+
"days_to_pay": null,
|
| 442 |
+
"_created": "2023-06-15 09:15:00",
|
| 443 |
+
"lat": 27.3364,
|
| 444 |
+
"lon": -82.5307,
|
| 445 |
+
"odoo_status": "Active",
|
| 446 |
+
"dba": "Fisch"
|
| 447 |
+
},
|
| 448 |
+
{
|
| 449 |
+
"pid": 107,
|
| 450 |
+
"customer": "Verbena Market Florals",
|
| 451 |
+
"status": "Lost",
|
| 452 |
+
"agent": "Naomi Linnell Rivera",
|
| 453 |
+
"city": "Austin",
|
| 454 |
+
"state": "Texas (US)",
|
| 455 |
+
"last_order": "2025-11-04",
|
| 456 |
+
"est_missed": 78300,
|
| 457 |
+
"notes": "Went with a competitor on freight terms.",
|
| 458 |
+
"country": "United States",
|
| 459 |
+
"zip": "08701",
|
| 460 |
+
"payment_terms": "30 Days",
|
| 461 |
+
"pricelist": "Fisch 1 (USD)",
|
| 462 |
+
"tags": "Fisch",
|
| 463 |
+
"customer_since": "2025-07-16",
|
| 464 |
+
"salesperson": "Karen",
|
| 465 |
+
"ar_open": 0,
|
| 466 |
+
"ar_overdue": 5120.25,
|
| 467 |
+
"ar_exposure": 5120.25,
|
| 468 |
+
"top_category": "Foams & Finishes",
|
| 469 |
+
"top_category_pct": 0.31,
|
| 470 |
+
"sku_count": 27,
|
| 471 |
+
"top_sku": "SATIN RIBBON 2IN",
|
| 472 |
+
"days_to_pay": 61,
|
| 473 |
+
"_created": "2023-07-15 09:16:00",
|
| 474 |
+
"lat": null,
|
| 475 |
+
"lon": null,
|
| 476 |
+
"odoo_status": "Active",
|
| 477 |
+
"dba": "Both"
|
| 478 |
+
},
|
| 479 |
+
{
|
| 480 |
+
"pid": 108,
|
| 481 |
+
"customer": "Larkspur Lane Supply",
|
| 482 |
+
"status": "New",
|
| 483 |
+
"agent": "Carla Jimenez",
|
| 484 |
+
"city": "Denver",
|
| 485 |
+
"state": "Colorado (US)",
|
| 486 |
+
"last_order": "2026-07-14",
|
| 487 |
+
"est_missed": 0,
|
| 488 |
+
"notes": "First order in April.",
|
| 489 |
+
"country": "United States",
|
| 490 |
+
"zip": "60614",
|
| 491 |
+
"payment_terms": "Immediate Payment",
|
| 492 |
+
"pricelist": "Royal 1 (USD)",
|
| 493 |
+
"tags": "(none)",
|
| 494 |
+
"customer_since": "2026-08-17",
|
| 495 |
+
"salesperson": "(none)",
|
| 496 |
+
"ar_open": 8300,
|
| 497 |
+
"ar_overdue": 940,
|
| 498 |
+
"ar_exposure": 11440,
|
| 499 |
+
"top_category": "All",
|
| 500 |
+
"top_category_pct": 1.0,
|
| 501 |
+
"sku_count": 1,
|
| 502 |
+
"top_sku": "(none)",
|
| 503 |
+
"days_to_pay": 12,
|
| 504 |
+
"_created": "2023-08-15 09:17:00",
|
| 505 |
+
"lat": 33.749,
|
| 506 |
+
"lon": -84.388,
|
| 507 |
+
"odoo_status": "Active",
|
| 508 |
+
"dba": "Royal"
|
| 509 |
+
}
|
| 510 |
+
]
|
| 511 |
+
}
|
web/src/customer-grid/ColumnMenu.tsx
CHANGED
|
@@ -607,13 +607,24 @@ function ScopeControl({
|
|
| 607 |
return (
|
| 608 |
<label>
|
| 609 |
<span>Scope</span>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 610 |
<select
|
| 611 |
className="cg-select cg-scope-select"
|
| 612 |
value={value}
|
| 613 |
aria-label="Field scope"
|
| 614 |
onChange={(event) => onValue(event.target.value as FieldScope)}
|
| 615 |
>
|
| 616 |
-
<option value="cohort"
|
|
|
|
|
|
|
| 617 |
<option value="global">All customer tables</option>
|
| 618 |
</select>
|
| 619 |
</label>
|
|
|
|
| 607 |
return (
|
| 608 |
<label>
|
| 609 |
<span>Scope</span>
|
| 610 |
+
{/* β wave17 R1 β "cohort" scope means *served ONLY on the cohort TABLE*, and that table
|
| 611 |
+
(the retired `#/cohort` surface) no longer exists. A field created with it today would
|
| 612 |
+
be reachable from nowhere. So it is DISABLED for new selection.
|
| 613 |
+
|
| 614 |
+
β It is still RENDERED, and only disabled when it is not the current value. A `<select>`
|
| 615 |
+
whose `value` matches no option renders the FIRST option instead
|
| 616 |
+
([[cg-condition-builder-items]]) β dropping the row outright would silently re-scope
|
| 617 |
+
every existing cohort-scoped field to global on the next save, which is a data change
|
| 618 |
+
nobody asked for wearing a cosmetic edit's clothes. */}
|
| 619 |
<select
|
| 620 |
className="cg-select cg-scope-select"
|
| 621 |
value={value}
|
| 622 |
aria-label="Field scope"
|
| 623 |
onChange={(event) => onValue(event.target.value as FieldScope)}
|
| 624 |
>
|
| 625 |
+
<option value="cohort" disabled={value !== "cohort"}>
|
| 626 |
+
The cohort table only (retired)
|
| 627 |
+
</option>
|
| 628 |
<option value="global">All customer tables</option>
|
| 629 |
</select>
|
| 630 |
</label>
|
web/src/customer-grid/CustomerGrid.tsx
CHANGED
|
@@ -24,8 +24,7 @@ import "@glideapps/glide-data-grid/dist/index.css";
|
|
| 24 |
|
| 25 |
import { useCustomerData } from "./useCustomerData";
|
| 26 |
import type { SurfaceScope } from "./apiBridge";
|
| 27 |
-
import {
|
| 28 |
-
import { activeControlTone, defaultViewConfig, useGridColumns } from "./useGridColumns";
|
| 29 |
import { activeMeasureRuleIds, pendingMeasures, runPipeline, unresolvedConditions, useVisibleRows }
|
| 30 |
from "./useVisibleRows";
|
| 31 |
import type { CohortSets } from "./useVisibleRows";
|
|
@@ -35,7 +34,6 @@ import { useGridSelection } from "./useGridSelection";
|
|
| 35 |
import Toolbar from "./Toolbar";
|
| 36 |
import RecordDetail from "./RecordDetail";
|
| 37 |
import ViewSidebar from "./ViewSidebar";
|
| 38 |
-
import CohortSidebar from "./CohortSidebar";
|
| 39 |
import ColumnMenu from "./ColumnMenu";
|
| 40 |
import type { ColumnMenuState } from "./ColumnMenu";
|
| 41 |
import { HEADER_ICONS } from "./iconShapes";
|
|
@@ -59,7 +57,7 @@ import { cleanCharts } from "../viz/chartData";
|
|
| 59 |
import type { ChartSpec } from "../viz/chartData";
|
| 60 |
import { MapView } from "./MapView";
|
| 61 |
import { lightTheme, STATUS_ROW_THEME, HOVER_ROW_THEME, HOVER_NEUTRAL,
|
| 62 |
-
ACTIVE_ROW_NEUTRAL,
|
| 63 |
import { avatarInitials, formatDisplay, ratingCellRenderer, setAvatarRepaint, userCellRenderer }
|
| 64 |
from "./cells";
|
| 65 |
import { optionTint, pickTint } from "./choiceColors";
|
|
@@ -737,7 +735,11 @@ function CustomerGrid({ scope = "customer" }: { scope?: SurfaceScope } = {}) {
|
|
| 737 |
// cohort with no `pids` is a target you can add to but cannot filter on; the engine treats it
|
| 738 |
// as unanswerable (matches nothing) rather than absent (matches everything).
|
| 739 |
const lists = useMemo(() => payload?.workspace?.lists ?? [], [payload?.workspace?.lists]);
|
| 740 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 741 |
const cohortSets = useMemo(() => {
|
| 742 |
const out: CohortSets = {};
|
| 743 |
for (const l of lists) if (l.pids) out[l.id] = new Set(l.pids);
|
|
@@ -855,9 +857,10 @@ function CustomerGrid({ scope = "customer" }: { scope?: SurfaceScope } = {}) {
|
|
| 855 |
// Item 12 (C-LOCK) β the 14th positional, RECORD's engine input. The lock intersects
|
| 856 |
// FIRST, so everything downstream (conditions, memberPids, the ranking domain) operates
|
| 857 |
// inside the cohort. Absent = today's behaviour exactly.
|
| 858 |
-
//
|
| 859 |
-
//
|
| 860 |
-
|
|
|
|
| 861 |
);
|
| 862 |
|
| 863 |
// Owner item 8 β the DISPLAY cap. The pipeline above still ran over the whole book (counts,
|
|
@@ -973,32 +976,12 @@ function CustomerGrid({ scope = "customer" }: { scope?: SurfaceScope } = {}) {
|
|
| 973 |
// view MATCHES. What is painted is the "Showing first N" bar's job (owner item 8).
|
| 974 |
const recordCount = pidToIndex.size;
|
| 975 |
const shownRecords = displayPidToIndex.size;
|
| 976 |
-
/*
|
| 977 |
-
|
| 978 |
-
|
| 979 |
-
|
| 980 |
-
|
| 981 |
-
|
| 982 |
-
/**
|
| 983 |
-
* The banded rows, as a mask over DISPLAY indices.
|
| 984 |
-
*
|
| 985 |
-
* β Built from the DATA-ROW ORDINAL, not from the display index. Group headers occupy display
|
| 986 |
-
* indices too, so `row % 2` would flip the stripe at every group boundary and put two banded
|
| 987 |
-
* rows side by side β the one artefact that would make this read as a rendering bug rather
|
| 988 |
-
* than as a pattern. A Uint8Array rather than a Set: one byte per row, rebuilt only when the
|
| 989 |
-
* row pipeline re-identifies, and `displayRows` is a few thousand entries at most.
|
| 990 |
-
*/
|
| 991 |
-
const bandMask = useMemo(() => {
|
| 992 |
-
const mask = new Uint8Array(bandTone ? displayRows.length : 0);
|
| 993 |
-
let ordinal = 0;
|
| 994 |
-
if (bandTone)
|
| 995 |
-
for (let i = 0; i < displayRows.length; i += 1) {
|
| 996 |
-
if (displayRows[i].kind !== "data") continue;
|
| 997 |
-
if (ordinal % 2 === 1) mask[i] = 1;
|
| 998 |
-
ordinal += 1;
|
| 999 |
-
}
|
| 1000 |
-
return mask;
|
| 1001 |
-
}, [displayRows, bandTone]);
|
| 1002 |
const getRowThemeOverride = useCallback(
|
| 1003 |
(row: number): Partial<Theme> | undefined => {
|
| 1004 |
const visibleRow = displayRows[row];
|
|
@@ -1018,16 +1001,13 @@ function CustomerGrid({ scope = "customer" }: { scope?: SurfaceScope } = {}) {
|
|
| 1018 |
// accent ring is the active marker and this stays out of the way.
|
| 1019 |
if (!config.colorBy) {
|
| 1020 |
if (row === activeRow) return ACTIVE_ROW_NEUTRAL;
|
| 1021 |
-
|
| 1022 |
-
// colour-by all say something about THIS row; the band says something about the table,
|
| 1023 |
-
// so it yields to every one of them rather than stacking a second wash under a first.
|
| 1024 |
-
return bandTone && bandMask[row] ? CONTROL_BAND_THEME[bandTone] : undefined;
|
| 1025 |
}
|
| 1026 |
return STATUS_ROW_THEME[
|
| 1027 |
String(visibleRow.record[config.colorBy] ?? "").toLowerCase()
|
| 1028 |
];
|
| 1029 |
},
|
| 1030 |
-
[displayRows, config.colorBy, hoverRow, activeRow
|
| 1031 |
);
|
| 1032 |
const onItemHovered = useCallback(
|
| 1033 |
(args: GridMouseEventArgs) => {
|
|
@@ -1852,7 +1832,6 @@ function CustomerGrid({ scope = "customer" }: { scope?: SurfaceScope } = {}) {
|
|
| 1852 |
// refs) lives in folders.ts and is gated by verify_folders.py; this is only the
|
| 1853 |
// wiring: stamps for what this browser just did, and the five events.
|
| 1854 |
const [folderStamps, setFolderStamps] = useState<FolderStamps>({});
|
| 1855 |
-
const [cohortFolderStamps, setCohortFolderStamps] = useState<FolderStamps>({});
|
| 1856 |
/**
|
| 1857 |
* Folders THIS browser just created, held until the host echo returns them.
|
| 1858 |
*
|
|
@@ -1865,7 +1844,6 @@ function CustomerGrid({ scope = "customer" }: { scope?: SurfaceScope } = {}) {
|
|
| 1865 |
* arrays; it now also calls it the way this component does.
|
| 1866 |
*/
|
| 1867 |
const [localFolders, setLocalFolders] = useState<GridFolder[]>([]);
|
| 1868 |
-
const [localCohortFolders, setLocalCohortFolders] = useState<GridFolder[]>([]);
|
| 1869 |
const workspaceFolders = payload?.workspace?.folders;
|
| 1870 |
const folders = useMemo(
|
| 1871 |
() => reconcileFolders(workspaceFolders, localFolders, folderStamps, Date.now()),
|
|
@@ -1886,54 +1864,11 @@ function CustomerGrid({ scope = "customer" }: { scope?: SurfaceScope } = {}) {
|
|
| 1886 |
setFolderStamps((prev) => pruneFolderStamps(patch(prev), Date.now()));
|
| 1887 |
}, []);
|
| 1888 |
|
| 1889 |
-
/
|
| 1890 |
-
|
| 1891 |
-
|
| 1892 |
-
|
| 1893 |
-
|
| 1894 |
-
() =>
|
| 1895 |
-
reconcileFolders(
|
| 1896 |
-
workspaceCohortFolders,
|
| 1897 |
-
localCohortFolders,
|
| 1898 |
-
cohortFolderStamps,
|
| 1899 |
-
Date.now()
|
| 1900 |
-
),
|
| 1901 |
-
[workspaceCohortFolders, localCohortFolders, cohortFolderStamps]
|
| 1902 |
-
);
|
| 1903 |
-
const cohortFolderIdOf = useCallback(
|
| 1904 |
-
(cohortId: string) =>
|
| 1905 |
-
resolveFolderId(
|
| 1906 |
-
cohortId,
|
| 1907 |
-
lists.find((l) => l.id === cohortId)?.folderId ?? null,
|
| 1908 |
-
cohortFolders,
|
| 1909 |
-
cohortFolderStamps,
|
| 1910 |
-
Date.now()
|
| 1911 |
-
),
|
| 1912 |
-
[lists, cohortFolders, cohortFolderStamps]
|
| 1913 |
-
);
|
| 1914 |
-
const stampCohortFolder = useCallback((patch: (prev: FolderStamps) => FolderStamps) => {
|
| 1915 |
-
setCohortFolderStamps((prev) => pruneFolderStamps(patch(prev), Date.now()));
|
| 1916 |
-
}, []);
|
| 1917 |
-
/** C4 - a cohort folder's union is a plain set union of member pids. */
|
| 1918 |
-
const cohortFolderAddToList = useCallback(
|
| 1919 |
-
(folderId: string, cohortId: string, name: string) => {
|
| 1920 |
-
const pids = new Set<number>();
|
| 1921 |
-
for (const l of lists) {
|
| 1922 |
-
if (cohortFolderIdOf(l.id) !== folderId) continue;
|
| 1923 |
-
for (const pid of l.pids ?? []) pids.add(pid);
|
| 1924 |
-
}
|
| 1925 |
-
if (pids.size === 0) return;
|
| 1926 |
-
emitHostEvent({
|
| 1927 |
-
id: eventId("addlist"),
|
| 1928 |
-
type: "add_to_list",
|
| 1929 |
-
viewId: "",
|
| 1930 |
-
cohortId,
|
| 1931 |
-
name,
|
| 1932 |
-
pids: [...pids],
|
| 1933 |
-
});
|
| 1934 |
-
},
|
| 1935 |
-
[lists, cohortFolderIdOf]
|
| 1936 |
-
);
|
| 1937 |
|
| 1938 |
/**
|
| 1939 |
* C4 as AMENDED β the folder-level bulk add's PREVIEW. Deliberately re-runs the
|
|
@@ -2061,26 +1996,9 @@ function CustomerGrid({ scope = "customer" }: { scope?: SurfaceScope } = {}) {
|
|
| 2061 |
[views, fields, computedRows, exportRows]
|
| 2062 |
);
|
| 2063 |
|
| 2064 |
-
/** W2 β the cohort menu's Export: the cohort's saved view (clean default when it
|
| 2065 |
-
* never saved one) over the cohort's FIXED membership. */
|
| 2066 |
-
const exportCohortData = useCallback(
|
| 2067 |
-
(cohortId: string, format: ExportFormat) => {
|
| 2068 |
-
const cohort = lists.find((l) => l.id === cohortId);
|
| 2069 |
-
if (!cohort) return;
|
| 2070 |
-
const saved = views.find((v) => v.id === `cohort:${cohortId}`);
|
| 2071 |
-
const memberSet = new Set(cohort.pids ?? []);
|
| 2072 |
-
exportRows(
|
| 2073 |
-
cohort.name,
|
| 2074 |
-
normalizeConfig(saved?.config, fields),
|
| 2075 |
-
computedRows.filter((r) => memberSet.has(r.pid)),
|
| 2076 |
-
format
|
| 2077 |
-
);
|
| 2078 |
-
},
|
| 2079 |
-
[lists, views, fields, computedRows, exportRows]
|
| 2080 |
-
);
|
| 2081 |
-
|
| 2082 |
/**
|
| 2083 |
-
* The selection bar's "Add to
|
|
|
|
| 2084 |
* Same guarded `add_to_list` event β the host intersects the pids with the caller's pool
|
| 2085 |
* either way, so a hand-picked set and a view's match set ride one validation path.
|
| 2086 |
*/
|
|
@@ -2121,23 +2039,21 @@ function CustomerGrid({ scope = "customer" }: { scope?: SurfaceScope } = {}) {
|
|
| 2121 |
* narrow within the lock, so the two differ and the banner is stating the lock.
|
| 2122 |
*/
|
| 2123 |
/**
|
| 2124 |
-
* β
|
| 2125 |
-
*
|
| 2126 |
-
* β EPHEMERAL BY CONSTRUCTION, and that is the whole design. A projected cohort is not a
|
| 2127 |
-
* saved view, so opening one must not write anything: this is component state, it never
|
| 2128 |
-
* reaches `persistView`, and it dies with the mount. The alternative β routing it through
|
| 2129 |
-
* `onViewCohortLock` like the rail MENU does β would have saved the lock onto whichever view
|
| 2130 |
-
* was open, which is a lock somebody did not ask for on a view they will keep.
|
| 2131 |
*
|
| 2132 |
-
*
|
| 2133 |
-
*
|
|
|
|
|
|
|
|
|
|
| 2134 |
*/
|
| 2135 |
-
const effectiveCohortLock =
|
| 2136 |
-
/*
|
| 2137 |
-
|
| 2138 |
-
|
| 2139 |
-
|
| 2140 |
-
|
|
|
|
| 2141 |
const cohortLockChip = useMemo(() => {
|
| 2142 |
const id = effectiveCohortLock;
|
| 2143 |
if (!id) return undefined;
|
|
@@ -2430,19 +2346,11 @@ function CustomerGrid({ scope = "customer" }: { scope?: SurfaceScope } = {}) {
|
|
| 2430 |
[fieldByKey, measures, saveField]
|
| 2431 |
);
|
| 2432 |
|
| 2433 |
-
/*
|
| 2434 |
-
|
| 2435 |
-
|
| 2436 |
-
|
| 2437 |
-
|
| 2438 |
-
setDetailPid(null);
|
| 2439 |
-
setDisplayCap(DISPLAY_PAGE);
|
| 2440 |
-
setAddCustPicked(new Set());
|
| 2441 |
-
setAddCustQuery("");
|
| 2442 |
-
setAddCustOpen(false);
|
| 2443 |
-
},
|
| 2444 |
-
[clearSelection]
|
| 2445 |
-
);
|
| 2446 |
|
| 2447 |
/**
|
| 2448 |
* Cohort mode β the selection bar's "Remove from cohort" (contract event `cohort_remove`).
|
|
@@ -2462,32 +2370,6 @@ function CustomerGrid({ scope = "customer" }: { scope?: SurfaceScope } = {}) {
|
|
| 2462 |
clearSelection();
|
| 2463 |
}, [activeCohortId, selectedPids, cohortMemberSet, clearSelection]);
|
| 2464 |
|
| 2465 |
-
/** Cohort lifecycle (host contract addition): rename/delete ride the panel's row menu. The
|
| 2466 |
-
* emit itself triggers the host rerun, so the fresh name/list arrives with the next payload
|
| 2467 |
-
* β no local mutation to drift from the store. */
|
| 2468 |
-
const renameCohort = useCallback((id: string, name: string) => {
|
| 2469 |
-
const clean = name.trim();
|
| 2470 |
-
if (!clean) return;
|
| 2471 |
-
emitHostEvent({
|
| 2472 |
-
id: eventId("cohortren"),
|
| 2473 |
-
type: "cohort_rename",
|
| 2474 |
-
cohortId: id,
|
| 2475 |
-
name: clean,
|
| 2476 |
-
});
|
| 2477 |
-
}, []);
|
| 2478 |
-
const deleteCohort = useCallback(
|
| 2479 |
-
(id: string) => {
|
| 2480 |
-
emitHostEvent({ id: eventId("cohortdel"), type: "cohort_delete", cohortId: id });
|
| 2481 |
-
if (activeCohortId === id) {
|
| 2482 |
-
// The keep-valid effect re-anchors to the first remaining cohort when the next
|
| 2483 |
-
// payload arrives; positional state resets now so nothing points into the old scope.
|
| 2484 |
-
clearSelection();
|
| 2485 |
-
setDetailPid(null);
|
| 2486 |
-
setDisplayCap(DISPLAY_PAGE);
|
| 2487 |
-
}
|
| 2488 |
-
},
|
| 2489 |
-
[activeCohortId, clearSelection]
|
| 2490 |
-
);
|
| 2491 |
|
| 2492 |
/** Cohort mode β confirm the "+ Add customers" picker (contract event `cohort_add`). */
|
| 2493 |
const addCustomersToCohort = useCallback(() => {
|
|
@@ -2794,7 +2676,16 @@ function CustomerGrid({ scope = "customer" }: { scope?: SurfaceScope } = {}) {
|
|
| 2794 |
: null;
|
| 2795 |
|
| 2796 |
if (loading || !workspaceReady) {
|
| 2797 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2798 |
}
|
| 2799 |
|
| 2800 |
const activeView = views.find((view) => view.id === activeViewId);
|
|
@@ -2913,102 +2804,17 @@ function CustomerGrid({ scope = "customer" }: { scope?: SurfaceScope } = {}) {
|
|
| 2913 |
data-measure-rules={measureRuleKeys}
|
| 2914 |
data-measure-sets={measureSetKeys}
|
| 2915 |
>
|
| 2916 |
-
{/*
|
| 2917 |
-
|
| 2918 |
-
|
| 2919 |
-
|
| 2920 |
-
|
| 2921 |
-
|
| 2922 |
-
|
| 2923 |
-
|
| 2924 |
-
|
| 2925 |
-
onRename={renameCohort}
|
| 2926 |
-
onDelete={deleteCohort}
|
| 2927 |
-
onExport={serverWindowed ? undefined : exportCohortData}
|
| 2928 |
-
folders={cohortFolders}
|
| 2929 |
-
folderIdOf={cohortFolderIdOf}
|
| 2930 |
-
today={today}
|
| 2931 |
-
onFolderCreate={(name) => {
|
| 2932 |
-
const id = newFolderId();
|
| 2933 |
-
setLocalCohortFolders((prev) => [...prev.slice(-31), { id, name, order: 9_999 }]);
|
| 2934 |
-
stampCohortFolder((p) => ({ ...p, created: { ...p.created, [id]: Date.now() } }));
|
| 2935 |
-
emitHostEvent({
|
| 2936 |
-
id: eventId("foldnew"),
|
| 2937 |
-
type: "folder_create",
|
| 2938 |
-
surface: "cohorts",
|
| 2939 |
-
folderId: id,
|
| 2940 |
-
name,
|
| 2941 |
-
});
|
| 2942 |
-
}}
|
| 2943 |
-
onFolderRename={(folderId, name) => {
|
| 2944 |
-
stampCohortFolder((p) => ({
|
| 2945 |
-
...p,
|
| 2946 |
-
renamed: { ...p.renamed, [folderId]: { at: Date.now(), name } },
|
| 2947 |
-
}));
|
| 2948 |
-
emitHostEvent({
|
| 2949 |
-
id: eventId("foldren"),
|
| 2950 |
-
type: "folder_rename",
|
| 2951 |
-
surface: "cohorts",
|
| 2952 |
-
folderId,
|
| 2953 |
-
name,
|
| 2954 |
-
});
|
| 2955 |
-
}}
|
| 2956 |
-
onFolderDelete={(folderId) => {
|
| 2957 |
-
// Tombstone BEFORE the emit - see the views rail's note.
|
| 2958 |
-
stampCohortFolder((p) => ({
|
| 2959 |
-
...p,
|
| 2960 |
-
deleted: { ...p.deleted, [folderId]: Date.now() },
|
| 2961 |
-
}));
|
| 2962 |
-
emitHostEvent({
|
| 2963 |
-
id: eventId("folddel"),
|
| 2964 |
-
type: "folder_delete",
|
| 2965 |
-
surface: "cohorts",
|
| 2966 |
-
folderId,
|
| 2967 |
-
});
|
| 2968 |
-
}}
|
| 2969 |
-
onFolderDuplicate={(folderId) => {
|
| 2970 |
-
const newId = newFolderId();
|
| 2971 |
-
const src = cohortFolders.find((f) => f.id === folderId);
|
| 2972 |
-
setLocalCohortFolders((prev) => [
|
| 2973 |
-
...prev.slice(-31),
|
| 2974 |
-
{ id: newId, name: `${src?.name ?? "Folder"} copy`, order: 9_999 },
|
| 2975 |
-
]);
|
| 2976 |
-
stampCohortFolder((p) => ({
|
| 2977 |
-
...p,
|
| 2978 |
-
created: { ...p.created, [newId]: Date.now() },
|
| 2979 |
-
}));
|
| 2980 |
-
emitHostEvent({
|
| 2981 |
-
id: eventId("folddup"),
|
| 2982 |
-
type: "folder_duplicate",
|
| 2983 |
-
surface: "cohorts",
|
| 2984 |
-
folderId,
|
| 2985 |
-
newId,
|
| 2986 |
-
});
|
| 2987 |
-
}}
|
| 2988 |
-
onItemMove={(cohortId, folderId) => {
|
| 2989 |
-
stampCohortFolder((p) => ({
|
| 2990 |
-
...p,
|
| 2991 |
-
moved: { ...p.moved, [cohortId]: { at: Date.now(), folderId } },
|
| 2992 |
-
}));
|
| 2993 |
-
emitHostEvent({
|
| 2994 |
-
id: eventId("itemmove"),
|
| 2995 |
-
type: "item_move",
|
| 2996 |
-
surface: "cohorts",
|
| 2997 |
-
itemId: cohortId,
|
| 2998 |
-
folderId,
|
| 2999 |
-
});
|
| 3000 |
-
}}
|
| 3001 |
-
onFolderAddToList={cohortFolderAddToList}
|
| 3002 |
-
/>
|
| 3003 |
-
) : (
|
| 3004 |
-
!hideViews && (
|
| 3005 |
-
<ViewSidebar
|
| 3006 |
// Item 12 (C-LOCK) β the rail's menu is the only emitter of a SAVED `cohortLock`.
|
| 3007 |
onCohortLock={onViewCohortLock}
|
| 3008 |
-
// Item 5 (R10) β the Cohorts section. Selecting a row locks the grid TRANSIENTLY;
|
| 3009 |
-
// clicking the held one releases it.
|
| 3010 |
-
cohorts={cohortRows}
|
| 3011 |
-
onSelectCohort={setRailCohortId}
|
| 3012 |
views={views}
|
| 3013 |
activeViewId={activeViewId}
|
| 3014 |
saveState={saveState}
|
|
@@ -3101,8 +2907,7 @@ function CustomerGrid({ scope = "customer" }: { scope?: SurfaceScope } = {}) {
|
|
| 3101 |
viewer={viewer}
|
| 3102 |
onToggleLock={toggleViewLock}
|
| 3103 |
userOptions={payload?.userOptions}
|
| 3104 |
-
|
| 3105 |
-
)
|
| 3106 |
)}
|
| 3107 |
<main className="cg-main">
|
| 3108 |
<Toolbar
|
|
@@ -3283,6 +3088,9 @@ function CustomerGrid({ scope = "customer" }: { scope?: SurfaceScope } = {}) {
|
|
| 3283 |
mode={displaySpec?.calendarMode ?? "records"}
|
| 3284 |
metrics={displaySpec?.calendarMetrics}
|
| 3285 |
fieldByKey={fieldByKey}
|
|
|
|
|
|
|
|
|
|
| 3286 |
onOpen={setDetailPid}
|
| 3287 |
/>
|
| 3288 |
) : (
|
|
@@ -3334,6 +3142,10 @@ function CustomerGrid({ scope = "customer" }: { scope?: SurfaceScope } = {}) {
|
|
| 3334 |
scope={scope}
|
| 3335 |
pids={timeseriesPids}
|
| 3336 |
fields={fields}
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3337 |
display={displaySpec}
|
| 3338 |
onDisplay={onTimeseriesDisplay}
|
| 3339 |
/>
|
|
@@ -3657,11 +3469,11 @@ function CustomerGrid({ scope = "customer" }: { scope?: SurfaceScope } = {}) {
|
|
| 3657 |
className="cg-pop cg-add-list-pop"
|
| 3658 |
placement="bottom-start"
|
| 3659 |
role="dialog"
|
| 3660 |
-
ariaLabel="Add selected customers to a
|
| 3661 |
onDismiss={() => setSelAddOpen(false)}
|
| 3662 |
dataKind="selection-add-to-list"
|
| 3663 |
>
|
| 3664 |
-
<div className="cg-pop-title">Add to
|
| 3665 |
<div className="cg-pop-note">
|
| 3666 |
Adds the {selectedPids.size.toLocaleString()} checked customer
|
| 3667 |
{selectedPids.size === 1 ? "" : "s"}. The cohort stays fixed as the data changes.
|
|
@@ -3677,7 +3489,7 @@ function CustomerGrid({ scope = "customer" }: { scope?: SurfaceScope } = {}) {
|
|
| 3677 |
</button>
|
| 3678 |
))}
|
| 3679 |
<div className="cg-view-create">
|
| 3680 |
-
<label htmlFor="cg-sel-new-list">
|
| 3681 |
<input
|
| 3682 |
id="cg-sel-new-list"
|
| 3683 |
className="cg-input"
|
|
@@ -3715,14 +3527,14 @@ function CustomerGrid({ scope = "customer" }: { scope?: SurfaceScope } = {}) {
|
|
| 3715 |
className="cg-pop cg-addcust-pop"
|
| 3716 |
placement="bottom-start"
|
| 3717 |
role="dialog"
|
| 3718 |
-
ariaLabel="Add customers to this
|
| 3719 |
onDismiss={() => setAddCustOpen(false)}
|
| 3720 |
dataKind="cohort-add-customers"
|
| 3721 |
>
|
| 3722 |
<div className="cg-pop-title">Add customers</div>
|
| 3723 |
<div className="cg-pop-note">
|
| 3724 |
Search your customer pool and tick who to add to{" "}
|
| 3725 |
-
<strong>{activeCohort?.name ?? "this
|
| 3726 |
</div>
|
| 3727 |
<input
|
| 3728 |
type="text"
|
|
@@ -3754,8 +3566,8 @@ function CustomerGrid({ scope = "customer" }: { scope?: SurfaceScope } = {}) {
|
|
| 3754 |
{addCandidates.length === 0 && (
|
| 3755 |
<div className="cg-pop-note">
|
| 3756 |
{addCustQuery.trim()
|
| 3757 |
-
? "No customer outside this
|
| 3758 |
-
: "Every customer in your pool is already in this
|
| 3759 |
</div>
|
| 3760 |
)}
|
| 3761 |
</div>
|
|
|
|
| 24 |
|
| 25 |
import { useCustomerData } from "./useCustomerData";
|
| 26 |
import type { SurfaceScope } from "./apiBridge";
|
| 27 |
+
import { defaultViewConfig, useGridColumns } from "./useGridColumns";
|
|
|
|
| 28 |
import { activeMeasureRuleIds, pendingMeasures, runPipeline, unresolvedConditions, useVisibleRows }
|
| 29 |
from "./useVisibleRows";
|
| 30 |
import type { CohortSets } from "./useVisibleRows";
|
|
|
|
| 34 |
import Toolbar from "./Toolbar";
|
| 35 |
import RecordDetail from "./RecordDetail";
|
| 36 |
import ViewSidebar from "./ViewSidebar";
|
|
|
|
| 37 |
import ColumnMenu from "./ColumnMenu";
|
| 38 |
import type { ColumnMenuState } from "./ColumnMenu";
|
| 39 |
import { HEADER_ICONS } from "./iconShapes";
|
|
|
|
| 57 |
import type { ChartSpec } from "../viz/chartData";
|
| 58 |
import { MapView } from "./MapView";
|
| 59 |
import { lightTheme, STATUS_ROW_THEME, HOVER_ROW_THEME, HOVER_NEUTRAL,
|
| 60 |
+
ACTIVE_ROW_NEUTRAL, CUSTOM_FIELD_MARK } from "./theme";
|
| 61 |
import { avatarInitials, formatDisplay, ratingCellRenderer, setAvatarRepaint, userCellRenderer }
|
| 62 |
from "./cells";
|
| 63 |
import { optionTint, pickTint } from "./choiceColors";
|
|
|
|
| 735 |
// cohort with no `pids` is a target you can add to but cannot filter on; the engine treats it
|
| 736 |
// as unanswerable (matches nothing) rather than absent (matches everything).
|
| 737 |
const lists = useMemo(() => payload?.workspace?.lists ?? [], [payload?.workspace?.lists]);
|
| 738 |
+
/* wave17 R1 / C-LOCKV β `railCohortId` is gone. It held the TRANSIENT lock the retired
|
| 739 |
+
Cohorts section applied on click: a lock that lived in component state and was never
|
| 740 |
+
persisted. A locked view now carries its own `config.cohortLock`, so SELECTING the view
|
| 741 |
+
is the lock and the saved config is the only source. One mechanism, and it survives a
|
| 742 |
+
reload β which the transient one never did. */
|
| 743 |
const cohortSets = useMemo(() => {
|
| 744 |
const out: CohortSets = {};
|
| 745 |
for (const l of lists) if (l.pids) out[l.id] = new Set(l.pids);
|
|
|
|
| 857 |
// Item 12 (C-LOCK) β the 14th positional, RECORD's engine input. The lock intersects
|
| 858 |
// FIRST, so everything downstream (conditions, memberPids, the ranking domain) operates
|
| 859 |
// inside the cohort. Absent = today's behaviour exactly.
|
| 860 |
+
// wave17 R1 / C-LOCKV: the view's SAVED lock is now the only source. A locked view is a
|
| 861 |
+
// saved view whose `config.cohortLock` names its own id, so opening it IS applying the
|
| 862 |
+
// lock β the wave-15 transient rail pick that used to outrank this is gone with its rail.
|
| 863 |
+
config.cohortLock
|
| 864 |
);
|
| 865 |
|
| 866 |
// Owner item 8 β the DISPLAY cap. The pipeline above still ran over the whole book (counts,
|
|
|
|
| 976 |
// view MATCHES. What is painted is the "Showing first N" bar's job (owner item 8).
|
| 977 |
const recordCount = pidToIndex.size;
|
| 978 |
const shownRecords = displayPidToIndex.size;
|
| 979 |
+
/* wave17 GRID β item 2 / owner R5. The whole-table row band is GONE, and with it the
|
| 980 |
+
`bandTone` / `bandMask` pair that used to sit here: the winning control's tone, and the
|
| 981 |
+
alternating-row mask built from the DATA-ROW ORDINAL so group headers could not flip the
|
| 982 |
+
stripe at a boundary. R5 keeps the involved-COLUMN wash and the header tints β those are
|
| 983 |
+
`useGridColumns.columnTones` + `COLUMN_TONE_THEME` and are untouched. What follows is now
|
| 984 |
+
three row states, not four. */
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 985 |
const getRowThemeOverride = useCallback(
|
| 986 |
(row: number): Partial<Theme> | undefined => {
|
| 987 |
const visibleRow = displayRows[row];
|
|
|
|
| 1001 |
// accent ring is the active marker and this stays out of the way.
|
| 1002 |
if (!config.colorBy) {
|
| 1003 |
if (row === activeRow) return ACTIVE_ROW_NEUTRAL;
|
| 1004 |
+
return undefined;
|
|
|
|
|
|
|
|
|
|
| 1005 |
}
|
| 1006 |
return STATUS_ROW_THEME[
|
| 1007 |
String(visibleRow.record[config.colorBy] ?? "").toLowerCase()
|
| 1008 |
];
|
| 1009 |
},
|
| 1010 |
+
[displayRows, config.colorBy, hoverRow, activeRow]
|
| 1011 |
);
|
| 1012 |
const onItemHovered = useCallback(
|
| 1013 |
(args: GridMouseEventArgs) => {
|
|
|
|
| 1832 |
// refs) lives in folders.ts and is gated by verify_folders.py; this is only the
|
| 1833 |
// wiring: stamps for what this browser just did, and the five events.
|
| 1834 |
const [folderStamps, setFolderStamps] = useState<FolderStamps>({});
|
|
|
|
| 1835 |
/**
|
| 1836 |
* Folders THIS browser just created, held until the host echo returns them.
|
| 1837 |
*
|
|
|
|
| 1844 |
* arrays; it now also calls it the way this component does.
|
| 1845 |
*/
|
| 1846 |
const [localFolders, setLocalFolders] = useState<GridFolder[]>([]);
|
|
|
|
| 1847 |
const workspaceFolders = payload?.workspace?.folders;
|
| 1848 |
const folders = useMemo(
|
| 1849 |
() => reconcileFolders(workspaceFolders, localFolders, folderStamps, Date.now()),
|
|
|
|
| 1864 |
setFolderStamps((prev) => pruneFolderStamps(patch(prev), Date.now()));
|
| 1865 |
}, []);
|
| 1866 |
|
| 1867 |
+
/* wave17 R1 / C-LOCKV β the COHORT FOLDER surface is gone. `folders['cohorts']` merged
|
| 1868 |
+
into `folders['views']` in the host's one-shot migration and `cohortFolders` is no longer
|
| 1869 |
+
emitted at all, so `reconcileFolders` here would have been reconciling an absent list
|
| 1870 |
+
against nothing forever. A locked view files into an ORDINARY folder now, which is what R1
|
| 1871 |
+
means by "native folders". */
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1872 |
|
| 1873 |
/**
|
| 1874 |
* C4 as AMENDED β the folder-level bulk add's PREVIEW. Deliberately re-runs the
|
|
|
|
| 1996 |
[views, fields, computedRows, exportRows]
|
| 1997 |
);
|
| 1998 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1999 |
/**
|
| 2000 |
+
* The selection bar's "Add to locked view": exactly the CHECKED customers, not a view's
|
| 2001 |
+
* matches.
|
| 2002 |
* Same guarded `add_to_list` event β the host intersects the pids with the caller's pool
|
| 2003 |
* either way, so a hand-picked set and a view's match set ride one validation path.
|
| 2004 |
*/
|
|
|
|
| 2039 |
* narrow within the lock, so the two differ and the banner is stating the lock.
|
| 2040 |
*/
|
| 2041 |
/**
|
| 2042 |
+
* β wave17 R1 / C-LOCKV β the lock in force, which is now simply the ACTIVE VIEW's.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2043 |
*
|
| 2044 |
+
* Wave 15 had two sources: a saved `config.cohortLock` and an ephemeral pick from the Cohorts
|
| 2045 |
+
* rail that outranked it while held. The second existed only because a projected cohort was
|
| 2046 |
+
* not a saved view, so opening one could not be allowed to write anything. Under R1 it IS a
|
| 2047 |
+
* saved view, so selecting it applies its own stored lock through the ordinary view path β
|
| 2048 |
+
* one source, and it survives a reload, which the transient one never did.
|
| 2049 |
*/
|
| 2050 |
+
const effectiveCohortLock = config.cohortLock;
|
| 2051 |
+
/* wave17 R1 / C-LOCKV β `cohortRows` and the whole `cohortRail` projection are GONE. They
|
| 2052 |
+
turned `lists` into rail rows for a section that no longer exists; the host projects each
|
| 2053 |
+
cohort into `views` instead, so the rail renders them through the same path as every other
|
| 2054 |
+
view and there is nothing left to project. `lists` still arrives and is still load-bearing
|
| 2055 |
+
β it is the MEMBERSHIP channel that feeds `cohortSets`, which is what the lock resolves
|
| 2056 |
+
against. Its absence would blank every locked view, so it is not "unused". */
|
| 2057 |
const cohortLockChip = useMemo(() => {
|
| 2058 |
const id = effectiveCohortLock;
|
| 2059 |
if (!id) return undefined;
|
|
|
|
| 2346 |
[fieldByKey, measures, saveField]
|
| 2347 |
);
|
| 2348 |
|
| 2349 |
+
/* wave17 R1 β `selectCohort`, `renameCohort`, `deleteCohort` and `exportCohortData` are
|
| 2350 |
+
gone. Every one of them was called ONLY by `CohortSidebar`, and every one now has a
|
| 2351 |
+
better-governed twin: the Views rail renames and deletes a locked view through the
|
| 2352 |
+
ordinary view path, and the HOST routes those to `cohort_mod.rename` / `.delete` on a
|
| 2353 |
+
projected id (C-LOCKV guards b and c). One name, one lifecycle, one set of events. */
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2354 |
|
| 2355 |
/**
|
| 2356 |
* Cohort mode β the selection bar's "Remove from cohort" (contract event `cohort_remove`).
|
|
|
|
| 2370 |
clearSelection();
|
| 2371 |
}, [activeCohortId, selectedPids, cohortMemberSet, clearSelection]);
|
| 2372 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2373 |
|
| 2374 |
/** Cohort mode β confirm the "+ Add customers" picker (contract event `cohort_add`). */
|
| 2375 |
const addCustomersToCohort = useCallback(() => {
|
|
|
|
| 2676 |
: null;
|
| 2677 |
|
| 2678 |
if (loading || !workspaceReady) {
|
| 2679 |
+
/* wave17 GRID β item 3 / owner R6: one small bare rotating icon, NO WORDS. `aria-label`
|
| 2680 |
+
is not a word on screen and stays: `.lp-spin` is an empty span, so without it the wait
|
| 2681 |
+
is announced to a screen reader as nothing at all. (C-SPIN, SHELL defines the class.)
|
| 2682 |
+
`--lg` because this is the case C-SPIN sizes it for β the whole surface is this mark and
|
| 2683 |
+
nothing else, where the 14px version "reads as dust". */
|
| 2684 |
+
return (
|
| 2685 |
+
<div className="cg-loading">
|
| 2686 |
+
<span className="lp-spin lp-spin--lg" role="status" aria-label="Loading" />
|
| 2687 |
+
</div>
|
| 2688 |
+
);
|
| 2689 |
}
|
| 2690 |
|
| 2691 |
const activeView = views.find((view) => view.id === activeViewId);
|
|
|
|
| 2804 |
data-measure-rules={measureRuleKeys}
|
| 2805 |
data-measure-sets={measureSetKeys}
|
| 2806 |
>
|
| 2807 |
+
{/* β wave17 R1 / C-LOCKV β the COHORT SIDEBAR is gone, and with it the last surface that
|
| 2808 |
+
treated a cohort as its own kind of object. `CohortSidebar` was the retired `#/cohort`
|
| 2809 |
+
page's left panel: a second rail, with its own rename, delete, export and folder
|
| 2810 |
+
machinery, over `workspace.lists`. Under R1 a cohort IS a saved view, so the Views rail
|
| 2811 |
+
below renders every one of them and the second rail has nothing to switch between.
|
| 2812 |
+
β `lists` is NOT gone with it β it stays the membership channel that feeds `cohortSets`
|
| 2813 |
+
(C-LOCKV point 2), which is what the lock resolves against. */}
|
| 2814 |
+
{!hideViews && (
|
| 2815 |
+
<ViewSidebar
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2816 |
// Item 12 (C-LOCK) β the rail's menu is the only emitter of a SAVED `cohortLock`.
|
| 2817 |
onCohortLock={onViewCohortLock}
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2818 |
views={views}
|
| 2819 |
activeViewId={activeViewId}
|
| 2820 |
saveState={saveState}
|
|
|
|
| 2907 |
viewer={viewer}
|
| 2908 |
onToggleLock={toggleViewLock}
|
| 2909 |
userOptions={payload?.userOptions}
|
| 2910 |
+
/>
|
|
|
|
| 2911 |
)}
|
| 2912 |
<main className="cg-main">
|
| 2913 |
<Toolbar
|
|
|
|
| 3088 |
mode={displaySpec?.calendarMode ?? "records"}
|
| 3089 |
metrics={displaySpec?.calendarMetrics}
|
| 3090 |
fieldByKey={fieldByKey}
|
| 3091 |
+
/* wave17 item 9 / R4 β the surface the day-grain measure channel is asked
|
| 3092 |
+
about (C-CAL). The server refuses `product` in words. */
|
| 3093 |
+
scope={scope}
|
| 3094 |
onOpen={setDetailPid}
|
| 3095 |
/>
|
| 3096 |
) : (
|
|
|
|
| 3142 |
scope={scope}
|
| 3143 |
pids={timeseriesPids}
|
| 3144 |
fields={fields}
|
| 3145 |
+
/* wave17 item 5 / R9 β the SAME rows `timeseriesPids` is derived from (see its
|
| 3146 |
+
memo), so a snapshot metric and a server metric on one sheet cannot be
|
| 3147 |
+
answering about different populations. */
|
| 3148 |
+
rows={modeDataRows}
|
| 3149 |
display={displaySpec}
|
| 3150 |
onDisplay={onTimeseriesDisplay}
|
| 3151 |
/>
|
|
|
|
| 3469 |
className="cg-pop cg-add-list-pop"
|
| 3470 |
placement="bottom-start"
|
| 3471 |
role="dialog"
|
| 3472 |
+
ariaLabel="Add selected customers to a locked view"
|
| 3473 |
onDismiss={() => setSelAddOpen(false)}
|
| 3474 |
dataKind="selection-add-to-list"
|
| 3475 |
>
|
| 3476 |
+
<div className="cg-pop-title">Add to locked view</div>
|
| 3477 |
<div className="cg-pop-note">
|
| 3478 |
Adds the {selectedPids.size.toLocaleString()} checked customer
|
| 3479 |
{selectedPids.size === 1 ? "" : "s"}. The cohort stays fixed as the data changes.
|
|
|
|
| 3489 |
</button>
|
| 3490 |
))}
|
| 3491 |
<div className="cg-view-create">
|
| 3492 |
+
<label htmlFor="cg-sel-new-list">Lock records into a new view</label>
|
| 3493 |
<input
|
| 3494 |
id="cg-sel-new-list"
|
| 3495 |
className="cg-input"
|
|
|
|
| 3527 |
className="cg-pop cg-addcust-pop"
|
| 3528 |
placement="bottom-start"
|
| 3529 |
role="dialog"
|
| 3530 |
+
ariaLabel="Add customers to this locked view"
|
| 3531 |
onDismiss={() => setAddCustOpen(false)}
|
| 3532 |
dataKind="cohort-add-customers"
|
| 3533 |
>
|
| 3534 |
<div className="cg-pop-title">Add customers</div>
|
| 3535 |
<div className="cg-pop-note">
|
| 3536 |
Search your customer pool and tick who to add to{" "}
|
| 3537 |
+
<strong>{activeCohort?.name ?? "this locked view"}</strong>.
|
| 3538 |
</div>
|
| 3539 |
<input
|
| 3540 |
type="text"
|
|
|
|
| 3566 |
{addCandidates.length === 0 && (
|
| 3567 |
<div className="cg-pop-note">
|
| 3568 |
{addCustQuery.trim()
|
| 3569 |
+
? "No customer outside this locked view matches your search."
|
| 3570 |
+
: "Every customer in your pool is already in this locked view."}
|
| 3571 |
</div>
|
| 3572 |
)}
|
| 3573 |
</div>
|
web/src/customer-grid/RecordComments.tsx
CHANGED
|
@@ -103,7 +103,13 @@ export default function RecordComments({
|
|
| 103 |
<span>{comments.length.toLocaleString()}</span>
|
| 104 |
</div>
|
| 105 |
<div className="cg-record-comment-feed" aria-live="polite">
|
| 106 |
-
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 107 |
{!loading && comments.length === 0 && !error && (
|
| 108 |
<div className="cg-record-comment-state">
|
| 109 |
No comments yet. Add context for the team here.
|
|
|
|
| 103 |
<span>{comments.length.toLocaleString()}</span>
|
| 104 |
</div>
|
| 105 |
<div className="cg-record-comment-feed" aria-live="polite">
|
| 106 |
+
{/* wave17 GRID β item 3 / R6. The feed is `aria-live="polite"`, so the spinner's
|
| 107 |
+
`aria-label` is what it announces; dropping it would make the wait silent. */}
|
| 108 |
+
{loading && (
|
| 109 |
+
<div className="cg-record-comment-state">
|
| 110 |
+
<span className="lp-spin" role="status" aria-label="Loading" />
|
| 111 |
+
</div>
|
| 112 |
+
)}
|
| 113 |
{!loading && comments.length === 0 && !error && (
|
| 114 |
<div className="cg-record-comment-state">
|
| 115 |
No comments yet. Add context for the team here.
|
web/src/customer-grid/RecordDetail.tsx
CHANGED
|
@@ -373,6 +373,9 @@ export default function RecordDetail({
|
|
| 373 |
// β Memoised, not `[Number(record.pid)]` inline: the panel's fetch effect depends on `pids`
|
| 374 |
// by identity, so a fresh array every render would re-fetch on every render β forever.
|
| 375 |
const insightPids = useMemo(() => [Number(record.pid)], [record.pid]);
|
|
|
|
|
|
|
|
|
|
| 376 |
|
| 377 |
/**
|
| 378 |
* The six-dot handle. `draggable` sits HERE and not on the row: a draggable ancestor
|
|
@@ -869,6 +872,9 @@ export default function RecordDetail({
|
|
| 869 |
scope={scope}
|
| 870 |
pids={insightPids}
|
| 871 |
fields={fields}
|
|
|
|
|
|
|
|
|
|
| 872 |
display={tsDisplay}
|
| 873 |
onDisplay={(next) => setTsDisplay((d) => ({ ...d, ...next }))}
|
| 874 |
locked
|
|
|
|
| 373 |
// β Memoised, not `[Number(record.pid)]` inline: the panel's fetch effect depends on `pids`
|
| 374 |
// by identity, so a fresh array every render would re-fetch on every render β forever.
|
| 375 |
const insightPids = useMemo(() => [Number(record.pid)], [record.pid]);
|
| 376 |
+
// wave17 item 5 β the same population as `insightPids`, as VALUES, so a snapshot metric can
|
| 377 |
+
// read this record's own numbers. Memoised for the identical reason the pid list is.
|
| 378 |
+
const insightRows = useMemo(() => [record], [record]);
|
| 379 |
|
| 380 |
/**
|
| 381 |
* The six-dot handle. `draggable` sits HERE and not on the row: a draggable ancestor
|
|
|
|
| 872 |
scope={scope}
|
| 873 |
pids={insightPids}
|
| 874 |
fields={fields}
|
| 875 |
+
/* wave17 item 5 / R9 β the population `insightPids` names, which here is one
|
| 876 |
+
record. sum-vs-avg is then moot: both reduce to this record's own value. */
|
| 877 |
+
rows={insightRows}
|
| 878 |
display={tsDisplay}
|
| 879 |
onDisplay={(next) => setTsDisplay((d) => ({ ...d, ...next }))}
|
| 880 |
locked
|
web/src/customer-grid/TimeSeriesPanel.tsx
CHANGED
|
@@ -40,12 +40,16 @@ import {
|
|
| 40 |
buildTsCsv,
|
| 41 |
buildTsRequest,
|
| 42 |
buildTsSheet,
|
|
|
|
| 43 |
buildTsTable,
|
|
|
|
| 44 |
formatTsDelta,
|
| 45 |
formatTsValue,
|
| 46 |
resolveTsStyle,
|
| 47 |
sparklinePoints,
|
| 48 |
sparklineSegments,
|
|
|
|
|
|
|
| 49 |
tsRowToChartModel,
|
| 50 |
} from "./timeSeriesData";
|
| 51 |
import type {
|
|
@@ -72,6 +76,7 @@ import type {
|
|
| 72 |
TsDeltaKind,
|
| 73 |
} from "./types";
|
| 74 |
import { FieldSelectButton } from "./FieldSelect";
|
|
|
|
| 75 |
import { toVegaLiteSpec } from "../viz/vega/toVegaLiteSpec";
|
| 76 |
import VegaLiteChart from "../viz/vega/VegaLiteChart";
|
| 77 |
|
|
@@ -89,12 +94,46 @@ const LAST_N_CHOICES = [6, 12, 24, 36];
|
|
| 89 |
const SPARK_W = 72;
|
| 90 |
const SPARK_H = 18;
|
| 91 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 92 |
export interface TimeSeriesPanelProps {
|
| 93 |
scope: SurfaceScope;
|
| 94 |
/** The rows in scope. The server intersects with the caller's book regardless. */
|
| 95 |
pids: number[];
|
| 96 |
-
/** Every field the table has β the panel
|
| 97 |
fields: Field[];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 98 |
/** The view's `config.display`; absent keys fall back to the panel's defaults. */
|
| 99 |
display?: DisplaySpec;
|
| 100 |
/** Persist a display change. Absent = the panel is ephemeral (RECORD's embed, v1). */
|
|
@@ -104,12 +143,30 @@ export interface TimeSeriesPanelProps {
|
|
| 104 |
}
|
| 105 |
|
| 106 |
/**
|
| 107 |
-
*
|
| 108 |
-
*
|
| 109 |
-
*
|
|
|
|
|
|
|
|
|
|
| 110 |
*/
|
| 111 |
-
function
|
| 112 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 113 |
}
|
| 114 |
|
| 115 |
/** A stable-enough id for a new custom row. `TS_ROW_ID_MAX` is 40; this is 12. */
|
|
@@ -124,11 +181,22 @@ export default function TimeSeriesPanel({
|
|
| 124 |
scope,
|
| 125 |
pids,
|
| 126 |
fields,
|
|
|
|
| 127 |
display,
|
| 128 |
onDisplay,
|
| 129 |
locked,
|
| 130 |
}: TimeSeriesPanelProps) {
|
| 131 |
-
const
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 132 |
|
| 133 |
const bucket: TsBucket = (TS_BUCKETS as readonly string[]).includes(display?.tsBucket ?? "")
|
| 134 |
? (display!.tsBucket as TsBucket)
|
|
@@ -144,6 +212,22 @@ export default function TimeSeriesPanel({
|
|
| 144 |
return live.length ? live : eligible.slice(0, 1).map((f) => f.key);
|
| 145 |
}, [display?.tsFields, eligible]);
|
| 146 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 147 |
const customRows = useMemo(() => display?.tsRows ?? [], [display?.tsRows]);
|
| 148 |
const deltaKinds = useMemo(() => display?.tsDeltas ?? [], [display?.tsDeltas]);
|
| 149 |
const styles = display?.tsStyles;
|
|
@@ -164,14 +248,14 @@ export default function TimeSeriesPanel({
|
|
| 164 |
|
| 165 |
useEffect(() => {
|
| 166 |
if (embedded) return;
|
| 167 |
-
if (!
|
| 168 |
setPayload(null);
|
| 169 |
setState("idle");
|
| 170 |
return;
|
| 171 |
}
|
| 172 |
const seq = ++reqRef.current;
|
| 173 |
setState("loading");
|
| 174 |
-
const body = buildTsRequest({ pids, bucket, span: { lastN }, fields:
|
| 175 |
fetchTimeseries(body, scope).then(({ payload: p, status }) => {
|
| 176 |
if (seq !== reqRef.current) return;
|
| 177 |
if (!p) {
|
|
@@ -183,12 +267,36 @@ export default function TimeSeriesPanel({
|
|
| 183 |
setPayload(p);
|
| 184 |
setState("idle");
|
| 185 |
});
|
| 186 |
-
}, [embedded, scope, pids, bucket, lastN,
|
| 187 |
-
|
| 188 |
-
const
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 189 |
const sheet: TsSheet = useMemo(
|
| 190 |
-
() =>
|
| 191 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 192 |
);
|
| 193 |
|
| 194 |
const onCsv = useCallback(() => {
|
|
@@ -251,14 +359,20 @@ export default function TimeSeriesPanel({
|
|
| 251 |
if (!eligible.length) {
|
| 252 |
return (
|
| 253 |
<div className="cg-mode-empty">
|
| 254 |
-
This table has no
|
| 255 |
-
|
| 256 |
</div>
|
| 257 |
);
|
| 258 |
}
|
| 259 |
|
| 260 |
const unused = eligible.filter((f) => !selected.includes(f.key));
|
| 261 |
const colCount = sheet.columns.length + 2 + (sparkline ? 1 : 0);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 262 |
|
| 263 |
return (
|
| 264 |
<div className="cg-ts">
|
|
@@ -295,22 +409,40 @@ export default function TimeSeriesPanel({
|
|
| 295 |
</label>
|
| 296 |
|
| 297 |
{/* Item 18 β four named comparisons where there used to be one unnamed toggle.
|
| 298 |
-
"Change vs prior" could not say WHICH prior, and there are four honest answers.
|
| 299 |
-
|
| 300 |
-
|
| 301 |
-
|
| 302 |
-
|
| 303 |
-
|
| 304 |
-
|
| 305 |
-
|
| 306 |
-
|
| 307 |
-
|
| 308 |
-
|
| 309 |
-
|
| 310 |
-
|
| 311 |
-
|
| 312 |
-
|
| 313 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 314 |
|
| 315 |
<span className="cg-ts-group">
|
| 316 |
<button
|
|
@@ -356,7 +488,37 @@ export default function TimeSeriesPanel({
|
|
| 356 |
</div>
|
| 357 |
)}
|
| 358 |
|
| 359 |
-
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 360 |
|
| 361 |
{payload && (
|
| 362 |
<div className="cg-ts-scroll">
|
|
@@ -676,9 +838,10 @@ function TsRowBlock({
|
|
| 676 |
(c.partial ? "is-partial" : "") + (cellStyle.bold ? " is-bold" : "") || undefined
|
| 677 |
}
|
| 678 |
>
|
| 679 |
-
{
|
| 680 |
-
|
| 681 |
-
|
|
|
|
| 682 |
</td>
|
| 683 |
);
|
| 684 |
})}
|
|
@@ -686,9 +849,7 @@ function TsRowBlock({
|
|
| 686 |
{/* An avg/min/max row has NO total β the cell stays empty rather than carrying an
|
| 687 |
average of averages. See timeSeriesData's header note (2). Formula and note rows
|
| 688 |
carry none either: an arbitrary expression is not additive across periods. */}
|
| 689 |
-
{row.total == null
|
| 690 |
-
? ""
|
| 691 |
-
: row.total.toLocaleString(undefined, { maximumFractionDigits: 2 })}
|
| 692 |
</td>
|
| 693 |
{sparkline && (
|
| 694 |
<td className="cg-ts-spark">
|
|
@@ -743,7 +904,7 @@ function TsDeltaRow({
|
|
| 743 |
? formatTsDelta(v)
|
| 744 |
: v == null
|
| 745 |
? "β"
|
| 746 |
-
: `${v > 0 ? "+" : ""}${
|
| 747 |
</td>
|
| 748 |
))}
|
| 749 |
<td className="cg-ts-total" />
|
|
|
|
| 40 |
buildTsCsv,
|
| 41 |
buildTsRequest,
|
| 42 |
buildTsSheet,
|
| 43 |
+
buildTsSnapshotRow,
|
| 44 |
buildTsTable,
|
| 45 |
+
classifyTsField,
|
| 46 |
formatTsDelta,
|
| 47 |
formatTsValue,
|
| 48 |
resolveTsStyle,
|
| 49 |
sparklinePoints,
|
| 50 |
sparklineSegments,
|
| 51 |
+
tsDisplayNumber,
|
| 52 |
+
tsRefusalReason,
|
| 53 |
tsRowToChartModel,
|
| 54 |
} from "./timeSeriesData";
|
| 55 |
import type {
|
|
|
|
| 76 |
TsDeltaKind,
|
| 77 |
} from "./types";
|
| 78 |
import { FieldSelectButton } from "./FieldSelect";
|
| 79 |
+
import { Popover } from "../filter-kit";
|
| 80 |
import { toVegaLiteSpec } from "../viz/vega/toVegaLiteSpec";
|
| 81 |
import VegaLiteChart from "../viz/vega/VegaLiteChart";
|
| 82 |
|
|
|
|
| 94 |
const SPARK_W = 72;
|
| 95 |
const SPARK_H = 18;
|
| 96 |
|
| 97 |
+
/**
|
| 98 |
+
* wave17 owner item 7 β the Compare popover's mark: a rising step over a baseline.
|
| 99 |
+
*
|
| 100 |
+
* Private to this file, the way `Toolbar.tsx` keeps its own `Icon*` set: the toolbar's glyphs
|
| 101 |
+
* are not exported, and this is the only surface that means "compare with the prior period".
|
| 102 |
+
* A step rather than an arrow β all four comparisons are period-to-period, and an arrow would
|
| 103 |
+
* claim a direction the control does not have.
|
| 104 |
+
*/
|
| 105 |
+
function IconCompare() {
|
| 106 |
+
const s = {
|
| 107 |
+
stroke: "currentColor",
|
| 108 |
+
strokeWidth: 1.5,
|
| 109 |
+
strokeLinecap: "round" as const,
|
| 110 |
+
strokeLinejoin: "round" as const,
|
| 111 |
+
fill: "none",
|
| 112 |
+
};
|
| 113 |
+
return (
|
| 114 |
+
<svg width="14" height="14" viewBox="0 0 16 16" aria-hidden>
|
| 115 |
+
<path d="M2.5 11.5h4v-4h4v-3h3" {...s} />
|
| 116 |
+
<path d="M2.5 13.5h11" {...s} opacity="0.45" />
|
| 117 |
+
</svg>
|
| 118 |
+
);
|
| 119 |
+
}
|
| 120 |
+
|
| 121 |
export interface TimeSeriesPanelProps {
|
| 122 |
scope: SurfaceScope;
|
| 123 |
/** The rows in scope. The server intersects with the caller's book regardless. */
|
| 124 |
pids: number[];
|
| 125 |
+
/** Every field the table has β the panel classifies them itself (item 5 / R9). */
|
| 126 |
fields: Field[];
|
| 127 |
+
/**
|
| 128 |
+
* wave17 item 5 / R9 β the view's data rows, for SNAPSHOT metrics only.
|
| 129 |
+
*
|
| 130 |
+
* β Does NOT break this file's host-agnostic rule. The rule is that the panel reads no
|
| 131 |
+
* CustomerGrid STATE; `pids` and `fields` already arrive the same way, and RECORD passes its
|
| 132 |
+
* one record. It must be the SAME population `pids` came from, or the two halves of one sheet
|
| 133 |
+
* would answer different questions with nothing going red β CustomerGrid derives both from
|
| 134 |
+
* `modeDataRows`.
|
| 135 |
+
*/
|
| 136 |
+
rows?: readonly Record<string, unknown>[];
|
| 137 |
/** The view's `config.display`; absent keys fall back to the panel's defaults. */
|
| 138 |
display?: DisplaySpec;
|
| 139 |
/** Persist a display change. Absent = the panel is ephemeral (RECORD's embed, v1). */
|
|
|
|
| 143 |
}
|
| 144 |
|
| 145 |
/**
|
| 146 |
+
* wave17 item 5 / owner R9 β **OFFER EVERYTHING, best-effort.**
|
| 147 |
+
*
|
| 148 |
+
* v1 offered `key.startsWith("measure_")`, which was both too narrow and the wrong test. The
|
| 149 |
+
* classification now lives in `timeSeriesData.classifyTsField` (pure, gated under node) and this
|
| 150 |
+
* file only groups the result. A formula FIELD is still refused, for the reason it always was: it
|
| 151 |
+
* has no time dimension of its own, and a formula ROW on this sheet (R2) is a different thing.
|
| 152 |
*/
|
| 153 |
+
function classifyFields(fields: Field[]): {
|
| 154 |
+
server: Field[];
|
| 155 |
+
snapshot: Field[];
|
| 156 |
+
refused: { field: Field; why: string }[];
|
| 157 |
+
} {
|
| 158 |
+
const out = {
|
| 159 |
+
server: [] as Field[],
|
| 160 |
+
snapshot: [] as Field[],
|
| 161 |
+
refused: [] as { field: Field; why: string }[],
|
| 162 |
+
};
|
| 163 |
+
for (const f of fields) {
|
| 164 |
+
const cls = classifyTsField(f);
|
| 165 |
+
if (cls === "server") out.server.push(f);
|
| 166 |
+
else if (cls === "snapshot") out.snapshot.push(f);
|
| 167 |
+
else out.refused.push({ field: f, why: tsRefusalReason(f) });
|
| 168 |
+
}
|
| 169 |
+
return out;
|
| 170 |
}
|
| 171 |
|
| 172 |
/** A stable-enough id for a new custom row. `TS_ROW_ID_MAX` is 40; this is 12. */
|
|
|
|
| 181 |
scope,
|
| 182 |
pids,
|
| 183 |
fields,
|
| 184 |
+
rows,
|
| 185 |
display,
|
| 186 |
onDisplay,
|
| 187 |
locked,
|
| 188 |
}: TimeSeriesPanelProps) {
|
| 189 |
+
const classed = useMemo(() => classifyFields(fields), [fields]);
|
| 190 |
+
// The OFFERED list: everything with a way onto the sheet, server-served first so a real series
|
| 191 |
+
// is never buried under a flat one in the picker.
|
| 192 |
+
const eligible = useMemo(
|
| 193 |
+
() => [...classed.server, ...classed.snapshot],
|
| 194 |
+
[classed.server, classed.snapshot]
|
| 195 |
+
);
|
| 196 |
+
const snapshotKeys = useMemo(
|
| 197 |
+
() => new Set(classed.snapshot.map((f) => f.key)),
|
| 198 |
+
[classed.snapshot]
|
| 199 |
+
);
|
| 200 |
|
| 201 |
const bucket: TsBucket = (TS_BUCKETS as readonly string[]).includes(display?.tsBucket ?? "")
|
| 202 |
? (display!.tsBucket as TsBucket)
|
|
|
|
| 212 |
return live.length ? live : eligible.slice(0, 1).map((f) => f.key);
|
| 213 |
}, [display?.tsFields, eligible]);
|
| 214 |
|
| 215 |
+
/**
|
| 216 |
+
* wave17 item 5 β the selection SPLIT by where its answer comes from.
|
| 217 |
+
*
|
| 218 |
+
* β Only `wired` reaches the server. Sending a snapshot key would be answered with
|
| 219 |
+
* `not_a_measure_field` and rendered as a refusal footnote β telling the reader a field failed
|
| 220 |
+
* when the panel chose, deliberately, to compute it here.
|
| 221 |
+
*/
|
| 222 |
+
const wired = useMemo(
|
| 223 |
+
() => selected.filter((k) => !snapshotKeys.has(k)),
|
| 224 |
+
[selected, snapshotKeys]
|
| 225 |
+
);
|
| 226 |
+
const snapshotSelected = useMemo(
|
| 227 |
+
() => selected.filter((k) => snapshotKeys.has(k)),
|
| 228 |
+
[selected, snapshotKeys]
|
| 229 |
+
);
|
| 230 |
+
|
| 231 |
const customRows = useMemo(() => display?.tsRows ?? [], [display?.tsRows]);
|
| 232 |
const deltaKinds = useMemo(() => display?.tsDeltas ?? [], [display?.tsDeltas]);
|
| 233 |
const styles = display?.tsStyles;
|
|
|
|
| 248 |
|
| 249 |
useEffect(() => {
|
| 250 |
if (embedded) return;
|
| 251 |
+
if (!wired.length || !pids.length) {
|
| 252 |
setPayload(null);
|
| 253 |
setState("idle");
|
| 254 |
return;
|
| 255 |
}
|
| 256 |
const seq = ++reqRef.current;
|
| 257 |
setState("loading");
|
| 258 |
+
const body = buildTsRequest({ pids, bucket, span: { lastN }, fields: wired });
|
| 259 |
fetchTimeseries(body, scope).then(({ payload: p, status }) => {
|
| 260 |
if (seq !== reqRef.current) return;
|
| 261 |
if (!p) {
|
|
|
|
| 267 |
setPayload(p);
|
| 268 |
setState("idle");
|
| 269 |
});
|
| 270 |
+
}, [embedded, scope, pids, bucket, lastN, wired]);
|
| 271 |
+
|
| 272 |
+
const served = useMemo(() => buildTsTable(payload), [payload]);
|
| 273 |
+
/**
|
| 274 |
+
* wave17 item 5 / R9 β the snapshot rows, spliced in AFTER the server's.
|
| 275 |
+
*
|
| 276 |
+
* β They ride the SERVER's columns. Bucket starts and bucket labels are server math
|
| 277 |
+
* (`_ts_next`/`_ts_label`), and re-deriving them here would be a second copy with no parity
|
| 278 |
+
* gate holding it to the first. The consequence β a snapshot-only sheet has no columns to sit
|
| 279 |
+
* on β is DISCLOSED below rather than papered over; the relaxation that would remove it is a
|
| 280 |
+
* one-line 400β200 on the TS route, requested as an amendment in the wave doc.
|
| 281 |
+
*/
|
| 282 |
+
const table = useMemo(() => {
|
| 283 |
+
if (!snapshotSelected.length || !served.columns.length) return served;
|
| 284 |
+
const byKey = new Map(fields.map((f) => [f.key, f]));
|
| 285 |
+
const extra = snapshotSelected
|
| 286 |
+
.map((k) => byKey.get(k))
|
| 287 |
+
.filter((f): f is Field => !!f)
|
| 288 |
+
.map((f) => buildTsSnapshotRow(f, rows ?? [], served.columns, payload?.meta?.today));
|
| 289 |
+
return { ...served, rows: [...served.rows, ...extra], empty: false };
|
| 290 |
+
}, [served, snapshotSelected, fields, rows, payload?.meta?.today]);
|
| 291 |
const sheet: TsSheet = useMemo(
|
| 292 |
+
() =>
|
| 293 |
+
buildTsSheet(table, {
|
| 294 |
+
customRows,
|
| 295 |
+
deltas: deltaKinds,
|
| 296 |
+
bucket,
|
| 297 |
+
today: payload?.meta?.today,
|
| 298 |
+
}),
|
| 299 |
+
[table, customRows, deltaKinds, bucket, payload?.meta?.today]
|
| 300 |
);
|
| 301 |
|
| 302 |
const onCsv = useCallback(() => {
|
|
|
|
| 359 |
if (!eligible.length) {
|
| 360 |
return (
|
| 361 |
<div className="cg-mode-empty">
|
| 362 |
+
This table has no number fields to plot. A time series needs either a metric with a
|
| 363 |
+
period, or a numeric column to snapshot β add one from a column menu, then pick it here.
|
| 364 |
</div>
|
| 365 |
);
|
| 366 |
}
|
| 367 |
|
| 368 |
const unused = eligible.filter((f) => !selected.includes(f.key));
|
| 369 |
const colCount = sheet.columns.length + 2 + (sparkline ? 1 : 0);
|
| 370 |
+
/* wave17 item 5 / R9 β the honest edge, while the TS route still 400s a request with no
|
| 371 |
+
measure field in it. Snapshot rows are painted under the SERVER's bucket columns, so with
|
| 372 |
+
no measure metric on the sheet there is nowhere to put them. Said in words, with the fix,
|
| 373 |
+
rather than rendering an empty table that looks broken. */
|
| 374 |
+
const snapshotsUnplaced =
|
| 375 |
+
snapshotSelected.length > 0 && sheet.columns.length === 0 && state !== "loading";
|
| 376 |
|
| 377 |
return (
|
| 378 |
<div className="cg-ts">
|
|
|
|
| 409 |
</label>
|
| 410 |
|
| 411 |
{/* Item 18 β four named comparisons where there used to be one unnamed toggle.
|
| 412 |
+
"Change vs prior" could not say WHICH prior, and there are four honest answers.
|
| 413 |
+
|
| 414 |
+
wave17 owner item 7 β those four sat OPEN on the bar as a labelled strip, which made
|
| 415 |
+
this panel's most consequential control look like nothing else in the product. It is
|
| 416 |
+
a `Popover` now: the same component Filter / Sort / Group mount, so "the same" is
|
| 417 |
+
achieved by BEING the same rather than by resembling it (the component's own note).
|
| 418 |
+
The count rides the label in the `Filter Β· 2` grammar, and `active` lights the button
|
| 419 |
+
while any comparison is on β the strip used to be the only way to know. */}
|
| 420 |
+
<Popover
|
| 421 |
+
label={deltaKinds.length ? `Compare Β· ${deltaKinds.length}` : "Compare"}
|
| 422 |
+
icon={<IconCompare />}
|
| 423 |
+
active={deltaKinds.length > 0}
|
| 424 |
+
>
|
| 425 |
+
{() => (
|
| 426 |
+
<div className="cg-pop-body">
|
| 427 |
+
<div className="cg-pop-title">Compare each period with</div>
|
| 428 |
+
<div className="cg-pop-note">
|
| 429 |
+
Each choice adds a sub-row under every metric. A comparison that cannot be
|
| 430 |
+
answered for a metric says so in the footnotes rather than printing a number.
|
| 431 |
+
</div>
|
| 432 |
+
{TS_DELTA_KINDS.map((kind) => (
|
| 433 |
+
<label key={kind} className="cg-check-row">
|
| 434 |
+
<input
|
| 435 |
+
type="checkbox"
|
| 436 |
+
checked={deltaKinds.includes(kind)}
|
| 437 |
+
disabled={!onDisplay}
|
| 438 |
+
onChange={() => toggleDelta(kind)}
|
| 439 |
+
/>
|
| 440 |
+
<span className="cg-check-label">{TS_DELTA_LABELS[kind]}</span>
|
| 441 |
+
</label>
|
| 442 |
+
))}
|
| 443 |
+
</div>
|
| 444 |
+
)}
|
| 445 |
+
</Popover>
|
| 446 |
|
| 447 |
<span className="cg-ts-group">
|
| 448 |
<button
|
|
|
|
| 488 |
</div>
|
| 489 |
)}
|
| 490 |
|
| 491 |
+
{snapshotsUnplaced && (
|
| 492 |
+
<div className="cg-ts-note">
|
| 493 |
+
{snapshotSelected.length === 1 ? "That column has" : "Those columns have"} no period of
|
| 494 |
+
its own, so {snapshotSelected.length === 1 ? "it is" : "they are"} shown as a snapshot
|
| 495 |
+
across the periods on the sheet β and this sheet has no periods yet. Add one metric with
|
| 496 |
+
a period and {snapshotSelected.length === 1 ? "it" : "they"} will appear beside it.
|
| 497 |
+
</div>
|
| 498 |
+
)}
|
| 499 |
+
|
| 500 |
+
{/* wave17 item 5 / R9 β "offered is the ruling, undisclosed is not", and its converse: a
|
| 501 |
+
field that CANNOT be plotted is NAMED here rather than quietly missing from the picker.
|
| 502 |
+
A reader who can see "Status" in the table and cannot find it in this list otherwise has
|
| 503 |
+
no way to tell a refusal from an oversight. */}
|
| 504 |
+
{classed.refused.length > 0 && (
|
| 505 |
+
<div className="cg-ts-refused">
|
| 506 |
+
{classed.refused.map(({ field, why }) => (
|
| 507 |
+
<span key={field.key} className="cg-ts-refchip" title={why}>
|
| 508 |
+
{field.label}
|
| 509 |
+
</span>
|
| 510 |
+
))}
|
| 511 |
+
</div>
|
| 512 |
+
)}
|
| 513 |
+
|
| 514 |
+
{/* wave17 GRID β item 3 / R6. Only the LOADING note becomes a spinner; the refusal notes
|
| 515 |
+
above it keep their words, because "could not be loaded" is an answer and R6 is about
|
| 516 |
+
the wait. A spinner in place of a refusal would spin forever. */}
|
| 517 |
+
{state === "loading" && !payload && (
|
| 518 |
+
<div className="cg-ts-note">
|
| 519 |
+
<span className="lp-spin" role="status" aria-label="Loading" />
|
| 520 |
+
</div>
|
| 521 |
+
)}
|
| 522 |
|
| 523 |
{payload && (
|
| 524 |
<div className="cg-ts-scroll">
|
|
|
|
| 838 |
(c.partial ? "is-partial" : "") + (cellStyle.bold ? " is-bold" : "") || undefined
|
| 839 |
}
|
| 840 |
>
|
| 841 |
+
{/* item 6 β `tsDisplayNumber`, never an inline toLocaleString: the CSV calls the
|
| 842 |
+
same function, and that is the only thing making "the file matches the sheet"
|
| 843 |
+
a property rather than a coincidence. */}
|
| 844 |
+
{formatTsValue(c.value, tsDisplayNumber)}
|
| 845 |
</td>
|
| 846 |
);
|
| 847 |
})}
|
|
|
|
| 849 |
{/* An avg/min/max row has NO total β the cell stays empty rather than carrying an
|
| 850 |
average of averages. See timeSeriesData's header note (2). Formula and note rows
|
| 851 |
carry none either: an arbitrary expression is not additive across periods. */}
|
| 852 |
+
{row.total == null ? "" : tsDisplayNumber(row.total)}
|
|
|
|
|
|
|
| 853 |
</td>
|
| 854 |
{sparkline && (
|
| 855 |
<td className="cg-ts-spark">
|
|
|
|
| 904 |
? formatTsDelta(v)
|
| 905 |
: v == null
|
| 906 |
? "β"
|
| 907 |
+
: `${v > 0 ? "+" : ""}${tsDisplayNumber(v)}`}
|
| 908 |
</td>
|
| 909 |
))}
|
| 910 |
<td className="cg-ts-total" />
|
web/src/customer-grid/Toolbar.tsx
CHANGED
|
@@ -36,7 +36,6 @@ import { AnchoredOverlay } from "./OverlaySurface";
|
|
| 36 |
import { EyeOffIcon, FieldTypeIcon, ModeIcon } from "./icons";
|
| 37 |
import { FieldSelectButton } from "./FieldSelect";
|
| 38 |
import { TYPE_LABELS } from "./iconShapes";
|
| 39 |
-
import { cohortLockChipText } from "./cohortRail";
|
| 40 |
import { countLabel, countLabelCompact, poolProgressLabel } from "./counts";
|
| 41 |
import type { PoolProgress } from "./counts";
|
| 42 |
// Wave-15 (C-KIT) β the condition builder and the hide-fields list live in `filter-kit/` now,
|
|
@@ -617,13 +616,20 @@ export default function Toolbar({
|
|
| 617 |
if (nodes !== filters) onFilters(nodes);
|
| 618 |
if (conj !== filterConj) onFilterConj(conj);
|
| 619 |
};
|
| 620 |
-
/**
|
| 621 |
-
*
|
| 622 |
-
*
|
| 623 |
-
*
|
| 624 |
-
|
| 625 |
-
|
| 626 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 627 |
/** The copy door renders only when BOTH halves are wired β the house posture for an action
|
| 628 |
* whose host half may not exist yet. */
|
| 629 |
const canCopyConfig = !!onCopyConfig && (copyViews?.length ?? 0) > 0;
|
|
@@ -813,16 +819,29 @@ export default function Toolbar({
|
|
| 813 |
Filter / Sort / Group because it is the same kind of fact β what this table is showing
|
| 814 |
β and it is NOT a button: the lock is set from the view rail's menu, and a chip that
|
| 815 |
looked clickable here would promise an action this strip does not have. */}
|
| 816 |
-
{
|
| 817 |
<span
|
| 818 |
className="cg-tb-lock"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 819 |
title={
|
| 820 |
-
|
| 821 |
-
|
|
|
|
|
|
|
|
|
|
| 822 |
}
|
| 823 |
>
|
| 824 |
<LockIcon />
|
| 825 |
-
<span className="cg-tb-label">
|
| 826 |
</span>
|
| 827 |
)}
|
| 828 |
|
|
@@ -942,8 +961,17 @@ export default function Toolbar({
|
|
| 942 |
)}
|
| 943 |
{poolProgressLabel(pool) != null ? (
|
| 944 |
// W1c (C1): the pool is a PARTIAL fast slice β the count says so instead of
|
| 945 |
-
// presenting the slice as a total.
|
| 946 |
-
//
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 947 |
<span
|
| 948 |
className="cg-count cg-count-partial"
|
| 949 |
title={
|
|
@@ -951,7 +979,7 @@ export default function Toolbar({
|
|
| 951 |
"filter and sort what is already here."
|
| 952 |
}
|
| 953 |
>
|
| 954 |
-
<span className="
|
| 955 |
{poolProgressLabel(pool)}
|
| 956 |
</span>
|
| 957 |
) : (
|
|
|
|
| 36 |
import { EyeOffIcon, FieldTypeIcon, ModeIcon } from "./icons";
|
| 37 |
import { FieldSelectButton } from "./FieldSelect";
|
| 38 |
import { TYPE_LABELS } from "./iconShapes";
|
|
|
|
| 39 |
import { countLabel, countLabelCompact, poolProgressLabel } from "./counts";
|
| 40 |
import type { PoolProgress } from "./counts";
|
| 41 |
// Wave-15 (C-KIT) β the condition builder and the hide-fields list live in `filter-kit/` now,
|
|
|
|
| 616 |
if (nodes !== filters) onFilters(nodes);
|
| 617 |
if (conj !== filterConj) onFilterConj(conj);
|
| 618 |
};
|
| 619 |
+
/**
|
| 620 |
+
* Item 5c β wave17 owner item 1 (R1) β **the chip is a STATE, not a sentence.**
|
| 621 |
+
*
|
| 622 |
+
* It read "Β«nameΒ» Β· 1,204 customers", or "Locked to a list you cannot see" when the reader
|
| 623 |
+
* could not count the set β three sentences from `cohortRail.cohortLockChipText`, which is why
|
| 624 |
+
* that projection existed. R1 replaces all three with a lock mark and the word "Locked".
|
| 625 |
+
*
|
| 626 |
+
* That is not merely shorter. Under R1 the locked view is IN THE RAIL, named, selected, with
|
| 627 |
+
* its own row β so the chip repeating its name told you what you had just clicked, and the
|
| 628 |
+
* count duplicated the record count sitting six inches to its right. What the chip is for is
|
| 629 |
+
* the one thing neither of those says: *this table is narrowed by something that is not a
|
| 630 |
+
* filter*. The name and the explanation move to the `title`.
|
| 631 |
+
*/
|
| 632 |
+
const lockOn = !!cohortLock;
|
| 633 |
/** The copy door renders only when BOTH halves are wired β the house posture for an action
|
| 634 |
* whose host half may not exist yet. */
|
| 635 |
const canCopyConfig = !!onCopyConfig && (copyViews?.length ?? 0) > 0;
|
|
|
|
| 819 |
Filter / Sort / Group because it is the same kind of fact β what this table is showing
|
| 820 |
β and it is NOT a button: the lock is set from the view rail's menu, and a chip that
|
| 821 |
looked clickable here would promise an action this strip does not have. */}
|
| 822 |
+
{lockOn && (
|
| 823 |
<span
|
| 824 |
className="cg-tb-lock"
|
| 825 |
+
// The name and the count left the CHIP (R1) β they did not leave the product. The
|
| 826 |
+
// rail row is named and selected; this is the hover that explains what the mark means.
|
| 827 |
+
//
|
| 828 |
+
// β Branches on `name`, NOT on `count`, and that is the honest test. A set the reader
|
| 829 |
+
// may not see arrives with NEITHER field (`CustomerGrid.cohortLockChip` returns `{}`
|
| 830 |
+
// for a lock whose set is not in `lists`) β while a set that IS found always reports a
|
| 831 |
+
// number, because that producer reads `pids?.length ?? 0`. So `count == null` is not a
|
| 832 |
+
// state this chip can observe, and testing it would be a branch that never runs. The
|
| 833 |
+
// "unreadable set" sentence still has to exist: the table is empty for a reason that
|
| 834 |
+
// is not a filter, and the reader has to be told which kind of nothing this is.
|
| 835 |
title={
|
| 836 |
+
(cohortLock?.name
|
| 837 |
+
? `Locked to ${cohortLock.name}. `
|
| 838 |
+
: "Locked to a set of records you cannot see. ") +
|
| 839 |
+
"Only the records locked into that view are shown. Filters and sort narrow WITHIN " +
|
| 840 |
+
"the lock; the lock itself is changed from the view menu in the rail."
|
| 841 |
}
|
| 842 |
>
|
| 843 |
<LockIcon />
|
| 844 |
+
<span className="cg-tb-label">Locked</span>
|
| 845 |
</span>
|
| 846 |
)}
|
| 847 |
|
|
|
|
| 961 |
)}
|
| 962 |
{poolProgressLabel(pool) != null ? (
|
| 963 |
// W1c (C1): the pool is a PARTIAL fast slice β the count says so instead of
|
| 964 |
+
// presenting the slice as a total.
|
| 965 |
+
//
|
| 966 |
+
// wave17 GRID β item 3 / owner R6: the affordance is now the ONE app-wide spinner
|
| 967 |
+
// (`.lp-spin`, C-SPIN) rather than this chip's own pulsing dot. R6's point is that every
|
| 968 |
+
// wait in the product looks the same; a bespoke dot here was the last place it did not.
|
| 969 |
+
//
|
| 970 |
+
// β What R6 does NOT take: the COUNT stays, and so does the sentence in the `title`.
|
| 971 |
+
// "No words" is about the loading indicator, and "100 of 1,550" is a number, not a word
|
| 972 |
+
// β it is the disclosure that this slice is partial, and dropping it would leave a count
|
| 973 |
+
// silently capped, which the owner constants forbid outright. The title is a hover
|
| 974 |
+
// affordance, not text on screen.
|
| 975 |
<span
|
| 976 |
className="cg-count cg-count-partial"
|
| 977 |
title={
|
|
|
|
| 979 |
"filter and sort what is already here."
|
| 980 |
}
|
| 981 |
>
|
| 982 |
+
<span className="lp-spin" role="status" aria-label="Loading" />
|
| 983 |
{poolProgressLabel(pool)}
|
| 984 |
</span>
|
| 985 |
) : (
|
web/src/customer-grid/ViewSidebar.tsx
CHANGED
|
@@ -1,7 +1,6 @@
|
|
| 1 |
import { useState } from "react";
|
| 2 |
import type { KeyboardEvent as ReactKeyboardEvent } from "react";
|
| 3 |
import { AnchoredOverlay } from "./OverlaySurface";
|
| 4 |
-
import type { CohortRailRow } from "./cohortRail";
|
| 5 |
import { EXPORT_FORMATS, EXPORT_LABELS } from "./export";
|
| 6 |
import type { ExportFormat } from "./export";
|
| 7 |
import type {
|
|
@@ -120,15 +119,10 @@ interface ViewSidebarProps {
|
|
| 120 |
viewer?: Viewer;
|
| 121 |
/** C3 β freeze/unfreeze this view's DISPLAY MODE. The host re-checks the actor. */
|
| 122 |
onToggleLock?: (viewId: string, locked: boolean) => void;
|
| 123 |
-
/*
|
| 124 |
-
|
| 125 |
-
|
| 126 |
-
|
| 127 |
-
*/
|
| 128 |
-
cohorts?: CohortRailRow[];
|
| 129 |
-
/** Apply (or, with null, release) a TRANSIENT cohort lock. Never persisted β see the
|
| 130 |
-
* section's own note; a projected cohort is not a saved view and must not become one. */
|
| 131 |
-
onSelectCohort?: (id: string | null) => void;
|
| 132 |
/** I17 (C4) β the tenant's real account list, for the "Specific users" picker. The HOST
|
| 133 |
* re-validates every name against core/users.py and drops what it cannot resolve, so this
|
| 134 |
* list is a convenience, never the authority. */
|
|
@@ -136,8 +130,6 @@ interface ViewSidebarProps {
|
|
| 136 |
}
|
| 137 |
|
| 138 |
export default function ViewSidebar({
|
| 139 |
-
cohorts,
|
| 140 |
-
onSelectCohort,
|
| 141 |
views,
|
| 142 |
activeViewId,
|
| 143 |
saveState,
|
|
@@ -399,8 +391,12 @@ export default function ViewSidebar({
|
|
| 399 |
directly under this one β is DELETED. It was a duplicate of the flyout's own Folder
|
| 400 |
row, so the rail offered two controls that did the same thing. `startFolder()` still
|
| 401 |
has exactly one caller (the flyout row); only the redundant entry point is gone.
|
| 402 |
-
β
|
| 403 |
-
own "+ New folder" under that class and
|
|
|
|
|
|
|
|
|
|
|
|
|
| 404 |
<div className="cg-create-new">
|
| 405 |
<button
|
| 406 |
type="button"
|
|
@@ -806,16 +802,42 @@ export default function ViewSidebar({
|
|
| 806 |
<span className="cg-view-desc">{view.note}</span>
|
| 807 |
)}
|
| 808 |
</span>
|
| 809 |
-
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 810 |
<span
|
| 811 |
className="cg-view-lock"
|
| 812 |
// Not aria-hidden: "this view is frozen" is information, and the row's
|
| 813 |
// accessible name is the only place a non-sighted user can receive it.
|
| 814 |
role="img"
|
| 815 |
-
aria-label={
|
| 816 |
-
|
| 817 |
-
|
| 818 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 819 |
>
|
| 820 |
<LockMark />
|
| 821 |
</span>
|
|
@@ -852,61 +874,14 @@ export default function ViewSidebar({
|
|
| 852 |
);
|
| 853 |
})}
|
| 854 |
|
| 855 |
-
{/* β
|
| 856 |
-
|
| 857 |
-
|
| 858 |
-
|
| 859 |
-
|
| 860 |
-
|
| 861 |
-
|
| 862 |
-
|
| 863 |
-
{cohorts && cohorts.length > 0 && onSelectCohort && (
|
| 864 |
-
<div className="cg-rail-section">
|
| 865 |
-
<div className="cg-rail-head">Cohorts</div>
|
| 866 |
-
{cohorts.map((c) => (
|
| 867 |
-
<div
|
| 868 |
-
key={c.id}
|
| 869 |
-
// The SAME lock vocabulary a saved locked view wears β one mark in the product.
|
| 870 |
-
className={"cg-view-row cg-view-lockset" + (c.active ? " is-active" : "")}
|
| 871 |
-
>
|
| 872 |
-
<button
|
| 873 |
-
type="button"
|
| 874 |
-
className="cg-view-main"
|
| 875 |
-
// Clicking the active one lets go of it, so the rail is also the way OUT of a
|
| 876 |
-
// lock. Without this the only exit would be picking another view.
|
| 877 |
-
onClick={() => onSelectCohort(c.active ? null : c.id)}
|
| 878 |
-
title={
|
| 879 |
-
c.count == null
|
| 880 |
-
? `${c.name} β you cannot see who is in this list.`
|
| 881 |
-
: `${c.name} β ${c.count.toLocaleString()} of your customers` +
|
| 882 |
-
(c.missing > 0
|
| 883 |
-
? `, and ${c.missing.toLocaleString()} outside what you can see.`
|
| 884 |
-
: ".")
|
| 885 |
-
}
|
| 886 |
-
>
|
| 887 |
-
<span className="cg-view-text">
|
| 888 |
-
<span className="cg-view-name">{c.name}</span>
|
| 889 |
-
{/* β `null` is NOT 0 β "a list with nobody in it" and "a list I may not
|
| 890 |
-
count" are different sentences, and only one of them may be a number. */}
|
| 891 |
-
<span className="cg-view-desc">
|
| 892 |
-
{c.count == null
|
| 893 |
-
? "Members hidden"
|
| 894 |
-
: `${c.count.toLocaleString()} customer${c.count === 1 ? "" : "s"}` +
|
| 895 |
-
(c.missing > 0 ? ` Β· ${c.missing.toLocaleString()} hidden` : "")}
|
| 896 |
-
</span>
|
| 897 |
-
</span>
|
| 898 |
-
<span
|
| 899 |
-
className="cg-view-lock"
|
| 900 |
-
role="img"
|
| 901 |
-
aria-label={`${c.name}, a locked customer list`}
|
| 902 |
-
>
|
| 903 |
-
<LockMark />
|
| 904 |
-
</span>
|
| 905 |
-
</button>
|
| 906 |
-
</div>
|
| 907 |
-
))}
|
| 908 |
-
</div>
|
| 909 |
-
)}
|
| 910 |
</div>
|
| 911 |
|
| 912 |
{/* I11c β the folder "β¦" menu. Rename Β· Add to cohort Β· Duplicate Β· Delete. */}
|
|
@@ -998,13 +973,13 @@ export default function ViewSidebar({
|
|
| 998 |
className="cg-pop cg-lock-pop"
|
| 999 |
placement="bottom-start"
|
| 1000 |
role="dialog"
|
| 1001 |
-
ariaLabel="Lock this view to a
|
| 1002 |
onDismiss={() => setLockFor(null)}
|
| 1003 |
dataKind="view-cohort-lock"
|
| 1004 |
>
|
| 1005 |
-
<div className="cg-pop-title">Lock to
|
| 1006 |
<div className="cg-pop-note">
|
| 1007 |
-
|
| 1008 |
within it, and the lock cannot be removed as a condition.
|
| 1009 |
</div>
|
| 1010 |
{(lists ?? []).map((l) => (
|
|
@@ -1045,7 +1020,7 @@ export default function ViewSidebar({
|
|
| 1045 |
className="cg-pop cg-fold-addpop"
|
| 1046 |
placement="bottom-start"
|
| 1047 |
role="dialog"
|
| 1048 |
-
ariaLabel="Add this folder's customers to a
|
| 1049 |
onDismiss={() => setAddTarget(null)}
|
| 1050 |
dataKind="folder-add-to-list"
|
| 1051 |
>
|
|
@@ -1079,7 +1054,7 @@ export default function ViewSidebar({
|
|
| 1079 |
</button>
|
| 1080 |
))}
|
| 1081 |
<div className="cg-view-create">
|
| 1082 |
-
<label htmlFor="cg-fold-new-list">
|
| 1083 |
<input
|
| 1084 |
id="cg-fold-new-list"
|
| 1085 |
className="cg-input"
|
|
@@ -1189,19 +1164,28 @@ export default function ViewSidebar({
|
|
| 1189 |
setMenu(null);
|
| 1190 |
}}
|
| 1191 |
>
|
| 1192 |
-
<MenuLabel icon="cohortAdd" text="Add to
|
| 1193 |
</button>
|
| 1194 |
)}
|
| 1195 |
{/* Item 12 (C-LOCK) β LOCK the view to a cohort. This menu is the ONLY emitter of
|
| 1196 |
`cohortLock`, which is why it lands after RECORD's engine: an emitter for an
|
| 1197 |
engine that cannot yet read the key writes a config that silently does nothing.
|
| 1198 |
|
| 1199 |
-
Deliberately NOT beside "Add to
|
| 1200 |
-
the menu: that one COPIES today's matches into a set; this one makes the set the
|
| 1201 |
-
view's permanent boundary. The submenu lists the
|
| 1202 |
one is already set, because a lock that cannot be removed from the same place it
|
| 1203 |
-
was applied is a trap.
|
| 1204 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1205 |
<button
|
| 1206 |
type="button"
|
| 1207 |
role="menuitem"
|
|
@@ -1212,7 +1196,7 @@ export default function ViewSidebar({
|
|
| 1212 |
>
|
| 1213 |
<MenuLabel
|
| 1214 |
icon="permissions"
|
| 1215 |
-
text={menuView.config?.cohortLock ? "Change
|
| 1216 |
/>
|
| 1217 |
</button>
|
| 1218 |
)}
|
|
@@ -1306,7 +1290,7 @@ export default function ViewSidebar({
|
|
| 1306 |
className="cg-pop cg-add-list-pop"
|
| 1307 |
placement="bottom-end"
|
| 1308 |
role="dialog"
|
| 1309 |
-
ariaLabel={`Add ${addView.name} to a
|
| 1310 |
onDismiss={() => setAddFor(null)}
|
| 1311 |
dataKind="add-to-list"
|
| 1312 |
>
|
|
@@ -1329,7 +1313,7 @@ export default function ViewSidebar({
|
|
| 1329 |
</button>
|
| 1330 |
))}
|
| 1331 |
<div className="cg-view-create">
|
| 1332 |
-
<label htmlFor="cg-new-list">
|
| 1333 |
<input
|
| 1334 |
id="cg-new-list"
|
| 1335 |
className="cg-input"
|
|
|
|
| 1 |
import { useState } from "react";
|
| 2 |
import type { KeyboardEvent as ReactKeyboardEvent } from "react";
|
| 3 |
import { AnchoredOverlay } from "./OverlaySurface";
|
|
|
|
| 4 |
import { EXPORT_FORMATS, EXPORT_LABELS } from "./export";
|
| 5 |
import type { ExportFormat } from "./export";
|
| 6 |
import type {
|
|
|
|
| 119 |
viewer?: Viewer;
|
| 120 |
/** C3 β freeze/unfreeze this view's DISPLAY MODE. The host re-checks the actor. */
|
| 121 |
onToggleLock?: (viewId: string, locked: boolean) => void;
|
| 122 |
+
/* wave17 R1 / C-LOCKV β `cohorts` and `onSelectCohort` are GONE from this component's
|
| 123 |
+
surface. They carried the transient-lock selection for the retired Cohorts section; a
|
| 124 |
+
locked view is now an ordinary member of `views` and is selected by `onSelect` like any
|
| 125 |
+
other, which is the whole point of R1. */
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 126 |
/** I17 (C4) β the tenant's real account list, for the "Specific users" picker. The HOST
|
| 127 |
* re-validates every name against core/users.py and drops what it cannot resolve, so this
|
| 128 |
* list is a convenience, never the authority. */
|
|
|
|
| 130 |
}
|
| 131 |
|
| 132 |
export default function ViewSidebar({
|
|
|
|
|
|
|
| 133 |
views,
|
| 134 |
activeViewId,
|
| 135 |
saveState,
|
|
|
|
| 391 |
directly under this one β is DELETED. It was a duplicate of the flyout's own Folder
|
| 392 |
row, so the rail offered two controls that did the same thing. `startFolder()` still
|
| 393 |
has exactly one caller (the flyout row); only the redundant entry point is gone.
|
| 394 |
+
β wave17 R1 β the reason `.cg-fold-new` was kept has EXPIRED. It survived wave 10
|
| 395 |
+
because `CohortSidebar.tsx` rendered its own "+ New folder" under that class and had
|
| 396 |
+
no create-flyout to fold it into; that file is deleted this wave, so the class now has
|
| 397 |
+
no consumer in this tree. Left in index.css rather than swept blind: a CSS rule with
|
| 398 |
+
no consumer is inert, and hunting one down mid-wave is how a rule something else still
|
| 399 |
+
reads gets removed. Named here so the sweep is a decision, not a discovery. */}
|
| 400 |
<div className="cg-create-new">
|
| 401 |
<button
|
| 402 |
type="button"
|
|
|
|
| 802 |
<span className="cg-view-desc">{view.note}</span>
|
| 803 |
)}
|
| 804 |
</span>
|
| 805 |
+
{/* β wave17 R1 / C-LOCKV β ONE mark, TWO meanings, and they are genuinely
|
| 806 |
+
different things that both read as "locked":
|
| 807 |
+
|
| 808 |
+
Β· `kind === "locked"` β the view's ROWS are a hand-curated set. This is
|
| 809 |
+
what the retired Cohorts section used to say, and it is the more
|
| 810 |
+
consequential of the two: it explains why this view shows fewer
|
| 811 |
+
records than its siblings, which no filter chip accounts for.
|
| 812 |
+
Β· `isModeFrozen` β the view's DISPLAY MODE is frozen (the legacy
|
| 813 |
+
`locked` flag). It says nothing about which rows are here.
|
| 814 |
+
|
| 815 |
+
A locked view does NOT get the legacy flag set (the host's projection says
|
| 816 |
+
so explicitly), so most rows have exactly one reason. When a row has both,
|
| 817 |
+
the row-set meaning leads and the title carries the other β never two
|
| 818 |
+
padlocks side by side, which would read as a bug. */}
|
| 819 |
+
{(view.kind === "locked" || isModeFrozen(view)) && (
|
| 820 |
<span
|
| 821 |
className="cg-view-lock"
|
| 822 |
// Not aria-hidden: "this view is frozen" is information, and the row's
|
| 823 |
// accessible name is the only place a non-sighted user can receive it.
|
| 824 |
role="img"
|
| 825 |
+
aria-label={
|
| 826 |
+
view.kind === "locked"
|
| 827 |
+
? `${view.name}, a locked view`
|
| 828 |
+
: `${MODE_LABELS[mode]} view, locked`
|
| 829 |
+
}
|
| 830 |
+
title={
|
| 831 |
+
view.kind === "locked"
|
| 832 |
+
? "Locked β this view shows only the records locked into it. " +
|
| 833 |
+
"Filters, sorts and columns still narrow within them." +
|
| 834 |
+
(isModeFrozen(view)
|
| 835 |
+
? ` It also stays a ${MODE_LABELS[mode].toLowerCase()}.`
|
| 836 |
+
: "")
|
| 837 |
+
: `Locked β this view stays a ${MODE_LABELS[
|
| 838 |
+
mode
|
| 839 |
+
].toLowerCase()}. Filters, sorts and columns are still editable.`
|
| 840 |
+
}
|
| 841 |
>
|
| 842 |
<LockMark />
|
| 843 |
</span>
|
|
|
|
| 874 |
);
|
| 875 |
})}
|
| 876 |
|
| 877 |
+
{/* β wave17 R1 / C-LOCKV β THE "COHORTS" SECTION IS GONE, and nothing replaced it here.
|
| 878 |
+
Wave 15 projected each cohort as a transient row under its own heading, which made a
|
| 879 |
+
locked view a second-class object: it could not be renamed, filed into a folder,
|
| 880 |
+
reordered, sorted or shared, because it was not a view. R1: it IS a view. The host
|
| 881 |
+
projects each one into the SAME list above (`locked_view_projection` β id preserved,
|
| 882 |
+
`config.cohortLock` naming its own id), so every one of those capabilities arrives for
|
| 883 |
+
free and this section has nothing left to render.
|
| 884 |
+
The lock MARK moved onto the ordinary view row, where `kind === "locked"` drives it. */}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 885 |
</div>
|
| 886 |
|
| 887 |
{/* I11c β the folder "β¦" menu. Rename Β· Add to cohort Β· Duplicate Β· Delete. */}
|
|
|
|
| 973 |
className="cg-pop cg-lock-pop"
|
| 974 |
placement="bottom-start"
|
| 975 |
role="dialog"
|
| 976 |
+
ariaLabel="Lock this view to a locked view"
|
| 977 |
onDismiss={() => setLockFor(null)}
|
| 978 |
dataKind="view-cohort-lock"
|
| 979 |
>
|
| 980 |
+
<div className="cg-pop-title">Lock to a locked view</div>
|
| 981 |
<div className="cg-pop-note">
|
| 982 |
+
This view can then only ever show the records locked into the view you pick. Filters still narrow
|
| 983 |
within it, and the lock cannot be removed as a condition.
|
| 984 |
</div>
|
| 985 |
{(lists ?? []).map((l) => (
|
|
|
|
| 1020 |
className="cg-pop cg-fold-addpop"
|
| 1021 |
placement="bottom-start"
|
| 1022 |
role="dialog"
|
| 1023 |
+
ariaLabel="Add this folder's customers to a locked view"
|
| 1024 |
onDismiss={() => setAddTarget(null)}
|
| 1025 |
dataKind="folder-add-to-list"
|
| 1026 |
>
|
|
|
|
| 1054 |
</button>
|
| 1055 |
))}
|
| 1056 |
<div className="cg-view-create">
|
| 1057 |
+
<label htmlFor="cg-fold-new-list">Lock records into a new view</label>
|
| 1058 |
<input
|
| 1059 |
id="cg-fold-new-list"
|
| 1060 |
className="cg-input"
|
|
|
|
| 1164 |
setMenu(null);
|
| 1165 |
}}
|
| 1166 |
>
|
| 1167 |
+
<MenuLabel icon="cohortAdd" text="Add to locked view" />
|
| 1168 |
</button>
|
| 1169 |
)}
|
| 1170 |
{/* Item 12 (C-LOCK) β LOCK the view to a cohort. This menu is the ONLY emitter of
|
| 1171 |
`cohortLock`, which is why it lands after RECORD's engine: an emitter for an
|
| 1172 |
engine that cannot yet read the key writes a config that silently does nothing.
|
| 1173 |
|
| 1174 |
+
Deliberately NOT beside "Add to locked view" in meaning, though it sits beside it
|
| 1175 |
+
in the menu: that one COPIES today's matches into a set; this one makes the set the
|
| 1176 |
+
view's permanent boundary. The submenu lists the sets and offers Unlock when
|
| 1177 |
one is already set, because a lock that cannot be removed from the same place it
|
| 1178 |
+
was applied is a trap.
|
| 1179 |
+
|
| 1180 |
+
β wave17 R1 β HIDDEN ON A LOCKED VIEW ITSELF, and this is not tidiness. A
|
| 1181 |
+
projected locked view's lock IS its identity: `aios_grid.views_from_defs` re-stamps
|
| 1182 |
+
`config.cohortLock = view.id` on EVERY READ, unconditionally, so a lock chosen here
|
| 1183 |
+
would be accepted by the UI, sent, and then silently overwritten by the host on the
|
| 1184 |
+
next payload. The rail would show no change and nothing would go red β the
|
| 1185 |
+
present-and-silently-inert affordance this file's own posture forbids. An action
|
| 1186 |
+
the server will not honour must be ABSENT, not merely ineffective. */}
|
| 1187 |
+
{onCohortLock && lists.length > 0 && canEditMenuView &&
|
| 1188 |
+
menuView.kind !== "locked" && (
|
| 1189 |
<button
|
| 1190 |
type="button"
|
| 1191 |
role="menuitem"
|
|
|
|
| 1196 |
>
|
| 1197 |
<MenuLabel
|
| 1198 |
icon="permissions"
|
| 1199 |
+
text={menuView.config?.cohortLock ? "Change the lockβ¦" : "Lock to a locked viewβ¦"}
|
| 1200 |
/>
|
| 1201 |
</button>
|
| 1202 |
)}
|
|
|
|
| 1290 |
className="cg-pop cg-add-list-pop"
|
| 1291 |
placement="bottom-end"
|
| 1292 |
role="dialog"
|
| 1293 |
+
ariaLabel={`Add ${addView.name} to a locked view`}
|
| 1294 |
onDismiss={() => setAddFor(null)}
|
| 1295 |
dataKind="add-to-list"
|
| 1296 |
>
|
|
|
|
| 1313 |
</button>
|
| 1314 |
))}
|
| 1315 |
<div className="cg-view-create">
|
| 1316 |
+
<label htmlFor="cg-new-list">Lock records into a new view</label>
|
| 1317 |
<input
|
| 1318 |
id="cg-new-list"
|
| 1319 |
className="cg-input"
|
web/src/customer-grid/apiBridge.ts
CHANGED
|
@@ -259,6 +259,57 @@ export async function fetchTimeseries(
|
|
| 259 |
}
|
| 260 |
}
|
| 261 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 262 |
// --- the WRITE (CP-C) ------------------------------------------------------
|
| 263 |
|
| 264 |
/**
|
|
|
|
| 259 |
}
|
| 260 |
}
|
| 261 |
|
| 262 |
+
/**
|
| 263 |
+
* wave17 owner item 9 / ruling R4 (contract C-CAL) β per-DAY measure values.
|
| 264 |
+
*
|
| 265 |
+
* β WHY A SECOND CHANNEL rather than a parameter on the time-series one: **every group carries
|
| 266 |
+
* its OWN pid set.** A calendar day holds whatever records the date field placed there, so the
|
| 267 |
+
* subject changes from cell to cell; one `allowed_pids` for the whole request would compute
|
| 268 |
+
* every day over everybody, which is a different question with the same shape.
|
| 269 |
+
*
|
| 270 |
+
* The caps are the SERVER's and it answers a 400 with its reason rather than trimming: 31 days,
|
| 271 |
+
* 6 fields, 186 cells. The client's job is to send no more than that, never to guess what was
|
| 272 |
+
* dropped. `values[field][day] === null` is UNANSWERED β a day past the tenant's today, a day
|
| 273 |
+
* whose pids are all outside the reader's book, or a measure that could not resolve β and the
|
| 274 |
+
* renderer draws "β" for all three. Never 0.
|
| 275 |
+
*/
|
| 276 |
+
export interface CalMetricsResponse {
|
| 277 |
+
values: Record<string, Record<string, number | null>>;
|
| 278 |
+
today?: string;
|
| 279 |
+
/** C-TSWIN at day grain: which window each metric was resolved under. */
|
| 280 |
+
windows?: Record<string, { kind: string; label: string }>;
|
| 281 |
+
dropped?: { field: string; reason: string }[];
|
| 282 |
+
problems?: string[];
|
| 283 |
+
}
|
| 284 |
+
|
| 285 |
+
export async function fetchCalendarMetrics(
|
| 286 |
+
body: { groups: { key: string; pids: number[] }[]; fields: string[] },
|
| 287 |
+
scope: SurfaceScope = surfaceScope
|
| 288 |
+
): Promise<{ payload: CalMetricsResponse | null; status: number }> {
|
| 289 |
+
try {
|
| 290 |
+
const res = await fetch(
|
| 291 |
+
`${API_V1}/grid/calendar_metrics?scope=${encodeURIComponent(scope)}`,
|
| 292 |
+
{
|
| 293 |
+
method: "POST",
|
| 294 |
+
credentials: CREDENTIALS,
|
| 295 |
+
headers: JSON_HEADERS,
|
| 296 |
+
body: JSON.stringify(body),
|
| 297 |
+
}
|
| 298 |
+
);
|
| 299 |
+
if (handledUnauthorized(res.status)) return { payload: null, status: res.status };
|
| 300 |
+
if (!res.ok) return { payload: null, status: res.status };
|
| 301 |
+
const json = (await readJson(res)) as CalMetricsResponse | null;
|
| 302 |
+
// Shape-checked before it is trusted, the `fetchTimeseries` rule: every lookup below is
|
| 303 |
+
// `values[field][day]`, so a payload without `values` would read `undefined` as a value and
|
| 304 |
+
// paint blanks that look like real "β" refusals.
|
| 305 |
+
if (!json || !json.values || typeof json.values !== "object")
|
| 306 |
+
return { payload: null, status: res.status };
|
| 307 |
+
return { payload: json, status: res.status };
|
| 308 |
+
} catch {
|
| 309 |
+
return { payload: null, status: 0 };
|
| 310 |
+
}
|
| 311 |
+
}
|
| 312 |
+
|
| 313 |
// --- the WRITE (CP-C) ------------------------------------------------------
|
| 314 |
|
| 315 |
/**
|
web/src/customer-grid/iconShapes.ts
CHANGED
|
@@ -312,16 +312,25 @@ export const MODE_LABELS: Record<DisplayMode, string> = {
|
|
| 312 |
// wrote for 'dashboard', running forwards): `aios_grid._clean_display` drops a mode it does
|
| 313 |
// not know, so offering it early would let a user create a view that silently reverts to a
|
| 314 |
// grid on the next read with nothing going red. HOST posted "ACCEPTANCE LANDED" with
|
| 315 |
-
// `DISPLAY_MODES += timeseries`, so it is offerable now.
|
| 316 |
-
//
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 317 |
export const CREATABLE_MODES: DisplayMode[] = [
|
| 318 |
"grid",
|
| 319 |
"chart",
|
| 320 |
-
"list",
|
| 321 |
"calendar",
|
| 322 |
"kanban",
|
| 323 |
-
"map",
|
| 324 |
"timeseries",
|
|
|
|
|
|
|
| 325 |
];
|
| 326 |
|
| 327 |
export const MODE_TONE: Record<DisplayMode, FolderTone> = {
|
|
|
|
| 312 |
// wrote for 'dashboard', running forwards): `aios_grid._clean_display` drops a mode it does
|
| 313 |
// not know, so offering it early would let a user create a view that silently reverts to a
|
| 314 |
// grid on the next read with nothing going red. HOST posted "ACCEPTANCE LANDED" with
|
| 315 |
+
// `DISPLAY_MODES += timeseries`, so it is offerable now.
|
| 316 |
+
//
|
| 317 |
+
// wave17 GRID, owner item 10 β THE ORDER BELOW IS THE OWNER'S, stated verbatim:
|
| 318 |
+
// Grid Β· Chart Β· Calendar Β· Kanban Β· Time series Β· Map Β· List.
|
| 319 |
+
//
|
| 320 |
+
// β It supersedes the two orderings this list has carried before it, and the reasoning that
|
| 321 |
+
// produced them is now WRONG rather than merely outranked, so it is not left here to be
|
| 322 |
+
// re-applied: `timeseries` was "listed last⦠it belongs beside Chart", and `list` sat second
|
| 323 |
+
// as the other record-shaped mode. The owner put Time series FIFTH and List LAST. An order is
|
| 324 |
+
// a product decision, so it is asserted in `verify_icons` rather than left to a comment β
|
| 325 |
+
// nothing else on screen would go red if a future edit re-sorted it "sensibly".
|
| 326 |
export const CREATABLE_MODES: DisplayMode[] = [
|
| 327 |
"grid",
|
| 328 |
"chart",
|
|
|
|
| 329 |
"calendar",
|
| 330 |
"kanban",
|
|
|
|
| 331 |
"timeseries",
|
| 332 |
+
"map",
|
| 333 |
+
"list",
|
| 334 |
];
|
| 335 |
|
| 336 |
export const MODE_TONE: Record<DisplayMode, FolderTone> = {
|
web/src/customer-grid/theme.ts
CHANGED
|
@@ -277,27 +277,19 @@ export const COLUMN_TONE_THEME: Record<ControlTone, Partial<Theme>> = {
|
|
| 277 |
},
|
| 278 |
};
|
| 279 |
|
| 280 |
-
/**
|
| 281 |
-
* R5's second half β **a subtle row band while ANY control is active.**
|
| 282 |
-
*
|
| 283 |
-
* The columns say WHICH FIELD a control is about; this says, from anywhere on the table, THAT
|
| 284 |
-
* one is on. Alternating rows only, in the hue of the winning control (R6's
|
| 285 |
-
* filter > sort > group), and fainter than the column wash β it covers half the table, so the
|
| 286 |
-
* same 6% would read as a texture rather than a hint.
|
| 287 |
*
|
| 288 |
-
*
|
| 289 |
-
*
|
| 290 |
-
*
|
|
|
|
| 291 |
*
|
| 292 |
-
*
|
| 293 |
-
*
|
| 294 |
-
*
|
|
|
|
|
|
|
| 295 |
*/
|
| 296 |
-
export const CONTROL_BAND_THEME: Record<ControlTone, Partial<Theme>> = {
|
| 297 |
-
filter: { bgCell: washOf(LP_GREEN_DEEP, 0.035) },
|
| 298 |
-
sort: { bgCell: washOf(LP_YELLOW_DEEP, 0.035) },
|
| 299 |
-
group: { bgCell: washOf(LP_PURPLE_DEEP, 0.035) },
|
| 300 |
-
};
|
| 301 |
|
| 302 |
/**
|
| 303 |
* Wave-14 item 1 / R11 β **the yellow is dead.** `CUSTOM_FIELD_HEADER`'s
|
|
|
|
| 277 |
},
|
| 278 |
};
|
| 279 |
|
| 280 |
+
/* wave17 GRID β item 2 / owner R5: **THE ALTERNATING ROW BANDS ARE DEAD.**
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 281 |
*
|
| 282 |
+
* `CONTROL_BAND_THEME` stood here: a faint wash on every other data row while any control was
|
| 283 |
+
* active, in the winning control's hue. R5 kills it BY NAME ("kill the ALTERNATING ROW BANDS
|
| 284 |
+
* ONLY"), and is equally explicit that the involved-column cell wash and the header tints above
|
| 285 |
+
* STAY β so `COLUMN_TONE_THEME` is untouched and this is not a retreat from wave-15 item 8.
|
| 286 |
*
|
| 287 |
+
* Deleted rather than left exported-but-unused: an unused theme table is an invitation to wire it
|
| 288 |
+
* back in, and the whole point of R5 is that the table stops striping. Its other half,
|
| 289 |
+
* `useGridColumns.activeControlTone` (the whole-table winning tone, which had no other consumer),
|
| 290 |
+
* went with it; `columnTones` still owns the filter > sort > group precedence and is now the
|
| 291 |
+
* gate's subject. `verify_icons` asserts BOTH identifiers stay absent from the tree.
|
| 292 |
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 293 |
|
| 294 |
/**
|
| 295 |
* Wave-14 item 1 / R11 β **the yellow is dead.** `CUSTOM_FIELD_HEADER`'s
|
web/src/customer-grid/timeSeriesData.ts
CHANGED
|
@@ -199,6 +199,19 @@ export function deltaPct(current: number | null, prior: number | null): number |
|
|
| 199 |
return ((current - prior) / Math.abs(prior)) * 100;
|
| 200 |
}
|
| 201 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 202 |
/** Human text for a cell. `null` is "β" β the number-shaped hole, never a zero. */
|
| 203 |
export function formatTsValue(
|
| 204 |
value: number | null,
|
|
@@ -208,6 +221,26 @@ export function formatTsValue(
|
|
| 208 |
return format ? format(value) : String(value);
|
| 209 |
}
|
| 210 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 211 |
/** Human text for a delta. Refusals render as "β", and a real 0 renders as "0.0%". */
|
| 212 |
export function formatTsDelta(delta: number | null): string {
|
| 213 |
if (delta == null) return "β";
|
|
@@ -292,6 +325,153 @@ export function buildTsTable(payload: TsPayload | null): TsTable {
|
|
| 292 |
};
|
| 293 |
}
|
| 294 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 295 |
// βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 296 |
// WAVE 14 β the SHEET: custom rows (R2), delta sub-rows (item 18), sparklines, styles.
|
| 297 |
// βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
|
@@ -775,6 +955,8 @@ export function buildTsSheet(
|
|
| 775 |
customRows?: readonly TsCustomRow[];
|
| 776 |
deltas?: readonly TsDeltaKind[];
|
| 777 |
bucket: TsBucket;
|
|
|
|
|
|
|
| 778 |
}
|
| 779 |
): TsSheet {
|
| 780 |
const notes = [...table.notes];
|
|
@@ -848,9 +1030,18 @@ export function buildTsSheet(
|
|
| 848 |
agg: r.agg,
|
| 849 |
cells: r.cells,
|
| 850 |
total: r.total,
|
| 851 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 852 |
allUnanswered: r.allUnanswered,
|
| 853 |
}));
|
|
|
|
|
|
|
|
|
|
|
|
|
| 854 |
|
| 855 |
custom.forEach((r, index) => {
|
| 856 |
if (r.kind === "note") {
|
|
@@ -1030,6 +1221,20 @@ function csvCell(v: string): string {
|
|
| 1030 |
* spreadsheet, and there `β` is text that poisons a column while `0` is a lie that sums.
|
| 1031 |
* A withheld total exports empty for the same reason. A NOTE row exports its label and nothing
|
| 1032 |
* else, which is all it ever claimed.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1033 |
*/
|
| 1034 |
export function buildTsCsv(sheet: TsSheet): string {
|
| 1035 |
const head = ["Metric", ...sheet.columns.map((c) => c.label), "Total"];
|
|
@@ -1038,19 +1243,23 @@ export function buildTsCsv(sheet: TsSheet): string {
|
|
| 1038 |
lines.push(
|
| 1039 |
[
|
| 1040 |
csvCell(r.sublabel ? `${r.label} (${r.sublabel})` : r.label),
|
| 1041 |
-
...r.cells.map((c) => (
|
| 1042 |
-
r.total
|
| 1043 |
].join(",")
|
| 1044 |
);
|
| 1045 |
for (const d of r.deltas)
|
| 1046 |
lines.push(
|
| 1047 |
[
|
| 1048 |
csvCell(`${r.label} β ${d.label}${d.percent ? " (%)" : ""}`),
|
| 1049 |
-
...d.values.map((v) => (
|
| 1050 |
"",
|
| 1051 |
].join(",")
|
| 1052 |
);
|
| 1053 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1054 |
return lines.join("\r\n") + "\r\n";
|
| 1055 |
}
|
| 1056 |
|
|
|
|
| 199 |
return ((current - prior) / Math.abs(prior)) * 100;
|
| 200 |
}
|
| 201 |
|
| 202 |
+
/**
|
| 203 |
+
* wave17 item 6 β **THE sheet number format, one definition.**
|
| 204 |
+
*
|
| 205 |
+
* The panel used to inline `n.toLocaleString(undefined, {maximumFractionDigits: 2})` at three
|
| 206 |
+
* call sites and `buildTsCsv` used raw `String(value)`, which is how a download came out as
|
| 207 |
+
* `1234.5678901234` under a cell reading `1,234.57`. Item 6 says the file matches the sheet, and
|
| 208 |
+
* the only way that stays true is for both to call the same function β a second literal with the
|
| 209 |
+
* same options is a copy that agrees today.
|
| 210 |
+
*/
|
| 211 |
+
export function tsDisplayNumber(n: number): string {
|
| 212 |
+
return n.toLocaleString(undefined, { maximumFractionDigits: 2 });
|
| 213 |
+
}
|
| 214 |
+
|
| 215 |
/** Human text for a cell. `null` is "β" β the number-shaped hole, never a zero. */
|
| 216 |
export function formatTsValue(
|
| 217 |
value: number | null,
|
|
|
|
| 221 |
return format ? format(value) : String(value);
|
| 222 |
}
|
| 223 |
|
| 224 |
+
/**
|
| 225 |
+
* The same cell, for a FILE rather than for a reader.
|
| 226 |
+
*
|
| 227 |
+
* β The one place the export deliberately does NOT match the sheet: an unanswerable cell is an
|
| 228 |
+
* EMPTY FIELD, not "β". The reader here is a spreadsheet, where an em dash turns the whole column
|
| 229 |
+
* to text and `0` is a lie that sums. That rule predates item 6 and item 6 does not touch it β
|
| 230 |
+
* "formatted like the sheet" is about the numbers that EXIST.
|
| 231 |
+
*/
|
| 232 |
+
export function csvTsValue(value: number | null): string {
|
| 233 |
+
return value == null ? "" : tsDisplayNumber(value);
|
| 234 |
+
}
|
| 235 |
+
|
| 236 |
+
/** A delta, for a file. Percent rows carry the sign and the `%`, exactly as the sheet shows. */
|
| 237 |
+
export function csvTsDelta(value: number | null, percent: boolean): string {
|
| 238 |
+
if (value == null) return "";
|
| 239 |
+
return percent
|
| 240 |
+
? formatTsDelta(value)
|
| 241 |
+
: `${value > 0 ? "+" : ""}${tsDisplayNumber(value)}`;
|
| 242 |
+
}
|
| 243 |
+
|
| 244 |
/** Human text for a delta. Refusals render as "β", and a real 0 renders as "0.0%". */
|
| 245 |
export function formatTsDelta(delta: number | null): string {
|
| 246 |
if (delta == null) return "β";
|
|
|
|
| 325 |
};
|
| 326 |
}
|
| 327 |
|
| 328 |
+
// βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 329 |
+
// WAVE 17 β item 5 / owner R9: OFFER EVERYTHING, BEST-EFFORT.
|
| 330 |
+
// βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 331 |
+
//
|
| 332 |
+
// The panel used to offer only fields whose key started with `measure_`. Two things were wrong
|
| 333 |
+
// with that, and they are different problems with different fixes:
|
| 334 |
+
//
|
| 335 |
+
// 1. **It was STRICTER THAN THE SERVER, silently.** `routes_grid.py:374` accepts any field
|
| 336 |
+
// carrying a `measure` dict β the key prefix is not its rule. A PRESET measure field
|
| 337 |
+
// (`{preset: true, measure: {...}}`, the shape `aios_grid.py:445` reads) would have been
|
| 338 |
+
// hidden from the picker while the server stood ready to serve it a real series. That
|
| 339 |
+
// branch is memberless TODAY, which is exactly why this needs an assertion rather than a
|
| 340 |
+
// comment: nothing on screen would change the day one is added, and nobody would look.
|
| 341 |
+
// 2. **The numeric PRESETS have no time dimension at all** β `ar_open`, `overdue_days`,
|
| 342 |
+
// `sku_count` are values on a row, not measures over a window. R9: offer them anyway, as
|
| 343 |
+
// the current value repeated across the buckets, and DISCLOSE it. "Offered is the ruling,
|
| 344 |
+
// undisclosed is not."
|
| 345 |
+
//
|
| 346 |
+
// So eligibility is three classes, not a boolean. Everything below is pure and gated under
|
| 347 |
+
// node; the panel decides nothing about what a field IS.
|
| 348 |
+
|
| 349 |
+
export type TsFieldClass = "server" | "snapshot" | "refused";
|
| 350 |
+
|
| 351 |
+
/** The numeric types a snapshot can aggregate. Anything else has no arithmetic. */
|
| 352 |
+
const TS_SNAPSHOT_TYPES: ReadonlySet<string> = new Set(["currency", "int", "pct"]);
|
| 353 |
+
|
| 354 |
+
/**
|
| 355 |
+
* R9's aggregate, per field: **sum for currency/int, average for pct and the days family.**
|
| 356 |
+
*
|
| 357 |
+
* β THE DAYS FAMILY IS THE WHOLE REASON THIS IS NOT `type === "pct" ? avg : sum`. `days_to_pay`,
|
| 358 |
+
* `overdue_days`, `days_since` and `typical_gap_days` are all `int`, and the sum of "days to pay"
|
| 359 |
+
* across 1,500 customers is a number with no meaning that would nonetheless print, in bold, under
|
| 360 |
+
* a month heading. Matched on the KEY because the contract does not distinguish them by type and
|
| 361 |
+
* mostly leaves `agg` unset (measured: only `est_missed` declares one).
|
| 362 |
+
*
|
| 363 |
+
* A field's OWN declared `agg` wins when it has one β the contract saying so beats a heuristic.
|
| 364 |
+
*/
|
| 365 |
+
const TS_DAYS_KEY = /(^|_)days(_|$)/;
|
| 366 |
+
|
| 367 |
+
export function tsSnapshotAgg(field: { key: string; type: string; agg?: string }): "sum" | "avg" {
|
| 368 |
+
if (field.agg === "sum" || field.agg === "count") return "sum";
|
| 369 |
+
if (field.agg === "avg") return "avg";
|
| 370 |
+
if (field.type === "pct") return "avg";
|
| 371 |
+
return TS_DAYS_KEY.test(field.key) ? "avg" : "sum";
|
| 372 |
+
}
|
| 373 |
+
|
| 374 |
+
/**
|
| 375 |
+
* Which of the three ways this field can reach the sheet.
|
| 376 |
+
*
|
| 377 |
+
* `measure` FIRST and unconditionally: a measure-backed field is a real series and must never be
|
| 378 |
+
* downgraded to a flat line because it also happens to be numeric.
|
| 379 |
+
*/
|
| 380 |
+
export function classifyTsField(field: {
|
| 381 |
+
key: string;
|
| 382 |
+
type: string;
|
| 383 |
+
measure?: unknown;
|
| 384 |
+
formula?: string;
|
| 385 |
+
}): TsFieldClass {
|
| 386 |
+
if (field.measure && typeof field.measure === "object") return "server";
|
| 387 |
+
if (TS_SNAPSHOT_TYPES.has(field.type)) return "snapshot";
|
| 388 |
+
return "refused";
|
| 389 |
+
}
|
| 390 |
+
|
| 391 |
+
/**
|
| 392 |
+
* Why a field is not offered β in words, on the chip. Never a silent absence: a picker that
|
| 393 |
+
* simply omits "Status" leaves the reader hunting for a field they can see in the table.
|
| 394 |
+
*/
|
| 395 |
+
export function tsRefusalReason(field: { type: string; formula?: string }): string {
|
| 396 |
+
if (field.formula) return "a formula column has no time dimension of its own";
|
| 397 |
+
return `${field.type} is not a number, so it has nothing to plot over time`;
|
| 398 |
+
}
|
| 399 |
+
|
| 400 |
+
/**
|
| 401 |
+
* R9's synthesis: ONE current value, repeated across every bucket.
|
| 402 |
+
*
|
| 403 |
+
* β Three refusals are baked into the shape rather than left to the caller, because each of them
|
| 404 |
+
* is a way this row could state something nobody measured:
|
| 405 |
+
*
|
| 406 |
+
* 1. **`agg: "snapshot"` β so there is NO TOTAL.** `isAdditiveAgg` does not know the word, so
|
| 407 |
+
* the existing additivity law refuses the total without a second rule being written. One
|
| 408 |
+
* value repeated across twelve buckets sums to twelve times a real number.
|
| 409 |
+
* 2. **The sublabel NAMES THE DATE.** Printed under a `2026-05` heading, an undated "current
|
| 410 |
+
* value" reads as "AR open was $X in May". It was not: it is today's figure, seven times.
|
| 411 |
+
* `today` is the TENANT's parameter off `meta.today`, never the browser clock.
|
| 412 |
+
* 3. **No row at all when nothing is aggregable.** Every value blank/non-numeric yields a row
|
| 413 |
+
* of nulls (rendered "β"), not a 0 β the same asymmetry the wire's zero-fill obeys.
|
| 414 |
+
*
|
| 415 |
+
* Delta sub-rows are refused separately, in `buildTsSheet`: a flat line's period-over-period
|
| 416 |
+
* change is `+0.0%`, which looks like measured stability and is an artefact of the synthesis.
|
| 417 |
+
*/
|
| 418 |
+
export function buildTsSnapshotRow(
|
| 419 |
+
field: { key: string; label: string; type: string; agg?: string },
|
| 420 |
+
rows: readonly Record<string, unknown>[],
|
| 421 |
+
columns: readonly TsColumn[],
|
| 422 |
+
today?: string
|
| 423 |
+
): TsTableRow {
|
| 424 |
+
const agg = tsSnapshotAgg(field);
|
| 425 |
+
let sum = 0;
|
| 426 |
+
let n = 0;
|
| 427 |
+
for (const r of rows) {
|
| 428 |
+
const raw = r?.[field.key];
|
| 429 |
+
if (raw == null || raw === "") continue;
|
| 430 |
+
const v = typeof raw === "number" ? raw : Number(raw);
|
| 431 |
+
if (!Number.isFinite(v)) continue;
|
| 432 |
+
sum += v;
|
| 433 |
+
n += 1;
|
| 434 |
+
}
|
| 435 |
+
const value = n === 0 ? null : agg === "avg" ? sum / n : sum;
|
| 436 |
+
const cells: TsCell[] = columns.map((c) => ({
|
| 437 |
+
value,
|
| 438 |
+
// No delta, ever: prior === current on a flat line, and `deltaPct` would answer 0.0%.
|
| 439 |
+
delta: null,
|
| 440 |
+
partial: c.partial === true,
|
| 441 |
+
}));
|
| 442 |
+
return {
|
| 443 |
+
field: field.key,
|
| 444 |
+
label: field.label,
|
| 445 |
+
agg: "snapshot",
|
| 446 |
+
cells,
|
| 447 |
+
total: undefined,
|
| 448 |
+
allUnanswered: value == null,
|
| 449 |
+
window: {
|
| 450 |
+
kind: "snapshot",
|
| 451 |
+
label: today
|
| 452 |
+
? `Snapshot Β· the current value as of ${today}, not per period`
|
| 453 |
+
: "Snapshot Β· the current value, not per period",
|
| 454 |
+
},
|
| 455 |
+
};
|
| 456 |
+
}
|
| 457 |
+
|
| 458 |
+
/**
|
| 459 |
+
* The sheet's snapshot disclosure, said ONCE.
|
| 460 |
+
*
|
| 461 |
+
* The sublabel marks each row; this says the thing the sublabel is too short to say β that these
|
| 462 |
+
* rows are flat BY CONSTRUCTION, so a flat snapshot line is not a finding.
|
| 463 |
+
*/
|
| 464 |
+
export function tsSnapshotNote(labels: readonly string[], today?: string): string {
|
| 465 |
+
const which = labels.length === 1 ? labels[0] : `${labels.length} rows`;
|
| 466 |
+
return (
|
| 467 |
+
`${which} ${labels.length === 1 ? "has" : "have"} no time dimension, so ` +
|
| 468 |
+
`${labels.length === 1 ? "it is" : "they are"} shown as the current value` +
|
| 469 |
+
`${today ? ` as of ${today}` : ""} repeated across every period β a flat line here means ` +
|
| 470 |
+
`"not measured over time", not "unchanged". No total and no comparison is offered for ` +
|
| 471 |
+
`${labels.length === 1 ? "it" : "them"}.`
|
| 472 |
+
);
|
| 473 |
+
}
|
| 474 |
+
|
| 475 |
// βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 476 |
// WAVE 14 β the SHEET: custom rows (R2), delta sub-rows (item 18), sparklines, styles.
|
| 477 |
// βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
|
|
|
| 955 |
customRows?: readonly TsCustomRow[];
|
| 956 |
deltas?: readonly TsDeltaKind[];
|
| 957 |
bucket: TsBucket;
|
| 958 |
+
/** wave17 item 5 β the TENANT's today, for the snapshot note. Never the browser clock. */
|
| 959 |
+
today?: string;
|
| 960 |
}
|
| 961 |
): TsSheet {
|
| 962 |
const notes = [...table.notes];
|
|
|
|
| 1030 |
agg: r.agg,
|
| 1031 |
cells: r.cells,
|
| 1032 |
total: r.total,
|
| 1033 |
+
// wave17 item 5 / R9 β a SNAPSHOT row gets NO comparisons. Its line is flat by
|
| 1034 |
+
// construction, so every delta would compute as exactly +0.0%: a number that looks like
|
| 1035 |
+
// measured stability and is an artefact of repeating one value. `deltaPct` already refuses
|
| 1036 |
+
// three cases to avoid inventing a figure; this is the fourth, and it has to be refused
|
| 1037 |
+
// HERE because the arithmetic itself would succeed.
|
| 1038 |
+
deltas: r.agg === "snapshot" ? [] : buildTsDeltas(r, kinds, opts.bucket),
|
| 1039 |
allUnanswered: r.allUnanswered,
|
| 1040 |
}));
|
| 1041 |
+
// Said once, for all of them β the sublabel marks each row, this explains the flat line.
|
| 1042 |
+
const snapshots = table.rows.filter((r) => r.agg === "snapshot");
|
| 1043 |
+
if (snapshots.length > 0)
|
| 1044 |
+
notes.push(tsSnapshotNote(snapshots.map((r) => r.label), opts.today));
|
| 1045 |
|
| 1046 |
custom.forEach((r, index) => {
|
| 1047 |
if (r.kind === "note") {
|
|
|
|
| 1221 |
* spreadsheet, and there `β` is text that poisons a column while `0` is a lie that sums.
|
| 1222 |
* A withheld total exports empty for the same reason. A NOTE row exports its label and nothing
|
| 1223 |
* else, which is all it ever claimed.
|
| 1224 |
+
*
|
| 1225 |
+
* ββ wave17 item 6: "as shown" now means it, for the NUMBERS too βββββββββββββββββββββββββββββ
|
| 1226 |
+
*
|
| 1227 |
+
* Every value goes through `tsDisplayNumber` β the same function the panel's cells call β so a
|
| 1228 |
+
* cell reading `1,234.57` no longer downloads as `1234.5678901234`. Two consequences worth
|
| 1229 |
+
* knowing rather than rediscovering:
|
| 1230 |
+
*
|
| 1231 |
+
* Β· A grouped number contains a COMMA, so `csvCell` quotes it. That is RFC-4180 and both
|
| 1232 |
+
* Excel and Sheets parse `"1,234.57"` as a number. It is a deliberate trade: the owner asked
|
| 1233 |
+
* for the file to match the sheet, and matching a sheet that groups thousands means grouping.
|
| 1234 |
+
* Β· The FOOTNOTES now travel with the file. They were on the sheet and not in the export,
|
| 1235 |
+
* which meant the one document a reader keeps was the one without the disclosures β the
|
| 1236 |
+
* dropped fields, the partial periods, the snapshot rows that are flat by construction.
|
| 1237 |
+
* Appended at the END, after a blank line, so every column of data stays rectangular.
|
| 1238 |
*/
|
| 1239 |
export function buildTsCsv(sheet: TsSheet): string {
|
| 1240 |
const head = ["Metric", ...sheet.columns.map((c) => c.label), "Total"];
|
|
|
|
| 1243 |
lines.push(
|
| 1244 |
[
|
| 1245 |
csvCell(r.sublabel ? `${r.label} (${r.sublabel})` : r.label),
|
| 1246 |
+
...r.cells.map((c) => csvCell(csvTsValue(c.value))),
|
| 1247 |
+
csvCell(csvTsValue(r.total ?? null)),
|
| 1248 |
].join(",")
|
| 1249 |
);
|
| 1250 |
for (const d of r.deltas)
|
| 1251 |
lines.push(
|
| 1252 |
[
|
| 1253 |
csvCell(`${r.label} β ${d.label}${d.percent ? " (%)" : ""}`),
|
| 1254 |
+
...d.values.map((v) => csvCell(csvTsDelta(v, d.percent))),
|
| 1255 |
"",
|
| 1256 |
].join(",")
|
| 1257 |
);
|
| 1258 |
}
|
| 1259 |
+
if (sheet.notes.length > 0) {
|
| 1260 |
+
lines.push("");
|
| 1261 |
+
for (const n of sheet.notes) lines.push(csvCell(n));
|
| 1262 |
+
}
|
| 1263 |
return lines.join("\r\n") + "\r\n";
|
| 1264 |
}
|
| 1265 |
|
web/src/customer-grid/types.ts
CHANGED
|
@@ -768,8 +768,15 @@ export interface Field {
|
|
| 768 |
* β `options` stays the select-family list; top-level properties are the established
|
| 769 |
* pattern (`measure`, `multi`). Evaluated CLIENT-side by formulaEngine.ts over the row;
|
| 770 |
* host validation is structural only. The host re-emits formula fields as source 'odoo' +
|
| 771 |
-
* `derived`
|
| 772 |
-
*
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 773 |
*/
|
| 774 |
formula?: string;
|
| 775 |
/**
|
|
@@ -1386,7 +1393,23 @@ export interface ViewConfig {
|
|
| 1386 |
cohortLock?: string;
|
| 1387 |
}
|
| 1388 |
|
| 1389 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1390 |
|
| 1391 |
export interface SavedView {
|
| 1392 |
/** C4 β the folder this view sits in; null/absent = root. */
|
|
|
|
| 768 |
* β `options` stays the select-family list; top-level properties are the established
|
| 769 |
* pattern (`measure`, `multi`). Evaluated CLIENT-side by formulaEngine.ts over the row;
|
| 770 |
* host validation is structural only. The host re-emits formula fields as source 'odoo' +
|
| 771 |
+
* `derived`, and the client creates them in exactly that shape.
|
| 772 |
+
*
|
| 773 |
+
* β CORRECTED 2026-08-03 (wave17 C-FRM(c)). This note said `filterable:false`, citing CG-3's
|
| 774 |
+
* "a client-computed column must not enter the server-side count path". **Wave-6 item 6
|
| 775 |
+
* flipped it to `filterable: true` on BOTH runtimes** β `aios_grid.py`'s READONLY_CUSTOM_TYPES
|
| 776 |
+
* branch and `buildOverlayField` β because a formula's values live client-side, this table's
|
| 777 |
+
* counts are client-mode, and the windowed count path never sees these tables. CG-3 still
|
| 778 |
+
* holds; it simply never applied here. The prose had been wrong for a wave while the code was
|
| 779 |
+
* right, which is why `verify_formula_engine` now asserts it (and drives it red both ways).
|
| 780 |
*/
|
| 781 |
formula?: string;
|
| 782 |
/**
|
|
|
|
| 1393 |
cohortLock?: string;
|
| 1394 |
}
|
| 1395 |
|
| 1396 |
+
/**
|
| 1397 |
+
* wave17 R1 / contract C-LOCKV β **`"locked"` joins the vocabulary, and it is the whole of the
|
| 1398 |
+
* client's model of a locked view.**
|
| 1399 |
+
*
|
| 1400 |
+
* A cohort is no longer a separate object with its own rail section, its own projection and its
|
| 1401 |
+
* own selection state. The host PROJECTS each one as an ordinary saved view whose id IS the
|
| 1402 |
+
* cohort id and whose `config.cohortLock` names that same id
|
| 1403 |
+
* (`aios_grid.locked_view_projection`), so the shipped engine law does all the narrowing and the
|
| 1404 |
+
* client's only job is to wear the mark.
|
| 1405 |
+
*
|
| 1406 |
+
* β NOT to be confused with `SavedView.locked` below, which is the legacy mode-frozen flag and
|
| 1407 |
+
* is deliberately NOT set on these β a locked view reorders, files into folders, renames, sorts,
|
| 1408 |
+
* filters and changes display mode like any other. `kind` says whose ROWS they are; `locked`
|
| 1409 |
+
* says whether the display mode is frozen. Two different words that both read as "locked" is a
|
| 1410 |
+
* genuine trap, which is why both are documented at their definitions.
|
| 1411 |
+
*/
|
| 1412 |
+
export type ViewKind = "system" | "list" | "custom" | "locked";
|
| 1413 |
|
| 1414 |
export interface SavedView {
|
| 1415 |
/** C4 β the folder this view sits in; null/absent = root. */
|
web/src/customer-grid/useGridColumns.ts
CHANGED
|
@@ -102,7 +102,12 @@ function columnTheme(tone: ControlTone | undefined): Partial<Theme> | undefined
|
|
| 102 |
* changes a colour on screen and nothing else, so it is stated here rather than left to be
|
| 103 |
* re-derived from the sequence.
|
| 104 |
*/
|
| 105 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 106 |
const out = new Map<string, ControlTone>();
|
| 107 |
if (config.groupBy) out.set(config.groupBy, "group");
|
| 108 |
for (const s of config.sorts ?? []) out.set(s.colId, "sort");
|
|
@@ -112,21 +117,6 @@ function columnTones(config: ViewConfig): Map<string, ControlTone> {
|
|
| 112 |
return out;
|
| 113 |
}
|
| 114 |
|
| 115 |
-
/**
|
| 116 |
-
* R5's second half β the WINNING control for the whole table, or undefined when none is active.
|
| 117 |
-
*
|
| 118 |
-
* Same precedence as `columnTones`, stated once here rather than re-derived: the row band and
|
| 119 |
-
* the involved columns must agree about which control is "the" one, or the table would band in
|
| 120 |
-
* green while its only hued column was yellow.
|
| 121 |
-
*/
|
| 122 |
-
export function activeControlTone(config: ViewConfig): ControlTone | undefined {
|
| 123 |
-
const filtered = new Set<string>();
|
| 124 |
-
filteredKeys(config.filters ?? [], filtered);
|
| 125 |
-
if (filtered.size > 0) return "filter";
|
| 126 |
-
if ((config.sorts ?? []).length > 0) return "sort";
|
| 127 |
-
return config.groupBy ? "group" : undefined;
|
| 128 |
-
}
|
| 129 |
-
|
| 130 |
function isDefaultVisible(field: Field): boolean {
|
| 131 |
return field.default !== false || field.source === "overlay";
|
| 132 |
}
|
|
|
|
| 102 |
* changes a colour on screen and nothing else, so it is stated here rather than left to be
|
| 103 |
* re-derived from the sequence.
|
| 104 |
*/
|
| 105 |
+
/* wave17 GRID β item 2 / owner R5. EXPORTED, and only since the row band died.
|
| 106 |
+
`activeControlTone` used to sit below this function and restate the same precedence for the
|
| 107 |
+
whole-table band; the band was its only consumer, so R5 took both. That left the surviving
|
| 108 |
+
precedence β the one that still paints β asserted by nothing, because `verify_icons` was
|
| 109 |
+
testing the twin. Exported so the gate can reach the function that is actually on screen. */
|
| 110 |
+
export function columnTones(config: ViewConfig): Map<string, ControlTone> {
|
| 111 |
const out = new Map<string, ControlTone>();
|
| 112 |
if (config.groupBy) out.set(config.groupBy, "group");
|
| 113 |
for (const s of config.sorts ?? []) out.set(s.colId, "sort");
|
|
|
|
| 117 |
return out;
|
| 118 |
}
|
| 119 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 120 |
function isDefaultVisible(field: Field): boolean {
|
| 121 |
return field.default !== false || field.source === "overlay";
|
| 122 |
}
|
web/src/customer-grid/viewModes.tsx
CHANGED
|
@@ -18,7 +18,7 @@
|
|
| 18 |
// the display cap stays the grid's own "Showing first N" bar.
|
| 19 |
// ---------------------------------------------------------------------------
|
| 20 |
|
| 21 |
-
import { memo, useMemo, useRef, useState } from "react";
|
| 22 |
import type { DragEvent } from "react";
|
| 23 |
import { choiceOptions } from "./types";
|
| 24 |
import type { DisplayMode, Field, Row, VisibleRow } from "./types";
|
|
@@ -39,7 +39,10 @@ const AGG_LABELS: Record<ChartAgg, string> = {
|
|
| 39 |
import { formatDisplay } from "./cells";
|
| 40 |
import { optionTint } from "./choiceColors";
|
| 41 |
import { CREATABLE_MODES, MODE_LABELS } from "./iconShapes";
|
| 42 |
-
import { LockMark, ModeIcon } from "./icons";
|
|
|
|
|
|
|
|
|
|
| 43 |
import { FieldSelectButton } from "./FieldSelect";
|
| 44 |
import { Popover } from "../filter-kit";
|
| 45 |
|
|
@@ -47,6 +50,30 @@ import { Popover } from "../filter-kit";
|
|
| 47 |
* never a silent one (the stack header always carries the full count). */
|
| 48 |
const KANBAN_PAGE = 50;
|
| 49 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 50 |
// ------------------------------------------------------------- the switcher
|
| 51 |
|
| 52 |
export function ModeSwitch({
|
|
@@ -203,22 +230,56 @@ export function ModeSwitch({
|
|
| 203 |
{clamped ? "Short cards" : "Full cards"}
|
| 204 |
</button>
|
| 205 |
)}
|
| 206 |
-
{/* Owner item 4 (C-DISP) β records vs summaries.
|
| 207 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 208 |
{mode === "calendar" && onCalendarMode && (
|
| 209 |
-
<
|
| 210 |
-
|
| 211 |
-
|
| 212 |
-
|
| 213 |
-
|
| 214 |
-
|
| 215 |
-
calendarMode === "summary"
|
| 216 |
-
? "Each day shows totals. Click to list the records instead."
|
| 217 |
-
: "Each day lists its records. Click to show totals instead."
|
| 218 |
-
}
|
| 219 |
>
|
| 220 |
-
{
|
| 221 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 222 |
)}
|
| 223 |
{/* Item 4 β the metric PICKER, and it is what makes the item's "count/sum/avg" true.
|
| 224 |
Without it `summaryMetrics` can only ever be the always-on Records count, so a
|
|
@@ -264,6 +325,9 @@ export function ModeSwitch({
|
|
| 264 |
onCalendarMetrics(next);
|
| 265 |
}}
|
| 266 |
/>
|
|
|
|
|
|
|
|
|
|
| 267 |
<span className="cg-check-label">{f.label}</span>
|
| 268 |
</label>
|
| 269 |
{chosen && (
|
|
@@ -443,6 +507,7 @@ export const CalendarView = memo(function CalendarView({
|
|
| 443 |
mode = "records",
|
| 444 |
metrics,
|
| 445 |
fieldByKey,
|
|
|
|
| 446 |
onOpen,
|
| 447 |
}: {
|
| 448 |
/** DISTINCT data rows from the full pipeline (never the display slice β a
|
|
@@ -457,6 +522,9 @@ export const CalendarView = memo(function CalendarView({
|
|
| 457 |
/** The aggregates a summary day shows. Count of records is always shown first. */
|
| 458 |
metrics?: { id: string; field: string; agg: string }[];
|
| 459 |
fieldByKey?: Map<string, Field>;
|
|
|
|
|
|
|
|
|
|
| 460 |
onOpen: (pid: number) => void;
|
| 461 |
}) {
|
| 462 |
const entries = useMemo(
|
|
@@ -518,6 +586,64 @@ export const CalendarView = memo(function CalendarView({
|
|
| 518 |
return out;
|
| 519 |
}, [metrics, fieldByKey]);
|
| 520 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 521 |
if (!shown) {
|
| 522 |
return (
|
| 523 |
<div className="cg-mode-empty">
|
|
@@ -578,6 +704,19 @@ export const CalendarView = memo(function CalendarView({
|
|
| 578 |
{noDate.toLocaleString()} without a date
|
| 579 |
</span>
|
| 580 |
)}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 581 |
</div>
|
| 582 |
<div className="cg-cal-grid">
|
| 583 |
{["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"].map((d) => (
|
|
@@ -598,22 +737,47 @@ export const CalendarView = memo(function CalendarView({
|
|
| 598 |
? day &&
|
| 599 |
bucket.length > 0 &&
|
| 600 |
summaryMetrics.map((m) => {
|
| 601 |
-
|
| 602 |
-
|
| 603 |
-
|
| 604 |
-
|
| 605 |
-
|
| 606 |
-
|
| 607 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 608 |
return (
|
| 609 |
<div key={m.id} className="cg-cal-metric">
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 610 |
<span className="cg-cal-metric-k">{m.label}</span>
|
| 611 |
<span className="cg-cal-metric-v">
|
| 612 |
{/* "β" when the day held no usable value. A 0 here would be a
|
| 613 |
-
measurement nobody made.
|
|
|
|
|
|
|
|
|
|
|
|
|
| 614 |
{v == null
|
| 615 |
? "β"
|
| 616 |
-
:
|
|
|
|
|
|
|
| 617 |
</span>
|
| 618 |
</div>
|
| 619 |
);
|
|
|
|
| 18 |
// the display cap stays the grid's own "Showing first N" bar.
|
| 19 |
// ---------------------------------------------------------------------------
|
| 20 |
|
| 21 |
+
import { memo, useEffect, useMemo, useRef, useState } from "react";
|
| 22 |
import type { DragEvent } from "react";
|
| 23 |
import { choiceOptions } from "./types";
|
| 24 |
import type { DisplayMode, Field, Row, VisibleRow } from "./types";
|
|
|
|
| 39 |
import { formatDisplay } from "./cells";
|
| 40 |
import { optionTint } from "./choiceColors";
|
| 41 |
import { CREATABLE_MODES, MODE_LABELS } from "./iconShapes";
|
| 42 |
+
import { FieldTypeIcon, LockMark, ModeIcon } from "./icons";
|
| 43 |
+
import { fetchCalendarMetrics } from "./apiBridge";
|
| 44 |
+
import type { SurfaceScope } from "./apiBridge";
|
| 45 |
+
import { classifyTsField } from "./timeSeriesData";
|
| 46 |
import { FieldSelectButton } from "./FieldSelect";
|
| 47 |
import { Popover } from "../filter-kit";
|
| 48 |
|
|
|
|
| 50 |
* never a silent one (the stack header always carries the full count). */
|
| 51 |
const KANBAN_PAGE = 50;
|
| 52 |
|
| 53 |
+
/**
|
| 54 |
+
* wave17 owner item 8 β the Records/Summaries popover's mark: one day cell with contents.
|
| 55 |
+
*
|
| 56 |
+
* Private to this file, matching `Toolbar.tsx`'s own `Icon*` set. Deliberately NOT `ModeIcon
|
| 57 |
+
* mode="calendar"` (the whole bar is already the calendar's) and NOT a glyph that changes with
|
| 58 |
+
* the state β a trigger whose picture moves is a different button each time you look for it,
|
| 59 |
+
* which is half of what item 8 is fixing.
|
| 60 |
+
*/
|
| 61 |
+
function IconDayCells() {
|
| 62 |
+
const s = {
|
| 63 |
+
stroke: "currentColor",
|
| 64 |
+
strokeWidth: 1.5,
|
| 65 |
+
strokeLinecap: "round" as const,
|
| 66 |
+
strokeLinejoin: "round" as const,
|
| 67 |
+
fill: "none",
|
| 68 |
+
};
|
| 69 |
+
return (
|
| 70 |
+
<svg width="14" height="14" viewBox="0 0 16 16" aria-hidden>
|
| 71 |
+
<rect x="2.5" y="3" width="11" height="10" rx="1.5" {...s} />
|
| 72 |
+
<path d="M5 7.5h6M5 10h4" {...s} />
|
| 73 |
+
</svg>
|
| 74 |
+
);
|
| 75 |
+
}
|
| 76 |
+
|
| 77 |
// ------------------------------------------------------------- the switcher
|
| 78 |
|
| 79 |
export function ModeSwitch({
|
|
|
|
| 230 |
{clamped ? "Short cards" : "Full cards"}
|
| 231 |
</button>
|
| 232 |
)}
|
| 233 |
+
{/* Owner item 4 (C-DISP) β records vs summaries.
|
| 234 |
+
wave17 owner item 8 β it WAS a bare toggle whose label was its own state, sitting in a
|
| 235 |
+
bar where every other control opens a panel. Two things were wrong with that beyond
|
| 236 |
+
the inconsistency: a toggle shows you the state you are IN and hides the one you could
|
| 237 |
+
switch to, and a label that changes identity ("Records" β "Summaries") is a different
|
| 238 |
+
button each time you look for it.
|
| 239 |
+
|
| 240 |
+
A `Popover` with radio rows fixes both β the trigger keeps ONE name and both choices
|
| 241 |
+
are visible with the current one marked β and it is the same component Filter / Sort /
|
| 242 |
+
Group / Totals mount, which is what item 8 asks for. */}
|
| 243 |
{mode === "calendar" && onCalendarMode && (
|
| 244 |
+
<Popover
|
| 245 |
+
label={`Day cells Β· ${calendarMode === "summary" ? "Summaries" : "Records"}`}
|
| 246 |
+
icon={<IconDayCells />}
|
| 247 |
+
// Lit while the NON-default choice is on, matching every other toolbar control: an
|
| 248 |
+
// always-active button is decoration, not a state.
|
| 249 |
+
active={calendarMode === "summary"}
|
|
|
|
|
|
|
|
|
|
|
|
|
| 250 |
>
|
| 251 |
+
{(close) => (
|
| 252 |
+
<div className="cg-pop-body">
|
| 253 |
+
<div className="cg-pop-title">Each day shows</div>
|
| 254 |
+
{(
|
| 255 |
+
[
|
| 256 |
+
["records", "Records", "The records that fall on that day, listed."],
|
| 257 |
+
["summary", "Summaries", "Totals computed over that day's records."],
|
| 258 |
+
] as const
|
| 259 |
+
).map(([value, label, help]) => (
|
| 260 |
+
<label key={value} className="cg-radio-row">
|
| 261 |
+
<input
|
| 262 |
+
type="radio"
|
| 263 |
+
name="cg-cal-mode"
|
| 264 |
+
checked={
|
| 265 |
+
value === "summary"
|
| 266 |
+
? calendarMode === "summary"
|
| 267 |
+
: calendarMode !== "summary"
|
| 268 |
+
}
|
| 269 |
+
onChange={() => {
|
| 270 |
+
onCalendarMode(value);
|
| 271 |
+
close();
|
| 272 |
+
}}
|
| 273 |
+
/>
|
| 274 |
+
<span className="cg-check-label">
|
| 275 |
+
{label}
|
| 276 |
+
<span className="cg-pop-note cg-radio-help">{help}</span>
|
| 277 |
+
</span>
|
| 278 |
+
</label>
|
| 279 |
+
))}
|
| 280 |
+
</div>
|
| 281 |
+
)}
|
| 282 |
+
</Popover>
|
| 283 |
)}
|
| 284 |
{/* Item 4 β the metric PICKER, and it is what makes the item's "count/sum/avg" true.
|
| 285 |
Without it `summaryMetrics` can only ever be the always-on Records count, so a
|
|
|
|
| 325 |
onCalendarMetrics(next);
|
| 326 |
}}
|
| 327 |
/>
|
| 328 |
+
{/* wave17 item 9 β the SAME type mark the day cell will wear, so the row
|
| 329 |
+
you tick and the figure you get are recognisably the same thing. */}
|
| 330 |
+
<FieldTypeIcon type={f.type} size={11} />
|
| 331 |
<span className="cg-check-label">{f.label}</span>
|
| 332 |
</label>
|
| 333 |
{chosen && (
|
|
|
|
| 507 |
mode = "records",
|
| 508 |
metrics,
|
| 509 |
fieldByKey,
|
| 510 |
+
scope = "customer",
|
| 511 |
onOpen,
|
| 512 |
}: {
|
| 513 |
/** DISTINCT data rows from the full pipeline (never the display slice β a
|
|
|
|
| 522 |
/** The aggregates a summary day shows. Count of records is always shown first. */
|
| 523 |
metrics?: { id: string; field: string; agg: string }[];
|
| 524 |
fieldByKey?: Map<string, Field>;
|
| 525 |
+
/** wave17 item 9 / C-CAL β which surface the day-grain channel is asked about. The server
|
| 526 |
+
* REFUSES `product` in words (measures are customer-grain), so this is never free text. */
|
| 527 |
+
scope?: SurfaceScope;
|
| 528 |
onOpen: (pid: number) => void;
|
| 529 |
}) {
|
| 530 |
const entries = useMemo(
|
|
|
|
| 586 |
return out;
|
| 587 |
}, [metrics, fieldByKey]);
|
| 588 |
|
| 589 |
+
/**
|
| 590 |
+
* β wave17 owner item 9 / ruling R4 β **A MEASURE IN A DAY CELL IS COMPUTED AS OF THAT DAY.**
|
| 591 |
+
*
|
| 592 |
+
* The client used to aggregate the ROW VALUES it already held. For a measure column that means
|
| 593 |
+
* "every member's year-to-date **as of today**", summed and printed in a cell labelled 14
|
| 594 |
+
* March. The arithmetic was fine and the claim was false, which is the only kind of wrong this
|
| 595 |
+
* surface produces. R4 sends the day back to the server (C-CAL) and lets each metric's own
|
| 596 |
+
* window slide to it.
|
| 597 |
+
*
|
| 598 |
+
* β Only MEASURE-backed fields go over the wire. A static numeric column has no window to
|
| 599 |
+
* slide, so the client-side aggregation below stays exactly correct for it β and sending it
|
| 600 |
+
* would invite a second implementation of arithmetic that already works.
|
| 601 |
+
*
|
| 602 |
+
* β The request is bounded to the server's OWN caps (31 days, 6 fields) by construction: a
|
| 603 |
+
* month has at most 31 days and `MAX_CALENDAR_METRICS` is under 6. If either ever grows past
|
| 604 |
+
* the other, the server answers 400 with its reason and this renders "β" β a refusal, never a
|
| 605 |
+
* silent trim.
|
| 606 |
+
*/
|
| 607 |
+
const measureMetricKeys = useMemo(
|
| 608 |
+
() =>
|
| 609 |
+
summaryMetrics
|
| 610 |
+
// `classifyTsField`, not a local `field.measure` test. The server's rule for "is this a
|
| 611 |
+
// measure" is one rule (`routes_grid.py` applies it to BOTH channels), so the client
|
| 612 |
+
// states it once too β and it arrives already gated, including the case that would
|
| 613 |
+
// otherwise be silent: a PRESET measure field, which has a `measure` and no `measure_`
|
| 614 |
+
// key prefix.
|
| 615 |
+
.filter((m) => m.field && classifyTsField(m.field) === "server")
|
| 616 |
+
.map((m) => m.field!.key),
|
| 617 |
+
[summaryMetrics]
|
| 618 |
+
);
|
| 619 |
+
const [dayValues, setDayValues] = useState<
|
| 620 |
+
Record<string, Record<string, number | null>>
|
| 621 |
+
>({});
|
| 622 |
+
const [dayWindows, setDayWindows] = useState<Record<string, { label: string }>>({});
|
| 623 |
+
const calReq = useRef(0);
|
| 624 |
+
useEffect(() => {
|
| 625 |
+
// Nothing measure-backed on screen, or not in summary mode: no request, and clear anything
|
| 626 |
+
// a previous month left behind so a stale day can never paint under a new heading.
|
| 627 |
+
if (mode !== "summary" || !measureMetricKeys.length || byDay.size === 0) {
|
| 628 |
+
setDayValues({});
|
| 629 |
+
setDayWindows({});
|
| 630 |
+
return;
|
| 631 |
+
}
|
| 632 |
+
const groups = [...byDay.entries()].map(([key, list]) => ({
|
| 633 |
+
key,
|
| 634 |
+
pids: list.map((e) => e.pid),
|
| 635 |
+
}));
|
| 636 |
+
const seq = ++calReq.current;
|
| 637 |
+
fetchCalendarMetrics({ groups, fields: measureMetricKeys }, scope).then(({ payload }) => {
|
| 638 |
+
// The last month the user asked for wins, not the last response to arrive β the
|
| 639 |
+
// `fetchTimeseries` guard, for the same reason: paging months is fast and the answers
|
| 640 |
+
// are not ordered.
|
| 641 |
+
if (seq !== calReq.current) return;
|
| 642 |
+
setDayValues(payload?.values ?? {});
|
| 643 |
+
setDayWindows(payload?.windows ?? {});
|
| 644 |
+
});
|
| 645 |
+
}, [mode, measureMetricKeys, byDay, scope]);
|
| 646 |
+
|
| 647 |
if (!shown) {
|
| 648 |
return (
|
| 649 |
<div className="cg-mode-empty">
|
|
|
|
| 704 |
{noDate.toLocaleString()} without a date
|
| 705 |
</span>
|
| 706 |
)}
|
| 707 |
+
{/* wave17 item 9 / R4 + C-TSWIN at day grain. WITHOUT this line a cumulative metric and
|
| 708 |
+
a periodic one look identical in a day cell β "$40,120" under 14 March is either
|
| 709 |
+
that day's sales or the year to date, and the cell cannot say which. HOST returns
|
| 710 |
+
the label per field precisely so a reader can see it. Said once in the header rather
|
| 711 |
+
than in all 31 cells. */}
|
| 712 |
+
{mode === "summary" &&
|
| 713 |
+
summaryMetrics
|
| 714 |
+
.filter((m) => m.field && dayWindows[m.field.key]?.label)
|
| 715 |
+
.map((m) => (
|
| 716 |
+
<span key={m.id} className="cg-cal-window">
|
| 717 |
+
{m.label} Β· {dayWindows[m.field!.key].label}, as of each day
|
| 718 |
+
</span>
|
| 719 |
+
))}
|
| 720 |
</div>
|
| 721 |
<div className="cg-cal-grid">
|
| 722 |
{["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"].map((d) => (
|
|
|
|
| 737 |
? day &&
|
| 738 |
bucket.length > 0 &&
|
| 739 |
summaryMetrics.map((m) => {
|
| 740 |
+
// wave17 item 9 / R4 β a measure reads its AS-OF-THAT-DAY answer from the
|
| 741 |
+
// channel; everything else keeps the client aggregation, which is still
|
| 742 |
+
// exactly right for a column with no window.
|
| 743 |
+
const served = m.field ? dayValues[m.field.key] : undefined;
|
| 744 |
+
let v: number | null;
|
| 745 |
+
if (served) {
|
| 746 |
+
// `undefined` (the field was dropped) and `null` (unanswered) are the same
|
| 747 |
+
// thing to a reader and both draw "β". Neither is 0.
|
| 748 |
+
v = served[iso] ?? null;
|
| 749 |
+
} else {
|
| 750 |
+
const vals: number[] = [];
|
| 751 |
+
if (m.field)
|
| 752 |
+
for (const e of bucket) {
|
| 753 |
+
const n = asChartNumber(e.row[m.field.key]);
|
| 754 |
+
if (n != null) vals.push(n);
|
| 755 |
+
}
|
| 756 |
+
v = aggregateOrNull(m.agg, vals, bucket.length);
|
| 757 |
+
}
|
| 758 |
return (
|
| 759 |
<div key={m.id} className="cg-cal-metric">
|
| 760 |
+
{/* wave17 item 9 β the field's TYPE mark, so a row of figures in a
|
| 761 |
+
crowded cell says what KIND of number each one is without the label
|
| 762 |
+
having to carry "$" or "%". The Records row has no field and wears
|
| 763 |
+
the `int` mark: it is a count of rows. */}
|
| 764 |
+
<FieldTypeIcon
|
| 765 |
+
type={m.field ? m.field.type : "int"}
|
| 766 |
+
size={11}
|
| 767 |
+
/>
|
| 768 |
<span className="cg-cal-metric-k">{m.label}</span>
|
| 769 |
<span className="cg-cal-metric-v">
|
| 770 |
{/* "β" when the day held no usable value. A 0 here would be a
|
| 771 |
+
measurement nobody made.
|
| 772 |
+
wave17 item 9 β formatted with the FIELD's own formatter, not a
|
| 773 |
+
bare toLocaleString: a currency column printed as "12345.67" in a
|
| 774 |
+
day cell and as "$12,345.67" one view away is the same number
|
| 775 |
+
claiming to be two. */}
|
| 776 |
{v == null
|
| 777 |
? "β"
|
| 778 |
+
: m.field
|
| 779 |
+
? formatDisplay(m.field, v)
|
| 780 |
+
: v.toLocaleString()}
|
| 781 |
</span>
|
| 782 |
</div>
|
| 783 |
);
|
web/src/index.css
CHANGED
|
@@ -1551,6 +1551,19 @@ body {
|
|
| 1551 |
overflow: hidden;
|
| 1552 |
text-overflow: ellipsis;
|
| 1553 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1554 |
/* R7 (2026-08-02) β the RADIO rows never got the treatment their checkbox twins have had
|
| 1555 |
since wave 2, and they are the ones that list FIELD LABELS (the Group-by popover): a
|
| 1556 |
two-line "Estimated missed revenue, last 12 months" pushed the row below it out of the
|
|
@@ -2526,6 +2539,59 @@ body {
|
|
| 2526 |
border-top-style: dashed;
|
| 2527 |
}
|
| 2528 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2529 |
/* ---- shell (wave 4, 2026-07-27; EXIT wave 1 door + nav, 2026-07-30) --------
|
| 2530 |
Renders ONLY when the bundle is NOT hosted (App.tsx branch) β the embed
|
| 2531 |
never sees these classes. Every color/measure is a named token (anti-slop
|
|
@@ -2948,9 +3014,15 @@ body {
|
|
| 2948 |
.shell-nav-item:hover { background: var(--lp-surface-2); }
|
| 2949 |
.shell-nav-item.is-child { padding-left: 30px; }
|
| 2950 |
/* The current row is marked the way the host marks it: the selected-row tint,
|
| 2951 |
-
weight, and the icon at full strength β no accent stripe (wave-10 I25a).
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2952 |
.shell-nav-item.is-active {
|
| 2953 |
-
background: var(--lp-blue-tint);
|
| 2954 |
font-weight: 600;
|
| 2955 |
}
|
| 2956 |
.shell-nav-item:focus-visible { outline: 2px solid var(--lp-blue-deep); outline-offset: -2px; }
|
|
@@ -3034,6 +3106,25 @@ body {
|
|
| 3034 |
line-height: var(--lp-lh);
|
| 3035 |
color: var(--lp-muted);
|
| 3036 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3037 |
|
| 3038 |
.shell-side-bottom {
|
| 3039 |
margin-top: auto;
|
|
@@ -4073,16 +4164,26 @@ a.cg-map-ctl-b { text-decoration: none; }
|
|
| 4073 |
gap: 6px;
|
| 4074 |
color: var(--cg-muted);
|
| 4075 |
}
|
| 4076 |
-
.cg-count-loaddot
|
| 4077 |
-
|
| 4078 |
-
|
| 4079 |
-
|
| 4080 |
-
|
| 4081 |
-
|
| 4082 |
-
|
| 4083 |
-
|
| 4084 |
-
|
| 4085 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 4086 |
}
|
| 4087 |
|
| 4088 |
/* Item W2 (C2) β the export format pane's small title line above the menuitems. */
|
|
@@ -4330,7 +4431,20 @@ a.cg-map-ctl-b { text-decoration: none; }
|
|
| 4330 |
text-overflow: ellipsis;
|
| 4331 |
white-space: nowrap;
|
| 4332 |
}
|
| 4333 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 4334 |
.cg-fold-rename { flex: 1 1 auto; height: 24px; font-weight: 400; }
|
| 4335 |
.cg-fold-empty {
|
| 4336 |
padding: 4px 10px 6px 24px;
|
|
@@ -5144,6 +5258,18 @@ a.cg-map-ctl-b { text-decoration: none; }
|
|
| 5144 |
.set-close:focus-visible { outline: 2px solid var(--lp-blue-deep); outline-offset: 1px; }
|
| 5145 |
|
| 5146 |
.set-pane { font-size: var(--lp-fs-xs); }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 5147 |
.set-h { margin: 0 0 14px; font-size: var(--lp-fs-md); font-weight: 620; }
|
| 5148 |
.set-h4 { margin: 0 0 12px; font-size: var(--lp-fs-sm); font-weight: 620; }
|
| 5149 |
.set-help { margin: 5px 0 0; font-size: var(--lp-fs-2xs); color: var(--lp-muted); }
|
|
@@ -5163,11 +5289,215 @@ a.cg-map-ctl-b { text-decoration: none; }
|
|
| 5163 |
color: var(--lp-green-deep);
|
| 5164 |
font-size: var(--lp-fs-2xs);
|
| 5165 |
}
|
| 5166 |
-
.set-table
|
| 5167 |
-
|
| 5168 |
-
|
|
|
|
|
|
|
| 5169 |
.set-username { display: block; font-size: var(--lp-fs-3xs); color: var(--lp-muted); }
|
| 5170 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 5171 |
.set-card {
|
| 5172 |
margin: 16px 0 0;
|
| 5173 |
padding: 16px 18px;
|
|
@@ -5243,10 +5573,20 @@ a.cg-map-ctl-b { text-decoration: none; }
|
|
| 5243 |
.set-perms { position: relative; }
|
| 5244 |
.set-perm-head {
|
| 5245 |
display: flex;
|
| 5246 |
-
align-items:
|
| 5247 |
gap: 14px;
|
| 5248 |
margin-bottom: 16px;
|
|
|
|
|
|
|
|
|
|
|
|
|
| 5249 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 5250 |
.set-perm-who { min-width: 0; }
|
| 5251 |
/* The `.set-h` default carries 14px of bottom margin meant for a pane title
|
| 5252 |
that starts a block; here the username sits directly under it. */
|
|
@@ -5286,11 +5626,10 @@ a.cg-map-ctl-b { text-decoration: none; }
|
|
| 5286 |
.set-perm-actions { align-items: center; margin-top: 20px; }
|
| 5287 |
.set-perm-dirty { margin: 0; }
|
| 5288 |
|
| 5289 |
-
/*
|
| 5290 |
-
|
| 5291 |
-
the
|
| 5292 |
-
|
| 5293 |
-
.set-user-door .set-user { display: block; }
|
| 5294 |
|
| 5295 |
/* Save asks first. Scoped INSIDE `.set-perms` rather than to the viewport: the
|
| 5296 |
question is about this page, and a second full-screen scrim over a dialog
|
|
@@ -5378,6 +5717,25 @@ a.cg-map-ctl-b { text-decoration: none; }
|
|
| 5378 |
color: var(--lp-muted);
|
| 5379 |
font-variant-numeric: tabular-nums;
|
| 5380 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 5381 |
/* A bar toggle (a comparison, gridlines, the trend column).
|
| 5382 |
β This REPLACES `.cg-ts-chip`, the metric chip row wave 14 deleted: metrics are ROWS now,
|
| 5383 |
added and removed on the sheet itself, so the only chips left are display switches.
|
|
@@ -5671,20 +6029,41 @@ a.cg-map-ctl-b { text-decoration: none; }
|
|
| 5671 |
/* Item 4 β a summary day. Key left, value right, one metric per line: the same key/value
|
| 5672 |
rhythm the list cards use, so a day cell reads like the rest of the app rather than like a
|
| 5673 |
spreadsheet dropped into a calendar. */
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 5674 |
.cg-cal-metric {
|
| 5675 |
display: flex;
|
| 5676 |
-
align-items:
|
| 5677 |
-
|
| 5678 |
-
gap: 8px;
|
| 5679 |
padding: 1px 0;
|
| 5680 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
| 5681 |
.cg-cal-metric-k {
|
|
|
|
|
|
|
| 5682 |
font-size: var(--lp-fs-3xs);
|
| 5683 |
color: var(--lp-muted);
|
| 5684 |
overflow: hidden;
|
| 5685 |
text-overflow: ellipsis;
|
| 5686 |
white-space: nowrap;
|
| 5687 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 5688 |
.cg-cal-metric-v {
|
| 5689 |
font-size: var(--lp-fs-2xs);
|
| 5690 |
font-weight: 600;
|
|
|
|
| 1551 |
overflow: hidden;
|
| 1552 |
text-overflow: ellipsis;
|
| 1553 |
}
|
| 1554 |
+
/* wave17 GRID β owner item 8. A radio row may carry a line of help under its name, which the
|
| 1555 |
+
ellipsis rules above would clip to nothing. Scoped to `.cg-radio-row` so the checkbox lists
|
| 1556 |
+
(fields, totals, comparisons β long labels in a narrow panel) keep their single-line
|
| 1557 |
+
truncation, which is right for a NAME and wrong for a SENTENCE. */
|
| 1558 |
+
.cg-radio-row .cg-check-label {
|
| 1559 |
+
white-space: normal;
|
| 1560 |
+
overflow: visible;
|
| 1561 |
+
}
|
| 1562 |
+
.cg-radio-help {
|
| 1563 |
+
display: block;
|
| 1564 |
+
padding: 2px 0 0;
|
| 1565 |
+
max-width: 220px;
|
| 1566 |
+
}
|
| 1567 |
/* R7 (2026-08-02) β the RADIO rows never got the treatment their checkbox twins have had
|
| 1568 |
since wave 2, and they are the ones that list FIELD LABELS (the Group-by popover): a
|
| 1569 |
two-line "Estimated missed revenue, last 12 months" pushed the row below it out of the
|
|
|
|
| 2539 |
border-top-style: dashed;
|
| 2540 |
}
|
| 2541 |
|
| 2542 |
+
/* =========================================================================== */
|
| 2543 |
+
/* wave17 SHELL β C-SPIN: THE loading mark, shared by every surface (item 3/R6) */
|
| 2544 |
+
/* =========================================================================== */
|
| 2545 |
+
/* Deliberately ABOVE the shell block below, whose header says "the embed never
|
| 2546 |
+
sees these classes". This one it does: the grid's own load states consume
|
| 2547 |
+
`.lp-spin` inside the Streamlit twin, so it belongs to no runtime in
|
| 2548 |
+
particular. SHELL owns the definition (C-SPIN); GRID consumes the CLASS.
|
| 2549 |
+
|
| 2550 |
+
R6: one small bare rotating icon, NO WORDS, on every load β module, panel,
|
| 2551 |
+
nav, first login. The sentences it replaces were all some flavour of telling
|
| 2552 |
+
the user what they could already see ("Loading customersβ¦" over an empty
|
| 2553 |
+
grid), and several of them lied by omission: a nav that is still fetching and
|
| 2554 |
+
a nav that came back empty said the same thing. A mark that spins says only
|
| 2555 |
+
"still working", which is the one true statement available.
|
| 2556 |
+
|
| 2557 |
+
TWO COLOURS, ZERO LITERALS. The leading arc is `currentColor`, so the mark
|
| 2558 |
+
inherits the ink of whatever it sits in and no caller has to pick a colour;
|
| 2559 |
+
the track is that same ink at 22%, which reads as the muted grey the contract
|
| 2560 |
+
asks for WITHOUT hard-coding a grey that would disappear on a tinted panel.
|
| 2561 |
+
A literal here would be exactly the mid-render one-off the palette block at
|
| 2562 |
+
the top of this file spent 55 call sites removing.
|
| 2563 |
+
|
| 2564 |
+
Markup contract (C-SPIN): <span class="lp-spin" role="status" aria-label="Loading" />
|
| 2565 |
+
β an empty element, sized by CSS. `aria-label` carries the word so the screen
|
| 2566 |
+
reader still hears it; the ruling is about pixels, not about a11y. */
|
| 2567 |
+
.lp-spin {
|
| 2568 |
+
display: inline-block;
|
| 2569 |
+
flex: 0 0 auto;
|
| 2570 |
+
width: 14px;
|
| 2571 |
+
height: 14px;
|
| 2572 |
+
border: 2px solid color-mix(in srgb, currentColor 22%, transparent);
|
| 2573 |
+
border-top-color: currentColor;
|
| 2574 |
+
border-radius: 50%;
|
| 2575 |
+
animation: lp-spin-rot 0.7s linear infinite;
|
| 2576 |
+
}
|
| 2577 |
+
/* 20px for a surface with nothing else on it (a whole page mid-load) β the
|
| 2578 |
+
14px mark is sized to sit BESIDE things, and alone on an empty panel it reads
|
| 2579 |
+
as dust. Border weight rises with it, or the ring goes spindly. */
|
| 2580 |
+
.lp-spin--lg {
|
| 2581 |
+
width: 20px;
|
| 2582 |
+
height: 20px;
|
| 2583 |
+
border-width: 2.5px;
|
| 2584 |
+
}
|
| 2585 |
+
@keyframes lp-spin-rot {
|
| 2586 |
+
to { transform: rotate(360deg); }
|
| 2587 |
+
}
|
| 2588 |
+
/* Reduced motion SLOWS the mark, it does not stop it: a frozen ring is not a
|
| 2589 |
+
calmer spinner, it is a broken one β the user loses the only signal that the
|
| 2590 |
+
app is still alive. Stepped so there is no continuous movement to track. */
|
| 2591 |
+
@media (prefers-reduced-motion: reduce) {
|
| 2592 |
+
.lp-spin { animation: lp-spin-rot 2.4s steps(8, end) infinite; }
|
| 2593 |
+
}
|
| 2594 |
+
|
| 2595 |
/* ---- shell (wave 4, 2026-07-27; EXIT wave 1 door + nav, 2026-07-30) --------
|
| 2596 |
Renders ONLY when the bundle is NOT hosted (App.tsx branch) β the embed
|
| 2597 |
never sees these classes. Every color/measure is a named token (anti-slop
|
|
|
|
| 3014 |
.shell-nav-item:hover { background: var(--lp-surface-2); }
|
| 3015 |
.shell-nav-item.is-child { padding-left: 30px; }
|
| 3016 |
/* The current row is marked the way the host marks it: the selected-row tint,
|
| 3017 |
+
weight, and the icon at full strength β no accent stripe (wave-10 I25a).
|
| 3018 |
+
β wave17 SHELL (item 12): THE TINT MOVED OUT OF THIS RULE. It painted the
|
| 3019 |
+
`<a>`, and the `<a>` is only part of the row β the three-dots is its SIBLING
|
| 3020 |
+
β so the current database was marked by a highlight that stopped two-thirds
|
| 3021 |
+
of the way across and left a notch of bare rail beside the β―. The Views rail
|
| 3022 |
+
never had that, because there the ROW carries the tint. It does here now
|
| 3023 |
+
(`.shell-nav-row.is-active`, navExtras.css). What stays here is everything
|
| 3024 |
+
that genuinely belongs to the LINK: its weight, and the icon below. */
|
| 3025 |
.shell-nav-item.is-active {
|
|
|
|
| 3026 |
font-weight: 600;
|
| 3027 |
}
|
| 3028 |
.shell-nav-item:focus-visible { outline: 2px solid var(--lp-blue-deep); outline-offset: -2px; }
|
|
|
|
| 3106 |
line-height: var(--lp-lh);
|
| 3107 |
color: var(--lp-muted);
|
| 3108 |
}
|
| 3109 |
+
/* wave17 SHELL (item 3/R6) β the nav's own load is a mark, not a sentence.
|
| 3110 |
+
Centred in the rail's width so it reads as chrome rather than as a row that
|
| 3111 |
+
failed to render its label. The muted ink is what the mark inherits. */
|
| 3112 |
+
.shell-nav-note.is-spin {
|
| 3113 |
+
display: flex;
|
| 3114 |
+
justify-content: center;
|
| 3115 |
+
padding: 14px 8px;
|
| 3116 |
+
}
|
| 3117 |
+
|
| 3118 |
+
/* wave17 SHELL (item 4/R6) β the work area while the nav is still being asked
|
| 3119 |
+
for. Centred in BOTH axes: this is the whole surface, not a line in a panel,
|
| 3120 |
+
and a 20px mark pinned to the top-left of an empty page reads as debris. */
|
| 3121 |
+
.shell-loading {
|
| 3122 |
+
display: grid;
|
| 3123 |
+
place-items: center;
|
| 3124 |
+
width: 100%;
|
| 3125 |
+
height: 100%;
|
| 3126 |
+
color: var(--lp-muted);
|
| 3127 |
+
}
|
| 3128 |
|
| 3129 |
.shell-side-bottom {
|
| 3130 |
margin-top: auto;
|
|
|
|
| 4164 |
gap: 6px;
|
| 4165 |
color: var(--cg-muted);
|
| 4166 |
}
|
| 4167 |
+
/* wave17 GRID β item 3 / owner R6. `.cg-count-loaddot` (a 6px gold disc pulsing on its own
|
| 4168 |
+
`@keyframes cg-loaddot`) stood here and is DELETED, not merely unused: the count chip now
|
| 4169 |
+
wears `.lp-spin` like every other wait in the product, and a second loading animation left
|
| 4170 |
+
in the stylesheet is how one surface quietly keeps its own dialect. Both the rule and its
|
| 4171 |
+
keyframes went; nothing references either.
|
| 4172 |
+
|
| 4173 |
+
R6 is a CONSISTENCY ruling, which is why deleting a perfectly good affordance is the point
|
| 4174 |
+
rather than collateral. */
|
| 4175 |
+
|
| 4176 |
+
/* wave17 GRID β item 3 / R6: a container whose ONLY child is the spinner CENTRES it.
|
| 4177 |
+
These four are text boxes that now hold a single 14px mark, and a bare ring pinned to the
|
| 4178 |
+
left of an 18px-padded card reads as a rendering artefact rather than as a wait. Scoped to
|
| 4179 |
+
`:only-child` so a spinner sitting BESIDE content (the toolbar count chip) keeps its inline
|
| 4180 |
+
flow. Layout only β size, colour and animation stay SHELL's under C-SPIN. */
|
| 4181 |
+
.cg-ts-note > .lp-spin:only-child,
|
| 4182 |
+
.cg-ch-empty > .lp-spin:only-child,
|
| 4183 |
+
.cg-ch-loading > .lp-spin:only-child,
|
| 4184 |
+
.cg-record-comment-state > .lp-spin:only-child {
|
| 4185 |
+
display: block;
|
| 4186 |
+
margin: 2px auto;
|
| 4187 |
}
|
| 4188 |
|
| 4189 |
/* Item W2 (C2) β the export format pane's small title line above the menuitems. */
|
|
|
|
| 4431 |
text-overflow: ellipsis;
|
| 4432 |
white-space: nowrap;
|
| 4433 |
}
|
| 4434 |
+
/* wave17 GRID β owner item 11a: the folder count is smaller and grey.
|
| 4435 |
+
β IDENTICAL to `.shell-nav-foldercount`'s wave17 treatment, token for token, and that is the
|
| 4436 |
+
item rather than a coincidence: item 11 asks BOTH rails for it, and the DB nav and the Views
|
| 4437 |
+
rail sit one above the other. `--lp-muted` unchanged β it already IS the grey, and a lighter
|
| 4438 |
+
literal invented here would have nowhere legal to live and would put the two rails a shade
|
| 4439 |
+
apart, which is the symmetry complaint wave 14 was answering. Shrinking the type does the
|
| 4440 |
+
lightening. */
|
| 4441 |
+
.cg-fold-count {
|
| 4442 |
+
flex: 0 0 auto;
|
| 4443 |
+
font-size: var(--lp-fs-3xs);
|
| 4444 |
+
font-weight: 400;
|
| 4445 |
+
color: var(--lp-muted);
|
| 4446 |
+
font-variant-numeric: tabular-nums;
|
| 4447 |
+
}
|
| 4448 |
.cg-fold-rename { flex: 1 1 auto; height: 24px; font-weight: 400; }
|
| 4449 |
.cg-fold-empty {
|
| 4450 |
padding: 4px 10px 6px 24px;
|
|
|
|
| 5258 |
.set-close:focus-visible { outline: 2px solid var(--lp-blue-deep); outline-offset: 1px; }
|
| 5259 |
|
| 5260 |
.set-pane { font-size: var(--lp-fs-xs); }
|
| 5261 |
+
/* wave17 SHELL (item 3/R6) β a pane that is still being fetched. NOT `.pg-empty`,
|
| 5262 |
+
which is the dashed EMPTY-STATE frame: drawing a list that is merely on its way
|
| 5263 |
+
inside the box that means "there is nothing here" is a wrong answer that looks
|
| 5264 |
+
like a right one. Tall enough that the modal body does not jump when the real
|
| 5265 |
+
content replaces it. */
|
| 5266 |
+
.set-loading {
|
| 5267 |
+
display: flex;
|
| 5268 |
+
justify-content: center;
|
| 5269 |
+
align-items: center;
|
| 5270 |
+
min-height: 140px;
|
| 5271 |
+
color: var(--lp-muted);
|
| 5272 |
+
}
|
| 5273 |
.set-h { margin: 0 0 14px; font-size: var(--lp-fs-md); font-weight: 620; }
|
| 5274 |
.set-h4 { margin: 0 0 12px; font-size: var(--lp-fs-sm); font-weight: 620; }
|
| 5275 |
.set-help { margin: 5px 0 0; font-size: var(--lp-fs-2xs); color: var(--lp-muted); }
|
|
|
|
| 5289 |
color: var(--lp-green-deep);
|
| 5290 |
font-size: var(--lp-fs-2xs);
|
| 5291 |
}
|
| 5292 |
+
/* β `.set-table`, `.set-table tbody tr.is-inactive` and `.set-user` WENT WITH
|
| 5293 |
+
THE ACCOUNTS TABLE (wave 17 R7). Grepped, not assumed: nothing outside this
|
| 5294 |
+
file referenced them once the card list replaced the table. A dead rule with a
|
| 5295 |
+
plausible name is worse than no rule β it gets adopted by the next thing that
|
| 5296 |
+
needs a table and quietly inherits decisions nobody made for it. */
|
| 5297 |
.set-username { display: block; font-size: var(--lp-fs-3xs); color: var(--lp-muted); }
|
| 5298 |
|
| 5299 |
+
/* βββ wave17 SHELL β items 16 + 16b: the profile surfaces βββββββββββββββββββ
|
| 5300 |
+
The three panes were built as forms first: key/value rows for identity, a
|
| 5301 |
+
table for accounts, an inline card for editing one. This block is the layout
|
| 5302 |
+
that replaces most of that copy β an avatar you can see, a name at title
|
| 5303 |
+
weight, a role as a chip, and one card per group of controls. */
|
| 5304 |
+
|
| 5305 |
+
/* --- the monogram / photo, at the two sizes the product needs -------------- */
|
| 5306 |
+
.set-avatar {
|
| 5307 |
+
flex: none;
|
| 5308 |
+
width: 34px;
|
| 5309 |
+
height: 34px;
|
| 5310 |
+
border-radius: var(--lp-r-pill);
|
| 5311 |
+
object-fit: cover;
|
| 5312 |
+
display: inline-flex;
|
| 5313 |
+
align-items: center;
|
| 5314 |
+
justify-content: center;
|
| 5315 |
+
font-size: var(--lp-fs-xs);
|
| 5316 |
+
font-weight: 600;
|
| 5317 |
+
/* The tint is a FILL and the ink is the `-deep` weight β the brand rule, and
|
| 5318 |
+
not a style choice: the pastels measure 1.38β1.94:1 on white, so a pastel
|
| 5319 |
+
letter here would be an initial nobody can read. */
|
| 5320 |
+
background: var(--lp-blue-tint);
|
| 5321 |
+
color: var(--lp-blue-deep);
|
| 5322 |
+
}
|
| 5323 |
+
.set-avatar--lg {
|
| 5324 |
+
width: 56px;
|
| 5325 |
+
height: 56px;
|
| 5326 |
+
font-size: var(--lp-fs-lg);
|
| 5327 |
+
}
|
| 5328 |
+
|
| 5329 |
+
/* --- a role, a state: chips, not table cells ------------------------------ */
|
| 5330 |
+
.set-chip {
|
| 5331 |
+
flex: none;
|
| 5332 |
+
padding: 1px 8px;
|
| 5333 |
+
border-radius: var(--lp-r-pill);
|
| 5334 |
+
font-size: var(--lp-fs-3xs);
|
| 5335 |
+
font-weight: 600;
|
| 5336 |
+
line-height: 1.7;
|
| 5337 |
+
white-space: nowrap;
|
| 5338 |
+
background: var(--lp-surface-2);
|
| 5339 |
+
color: var(--lp-muted);
|
| 5340 |
+
}
|
| 5341 |
+
/* Admin is the one role that bypasses every rule in the product. It earns a
|
| 5342 |
+
colour; Member is the default and does not. */
|
| 5343 |
+
.set-chip--admin { background: var(--lp-blue-tint); color: var(--lp-blue-deep); }
|
| 5344 |
+
.set-chip--off { background: var(--lp-red-tint); color: var(--lp-red-deep); }
|
| 5345 |
+
|
| 5346 |
+
/* --- the identity header (Account pane) ----------------------------------- */
|
| 5347 |
+
.set-identity {
|
| 5348 |
+
display: flex;
|
| 5349 |
+
align-items: flex-start;
|
| 5350 |
+
gap: 14px;
|
| 5351 |
+
padding: 16px 18px;
|
| 5352 |
+
border: 1px solid var(--lp-line);
|
| 5353 |
+
border-radius: var(--lp-r-md);
|
| 5354 |
+
background: var(--lp-wash);
|
| 5355 |
+
}
|
| 5356 |
+
.set-identity-body { min-width: 0; flex: 1 1 auto; }
|
| 5357 |
+
.set-identity-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
|
| 5358 |
+
.set-identity-name {
|
| 5359 |
+
font-size: var(--lp-fs-md);
|
| 5360 |
+
font-weight: 620;
|
| 5361 |
+
color: var(--lp-ink);
|
| 5362 |
+
}
|
| 5363 |
+
.set-identity-sub { margin-top: 1px; font-size: var(--lp-fs-2xs); color: var(--lp-muted); }
|
| 5364 |
+
.set-identity-acts { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
|
| 5365 |
+
.set-identity-err { margin: 10px 0 0; }
|
| 5366 |
+
/* The <input type=file> is driven by the button beside it and is never itself a
|
| 5367 |
+
control the user sees. A class, because a `style` attribute is still a style
|
| 5368 |
+
decision living outside the stylesheet. */
|
| 5369 |
+
.set-filepick { display: none; }
|
| 5370 |
+
|
| 5371 |
+
.set-pane-intro { margin: 0 0 14px; max-width: 68ch; line-height: var(--lp-lh); }
|
| 5372 |
+
/* A card whose whole content is `.pg-drill-row`s: the rows bring their own
|
| 5373 |
+
rhythm, so the card only has to stop adding a second one. The LAST row drops
|
| 5374 |
+
its rule β inside a bordered card the final hairline has nothing under it to
|
| 5375 |
+
separate, and on a one-row card (a member with no restrictions) it reads as a
|
| 5376 |
+
stray underline beneath the only line of content. */
|
| 5377 |
+
.set-card--rows { padding-top: 6px; padding-bottom: 6px; }
|
| 5378 |
+
.set-card--rows .pg-drill-row:last-child { border-bottom: 0; }
|
| 5379 |
+
|
| 5380 |
+
/* --- the accounts list (R7): one button per account ----------------------- */
|
| 5381 |
+
.set-acctlist {
|
| 5382 |
+
list-style: none;
|
| 5383 |
+
margin: 0;
|
| 5384 |
+
padding: 0;
|
| 5385 |
+
display: flex;
|
| 5386 |
+
flex-direction: column;
|
| 5387 |
+
gap: 8px;
|
| 5388 |
+
}
|
| 5389 |
+
/* β THE WHOLE CARD IS THE CONTROL. The owner's words were "click the whole
|
| 5390 |
+
user's Card, not just name, so it has bigger hit box" β so this is a real
|
| 5391 |
+
<button>, full width, and every pixel of it opens the same page. `text-align`
|
| 5392 |
+
and `font` are reset because a button brings centred, small, system type with
|
| 5393 |
+
it and this is a row of content, not a label. */
|
| 5394 |
+
.set-acct {
|
| 5395 |
+
display: flex;
|
| 5396 |
+
align-items: center;
|
| 5397 |
+
gap: 12px;
|
| 5398 |
+
width: 100%;
|
| 5399 |
+
padding: 12px 14px;
|
| 5400 |
+
border: 1px solid var(--lp-line);
|
| 5401 |
+
border-radius: var(--lp-r-md);
|
| 5402 |
+
background: var(--lp-surface);
|
| 5403 |
+
font: inherit;
|
| 5404 |
+
font-size: var(--lp-fs-xs);
|
| 5405 |
+
color: var(--lp-ink);
|
| 5406 |
+
text-align: left;
|
| 5407 |
+
cursor: pointer;
|
| 5408 |
+
}
|
| 5409 |
+
.set-acct:hover { border-color: var(--lp-blue-deep); background: var(--lp-surface-2); }
|
| 5410 |
+
.set-acct:focus-visible { outline: 2px solid var(--lp-blue-deep); outline-offset: 1px; }
|
| 5411 |
+
/* Deactivated is a property of the ACCOUNT, not of the row's readability: the
|
| 5412 |
+
chip says it, so the card only steps back rather than greying out β a row you
|
| 5413 |
+
cannot read is a row you cannot reactivate. */
|
| 5414 |
+
.set-acct.is-inactive .set-avatar { background: var(--lp-surface-2); color: var(--lp-muted); }
|
| 5415 |
+
.set-acct-body { min-width: 0; flex: 1 1 auto; display: block; }
|
| 5416 |
+
.set-acct-top { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; }
|
| 5417 |
+
.set-acct-name { font-size: var(--lp-fs-sm); font-weight: 620; }
|
| 5418 |
+
.set-acct-sub { display: block; font-size: var(--lp-fs-3xs); color: var(--lp-muted); }
|
| 5419 |
+
.set-acct-access { display: block; margin-top: 3px; font-size: var(--lp-fs-2xs); color: var(--lp-muted); }
|
| 5420 |
+
/* The affordance, not a second control β see the note in SettingsModal.tsx.
|
| 5421 |
+
Quiet until the card is hovered, because it is a property of the click. */
|
| 5422 |
+
.set-acct-go {
|
| 5423 |
+
flex: none;
|
| 5424 |
+
display: flex;
|
| 5425 |
+
align-items: center;
|
| 5426 |
+
gap: 5px;
|
| 5427 |
+
font-size: var(--lp-fs-2xs);
|
| 5428 |
+
font-weight: 600;
|
| 5429 |
+
color: var(--lp-muted);
|
| 5430 |
+
}
|
| 5431 |
+
.set-acct:hover .set-acct-go { color: var(--lp-blue-deep); }
|
| 5432 |
+
.set-acct-chev {
|
| 5433 |
+
width: 12px;
|
| 5434 |
+
height: 12px;
|
| 5435 |
+
fill: none;
|
| 5436 |
+
stroke: currentColor;
|
| 5437 |
+
stroke-width: 1.6;
|
| 5438 |
+
stroke-linecap: round;
|
| 5439 |
+
stroke-linejoin: round;
|
| 5440 |
+
}
|
| 5441 |
+
|
| 5442 |
+
/* --- the user page's own additions (R7 + C-PERMCOPY) ---------------------- */
|
| 5443 |
+
/* Two short fields side by side on a wide modal, stacked on a narrow one. */
|
| 5444 |
+
.set-grid2 {
|
| 5445 |
+
display: grid;
|
| 5446 |
+
grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
|
| 5447 |
+
gap: 0 16px;
|
| 5448 |
+
}
|
| 5449 |
+
/* The password warning and its button, in the grid cell beside the field. */
|
| 5450 |
+
.set-pw-side { align-self: end; padding-bottom: 1px; }
|
| 5451 |
+
.set-pw-side .set-help { margin: 0 0 7px; }
|
| 5452 |
+
/* The Access heading and its whole-record copy door share one line. */
|
| 5453 |
+
.set-perm-sect {
|
| 5454 |
+
display: flex;
|
| 5455 |
+
align-items: center;
|
| 5456 |
+
justify-content: space-between;
|
| 5457 |
+
gap: 12px;
|
| 5458 |
+
margin: 22px 0 8px;
|
| 5459 |
+
}
|
| 5460 |
+
.set-perm-sect .set-h4 { margin: 0; }
|
| 5461 |
+
/* A copy door is a small, secondary act beside the thing it copies. */
|
| 5462 |
+
.set-copy-door { height: 28px; padding: 0 10px; font-size: var(--lp-fs-2xs); }
|
| 5463 |
+
.set-copy-why { margin: -8px 0 14px; }
|
| 5464 |
+
.set-copy { width: min(520px, 100%); }
|
| 5465 |
+
.set-copy-list {
|
| 5466 |
+
max-height: 240px;
|
| 5467 |
+
overflow-y: auto;
|
| 5468 |
+
margin: 12px 0 4px;
|
| 5469 |
+
padding: 4px 2px;
|
| 5470 |
+
border: 1px solid var(--lp-line);
|
| 5471 |
+
border-radius: var(--lp-r-sm);
|
| 5472 |
+
}
|
| 5473 |
+
.set-copy-row { gap: 8px; padding: 5px 8px; border-radius: var(--lp-r-sm); }
|
| 5474 |
+
.set-copy-row:hover { background: var(--lp-surface-2); }
|
| 5475 |
+
.set-copy-name { font-weight: 600; }
|
| 5476 |
+
.set-copy-user { display: inline; }
|
| 5477 |
+
/* The confirm's per-target list. Each entry states what that account has TODAY
|
| 5478 |
+
and anything else the write does to it, so the question can be answered
|
| 5479 |
+
without remembering six other screens. */
|
| 5480 |
+
.set-copy-plans {
|
| 5481 |
+
list-style: none;
|
| 5482 |
+
margin: 12px 0 4px;
|
| 5483 |
+
padding: 0;
|
| 5484 |
+
display: flex;
|
| 5485 |
+
flex-direction: column;
|
| 5486 |
+
gap: 9px;
|
| 5487 |
+
max-height: 260px;
|
| 5488 |
+
overflow-y: auto;
|
| 5489 |
+
font-size: var(--lp-fs-2xs);
|
| 5490 |
+
}
|
| 5491 |
+
.set-copy-before { color: var(--lp-muted); }
|
| 5492 |
+
.set-copy-note {
|
| 5493 |
+
display: block;
|
| 5494 |
+
margin-top: 2px;
|
| 5495 |
+
padding-left: 10px;
|
| 5496 |
+
border-left: 2px solid var(--lp-yellow-deep);
|
| 5497 |
+
color: var(--lp-muted);
|
| 5498 |
+
line-height: var(--lp-lh);
|
| 5499 |
+
}
|
| 5500 |
+
|
| 5501 |
.set-card {
|
| 5502 |
margin: 16px 0 0;
|
| 5503 |
padding: 16px 18px;
|
|
|
|
| 5573 |
.set-perms { position: relative; }
|
| 5574 |
.set-perm-head {
|
| 5575 |
display: flex;
|
| 5576 |
+
align-items: center;
|
| 5577 |
gap: 14px;
|
| 5578 |
margin-bottom: 16px;
|
| 5579 |
+
/* wave17 R7 β the head carries the role and status chips now, so it wraps
|
| 5580 |
+
rather than crushing the name on a narrow modal. `center` replaces
|
| 5581 |
+
`flex-start`: chips beside a two-line name look dropped when top-aligned. */
|
| 5582 |
+
flex-wrap: wrap;
|
| 5583 |
}
|
| 5584 |
+
/* β The chips sit BESIDE the name, not at the far end. The first version pushed
|
| 5585 |
+
them right with `margin-left: auto` and the screenshot settled it: on an
|
| 5586 |
+
880px modal "Member" ended up an inch from anything it described, reading as
|
| 5587 |
+
a status of the dialog rather than of the person. Both other places a role is
|
| 5588 |
+
shown (the identity header, the account cards) put the chip next to the name;
|
| 5589 |
+
a third arrangement for the same fact is drift, not variety. */
|
| 5590 |
.set-perm-who { min-width: 0; }
|
| 5591 |
/* The `.set-h` default carries 14px of bottom margin meant for a pane title
|
| 5592 |
that starts a block; here the username sits directly under it. */
|
|
|
|
| 5626 |
.set-perm-actions { align-items: center; margin-top: 20px; }
|
| 5627 |
.set-perm-dirty { margin: 0; }
|
| 5628 |
|
| 5629 |
+
/* β `.set-user-door` IS GONE WITH THE TABLE (wave 17 R7). It existed to make a
|
| 5630 |
+
<button> stop looking like a button inside a table cell, so that the account
|
| 5631 |
+
NAME could be the only door. The card is the door now, and it is allowed to
|
| 5632 |
+
look like the control it is. */
|
|
|
|
| 5633 |
|
| 5634 |
/* Save asks first. Scoped INSIDE `.set-perms` rather than to the viewport: the
|
| 5635 |
question is about this page, and a second full-screen scrim over a dialog
|
|
|
|
| 5717 |
color: var(--lp-muted);
|
| 5718 |
font-variant-numeric: tabular-nums;
|
| 5719 |
}
|
| 5720 |
+
/* wave17 GRID β item 5 / owner R9: the fields this sheet CANNOT plot, named rather than absent.
|
| 5721 |
+
R9's rule is "offered is the ruling, undisclosed is not"; the converse matters just as much,
|
| 5722 |
+
because a reader who can see "Status" in the table and cannot find it in the metric picker has
|
| 5723 |
+
no way to tell a deliberate refusal from a bug. Quiet by design β struck-through muted text,
|
| 5724 |
+
not a warning colour: nothing here is wrong, these columns simply have no time dimension. The
|
| 5725 |
+
reason rides the `title`. */
|
| 5726 |
+
.cg-ts-refused {
|
| 5727 |
+
display: flex;
|
| 5728 |
+
flex-wrap: wrap;
|
| 5729 |
+
gap: 4px 8px;
|
| 5730 |
+
padding: 6px 2px 2px;
|
| 5731 |
+
}
|
| 5732 |
+
.cg-ts-refchip {
|
| 5733 |
+
font-size: var(--lp-fs-3xs);
|
| 5734 |
+
color: var(--lp-muted);
|
| 5735 |
+
text-decoration: line-through;
|
| 5736 |
+
text-decoration-color: var(--lp-line);
|
| 5737 |
+
cursor: help;
|
| 5738 |
+
}
|
| 5739 |
/* A bar toggle (a comparison, gridlines, the trend column).
|
| 5740 |
β This REPLACES `.cg-ts-chip`, the metric chip row wave 14 deleted: metrics are ROWS now,
|
| 5741 |
added and removed on the sheet itself, so the only chips left are display switches.
|
|
|
|
| 6029 |
/* Item 4 β a summary day. Key left, value right, one metric per line: the same key/value
|
| 6030 |
rhythm the list cards use, so a day cell reads like the rest of the app rather than like a
|
| 6031 |
spreadsheet dropped into a calendar. */
|
| 6032 |
+
/* wave17 GRID β item 9: the row is now icon Β· name Β· value, three children where there were
|
| 6033 |
+
two, so the layout is stated rather than left to `space-between` β which would have parked
|
| 6034 |
+
the NAME in the middle of the cell, away from the mark that qualifies it.
|
| 6035 |
+
`align-items` moves off `baseline` for the same reason: an inline SVG has no text baseline
|
| 6036 |
+
to sit on, so the mark would ride high against its label. */
|
| 6037 |
.cg-cal-metric {
|
| 6038 |
display: flex;
|
| 6039 |
+
align-items: center;
|
| 6040 |
+
gap: 5px;
|
|
|
|
| 6041 |
padding: 1px 0;
|
| 6042 |
}
|
| 6043 |
+
.cg-cal-metric > .cg-type-icon {
|
| 6044 |
+
flex: 0 0 auto;
|
| 6045 |
+
color: var(--lp-muted);
|
| 6046 |
+
}
|
| 6047 |
.cg-cal-metric-k {
|
| 6048 |
+
/* Takes the slack, so the value stays hard right and the marks stay a column. */
|
| 6049 |
+
flex: 1 1 auto;
|
| 6050 |
font-size: var(--lp-fs-3xs);
|
| 6051 |
color: var(--lp-muted);
|
| 6052 |
overflow: hidden;
|
| 6053 |
text-overflow: ellipsis;
|
| 6054 |
white-space: nowrap;
|
| 6055 |
}
|
| 6056 |
+
/* The window disclosure in the calendar header (C-TSWIN at day grain). Quiet β it qualifies a
|
| 6057 |
+
number, it does not warn about one β but present, because without it a cumulative cell and a
|
| 6058 |
+
periodic one are the same picture. */
|
| 6059 |
+
.cg-cal-window {
|
| 6060 |
+
font-size: var(--lp-fs-3xs);
|
| 6061 |
+
color: var(--lp-muted);
|
| 6062 |
+
white-space: nowrap;
|
| 6063 |
+
overflow: hidden;
|
| 6064 |
+
text-overflow: ellipsis;
|
| 6065 |
+
max-width: 320px;
|
| 6066 |
+
}
|
| 6067 |
.cg-cal-metric-v {
|
| 6068 |
font-size: var(--lp-fs-2xs);
|
| 6069 |
font-weight: 600;
|
web/src/pages/PageSurface.tsx
CHANGED
|
@@ -76,8 +76,14 @@ export function PageSurface({ pageKey, label }: { pageKey: string; label: string
|
|
| 76 |
if (state.phase === "loading") {
|
| 77 |
return (
|
| 78 |
<div className="pg-state">
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 79 |
<h1>{label}</h1>
|
| 80 |
-
<
|
| 81 |
</div>
|
| 82 |
);
|
| 83 |
}
|
|
|
|
| 76 |
if (state.phase === "loading") {
|
| 77 |
return (
|
| 78 |
<div className="pg-state">
|
| 79 |
+
{/* β THE TITLE STAYS, THE SENTENCE GOES (wave 17 item 3/R6). R6 deletes
|
| 80 |
+
loading COPY β "Loading live figures from Odoo. The first read of a
|
| 81 |
+
new scope takes a moment." was an apology for a wait the mark states
|
| 82 |
+
without excusing. The heading is not loading copy: it is this page's
|
| 83 |
+
name, already chosen in the rail, and dropping it would make arrival
|
| 84 |
+
a title POP-IN on a surface that had been anonymous. */}
|
| 85 |
<h1>{label}</h1>
|
| 86 |
+
<span className="lp-spin lp-spin--lg" role="status" aria-label="Loading" />
|
| 87 |
</div>
|
| 88 |
);
|
| 89 |
}
|
web/src/settings/PermsEditor.tsx
CHANGED
|
@@ -1,11 +1,22 @@
|
|
| 1 |
// ---------------------------------------------------------------------------
|
| 2 |
-
// settings / PermsEditor.tsx β wave 15
|
|
|
|
| 3 |
//
|
| 4 |
-
// "Manage users β click a user β the modal body BECOMES that user's
|
| 5 |
-
//
|
| 6 |
-
//
|
| 7 |
-
//
|
| 8 |
-
//
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 9 |
//
|
| 10 |
// β EVERY CONTROL HERE IS A COURTESY. `/admin/*` is refused to a member at the
|
| 11 |
// server, fail-closed, and the wall that acts on what this page writes is
|
|
@@ -33,10 +44,18 @@
|
|
| 33 |
|
| 34 |
import { useCallback, useEffect, useRef, useState } from "react";
|
| 35 |
import { FilterBuilderPanel, FieldsHidePanel } from "../filter-kit";
|
| 36 |
-
import {
|
| 37 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 38 |
import {
|
| 39 |
accessSummary,
|
|
|
|
|
|
|
| 40 |
filterOf,
|
| 41 |
hiddenSet,
|
| 42 |
hideableKeys,
|
|
@@ -59,31 +78,102 @@ type Load =
|
|
| 59 |
/** What the confirm step is asking about. `null` = nothing is being confirmed. */
|
| 60 |
type Ask = null | { kind: "save" } | { kind: "discard" };
|
| 61 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 62 |
export function PermsEditor({
|
| 63 |
-
|
| 64 |
-
displayName,
|
| 65 |
userOptions,
|
|
|
|
| 66 |
onBack,
|
| 67 |
onSaved,
|
| 68 |
}: {
|
| 69 |
-
|
| 70 |
-
|
| 71 |
-
*
|
| 72 |
-
|
|
|
|
|
|
|
|
|
|
| 73 |
/** The people a `user`-typed field may name, for the condition builder. Real
|
| 74 |
* accounts, never invented: an admin filtering on an owner who does not exist
|
| 75 |
-
* writes a rule that matches nothing and looks like it should match.
|
|
|
|
| 76 |
userOptions?: string[];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 77 |
onBack: () => void;
|
|
|
|
|
|
|
| 78 |
onSaved: (message: string) => void;
|
| 79 |
}) {
|
|
|
|
|
|
|
|
|
|
| 80 |
const [load, setLoad] = useState<Load>({ phase: "loading" });
|
| 81 |
/** The record as the SERVER holds it β the baseline `isDirty` compares to. */
|
| 82 |
const [saved, setSaved] = useState<PermsRecord>({});
|
| 83 |
const [draft, setDraft] = useState<PermsRecord>({});
|
| 84 |
const [ask, setAsk] = useState<Ask>(null);
|
|
|
|
| 85 |
const [busy, setBusy] = useState(false);
|
| 86 |
const [error, setError] = useState("");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 87 |
|
| 88 |
useEffect(() => {
|
| 89 |
let dead = false;
|
|
@@ -116,24 +206,65 @@ export function PermsEditor({
|
|
| 116 |
|
| 117 |
const payload = load.phase === "ready" ? load.payload : null;
|
| 118 |
const dirty = payload ? isDirty(payload, saved, draft) : false;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 119 |
|
| 120 |
const goBack = useCallback(() => {
|
| 121 |
-
if (
|
| 122 |
else onBack();
|
| 123 |
-
}, [
|
| 124 |
|
| 125 |
// β CAPTURE PHASE, ON PURPOSE. The settings modal binds its own window
|
| 126 |
// `keydown` and closes the WHOLE dialog on Escape β which, on this page,
|
| 127 |
-
// would throw away an admin's unsaved
|
| 128 |
-
//
|
| 129 |
-
//
|
| 130 |
-
const dirtyRef = useRef(
|
| 131 |
-
dirtyRef.current =
|
| 132 |
const askRef = useRef(ask);
|
| 133 |
askRef.current = ask;
|
|
|
|
|
|
|
| 134 |
useEffect(() => {
|
| 135 |
const onKey = (e: KeyboardEvent) => {
|
| 136 |
if (e.key !== "Escape") return;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 137 |
if (askRef.current) {
|
| 138 |
e.stopPropagation();
|
| 139 |
setAsk(null);
|
|
@@ -157,12 +288,12 @@ export function PermsEditor({
|
|
| 157 |
// nothing appears to happen. One module fits today; the second one does not.
|
| 158 |
const confirmRef = useRef<HTMLDivElement | null>(null);
|
| 159 |
useEffect(() => {
|
| 160 |
-
if (!ask) return;
|
| 161 |
confirmRef.current?.scrollIntoView({ block: "center" });
|
| 162 |
// Focus follows the question, so Enter answers it and a screen reader is
|
| 163 |
// taken to the alert rather than left where the pointer was.
|
| 164 |
confirmRef.current?.querySelector<HTMLButtonElement>("button")?.focus();
|
| 165 |
-
}, [ask]);
|
| 166 |
|
| 167 |
const save = useCallback(() => {
|
| 168 |
if (!payload) return;
|
|
@@ -174,6 +305,7 @@ export function PermsEditor({
|
|
| 174 |
setAsk(null);
|
| 175 |
if (r.ok) {
|
| 176 |
setSaved(body.perms);
|
|
|
|
| 177 |
onSaved(`Saved access for ${username}.`);
|
| 178 |
} else {
|
| 179 |
setError(r.message);
|
|
@@ -181,6 +313,178 @@ export function PermsEditor({
|
|
| 181 |
});
|
| 182 |
}, [payload, draft, username, onSaved]);
|
| 183 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 184 |
return (
|
| 185 |
<div className="set-pane set-perms">
|
| 186 |
<div className="set-perm-head">
|
|
@@ -188,14 +492,131 @@ export function PermsEditor({
|
|
| 188 |
Back to accounts
|
| 189 |
</button>
|
| 190 |
<div className="set-perm-who">
|
| 191 |
-
<h3 className="set-h set-perm-title">
|
| 192 |
<span className="set-username">{username}</span>
|
| 193 |
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
| 194 |
</div>
|
| 195 |
|
| 196 |
{error ? <p className="set-error">{error}</p> : null}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 197 |
|
| 198 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 199 |
{load.phase === "error" ? <p className="set-error">{load.message}</p> : null}
|
| 200 |
|
| 201 |
{payload ? (
|
|
@@ -207,7 +628,7 @@ export function PermsEditor({
|
|
| 207 |
a word is inviting somebody to "restrict" an administrator and walk
|
| 208 |
away believing they did. The controls stay usable on purpose β the
|
| 209 |
rules are real the moment the account stops being an admin. */}
|
| 210 |
-
{
|
| 211 |
<p className="set-notice set-perm-banner">
|
| 212 |
This is an administrator account. Administrators see everything, so
|
| 213 |
nothing set here applies to them β these rules take effect only if
|
|
@@ -219,7 +640,7 @@ export function PermsEditor({
|
|
| 219 |
PREVIOUS wall, so its empty perms mean "not written yet", not "no
|
| 220 |
access". Saying so is the difference between an admin reading this
|
| 221 |
page correctly and one who thinks the account is locked out. */}
|
| 222 |
-
{!payload.migrated && !
|
| 223 |
<p className="set-notice set-perm-banner">
|
| 224 |
This account still uses the previous access model, so the rules below
|
| 225 |
are not in force yet. Saving moves it to the per-module model β set
|
|
@@ -237,6 +658,25 @@ export function PermsEditor({
|
|
| 237 |
</p>
|
| 238 |
) : null}
|
| 239 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 240 |
<p className="set-help set-perm-intro">
|
| 241 |
{accessSummary(payload, draft)}. Each module can be turned off entirely,
|
| 242 |
narrowed to the records a condition describes, or shown with fields
|
|
@@ -244,6 +684,16 @@ export function PermsEditor({
|
|
| 244 |
the exports and every number computed from them.
|
| 245 |
</p>
|
| 246 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 247 |
{payload.modules.length === 0 ? (
|
| 248 |
<p className="pg-empty">
|
| 249 |
This deployment declares no modules that can be restricted.
|
|
@@ -266,6 +716,16 @@ export function PermsEditor({
|
|
| 266 |
<span className="set-perm-modname">{m.label}</span>
|
| 267 |
</label>
|
| 268 |
<span className="set-perm-sum">{moduleSummary(entry, schemaless)}</span>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 269 |
</div>
|
| 270 |
|
| 271 |
{/* R9's fail-closed rendering: no readable schema means the
|
|
@@ -349,8 +809,11 @@ export function PermsEditor({
|
|
| 349 |
) : (
|
| 350 |
<>
|
| 351 |
<h4 className="set-h4">Discard these changes?</h4>
|
|
|
|
|
|
|
|
|
|
| 352 |
<p className="set-help">
|
| 353 |
-
|
| 354 |
</p>
|
| 355 |
</>
|
| 356 |
)}
|
|
@@ -375,6 +838,130 @@ export function PermsEditor({
|
|
| 375 |
</div>
|
| 376 |
</div>
|
| 377 |
) : null}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 378 |
</div>
|
| 379 |
);
|
| 380 |
}
|
|
@@ -386,3 +973,12 @@ function accessSummaryLine(payload: PermsPayload | null, draft: PermsRecord): st
|
|
| 386 |
const s = accessSummary(payload, draft);
|
| 387 |
return s ? `${s} after this change.` : "";
|
| 388 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
// ---------------------------------------------------------------------------
|
| 2 |
+
// settings / PermsEditor.tsx β THE USER PAGE. (wave 15 R9: the permission
|
| 3 |
+
// editor Β· wave 17 R7: everything else about the account, merged in.)
|
| 4 |
//
|
| 5 |
+
// "Manage users β click a user β the modal body BECOMES that user's page." A
|
| 6 |
+
// full-pane takeover, not a drawer beside the list and not a third dialog: the
|
| 7 |
+
// thing being edited is a whole account, and giving it a room of its own is
|
| 8 |
+
// what makes room for a filter builder and a field list per module without
|
| 9 |
+
// either being a 200px scroll-box.
|
| 10 |
+
//
|
| 11 |
+
// β WHY THE FILE NAME NO LONGER DESCRIBES THE FILE. Wave 17's R7, verbatim:
|
| 12 |
+
// *"Edit and clicking a user name should just be the EXACT same opening of a
|
| 13 |
+
// full page so its not confusing."* Before it there were two doors β the name
|
| 14 |
+
// opened this page, "Edit" unfolded a card at the BOTTOM of the accounts list β
|
| 15 |
+
// and which one an admin needed depended on a distinction only the code cared
|
| 16 |
+
// about (who the account IS vs what it may SEE). Both jobs live here now. The
|
| 17 |
+
// export keeps its name because renaming it would ripple through the shell, the
|
| 18 |
+
// gate's module list and the render smoke for no user-visible gain β the same
|
| 19 |
+
// trade R12 made for `SettingsModal`.
|
| 20 |
//
|
| 21 |
// β EVERY CONTROL HERE IS A COURTESY. `/admin/*` is refused to a member at the
|
| 22 |
// server, fail-closed, and the wall that acts on what this page writes is
|
|
|
|
| 44 |
|
| 45 |
import { useCallback, useEffect, useRef, useState } from "react";
|
| 46 |
import { FilterBuilderPanel, FieldsHidePanel } from "../filter-kit";
|
| 47 |
+
import {
|
| 48 |
+
getUserPerms,
|
| 49 |
+
patchUser,
|
| 50 |
+
putUserPerms,
|
| 51 |
+
setPassword,
|
| 52 |
+
} from "./settingsApi";
|
| 53 |
+
import type { AdminUser } from "./settingsApi";
|
| 54 |
+
import type { CopyScope, PermsPayload, PermsRecord } from "./permsModel";
|
| 55 |
import {
|
| 56 |
accessSummary,
|
| 57 |
+
copyDropped,
|
| 58 |
+
copyTargetRecord,
|
| 59 |
filterOf,
|
| 60 |
hiddenSet,
|
| 61 |
hideableKeys,
|
|
|
|
| 78 |
/** What the confirm step is asking about. `null` = nothing is being confirmed. */
|
| 79 |
type Ask = null | { kind: "save" } | { kind: "discard" };
|
| 80 |
|
| 81 |
+
// --- C-PERMCOPY -------------------------------------------------------------
|
| 82 |
+
//
|
| 83 |
+
// CLIENT-SIDE ONLY, by contract: `GET /admin/users/{u}/perms` per target,
|
| 84 |
+
// compose, then `PUT` the WHOLE tree back. No new route.
|
| 85 |
+
//
|
| 86 |
+
// β THE WHOLE-TREE LAW IS WHY THE GET IS NOT OPTIONAL, and why the composition
|
| 87 |
+
// itself lives in `permsModel.copyTargetRecord` rather than in this file: a PUT
|
| 88 |
+
// replaces the record, a key omitted from it is a DELETION, and that failure
|
| 89 |
+
// already has a named negative control on the OTHER producer of PUT bodies.
|
| 90 |
+
// A second producer with no gate is the same bug waiting for a different road.
|
| 91 |
+
|
| 92 |
+
/** The UI's scope: the model's `CopyScope` plus the label this page shows. */
|
| 93 |
+
type CopyScopeUI = CopyScope & { label?: string };
|
| 94 |
+
|
| 95 |
+
/** One target, already fetched, with everything the confirm has to disclose. */
|
| 96 |
+
interface CopyPlan {
|
| 97 |
+
user: AdminUser;
|
| 98 |
+
payload: PermsPayload;
|
| 99 |
+
/** What that account's access says TODAY β the thing being overwritten. */
|
| 100 |
+
before: string;
|
| 101 |
+
/** Consequences beyond the overwrite itself, named per target. */
|
| 102 |
+
notes: string[];
|
| 103 |
+
}
|
| 104 |
+
|
| 105 |
+
type Copy =
|
| 106 |
+
| { phase: "pick"; scope: CopyScopeUI; picked: ReadonlySet<string> }
|
| 107 |
+
| { phase: "preparing"; scope: CopyScopeUI }
|
| 108 |
+
| {
|
| 109 |
+
phase: "confirm";
|
| 110 |
+
scope: CopyScopeUI;
|
| 111 |
+
plans: CopyPlan[];
|
| 112 |
+
/** Targets whose record could not be READ. Named, never dropped. */
|
| 113 |
+
refused: Array<{ username: string; why: string }>;
|
| 114 |
+
}
|
| 115 |
+
| { phase: "writing"; scope: CopyScopeUI };
|
| 116 |
+
|
| 117 |
+
/** "a", "a and b", "a, b and c" β a list a person reads, in a message that
|
| 118 |
+
* names every account it touched. */
|
| 119 |
+
function nameList(items: readonly string[]): string {
|
| 120 |
+
if (items.length <= 1) return items[0] ?? "";
|
| 121 |
+
return `${items.slice(0, -1).join(", ")} and ${items[items.length - 1]}`;
|
| 122 |
+
}
|
| 123 |
+
|
| 124 |
+
function scopeWords(scope: CopyScopeUI): string {
|
| 125 |
+
return scope.kind === "all" ? "this account's whole access" : `${scope.label} access`;
|
| 126 |
+
}
|
| 127 |
+
|
| 128 |
export function PermsEditor({
|
| 129 |
+
user,
|
|
|
|
| 130 |
userOptions,
|
| 131 |
+
copyTargets,
|
| 132 |
onBack,
|
| 133 |
onSaved,
|
| 134 |
}: {
|
| 135 |
+
/**
|
| 136 |
+
* β THE WHOLE RECORD, not a username and a display name (wave 17 R7). The
|
| 137 |
+
* page edits the account as well as its access, so it needs `role` and
|
| 138 |
+
* `active` β and taking the record rather than five scalars means one place
|
| 139 |
+
* (the pane's `reload`) refreshes everything after a write.
|
| 140 |
+
*/
|
| 141 |
+
user: AdminUser;
|
| 142 |
/** The people a `user`-typed field may name, for the condition builder. Real
|
| 143 |
* accounts, never invented: an admin filtering on an owner who does not exist
|
| 144 |
+
* writes a rule that matches nothing and looks like it should match.
|
| 145 |
+
* β DISPLAY NAMES β the cells hold names. Not the copy targets below. */
|
| 146 |
userOptions?: string[];
|
| 147 |
+
/** Every OTHER account, as records, for C-PERMCOPY.
|
| 148 |
+
* β RECORDS, because a copy addresses an account by USERNAME and puts it in
|
| 149 |
+
* a URL. Handing this the display-name list would build a wrong path that
|
| 150 |
+
* 404s at best and writes to the wrong account at worst. */
|
| 151 |
+
copyTargets?: readonly AdminUser[];
|
| 152 |
onBack: () => void;
|
| 153 |
+
/** "The server took a write" β the list behind this page reloads. It does NOT
|
| 154 |
+
* close the page (R7: one page, several things to save on it). */
|
| 155 |
onSaved: (message: string) => void;
|
| 156 |
}) {
|
| 157 |
+
const displayName = user.name || user.username;
|
| 158 |
+
const username = user.username;
|
| 159 |
+
|
| 160 |
const [load, setLoad] = useState<Load>({ phase: "loading" });
|
| 161 |
/** The record as the SERVER holds it β the baseline `isDirty` compares to. */
|
| 162 |
const [saved, setSaved] = useState<PermsRecord>({});
|
| 163 |
const [draft, setDraft] = useState<PermsRecord>({});
|
| 164 |
const [ask, setAsk] = useState<Ask>(null);
|
| 165 |
+
const [copy, setCopy] = useState<Copy | null>(null);
|
| 166 |
const [busy, setBusy] = useState(false);
|
| 167 |
const [error, setError] = useState("");
|
| 168 |
+
/** What just happened, said ON THIS PAGE. The pane's own notice renders in the
|
| 169 |
+
* accounts LIST, which the admin is no longer sent back to on save β so
|
| 170 |
+
* without this a successful write would land in an empty room. */
|
| 171 |
+
const [said, setSaid] = useState("");
|
| 172 |
+
|
| 173 |
+
// --- the account half (R7, moved here from the accounts list's `EditUser`) --
|
| 174 |
+
const [name, setName] = useState(user.name ?? "");
|
| 175 |
+
const [role, setRole] = useState(user.role ?? "user");
|
| 176 |
+
const [pw, setPw] = useState("");
|
| 177 |
|
| 178 |
useEffect(() => {
|
| 179 |
let dead = false;
|
|
|
|
| 206 |
|
| 207 |
const payload = load.phase === "ready" ? load.payload : null;
|
| 208 |
const dirty = payload ? isDirty(payload, saved, draft) : false;
|
| 209 |
+
/**
|
| 210 |
+
* β `payload.isAdmin` ALONE GOES STALE THE MOMENT THIS PAGE CAN CHANGE THE
|
| 211 |
+
* ROLE β which is new in wave 17. It is a snapshot taken by the perms GET on
|
| 212 |
+
* mount; promote the account to Admin from the card above and that GET is not
|
| 213 |
+
* repeated, so the "these rules are inert" banner would stay hidden over an
|
| 214 |
+
* account whose rules had just become inert. `user.role` is the fresher
|
| 215 |
+
* truth: the accounts list reloads after every write here, and the record
|
| 216 |
+
* comes back with it. Both are read, because either can be the newer one β
|
| 217 |
+
* and the failure this prevents is an admin restricting an administrator and
|
| 218 |
+
* walking away believing they did, which is the exact misreading the banner
|
| 219 |
+
* exists to stop.
|
| 220 |
+
*
|
| 221 |
+
* β NOT the local `role` state: that is the DRAFT, and an unsaved role change
|
| 222 |
+
* has not made anything inert yet.
|
| 223 |
+
*/
|
| 224 |
+
const subjectIsAdmin = user.role === "admin" || payload?.isAdmin === true;
|
| 225 |
+
/**
|
| 226 |
+
* β THE GUARD HAD TO WIDEN WITH THE PAGE. `dirty` describes the PERMISSION
|
| 227 |
+
* draft only, and it was the whole story while this file was only a
|
| 228 |
+
* permission editor. Merge the account form in and Escape would throw away a
|
| 229 |
+
* half-typed display name or a role change with no prompt and no undo β
|
| 230 |
+
* exactly the failure the capture-phase listener below exists to prevent,
|
| 231 |
+
* arriving through a second door.
|
| 232 |
+
*
|
| 233 |
+
* β A TYPED PASSWORD IS DELIBERATELY NOT COUNTED. It is a one-shot field with
|
| 234 |
+
* its own button, retyped in seconds, and prompting "discard changes?" because
|
| 235 |
+
* a password box has characters in it trains people to click through the
|
| 236 |
+
* prompt β which weakens the guard for the edits that actually cost something.
|
| 237 |
+
*/
|
| 238 |
+
const accountDirty =
|
| 239 |
+
name.trim() !== (user.name ?? "").trim() || role !== (user.role ?? "user");
|
| 240 |
+
const anyDirty = dirty || accountDirty;
|
| 241 |
|
| 242 |
const goBack = useCallback(() => {
|
| 243 |
+
if (anyDirty) setAsk({ kind: "discard" });
|
| 244 |
else onBack();
|
| 245 |
+
}, [anyDirty, onBack]);
|
| 246 |
|
| 247 |
// β CAPTURE PHASE, ON PURPOSE. The settings modal binds its own window
|
| 248 |
// `keydown` and closes the WHOLE dialog on Escape β which, on this page,
|
| 249 |
+
// would throw away an admin's unsaved edits with no prompt and no undo. A
|
| 250 |
+
// capture-phase listener on the same target runs before that bubble-phase
|
| 251 |
+
// one, so `stopPropagation()` here actually stops it.
|
| 252 |
+
const dirtyRef = useRef(anyDirty);
|
| 253 |
+
dirtyRef.current = anyDirty;
|
| 254 |
const askRef = useRef(ask);
|
| 255 |
askRef.current = ask;
|
| 256 |
+
const copyRef = useRef(copy);
|
| 257 |
+
copyRef.current = copy;
|
| 258 |
useEffect(() => {
|
| 259 |
const onKey = (e: KeyboardEvent) => {
|
| 260 |
if (e.key !== "Escape") return;
|
| 261 |
+
// A copy in flight owns Escape first: it is the innermost thing open, and
|
| 262 |
+
// dismissing it must not also dismiss the page under it.
|
| 263 |
+
if (copyRef.current) {
|
| 264 |
+
e.stopPropagation();
|
| 265 |
+
if (copyRef.current.phase !== "writing") setCopy(null);
|
| 266 |
+
return;
|
| 267 |
+
}
|
| 268 |
if (askRef.current) {
|
| 269 |
e.stopPropagation();
|
| 270 |
setAsk(null);
|
|
|
|
| 288 |
// nothing appears to happen. One module fits today; the second one does not.
|
| 289 |
const confirmRef = useRef<HTMLDivElement | null>(null);
|
| 290 |
useEffect(() => {
|
| 291 |
+
if (!ask && !copy) return;
|
| 292 |
confirmRef.current?.scrollIntoView({ block: "center" });
|
| 293 |
// Focus follows the question, so Enter answers it and a screen reader is
|
| 294 |
// taken to the alert rather than left where the pointer was.
|
| 295 |
confirmRef.current?.querySelector<HTMLButtonElement>("button")?.focus();
|
| 296 |
+
}, [ask, copy]);
|
| 297 |
|
| 298 |
const save = useCallback(() => {
|
| 299 |
if (!payload) return;
|
|
|
|
| 305 |
setAsk(null);
|
| 306 |
if (r.ok) {
|
| 307 |
setSaved(body.perms);
|
| 308 |
+
setSaid(`Saved access for ${username}.`);
|
| 309 |
onSaved(`Saved access for ${username}.`);
|
| 310 |
} else {
|
| 311 |
setError(r.message);
|
|
|
|
| 313 |
});
|
| 314 |
}, [payload, draft, username, onSaved]);
|
| 315 |
|
| 316 |
+
/** The account half's write. β THE PATCH STILL CARRIES NO `bus` (R1), and
|
| 317 |
+
* that is load-bearing rather than tidy: with the picker gone this form
|
| 318 |
+
* cannot edit the field, so a PATCH that still sent it would be a client
|
| 319 |
+
* echoing back a value it only read β and once the migration converts `bus`
|
| 320 |
+
* into a permanent filter and clears the field, that echo would RESURRECT
|
| 321 |
+
* it. A form writes what it edits and nothing else. */
|
| 322 |
+
const applyAccount = useCallback(
|
| 323 |
+
(patch: Parameters<typeof patchUser>[1], said: string) => {
|
| 324 |
+
setBusy(true);
|
| 325 |
+
setError("");
|
| 326 |
+
void patchUser(username, patch).then((r) => {
|
| 327 |
+
setBusy(false);
|
| 328 |
+
if (r.ok) {
|
| 329 |
+
setSaid(said);
|
| 330 |
+
onSaved(said);
|
| 331 |
+
} else {
|
| 332 |
+
setError(r.message);
|
| 333 |
+
}
|
| 334 |
+
});
|
| 335 |
+
},
|
| 336 |
+
[username, onSaved]
|
| 337 |
+
);
|
| 338 |
+
|
| 339 |
+
// --- C-PERMCOPY: prepare, then confirm, then write ------------------------
|
| 340 |
+
|
| 341 |
+
/**
|
| 342 |
+
* β THE TARGETS ARE FETCHED BEFORE THE CONFIRM, NOT AFTER IT. The contract
|
| 343 |
+
* asks for "a confirm that names the overwrite", and a confirm written from
|
| 344 |
+
* this page's knowledge alone can only name the SOURCE β it would say what is
|
| 345 |
+
* being copied and stay silent on what is being destroyed. Reading each
|
| 346 |
+
* target first lets the question state, per account, what that account's
|
| 347 |
+
* access says today and what else this write does to it. The payload fetched
|
| 348 |
+
* here is the same one the PUT is built from, so it costs nothing extra.
|
| 349 |
+
*/
|
| 350 |
+
const prepareCopy = useCallback(
|
| 351 |
+
async (scope: CopyScopeUI, picked: readonly string[]) => {
|
| 352 |
+
setCopy({ phase: "preparing", scope });
|
| 353 |
+
const plans: CopyPlan[] = [];
|
| 354 |
+
const refused: Array<{ username: string; why: string }> = [];
|
| 355 |
+
for (const target of copyTargets ?? []) {
|
| 356 |
+
if (!picked.includes(target.username)) continue;
|
| 357 |
+
const r = await getUserPerms(target.username);
|
| 358 |
+
if (!r.ok) {
|
| 359 |
+
refused.push({ username: target.username, why: r.message });
|
| 360 |
+
continue;
|
| 361 |
+
}
|
| 362 |
+
const p = parsePermsPayload(r.data);
|
| 363 |
+
if (!p) {
|
| 364 |
+
refused.push({
|
| 365 |
+
username: target.username,
|
| 366 |
+
why: "its permission record could not be read",
|
| 367 |
+
});
|
| 368 |
+
continue;
|
| 369 |
+
}
|
| 370 |
+
const notes: string[] = [];
|
| 371 |
+
// An admin bypasses `perms` entirely, so a copy onto one is stored and
|
| 372 |
+
// inert. Silently writing rules that do nothing is how an admin comes
|
| 373 |
+
// to believe an account is restricted when it is not.
|
| 374 |
+
if (p.isAdmin) {
|
| 375 |
+
notes.push(
|
| 376 |
+
"is an administrator β the rules will be stored but stay inert until the account is changed to Member"
|
| 377 |
+
);
|
| 378 |
+
}
|
| 379 |
+
// β A COPY MIGRATES THE TARGET. An un-migrated record runs under the
|
| 380 |
+
// PREVIOUS wall; a PUT moves it to the per-module model, which changes
|
| 381 |
+
// what governs that account from that moment on. Fresh accounts are
|
| 382 |
+
// exactly the ones an admin reaches for the copy button over
|
| 383 |
+
// (`create_user` stamps no perms), so this is the common case, not the
|
| 384 |
+
// exotic one.
|
| 385 |
+
if (!p.migrated) {
|
| 386 |
+
notes.push(
|
| 387 |
+
"still uses the previous access model β this write moves it to the per-module model"
|
| 388 |
+
);
|
| 389 |
+
}
|
| 390 |
+
// The same disclosure this page already makes for the account it has
|
| 391 |
+
// open. A whole-record replace drops what it does not name, and a copy
|
| 392 |
+
// does it to somebody the admin never opened.
|
| 393 |
+
if (p.orphanModules.length) {
|
| 394 |
+
notes.push(
|
| 395 |
+
`has rules for ${p.orphanModules.join(", ")}, which this deployment no longer offers β those are removed`
|
| 396 |
+
);
|
| 397 |
+
}
|
| 398 |
+
// β DISCLOSED BEFORE THE WRITE, not only after it. `runCopy` also reports
|
| 399 |
+
// this, but a report arrives when the admin can no longer decide
|
| 400 |
+
// anything; the confirm is where the decision is. The payload needed to
|
| 401 |
+
// know it is already in hand, so there is no reason to make them find out
|
| 402 |
+
// the expensive way.
|
| 403 |
+
const cannot = copyDropped(p, saved, scope);
|
| 404 |
+
if (cannot.length) {
|
| 405 |
+
const named = cannot.map(
|
| 406 |
+
(k) => payload?.modules.find((m) => m.key === k)?.label ?? k
|
| 407 |
+
);
|
| 408 |
+
notes.push(
|
| 409 |
+
`does not offer ${named.join(", ")}, so that part of this copy cannot be written at all`
|
| 410 |
+
);
|
| 411 |
+
}
|
| 412 |
+
plans.push({
|
| 413 |
+
user: target,
|
| 414 |
+
payload: p,
|
| 415 |
+
before:
|
| 416 |
+
scope.kind === "all"
|
| 417 |
+
? accessSummary(p, p.entries) || "No access"
|
| 418 |
+
: moduleSummary(
|
| 419 |
+
p.entries[scope.key],
|
| 420 |
+
(p.modules.find((m) => m.key === scope.key)?.fields.length ?? 0) === 0
|
| 421 |
+
),
|
| 422 |
+
notes,
|
| 423 |
+
});
|
| 424 |
+
}
|
| 425 |
+
setCopy({ phase: "confirm", scope, plans, refused });
|
| 426 |
+
},
|
| 427 |
+
// `saved` and `payload`: the drop disclosure is computed against the record
|
| 428 |
+
// as STORED (what a copy actually sends) and labelled from this account's
|
| 429 |
+
// own module list, which is the only place a label for an undeclared-on-the-
|
| 430 |
+
// target module exists.
|
| 431 |
+
[copyTargets, saved, payload]
|
| 432 |
+
);
|
| 433 |
+
|
| 434 |
+
const runCopy = useCallback(
|
| 435 |
+
async (scope: CopyScopeUI, plans: readonly CopyPlan[]) => {
|
| 436 |
+
setCopy({ phase: "writing", scope });
|
| 437 |
+
setError("");
|
| 438 |
+
const done: string[] = [];
|
| 439 |
+
const failed: string[] = [];
|
| 440 |
+
const dropped = new Set<string>();
|
| 441 |
+
for (const plan of plans) {
|
| 442 |
+
// β THE COMPOSITION LIVES IN `permsModel`, NOT HERE β it is the second
|
| 443 |
+
// producer of a PUT body in the product and the first aimed at somebody
|
| 444 |
+
// else's record, so it belongs where the gate can reach it and where its
|
| 445 |
+
// negative control can prove it capable of going red. See
|
| 446 |
+
// `copyTargetRecord`'s own note for the whole-tree rule it enforces.
|
| 447 |
+
const merged = copyTargetRecord(plan.payload, saved, scope);
|
| 448 |
+
for (const k of copyDropped(plan.payload, saved, scope)) dropped.add(k);
|
| 449 |
+
const r = await putUserPerms(plan.user.username, toPutBody(plan.payload, merged));
|
| 450 |
+
if (r.ok) done.push(plan.user.username);
|
| 451 |
+
else failed.push(`${plan.user.username} (${r.message})`);
|
| 452 |
+
}
|
| 453 |
+
setCopy(null);
|
| 454 |
+
// β ONE MESSAGE PER OUTCOME, NEVER ONE MESSAGE FOR THE BATCH. Three
|
| 455 |
+
// targets with the second refused, reported as "that change could not be
|
| 456 |
+
// saved", is a sentence that lies about the two that took it β and the
|
| 457 |
+
// admin's only recovery is to re-copy onto accounts that already have it.
|
| 458 |
+
if (done.length) {
|
| 459 |
+
const msg = `Copied ${scopeWords(scope)} to ${nameList(done)}.`;
|
| 460 |
+
setSaid(msg);
|
| 461 |
+
onSaved(msg);
|
| 462 |
+
}
|
| 463 |
+
// β ONE MESSAGE, BUILT FROM WHAT ACTUALLY WENT WRONG β the refusals and
|
| 464 |
+
// the modules that could not ride the write are different failures and
|
| 465 |
+
// both have to survive into it. "Copied" alone over a dropped module would
|
| 466 |
+
// be a success message for a write that did not fully happen.
|
| 467 |
+
const problems: string[] = [];
|
| 468 |
+
if (failed.length) problems.push(`Not copied to ${nameList(failed)}.`);
|
| 469 |
+
if (dropped.size) {
|
| 470 |
+
const list = nameList([...dropped].sort());
|
| 471 |
+
problems.push(
|
| 472 |
+
`${list} could not be copied β the accounts you picked do not offer ${dropped.size === 1 ? "it" : "them"}.`
|
| 473 |
+
);
|
| 474 |
+
}
|
| 475 |
+
if (problems.length) setError(problems.join(" "));
|
| 476 |
+
},
|
| 477 |
+
[saved, onSaved]
|
| 478 |
+
);
|
| 479 |
+
|
| 480 |
+
const canCopy = (copyTargets?.length ?? 0) > 0 && !!payload && !dirty;
|
| 481 |
+
const openCopy = useCallback((scope: CopyScopeUI) => {
|
| 482 |
+
setAsk(null);
|
| 483 |
+
setError("");
|
| 484 |
+
setSaid("");
|
| 485 |
+
setCopy({ phase: "pick", scope, picked: new Set<string>() });
|
| 486 |
+
}, []);
|
| 487 |
+
|
| 488 |
return (
|
| 489 |
<div className="set-pane set-perms">
|
| 490 |
<div className="set-perm-head">
|
|
|
|
| 492 |
Back to accounts
|
| 493 |
</button>
|
| 494 |
<div className="set-perm-who">
|
| 495 |
+
<h3 className="set-h set-perm-title">{displayName}</h3>
|
| 496 |
<span className="set-username">{username}</span>
|
| 497 |
</div>
|
| 498 |
+
<span className={role === "admin" ? "set-chip set-chip--admin" : "set-chip"}>
|
| 499 |
+
{role === "admin" ? "Admin" : "Member"}
|
| 500 |
+
</span>
|
| 501 |
+
{user.active ? null : <span className="set-chip set-chip--off">Deactivated</span>}
|
| 502 |
</div>
|
| 503 |
|
| 504 |
{error ? <p className="set-error">{error}</p> : null}
|
| 505 |
+
{said ? <p className="set-notice">{said}</p> : null}
|
| 506 |
+
|
| 507 |
+
{/* ββ the account (R7) βββββββββββββββββββββββββββββββββββββββββββββββ */}
|
| 508 |
+
<section className="set-card">
|
| 509 |
+
<h4 className="set-h4">Account</h4>
|
| 510 |
+
<div className="set-grid2">
|
| 511 |
+
<div className="set-field">
|
| 512 |
+
<label className="set-label" htmlFor="set-name">Display name</label>
|
| 513 |
+
<input
|
| 514 |
+
id="set-name"
|
| 515 |
+
className="set-input"
|
| 516 |
+
value={name}
|
| 517 |
+
onChange={(e) => setName(e.target.value)}
|
| 518 |
+
/>
|
| 519 |
+
</div>
|
| 520 |
+
<div className="set-field">
|
| 521 |
+
<label className="set-label" htmlFor="set-role">Role</label>
|
| 522 |
+
<select
|
| 523 |
+
id="set-role"
|
| 524 |
+
className="pg-select"
|
| 525 |
+
value={role}
|
| 526 |
+
onChange={(e) => setRole(e.target.value)}
|
| 527 |
+
>
|
| 528 |
+
<option value="user">Member</option>
|
| 529 |
+
<option value="admin">Admin</option>
|
| 530 |
+
</select>
|
| 531 |
+
</div>
|
| 532 |
+
</div>
|
| 533 |
+
{/* An admin bypasses every rule below. Changing the role here therefore
|
| 534 |
+
changes whether this whole page means anything, and saying so at the
|
| 535 |
+
control beats discovering it from an access page that does nothing. */}
|
| 536 |
+
{role === "admin" && (user.role ?? "user") !== "admin" ? (
|
| 537 |
+
<p className="set-help">
|
| 538 |
+
Saving this makes the account an administrator, which bypasses every
|
| 539 |
+
access rule set below.
|
| 540 |
+
</p>
|
| 541 |
+
) : null}
|
| 542 |
+
<div className="set-actions">
|
| 543 |
+
<button
|
| 544 |
+
type="button"
|
| 545 |
+
className="set-primary"
|
| 546 |
+
disabled={busy || !accountDirty}
|
| 547 |
+
onClick={() => applyAccount({ name, role }, `Saved ${username}.`)}
|
| 548 |
+
>
|
| 549 |
+
Save account
|
| 550 |
+
</button>
|
| 551 |
+
<button
|
| 552 |
+
type="button"
|
| 553 |
+
className="set-secondary"
|
| 554 |
+
disabled={busy}
|
| 555 |
+
onClick={() =>
|
| 556 |
+
applyAccount(
|
| 557 |
+
{ active: !user.active },
|
| 558 |
+
`${user.active ? "Deactivated" : "Reactivated"} ${username}.`
|
| 559 |
+
)
|
| 560 |
+
}
|
| 561 |
+
>
|
| 562 |
+
{user.active ? "Deactivate account" : "Reactivate account"}
|
| 563 |
+
</button>
|
| 564 |
+
</div>
|
| 565 |
|
| 566 |
+
{/* β THE SAME GRID as the two fields above it, so the password box is
|
| 567 |
+
exactly the width of the display-name box. Left full-bleed it
|
| 568 |
+
stretched the whole card while the field above it was half of one β
|
| 569 |
+
an accident of markup that reads as the two being different kinds of
|
| 570 |
+
thing. The warning moves alongside, which is also where it belongs:
|
| 571 |
+
beside the control it is about, not under it. */}
|
| 572 |
+
<div className="set-danger set-grid2">
|
| 573 |
+
<div className="set-field">
|
| 574 |
+
<label className="set-label" htmlFor="set-pw">Set a new password</label>
|
| 575 |
+
<input
|
| 576 |
+
id="set-pw"
|
| 577 |
+
className="set-input"
|
| 578 |
+
type="password"
|
| 579 |
+
value={pw}
|
| 580 |
+
autoComplete="new-password"
|
| 581 |
+
onChange={(e) => setPw(e.target.value)}
|
| 582 |
+
/>
|
| 583 |
+
</div>
|
| 584 |
+
<div className="set-pw-side">
|
| 585 |
+
{/* Said plainly BEFORE the click. Resetting a password bumps the
|
| 586 |
+
session epoch, which signs the person out of every device they
|
| 587 |
+
are using β an admin should not discover that from a support
|
| 588 |
+
ticket. */}
|
| 589 |
+
<p className="set-help">This signs {username} out everywhere immediately.</p>
|
| 590 |
+
<button
|
| 591 |
+
type="button"
|
| 592 |
+
className="set-secondary"
|
| 593 |
+
disabled={busy || pw.length === 0}
|
| 594 |
+
onClick={() => {
|
| 595 |
+
setError("");
|
| 596 |
+
void setPassword(username, pw).then((r) => {
|
| 597 |
+
if (r.ok) {
|
| 598 |
+
setPw("");
|
| 599 |
+
setSaid(`Password reset; ${username} was signed out.`);
|
| 600 |
+
} else {
|
| 601 |
+
setError(r.message);
|
| 602 |
+
}
|
| 603 |
+
});
|
| 604 |
+
}}
|
| 605 |
+
>
|
| 606 |
+
Reset password
|
| 607 |
+
</button>
|
| 608 |
+
</div>
|
| 609 |
+
</div>
|
| 610 |
+
</section>
|
| 611 |
+
|
| 612 |
+
{/* wave17 item 3 (R6) β the mark, not "Loading accessβ¦". The way OUT is
|
| 613 |
+
rendered above this and stays rendered, which is what the loading state
|
| 614 |
+
actually owed the reader; the sentence never was. */}
|
| 615 |
+
{load.phase === "loading" ? (
|
| 616 |
+
<div className="set-loading">
|
| 617 |
+
<span className="lp-spin lp-spin--lg" role="status" aria-label="Loading" />
|
| 618 |
+
</div>
|
| 619 |
+
) : null}
|
| 620 |
{load.phase === "error" ? <p className="set-error">{load.message}</p> : null}
|
| 621 |
|
| 622 |
{payload ? (
|
|
|
|
| 628 |
a word is inviting somebody to "restrict" an administrator and walk
|
| 629 |
away believing they did. The controls stay usable on purpose β the
|
| 630 |
rules are real the moment the account stops being an admin. */}
|
| 631 |
+
{subjectIsAdmin ? (
|
| 632 |
<p className="set-notice set-perm-banner">
|
| 633 |
This is an administrator account. Administrators see everything, so
|
| 634 |
nothing set here applies to them β these rules take effect only if
|
|
|
|
| 640 |
PREVIOUS wall, so its empty perms mean "not written yet", not "no
|
| 641 |
access". Saying so is the difference between an admin reading this
|
| 642 |
page correctly and one who thinks the account is locked out. */}
|
| 643 |
+
{!payload.migrated && !subjectIsAdmin ? (
|
| 644 |
<p className="set-notice set-perm-banner">
|
| 645 |
This account still uses the previous access model, so the rules below
|
| 646 |
are not in force yet. Saving moves it to the per-module model β set
|
|
|
|
| 658 |
</p>
|
| 659 |
) : null}
|
| 660 |
|
| 661 |
+
<div className="set-perm-sect">
|
| 662 |
+
<h4 className="set-h4">Access</h4>
|
| 663 |
+
{copyTargets?.length ? (
|
| 664 |
+
<button
|
| 665 |
+
type="button"
|
| 666 |
+
className="set-secondary set-copy-door"
|
| 667 |
+
disabled={!canCopy || busy}
|
| 668 |
+
title={
|
| 669 |
+
dirty
|
| 670 |
+
? "Save this account's access first β a copy sends what is stored, not what is on screen."
|
| 671 |
+
: undefined
|
| 672 |
+
}
|
| 673 |
+
onClick={() => openCopy({ kind: "all" })}
|
| 674 |
+
>
|
| 675 |
+
Apply this access toβ¦
|
| 676 |
+
</button>
|
| 677 |
+
) : null}
|
| 678 |
+
</div>
|
| 679 |
+
|
| 680 |
<p className="set-help set-perm-intro">
|
| 681 |
{accessSummary(payload, draft)}. Each module can be turned off entirely,
|
| 682 |
narrowed to the records a condition describes, or shown with fields
|
|
|
|
| 684 |
the exports and every number computed from them.
|
| 685 |
</p>
|
| 686 |
|
| 687 |
+
{/* β NOT A DISABLED BUTTON'S TOOLTIP ALONE. A control that is refused
|
| 688 |
+
has to say why where the eye already is; a `title` only answers the
|
| 689 |
+
reader who thought to hover. */}
|
| 690 |
+
{dirty && copyTargets?.length ? (
|
| 691 |
+
<p className="set-help set-copy-why">
|
| 692 |
+
Copying is unavailable while there are unsaved changes β a copy sends
|
| 693 |
+
what is stored, not what is on screen.
|
| 694 |
+
</p>
|
| 695 |
+
) : null}
|
| 696 |
+
|
| 697 |
{payload.modules.length === 0 ? (
|
| 698 |
<p className="pg-empty">
|
| 699 |
This deployment declares no modules that can be restricted.
|
|
|
|
| 716 |
<span className="set-perm-modname">{m.label}</span>
|
| 717 |
</label>
|
| 718 |
<span className="set-perm-sum">{moduleSummary(entry, schemaless)}</span>
|
| 719 |
+
{copyTargets?.length ? (
|
| 720 |
+
<button
|
| 721 |
+
type="button"
|
| 722 |
+
className="set-secondary set-copy-door"
|
| 723 |
+
disabled={!canCopy || busy}
|
| 724 |
+
onClick={() => openCopy({ kind: "module", key: m.key, label: m.label })}
|
| 725 |
+
>
|
| 726 |
+
Copy toβ¦
|
| 727 |
+
</button>
|
| 728 |
+
) : null}
|
| 729 |
</div>
|
| 730 |
|
| 731 |
{/* R9's fail-closed rendering: no readable schema means the
|
|
|
|
| 809 |
) : (
|
| 810 |
<>
|
| 811 |
<h4 className="set-h4">Discard these changes?</h4>
|
| 812 |
+
{/* β IT NAMES WHICH ONES. The page holds two kinds of unsaved
|
| 813 |
+
work now, and "your changes" over a form the reader cannot
|
| 814 |
+
see behind the scrim is a question they cannot answer. */}
|
| 815 |
<p className="set-help">
|
| 816 |
+
{unsavedWords(dirty, accountDirty)} for {displayName} stay as they were.
|
| 817 |
</p>
|
| 818 |
</>
|
| 819 |
)}
|
|
|
|
| 838 |
</div>
|
| 839 |
</div>
|
| 840 |
) : null}
|
| 841 |
+
|
| 842 |
+
{copy ? (
|
| 843 |
+
<div className="set-confirm-wrap">
|
| 844 |
+
<div
|
| 845 |
+
ref={confirmRef}
|
| 846 |
+
className="set-confirm set-copy"
|
| 847 |
+
role="alertdialog"
|
| 848 |
+
aria-modal="true"
|
| 849 |
+
aria-label={`Copy ${scopeWords(copy.scope)}`}
|
| 850 |
+
>
|
| 851 |
+
{copy.phase === "pick" ? (
|
| 852 |
+
<>
|
| 853 |
+
<h4 className="set-h4">Copy {scopeWords(copy.scope)} toβ¦</h4>
|
| 854 |
+
<p className="set-help">
|
| 855 |
+
{copy.scope.kind === "all"
|
| 856 |
+
? `Every account you pick has its whole access record replaced with ${displayName}'s.`
|
| 857 |
+
: `Every account you pick has its ${copy.scope.label} access replaced with ${displayName}'s. Their other modules are left alone.`}
|
| 858 |
+
</p>
|
| 859 |
+
<div className="set-copy-list">
|
| 860 |
+
{(copyTargets ?? []).map((t) => (
|
| 861 |
+
<label className="set-check set-copy-row" key={t.username}>
|
| 862 |
+
<input
|
| 863 |
+
type="checkbox"
|
| 864 |
+
checked={copy.picked.has(t.username)}
|
| 865 |
+
onChange={(e) => {
|
| 866 |
+
const next = new Set(copy.picked);
|
| 867 |
+
if (e.target.checked) next.add(t.username);
|
| 868 |
+
else next.delete(t.username);
|
| 869 |
+
setCopy({ ...copy, picked: next });
|
| 870 |
+
}}
|
| 871 |
+
/>
|
| 872 |
+
<span className="set-copy-name">{t.name || t.username}</span>
|
| 873 |
+
<span className="set-username set-copy-user">{t.username}</span>
|
| 874 |
+
{t.role === "admin" ? (
|
| 875 |
+
<span className="set-chip set-chip--admin">Admin</span>
|
| 876 |
+
) : null}
|
| 877 |
+
{t.active ? null : (
|
| 878 |
+
<span className="set-chip set-chip--off">Deactivated</span>
|
| 879 |
+
)}
|
| 880 |
+
</label>
|
| 881 |
+
))}
|
| 882 |
+
</div>
|
| 883 |
+
<div className="set-actions">
|
| 884 |
+
<button
|
| 885 |
+
type="button"
|
| 886 |
+
className="set-primary"
|
| 887 |
+
disabled={copy.picked.size === 0}
|
| 888 |
+
onClick={() => void prepareCopy(copy.scope, [...copy.picked])}
|
| 889 |
+
>
|
| 890 |
+
Continue
|
| 891 |
+
</button>
|
| 892 |
+
<button type="button" className="set-secondary" onClick={() => setCopy(null)}>
|
| 893 |
+
Cancel
|
| 894 |
+
</button>
|
| 895 |
+
</div>
|
| 896 |
+
</>
|
| 897 |
+
) : null}
|
| 898 |
+
|
| 899 |
+
{copy.phase === "preparing" || copy.phase === "writing" ? (
|
| 900 |
+
<div className="set-loading">
|
| 901 |
+
<span className="lp-spin lp-spin--lg" role="status" aria-label="Loading" />
|
| 902 |
+
</div>
|
| 903 |
+
) : null}
|
| 904 |
+
|
| 905 |
+
{copy.phase === "confirm" ? (
|
| 906 |
+
<>
|
| 907 |
+
<h4 className="set-h4">
|
| 908 |
+
Replace {scopeWords(copy.scope)} for {copy.plans.length} account
|
| 909 |
+
{copy.plans.length === 1 ? "" : "s"}?
|
| 910 |
+
</h4>
|
| 911 |
+
{copy.plans.length === 0 ? (
|
| 912 |
+
<p className="set-help">
|
| 913 |
+
None of the accounts picked could be read, so there is nothing to write.
|
| 914 |
+
</p>
|
| 915 |
+
) : (
|
| 916 |
+
<ul className="set-copy-plans">
|
| 917 |
+
{copy.plans.map((p) => (
|
| 918 |
+
<li key={p.user.username}>
|
| 919 |
+
{/* β THE OVERWRITE, NAMED PER TARGET. What is destroyed
|
| 920 |
+
is what this account has TODAY, so the question shows
|
| 921 |
+
it β a confirm that only describes the source asks
|
| 922 |
+
the admin to remember the rest. */}
|
| 923 |
+
<span className="set-copy-name">{p.user.name || p.user.username}</span>{" "}
|
| 924 |
+
<span className="set-copy-before">now: {p.before}</span>
|
| 925 |
+
{p.notes.map((n) => (
|
| 926 |
+
<span className="set-copy-note" key={n}>
|
| 927 |
+
{p.user.username} {n}
|
| 928 |
+
</span>
|
| 929 |
+
))}
|
| 930 |
+
</li>
|
| 931 |
+
))}
|
| 932 |
+
</ul>
|
| 933 |
+
)}
|
| 934 |
+
{copy.refused.length ? (
|
| 935 |
+
<p className="set-error">
|
| 936 |
+
{/* β The reason comes from the API and ends in a full stop
|
| 937 |
+
of its own ("Administrators only."), which read as
|
| 938 |
+
"(Administrators only.) could not be read" β a stray
|
| 939 |
+
period mid-sentence. Trimmed where the sentence is
|
| 940 |
+
built, not in the message the API returns. */}
|
| 941 |
+
{nameList(
|
| 942 |
+
copy.refused.map((r) => `${r.username} (${r.why.replace(/\.\s*$/, "")})`)
|
| 943 |
+
)}{" "}
|
| 944 |
+
could not be read and will not be changed.
|
| 945 |
+
</p>
|
| 946 |
+
) : null}
|
| 947 |
+
<div className="set-actions">
|
| 948 |
+
<button
|
| 949 |
+
type="button"
|
| 950 |
+
className="set-primary"
|
| 951 |
+
disabled={copy.plans.length === 0}
|
| 952 |
+
onClick={() => void runCopy(copy.scope, copy.plans)}
|
| 953 |
+
>
|
| 954 |
+
Replace access
|
| 955 |
+
</button>
|
| 956 |
+
<button type="button" className="set-secondary" onClick={() => setCopy(null)}>
|
| 957 |
+
Cancel
|
| 958 |
+
</button>
|
| 959 |
+
</div>
|
| 960 |
+
</>
|
| 961 |
+
) : null}
|
| 962 |
+
</div>
|
| 963 |
+
</div>
|
| 964 |
+
) : null}
|
| 965 |
</div>
|
| 966 |
);
|
| 967 |
}
|
|
|
|
| 973 |
const s = accessSummary(payload, draft);
|
| 974 |
return s ? `${s} after this change.` : "";
|
| 975 |
}
|
| 976 |
+
|
| 977 |
+
/** Which kinds of unsaved work the discard question is about. Exported-shaped
|
| 978 |
+
* as a pure function so it reads once and cannot drift between the two places
|
| 979 |
+
* a reader meets it. */
|
| 980 |
+
function unsavedWords(permsDirty: boolean, accountDirty: boolean): string {
|
| 981 |
+
if (permsDirty && accountDirty) return "The account details and access rules";
|
| 982 |
+
if (accountDirty) return "The account details";
|
| 983 |
+
return "The access rules";
|
| 984 |
+
}
|
web/src/settings/SettingsModal.tsx
CHANGED
|
@@ -29,16 +29,13 @@
|
|
| 29 |
import { useCallback, useEffect, useRef, useState } from "react";
|
| 30 |
import type { SessionUser } from "../shell/session";
|
| 31 |
import { isAdmin, parseUserEnvelope } from "../shell/session";
|
| 32 |
-
import type { AdminUser, SettingsPayload
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
setAvatar,
|
| 40 |
-
setPassword,
|
| 41 |
-
} from "./settingsApi";
|
| 42 |
import { PermsEditor } from "./PermsEditor";
|
| 43 |
import { moduleSummary, parseEntry, reachableSection } from "./permsModel";
|
| 44 |
|
|
@@ -64,16 +61,32 @@ function moduleWords(mods: string[] | "all"): string {
|
|
| 64 |
|
| 65 |
// ------------------------------------------------------------------ the users pane
|
| 66 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 67 |
function UsersPane() {
|
| 68 |
const [users, setUsers] = useState<AdminUser[] | null>(null);
|
| 69 |
const [error, setError] = useState("");
|
| 70 |
const [notice, setNotice] = useState("");
|
| 71 |
-
|
| 72 |
-
|
| 73 |
-
*
|
| 74 |
-
*
|
| 75 |
-
|
| 76 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 77 |
|
| 78 |
const reload = useCallback(() => {
|
| 79 |
void listUsers().then((r) => {
|
|
@@ -89,41 +102,60 @@ function UsersPane() {
|
|
| 89 |
|
| 90 |
useEffect(reload, [reload]);
|
| 91 |
|
| 92 |
-
|
| 93 |
-
|
| 94 |
-
|
| 95 |
-
|
| 96 |
-
|
| 97 |
-
|
| 98 |
-
|
| 99 |
-
|
| 100 |
-
|
| 101 |
-
} else {
|
| 102 |
-
setError(r.message);
|
| 103 |
-
}
|
| 104 |
-
},
|
| 105 |
-
[reload]
|
| 106 |
-
);
|
| 107 |
-
|
| 108 |
-
if (users === null) return <p className="pg-empty">Loading accountsβ¦</p>;
|
| 109 |
|
| 110 |
-
//
|
| 111 |
-
//
|
| 112 |
-
//
|
| 113 |
-
//
|
| 114 |
-
if (
|
| 115 |
-
const who = users.find((u) => u.username ===
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 116 |
return (
|
| 117 |
<PermsEditor
|
| 118 |
-
|
| 119 |
-
|
| 120 |
-
//
|
| 121 |
-
|
| 122 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 123 |
userOptions={users.map((u) => u.name || u.username)}
|
| 124 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 125 |
onSaved={(msg) => {
|
| 126 |
-
setPermsFor(null);
|
| 127 |
setNotice(msg);
|
| 128 |
setError("");
|
| 129 |
reload();
|
|
@@ -141,73 +173,62 @@ function UsersPane() {
|
|
| 141 |
{users.length === 0 && !error ? (
|
| 142 |
<p className="pg-empty">No accounts are configured on this deployment yet.</p>
|
| 143 |
) : (
|
| 144 |
-
|
| 145 |
-
|
| 146 |
-
|
| 147 |
-
|
| 148 |
-
|
| 149 |
-
|
| 150 |
-
|
| 151 |
-
|
| 152 |
-
|
| 153 |
-
|
| 154 |
-
|
| 155 |
-
|
| 156 |
-
|
| 157 |
-
|
| 158 |
-
<
|
| 159 |
-
|
| 160 |
-
|
| 161 |
-
|
| 162 |
-
|
| 163 |
-
|
| 164 |
-
<
|
| 165 |
-
|
| 166 |
-
|
| 167 |
-
|
| 168 |
-
className="
|
| 169 |
-
|
| 170 |
-
>
|
| 171 |
-
|
| 172 |
-
|
| 173 |
-
|
| 174 |
-
|
| 175 |
-
|
| 176 |
-
|
| 177 |
-
|
| 178 |
-
|
| 179 |
-
|
| 180 |
-
|
| 181 |
-
|
| 182 |
-
|
| 183 |
-
|
| 184 |
-
|
| 185 |
-
|
| 186 |
-
|
| 187 |
-
|
| 188 |
-
|
| 189 |
-
|
| 190 |
-
|
| 191 |
-
|
| 192 |
-
>
|
| 193 |
-
|
| 194 |
-
|
| 195 |
-
|
| 196 |
-
|
| 197 |
-
|
| 198 |
-
</tbody>
|
| 199 |
-
</table>
|
| 200 |
)}
|
| 201 |
|
| 202 |
-
{editing ? (
|
| 203 |
-
<EditUser
|
| 204 |
-
user={users.find((u) => u.username === editing) as AdminUser}
|
| 205 |
-
busy={busy}
|
| 206 |
-
onApply={apply}
|
| 207 |
-
onDone={() => setEditing(null)}
|
| 208 |
-
/>
|
| 209 |
-
) : null}
|
| 210 |
-
|
| 211 |
<AddUser
|
| 212 |
onCreated={(msg) => {
|
| 213 |
setNotice(msg);
|
|
@@ -237,105 +258,20 @@ function UsersPane() {
|
|
| 237 |
// no longer exists is a UI that WRITES it β see EditUser/AddUser below, which
|
| 238 |
// deliberately stopped sending the field they can no longer edit.
|
| 239 |
|
| 240 |
-
|
| 241 |
-
|
| 242 |
-
|
| 243 |
-
|
| 244 |
-
|
| 245 |
-
|
| 246 |
-
|
| 247 |
-
|
| 248 |
-
|
| 249 |
-
|
| 250 |
-
|
| 251 |
-
|
| 252 |
-
|
| 253 |
-
|
| 254 |
-
const [pwSaid, setPwSaid] = useState("");
|
| 255 |
-
|
| 256 |
-
if (!user) return null;
|
| 257 |
-
return (
|
| 258 |
-
<section className="set-card">
|
| 259 |
-
<h4 className="set-h4">Edit {user.username}</h4>
|
| 260 |
-
<div className="set-field">
|
| 261 |
-
<label className="set-label" htmlFor="set-name">Display name</label>
|
| 262 |
-
<input id="set-name" className="set-input" value={name} onChange={(e) => setName(e.target.value)} />
|
| 263 |
-
</div>
|
| 264 |
-
<div className="set-field">
|
| 265 |
-
<label className="set-label" htmlFor="set-role">Role</label>
|
| 266 |
-
<select id="set-role" className="pg-select" value={role} onChange={(e) => setRole(e.target.value)}>
|
| 267 |
-
<option value="user">Member</option>
|
| 268 |
-
<option value="admin">Admin</option>
|
| 269 |
-
</select>
|
| 270 |
-
</div>
|
| 271 |
-
{/* β THE PATCH NO LONGER CARRIES `bus`, and that is load-bearing rather
|
| 272 |
-
than tidy. With the picker gone this form cannot edit the field, so a
|
| 273 |
-
PATCH that still sent it would be a client echoing back a value it
|
| 274 |
-
only read β and once S1's migration converts `bus` into a permanent
|
| 275 |
-
filter and clears the field, that echo would RESURRECT it. A form
|
| 276 |
-
writes what it edits and nothing else. */}
|
| 277 |
-
<div className="set-actions">
|
| 278 |
-
<button
|
| 279 |
-
type="button"
|
| 280 |
-
className="set-primary"
|
| 281 |
-
disabled={busy}
|
| 282 |
-
onClick={() => onApply(user.username, { name, role }, `Saved ${user.username}.`)}
|
| 283 |
-
>
|
| 284 |
-
Save changes
|
| 285 |
-
</button>
|
| 286 |
-
<button
|
| 287 |
-
type="button"
|
| 288 |
-
className="set-secondary"
|
| 289 |
-
disabled={busy}
|
| 290 |
-
onClick={() =>
|
| 291 |
-
onApply(
|
| 292 |
-
user.username,
|
| 293 |
-
{ active: !user.active },
|
| 294 |
-
`${user.active ? "Deactivated" : "Reactivated"} ${user.username}.`
|
| 295 |
-
)
|
| 296 |
-
}
|
| 297 |
-
>
|
| 298 |
-
{user.active ? "Deactivate account" : "Reactivate account"}
|
| 299 |
-
</button>
|
| 300 |
-
<button type="button" className="set-secondary" onClick={onDone}>
|
| 301 |
-
Done
|
| 302 |
-
</button>
|
| 303 |
-
</div>
|
| 304 |
-
|
| 305 |
-
<div className="set-field set-danger">
|
| 306 |
-
<label className="set-label" htmlFor="set-pw">Set a new password</label>
|
| 307 |
-
<input
|
| 308 |
-
id="set-pw"
|
| 309 |
-
className="set-input"
|
| 310 |
-
type="password"
|
| 311 |
-
value={pw}
|
| 312 |
-
autoComplete="new-password"
|
| 313 |
-
onChange={(e) => setPw(e.target.value)}
|
| 314 |
-
/>
|
| 315 |
-
{/* Said plainly BEFORE the click. Resetting a password bumps the session
|
| 316 |
-
epoch, which signs the person out of every device they are using β
|
| 317 |
-
an admin should not discover that from a support ticket. */}
|
| 318 |
-
<p className="set-help">
|
| 319 |
-
This signs {user.username} out everywhere immediately.
|
| 320 |
-
</p>
|
| 321 |
-
<button
|
| 322 |
-
type="button"
|
| 323 |
-
className="set-secondary"
|
| 324 |
-
disabled={busy || pw.length === 0}
|
| 325 |
-
onClick={() => {
|
| 326 |
-
void setPassword(user.username, pw).then((r) => {
|
| 327 |
-
setPwSaid(r.ok ? `Password reset; ${user.username} was signed out.` : r.message);
|
| 328 |
-
if (r.ok) setPw("");
|
| 329 |
-
});
|
| 330 |
-
}}
|
| 331 |
-
>
|
| 332 |
-
Reset password
|
| 333 |
-
</button>
|
| 334 |
-
{pwSaid ? <p className="set-notice">{pwSaid}</p> : null}
|
| 335 |
-
</div>
|
| 336 |
-
</section>
|
| 337 |
-
);
|
| 338 |
-
}
|
| 339 |
|
| 340 |
function AddUser({
|
| 341 |
onCreated,
|
|
@@ -481,54 +417,66 @@ async function fileToAvatarDataUrl(file: File): Promise<string | null> {
|
|
| 481 |
}
|
| 482 |
}
|
| 483 |
|
| 484 |
-
/**
|
| 485 |
-
*
|
| 486 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 487 |
if (user.avatar) {
|
| 488 |
-
return
|
| 489 |
-
<img
|
| 490 |
-
src={user.avatar}
|
| 491 |
-
alt=""
|
| 492 |
-
aria-hidden="true"
|
| 493 |
-
style={{
|
| 494 |
-
width: size,
|
| 495 |
-
height: size,
|
| 496 |
-
borderRadius: "50%",
|
| 497 |
-
objectFit: "cover",
|
| 498 |
-
display: "block",
|
| 499 |
-
flex: "none",
|
| 500 |
-
}}
|
| 501 |
-
/>
|
| 502 |
-
);
|
| 503 |
}
|
| 504 |
-
const initial = (user.name.match(/[\p{L}\p{N}]/u)?.[0] ?? "?").toUpperCase();
|
| 505 |
return (
|
| 506 |
-
<span
|
| 507 |
-
|
| 508 |
-
|
| 509 |
-
|
| 510 |
-
|
| 511 |
-
|
| 512 |
-
|
| 513 |
-
|
| 514 |
-
|
| 515 |
-
|
| 516 |
-
|
| 517 |
-
|
| 518 |
-
|
| 519 |
-
|
| 520 |
-
|
| 521 |
-
|
| 522 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 523 |
</span>
|
| 524 |
);
|
| 525 |
}
|
| 526 |
|
| 527 |
function ProfilePhotoBlock({
|
| 528 |
user,
|
|
|
|
| 529 |
onUser,
|
| 530 |
}: {
|
| 531 |
user: SessionUser;
|
|
|
|
| 532 |
onUser?: (u: SessionUser) => void;
|
| 533 |
}) {
|
| 534 |
const [busy, setBusy] = useState(false);
|
|
@@ -570,42 +518,54 @@ function ProfilePhotoBlock({
|
|
| 570 |
}
|
| 571 |
}, [onUser]);
|
| 572 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 573 |
return (
|
| 574 |
-
<>
|
| 575 |
-
<
|
| 576 |
-
<
|
| 577 |
-
|
| 578 |
-
|
| 579 |
-
|
| 580 |
-
|
| 581 |
-
|
| 582 |
-
<
|
| 583 |
-
|
| 584 |
-
|
| 585 |
-
|
| 586 |
-
|
| 587 |
-
|
| 588 |
-
|
| 589 |
-
|
| 590 |
-
|
| 591 |
-
|
| 592 |
-
|
| 593 |
-
|
| 594 |
-
|
| 595 |
-
|
| 596 |
-
|
| 597 |
-
|
| 598 |
-
|
| 599 |
-
|
| 600 |
-
|
| 601 |
-
</button>
|
| 602 |
-
{user.avatar ? (
|
| 603 |
-
<button type="button" className="set-secondary" disabled={busy} onClick={remove}>
|
| 604 |
-
Remove
|
| 605 |
</button>
|
| 606 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 607 |
</div>
|
| 608 |
-
</>
|
| 609 |
);
|
| 610 |
}
|
| 611 |
|
|
@@ -698,19 +658,16 @@ export function SettingsModal({
|
|
| 698 |
{active === "account" ? (
|
| 699 |
<div className="set-pane">
|
| 700 |
<h3 className="set-h">Account</h3>
|
| 701 |
-
|
| 702 |
-
|
| 703 |
-
|
| 704 |
-
|
| 705 |
-
|
| 706 |
-
|
| 707 |
-
|
| 708 |
-
|
| 709 |
-
|
| 710 |
-
|
| 711 |
-
<span className="pg-drill-val">{admin ? "Admin" : "Member"}</span>
|
| 712 |
-
</div>
|
| 713 |
-
<ProfilePhotoBlock user={user} onUser={onUser} />
|
| 714 |
</div>
|
| 715 |
) : null}
|
| 716 |
|
|
@@ -724,16 +681,32 @@ export function SettingsModal({
|
|
| 724 |
say so. A pane reporting "All modules" while a filter quietly
|
| 725 |
halves somebody's book is worse than the row it replaced β
|
| 726 |
that is the user who files a bug about the numbers. */}
|
| 727 |
-
<p className="set-help">
|
| 728 |
What this account may open, and anything that narrows it. Only an
|
| 729 |
administrator can change this.
|
| 730 |
</p>
|
| 731 |
-
|
| 732 |
-
|
| 733 |
-
|
| 734 |
-
|
| 735 |
-
|
| 736 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 737 |
{/* One row per module the account is restricted in. `moduleSummary`
|
| 738 |
is the SAME sentence the admin editor shows, from the same
|
| 739 |
function β two dialects of "2 conditions, 3 fields hidden"
|
|
@@ -755,6 +728,7 @@ export function SettingsModal({
|
|
| 755 |
);
|
| 756 |
})
|
| 757 |
: null}
|
|
|
|
| 758 |
</div>
|
| 759 |
) : null}
|
| 760 |
|
|
|
|
| 29 |
import { useCallback, useEffect, useRef, useState } from "react";
|
| 30 |
import type { SessionUser } from "../shell/session";
|
| 31 |
import { isAdmin, parseUserEnvelope } from "../shell/session";
|
| 32 |
+
import type { AdminUser, SettingsPayload } from "./settingsApi";
|
| 33 |
+
// β `patchUser` and `setPassword` left this file with `EditUser` (R7) β they are
|
| 34 |
+
// imported by `PermsEditor` now, where the form that writes them lives, and it
|
| 35 |
+
// spells the patch shape `Parameters<typeof patchUser>[1]` rather than importing
|
| 36 |
+
// `UserPatch` separately. `noUnusedLocals` is what walks a move like this down to
|
| 37 |
+
// the last orphaned import, which is the tsconfig earning its keep again.
|
| 38 |
+
import { clearAvatar, createUser, getSettings, listUsers, setAvatar } from "./settingsApi";
|
|
|
|
|
|
|
|
|
|
| 39 |
import { PermsEditor } from "./PermsEditor";
|
| 40 |
import { moduleSummary, parseEntry, reachableSection } from "./permsModel";
|
| 41 |
|
|
|
|
| 61 |
|
| 62 |
// ------------------------------------------------------------------ the users pane
|
| 63 |
|
| 64 |
+
/** The trailing affordance on an account card. SVG, never a character glyph. */
|
| 65 |
+
function ChevIcon() {
|
| 66 |
+
return (
|
| 67 |
+
<svg className="set-acct-chev" viewBox="0 0 12 12" aria-hidden="true">
|
| 68 |
+
<path d="M4.4 2.4 8 6l-3.6 3.6" />
|
| 69 |
+
</svg>
|
| 70 |
+
);
|
| 71 |
+
}
|
| 72 |
+
|
| 73 |
function UsersPane() {
|
| 74 |
const [users, setUsers] = useState<AdminUser[] | null>(null);
|
| 75 |
const [error, setError] = useState("");
|
| 76 |
const [notice, setNotice] = useState("");
|
| 77 |
+
/**
|
| 78 |
+
* β WAVE 17 R7 β ONE STATE, WHERE THERE WERE TWO. This pane held `editing`
|
| 79 |
+
* (the inline account-details card, at the BOTTOM of the list) and `permsFor`
|
| 80 |
+
* (the full-pane access page) as separate things, on the wave-15 reasoning
|
| 81 |
+
* that *"they are two different jobs: one changes who the account IS, the
|
| 82 |
+
* other changes what it may SEE"*. True about the data, wrong about the
|
| 83 |
+
* person: an admin opening an account does not know in advance which of the
|
| 84 |
+
* two they came for, and the product offered them two doors, one of which
|
| 85 |
+
* scrolled the page instead of changing it. The owner met that as *"Edit and
|
| 86 |
+
* clicking a user name should just be the EXACT same opening of a full page
|
| 87 |
+
* so its not confusing"*. There is one door now, and one thing behind it.
|
| 88 |
+
*/
|
| 89 |
+
const [open, setOpen] = useState<string | null>(null);
|
| 90 |
|
| 91 |
const reload = useCallback(() => {
|
| 92 |
void listUsers().then((r) => {
|
|
|
|
| 102 |
|
| 103 |
useEffect(reload, [reload]);
|
| 104 |
|
| 105 |
+
// wave17 item 3 (R6). β `.pg-empty` was the WRONG BOX as well as the wrong
|
| 106 |
+
// words: it is the dashed empty-state frame, so a list that was merely still
|
| 107 |
+
// arriving was drawn in the chrome that means "there is nothing here".
|
| 108 |
+
if (users === null)
|
| 109 |
+
return (
|
| 110 |
+
<div className="set-loading">
|
| 111 |
+
<span className="lp-spin lp-spin--lg" role="status" aria-label="Loading" />
|
| 112 |
+
</div>
|
| 113 |
+
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 114 |
|
| 115 |
+
// The FULL-PANE TAKEOVER: the users pane IS the modal body, so returning the
|
| 116 |
+
// page here replaces the whole body and nothing else has to know. The rail
|
| 117 |
+
// stays β it is chrome, not body, and an admin who wants out of this page
|
| 118 |
+
// entirely should not have to find a Back button first.
|
| 119 |
+
if (open) {
|
| 120 |
+
const who = users.find((u) => u.username === open);
|
| 121 |
+
// The record can genuinely vanish under an open page: `reload()` runs after
|
| 122 |
+
// every write, and another admin may have removed the account in between.
|
| 123 |
+
// Saying so beats rendering a page about nobody.
|
| 124 |
+
if (!who) {
|
| 125 |
+
return (
|
| 126 |
+
<div className="set-pane">
|
| 127 |
+
<section className="set-card">
|
| 128 |
+
<h4 className="set-h4">That account is no longer listed</h4>
|
| 129 |
+
<p className="set-help">It may have been removed since this list was loaded.</p>
|
| 130 |
+
<div className="set-actions">
|
| 131 |
+
<button type="button" className="set-secondary" onClick={() => setOpen(null)}>
|
| 132 |
+
Back to accounts
|
| 133 |
+
</button>
|
| 134 |
+
</div>
|
| 135 |
+
</section>
|
| 136 |
+
</div>
|
| 137 |
+
);
|
| 138 |
+
}
|
| 139 |
return (
|
| 140 |
<PermsEditor
|
| 141 |
+
// Remount per account: the page holds a DRAFT of somebody's permissions
|
| 142 |
+
// and an unsaved display name, and carrying either across a switch of
|
| 143 |
+
// subject is how one account's edits get saved onto another.
|
| 144 |
+
key={who.username}
|
| 145 |
+
user={who}
|
| 146 |
+
// β TWO LISTS, TWO JOBS, AND MIXING THEM MAKES A WRONG URL. These are
|
| 147 |
+
// DISPLAY NAMES, for `user`-typed filter conditions β the cells hold
|
| 148 |
+
// names, so the builder must offer names. `copyTargets` below carries
|
| 149 |
+
// the RECORDS, because a copy addresses accounts by USERNAME.
|
| 150 |
userOptions={users.map((u) => u.name || u.username)}
|
| 151 |
+
copyTargets={users.filter((u) => u.username !== who.username)}
|
| 152 |
+
onBack={() => setOpen(null)}
|
| 153 |
+
// β IT DOES NOT CLOSE THE PAGE ANY MORE. Wave 15's version returned to
|
| 154 |
+
// the list on save, which was right when this was only an access
|
| 155 |
+
// editor. It is one page with several things to save now, and a page
|
| 156 |
+
// that ejects you after the first of them is a page you have to
|
| 157 |
+
// re-open to finish the job. The way out stays visible instead.
|
| 158 |
onSaved={(msg) => {
|
|
|
|
| 159 |
setNotice(msg);
|
| 160 |
setError("");
|
| 161 |
reload();
|
|
|
|
| 173 |
{users.length === 0 && !error ? (
|
| 174 |
<p className="pg-empty">No accounts are configured on this deployment yet.</p>
|
| 175 |
) : (
|
| 176 |
+
/* β WAVE 17 R7 β A LIST OF CARDS, NOT A TABLE, and the shape is the
|
| 177 |
+
feature. The owner asked to "click the whole user's Card, not just
|
| 178 |
+
name, so it has bigger hit box": in a table the only click target
|
| 179 |
+
that could exist was the name itself, because a `<tr onClick>` is
|
| 180 |
+
invisible to a keyboard and wrapping every cell in a button is five
|
| 181 |
+
tab stops per row. One `<button>` per account is ONE control with the
|
| 182 |
+
whole card as its hit box, focusable and Enter-able for free.
|
| 183 |
+
β "Business units" IS STILL GONE (R1) and did not come back as a
|
| 184 |
+
card line. What replaced it is the access sentence, which is a page
|
| 185 |
+
now rather than a cell because a permanent filter does not fit in
|
| 186 |
+
one. */
|
| 187 |
+
<ul className="set-acctlist">
|
| 188 |
+
{users.map((u) => (
|
| 189 |
+
<li key={u.username}>
|
| 190 |
+
<button
|
| 191 |
+
type="button"
|
| 192 |
+
className={"set-acct" + (u.active ? "" : " is-inactive")}
|
| 193 |
+
onClick={() => setOpen(u.username)}
|
| 194 |
+
>
|
| 195 |
+
<Monogram name={u.name || u.username} />
|
| 196 |
+
<span className="set-acct-body">
|
| 197 |
+
<span className="set-acct-top">
|
| 198 |
+
<span className="set-acct-name">{u.name || u.username}</span>
|
| 199 |
+
<RoleChip admin={u.role === "admin"} />
|
| 200 |
+
{u.active ? null : <span className="set-chip set-chip--off">Deactivated</span>}
|
| 201 |
+
</span>
|
| 202 |
+
<span className="set-acct-sub">{u.username}</span>
|
| 203 |
+
{/* β An admin BYPASSES perms entirely (C-PERM amendment 4) β
|
| 204 |
+
the clause that also keeps break-glass alive during a
|
| 205 |
+
store outage. Saying "Everything (admin)" rather than
|
| 206 |
+
rendering a rule prevents the one dangerous misreading:
|
| 207 |
+
that the restrictions on an admin's access page are in
|
| 208 |
+
force. */}
|
| 209 |
+
<span className="set-acct-access">
|
| 210 |
+
{u.role === "admin"
|
| 211 |
+
? "Everything (admin)"
|
| 212 |
+
: (u.accessSummary ?? moduleWords(u.modules))}
|
| 213 |
+
</span>
|
| 214 |
+
</span>
|
| 215 |
+
{/* β A SPAN, NOT A BUTTON, AND THAT IS THE POINT OF R7. It is
|
| 216 |
+
inside the card's own button, so clicking the word "Edit"
|
| 217 |
+
opens exactly the page clicking anywhere else on the card
|
| 218 |
+
opens β which is the ruling, literally. A real nested button
|
| 219 |
+
is invalid markup, and the stretched-link alternative would
|
| 220 |
+
put two tab stops on one destination: the confusion the
|
| 221 |
+
ruling names, rebuilt in the accessibility tree. */}
|
| 222 |
+
<span className="set-acct-go">
|
| 223 |
+
Edit
|
| 224 |
+
<ChevIcon />
|
| 225 |
+
</span>
|
| 226 |
+
</button>
|
| 227 |
+
</li>
|
| 228 |
+
))}
|
| 229 |
+
</ul>
|
|
|
|
|
|
|
| 230 |
)}
|
| 231 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 232 |
<AddUser
|
| 233 |
onCreated={(msg) => {
|
| 234 |
setNotice(msg);
|
|
|
|
| 258 |
// no longer exists is a UI that WRITES it β see EditUser/AddUser below, which
|
| 259 |
// deliberately stopped sending the field they can no longer edit.
|
| 260 |
|
| 261 |
+
// β `EditUser` WAS HERE. It is not deleted so much as RELOCATED β every control
|
| 262 |
+
// it held (display name, role, deactivate/reactivate, password reset with its
|
| 263 |
+
// signs-them-out-everywhere warning) now lives at the top of the user page in
|
| 264 |
+
// `PermsEditor`, which is the whole of R7: *"Edit and clicking a user name
|
| 265 |
+
// should just be the EXACT same opening of a full page"*. What genuinely died
|
| 266 |
+
// is the SHAPE β a card that appeared at the bottom of the accounts list, below
|
| 267 |
+
// the fold, describing a row somewhere above it. Two doors, two layouts and one
|
| 268 |
+
// of them scrolled instead of navigating.
|
| 269 |
+
//
|
| 270 |
+
// β The load-bearing note from this block MOVES WITH THE FORM and is restated
|
| 271 |
+
// there: the PATCH still carries no `bus` (R1). With the picker gone the form
|
| 272 |
+
// cannot edit that field, so sending it would be a client echoing back a value
|
| 273 |
+
// it only read β and once the migration converts `bus` into a permanent filter
|
| 274 |
+
// and clears the field, that echo would RESURRECT it.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 275 |
|
| 276 |
function AddUser({
|
| 277 |
onCreated,
|
|
|
|
| 417 |
}
|
| 418 |
}
|
| 419 |
|
| 420 |
+
/** The first letter of a name, the way both shells compute it.
|
| 421 |
+
* β Unicode letter/number, not `[a-z0-9]` β the app's `_account_css` uses
|
| 422 |
+
* Python's `str.isalnum()`, so an ASCII-only class here would give a non-Latin
|
| 423 |
+
* name an initial in one door and a blank circle in the other. */
|
| 424 |
+
function initialOf(name: string): string {
|
| 425 |
+
return (name.match(/[\p{L}\p{N}]/u)?.[0] ?? "?").toUpperCase();
|
| 426 |
+
}
|
| 427 |
+
|
| 428 |
+
/**
|
| 429 |
+
* β WAVE 17 (16b) β THE INLINE STYLES ARE GONE, AND SO IS THEIR JUSTIFICATION.
|
| 430 |
+
* This block used to carry twelve declarations in a `style` object under the
|
| 431 |
+
* note *"the `.set-*`/`.shell-*` stylesheet is another wave-14 session's file"*.
|
| 432 |
+
* That was true then and is not true now β SHELL owns the `.set-*` region this
|
| 433 |
+
* wave β and an inline `background: "var(--lp-blue-tint)"` is still a colour
|
| 434 |
+
* decision living outside the stylesheet, which is the thing the file-wide
|
| 435 |
+
* token rule exists to stop. Two sizes are needed (the identity header and an
|
| 436 |
+
* accounts card), so there are two classes rather than a size prop threading a
|
| 437 |
+
* number into CSS.
|
| 438 |
+
*/
|
| 439 |
+
function AvatarPreview({ user, large }: { user: SessionUser; large?: boolean }) {
|
| 440 |
+
const cls = large ? "set-avatar set-avatar--lg" : "set-avatar";
|
| 441 |
if (user.avatar) {
|
| 442 |
+
return <img className={cls} src={user.avatar} alt="" aria-hidden="true" />;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 443 |
}
|
|
|
|
| 444 |
return (
|
| 445 |
+
<span className={cls} aria-hidden="true">
|
| 446 |
+
{initialOf(user.name)}
|
| 447 |
+
</span>
|
| 448 |
+
);
|
| 449 |
+
}
|
| 450 |
+
|
| 451 |
+
/** The accounts list's monogram. A separate component because `AdminUser`
|
| 452 |
+
* carries no `avatar` β only the SIGNED-IN user's photo is on the wire β so
|
| 453 |
+
* offering a photo slot here would be a hole nothing can fill. */
|
| 454 |
+
function Monogram({ name }: { name: string }) {
|
| 455 |
+
return (
|
| 456 |
+
<span className="set-avatar" aria-hidden="true">
|
| 457 |
+
{initialOf(name)}
|
| 458 |
+
</span>
|
| 459 |
+
);
|
| 460 |
+
}
|
| 461 |
+
|
| 462 |
+
/** The role, as a chip rather than a table cell (16b). Two roles, one of which
|
| 463 |
+
* bypasses every rule in the product β that is a property of the account, and a
|
| 464 |
+
* property belongs beside the name, not in a row of key/value pairs. */
|
| 465 |
+
function RoleChip({ admin }: { admin: boolean }) {
|
| 466 |
+
return (
|
| 467 |
+
<span className={admin ? "set-chip set-chip--admin" : "set-chip"}>
|
| 468 |
+
{admin ? "Admin" : "Member"}
|
| 469 |
</span>
|
| 470 |
);
|
| 471 |
}
|
| 472 |
|
| 473 |
function ProfilePhotoBlock({
|
| 474 |
user,
|
| 475 |
+
admin,
|
| 476 |
onUser,
|
| 477 |
}: {
|
| 478 |
user: SessionUser;
|
| 479 |
+
admin: boolean;
|
| 480 |
onUser?: (u: SessionUser) => void;
|
| 481 |
}) {
|
| 482 |
const [busy, setBusy] = useState(false);
|
|
|
|
| 518 |
}
|
| 519 |
}, [onUser]);
|
| 520 |
|
| 521 |
+
// β THE HELP SENTENCE IS DELETED (wave 17, item 16b, owner's instruction:
|
| 522 |
+
// "replace with layout, not copy"). It read "Shown on Assignee fields and your
|
| 523 |
+
// account chip. Square images look best; large ones are scaled down
|
| 524 |
+
// automatically." Every clause was work the interface should do rather than
|
| 525 |
+
// explain: WHERE the photo appears is answered by showing it at the size and
|
| 526 |
+
// shape it will be worn, beside the name it belongs to; SQUARE IS BEST and
|
| 527 |
+
// LARGE ONES ARE SCALED are apologies for a centre-crop-and-downscale that
|
| 528 |
+
// already happens without asking (`fileToAvatarDataUrl`) and that the user
|
| 529 |
+
// cannot influence. A sentence describing behaviour the reader has no control
|
| 530 |
+
// over is decoration.
|
| 531 |
return (
|
| 532 |
+
<div className="set-identity">
|
| 533 |
+
<AvatarPreview user={user} large />
|
| 534 |
+
<div className="set-identity-body">
|
| 535 |
+
<div className="set-identity-head">
|
| 536 |
+
<span className="set-identity-name">{user.name}</span>
|
| 537 |
+
<RoleChip admin={admin} />
|
| 538 |
+
</div>
|
| 539 |
+
<div className="set-identity-sub">{user.username}</div>
|
| 540 |
+
<div className="set-identity-acts">
|
| 541 |
+
<input
|
| 542 |
+
ref={fileRef}
|
| 543 |
+
type="file"
|
| 544 |
+
accept="image/png,image/jpeg"
|
| 545 |
+
className="set-filepick"
|
| 546 |
+
onChange={(e) => {
|
| 547 |
+
const f = e.target.files?.[0];
|
| 548 |
+
e.target.value = "";
|
| 549 |
+
if (f) void upload(f);
|
| 550 |
+
}}
|
| 551 |
+
/>
|
| 552 |
+
<button
|
| 553 |
+
type="button"
|
| 554 |
+
className="set-secondary"
|
| 555 |
+
disabled={busy}
|
| 556 |
+
onClick={() => fileRef.current?.click()}
|
| 557 |
+
>
|
| 558 |
+
{user.avatar ? "Change photo" : "Upload photo"}
|
|
|
|
|
|
|
|
|
|
|
|
|
| 559 |
</button>
|
| 560 |
+
{user.avatar ? (
|
| 561 |
+
<button type="button" className="set-secondary" disabled={busy} onClick={remove}>
|
| 562 |
+
Remove
|
| 563 |
+
</button>
|
| 564 |
+
) : null}
|
| 565 |
+
</div>
|
| 566 |
+
{error ? <p className="set-error set-identity-err">{error}</p> : null}
|
| 567 |
</div>
|
| 568 |
+
</div>
|
| 569 |
);
|
| 570 |
}
|
| 571 |
|
|
|
|
| 658 |
{active === "account" ? (
|
| 659 |
<div className="set-pane">
|
| 660 |
<h3 className="set-h">Account</h3>
|
| 661 |
+
{/* β WAVE 17 (16b) β THE THREE KEY/VALUE ROWS ARE NOT DELETED,
|
| 662 |
+
THEY ARE LAID OUT. "Signed in as", "Username" and "Role" were a
|
| 663 |
+
three-row table restating what a photo, a name and a chip say
|
| 664 |
+
at a glance β and the photo block sat UNDER them, so the pane
|
| 665 |
+
opened on a label reading "Signed in as" above the picture of
|
| 666 |
+
the person it was labelling. The identity header carries all
|
| 667 |
+
three now: the name at title weight, the username beneath it,
|
| 668 |
+
the role as a chip beside it. Nothing was dropped; the labels
|
| 669 |
+
were, because each one named the obvious. */}
|
| 670 |
+
<ProfilePhotoBlock user={user} admin={admin} onUser={onUser} />
|
|
|
|
|
|
|
|
|
|
| 671 |
</div>
|
| 672 |
) : null}
|
| 673 |
|
|
|
|
| 681 |
say so. A pane reporting "All modules" while a filter quietly
|
| 682 |
halves somebody's book is worse than the row it replaced β
|
| 683 |
that is the user who files a bug about the numbers. */}
|
| 684 |
+
<p className="set-help set-pane-intro">
|
| 685 |
What this account may open, and anything that narrows it. Only an
|
| 686 |
administrator can change this.
|
| 687 |
</p>
|
| 688 |
+
{/* 16b β one card, so the restrictions read as a group belonging to
|
| 689 |
+
the heading rather than as loose rows floating under it. */}
|
| 690 |
+
<section className="set-card set-card--rows">
|
| 691 |
+
<div className="pg-drill-row">
|
| 692 |
+
<span className="pg-drill-key">Modules</span>
|
| 693 |
+
<span className="pg-drill-val">
|
| 694 |
+
{moduleWords(settings?.scope.modules ?? user.modules)}
|
| 695 |
+
</span>
|
| 696 |
+
</div>
|
| 697 |
+
{/* An admin's "All modules" is true but does not say WHY, and the
|
| 698 |
+
why is the part that matters: it is not a grant somebody can
|
| 699 |
+
revoke module by module, it is a bypass. The accounts list
|
| 700 |
+
already says "Everything (admin)" β this is the same fact, on
|
| 701 |
+
the account's own page, so the two doors agree. */}
|
| 702 |
+
{admin ? (
|
| 703 |
+
<div className="pg-drill-row">
|
| 704 |
+
<span className="pg-drill-key">Restrictions</span>
|
| 705 |
+
<span className="pg-drill-val">
|
| 706 |
+
None apply β administrators bypass every rule
|
| 707 |
+
</span>
|
| 708 |
+
</div>
|
| 709 |
+
) : null}
|
| 710 |
{/* One row per module the account is restricted in. `moduleSummary`
|
| 711 |
is the SAME sentence the admin editor shows, from the same
|
| 712 |
function β two dialects of "2 conditions, 3 fields hidden"
|
|
|
|
| 728 |
);
|
| 729 |
})
|
| 730 |
: null}
|
| 731 |
+
</section>
|
| 732 |
</div>
|
| 733 |
) : null}
|
| 734 |
|
web/src/settings/permsModel.ts
CHANGED
|
@@ -362,6 +362,72 @@ export function toPutBody(payload: PermsPayload, rec: PermsRecord): { perms: Per
|
|
| 362 |
return { perms };
|
| 363 |
}
|
| 364 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 365 |
/** Compares the SENT SHAPE, not the draft, so a change the payload cannot carry
|
| 366 |
* (a hidden-field list on a schema-less module) never lights up Save. */
|
| 367 |
export function isDirty(payload: PermsPayload, saved: PermsRecord, draft: PermsRecord): boolean {
|
|
|
|
| 362 |
return { perms };
|
| 363 |
}
|
| 364 |
|
| 365 |
+
/** Which slice of one account's access a copy carries onto another. */
|
| 366 |
+
export type CopyScope = { kind: "all" } | { kind: "module"; key: string };
|
| 367 |
+
|
| 368 |
+
/**
|
| 369 |
+
* C-PERMCOPY (wave 17, item 16) β the record to PUT onto ONE target, composed
|
| 370 |
+
* from that target's OWN payload and this account's SAVED entries.
|
| 371 |
+
*
|
| 372 |
+
* β WHY THIS IS A FUNCTION AND NOT FOUR LINES IN THE COMPONENT. It is the
|
| 373 |
+
* SECOND producer of a PUT body in the product, and the first one aimed at
|
| 374 |
+
* somebody else's record. A PUT is a whole-record replace: a key that does not
|
| 375 |
+
* come back is DELETED. `toPutBody` already carries a negative control named
|
| 376 |
+
* `replace-omits-untouched-modules` for exactly that failure β and every way of
|
| 377 |
+
* getting it wrong from here reaches the same place by a different road. Inline
|
| 378 |
+
* in a `useCallback`, no gate could see any of it.
|
| 379 |
+
*
|
| 380 |
+
* THE RULE, in one line: **the target's tree is the base; the copy overwrites
|
| 381 |
+
* a slice of it.** Never the source's tree with the target's bits merged in β
|
| 382 |
+
* that composes a record out of modules the TARGET may not declare.
|
| 383 |
+
*
|
| 384 |
+
* Β· `{kind:'all'}` β the whole record is replaced by the source's.
|
| 385 |
+
* Β· `{kind:'module'}` β that one module is replaced; every other module keeps
|
| 386 |
+
* the value the target's own GET returned, byte for byte.
|
| 387 |
+
*
|
| 388 |
+
* β TWO EDGES, both currently unreachable because `_PERM_MODULES` is server-wide
|
| 389 |
+
* (every payload declares the same modules), and both named rather than left to
|
| 390 |
+
* be discovered if that ever stops being true:
|
| 391 |
+
* 1. The source has a module the TARGET does not declare. `toPutBody` iterates
|
| 392 |
+
* the TARGET's modules, so the copy is dropped β silently, under a message
|
| 393 |
+
* that says it was copied. `copyDropped()` below is what lets the caller
|
| 394 |
+
* tell the truth about that.
|
| 395 |
+
* 2. The target declares a module the SOURCE has no entry for. It lands on
|
| 396 |
+
* `NO_ACCESS`, which is the honest reading of "apply this account's access":
|
| 397 |
+
* if the source does not grant it, the target must not keep it. Deliberate,
|
| 398 |
+
* and it is why a whole-record copy is offered as "replace", not "merge".
|
| 399 |
+
*/
|
| 400 |
+
export function copyTargetRecord(
|
| 401 |
+
target: PermsPayload,
|
| 402 |
+
source: PermsRecord,
|
| 403 |
+
scope: CopyScope
|
| 404 |
+
): PermsRecord {
|
| 405 |
+
if (scope.kind === "all") {
|
| 406 |
+
const out: PermsRecord = {};
|
| 407 |
+
for (const m of target.modules) {
|
| 408 |
+
out[m.key] = source[m.key] ?? { access: false, filter: null, hiddenFields: [] };
|
| 409 |
+
}
|
| 410 |
+
return out;
|
| 411 |
+
}
|
| 412 |
+
return {
|
| 413 |
+
...target.entries,
|
| 414 |
+
[scope.key]: source[scope.key] ?? { access: false, filter: null, hiddenFields: [] },
|
| 415 |
+
};
|
| 416 |
+
}
|
| 417 |
+
|
| 418 |
+
/** The modules a copy CANNOT carry, because the target does not declare them.
|
| 419 |
+
* Empty in every deployment where the module list is server-wide; a caller that
|
| 420 |
+
* reports "copied" without consulting it would be guessing. */
|
| 421 |
+
export function copyDropped(
|
| 422 |
+
target: PermsPayload,
|
| 423 |
+
source: PermsRecord,
|
| 424 |
+
scope: CopyScope
|
| 425 |
+
): string[] {
|
| 426 |
+
const declared = new Set(target.modules.map((m) => m.key));
|
| 427 |
+
const wanted = scope.kind === "all" ? Object.keys(source) : [scope.key];
|
| 428 |
+
return wanted.filter((k) => !declared.has(k)).sort();
|
| 429 |
+
}
|
| 430 |
+
|
| 431 |
/** Compares the SENT SHAPE, not the draft, so a change the payload cannot carry
|
| 432 |
* (a hidden-field list on a schema-less module) never lights up Save. */
|
| 433 |
export function isDirty(payload: PermsPayload, saved: PermsRecord, draft: PermsRecord): boolean {
|
web/src/shell/NavExtras.tsx
CHANGED
|
@@ -332,7 +332,12 @@ export function SchemaDrawer({
|
|
| 332 |
aria-label="Database schema"
|
| 333 |
onMouseDown={(e) => e.stopPropagation()}
|
| 334 |
>
|
| 335 |
-
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 336 |
{state.phase === "error" && (
|
| 337 |
<div className="shell-schema-empty">
|
| 338 |
The schema could not be loaded. Close this panel and try again.
|
|
|
|
| 332 |
aria-label="Database schema"
|
| 333 |
onMouseDown={(e) => e.stopPropagation()}
|
| 334 |
>
|
| 335 |
+
{/* wave17 item 3 (R6) β the drawer opens on a mark, not on a sentence. */}
|
| 336 |
+
{state.phase === "loading" && (
|
| 337 |
+
<div className="shell-schema-empty is-spin">
|
| 338 |
+
<span className="lp-spin lp-spin--lg" role="status" aria-label="Loading" />
|
| 339 |
+
</div>
|
| 340 |
+
)}
|
| 341 |
{state.phase === "error" && (
|
| 342 |
<div className="shell-schema-empty">
|
| 343 |
The schema could not be loaded. Close this panel and try again.
|
web/src/shell/Shell.tsx
CHANGED
|
@@ -255,15 +255,16 @@ function AccountMenu({
|
|
| 255 |
rel="noreferrer"
|
| 256 |
onClick={() => setOpen(false)}
|
| 257 |
>
|
| 258 |
-
{/*
|
| 259 |
-
|
| 260 |
-
|
| 261 |
-
|
| 262 |
-
|
| 263 |
-
|
| 264 |
-
|
| 265 |
-
|
| 266 |
-
|
|
|
|
| 267 |
<ExtIcon />
|
| 268 |
</a>
|
| 269 |
))}
|
|
@@ -689,10 +690,15 @@ export default function Shell() {
|
|
| 689 |
);
|
| 690 |
}
|
| 691 |
const item = row.entry;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 692 |
const cls =
|
| 693 |
"shell-nav-item" +
|
| 694 |
(item.depth > 0 ? " is-child" : "") +
|
| 695 |
-
(
|
| 696 |
const inner = (
|
| 697 |
<>
|
| 698 |
<DbIcon />
|
|
@@ -744,6 +750,7 @@ export default function Shell() {
|
|
| 744 |
key={item.key}
|
| 745 |
className={
|
| 746 |
"shell-nav-row" +
|
|
|
|
| 747 |
(row.folderId ? " is-foldered" : "") +
|
| 748 |
(dragKey === item.key ? " is-dragging" : "")
|
| 749 |
}
|
|
@@ -775,7 +782,14 @@ export default function Shell() {
|
|
| 775 |
<NewFolderRow onCreate={createFolder} />
|
| 776 |
) : null}
|
| 777 |
</div>
|
| 778 |
-
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 779 |
{/* Honest, and it names the fix. Inventing a nav here would show
|
| 780 |
surfaces the server never granted. */}
|
| 781 |
{nav.phase === "error" ? (
|
|
@@ -859,7 +873,15 @@ export default function Shell() {
|
|
| 859 |
</div>
|
| 860 |
) : active ? (
|
| 861 |
<StranglerPage entry={active} />
|
| 862 |
-
) : (
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 863 |
<div className="shell-placeholder">
|
| 864 |
<h1>Nothing to show</h1>
|
| 865 |
<p>
|
|
@@ -868,6 +890,11 @@ export default function Shell() {
|
|
| 868 |
: "This account has access to no surfaces yet."}
|
| 869 |
</p>
|
| 870 |
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 871 |
)}
|
| 872 |
</main>
|
| 873 |
|
|
|
|
| 255 |
rel="noreferrer"
|
| 256 |
onClick={() => setOpen(false)}
|
| 257 |
>
|
| 258 |
+
{/* WAVE 17 ITEM 15b (R8) β the `settings` special-case is GONE.
|
| 259 |
+
This row used to relabel one registry key on its way to the
|
| 260 |
+
screen, which is a client deciding what the payload meant. R8
|
| 261 |
+
deletes the host surface itself, so the honest client change
|
| 262 |
+
is not to HIDE the key here β hard-coding an exclusion would
|
| 263 |
+
outlive the thing it excludes β but to stop treating any key
|
| 264 |
+
specially and let the payload decide. When `nav_pages` stops
|
| 265 |
+
emitting it, the row stops existing, with nothing here to
|
| 266 |
+
update. Every utility row now wears its registry label. */}
|
| 267 |
+
{p.label}
|
| 268 |
<ExtIcon />
|
| 269 |
</a>
|
| 270 |
))}
|
|
|
|
| 690 |
);
|
| 691 |
}
|
| 692 |
const item = row.entry;
|
| 693 |
+
// Wave 17 item 12 β ONE answer, read by the row AND the link.
|
| 694 |
+
// The row paints the tint (so it reaches under the β―, matching
|
| 695 |
+
// the Views rail); the link keeps the class because the weight
|
| 696 |
+
// and the full-strength icon hang off `.shell-nav-item.is-active`.
|
| 697 |
+
const isActive = !!active && active.key === item.key;
|
| 698 |
const cls =
|
| 699 |
"shell-nav-item" +
|
| 700 |
(item.depth > 0 ? " is-child" : "") +
|
| 701 |
+
(isActive ? " is-active" : "");
|
| 702 |
const inner = (
|
| 703 |
<>
|
| 704 |
<DbIcon />
|
|
|
|
| 750 |
key={item.key}
|
| 751 |
className={
|
| 752 |
"shell-nav-row" +
|
| 753 |
+
(isActive ? " is-active" : "") +
|
| 754 |
(row.folderId ? " is-foldered" : "") +
|
| 755 |
(dragKey === item.key ? " is-dragging" : "")
|
| 756 |
}
|
|
|
|
| 782 |
<NewFolderRow onCreate={createFolder} />
|
| 783 |
) : null}
|
| 784 |
</div>
|
| 785 |
+
{/* Wave 17 item 3 (R6) β the mark, never the word. "Loadingβ¦" under an
|
| 786 |
+
empty rail told the reader what they could already see, and it read
|
| 787 |
+
as a nav ITEM for the beat before it vanished. */}
|
| 788 |
+
{nav.phase === "loading" ? (
|
| 789 |
+
<div className="shell-nav-note is-spin">
|
| 790 |
+
<span className="lp-spin" role="status" aria-label="Loading" />
|
| 791 |
+
</div>
|
| 792 |
+
) : null}
|
| 793 |
{/* Honest, and it names the fix. Inventing a nav here would show
|
| 794 |
surfaces the server never granted. */}
|
| 795 |
{nav.phase === "error" ? (
|
|
|
|
| 873 |
</div>
|
| 874 |
) : active ? (
|
| 875 |
<StranglerPage entry={active} />
|
| 876 |
+
) : nav.phase === "ready" || nav.phase === "error" ? (
|
| 877 |
+
// β WAVE 17 ITEM 4 (R6) β THIS BRANCH IS ONLY REACHED HONESTLY ONCE
|
| 878 |
+
// THE NAV HAS ANSWERED. `active` is resolved from `entries`, which is
|
| 879 |
+
// empty while the nav is in flight, so every first login used to land
|
| 880 |
+
// here and be told "This account has access to no surfaces yet" β
|
| 881 |
+
// stating, as fact, the single worst thing this frame could say to a
|
| 882 |
+
// new user, for as long as the round trip took. The sentence is
|
| 883 |
+
// RIGHT for a nav that came back empty and WRONG for one that has not
|
| 884 |
+
// come back, and those two were indistinguishable. They are not now.
|
| 885 |
<div className="shell-placeholder">
|
| 886 |
<h1>Nothing to show</h1>
|
| 887 |
<p>
|
|
|
|
| 890 |
: "This account has access to no surfaces yet."}
|
| 891 |
</p>
|
| 892 |
</div>
|
| 893 |
+
) : (
|
| 894 |
+
// Still asking (`loading`, or the `idle` beat before the effect runs).
|
| 895 |
+
<div className="shell-loading">
|
| 896 |
+
<span className="lp-spin lp-spin--lg" role="status" aria-label="Loading" />
|
| 897 |
+
</div>
|
| 898 |
)}
|
| 899 |
</main>
|
| 900 |
|
web/src/shell/navExtras.css
CHANGED
|
@@ -6,6 +6,23 @@
|
|
| 6 |
display: flex;
|
| 7 |
align-items: stretch;
|
| 8 |
min-width: 0;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 9 |
}
|
| 10 |
|
| 11 |
.shell-nav-row > .shell-nav-item {
|
|
@@ -13,6 +30,19 @@
|
|
| 13 |
min-width: 0;
|
| 14 |
}
|
| 15 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 16 |
.shell-nav-row > .shell-dots,
|
| 17 |
.shell-nav-folder > .shell-dots {
|
| 18 |
flex: 0 0 auto;
|
|
@@ -86,10 +116,22 @@
|
|
| 86 |
.shell-nav-foldercount {
|
| 87 |
margin-left: auto;
|
| 88 |
/* Wave 14 item 7 β the count wears the LABEL's size, muted; nothing "all over the
|
| 89 |
-
place with regards to symmetry".
|
| 90 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 91 |
font-weight: 400;
|
| 92 |
color: var(--lp-muted);
|
|
|
|
|
|
|
| 93 |
}
|
| 94 |
|
| 95 |
/* ββ wave 14 C-NAVFOLD: drag placement (items 4/6) βββββββββββββββββββββββββ */
|
|
@@ -318,6 +360,15 @@
|
|
| 318 |
font-size: var(--lp-fs-xs);
|
| 319 |
}
|
| 320 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 321 |
.shell-schema-note {
|
| 322 |
padding: 9px 11px;
|
| 323 |
border: 1px solid var(--lp-line);
|
|
|
|
| 6 |
display: flex;
|
| 7 |
align-items: stretch;
|
| 8 |
min-width: 0;
|
| 9 |
+
/* wave17 SHELL (item 12) β the row is the painted surface now, so it needs
|
| 10 |
+
the shape the `<a>` used to draw. `--lp-r-sm` and not the Views rail's
|
| 11 |
+
`--lp-r-md`: the tint must land exactly where the item's hover pill lands
|
| 12 |
+
today, and every other pill in this rail is 4px. Item 12 asks the highlight
|
| 13 |
+
to reach the β―; it does not ask the nav to change shape. */
|
| 14 |
+
border-radius: var(--lp-r-sm);
|
| 15 |
+
}
|
| 16 |
+
|
| 17 |
+
/* The ROW carries hover and current-state, exactly as `.cg-view-row` does in
|
| 18 |
+
the Views rail β which is the whole of item 12. Hovering the three-dots now
|
| 19 |
+
lights the row it belongs to instead of leaving the link beside it cold. */
|
| 20 |
+
.shell-nav-row:hover {
|
| 21 |
+
background: var(--lp-surface-2);
|
| 22 |
+
}
|
| 23 |
+
|
| 24 |
+
.shell-nav-row.is-active {
|
| 25 |
+
background: var(--lp-blue-tint);
|
| 26 |
}
|
| 27 |
|
| 28 |
.shell-nav-row > .shell-nav-item {
|
|
|
|
| 30 |
min-width: 0;
|
| 31 |
}
|
| 32 |
|
| 33 |
+
/* β LOAD-BEARING, not tidiness. `.shell-nav-item:hover` still paints its own
|
| 34 |
+
grey β it must, because the AI-assistant row is a bare `.shell-nav-item`
|
| 35 |
+
with no row around it. Left alone inside a row it would paint that grey
|
| 36 |
+
OVER the blue of the current database the moment the pointer crossed the
|
| 37 |
+
label: the link half would go grey while the β― half stayed blue. The child
|
| 38 |
+
selector outranks it (0,3,0 over 0,2,0), so this holds no matter which
|
| 39 |
+
stylesheet the bundler emits first β the nav has lost a rule to source
|
| 40 |
+
order before ([[loopable-nav-logo-toggle]]) and specificity is the fix that
|
| 41 |
+
does not depend on being lucky. */
|
| 42 |
+
.shell-nav-row > .shell-nav-item:hover {
|
| 43 |
+
background: transparent;
|
| 44 |
+
}
|
| 45 |
+
|
| 46 |
.shell-nav-row > .shell-dots,
|
| 47 |
.shell-nav-folder > .shell-dots {
|
| 48 |
flex: 0 0 auto;
|
|
|
|
| 116 |
.shell-nav-foldercount {
|
| 117 |
margin-left: auto;
|
| 118 |
/* Wave 14 item 7 β the count wears the LABEL's size, muted; nothing "all over the
|
| 119 |
+
place with regards to symmetry".
|
| 120 |
+
β wave17 SHELL (item 11b) SUPERSEDES THE SIZE HALF. Wave 14 matched the count
|
| 121 |
+
to the label so the row would not look ragged; at the label's own size, next
|
| 122 |
+
to a 600-weight name, it stopped reading as an annotation and started reading
|
| 123 |
+
as a second piece of the title. Smaller is what makes it recede.
|
| 124 |
+
The COLOUR TOKEN IS UNCHANGED on purpose: `--lp-muted` already IS the grey,
|
| 125 |
+
and the same owner item asks the Views rail's `cg-fold-count` for the same
|
| 126 |
+
treatment. A lighter grey invented here would need a literal that has nowhere
|
| 127 |
+
legal to live, and would put the two rails' counts a shade apart β which is
|
| 128 |
+
the exact symmetry complaint wave 14 was answering. Shrinking the type does
|
| 129 |
+
the lightening. */
|
| 130 |
+
font-size: var(--lp-fs-3xs);
|
| 131 |
font-weight: 400;
|
| 132 |
color: var(--lp-muted);
|
| 133 |
+
/* Counts line up column-wise as folders open and close, in both rails. */
|
| 134 |
+
font-variant-numeric: tabular-nums;
|
| 135 |
}
|
| 136 |
|
| 137 |
/* ββ wave 14 C-NAVFOLD: drag placement (items 4/6) βββββββββββββββββββββββββ */
|
|
|
|
| 360 |
font-size: var(--lp-fs-xs);
|
| 361 |
}
|
| 362 |
|
| 363 |
+
/* wave17 SHELL (item 3/R6) β the same box, carrying the mark instead of a
|
| 364 |
+
sentence. Centred, because a drawer that has not loaded yet has no left edge
|
| 365 |
+
of content for it to hang off. */
|
| 366 |
+
.shell-schema-empty.is-spin {
|
| 367 |
+
display: flex;
|
| 368 |
+
justify-content: center;
|
| 369 |
+
padding: 40px 18px;
|
| 370 |
+
}
|
| 371 |
+
|
| 372 |
.shell-schema-note {
|
| 373 |
padding: 9px 11px;
|
| 374 |
border: 1px solid var(--lp-line);
|
web/src/viz/DashboardView.tsx
CHANGED
|
@@ -677,13 +677,27 @@ export function ChartCard({
|
|
| 677 |
<GroupTableView table={table} xLabel={xLabel ?? "Group"} yField={yField} />
|
| 678 |
</div>
|
| 679 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 680 |
) : data.problem ? (
|
| 681 |
<div className="cg-ch-empty">{data.problem}</div>
|
| 682 |
) : data.points.length === 0 ? (
|
| 683 |
<div className="cg-ch-empty">No records match this view, so there is nothing to chart.</div>
|
| 684 |
) : (
|
| 685 |
<div className={`cg-ch-viz cg-ch-viz--${spec.kind}`}>
|
| 686 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 687 |
<VegaLiteChart spec={rendererSpec} label={spec.title || auto} />
|
| 688 |
</Suspense>
|
| 689 |
</div>
|
|
@@ -1000,13 +1014,17 @@ export function DashboardView({
|
|
| 1000 |
};
|
| 1001 |
const payload = series[periodGroupKey(spec)];
|
| 1002 |
if (!payload)
|
| 1003 |
-
|
| 1004 |
-
|
| 1005 |
-
|
| 1006 |
-
|
| 1007 |
-
|
| 1008 |
-
|
| 1009 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1010 |
const table = buildTsTable(payload);
|
| 1011 |
const row = table.rows.find((r) => r.field === spec.y);
|
| 1012 |
if (!row)
|
|
|
|
| 677 |
<GroupTableView table={table} xLabel={xLabel ?? "Group"} yField={yField} />
|
| 678 |
</div>
|
| 679 |
)
|
| 680 |
+
) : data.pending ? (
|
| 681 |
+
/* wave17 GRID β item 3 / R6. BEFORE `problem`, on purpose: a card still waiting has
|
| 682 |
+
nothing to refuse yet, and showing a refusal that resolves itself a moment later is
|
| 683 |
+
the reading error this branch exists to end. */
|
| 684 |
+
<div className="cg-ch-empty">
|
| 685 |
+
<span className="lp-spin" role="status" aria-label="Loading" />
|
| 686 |
+
</div>
|
| 687 |
) : data.problem ? (
|
| 688 |
<div className="cg-ch-empty">{data.problem}</div>
|
| 689 |
) : data.points.length === 0 ? (
|
| 690 |
<div className="cg-ch-empty">No records match this view, so there is nothing to chart.</div>
|
| 691 |
) : (
|
| 692 |
<div className={`cg-ch-viz cg-ch-viz--${spec.kind}`}>
|
| 693 |
+
{/* R6: the renderer chunk's own wait, same bare icon as every other load. */}
|
| 694 |
+
<Suspense
|
| 695 |
+
fallback={
|
| 696 |
+
<div className="cg-ch-loading">
|
| 697 |
+
<span className="lp-spin" role="status" aria-label="Loading" />
|
| 698 |
+
</div>
|
| 699 |
+
}
|
| 700 |
+
>
|
| 701 |
<VegaLiteChart spec={rendererSpec} label={spec.title || auto} />
|
| 702 |
</Suspense>
|
| 703 |
</div>
|
|
|
|
| 1014 |
};
|
| 1015 |
const payload = series[periodGroupKey(spec)];
|
| 1016 |
if (!payload)
|
| 1017 |
+
// wave17 GRID β item 3 / R6. Waiting and refusing were one string here; they are two
|
| 1018 |
+
// states now. `pending` renders the spinner, and the refusal keeps its sentence for the
|
| 1019 |
+
// case that is genuinely an answer.
|
| 1020 |
+
return pending
|
| 1021 |
+
? { ...fallback, points: [], pending: true }
|
| 1022 |
+
: {
|
| 1023 |
+
...fallback,
|
| 1024 |
+
points: [],
|
| 1025 |
+
problem:
|
| 1026 |
+
"The periods could not be loaded, so nothing is drawn rather than a guess.",
|
| 1027 |
+
};
|
| 1028 |
const table = buildTsTable(payload);
|
| 1029 |
const row = table.rows.find((r) => r.field === spec.y);
|
| 1030 |
if (!row)
|
web/src/viz/chartData.ts
CHANGED
|
@@ -205,6 +205,16 @@ export interface ChartData {
|
|
| 205 |
zeroBuckets?: number;
|
| 206 |
/** Populated when the spec cannot be drawn; the card shows this verbatim. */
|
| 207 |
problem?: string;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 208 |
}
|
| 209 |
|
| 210 |
/**
|
|
|
|
| 205 |
zeroBuckets?: number;
|
| 206 |
/** Populated when the spec cannot be drawn; the card shows this verbatim. */
|
| 207 |
problem?: string;
|
| 208 |
+
/**
|
| 209 |
+
* wave17 GRID β item 3 / owner R6. **Waiting is not a problem.**
|
| 210 |
+
*
|
| 211 |
+
* The period-series chart used to report its wait by writing "Loading the periodsβ¦" INTO
|
| 212 |
+
* `problem`, which meant a card that was merely early and a card that is refusing were the
|
| 213 |
+
* same state to every reader. R6 asks for a spinner and no words, and you cannot render a
|
| 214 |
+
* spinner from a string field β so the two states are now distinct, and the card checks this
|
| 215 |
+
* FIRST. A `problem` set beside it still says what went wrong once the wait ends.
|
| 216 |
+
*/
|
| 217 |
+
pending?: boolean;
|
| 218 |
}
|
| 219 |
|
| 220 |
/**
|