GEOLYTIX / xyz

An open source javascript framework for spatial data and application interfaces.
MIT License
87 stars 25 forks source link

infoj_order mode #1252

Closed dbauszus-glx closed 1 month ago

dbauszus-glx commented 1 month ago

The infoj method has a second infoj_order argument. This argument can be an array of keys and entry objects.

layer.infoj entries will be filtered in the order of keys. It is checked whether the key matches the entry's key, field, query, or group key value.

The key key value is specifically used as an identifier for entries and serves no other purpose.

The infoj_order argument can be a mix of entry objects and keys. Entry object are directly spliced into the infoj array and don't require to be in the layer.infoj array.

The infoj_order can be defined as an array in the layer json. The infoj_order plugin will be retired in favour of this.


cityremade commented 1 month ago

when including a dataview object in the order I see the following error: infoj.mjs:130 Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'layer') at line 130 in infoj.mjs: entry.location.layer.queryparams || {} Entry in the order array doesn't inherit properties when they are referenced.

dbauszus-glx commented 1 month ago

@KieronFerrey group won't work since the values are not unique. tyoe won't work neither for the same reason. we need to remove the group key since sorting requires a unique identifier.

simon-leech commented 1 month ago

I just pushed a commit to this PR after chatting to @RobAndrewHurst. This PR simply console warns the developer if a value provided in infoj_order array does not exist in the location.infoj. This is required to ensure that the developer added a unique identifier to plugin entries or other entries that may not be unique.

dbauszus-glx commented 1 month ago

I have removed group from the infoj_order lookup since this is by definition not unique.

simon-leech commented 1 month ago

I just pushed a check on the mapview and locale - as is custom views called entries may not have a locale

// Assign queryparams from layer, and locale.
  entry.queryparams = Object.assign(
    entry.queryparams || {},
    entry.location.layer.queryparams || {},
    entry.location.layer?.mapview?.locale?.queryparams || {})
sonarcloud[bot] commented 1 month ago

Quality Gate Passed Quality Gate passed

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
0.0% Duplication on New Code

See analysis details on SonarCloud

dbauszus-glx commented 1 month ago

@simon-leech Can you test whether this works using the spread operator?

image

Aren't the locale queryparams already assigned to the layer somewhere else?

simon-leech commented 1 month ago

@dbauszus-glx Yeah all seems to be working for me :)

dbauszus-glx commented 1 month ago

https://github.com/GEOLYTIX/xyz/wiki/Workspace-Configuration#infoj_order