Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion plugins/datasets/src/adapters/esri/esriLayerAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ import { logger } from '../../../../../src/services/logger.js'
export default class EsriLayerAdapter extends LayerAdapter {
constructor (mapProvider) {
super()
this.ready = new Promise((resolve) => {
this.resolveReady = resolve
})
this._mapProvider = mapProvider
this._map = mapProvider.map

Expand Down Expand Up @@ -46,6 +49,7 @@ export default class EsriLayerAdapter extends LayerAdapter {

// Finally show all layers that are visible based on the dataset/mapStyle visibility
await Promise.all(topLevelDatasets.map(registryDataset => this.applyDatasetVisibility(registryDataset.id)))
this.resolveReady()
}

_addGroupLayer (esriGroupId) {
Expand Down Expand Up @@ -199,7 +203,9 @@ export default class EsriLayerAdapter extends LayerAdapter {
if (!esriStyleLayerId || !vectorTileLayer) {
return
}
vectorTileLayer.setStyleLayerVisibility(esriStyleLayerId, registryDataset.visibility)
this.ready.then(() => {
vectorTileLayer.setStyleLayerVisibility(esriStyleLayerId, registryDataset.visibility)
})
}

_applyStyleLayerPaintProperties (registryDataset, vectorTileLayer) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ describe('esriLayerAdapter', () => {
map = makeMap()
mapProvider = makeMapProvider(map)
adapter = new EsriLayerAdapter(mapProvider, null, null)
adapter.resolveReady()
})

// ─── createDataset ───────────────────────────────────────────────────────────
Expand Down
3 changes: 3 additions & 0 deletions plugins/datasets/src/components/LayersMenu/Layers.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,9 @@
font-size: 1rem;
font-weight: bold;
color: var(--foreground-color);
h3 {
font-size: inherit;
}
}

.im-c-datasets-layers-group:first-child .im-c-datasets-layers-group__legend {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ export const LayersMenuGroupWrapper = ({ menuGroup, children }) => {
<div key={menuGroup.id} className={wrapperClass}>
<fieldset className='im-c-datasets-layers-group__fieldset'>
<legend className='im-c-datasets-layers-group__legend'>
{menuGroup.groupLabel}
<h3>
{menuGroup.groupLabel}
</h3>
</legend>
{children}
</fieldset>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ export const LayersRadioGroupWrapper = ({ pluginState, menuGroup }) => {
<div key={menuGroup.id} className={wrapperClass}>
<fieldset className='im-c-datasets-layers-group__fieldset'>
<legend className='im-c-datasets-layers-group__legend'>
{menuGroup.label}
<h3>
{menuGroup.label}
</h3>
</legend>
<div className='govuk-radios govuk-radios--small' data-module='govuk-radios'>
{items.map((menuGroupItem) =>
Expand Down
4 changes: 2 additions & 2 deletions plugins/datasets/src/initialise/initialiseDatasets.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ export const initialiseDatasets = ({
datasetRegistry.attach(mappedDatasets, orderedDatasets, mapStyle)
const menu = pluginConfig.menu || datasetsToMenu({ datasets: processedDatasets })
setMenuState(buildMenuState(menu)) // Must be called before adapter.init so that menuState is set before any datasets are checked for visibility
dispatch({ type: 'SET_MENU', payload: { menu } })
dispatch({ type: 'SET_DATASETS', payload: { mappedDatasets, orderedDatasets } })

adapter.init().then(() => {
datasetRegistry.forEachDataset(registryDataset => {
Expand All @@ -48,8 +50,6 @@ export const initialiseDatasets = ({
})
adapter.attachDynamicSources(dynamicSources)
// TODO - apply dynamic source defaults here, and include in mappedDatasets
dispatch({ type: 'SET_MENU', payload: { menu } })
dispatch({ type: 'SET_DATASETS', payload: { datasets: processedDatasets, mappedDatasets, orderedDatasets } })
eventBus.emit('datasets:ready')
})

Expand Down
2 changes: 2 additions & 0 deletions plugins/datasets/src/reducers/pluginState.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ const initialState = {
items: [],
hasGroups: false
},
mappedDatasets: {},
orderedDatasets: [],
actionsArray: [],
menu: [],
menuState: {}
Expand Down
2 changes: 1 addition & 1 deletion plugins/datasets/src/registry/datasetRegistry.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ const datasetRegistry = {
type: 'group',
groupLabel: dataset.groupLabel,
datasets: this.topLevelDatasets()
.filter(groupDataset => (groupDataset.groupLabel === dataset.groupLabel && !groupDataset.hasSublayers && groupDataset.showInKey))
.filter(groupDataset => (groupDataset.groupLabel === dataset.groupLabel && !groupDataset.hasSublayers && groupDataset.keyVisibility))
})
} else {
items.push({ type: 'flat', dataset })
Expand Down
Loading