Deploy AIOS web (React glide grid + FastAPI slice)
Browse files- RELEASES.json +1 -1
- VERSION +1 -1
- platform/aios_grid.py +14 -6
- web/src/customer-grid/CustomerGrid.tsx +41 -35
- web/src/customer-grid/Toolbar.tsx +13 -4
- web/src/customer-grid/mapSetup.ts +44 -0
- web/src/customer-grid/types.ts +0 -2
- web/src/customer-grid/viewModes.tsx +75 -10
RELEASES.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
| 1 |
{
|
| 2 |
-
"current": "
|
| 3 |
"releases": [
|
| 4 |
{
|
| 5 |
"version": "v68",
|
|
|
|
| 1 |
{
|
| 2 |
+
"current": "0c1b893",
|
| 3 |
"releases": [
|
| 4 |
{
|
| 5 |
"version": "v68",
|
VERSION
CHANGED
|
@@ -1 +1 @@
|
|
| 1 |
-
|
|
|
|
| 1 |
+
0c1b893
|
platform/aios_grid.py
CHANGED
|
@@ -2698,10 +2698,11 @@ def _clean_catalogs(raw, valid_keys):
|
|
| 2698 |
def _clean_display(raw, valid_keys):
|
| 2699 |
"""Structural passthrough for a view's `config.display` (wave-6 item 10), fail-closed.
|
| 2700 |
|
| 2701 |
-
`{mode, dateField?, stackField?, titleField?, colorField?, sizeField?, charts?}` — mode
|
| 2702 |
-
must be
|
| 2703 |
-
|
| 2704 |
-
|
|
|
|
| 2705 |
dropped. What each mode MEANS — calendar wants a date-family field, kanban a select-family
|
| 2706 |
stack, map a single-select to colour by and a numeric to size by — is the client's
|
| 2707 |
business: it is the only layer that renders them, and a wrong-typed ref degrades to that
|
|
@@ -2727,8 +2728,15 @@ def _clean_display(raw, valid_keys):
|
|
| 2727 |
if any(key in raw for key in ('expr', 'formula', 'signal', 'fn')):
|
| 2728 |
return None
|
| 2729 |
mode = raw.get('mode')
|
| 2730 |
-
if mode not in DISPLAY_MODES
|
| 2731 |
return None
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2732 |
# Wave-9 I10 (C2): normalise the legacy wire value AFTER the membership test, so an unknown
|
| 2733 |
# mode is still rejected rather than accidentally aliased into a real one. Every already
|
| 2734 |
# saved 'dashboard' view reads back as 'chart' from here on; nothing writes 'dashboard'.
|
|
@@ -2738,7 +2746,7 @@ def _clean_display(raw, valid_keys):
|
|
| 2738 |
# longer a customers-only feature. It joins this loop rather than getting a clause of its own
|
| 2739 |
# because it IS a field ref with the same drop-if-deleted rule; `customer-grid/types.ts`
|
| 2740 |
# gains it in the SAME change, which is contract C2's whole point.
|
| 2741 |
-
for ref in ('dateField', 'stackField', 'titleField', 'colorField', 'sizeField', 'coordField'
|
| 2742 |
if raw.get(ref) in valid_keys:
|
| 2743 |
out[ref] = raw[ref]
|
| 2744 |
# ── C-DISP (wave 2026-08-02) ─────────────────────────────────────────────────────────
|
|
|
|
| 2698 |
def _clean_display(raw, valid_keys):
|
| 2699 |
"""Structural passthrough for a view's `config.display` (wave-6 item 10), fail-closed.
|
| 2700 |
|
| 2701 |
+
`{mode, dateField?, stackField?, titleField?, colorField?, sizeField?, coordField?, charts?}` — mode
|
| 2702 |
+
must be known. Bare `grid` is the absent default, but Grid + `coordField` is the one durable
|
| 2703 |
+
pre-Map setup state: a person may choose their location column before opening Map. Every field
|
| 2704 |
+
ref must name a field this table has (a ref to a deleted field is DROPPED and the client falls
|
| 2705 |
+
back to its per-mode default); unknown keys are
|
| 2706 |
dropped. What each mode MEANS — calendar wants a date-family field, kanban a select-family
|
| 2707 |
stack, map a single-select to colour by and a numeric to size by — is the client's
|
| 2708 |
business: it is the only layer that renders them, and a wrong-typed ref degrades to that
|
|
|
|
| 2728 |
if any(key in raw for key in ('expr', 'formula', 'signal', 'fn')):
|
| 2729 |
return None
|
| 2730 |
mode = raw.get('mode')
|
| 2731 |
+
if mode not in DISPLAY_MODES:
|
| 2732 |
return None
|
| 2733 |
+
# Grid is normally represented by an absent display object. The custom Map location picker is
|
| 2734 |
+
# deliberately reachable *before* Map, though, so retain this one valid field reference while
|
| 2735 |
+
# refusing every unrelated Grid-only display setting. Without this narrow exception Setup
|
| 2736 |
+
# appears to work, then silently loses its selection on the next server round trip.
|
| 2737 |
+
if mode == 'grid':
|
| 2738 |
+
coord_field = raw.get('coordField')
|
| 2739 |
+
return {'mode': 'grid', 'coordField': coord_field} if coord_field in valid_keys else None
|
| 2740 |
# Wave-9 I10 (C2): normalise the legacy wire value AFTER the membership test, so an unknown
|
| 2741 |
# mode is still rejected rather than accidentally aliased into a real one. Every already
|
| 2742 |
# saved 'dashboard' view reads back as 'chart' from here on; nothing writes 'dashboard'.
|
|
|
|
| 2746 |
# longer a customers-only feature. It joins this loop rather than getting a clause of its own
|
| 2747 |
# because it IS a field ref with the same drop-if-deleted rule; `customer-grid/types.ts`
|
| 2748 |
# gains it in the SAME change, which is contract C2's whole point.
|
| 2749 |
+
for ref in ('dateField', 'stackField', 'titleField', 'colorField', 'sizeField', 'coordField'):
|
| 2750 |
if raw.get(ref) in valid_keys:
|
| 2751 |
out[ref] = raw[ref]
|
| 2752 |
# ── C-DISP (wave 2026-08-02) ─────────────────────────────────────────────────────────
|
web/src/customer-grid/CustomerGrid.tsx
CHANGED
|
@@ -122,7 +122,8 @@ import type { GridFolder } from "./types";
|
|
| 122 |
import type { FieldStamps } from "./optimism";
|
| 123 |
import { evalFormula, orderFormulas, parseFormula } from "./formulaEngine";
|
| 124 |
import type { FormulaAst } from "./formulaEngine";
|
| 125 |
-
import { CalendarSettings, CalendarView, KanbanView, ListView, MapSettings, ModeSwitch } from "./viewModes";
|
|
|
|
| 126 |
import { SwipeView } from "./SwipeView";
|
| 127 |
import type { SwipeSpec } from "./SwipeView";
|
| 128 |
// The chart engine lives in `viz/` since EXIT wave 2 (W2-5/Y3) — the grid is now
|
|
@@ -737,6 +738,18 @@ function withColorField(config: ViewConfig, key: string): ViewConfig {
|
|
| 737 |
return { ...config, colorBy: key || null, display: cleanDisplay(display) };
|
| 738 |
}
|
| 739 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 740 |
/** Atomically scrub every view reference to the fields the server actually removed. */
|
| 741 |
export function configWithoutFields(
|
| 742 |
config: ViewConfig,
|
|
@@ -756,9 +769,11 @@ export function configWithoutFields(
|
|
| 756 |
colorBy: config.colorBy && gone.has(config.colorBy) ? null : config.colorBy,
|
| 757 |
};
|
| 758 |
const spec = next.display;
|
| 759 |
-
if (spec?.colorField && gone.has(spec.colorField))
|
|
|
|
| 760 |
const display: DisplaySpec = { ...spec };
|
| 761 |
-
delete display.colorField;
|
|
|
|
| 762 |
next.display = cleanDisplay(display);
|
| 763 |
}
|
| 764 |
return next;
|
|
@@ -1470,12 +1485,9 @@ function CustomerGridSurface({
|
|
| 1470 |
? projected.filter((row) => row.pid !== embeddedExcludeRecordId)
|
| 1471 |
: projected;
|
| 1472 |
const audit = payload?.workspace?.auditTimestamps ?? {};
|
| 1473 |
-
const watchedField = typeof config.display?.watchedField === "string"
|
| 1474 |
-
? config.display.watchedField : "";
|
| 1475 |
const stamped: Row[] = base.map((row): Row => ({
|
| 1476 |
...row,
|
| 1477 |
_updated: audit[String(row.pid)]?.record ?? "",
|
| 1478 |
-
...(watchedField ? { _watched_updated: audit[String(row.pid)]?.fields?.[watchedField] ?? "" } : {}),
|
| 1479 |
}));
|
| 1480 |
if (!pendingRows.length) return stamped;
|
| 1481 |
const known = new Set(stamped.map((r) => r.pid));
|
|
@@ -1483,7 +1495,7 @@ function CustomerGridSurface({
|
|
| 1483 |
return extra.length ? [...stamped, ...extra] : stamped;
|
| 1484 |
// The scalar key keeps this stable when a caller reconstructs the same id list.
|
| 1485 |
// eslint-disable-next-line react-hooks/exhaustive-deps
|
| 1486 |
-
}, [fetchedRows, embeddedIdsKey, embeddedExcludeRecordId, pendingRows, payload?.workspace?.auditTimestamps
|
| 1487 |
useEffect(() => {
|
| 1488 |
// ⚠ PRUNED AGAINST THE FETCHED PAYLOAD, not against `rawRows` — `rawRows` contains the
|
| 1489 |
// pending rows, so it can never report that one has been absorbed. Pruning against the
|
|
@@ -7304,6 +7316,14 @@ function CustomerGridSurface({
|
|
| 7304 |
// cleanDisplay's carry), which is what lets the next Kanban/Calendar restore the
|
| 7305 |
// chosen field instead of feeding the select its default. A view that never picked
|
| 7306 |
// stays byte-identical (ref-less grid normalizes to absent, the legacy rule).
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 7307 |
const setDisplayMode = useCallback(
|
| 7308 |
(m: DisplayMode) => {
|
| 7309 |
// I12 (C3) — a locked view's MODE is frozen. The switcher is already hidden for one,
|
|
@@ -7314,10 +7334,6 @@ function CustomerGridSurface({
|
|
| 7314 |
// callback is declared above it.)
|
| 7315 |
const av = views.find((v) => v.id === activeViewId);
|
| 7316 |
if (av && isModeFrozen(av)) return;
|
| 7317 |
-
const mapReady = Boolean(
|
| 7318 |
-
(displaySpec?.coordField && fields.some((field) => field.key === displaySpec.coordField))
|
| 7319 |
-
|| (fields.some((field) => field.key === "lat") && fields.some((field) => field.key === "lon"))
|
| 7320 |
-
);
|
| 7321 |
if (m === "map" && !mapReady) {
|
| 7322 |
signal(TOAST_EVENT, "Map needs coordinates. Open Setup and choose a coordinate field first.");
|
| 7323 |
return;
|
|
@@ -7332,7 +7348,7 @@ function CustomerGridSurface({
|
|
| 7332 |
}
|
| 7333 |
updateConfig({ ...config, display: { ...(spec ?? {}), mode: m } });
|
| 7334 |
},
|
| 7335 |
-
[config, displaySpec, updateConfig, views, activeViewId,
|
| 7336 |
);
|
| 7337 |
// C4 (amended): the pick is written INTO display and the selects are FED from the
|
| 7338 |
// view def (`display.<field>`), never from component state that dies on unmount.
|
|
@@ -7516,7 +7532,7 @@ function CustomerGridSurface({
|
|
| 7516 |
* "N matching records have no location" chip rather than in an error.
|
| 7517 |
*/
|
| 7518 |
const coordFieldChoices = useMemo(
|
| 7519 |
-
() => fields.filter(
|
| 7520 |
[fields]
|
| 7521 |
);
|
| 7522 |
const mapCoordField = displaySpec?.coordField
|
|
@@ -7530,22 +7546,10 @@ function CustomerGridSurface({
|
|
| 7530 |
*/
|
| 7531 |
const onPickCoordField = useCallback(
|
| 7532 |
(key: string) => {
|
| 7533 |
-
|
| 7534 |
-
if (!spec) return;
|
| 7535 |
-
const next: DisplaySpec = { ...spec };
|
| 7536 |
-
if (key) next.coordField = key;
|
| 7537 |
-
else delete next.coordField;
|
| 7538 |
-
updateConfig({ ...config, display: next });
|
| 7539 |
},
|
| 7540 |
-
[config,
|
| 7541 |
);
|
| 7542 |
-
const onPickWatchedField = useCallback((key: string) => {
|
| 7543 |
-
const spec = displaySpec;
|
| 7544 |
-
if (!spec) return;
|
| 7545 |
-
const next: DisplaySpec = { ...spec, watchedField: key };
|
| 7546 |
-
if (!key) delete next.watchedField;
|
| 7547 |
-
updateConfig({ ...config, display: next });
|
| 7548 |
-
}, [config, displaySpec, updateConfig]);
|
| 7549 |
/**
|
| 7550 |
* ⛔⛔ AN ADAPTER, AND IT EXISTS BECAUSE THE STORED SHAPE IS DECLARED TWICE (reported as
|
| 7551 |
* `NOTE C-23`). `types.ts::CatalogViewSpec` mirrors `aios_grid._clean_catalog_spec`, which emits
|
|
@@ -8018,6 +8022,14 @@ function CustomerGridSurface({
|
|
| 8018 |
// the OPTIMISTIC edit wins over the raw record, so a save the server has not echoed yet is
|
| 8019 |
// what re-opening the cell shows (the echo-suppression law — reading the raw row here would
|
| 8020 |
// make a just-saved document appear to revert).
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 8021 |
const jsonField = jsonAt ? fieldByKey.get(jsonAt.fieldKey) : undefined;
|
| 8022 |
const jsonRow = jsonAt ? rawRows.find((r) => r.pid === jsonAt.pid) : undefined;
|
| 8023 |
const jsonValue = String(
|
|
@@ -8761,6 +8773,7 @@ function CustomerGridSurface({
|
|
| 8761 |
serverWindowed={serverWindowed}
|
| 8762 |
cohortAction={cohortAction}
|
| 8763 |
filterSeed={filterSeed}
|
|
|
|
| 8764 |
modeControl={modeControl}
|
| 8765 |
/* ⭐⭐ W41-T42 · R11 — BOTH CONTROL ROWS STAY VISIBLE and THIS one is the greyed,
|
| 8766 |
unclickable primary. Not hidden and not collapsed to a chip: the conditions the
|
|
@@ -8791,6 +8804,7 @@ function CustomerGridSurface({
|
|
| 8791 |
<MapSettings
|
| 8792 |
coordField={mapCoordField}
|
| 8793 |
coordChoices={coordFieldChoices}
|
|
|
|
| 8794 |
onPickCoordField={onPickCoordField}
|
| 8795 |
sizeField={mapSizeField}
|
| 8796 |
sizeChoices={sizeFieldChoices}
|
|
@@ -8803,14 +8817,6 @@ function CustomerGridSurface({
|
|
| 8803 |
})}
|
| 8804 |
/>
|
| 8805 |
)}
|
| 8806 |
-
{!pivotOn && displaySpec && (
|
| 8807 |
-
<label className="cg-field-select">Watch field
|
| 8808 |
-
<select className="cg-select" value={displaySpec.watchedField ?? ""} onChange={(event) => onPickWatchedField(event.target.value)}>
|
| 8809 |
-
<option value="">Record Last updated</option>
|
| 8810 |
-
{fields.filter((field) => field.key !== "_updated").map((field) => <option key={field.key} value={field.key}>{field.label}</option>)}
|
| 8811 |
-
</select>
|
| 8812 |
-
</label>
|
| 8813 |
-
)}
|
| 8814 |
{/* ⭐⭐ WAVE 42 · W42-T19 (owner instruction 11) — CALENDAR'S SECOND ROW. The real
|
| 8815 |
`CalendarSettings` render stays in the same position and guard shape as `MapSettings`:
|
| 8816 |
after the primary Toolbar, before the grid. The primary mode trigger therefore stays
|
|
|
|
| 122 |
import type { FieldStamps } from "./optimism";
|
| 123 |
import { evalFormula, orderFormulas, parseFormula } from "./formulaEngine";
|
| 124 |
import type { FormulaAst } from "./formulaEngine";
|
| 125 |
+
import { CalendarSettings, CalendarView, KanbanView, ListView, MapSettings, MapSetup, ModeSwitch } from "./viewModes";
|
| 126 |
+
import { hasBuiltInMapCoordinates, isMapCoordinateField, mapCoordinatesReady } from "./mapSetup";
|
| 127 |
import { SwipeView } from "./SwipeView";
|
| 128 |
import type { SwipeSpec } from "./SwipeView";
|
| 129 |
// The chart engine lives in `viz/` since EXIT wave 2 (W2-5/Y3) — the grid is now
|
|
|
|
| 738 |
return { ...config, colorBy: key || null, display: cleanDisplay(display) };
|
| 739 |
}
|
| 740 |
|
| 741 |
+
/**
|
| 742 |
+
* The one writer for Map's custom location field. Setup is available on Grid as well as Map, so
|
| 743 |
+
* an absent display spec must become a grid-carried spec rather than making a painted control inert.
|
| 744 |
+
*/
|
| 745 |
+
function withMapCoordinateField(config: ViewConfig, key: string): ViewConfig {
|
| 746 |
+
const spec = cleanDisplay(config.display) ?? { mode: "grid" as const };
|
| 747 |
+
const display: DisplaySpec = { ...spec };
|
| 748 |
+
if (key) display.coordField = key;
|
| 749 |
+
else delete display.coordField;
|
| 750 |
+
return { ...config, display: cleanDisplay(display) };
|
| 751 |
+
}
|
| 752 |
+
|
| 753 |
/** Atomically scrub every view reference to the fields the server actually removed. */
|
| 754 |
export function configWithoutFields(
|
| 755 |
config: ViewConfig,
|
|
|
|
| 769 |
colorBy: config.colorBy && gone.has(config.colorBy) ? null : config.colorBy,
|
| 770 |
};
|
| 771 |
const spec = next.display;
|
| 772 |
+
if ((spec?.colorField && gone.has(spec.colorField)) ||
|
| 773 |
+
(spec?.coordField && gone.has(spec.coordField))) {
|
| 774 |
const display: DisplaySpec = { ...spec };
|
| 775 |
+
if (display.colorField && gone.has(display.colorField)) delete display.colorField;
|
| 776 |
+
if (display.coordField && gone.has(display.coordField)) delete display.coordField;
|
| 777 |
next.display = cleanDisplay(display);
|
| 778 |
}
|
| 779 |
return next;
|
|
|
|
| 1485 |
? projected.filter((row) => row.pid !== embeddedExcludeRecordId)
|
| 1486 |
: projected;
|
| 1487 |
const audit = payload?.workspace?.auditTimestamps ?? {};
|
|
|
|
|
|
|
| 1488 |
const stamped: Row[] = base.map((row): Row => ({
|
| 1489 |
...row,
|
| 1490 |
_updated: audit[String(row.pid)]?.record ?? "",
|
|
|
|
| 1491 |
}));
|
| 1492 |
if (!pendingRows.length) return stamped;
|
| 1493 |
const known = new Set(stamped.map((r) => r.pid));
|
|
|
|
| 1495 |
return extra.length ? [...stamped, ...extra] : stamped;
|
| 1496 |
// The scalar key keeps this stable when a caller reconstructs the same id list.
|
| 1497 |
// eslint-disable-next-line react-hooks/exhaustive-deps
|
| 1498 |
+
}, [fetchedRows, embeddedIdsKey, embeddedExcludeRecordId, pendingRows, payload?.workspace?.auditTimestamps]);
|
| 1499 |
useEffect(() => {
|
| 1500 |
// ⚠ PRUNED AGAINST THE FETCHED PAYLOAD, not against `rawRows` — `rawRows` contains the
|
| 1501 |
// pending rows, so it can never report that one has been absorbed. Pruning against the
|
|
|
|
| 7316 |
// cleanDisplay's carry), which is what lets the next Kanban/Calendar restore the
|
| 7317 |
// chosen field instead of feeding the select its default. A view that never picked
|
| 7318 |
// stays byte-identical (ref-less grid normalizes to absent, the legacy rule).
|
| 7319 |
+
const hasDefaultMapCoordinates = useMemo(
|
| 7320 |
+
() => hasBuiltInMapCoordinates(fields, rawRows),
|
| 7321 |
+
[fields, rawRows]
|
| 7322 |
+
);
|
| 7323 |
+
const mapReady = useMemo(
|
| 7324 |
+
() => mapCoordinatesReady(fields, rawRows, displaySpec?.coordField),
|
| 7325 |
+
[fields, rawRows, displaySpec?.coordField]
|
| 7326 |
+
);
|
| 7327 |
const setDisplayMode = useCallback(
|
| 7328 |
(m: DisplayMode) => {
|
| 7329 |
// I12 (C3) — a locked view's MODE is frozen. The switcher is already hidden for one,
|
|
|
|
| 7334 |
// callback is declared above it.)
|
| 7335 |
const av = views.find((v) => v.id === activeViewId);
|
| 7336 |
if (av && isModeFrozen(av)) return;
|
|
|
|
|
|
|
|
|
|
|
|
|
| 7337 |
if (m === "map" && !mapReady) {
|
| 7338 |
signal(TOAST_EVENT, "Map needs coordinates. Open Setup and choose a coordinate field first.");
|
| 7339 |
return;
|
|
|
|
| 7348 |
}
|
| 7349 |
updateConfig({ ...config, display: { ...(spec ?? {}), mode: m } });
|
| 7350 |
},
|
| 7351 |
+
[config, displaySpec, updateConfig, views, activeViewId, mapReady]
|
| 7352 |
);
|
| 7353 |
// C4 (amended): the pick is written INTO display and the selects are FED from the
|
| 7354 |
// view def (`display.<field>`), never from component state that dies on unmount.
|
|
|
|
| 7532 |
* "N matching records have no location" chip rather than in an error.
|
| 7533 |
*/
|
| 7534 |
const coordFieldChoices = useMemo(
|
| 7535 |
+
() => fields.filter(isMapCoordinateField),
|
| 7536 |
[fields]
|
| 7537 |
);
|
| 7538 |
const mapCoordField = displaySpec?.coordField
|
|
|
|
| 7546 |
*/
|
| 7547 |
const onPickCoordField = useCallback(
|
| 7548 |
(key: string) => {
|
| 7549 |
+
updateConfig(withMapCoordinateField(config, key));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 7550 |
},
|
| 7551 |
+
[config, updateConfig]
|
| 7552 |
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 7553 |
/**
|
| 7554 |
* ⛔⛔ AN ADAPTER, AND IT EXISTS BECAUSE THE STORED SHAPE IS DECLARED TWICE (reported as
|
| 7555 |
* `NOTE C-23`). `types.ts::CatalogViewSpec` mirrors `aios_grid._clean_catalog_spec`, which emits
|
|
|
|
| 8022 |
// the OPTIMISTIC edit wins over the raw record, so a save the server has not echoed yet is
|
| 8023 |
// what re-opening the cell shows (the echo-suppression law — reading the raw row here would
|
| 8024 |
// make a just-saved document appear to revert).
|
| 8025 |
+
const mapSetupControl = serverWindowed || embedded || isQueryPreview ? undefined : (
|
| 8026 |
+
<MapSetup
|
| 8027 |
+
coordField={mapCoordField}
|
| 8028 |
+
coordChoices={coordFieldChoices}
|
| 8029 |
+
hasDefaultCoordinates={hasDefaultMapCoordinates}
|
| 8030 |
+
onPickCoordField={onPickCoordField}
|
| 8031 |
+
/>
|
| 8032 |
+
);
|
| 8033 |
const jsonField = jsonAt ? fieldByKey.get(jsonAt.fieldKey) : undefined;
|
| 8034 |
const jsonRow = jsonAt ? rawRows.find((r) => r.pid === jsonAt.pid) : undefined;
|
| 8035 |
const jsonValue = String(
|
|
|
|
| 8773 |
serverWindowed={serverWindowed}
|
| 8774 |
cohortAction={cohortAction}
|
| 8775 |
filterSeed={filterSeed}
|
| 8776 |
+
setupControl={mapSetupControl}
|
| 8777 |
modeControl={modeControl}
|
| 8778 |
/* ⭐⭐ W41-T42 · R11 — BOTH CONTROL ROWS STAY VISIBLE and THIS one is the greyed,
|
| 8779 |
unclickable primary. Not hidden and not collapsed to a chip: the conditions the
|
|
|
|
| 8804 |
<MapSettings
|
| 8805 |
coordField={mapCoordField}
|
| 8806 |
coordChoices={coordFieldChoices}
|
| 8807 |
+
hasDefaultCoordinates={hasDefaultMapCoordinates}
|
| 8808 |
onPickCoordField={onPickCoordField}
|
| 8809 |
sizeField={mapSizeField}
|
| 8810 |
sizeChoices={sizeFieldChoices}
|
|
|
|
| 8817 |
})}
|
| 8818 |
/>
|
| 8819 |
)}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 8820 |
{/* ⭐⭐ WAVE 42 · W42-T19 (owner instruction 11) — CALENDAR'S SECOND ROW. The real
|
| 8821 |
`CalendarSettings` render stays in the same position and guard shape as `MapSettings`:
|
| 8822 |
after the primary Toolbar, before the grid. The primary mode trigger therefore stays
|
web/src/customer-grid/Toolbar.tsx
CHANGED
|
@@ -226,9 +226,14 @@ interface ToolbarBaseProps {
|
|
| 226 |
measure?: { key: string; window: WindowSpec };
|
| 227 |
n: number;
|
| 228 |
} | null;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 229 |
/** Wave-6 item 10 — the view-mode switcher (Grid · List · Calendar · Kanban), built by
|
| 230 |
-
* CustomerGrid (it owns the display config)
|
| 231 |
-
*
|
| 232 |
modeControl?: ReactNode;
|
| 233 |
|
| 234 |
/**
|
|
@@ -798,6 +803,7 @@ export default function Toolbar({
|
|
| 798 |
serverWindowed = false,
|
| 799 |
cohortAction,
|
| 800 |
filterSeed = null,
|
|
|
|
| 801 |
modeControl,
|
| 802 |
frozen = false,
|
| 803 |
relationalTargets = [],
|
|
@@ -958,8 +964,11 @@ export default function Toolbar({
|
|
| 958 |
: undefined
|
| 959 |
}
|
| 960 |
>
|
| 961 |
-
{/*
|
| 962 |
-
|
|
|
|
|
|
|
|
|
|
| 963 |
{modeControl}
|
| 964 |
|
| 965 |
{/* Fields — show / hide columns, searchable, Pre-set chips (item 7 remainder) */}
|
|
|
|
| 226 |
measure?: { key: string; window: WindowSpec };
|
| 227 |
n: number;
|
| 228 |
} | null;
|
| 229 |
+
/**
|
| 230 |
+
* The leftmost setup door, built by CustomerGrid because it owns any view-level
|
| 231 |
+
* configuration. It must remain reachable before a person can enter a mode that needs it.
|
| 232 |
+
*/
|
| 233 |
+
setupControl?: ReactNode;
|
| 234 |
/** Wave-6 item 10 — the view-mode switcher (Grid · List · Calendar · Kanban), built by
|
| 235 |
+
* CustomerGrid (it owns the display config). A slot, like `cohortAction`, so the toolbar
|
| 236 |
+
* stays presentational. */
|
| 237 |
modeControl?: ReactNode;
|
| 238 |
|
| 239 |
/**
|
|
|
|
| 803 |
serverWindowed = false,
|
| 804 |
cohortAction,
|
| 805 |
filterSeed = null,
|
| 806 |
+
setupControl,
|
| 807 |
modeControl,
|
| 808 |
frozen = false,
|
| 809 |
relationalTargets = [],
|
|
|
|
| 964 |
: undefined
|
| 965 |
}
|
| 966 |
>
|
| 967 |
+
{/* Setup comes first so a mode can never direct a person to a configuration control that
|
| 968 |
+
only appears after that mode has already opened. */}
|
| 969 |
+
{setupControl}
|
| 970 |
+
{/* Wave-6 item 10 — the view-mode switcher decides what everything to its right operates
|
| 971 |
+
on. */}
|
| 972 |
{modeControl}
|
| 973 |
|
| 974 |
{/* Fields — show / hide columns, searchable, Pre-set chips (item 7 remainder) */}
|
web/src/customer-grid/mapSetup.ts
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// ---------------------------------------------------------------------------
|
| 2 |
+
// customer-grid / mapSetup.ts
|
| 3 |
+
// The Map capability contract: built-in `lat`/`lon` is a default when the payload
|
| 4 |
+
// supplies it; every other table must explicitly choose one `latitude, longitude`
|
| 5 |
+
// text-like field before Map can open.
|
| 6 |
+
// ---------------------------------------------------------------------------
|
| 7 |
+
|
| 8 |
+
import type { Field, Row } from "./types";
|
| 9 |
+
|
| 10 |
+
type CoordinateField = Pick<Field, "key" | "type">;
|
| 11 |
+
|
| 12 |
+
/** A single custom coordinate cell is parsed by MapView as `latitude, longitude`. */
|
| 13 |
+
export function isMapCoordinateField(field: Pick<Field, "type">): boolean {
|
| 14 |
+
return field.type === "text" || field.type === "url" || field.type === "email";
|
| 15 |
+
}
|
| 16 |
+
|
| 17 |
+
/**
|
| 18 |
+
* Odoo's coordinates are transport values and are deliberately absent from the ordinary visible
|
| 19 |
+
* field list. A table may instead publish the pair as normal fields, so both schema surfaces count.
|
| 20 |
+
*/
|
| 21 |
+
export function hasBuiltInMapCoordinates(
|
| 22 |
+
fields: readonly CoordinateField[],
|
| 23 |
+
rows: readonly Row[],
|
| 24 |
+
): boolean {
|
| 25 |
+
return (
|
| 26 |
+
(fields.some((field) => field.key === "lat") && fields.some((field) => field.key === "lon"))
|
| 27 |
+
|| rows.some((row) => (
|
| 28 |
+
Object.prototype.hasOwnProperty.call(row, "lat")
|
| 29 |
+
&& Object.prototype.hasOwnProperty.call(row, "lon")
|
| 30 |
+
))
|
| 31 |
+
);
|
| 32 |
+
}
|
| 33 |
+
|
| 34 |
+
/** The exact capability gate used before Map changes mode. */
|
| 35 |
+
export function mapCoordinatesReady(
|
| 36 |
+
fields: readonly CoordinateField[],
|
| 37 |
+
rows: readonly Row[],
|
| 38 |
+
coordField?: string,
|
| 39 |
+
): boolean {
|
| 40 |
+
return hasBuiltInMapCoordinates(fields, rows)
|
| 41 |
+
|| !!coordField && fields.some((field) => (
|
| 42 |
+
field.key === coordField && isMapCoordinateField(field)
|
| 43 |
+
));
|
| 44 |
+
}
|
web/src/customer-grid/types.ts
CHANGED
|
@@ -672,8 +672,6 @@ export function normalizeDisplayMode(mode: DisplayMode): DisplayMode {
|
|
| 672 |
return LEGACY_DISPLAY_MODES[mode] ?? mode;
|
| 673 |
}
|
| 674 |
export interface DisplaySpec {
|
| 675 |
-
/** W48-T10: optional admitted field whose own audit timestamp may be sorted. */
|
| 676 |
-
watchedField?: string;
|
| 677 |
mode: DisplayMode;
|
| 678 |
dateField?: string;
|
| 679 |
stackField?: string;
|
|
|
|
| 672 |
return LEGACY_DISPLAY_MODES[mode] ?? mode;
|
| 673 |
}
|
| 674 |
export interface DisplaySpec {
|
|
|
|
|
|
|
| 675 |
mode: DisplayMode;
|
| 676 |
dateField?: string;
|
| 677 |
stackField?: string;
|
web/src/customer-grid/viewModes.tsx
CHANGED
|
@@ -519,10 +519,78 @@ export function CalendarSettings({
|
|
| 519 |
);
|
| 520 |
}
|
| 521 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 522 |
/** Map-only settings live beneath the main Filter / Sort / Group navigation. */
|
| 523 |
export function MapSettings({
|
| 524 |
coordField,
|
| 525 |
coordChoices,
|
|
|
|
| 526 |
onPickCoordField,
|
| 527 |
sizeField,
|
| 528 |
sizeChoices,
|
|
@@ -533,6 +601,7 @@ export function MapSettings({
|
|
| 533 |
}: {
|
| 534 |
coordField?: Field;
|
| 535 |
coordChoices: Field[];
|
|
|
|
| 536 |
onPickCoordField: (key: string) => void;
|
| 537 |
sizeField?: Field;
|
| 538 |
sizeChoices: Field[];
|
|
@@ -541,6 +610,7 @@ export function MapSettings({
|
|
| 541 |
selectedCount: number;
|
| 542 |
onToggleRoute: () => void;
|
| 543 |
}) {
|
|
|
|
| 544 |
/**
|
| 545 |
* W42-T24 retained contract: this row never self-hides. Route is a navigation into saved
|
| 546 |
* routes as well as a planner for the current selection, so it must remain reachable before
|
|
@@ -560,22 +630,17 @@ export function MapSettings({
|
|
| 560 |
<IconRouteZone />
|
| 561 |
<span>Routes{selectedCount >= 2 ? ` / ${selectedCount} selected` : ""}</span>
|
| 562 |
</button>
|
| 563 |
-
{
|
| 564 |
<span className="cg-mode-field-mark" aria-hidden><IconLocation /></span>
|
| 565 |
)}
|
| 566 |
-
{
|
| 567 |
<FieldSelectButton
|
| 568 |
className="cg-mode-field"
|
| 569 |
ariaLabel="Plot pins from"
|
| 570 |
-
placeholder="
|
| 571 |
-
value={coordField?.key ?? ""}
|
| 572 |
onChange={onPickCoordField}
|
| 573 |
-
fields={
|
| 574 |
-
{ key: "", label: "Location: the lat and lon columns", type: undefined },
|
| 575 |
-
...coordChoices.map((f) => ({
|
| 576 |
-
key: f.key, label: `Location: ${f.label}`, type: f.type,
|
| 577 |
-
})),
|
| 578 |
-
]}
|
| 579 |
/>
|
| 580 |
)}
|
| 581 |
{sizeChoices.length > 0 && (
|
|
|
|
| 519 |
);
|
| 520 |
}
|
| 521 |
|
| 522 |
+
/**
|
| 523 |
+
* The one vocabulary both Map's persistent Setup door and its in-map quick picker use.
|
| 524 |
+
* A database earns the default only when it actually supplies the historic lat/lon pair;
|
| 525 |
+
* every other database must name one field containing `latitude, longitude`.
|
| 526 |
+
*/
|
| 527 |
+
function mapLocationChoices(hasDefaultCoordinates: boolean, coordChoices: Field[]) {
|
| 528 |
+
return [
|
| 529 |
+
...(hasDefaultCoordinates
|
| 530 |
+
? [{ key: "", label: "Built-in lat/lon columns", type: undefined }]
|
| 531 |
+
: []),
|
| 532 |
+
...coordChoices.map((field) => ({
|
| 533 |
+
key: field.key, label: `Location: ${field.label}`, type: field.type,
|
| 534 |
+
})),
|
| 535 |
+
];
|
| 536 |
+
}
|
| 537 |
+
|
| 538 |
+
/**
|
| 539 |
+
* Map setup is intentionally available before Map opens. A mode must never be the only route to
|
| 540 |
+
* configuring the prerequisite that lets a person enter that mode.
|
| 541 |
+
*/
|
| 542 |
+
export function MapSetup({
|
| 543 |
+
coordField,
|
| 544 |
+
coordChoices,
|
| 545 |
+
hasDefaultCoordinates,
|
| 546 |
+
onPickCoordField,
|
| 547 |
+
}: {
|
| 548 |
+
coordField?: Field;
|
| 549 |
+
coordChoices: Field[];
|
| 550 |
+
hasDefaultCoordinates: boolean;
|
| 551 |
+
onPickCoordField: (key: string) => void;
|
| 552 |
+
}) {
|
| 553 |
+
const locations = mapLocationChoices(hasDefaultCoordinates, coordChoices);
|
| 554 |
+
const value = coordField?.key ?? (hasDefaultCoordinates ? "" : undefined);
|
| 555 |
+
return (
|
| 556 |
+
<Popover label="Setup" icon={<IconLocation />} active={!!coordField}>
|
| 557 |
+
{(close) => (
|
| 558 |
+
<div className="cg-pop-body cg-builder">
|
| 559 |
+
<div className="cg-pop-title">Map setup</div>
|
| 560 |
+
<p className="cg-builder-caption">
|
| 561 |
+
Use built-in lat/lon columns when available, or choose one field containing latitude, longitude.
|
| 562 |
+
</p>
|
| 563 |
+
{locations.length > 0 ? (
|
| 564 |
+
<div className="cg-cond-line">
|
| 565 |
+
<span className="cg-cond-prefix">Location</span>
|
| 566 |
+
<FieldSelectButton
|
| 567 |
+
className="cg-cond-field"
|
| 568 |
+
ariaLabel="Map location field"
|
| 569 |
+
placeholder="Choose a location field…"
|
| 570 |
+
value={value}
|
| 571 |
+
onChange={(key) => {
|
| 572 |
+
onPickCoordField(key);
|
| 573 |
+
close();
|
| 574 |
+
}}
|
| 575 |
+
fields={locations}
|
| 576 |
+
/>
|
| 577 |
+
</div>
|
| 578 |
+
) : (
|
| 579 |
+
<div className="cg-builder-empty">
|
| 580 |
+
Add a text field that stores latitude, longitude before opening Map.
|
| 581 |
+
</div>
|
| 582 |
+
)}
|
| 583 |
+
</div>
|
| 584 |
+
)}
|
| 585 |
+
</Popover>
|
| 586 |
+
);
|
| 587 |
+
}
|
| 588 |
+
|
| 589 |
/** Map-only settings live beneath the main Filter / Sort / Group navigation. */
|
| 590 |
export function MapSettings({
|
| 591 |
coordField,
|
| 592 |
coordChoices,
|
| 593 |
+
hasDefaultCoordinates,
|
| 594 |
onPickCoordField,
|
| 595 |
sizeField,
|
| 596 |
sizeChoices,
|
|
|
|
| 601 |
}: {
|
| 602 |
coordField?: Field;
|
| 603 |
coordChoices: Field[];
|
| 604 |
+
hasDefaultCoordinates: boolean;
|
| 605 |
onPickCoordField: (key: string) => void;
|
| 606 |
sizeField?: Field;
|
| 607 |
sizeChoices: Field[];
|
|
|
|
| 610 |
selectedCount: number;
|
| 611 |
onToggleRoute: () => void;
|
| 612 |
}) {
|
| 613 |
+
const locations = mapLocationChoices(hasDefaultCoordinates, coordChoices);
|
| 614 |
/**
|
| 615 |
* W42-T24 retained contract: this row never self-hides. Route is a navigation into saved
|
| 616 |
* routes as well as a planner for the current selection, so it must remain reachable before
|
|
|
|
| 630 |
<IconRouteZone />
|
| 631 |
<span>Routes{selectedCount >= 2 ? ` / ${selectedCount} selected` : ""}</span>
|
| 632 |
</button>
|
| 633 |
+
{locations.length > 0 && (
|
| 634 |
<span className="cg-mode-field-mark" aria-hidden><IconLocation /></span>
|
| 635 |
)}
|
| 636 |
+
{locations.length > 0 && (
|
| 637 |
<FieldSelectButton
|
| 638 |
className="cg-mode-field"
|
| 639 |
ariaLabel="Plot pins from"
|
| 640 |
+
placeholder="Choose a location field…"
|
| 641 |
+
value={coordField?.key ?? (hasDefaultCoordinates ? "" : undefined)}
|
| 642 |
onChange={onPickCoordField}
|
| 643 |
+
fields={locations}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 644 |
/>
|
| 645 |
)}
|
| 646 |
{sizeChoices.length > 0 && (
|