terriajs icon indicating copy to clipboard operation
terriajs copied to clipboard

Add `GroupTraits` like `excludeMembers` to `TerriaReference`

Open mwu2018 opened this issue 1 year ago • 4 comments

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 avatar Aug 07 '23 23:08 mwu2018

@mwu2018 - Maybe you have already figured it but one way to do this might be to implement an override trait similar to MagdaReferenceand use it to override the excludeMembers trait for the target group.

na9da avatar Aug 08 '23 02:08 na9da

Example.

na9da avatar Aug 08 '23 02:08 na9da

@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"
    }
  ]
}

mwu2018 avatar Aug 08 '23 03:08 mwu2018

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

nf-s avatar Sep 07 '23 02:09 nf-s