@aglyn/plugins-data 1.0.0-beta.246 → 1.0.0-beta.249

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -37,6 +37,7 @@ import { listQueryConstraints } from "@aglyn/tenant-feature-instance/hooks/use-l
37
37
  import { authorizedFetch } from "@aglyn/shared-util-http/authorized-token";
38
38
  import { DatasetSchemaDialog } from "./dataset-schema-dialog.component.js";
39
39
  import { DatasetRecordDialog } from "./dataset-record-dialog.component.js";
40
+ import { DatasetRecordSiteContext } from "./dataset-field-inputs.component.js";
40
41
  import { datasetRecordFilter, planRecordQuery, recordColumn } from "./dataset-record-filter.js";
41
42
  import { coerceDocumentValues, datasetIntegrityUpdate, datasetValueToInput, effectiveDatasetModel, formatDatasetValue, modelFromFieldEntries, validateDocument } from "../model/dataset-models.js";
42
43
  import { fillRecordAddresses } from "../record-pages/record-pages.js";
@@ -114,6 +115,15 @@ export function newDatasetSharingNote(siteOnly) {
114
115
  createdFromHostId
115
116
  ]);
116
117
  /**
118
+ * The site the record editor's Page field lists pages from (AGL-3763): the
119
+ * site whose Data page this is, and none on the organization Data page,
120
+ * where a dataset is no one site's.
121
+ */ const recordSite = useMemo(()=>({
122
+ hostId: createdFromHostId
123
+ }), [
124
+ createdFromHostId
125
+ ]);
126
+ /**
117
127
  * Whether a dataset created here starts on this site alone: the org chose
118
128
  * "Only the site they were created in" and there is a site to limit it to.
119
129
  * The caption reads it so it never promises All sites to a create that
@@ -1329,146 +1339,149 @@ export function newDatasetSharingNote(siteOnly) {
1329
1339
  flexDirection: 'column',
1330
1340
  gap: 2
1331
1341
  },
1332
- children: fields.map((fieldId, index)=>{
1333
- var _ref;
1334
- var _field_validation_options, _field_validation;
1335
- const field = model.fields[fieldId];
1336
- if (!field) return null;
1337
- const value = (_ref = editor == null ? void 0 : editor.values[fieldId]) != null ? _ref : '';
1338
- const error = editor == null ? void 0 : editor.errors[fieldId];
1339
- const label = field.required ? `${field.name} *` : field.name;
1340
- const setValue = (nextValue)=>setEditor((prev)=>prev ? _extends({}, prev, {
1341
- values: _extends({}, prev.values, {
1342
- [fieldId]: nextValue
1343
- }),
1344
- errors: _extends({}, prev.errors, {
1345
- [fieldId]: ''
1346
- })
1347
- }) : prev);
1348
- const common = {
1349
- label,
1350
- value,
1351
- size: 'small',
1352
- autoFocus: index === 0,
1353
- error: Boolean(error),
1354
- helperText: error || field.description,
1355
- sx: index === 0 ? {
1356
- mt: 1
1357
- } : undefined,
1358
- onChange: (event)=>setValue(event.target.value)
1359
- };
1360
- // Custom field types (AGL-434): the declaring plugin's Input
1361
- // takes over; values stay in input form (strings) so the
1362
- // existing coerce/validate pipeline is unchanged.
1363
- const customFieldType = getCustomFieldType(field.customType);
1364
- if (customFieldType == null ? void 0 : customFieldType.Input) {
1365
- const CustomInput = customFieldType.Input;
1366
- return /*#__PURE__*/ _jsxs(Stack, {
1342
+ children: /*#__PURE__*/ _jsx(DatasetRecordSiteContext.Provider, {
1343
+ value: recordSite,
1344
+ children: fields.map((fieldId, index)=>{
1345
+ var _ref;
1346
+ var _field_validation_options, _field_validation;
1347
+ const field = model.fields[fieldId];
1348
+ if (!field) return null;
1349
+ const value = (_ref = editor == null ? void 0 : editor.values[fieldId]) != null ? _ref : '';
1350
+ const error = editor == null ? void 0 : editor.errors[fieldId];
1351
+ const label = field.required ? `${field.name} *` : field.name;
1352
+ const setValue = (nextValue)=>setEditor((prev)=>prev ? _extends({}, prev, {
1353
+ values: _extends({}, prev.values, {
1354
+ [fieldId]: nextValue
1355
+ }),
1356
+ errors: _extends({}, prev.errors, {
1357
+ [fieldId]: ''
1358
+ })
1359
+ }) : prev);
1360
+ const common = {
1361
+ label,
1362
+ value,
1363
+ size: 'small',
1364
+ autoFocus: index === 0,
1365
+ error: Boolean(error),
1366
+ helperText: error || field.description,
1367
1367
  sx: index === 0 ? {
1368
1368
  mt: 1
1369
1369
  } : undefined,
1370
- children: [
1371
- /*#__PURE__*/ _jsx(CustomInput, {
1372
- value: value,
1373
- label: common.label,
1374
- onChange: (next)=>setValue(String(next != null ? next : ''))
1375
- }),
1376
- error || field.description ? /*#__PURE__*/ _jsx(Typography, {
1377
- variant: "caption",
1378
- color: error ? 'error' : 'text.secondary',
1379
- children: error || field.description
1380
- }) : null
1381
- ]
1382
- }, fieldId);
1383
- }
1384
- // Typed inputs per FT.Tag (AGL-179).
1385
- if (field.type === 'bool') {
1386
- return /*#__PURE__*/ _jsxs(TextField, _extends({}, common, {
1387
- select: true,
1388
- children: [
1389
- /*#__PURE__*/ _jsx(MenuItem, {
1390
- value: "",
1391
- children: '—'
1392
- }),
1393
- /*#__PURE__*/ _jsx(MenuItem, {
1394
- value: "true",
1395
- children: 'Yes'
1396
- }),
1397
- /*#__PURE__*/ _jsx(MenuItem, {
1398
- value: "false",
1399
- children: 'No'
1400
- })
1401
- ]
1402
- }), fieldId);
1403
- }
1404
- if (field.type === 'text' && ((_field_validation = field.validation) == null ? void 0 : (_field_validation_options = _field_validation.options) == null ? void 0 : _field_validation_options.length)) {
1405
- return /*#__PURE__*/ _jsxs(TextField, _extends({}, common, {
1406
- select: true,
1407
- children: [
1408
- /*#__PURE__*/ _jsx(MenuItem, {
1409
- value: "",
1410
- children: '—'
1411
- }),
1412
- field.validation.options.map((option)=>/*#__PURE__*/ _jsx(MenuItem, {
1413
- value: option,
1414
- children: option
1415
- }, option))
1416
- ]
1417
- }), fieldId);
1418
- }
1419
- if (field.type === 'reference') {
1420
- var _refOptions_fieldId;
1421
- var _field_reference;
1422
- const options = (_refOptions_fieldId = refOptions[fieldId]) != null ? _refOptions_fieldId : [];
1423
- const multiple = Boolean((_field_reference = field.reference) == null ? void 0 : _field_reference.multiple);
1424
- const selectedIds = value.split(',').map((part)=>part.trim()).filter(Boolean);
1425
- return /*#__PURE__*/ _jsxs(TextField, _extends({}, common, {
1426
- select: true,
1427
- value: multiple ? selectedIds : value,
1428
- slotProps: {
1429
- select: multiple ? {
1430
- multiple: true,
1431
- onChange: (event)=>setValue(event.target.value.join(', '))
1432
- } : undefined
1433
- },
1434
- children: [
1435
- multiple ? null : /*#__PURE__*/ _jsx(MenuItem, {
1436
- value: "",
1437
- children: '—'
1438
- }),
1439
- options.map((option)=>/*#__PURE__*/ _jsx(MenuItem, {
1440
- value: option.id,
1441
- children: option.label
1442
- }, option.id))
1443
- ]
1444
- }), fieldId);
1445
- }
1446
- if (field.type === 'int32' || field.type === 'int64' || field.type === 'float') {
1447
- return /*#__PURE__*/ _jsx(TextField, _extends({}, common, {
1448
- type: "number"
1449
- }), fieldId);
1450
- }
1451
- if (field.type === 'timestamp') {
1452
- return /*#__PURE__*/ _jsx(TextField, _extends({}, common, {
1453
- type: "datetime-local",
1454
- slotProps: {
1455
- inputLabel: {
1456
- shrink: true
1370
+ onChange: (event)=>setValue(event.target.value)
1371
+ };
1372
+ // Custom field types (AGL-434): the declaring plugin's Input
1373
+ // takes over; values stay in input form (strings) so the
1374
+ // existing coerce/validate pipeline is unchanged.
1375
+ const customFieldType = getCustomFieldType(field.customType);
1376
+ if (customFieldType == null ? void 0 : customFieldType.Input) {
1377
+ const CustomInput = customFieldType.Input;
1378
+ return /*#__PURE__*/ _jsxs(Stack, {
1379
+ sx: index === 0 ? {
1380
+ mt: 1
1381
+ } : undefined,
1382
+ children: [
1383
+ /*#__PURE__*/ _jsx(CustomInput, {
1384
+ value: value,
1385
+ label: common.label,
1386
+ onChange: (next)=>setValue(String(next != null ? next : ''))
1387
+ }),
1388
+ error || field.description ? /*#__PURE__*/ _jsx(Typography, {
1389
+ variant: "caption",
1390
+ color: error ? 'error' : 'text.secondary',
1391
+ children: error || field.description
1392
+ }) : null
1393
+ ]
1394
+ }, fieldId);
1395
+ }
1396
+ // Typed inputs per FT.Tag (AGL-179).
1397
+ if (field.type === 'bool') {
1398
+ return /*#__PURE__*/ _jsxs(TextField, _extends({}, common, {
1399
+ select: true,
1400
+ children: [
1401
+ /*#__PURE__*/ _jsx(MenuItem, {
1402
+ value: "",
1403
+ children: '—'
1404
+ }),
1405
+ /*#__PURE__*/ _jsx(MenuItem, {
1406
+ value: "true",
1407
+ children: 'Yes'
1408
+ }),
1409
+ /*#__PURE__*/ _jsx(MenuItem, {
1410
+ value: "false",
1411
+ children: 'No'
1412
+ })
1413
+ ]
1414
+ }), fieldId);
1415
+ }
1416
+ if (field.type === 'text' && ((_field_validation = field.validation) == null ? void 0 : (_field_validation_options = _field_validation.options) == null ? void 0 : _field_validation_options.length)) {
1417
+ return /*#__PURE__*/ _jsxs(TextField, _extends({}, common, {
1418
+ select: true,
1419
+ children: [
1420
+ /*#__PURE__*/ _jsx(MenuItem, {
1421
+ value: "",
1422
+ children: '—'
1423
+ }),
1424
+ field.validation.options.map((option)=>/*#__PURE__*/ _jsx(MenuItem, {
1425
+ value: option,
1426
+ children: option
1427
+ }, option))
1428
+ ]
1429
+ }), fieldId);
1430
+ }
1431
+ if (field.type === 'reference') {
1432
+ var _refOptions_fieldId;
1433
+ var _field_reference;
1434
+ const options = (_refOptions_fieldId = refOptions[fieldId]) != null ? _refOptions_fieldId : [];
1435
+ const multiple = Boolean((_field_reference = field.reference) == null ? void 0 : _field_reference.multiple);
1436
+ const selectedIds = value.split(',').map((part)=>part.trim()).filter(Boolean);
1437
+ return /*#__PURE__*/ _jsxs(TextField, _extends({}, common, {
1438
+ select: true,
1439
+ value: multiple ? selectedIds : value,
1440
+ slotProps: {
1441
+ select: multiple ? {
1442
+ multiple: true,
1443
+ onChange: (event)=>setValue(event.target.value.join(', '))
1444
+ } : undefined
1445
+ },
1446
+ children: [
1447
+ multiple ? null : /*#__PURE__*/ _jsx(MenuItem, {
1448
+ value: "",
1449
+ children: '—'
1450
+ }),
1451
+ options.map((option)=>/*#__PURE__*/ _jsx(MenuItem, {
1452
+ value: option.id,
1453
+ children: option.label
1454
+ }, option.id))
1455
+ ]
1456
+ }), fieldId);
1457
+ }
1458
+ if (field.type === 'int32' || field.type === 'int64' || field.type === 'float') {
1459
+ return /*#__PURE__*/ _jsx(TextField, _extends({}, common, {
1460
+ type: "number"
1461
+ }), fieldId);
1462
+ }
1463
+ if (field.type === 'timestamp') {
1464
+ return /*#__PURE__*/ _jsx(TextField, _extends({}, common, {
1465
+ type: "datetime-local",
1466
+ slotProps: {
1467
+ inputLabel: {
1468
+ shrink: true
1469
+ }
1457
1470
  }
1458
- }
1459
- }), fieldId);
1460
- }
1461
- if (field.type === 'coordinates') {
1462
- return /*#__PURE__*/ _jsx(TextField, _extends({}, common, {
1463
- helperText: error || field.description || 'lat, lon'
1464
- }), fieldId);
1465
- }
1466
- if (field.type === 'sorted') {
1467
- return /*#__PURE__*/ _jsx(TextField, _extends({}, common, {
1468
- helperText: error || field.description || 'Comma-separated list'
1469
- }), fieldId);
1470
- }
1471
- return /*#__PURE__*/ _jsx(TextField, _extends({}, common), fieldId);
1471
+ }), fieldId);
1472
+ }
1473
+ if (field.type === 'coordinates') {
1474
+ return /*#__PURE__*/ _jsx(TextField, _extends({}, common, {
1475
+ helperText: error || field.description || 'lat, lon'
1476
+ }), fieldId);
1477
+ }
1478
+ if (field.type === 'sorted') {
1479
+ return /*#__PURE__*/ _jsx(TextField, _extends({}, common, {
1480
+ helperText: error || field.description || 'Comma-separated list'
1481
+ }), fieldId);
1482
+ }
1483
+ return /*#__PURE__*/ _jsx(TextField, _extends({}, common), fieldId);
1484
+ })
1472
1485
  })
1473
1486
  }),
1474
1487
  /*#__PURE__*/ _jsxs(DialogActions, {