Skip to content

Commit c4a22d6

Browse files
committed
#643 InfoTool with one-to-many Datasets
1 parent ccd4c7f commit c4a22d6

File tree

10 files changed

+338
-200
lines changed

10 files changed

+338
-200
lines changed

configure/src/metaconfigs/layer-model-config.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -835,6 +835,13 @@
835835
"description": "This is a property key already within the features properties. It's value will be searched for in the specified dataset column.",
836836
"type": "text",
837837
"width": 3
838+
},
839+
{
840+
"field": "displayProp",
841+
"name": "Connecting Feature Display Name Property",
842+
"description": "This is a property key within the returned dataset feature properties. This is effectively an optional second-order property key. In the case of multiple dataset row entries being returned, this is useful for users of the UI to be able to distinguish between them. If unset, defaults to the value of 'Connecting Feature Property'.",
843+
"type": "text",
844+
"width": 3
838845
}
839846
]
840847
}

configure/src/metaconfigs/layer-query-config.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -984,6 +984,13 @@
984984
"description": "This is a property key already within the features properties. It's value will be searched for in the specified dataset column.",
985985
"type": "text",
986986
"width": 3
987+
},
988+
{
989+
"field": "displayProp",
990+
"name": "Connecting Feature Display Name Property",
991+
"description": "This is a property key within the returned dataset feature properties. This is effectively an optional second-order property key. In the case of multiple dataset row entries being returned, this is useful for users of the UI to be able to distinguish between them. If unset, defaults to the value of 'Connecting Feature Property'.",
992+
"type": "text",
993+
"width": 3
987994
}
988995
]
989996
}

configure/src/metaconfigs/layer-vector-config.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -931,6 +931,13 @@
931931
"description": "This is a property key already within the features properties. It's value will be searched for in the specified dataset column.",
932932
"type": "text",
933933
"width": 3
934+
},
935+
{
936+
"field": "displayProp",
937+
"name": "Connecting Feature Display Name Property",
938+
"description": "This is a property key within the returned dataset feature properties. This is effectively an optional second-order property key. In the case of multiple dataset row entries being returned, this is useful for users of the UI to be able to distinguish between them. If unset, defaults to the value of 'Connecting Feature Property'.",
939+
"type": "text",
940+
"width": 3
934941
}
935942
]
936943
}

configure/src/metaconfigs/layer-vectortile-config.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -892,6 +892,13 @@
892892
"description": "This is a property key already within the features properties. It's value will be searched for in the specified dataset column.",
893893
"type": "text",
894894
"width": 3
895+
},
896+
{
897+
"field": "displayProp",
898+
"name": "Connecting Feature Display Name Property",
899+
"description": "This is a property key within the returned dataset feature properties. This is effectively an optional second-order property key. In the case of multiple dataset row entries being returned, this is useful for users of the UI to be able to distinguish between them. If unset, defaults to the value of 'Connecting Feature Property'.",
900+
"type": "text",
901+
"width": 3
895902
}
896903
]
897904
}

src/essence/Ancillary/Datasets.js

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
import F_ from '../Basics/Formulae_/Formulae_'
2+
import calls from '../../pre/calls'
3+
4+
const Datasets = {
5+
populateFromDataset(layer, cb) {
6+
if (
7+
layer.options.layerName &&
8+
L_.layers.data[layer.options.layerName] &&
9+
L_.layers.data[layer.options.layerName].variables &&
10+
L_.layers.data[layer.options.layerName].variables.datasetLinks
11+
) {
12+
const dl =
13+
L_.layers.data[layer.options.layerName].variables.datasetLinks
14+
let dlFilled = dl
15+
for (let i = 0; i < dlFilled.length; i++) {
16+
dlFilled[i].search = F_.getIn(
17+
layer.feature.properties,
18+
dlFilled[i].prop.split('.')
19+
)
20+
}
21+
22+
calls.api(
23+
'datasets_get',
24+
{
25+
queries: JSON.stringify(dlFilled),
26+
},
27+
function (data) {
28+
const d = data.body
29+
for (let i = 0; i < d.length; i++) {
30+
if (d[i].type == 'images') {
31+
layer.feature.properties.images =
32+
layer.feature.properties.images || []
33+
for (let j = 0; j < d[i].results.length; j++) {
34+
layer.feature.properties.images.push(
35+
d[i].results[j]
36+
)
37+
}
38+
//remove duplicates
39+
layer.feature.properties.images =
40+
F_.removeDuplicatesInArrayOfObjects(
41+
layer.feature.properties.images
42+
)
43+
} else {
44+
layer.feature.properties._dataset = {
45+
prop: dlFilled[i].displayProp || d[i].prop,
46+
results: d[i].results,
47+
}
48+
}
49+
}
50+
if (cb != null && typeof cb === 'function') cb()
51+
},
52+
function (data) {
53+
if (cb != null && typeof cb === 'function') cb()
54+
}
55+
)
56+
} else {
57+
if (cb != null && typeof cb === 'function') cb()
58+
}
59+
},
60+
}
61+
62+
export default Datasets

src/essence/Basics/Layers_/Layers_.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2054,6 +2054,8 @@ const L_ = {
20542054
const featureWithout_ = JSON.parse(JSON.stringify(f))
20552055
if (featureWithout_.properties?._ != null)
20562056
delete featureWithout_.properties._
2057+
if (featureWithout_.properties?._dataset != null)
2058+
delete featureWithout_.properties._dataset
20572059

20582060
for (let i = 0; i < layerKeys.length; i++) {
20592061
const l = layerKeys[i]

0 commit comments

Comments
 (0)