@vectoriahq/quac 0.24.0 → 0.25.0-next.1
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.
- package/dist/generate/normalizedProject.d.ts +8 -1
- package/dist/generate/normalizedProject.js +25 -0
- package/dist/generate/serverStacCatalogue.d.ts +3 -1
- package/dist/generate/serverStacCatalogue.js +33 -5
- package/dist/generate/stacCatalogue.js +49 -5
- package/dist/generate/validateNewFeature.d.ts +3 -1
- package/dist/generate/validateNewFeature.js +2 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.js +1 -1
- package/dist/model/QgsProject.d.ts +21 -0
- package/dist/model/Stac.d.ts +16 -0
- package/dist/parse/parseLayers.js +45 -1
- package/dist/parse/projectNotes.d.ts +14 -3
- package/dist/parse/projectNotes.js +24 -2
- package/package.json +1 -1
- package/src/schema/quac.schema.json +26 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { LayerLocks, PrintLayoutTemplate, FieldAttachment, FieldEditRule, LayerFormLayout, LayerScaleRange, ProjectMeasurement } from '../model/QgsProject.ts';
|
|
2
|
-
import type { StacAsset, StacCatalog, StacCollection, StacExtent, StacLink, StacProvider, TableColumn, TableColumnRuleLeftOut, TableColumnValue, TableColumnValueRelation } from '../model/Stac.ts';
|
|
2
|
+
import type { StacAsset, StacCatalog, StacCollection, StacExtent, StacLink, StacProvider, TableColumn, TableColumnRuleLeftOut, TableColumnRelationReference, TableColumnValue, TableColumnValueRelation } from '../model/Stac.ts';
|
|
3
3
|
/**
|
|
4
4
|
* Source-agnostic intermediate model + the single STAC generator that
|
|
5
5
|
* consumes it.
|
|
@@ -449,6 +449,13 @@ export declare function readCollectionFieldValues(collection: StacCollection): R
|
|
|
449
449
|
* `order_field`, reads as ordered by key.
|
|
450
450
|
*/
|
|
451
451
|
export declare function readCollectionFieldValueRelations(collection: StacCollection): Record<string, TableColumnValueRelation>;
|
|
452
|
+
/**
|
|
453
|
+
* Each column's `quac:relation_reference`, keyed by field name — the
|
|
454
|
+
* counterpart of the write in `stacCatalogue.ts`. A column declaring none is
|
|
455
|
+
* absent from the result, as is one naming no relation or a relation the
|
|
456
|
+
* Collection's `quac:related_to` does not declare.
|
|
457
|
+
*/
|
|
458
|
+
export declare function readCollectionFieldRelationReferences(collection: StacCollection): Record<string, TableColumnRelationReference>;
|
|
452
459
|
/**
|
|
453
460
|
* The units a Collection's source measures in, or null where it names none or
|
|
454
461
|
* names anything this does not read, which is read as QGIS's default of square
|
|
@@ -662,6 +662,31 @@ export function readCollectionFieldValueRelations(collection) {
|
|
|
662
662
|
}
|
|
663
663
|
return relations;
|
|
664
664
|
}
|
|
665
|
+
/**
|
|
666
|
+
* Each column's `quac:relation_reference`, keyed by field name — the
|
|
667
|
+
* counterpart of the write in `stacCatalogue.ts`. A column declaring none is
|
|
668
|
+
* absent from the result, as is one naming no relation or a relation the
|
|
669
|
+
* Collection's `quac:related_to` does not declare.
|
|
670
|
+
*/
|
|
671
|
+
export function readCollectionFieldRelationReferences(collection) {
|
|
672
|
+
const declaredRelations = new Set(readCollectionRelatedTo(collection).map((relation) => relation.id));
|
|
673
|
+
const references = nameRecord();
|
|
674
|
+
for (const [name, column] of declaredColumns(collection)) {
|
|
675
|
+
const entry = readObject(column['quac:relation_reference']);
|
|
676
|
+
if (!entry)
|
|
677
|
+
continue;
|
|
678
|
+
const relation = readTrimmedString(entry.relation);
|
|
679
|
+
if (!relation || !declaredRelations.has(relation))
|
|
680
|
+
continue;
|
|
681
|
+
const filter = readTrimmedString(entry.filter);
|
|
682
|
+
references[name] = {
|
|
683
|
+
relation,
|
|
684
|
+
...(entry.allow_null === true ? { allow_null: true } : {}),
|
|
685
|
+
...(filter ? { filter } : {})
|
|
686
|
+
};
|
|
687
|
+
}
|
|
688
|
+
return references;
|
|
689
|
+
}
|
|
665
690
|
/**
|
|
666
691
|
* The units a Collection's source measures in, or null where it names none or
|
|
667
692
|
* names anything this does not read, which is read as QGIS's default of square
|
|
@@ -117,7 +117,9 @@ export interface HiddenFieldContext {
|
|
|
117
117
|
* while such an expression holds becomes read-only, so that hiding a field
|
|
118
118
|
* never unlocks an edit. A relation or Value Relation to a layer that is not
|
|
119
119
|
* served is dropped, and one to a served layer names it by its served id. A
|
|
120
|
-
*
|
|
120
|
+
* Relation Reference goes with its relation, or where its filter uses a
|
|
121
|
+
* hidden field. A column's default, constraint expression, Value Relation or
|
|
122
|
+
* Relation Reference dropped so is
|
|
121
123
|
* added to its `quac:rules_left_out`, and a rule already there loses an
|
|
122
124
|
* expression that names a hidden field. For
|
|
123
125
|
* an application that serves a project's layers itself, as
|
|
@@ -227,7 +227,9 @@ function serveCollection(source, context) {
|
|
|
227
227
|
* while such an expression holds becomes read-only, so that hiding a field
|
|
228
228
|
* never unlocks an edit. A relation or Value Relation to a layer that is not
|
|
229
229
|
* served is dropped, and one to a served layer names it by its served id. A
|
|
230
|
-
*
|
|
230
|
+
* Relation Reference goes with its relation, or where its filter uses a
|
|
231
|
+
* hidden field. A column's default, constraint expression, Value Relation or
|
|
232
|
+
* Relation Reference dropped so is
|
|
231
233
|
* added to its `quac:rules_left_out`, and a rule already there loses an
|
|
232
234
|
* expression that names a hidden field. For
|
|
233
235
|
* an application that serves a project's layers itself, as
|
|
@@ -242,7 +244,7 @@ export function withoutHiddenFields(source, layerId, context) {
|
|
|
242
244
|
serveFilters(collection, hidden);
|
|
243
245
|
serveRelations(collection, hidden, context);
|
|
244
246
|
serveLocks(collection, hidden);
|
|
245
|
-
serveColumns(collection, hidden, context);
|
|
247
|
+
serveColumns(collection, hidden, context, servedRelationParents(source, collection));
|
|
246
248
|
serveStyleFields(collection, hidden);
|
|
247
249
|
return collection;
|
|
248
250
|
}
|
|
@@ -289,13 +291,30 @@ function serveLocks(collection, hidden) {
|
|
|
289
291
|
}
|
|
290
292
|
collection['quac:locks'] = served;
|
|
291
293
|
}
|
|
292
|
-
|
|
294
|
+
/**
|
|
295
|
+
* Each relation `serveRelations` kept, by id, with its parent's id in the
|
|
296
|
+
* source catalogue, where that parent's hidden fields are read.
|
|
297
|
+
*/
|
|
298
|
+
function servedRelationParents(source, served) {
|
|
299
|
+
const keptIds = new Set(Array.isArray(served['quac:related_to'])
|
|
300
|
+
? served['quac:related_to'].map((relation) => relation.id)
|
|
301
|
+
: []);
|
|
302
|
+
const parents = new Map();
|
|
303
|
+
if (!Array.isArray(source['quac:related_to']))
|
|
304
|
+
return parents;
|
|
305
|
+
for (const relation of source['quac:related_to']) {
|
|
306
|
+
if (keptIds.has(relation.id))
|
|
307
|
+
parents.set(relation.id, relation.parent_collection_id);
|
|
308
|
+
}
|
|
309
|
+
return parents;
|
|
310
|
+
}
|
|
311
|
+
function serveColumns(collection, hidden, context, servedRelations) {
|
|
293
312
|
const columns = collection['table:columns'];
|
|
294
313
|
if (!Array.isArray(columns))
|
|
295
314
|
return;
|
|
296
315
|
const kept = columns
|
|
297
316
|
.filter((column) => !hidden.has(column.name))
|
|
298
|
-
.map((column) => serveColumn(column, hidden, context));
|
|
317
|
+
.map((column) => serveColumn(column, hidden, context, servedRelations));
|
|
299
318
|
if (kept.length > 0)
|
|
300
319
|
collection['table:columns'] = kept;
|
|
301
320
|
else
|
|
@@ -367,7 +386,7 @@ function withFieldType(column, fieldType, projectComments) {
|
|
|
367
386
|
sized['quac:filled_by_data'] = true;
|
|
368
387
|
return sized;
|
|
369
388
|
}
|
|
370
|
-
function serveColumn(source, hidden, context) {
|
|
389
|
+
function serveColumn(source, hidden, context, servedRelations) {
|
|
371
390
|
const column = { ...source };
|
|
372
391
|
const visibleWhen = column['quac:visible_when'];
|
|
373
392
|
if (Array.isArray(visibleWhen)) {
|
|
@@ -430,6 +449,15 @@ function serveColumn(source, hidden, context) {
|
|
|
430
449
|
else
|
|
431
450
|
column['quac:value_relation'] = { ...relation, collection: lookupId };
|
|
432
451
|
}
|
|
452
|
+
const reference = column['quac:relation_reference'];
|
|
453
|
+
if (reference) {
|
|
454
|
+
const parentId = servedRelations.get(reference.relation);
|
|
455
|
+
const parentHidden = parentId === undefined ? new Set() : context.hiddenOf(parentId);
|
|
456
|
+
if (parentId === undefined || mentionsAny(reference.filter, parentHidden) || mentionsAny(reference.filter, hidden)) {
|
|
457
|
+
delete column['quac:relation_reference'];
|
|
458
|
+
leftOut.push({ rule: 'widget', text: 'RelationReference' });
|
|
459
|
+
}
|
|
460
|
+
}
|
|
433
461
|
if (leftOut.length > 0)
|
|
434
462
|
column['quac:rules_left_out'] = leftOut;
|
|
435
463
|
return column;
|
|
@@ -13,7 +13,7 @@ import { buildXyzLink } from "../model/stacXyz.js";
|
|
|
13
13
|
import { brandColorOf } from "../parse/parseBrandColour.js";
|
|
14
14
|
import { safeName } from "./splitCatalogue.js";
|
|
15
15
|
import { findGeometrySiblings, readSiblingShapes, siblingCollectionId } from "../parse/geometrySiblings.js";
|
|
16
|
-
import { findValueRelationLookup, isFilterInProject, isRelationInProject } from "../parse/projectNotes.js";
|
|
16
|
+
import { findRelationReferenceRelation, findValueRelationLookup, isFilterInProject, isRelationInProject } from "../parse/projectNotes.js";
|
|
17
17
|
import { declaredMediaTypeForFile, isLayerFileOfFormat, PROJECT_DATA_ROLES, QML_STYLE_MEDIA_TYPE } from "../util/catalogueFileFormats.js";
|
|
18
18
|
import { nameRecord } from "../util/nameRecord.js";
|
|
19
19
|
/**
|
|
@@ -147,6 +147,7 @@ function qgsProjectToNormalized(project, companions, projectPath, projectFileNam
|
|
|
147
147
|
styleFiles,
|
|
148
148
|
relationsByChildLayerId: collectRelationsByChildLayerId(project.relations ?? [], layersById, collectionIdOf),
|
|
149
149
|
valueRelationsByLayerId: collectValueRelationsByLayerId(project.layers, layersById, collectionIdOf),
|
|
150
|
+
relationReferencesByLayerId: collectRelationReferencesByLayerId(project.layers, project.relations ?? [], layersById),
|
|
150
151
|
siblingsById,
|
|
151
152
|
measurement: project.measurement ?? null,
|
|
152
153
|
wfsTransactionLayers: project.wfsTransactionLayers ?? null,
|
|
@@ -359,6 +360,35 @@ function collectValueRelationsByLayerId(layers, layersById, collectionIdOf) {
|
|
|
359
360
|
}
|
|
360
361
|
return byLayerId;
|
|
361
362
|
}
|
|
363
|
+
/**
|
|
364
|
+
* Each layer's Relation Reference widgets as `quac:relation_reference`
|
|
365
|
+
* writes them, keyed by layer id and then field name. The relation is found
|
|
366
|
+
* as `findRelationReferenceRelation` finds it; a widget with none writes
|
|
367
|
+
* nothing. Where the widget does not say whether a blank is allowed, one is
|
|
368
|
+
* allowed unless a field the relation joins must not be blank, as QGIS
|
|
369
|
+
* decides (`QgsRelation::referencingFieldsAllowNull`,
|
|
370
|
+
* `src/core/qgsrelation.cpp`, `qgis/QGIS@release-3_40`).
|
|
371
|
+
*/
|
|
372
|
+
function collectRelationReferencesByLayerId(layers, relations, layersById) {
|
|
373
|
+
const byLayerId = new Map();
|
|
374
|
+
for (const layer of layers) {
|
|
375
|
+
const references = nameRecord();
|
|
376
|
+
for (const [field, widget] of Object.entries(layer.fieldRelationReferences ?? {})) {
|
|
377
|
+
const relation = findRelationReferenceRelation(layer.id, field, widget, relations, layersById);
|
|
378
|
+
if (!relation)
|
|
379
|
+
continue;
|
|
380
|
+
const allowNull = widget.allowNull ?? relation.fieldPairs.every((pair) => !layer.fieldEditRules[pair.childField]?.notNull);
|
|
381
|
+
references[field] = {
|
|
382
|
+
relation: relation.id,
|
|
383
|
+
...(allowNull ? { allow_null: true } : {}),
|
|
384
|
+
...(widget.filterExpression ? { filter: widget.filterExpression } : {})
|
|
385
|
+
};
|
|
386
|
+
}
|
|
387
|
+
if (Object.keys(references).length > 0)
|
|
388
|
+
byLayerId.set(layer.id, references);
|
|
389
|
+
}
|
|
390
|
+
return byLayerId;
|
|
391
|
+
}
|
|
362
392
|
/** A Value Relation widget as `quac:value_relation` stores it: a member at its default is left off. */
|
|
363
393
|
function valueRelationToJson(collectionId, widget) {
|
|
364
394
|
return {
|
|
@@ -525,6 +555,7 @@ function qgsLayerToNormalized(layer, context, geometryFilter = geometryFilterOf(
|
|
|
525
555
|
const { layerWgs84Extents } = context;
|
|
526
556
|
const relatedTo = context.relationsByChildLayerId.get(layer.id);
|
|
527
557
|
const valueRelations = context.valueRelationsByLayerId.get(layer.id);
|
|
558
|
+
const relationReferences = context.relationReferencesByLayerId.get(layer.id);
|
|
528
559
|
const bbox = effectiveWgs84Bbox(layer, layerWgs84Extents);
|
|
529
560
|
const metadata = layer.resourceMetadata;
|
|
530
561
|
const ds = layer.dataSource;
|
|
@@ -539,7 +570,7 @@ function qgsLayerToNormalized(layer, context, geometryFilter = geometryFilterOf(
|
|
|
539
570
|
geometryType: layer.geometryType,
|
|
540
571
|
wkbTypes: layer.wkbType ? [layer.wkbType] : [],
|
|
541
572
|
qgisServerNames: qgisServerNamesOf(layer, context),
|
|
542
|
-
tableColumns: deriveTableColumns(geojson, layer.fieldNames, layer.fieldAliases, layer.fieldValueMaps, layer.fieldAttachments, layer.fieldEditRules, valueRelations, layer.formLayout ?? null, layer.fieldIcons, layer.fieldControls, layer.fieldComments, layer.serverHiddenFields, fieldRulesLeftOutOf(layer, valueRelations)),
|
|
573
|
+
tableColumns: deriveTableColumns(geojson, layer.fieldNames, layer.fieldAliases, layer.fieldValueMaps, layer.fieldAttachments, layer.fieldEditRules, valueRelations, layer.formLayout ?? null, layer.fieldIcons, layer.fieldControls, layer.fieldComments, layer.serverHiddenFields, fieldRulesLeftOutOf(layer, valueRelations, relationReferences), relationReferences),
|
|
543
574
|
formOrder: layer.formLayout?.fields.map((field) => field.name),
|
|
544
575
|
assets: buildLayerAssets(layer, context, geometryFilter, styleParts),
|
|
545
576
|
keywords: metadata.keywords.length > 0 ? metadata.keywords : undefined,
|
|
@@ -914,6 +945,10 @@ function unionExtent(layers, layerWgs84Extents) {
|
|
|
914
945
|
* - **quac:value_relation**
|
|
915
946
|
* the Collection a field's choices are read from, when
|
|
916
947
|
* QGIS's Value Relation edit widget names one the project holds
|
|
948
|
+
* - **quac:relation_reference**
|
|
949
|
+
* the relation whose parent features fill the field, when
|
|
950
|
+
* QGIS's Relation Reference edit widget joins it to a parent
|
|
951
|
+
* the project holds
|
|
917
952
|
* - **quac:attachment**
|
|
918
953
|
* that the field holds a file's path, when QGIS's
|
|
919
954
|
* Attachment edit widget declares one
|
|
@@ -946,7 +981,7 @@ function unionExtent(layers, layerWgs84Extents) {
|
|
|
946
981
|
* exist": this means a hidden WFS layer's schema is fully visible to the
|
|
947
982
|
* dev panel and to STAC clients before any data is fetched.
|
|
948
983
|
*/
|
|
949
|
-
function deriveTableColumns(geojson, fieldNames, fieldAliases, fieldValueMaps = nameRecord(), fieldAttachments = nameRecord(), fieldEditRules = nameRecord(), fieldValueRelations = nameRecord(), formLayout = null, fieldIcons = nameRecord(), fieldControls = nameRecord(), fieldComments = nameRecord(), serverHiddenFields = undefined, fieldRulesLeftOut = nameRecord()) {
|
|
984
|
+
function deriveTableColumns(geojson, fieldNames, fieldAliases, fieldValueMaps = nameRecord(), fieldAttachments = nameRecord(), fieldEditRules = nameRecord(), fieldValueRelations = nameRecord(), formLayout = null, fieldIcons = nameRecord(), fieldControls = nameRecord(), fieldComments = nameRecord(), serverHiddenFields = undefined, fieldRulesLeftOut = nameRecord(), fieldRelationReferences = nameRecord()) {
|
|
950
985
|
const observedTypes = new Map();
|
|
951
986
|
const orderedFieldNames = [];
|
|
952
987
|
const seen = new Set();
|
|
@@ -996,6 +1031,9 @@ function deriveTableColumns(geojson, fieldNames, fieldAliases, fieldValueMaps =
|
|
|
996
1031
|
const valueRelation = fieldValueRelations[name];
|
|
997
1032
|
if (valueRelation)
|
|
998
1033
|
column['quac:value_relation'] = valueRelation;
|
|
1034
|
+
const relationReference = fieldRelationReferences[name];
|
|
1035
|
+
if (relationReference)
|
|
1036
|
+
column['quac:relation_reference'] = relationReference;
|
|
999
1037
|
const attachment = fieldAttachments[name];
|
|
1000
1038
|
if (attachment)
|
|
1001
1039
|
column['quac:attachment'] = attachmentToJson(attachment);
|
|
@@ -1071,10 +1109,11 @@ function deriveTableColumns(geojson, fieldNames, fieldAliases, fieldValueMaps =
|
|
|
1071
1109
|
/**
|
|
1072
1110
|
* A layer's field rules its Collection leaves out: those its parsing left out
|
|
1073
1111
|
* (`fieldRulesLeftOut`), then each Value Relation whose lookup layer is not
|
|
1074
|
-
* in the catalogue, which `quac:value_relation` therefore does not name
|
|
1112
|
+
* in the catalogue, which `quac:value_relation` therefore does not name, then
|
|
1113
|
+
* each Relation Reference with no relation, as a widget left out. The
|
|
1075
1114
|
* lookup is not named either: it may be a layer the project leaves out of WMS.
|
|
1076
1115
|
*/
|
|
1077
|
-
function fieldRulesLeftOutOf(layer, valueRelations) {
|
|
1116
|
+
function fieldRulesLeftOutOf(layer, valueRelations, relationReferences) {
|
|
1078
1117
|
const leftOut = nameRecord();
|
|
1079
1118
|
for (const [field, rules] of Object.entries(layer.fieldRulesLeftOut ?? {}))
|
|
1080
1119
|
leftOut[field] = [...rules];
|
|
@@ -1083,6 +1122,11 @@ function fieldRulesLeftOutOf(layer, valueRelations) {
|
|
|
1083
1122
|
continue;
|
|
1084
1123
|
(leftOut[field] ??= []).push({ rule: 'value_relation', text: null });
|
|
1085
1124
|
}
|
|
1125
|
+
for (const field of Object.keys(layer.fieldRelationReferences ?? {})) {
|
|
1126
|
+
if (relationReferences?.[field])
|
|
1127
|
+
continue;
|
|
1128
|
+
(leftOut[field] ??= []).push({ rule: 'widget', text: 'RelationReference' });
|
|
1129
|
+
}
|
|
1086
1130
|
return leftOut;
|
|
1087
1131
|
}
|
|
1088
1132
|
/** A left-out field rule as `quac:rules_left_out` stores it: a blank text is left off. */
|
|
@@ -21,6 +21,8 @@ export type NewFeatureProblem = 'unknown-field' | 'not-fillable' | 'required' |
|
|
|
21
21
|
* - `visible-when` / `editable-when`: an expression that hides or locks the
|
|
22
22
|
* field in the form, so whether it is filled in depends on the other values;
|
|
23
23
|
* - `value-relation`: its choices are another layer's records;
|
|
24
|
+
* - `relation-reference`: it holds a parent feature's key, which only the
|
|
25
|
+
* parent layer's features can check;
|
|
24
26
|
* - `unique`: an enforced Unique constraint, which needs the layer's other features;
|
|
25
27
|
* - `date-format`: it stores dates in a format of its own;
|
|
26
28
|
* - `attachment`: it holds a file's path, and the file is not part of the feature;
|
|
@@ -32,7 +34,7 @@ export type NewFeatureProblem = 'unknown-field' | 'not-fillable' | 'required' |
|
|
|
32
34
|
* A constraint expression or Value Relation the catalogue leaves out is
|
|
33
35
|
* `constraint-expression` or `value-relation`, as one it carries is.
|
|
34
36
|
*/
|
|
35
|
-
export type UncheckedFieldRule = 'constraint-expression' | 'visible-when' | 'editable-when' | 'value-relation' | 'unique' | 'date-format' | 'attachment' | 'type' | 'widget' | 'left-out';
|
|
37
|
+
export type UncheckedFieldRule = 'constraint-expression' | 'visible-when' | 'editable-when' | 'value-relation' | 'relation-reference' | 'unique' | 'date-format' | 'attachment' | 'type' | 'widget' | 'left-out';
|
|
36
38
|
export interface NewFeatureCheck {
|
|
37
39
|
/** The fields refused, in the layer's field order, then the fields the layer does not have. */
|
|
38
40
|
problems: {
|
|
@@ -143,6 +143,8 @@ function uncheckedColumnRules(column, type, unique, dateFormat) {
|
|
|
143
143
|
found.push('editable-when');
|
|
144
144
|
if (column['quac:value_relation'])
|
|
145
145
|
found.push('value-relation');
|
|
146
|
+
if (column['quac:relation_reference'])
|
|
147
|
+
found.push('relation-reference');
|
|
146
148
|
if (unique)
|
|
147
149
|
found.push('unique');
|
|
148
150
|
if (dateFormat)
|
package/dist/index.d.ts
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* `@vectoriahq/quac`.
|
|
4
4
|
*/
|
|
5
5
|
export type { QgsProject, ProjectMetadata, MapExtent, BoundingBox, LayerEntry, EditLock, LayerLocks, LockedEdit, ProjectMeasurement, LayerStyle, LayerResourceMetadata, LayerScaleRange, LayerContact, LayerAttribution, FieldAttachment, FieldCheckbox, FieldConstraintExpression, FieldDefaultExpression, FieldDefaultValue, FieldEditRule, FormLayoutField, LayerFormLayout, FieldFixedValue, FieldRange, FieldUuidFormat, FieldValueMapEntry, DataSource, FileDataSource, WfsDataSource, WmsDataSource, UnsupportedDataSource, LayerTreeNode, LayerGroup, LayerTreeLeaf, QgsRelation, QgsRelationFieldPair, ProjectNote, ProjectNoteReason } from './model/QgsProject.ts';
|
|
6
|
-
export type { StacCatalog, StacCollection, StacItem, StacAsset, StacExtent, StacLink, StacObject, StacProvider, TableColumn, TableColumnType, TableColumnValue, TableColumnValueRelation, TableColumnRuleLeftOut, TableColumnServerService, TableColumnAttachment, TableColumnCheckbox, TableColumnRange } from './model/Stac.ts';
|
|
6
|
+
export type { StacCatalog, StacCollection, StacItem, StacAsset, StacExtent, StacLink, StacObject, StacProvider, TableColumn, TableColumnType, TableColumnValue, TableColumnRelationReference, TableColumnValueRelation, TableColumnRuleLeftOut, TableColumnServerService, TableColumnAttachment, TableColumnCheckbox, TableColumnRange } from './model/Stac.ts';
|
|
7
7
|
export { STAC_VERSION } from './model/Stac.ts';
|
|
8
8
|
export { isIconLibraryAddress, resolveFieldIconAddress } from './model/fieldIconAddress.ts';
|
|
9
9
|
export { collectCollectionStyles, getDefaultStyle, styleAssetKey, GL_STYLE_MEDIA_TYPE } from './model/stacStyles.ts';
|
|
@@ -37,7 +37,7 @@ export { FILE_EXTENSION, FILE_SIZE_FIELD, TABLE_ROW_COUNT_FIELD, readCollectionR
|
|
|
37
37
|
export { PMTILES_MEDIA_TYPE, VISUAL_ROLE, readCollectionPmtiles } from './model/stacPmtiles.ts';
|
|
38
38
|
export type { StacPmtilesSource } from './model/stacPmtiles.ts';
|
|
39
39
|
export type { StacCompanionData } from './generate/stacCatalogue.ts';
|
|
40
|
-
export { QUAC_ACTIVE_COLLECTION_FIELD, QUAC_FILTERS_FIELD, QUAC_FORM_ORDER_FIELD, QUAC_LOCKS_FIELD, QUAC_MUTUALLY_EXCLUSIVE_FIELD, QUAC_PRIVATE_FIELD, readCatalogueActiveCollection, readCatalogueInitialView, readCataloguePrintLayouts, readCatalogueBrandColor, readCatalogueLogos, readCatalogueLeftOut, readCatalogueLogoLeftOut, QUAC_LOGO_LEFT_OUT_FIELD, readCollectionDisplayField, readCollectionEditable, readCollectionFieldAliases, readCollectionFieldComments, readCollectionFieldAttachments, readCollectionFieldEditRules, readCollectionFieldNames, readCollectionFieldRulesLeftOut, readCollectionServerHiddenFields, QUAC_QGIS_SERVER_HIDDEN_FIELD, QUAC_RULES_LEFT_OUT_FIELD, readCollectionFieldTypes, readCollectionFieldValueRelations, readCollectionFieldValues, readCollectionFormLayout, readCollectionGeometryType, readCollectionGeometryTypes, readCollectionIdentifiable, readCollectionMeasurement, readCollectionOpacity, readCollectionIcon, readCollectionAddedMessage, readCollectionMapTip, readCollectionLegendImage, readCollectionFilters, readCollectionLocks, readCollectionPrivate, readCollectionRelatedTo, readCollectionScaleRange, readCollectionVisibility, statedOpacity } from './generate/normalizedProject.ts';
|
|
40
|
+
export { QUAC_ACTIVE_COLLECTION_FIELD, QUAC_FILTERS_FIELD, QUAC_FORM_ORDER_FIELD, QUAC_LOCKS_FIELD, QUAC_MUTUALLY_EXCLUSIVE_FIELD, QUAC_PRIVATE_FIELD, readCatalogueActiveCollection, readCatalogueInitialView, readCataloguePrintLayouts, readCatalogueBrandColor, readCatalogueLogos, readCatalogueLeftOut, readCatalogueLogoLeftOut, QUAC_LOGO_LEFT_OUT_FIELD, readCollectionDisplayField, readCollectionEditable, readCollectionFieldAliases, readCollectionFieldComments, readCollectionFieldAttachments, readCollectionFieldEditRules, readCollectionFieldNames, readCollectionFieldRulesLeftOut, readCollectionServerHiddenFields, QUAC_QGIS_SERVER_HIDDEN_FIELD, QUAC_RULES_LEFT_OUT_FIELD, readCollectionFieldTypes, readCollectionFieldValueRelations, readCollectionFieldRelationReferences, readCollectionFieldValues, readCollectionFormLayout, readCollectionGeometryType, readCollectionGeometryTypes, readCollectionIdentifiable, readCollectionMeasurement, readCollectionOpacity, readCollectionIcon, readCollectionAddedMessage, readCollectionMapTip, readCollectionLegendImage, readCollectionFilters, readCollectionLocks, readCollectionPrivate, readCollectionRelatedTo, readCollectionScaleRange, readCollectionVisibility, statedOpacity } from './generate/normalizedProject.ts';
|
|
41
41
|
export type { CatalogueLogo, LeftOutLayer, LeftOutReason, LogoLeftOut, LogoLeftOutReason, CollectionFilter, CollectionFormLayout, CollectionRelation, CollectionRelationField } from './generate/normalizedProject.ts';
|
|
42
42
|
export { generateStacCatalogueFromWfsCapabilities } from './generate/wfsStacCatalogue.ts';
|
|
43
43
|
export type { WfsStacCatalogueOptions } from './generate/wfsStacCatalogue.ts';
|
package/dist/index.js
CHANGED
|
@@ -24,7 +24,7 @@ export { DATA_ROLE, findAssetByRole, readDataAsset } from "./model/stacAssetRole
|
|
|
24
24
|
export { THUMBNAIL_ROLE, readCollectionAttribution, readCollectionDeprecation, readCollectionSelfHref, readCollectionThumbnail } from "./model/stacCollectionNotes.js";
|
|
25
25
|
export { FILE_EXTENSION, FILE_SIZE_FIELD, TABLE_ROW_COUNT_FIELD, readCollectionRowCount, readDataAssetFileSize } from "./model/stacSizeAndCount.js";
|
|
26
26
|
export { PMTILES_MEDIA_TYPE, VISUAL_ROLE, readCollectionPmtiles } from "./model/stacPmtiles.js";
|
|
27
|
-
export { QUAC_ACTIVE_COLLECTION_FIELD, QUAC_FILTERS_FIELD, QUAC_FORM_ORDER_FIELD, QUAC_LOCKS_FIELD, QUAC_MUTUALLY_EXCLUSIVE_FIELD, QUAC_PRIVATE_FIELD, readCatalogueActiveCollection, readCatalogueInitialView, readCataloguePrintLayouts, readCatalogueBrandColor, readCatalogueLogos, readCatalogueLeftOut, readCatalogueLogoLeftOut, QUAC_LOGO_LEFT_OUT_FIELD, readCollectionDisplayField, readCollectionEditable, readCollectionFieldAliases, readCollectionFieldComments, readCollectionFieldAttachments, readCollectionFieldEditRules, readCollectionFieldNames, readCollectionFieldRulesLeftOut, readCollectionServerHiddenFields, QUAC_QGIS_SERVER_HIDDEN_FIELD, QUAC_RULES_LEFT_OUT_FIELD, readCollectionFieldTypes, readCollectionFieldValueRelations, readCollectionFieldValues, readCollectionFormLayout, readCollectionGeometryType, readCollectionGeometryTypes, readCollectionIdentifiable, readCollectionMeasurement, readCollectionOpacity, readCollectionIcon, readCollectionAddedMessage, readCollectionMapTip, readCollectionLegendImage, readCollectionFilters, readCollectionLocks, readCollectionPrivate, readCollectionRelatedTo, readCollectionScaleRange, readCollectionVisibility, statedOpacity } from "./generate/normalizedProject.js";
|
|
27
|
+
export { QUAC_ACTIVE_COLLECTION_FIELD, QUAC_FILTERS_FIELD, QUAC_FORM_ORDER_FIELD, QUAC_LOCKS_FIELD, QUAC_MUTUALLY_EXCLUSIVE_FIELD, QUAC_PRIVATE_FIELD, readCatalogueActiveCollection, readCatalogueInitialView, readCataloguePrintLayouts, readCatalogueBrandColor, readCatalogueLogos, readCatalogueLeftOut, readCatalogueLogoLeftOut, QUAC_LOGO_LEFT_OUT_FIELD, readCollectionDisplayField, readCollectionEditable, readCollectionFieldAliases, readCollectionFieldComments, readCollectionFieldAttachments, readCollectionFieldEditRules, readCollectionFieldNames, readCollectionFieldRulesLeftOut, readCollectionServerHiddenFields, QUAC_QGIS_SERVER_HIDDEN_FIELD, QUAC_RULES_LEFT_OUT_FIELD, readCollectionFieldTypes, readCollectionFieldValueRelations, readCollectionFieldRelationReferences, readCollectionFieldValues, readCollectionFormLayout, readCollectionGeometryType, readCollectionGeometryTypes, readCollectionIdentifiable, readCollectionMeasurement, readCollectionOpacity, readCollectionIcon, readCollectionAddedMessage, readCollectionMapTip, readCollectionLegendImage, readCollectionFilters, readCollectionLocks, readCollectionPrivate, readCollectionRelatedTo, readCollectionScaleRange, readCollectionVisibility, statedOpacity } from "./generate/normalizedProject.js";
|
|
28
28
|
export { generateStacCatalogueFromWfsCapabilities } from "./generate/wfsStacCatalogue.js";
|
|
29
29
|
export { generateStacCatalogueFromFolder } from "./generate/folderStacCatalogue.js";
|
|
30
30
|
export { generateCollectionForDroppedFile, generateCollectionForLinkedFile } from "./generate/fileLayerCollection.js";
|
|
@@ -292,6 +292,12 @@ export interface LayerEntry {
|
|
|
292
292
|
* widget are absent.
|
|
293
293
|
*/
|
|
294
294
|
fieldValueRelations: Record<string, FieldValueRelation>;
|
|
295
|
+
/**
|
|
296
|
+
* Relation Reference edit widgets, keyed by field name — the fields QGIS
|
|
297
|
+
* fills by picking a feature of the parent layer under one of the
|
|
298
|
+
* project's relations. Fields with no such widget are absent.
|
|
299
|
+
*/
|
|
300
|
+
fieldRelationReferences?: Record<string, FieldRelationReference>;
|
|
295
301
|
/**
|
|
296
302
|
* Attachment edit widgets, keyed by field name — the fields QGIS declares as
|
|
297
303
|
* holding a file rather than text. Fields with no such widget are absent.
|
|
@@ -461,6 +467,21 @@ export interface FieldValueRelation {
|
|
|
461
467
|
/** Whether the order is reversed (`OrderByDescending`). */
|
|
462
468
|
descending: boolean;
|
|
463
469
|
}
|
|
470
|
+
/**
|
|
471
|
+
* A field's Relation Reference edit widget, as far as QUAC reads it: the
|
|
472
|
+
* relation whose parent features it offers, whether it offers a blank, and
|
|
473
|
+
* the expression narrowing the parent features. Its map identification,
|
|
474
|
+
* filter fields, embedded form, add-feature button and fetch limit are not
|
|
475
|
+
* read.
|
|
476
|
+
*/
|
|
477
|
+
export interface FieldRelationReference {
|
|
478
|
+
/** The relation's id (`Relation`); empty when the widget names none. */
|
|
479
|
+
relationId: string;
|
|
480
|
+
/** Whether the widget offers a blank (`AllowNULL`); null when the widget does not say. */
|
|
481
|
+
allowNull: boolean | null;
|
|
482
|
+
/** The QGIS expression narrowing the parent features (`FilterExpression`); empty for none. */
|
|
483
|
+
filterExpression: string;
|
|
484
|
+
}
|
|
464
485
|
/**
|
|
465
486
|
* A field's Attachment edit widget, as far as QUAC reads it. QGIS calls
|
|
466
487
|
* the widget `ExternalResource`; the field holds a file's path rather than
|
package/dist/model/Stac.d.ts
CHANGED
|
@@ -145,6 +145,8 @@ export interface TableColumn {
|
|
|
145
145
|
'quac:attachment'?: TableColumnAttachment;
|
|
146
146
|
/** Declares that the column's choices are the records of another Collection of the same catalogue. */
|
|
147
147
|
'quac:value_relation'?: TableColumnValueRelation;
|
|
148
|
+
/** Declares that the column is filled by picking a feature of the parent Collection under one of this Collection's relations. */
|
|
149
|
+
'quac:relation_reference'?: TableColumnRelationReference;
|
|
148
150
|
/** Written only as `false`: the source shows the column but does not let anyone change it. */
|
|
149
151
|
'quac:editable'?: false;
|
|
150
152
|
/** A value the column is filled with on its own. */
|
|
@@ -249,6 +251,20 @@ export interface TableColumnValueRelation {
|
|
|
249
251
|
/** Written only as `true`: the order is reversed. */
|
|
250
252
|
descending?: true;
|
|
251
253
|
}
|
|
254
|
+
/**
|
|
255
|
+
* A column filled by picking one of the parent's features under a relation
|
|
256
|
+
* this Collection declares in `quac:related_to`. The picked feature's values
|
|
257
|
+
* of the relation's parent fields fill its child fields, and the feature is
|
|
258
|
+
* shown by the parent Collection's `quac:display_field`.
|
|
259
|
+
*/
|
|
260
|
+
export interface TableColumnRelationReference {
|
|
261
|
+
/** The `id` of the relation, among this Collection's `quac:related_to`. */
|
|
262
|
+
relation: string;
|
|
263
|
+
/** Written only as `true`: the field may be left without a parent. */
|
|
264
|
+
allow_null?: true;
|
|
265
|
+
/** A QGIS expression narrowing the parent's features. */
|
|
266
|
+
filter?: string;
|
|
267
|
+
}
|
|
252
268
|
/**
|
|
253
269
|
* A Checkbox column. Every member is written only where it differs from the
|
|
254
270
|
* source's default, so `{}` is a checkbox with no states that allows no blank.
|
|
@@ -92,6 +92,7 @@ function parseMapLayer(maplayer, notes, photoSettings) {
|
|
|
92
92
|
const fieldAliases = parseFieldAliases(maplayer);
|
|
93
93
|
const { styles, activeIndex } = parseLayerStyles(maplayer);
|
|
94
94
|
const fieldValueRelations = parseFieldValueRelations(maplayer);
|
|
95
|
+
const fieldRelationReferences = parseFieldRelationReferences(maplayer);
|
|
95
96
|
const fieldAttachments = parseFieldAttachments(maplayer, photoSettings.merginNaming[id] ?? nameRecord(), photoSettings);
|
|
96
97
|
if (dataSource.kind === 'unsupported')
|
|
97
98
|
note('source', null, dataSource.hint);
|
|
@@ -127,6 +128,7 @@ function parseMapLayer(maplayer, notes, photoSettings) {
|
|
|
127
128
|
isPrivate: parsePrivate(maplayer),
|
|
128
129
|
legendImage: parseLegendImage(maplayer),
|
|
129
130
|
fieldValueRelations,
|
|
131
|
+
...(Object.keys(fieldRelationReferences).length > 0 ? { fieldRelationReferences } : {}),
|
|
130
132
|
fieldAttachments,
|
|
131
133
|
fieldEditRules: parseFieldEditRules(maplayer, note),
|
|
132
134
|
icon: parseLayerIcon(maplayer),
|
|
@@ -150,7 +152,7 @@ function parseMapLayer(maplayer, notes, photoSettings) {
|
|
|
150
152
|
* in `<editWidget type>`. `TextEdit` is QGIS's plain text box, which needs
|
|
151
153
|
* nothing carried. An empty type is a field with no widget set.
|
|
152
154
|
*/
|
|
153
|
-
const READ_WIDGET_TYPES = new Set(['', 'TextEdit', 'ValueMap', 'ValueRelation', 'ExternalResource', 'Hidden', 'Color', 'CheckBox', 'Range', 'DateTime', 'UuidGenerator']);
|
|
155
|
+
const READ_WIDGET_TYPES = new Set(['', 'TextEdit', 'ValueMap', 'ValueRelation', 'RelationReference', 'ExternalResource', 'Hidden', 'Color', 'CheckBox', 'Range', 'DateTime', 'UuidGenerator']);
|
|
154
156
|
/**
|
|
155
157
|
* Notes each field's widget the Collection does not carry: one of a type not
|
|
156
158
|
* in `READ_WIDGET_TYPES`, and a Value Relation or Attachment widget its reader
|
|
@@ -410,6 +412,48 @@ function parseFieldValueRelations(maplayer) {
|
|
|
410
412
|
}
|
|
411
413
|
return result;
|
|
412
414
|
}
|
|
415
|
+
/**
|
|
416
|
+
* Reads every field's Relation Reference edit widget, keyed by field name.
|
|
417
|
+
* QGIS writes its config as a flat `<Option>` map
|
|
418
|
+
* (`QgsRelationReferenceConfigDlg::config`,
|
|
419
|
+
* `src/gui/editorwidgets/qgsrelationreferenceconfigdlg.cpp`,
|
|
420
|
+
* `qgis/QGIS@release-3_40`, read 2026-12-02):
|
|
421
|
+
*
|
|
422
|
+
* <editWidget type="RelationReference">
|
|
423
|
+
* <config>
|
|
424
|
+
* <Option type="Map">
|
|
425
|
+
* <Option type="QString" value="trees_inspections" name="Relation"/>
|
|
426
|
+
* <Option type="bool" value="false" name="AllowNULL"/>
|
|
427
|
+
* <Option type="QString" value="" name="FilterExpression"/>
|
|
428
|
+
* </Option>
|
|
429
|
+
* </config>
|
|
430
|
+
* </editWidget>
|
|
431
|
+
*
|
|
432
|
+
* Every Relation Reference widget is read, as QGIS falls back to the first
|
|
433
|
+
* relation joining the field where `Relation` names none or one the project
|
|
434
|
+
* lacks, and leaves `AllowNULL` unset to mean "blank unless the field must
|
|
435
|
+
* not be empty" (`QgsRelationReferenceWidgetWrapper::initWidget`,
|
|
436
|
+
* `src/gui/editorwidgets/qgsrelationreferencewidgetwrapper.cpp`, same
|
|
437
|
+
* branch). The catalogue resolves both.
|
|
438
|
+
*
|
|
439
|
+
* A field with no RelationReference widget is absent from the returned map.
|
|
440
|
+
*/
|
|
441
|
+
function parseFieldRelationReferences(maplayer) {
|
|
442
|
+
const result = nameRecord();
|
|
443
|
+
for (const [name, editWidget] of layerEditWidgets(maplayer)) {
|
|
444
|
+
if (result[name])
|
|
445
|
+
continue;
|
|
446
|
+
if (editWidget?.getAttribute('type') !== 'RelationReference')
|
|
447
|
+
continue;
|
|
448
|
+
const options = readOptionMap(editWidget);
|
|
449
|
+
result[name] = {
|
|
450
|
+
relationId: readTrimmedOption(options, 'Relation') ?? '',
|
|
451
|
+
allowNull: options.has('AllowNULL') ? readFlag(options, 'AllowNULL') : null,
|
|
452
|
+
filterExpression: readTrimmedOption(options, 'FilterExpression') ?? ''
|
|
453
|
+
};
|
|
454
|
+
}
|
|
455
|
+
return result;
|
|
456
|
+
}
|
|
413
457
|
/**
|
|
414
458
|
* QGIS's `DocumentViewerContent`, by its own order from zero
|
|
415
459
|
* (`src/gui/qgsexternalresourcewidget.h`, `qgis/QGIS@master`, read
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { FieldValueRelation, LayerEntry, PresetFilter, ProjectNote, QgsRelation } from '../model/QgsProject.ts';
|
|
1
|
+
import type { FieldRelationReference, FieldValueRelation, LayerEntry, PresetFilter, ProjectNote, QgsRelation } from '../model/QgsProject.ts';
|
|
2
2
|
/**
|
|
3
3
|
* The rules that decide whether a setting naming another layer reaches the
|
|
4
4
|
* catalogue, and the notes for those that do not. `generateStacCatalogue`
|
|
@@ -13,14 +13,25 @@ import type { FieldValueRelation, LayerEntry, PresetFilter, ProjectNote, QgsRela
|
|
|
13
13
|
* project holds neither.
|
|
14
14
|
*/
|
|
15
15
|
export declare function findValueRelationLookup(widget: FieldValueRelation, layers: readonly LayerEntry[], layersById: ReadonlyMap<string, LayerEntry>): LayerEntry | undefined;
|
|
16
|
+
/**
|
|
17
|
+
* The relation a Relation Reference widget offers the parent features of:
|
|
18
|
+
* among the project's relations joining this field of this layer to a parent
|
|
19
|
+
* the project holds, the one whose id the widget names, and otherwise the
|
|
20
|
+
* first, as QGIS falls back to the first relation referencing the field
|
|
21
|
+
* (`QgsRelationReferenceWidgetWrapper::initWidget`,
|
|
22
|
+
* `src/gui/editorwidgets/qgsrelationreferencewidgetwrapper.cpp`,
|
|
23
|
+
* `qgis/QGIS@release-3_40`). Undefined where no such relation exists.
|
|
24
|
+
*/
|
|
25
|
+
export declare function findRelationReferenceRelation(layerId: string, field: string, widget: FieldRelationReference, relations: readonly QgsRelation[], layersById: ReadonlyMap<string, LayerEntry>): QgsRelation | undefined;
|
|
16
26
|
/** Whether the project holds both of a relation's layers. */
|
|
17
27
|
export declare function isRelationInProject(relation: QgsRelation, layersById: ReadonlyMap<string, LayerEntry>): boolean;
|
|
18
28
|
/** Whether the project holds a filter's layer and that layer has its field. */
|
|
19
29
|
export declare function isFilterInProject(filter: PresetFilter, layersById: ReadonlyMap<string, LayerEntry>): boolean;
|
|
20
30
|
/**
|
|
21
31
|
* The notes for the settings that name another layer and do not reach the
|
|
22
|
-
* catalogue: Value Relations, relations and filters, in
|
|
23
|
-
* in the project's order.
|
|
32
|
+
* catalogue: Value Relations, Relation References, relations and filters, in
|
|
33
|
+
* that order, and each in the project's order. A Relation Reference with no
|
|
34
|
+
* relation is noted as a widget left out, as the catalogue records it. `textFilters` are the Mergin Maps `Text` filters
|
|
24
35
|
* `parseMerginFilters` passes over.
|
|
25
36
|
*/
|
|
26
37
|
export declare function crossLayerNotes(layers: readonly LayerEntry[], relations: readonly QgsRelation[], filters: readonly PresetFilter[], textFilters: readonly PresetFilter[]): ProjectNote[];
|
|
@@ -14,6 +14,21 @@
|
|
|
14
14
|
export function findValueRelationLookup(widget, layers, layersById) {
|
|
15
15
|
return layersById.get(widget.layerId) ?? layers.find((candidate) => candidate.name === widget.layerName);
|
|
16
16
|
}
|
|
17
|
+
/**
|
|
18
|
+
* The relation a Relation Reference widget offers the parent features of:
|
|
19
|
+
* among the project's relations joining this field of this layer to a parent
|
|
20
|
+
* the project holds, the one whose id the widget names, and otherwise the
|
|
21
|
+
* first, as QGIS falls back to the first relation referencing the field
|
|
22
|
+
* (`QgsRelationReferenceWidgetWrapper::initWidget`,
|
|
23
|
+
* `src/gui/editorwidgets/qgsrelationreferencewidgetwrapper.cpp`,
|
|
24
|
+
* `qgis/QGIS@release-3_40`). Undefined where no such relation exists.
|
|
25
|
+
*/
|
|
26
|
+
export function findRelationReferenceRelation(layerId, field, widget, relations, layersById) {
|
|
27
|
+
const joining = relations.filter((relation) => (relation.childLayerId === layerId &&
|
|
28
|
+
isRelationInProject(relation, layersById) &&
|
|
29
|
+
relation.fieldPairs.some((pair) => pair.childField === field)));
|
|
30
|
+
return joining.find((relation) => relation.id === widget.relationId) ?? joining[0];
|
|
31
|
+
}
|
|
17
32
|
/** Whether the project holds both of a relation's layers. */
|
|
18
33
|
export function isRelationInProject(relation, layersById) {
|
|
19
34
|
return layersById.has(relation.parentLayerId) && layersById.has(relation.childLayerId);
|
|
@@ -24,8 +39,9 @@ export function isFilterInProject(filter, layersById) {
|
|
|
24
39
|
}
|
|
25
40
|
/**
|
|
26
41
|
* The notes for the settings that name another layer and do not reach the
|
|
27
|
-
* catalogue: Value Relations, relations and filters, in
|
|
28
|
-
* in the project's order.
|
|
42
|
+
* catalogue: Value Relations, Relation References, relations and filters, in
|
|
43
|
+
* that order, and each in the project's order. A Relation Reference with no
|
|
44
|
+
* relation is noted as a widget left out, as the catalogue records it. `textFilters` are the Mergin Maps `Text` filters
|
|
29
45
|
* `parseMerginFilters` passes over.
|
|
30
46
|
*/
|
|
31
47
|
export function crossLayerNotes(layers, relations, filters, textFilters) {
|
|
@@ -38,6 +54,12 @@ export function crossLayerNotes(layers, relations, filters, textFilters) {
|
|
|
38
54
|
notes.push(noteFor(layer.id, field, 'value-relation', widget.layerName || widget.layerId));
|
|
39
55
|
}
|
|
40
56
|
}
|
|
57
|
+
for (const layer of layers) {
|
|
58
|
+
for (const [field, widget] of Object.entries(layer.fieldRelationReferences ?? {})) {
|
|
59
|
+
if (!findRelationReferenceRelation(layer.id, field, widget, relations, layersById))
|
|
60
|
+
notes.push(noteFor(layer.id, field, 'widget', 'RelationReference'));
|
|
61
|
+
}
|
|
62
|
+
}
|
|
41
63
|
for (const relation of relations) {
|
|
42
64
|
if (!isRelationInProject(relation, layersById))
|
|
43
65
|
notes.push(noteFor(relation.childLayerId, null, 'relation', relation.name || relation.id));
|
package/package.json
CHANGED
|
@@ -758,6 +758,9 @@
|
|
|
758
758
|
"quac:value_relation": {
|
|
759
759
|
"$ref": "#/definitions/value_relation"
|
|
760
760
|
},
|
|
761
|
+
"quac:relation_reference": {
|
|
762
|
+
"$ref": "#/definitions/relation_reference"
|
|
763
|
+
},
|
|
761
764
|
"quac:attachment": {
|
|
762
765
|
"$ref": "#/definitions/attachment"
|
|
763
766
|
}
|
|
@@ -990,6 +993,29 @@
|
|
|
990
993
|
},
|
|
991
994
|
"additionalProperties": false
|
|
992
995
|
},
|
|
996
|
+
"relation_reference": {
|
|
997
|
+
"description": "The field is filled by picking a feature of the parent Collection under one of this Collection's relations. Written from a QGIS Relation Reference widget.",
|
|
998
|
+
"type": "object",
|
|
999
|
+
"required": [
|
|
1000
|
+
"relation"
|
|
1001
|
+
],
|
|
1002
|
+
"properties": {
|
|
1003
|
+
"relation": {
|
|
1004
|
+
"description": "The id of the relation, among this Collection's quac:related_to.",
|
|
1005
|
+
"type": "string",
|
|
1006
|
+
"minLength": 1
|
|
1007
|
+
},
|
|
1008
|
+
"allow_null": {
|
|
1009
|
+
"const": true,
|
|
1010
|
+
"description": "The field may be left without a parent."
|
|
1011
|
+
},
|
|
1012
|
+
"filter": {
|
|
1013
|
+
"type": "string",
|
|
1014
|
+
"description": "A QGIS expression narrowing the parent's features."
|
|
1015
|
+
}
|
|
1016
|
+
},
|
|
1017
|
+
"additionalProperties": false
|
|
1018
|
+
},
|
|
993
1019
|
"value_relation": {
|
|
994
1020
|
"description": "The field's choices are the records of another Collection in the same catalogue. Written from a QGIS Value Relation widget.",
|
|
995
1021
|
"type": "object",
|