terriajs
terriajs copied to clipboard
Add `GroupTraits` like `excludeMembers` to `TerriaReference`
A TerriaReference type is often used to reference catalogue from other sources. Sometimes it is desired to exclude some items from the referenced catalogue. The current code only allows for item inclusion but not exclusion.
@mwu2018 - Maybe you have already figured it but one way to do this might be to implement an override trait similar to MagdaReference
and use it to override the excludeMembers trait for the target group.
@na9da Using override
trait may not work because that property can not be passed down to the nested groups. Instead, I will use itemPropertiesByType
like this:
{
"catalog": [
{
"isGroup": true,
"name": "National Datasets",
"path": ["Root Group/National Data Sets"],
"itemPropertiesByType": [
{
"type": "terria-reference",
"itemProperties": {
"excludeMembers": [
"X8HQPf",
"yrTH6i"
]
}
}
],
"url": "https://terria-catalogs-public.storage.googleapis.com/nationalmap/prod.json",
"id": "national-datasets",
"type": "terria-reference"
}
]
}
Current work-around
Hi @mwu2018,
Good thinking on using
itemPropertiesByType
instead of my previous suggestion on the issue.However, I think I can get it to work without the change in this PR using a definition like below - please let me know if I'm missing something. Here is a working example using the
main
branch.{ "catalog": [ { "type": "terria-reference", "name": "natmap", "isGroup": true, "url": "https://terria-catalogs-public.storage.googleapis.com/nationalmap/prod.json", "itemPropertiesByType": [ { "type": "group", "itemProperties": { "excludeMembers": ["X8HQPf", "yrTH6i"] } } ] } ] }
Let me know if that works for your use-case.
Originally posted by @na9da in https://github.com/TerriaJS/terriajs/issues/6839#issuecomment-1687543793