Esri / arcgis-python-api

Documentation and samples for ArcGIS API for Python
https://developers.arcgis.com/python/
Apache License 2.0
1.87k stars 1.1k forks source link

configure_pop_ups() to turn on/off field visibility does not work if you have set popupElements in the JSON #1740

Open Clubdebambos opened 8 months ago

Clubdebambos commented 8 months ago

Describe the bug Using the configure_pop_ups() method to turn on/off field visibility in a popup does not work if you have set fieldInfos in the popupElements in the JSON.

To Reproduce Steps to reproduce the behavior: The current JSON

"popupInfo": {
    "popupElements": [
      {
        "type": "fields",
        "description": "...and a description here.",
        "fieldInfos": [
          {
            "fieldName": "FID",
            "isEditable": false,
            "label": "FID",
            "visible": true
          },
          {
            "fieldName": "REG_NO",
            "isEditable": false,
            "label": "Registered Number",
            "visible": true
          }
        ],
        "title": "We added a title here..."
      },
      {
        "type": "relationship",
        "description": "Click the related record to see more information.",
        "displayCount": 1,
        "displayType": "list",
        "orderByFields": [
          {
            "field": "REG_NO",
            "order": "asc"
          }
        ],
        "relationshipId": 0,
        "title": "NIAH Information"
      }
    ],
    "relatedRecordsInfo": {
      "showRelatedRecords": true,
      "orderByFields": [
        {
          "field": "relationships/0/REG_NO",
          "order": "asc"
        }
      ]
    },
    "fieldInfos": [
      {
        "fieldName": "FID",
        "isEditable": false,
        "label": "FID",
        "visible": true
      },
      {
        "fieldName": "REG_NO",
        "isEditable": false,
        "label": "Registered Number",
        "visible": true
      }
    ],
    "title": "National Inventory of Architectural Heritage"
  }

Turn off visibility for FID

from arcgis.gis import GIS
from arcgis.mapping import WebMap

## Access AGOL
agol = GIS("home")

## Access the WebMap Item
wm_item = agol.content.get("WM_ITEM_ID")

## Create a WebMap object from WebMp Item
webmap = WebMap(wm_item)

## turn
field_names = ["FID"]

webmap.configure_pop_ups("NIAH Locations", field_names, False)

webmap.update()

Check the updated JSON

"popupInfo": {
    "popupElements": [
      {
        "type": "fields",
        "description": "...and a description here.",
        "fieldInfos": [
          {
            "fieldName": "FID",
            "isEditable": false,
            "label": "FID",
            "visible": true
          },
          {
            "fieldName": "REG_NO",
            "isEditable": false,
            "label": "Registered Number",
            "visible": true
          }
        ],
        "title": "We added a title here..."
      },
      {
        "type": "relationship",
        "description": "Click the related record to see more information.",
        "displayCount": 1,
        "displayType": "list",
        "orderByFields": [
          {
            "field": "REG_NO",
            "order": "asc"
          }
        ],
        "relationshipId": 0,
        "title": "NIAH Information"
      }
    ],
    "relatedRecordsInfo": {
      "showRelatedRecords": true,
      "orderByFields": [
        {
          "field": "relationships/0/REG_NO",
          "order": "asc"
        }
      ]
    },
    "fieldInfos": [
      {
        "fieldName": "FID",
        "isEditable": false,
        "label": "FID",
        "visible": false
      },
      {
        "fieldName": "REG_NO",
        "isEditable": false,
        "label": "Registered Number",
        "visible": true
      }
    ],
    "title": "National Inventory of Architectural Heritage"
  }

error: Notice that the fieldInfos towards the bottom of the JSON updated for the FID visibility to false but not in the popupElements. The FID field remains visible in the Popup. Also tried with other fields and other layers but all had the same outcome. The only way the configure_pop_ups() method works is if there are no fieldInfos in the popupElements.

Screenshots If applicable, add screenshots to help explain your problem.

Expected behavior The FID field / fields entered into the configure_pop_ups() method should be turned on/off

Platform (please complete the following information):

Additional context Add any other context about the problem here, attachments etc.

nanaeaubry commented 8 months ago

@Clubdebambos Thank you for reporting this! We will work on fixing it and post any updates here