Skip to content

Commit

Permalink
fix(details): Display detail fields when service returns alias instea…
Browse files Browse the repository at this point in the history
…d of field name (Canadian-Geospatial-Platform#2658)

Fixes some of Canadian-Geospatial-Platform#2596, info is displayed properly, but icons are not fixed.
  • Loading branch information
DamonU2 authored Dec 13, 2024
1 parent dfdadc5 commit 0041cbf
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -579,11 +579,14 @@ export abstract class AbstractGVLayer extends AbstractBaseLayer {
dictFieldTypes[fieldName] = this.getFieldType(fieldName);
}
const fieldType = dictFieldTypes[fieldName];
const fieldEntry = outfields?.find((outfield) => outfield.name === fieldName);
const fieldEntry = outfields?.find((outfield) => outfield.name === fieldName || outfield.alias === fieldName);
if (fieldEntry) {
featureInfoEntry.fieldInfo[fieldName] = {
featureInfoEntry.fieldInfo[fieldEntry.name] = {
fieldKey: fieldKeyCounter++,
value: this.getFieldValue(feature, fieldName, fieldEntry!.type as 'string' | 'number' | 'date'),
value:
// If fieldName is the alias for the entry, we will not get a value, so we try the fieldEntry name.
this.getFieldValue(feature, fieldName, fieldEntry!.type as 'string' | 'number' | 'date') ||
this.getFieldValue(feature, fieldEntry.name, fieldEntry!.type as 'string' | 'number' | 'date'),
dataType: fieldEntry!.type,
alias: fieldEntry!.alias,
domain: fieldDomain,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,7 @@ export class GVEsriDynamic extends AbstractGVRaster {
logger.logInfo('There is a problem with this query: ', identifyUrl);
throw new Error(`Error code = ${jsonResponse.error.code} ${jsonResponse.error.message}` || '');
}

const features = new EsriJSON().readFeatures(
{ features: jsonResponse.results },
{ dataProjection: Projection.PROJECTION_NAMES.LNGLAT, featureProjection: mapViewer.getProjection().getCode() }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1260,7 +1260,7 @@ function searchUniqueValueEntry(fields: string[], uniqueValueStyleInfo: TypeLaye
// For obscure reasons, it seems that sometimes the field names in the feature do not have the same case as those in the
// unique value definition.
const fieldName = feature.getKeys().find((key) => {
return key.toLowerCase() === fields?.[j]?.toLowerCase();
return key.toLowerCase() === fields[j]?.toLowerCase();
});
if (fieldName) {
// TODO: info - explain why we need to use == instead of ===
Expand Down

0 comments on commit 0041cbf

Please sign in to comment.