Skip to content

Commit

Permalink
Merge branch 'GEOLYTIX:main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
cityremade authored Dec 18, 2024
2 parents 4837f68 + 2e53367 commit 7162da2
Show file tree
Hide file tree
Showing 6 changed files with 80 additions and 9 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
**v4.12.5**
**v4.12.6**

[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
![Codi Unit Tests](https://github.com/GEOLYTIX/xyz/actions/workflows/unit_tests.yml/badge.svg)
Expand Down
4 changes: 2 additions & 2 deletions lib/mapp.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,9 @@ if (window.ol === undefined) {
self.mapp = {
ol: _ol,

version: '4.12.5',
version: '4.12.6',

hash: '1864433eca14f8d6ff5fe643b99373ed5c6bb2e2',
hash: 'e19adad70af7047ccebda80df4825e8e408c0d91',

host: document.head?.dataset?.dir || '',

Expand Down
4 changes: 4 additions & 0 deletions lib/ui/locations/infoj.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ export default function infoj(location, infoj_order) {
// Create object to hold view groups.
groups = {}


// The infoj_order may be assigned to the layer.
infoj_order ??= location?.layer?.infoj_order

// infoj argument is provided as an array of strings to filter the location infoj entries.
const infoj = Array.isArray(infoj_order) ?
infoj_order
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "xyz",
"version": "v4.12.5",
"version": "v4.12.6",
"repository": {
"type": "git",
"url": "https://github.com/geolytix/xyz"
Expand Down
5 changes: 2 additions & 3 deletions public/tests/_base.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -445,6 +445,7 @@ export async function base() {
target: OL,
locale: locale,
hooks: false,
loadPlugins: true,
scrollWheelZoom: true,
attribution: {
target: document.getElementById('Map'),
Expand All @@ -456,9 +457,7 @@ export async function base() {
['SHA']: `https://github.com/GEOLYTIX/xyz/commit/${mapp.hash}`,
Openlayers: 'https://openlayers.org',
}
},
syncPlugins: locale.syncPlugins,
svgTemplates: locale.svg_templates
}
});


Expand Down
72 changes: 70 additions & 2 deletions tests/lib/ui/locations/infoj.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@ export function infojTest() {
/**
* ### It should create an infoj with a correct order
* 1. We define an infoj with a combination of different entries with keys, fields and queries
* 2. We assert against the order
* 2. We assert against the order when calling the infoj method
* 3. We assert against the order when calling the infoj method with a different order as defined in the layer
* @function it
*/
codi.it('It should create an infoj with certain order', () => {
codi.it('It should create an infoj with certain order as specified directly to the method', () => {

const location = {
infoj: [
Expand Down Expand Up @@ -74,5 +75,72 @@ export function infojTest() {
codi.assertEqual(results, expected, 'The infoj order needs to be as defined in the expected');

});

codi.it('It should create an infoj with certain order as defined on the layer', () => {

const location = {
infoj: [
{
field: 'field_1',
key: 'key_1',
label: 'test_1',
value: 'test 1 value'
},
{
field: 'field_2',
label: 'test_2',
value: 'value_2'
},
{
field: 'field_3',
label: 'test_3',
value: 'value_3'
},
{
key: 'key_4',
value: 'value_4'
},
{
query: 'query_5',
value: 'value_5',
location: {}
}
]
};

// Set the order on the layer
location.layer = {};
location.layer.infoj_order = [
'_field_1',
'field_2',
'field_3',
'key_4',
'query_5',
{
field: 'field6',
value: 'value_6'
}
];

// Get listview element from the infoj object
const infoj = mapp.ui.locations.infoj(location);

// Get textvalues from location listview elements.
const results = Array.from(infoj.children)
.map(el => el.firstChild.innerText.trim())

// Expected results
const expected = [
'value_2',
'value_3',
'value_4',
'value_5',
'value_6'
];

// Asserting we get the expected results and order
codi.assertEqual(results, expected, 'The infoj order needs to be as defined in the expected');

});
});
}

0 comments on commit 7162da2

Please sign in to comment.