Skip to content

Commit

Permalink
Fix for the config > metadata rule
Browse files Browse the repository at this point in the history
Better legends-layer-set.ts vs store sync
  • Loading branch information
Alex-NRCan committed May 25, 2024
1 parent 9713288 commit c929e71
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -112,12 +112,20 @@ export function commonValidateListOfLayerEntryConfig(
const newListOfLayerEntryConfig: TypeLayerEntryConfig[] = [];
const switchToGroupLayer = Cast<GroupLayerEntryConfig>(cloneDeep(layerConfig));
switchToGroupLayer.entryType = CONST_LAYER_ENTRY_TYPES.GROUP;
switchToGroupLayer.layerName = {
en: layer.metadata!.layers[esriIndex].name as string,
fr: layer.metadata!.layers[esriIndex].name as string,
};

// Only switch the layer name by the metadata if there were none pre-set (config wins over metadata rule?)
if (!switchToGroupLayer.layerName) {
switchToGroupLayer.layerName = {
en: layer.metadata!.layers[esriIndex].name as string,
fr: layer.metadata!.layers[esriIndex].name as string,
};
} else {
if (!switchToGroupLayer.layerName.en) switchToGroupLayer.layerName.en = layer.metadata!.layers[esriIndex].name as string;
if (!switchToGroupLayer.layerName.fr) switchToGroupLayer.layerName.fr = layer.metadata!.layers[esriIndex].name as string;
}
switchToGroupLayer.isMetadataLayerGroup = true;
switchToGroupLayer.listOfLayerEntryConfig = newListOfLayerEntryConfig;

const groupLayerConfig = new GroupLayerEntryConfig(switchToGroupLayer as GroupLayerEntryConfig);
// Replace the old version of the layer with the new layer group
listOfLayerEntryConfig[i] = groupLayerConfig;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ export abstract class AbstractLayerSet {
// Override this function to perform further registration logic in the inherited classes
this.resultSet[layerConfig.layerPath] = {
data: undefined,
layerStatus: 'newInstance',
layerStatus: layerConfig.layerStatus,
layerName: getLocalizedValue(layerConfig.layerName, AppEventProcessor.getDisplayLanguage(this.mapId)),
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ export class LegendsLayerSet extends AbstractLayerSet {
// Call parent
super.onRegisterLayer(layerConfig);

// Leaving this here for now, likely can be refactored later
this.resultSet[layerConfig.layerPath].data = undefined;
// Propagate to store immediately
LegendEventProcessor.propagateLegendToStore(this.mapId, layerConfig.layerPath, this.resultSet[layerConfig.layerPath]);
}

/**
Expand Down

0 comments on commit c929e71

Please sign in to comment.