Skip to content

Commit

Permalink
fix(bugs): wrong basemap when switch proj/lang, long field name BC WM… (
Browse files Browse the repository at this point in the history
#2575)

* fix(bugs): wrong basemap when switch proj/lang, long field name BC WMS, delete not working when switching action
Closes #2571, #2538, #2573

* fix typo
  • Loading branch information
jolevesq authored Nov 1, 2024
1 parent ff4d89a commit 13a555b
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ export class MapEventProcessor extends AbstractEventProcessor {
}

static getBasemapOptions(mapId: string): TypeBasemapOptions {
return this.getMapStateProtected(mapId).basemapOptions;
return this.getMapStateProtected(mapId).currentBasemapOptions || this.getMapStateProtected(mapId).basemapOptions;
}

static getCurrentBasemapOptions(mapId: string): TypeBasemapOptions {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,23 +103,25 @@ export default function DataTableModal(): JSX.Element {
const columnList = [] as MRTColumnDef<ColumnsType>[];

entries.forEach(([key, value]) => {
columnList.push({
id: key,
accessorFn: (row) => {
// check if row is valid react element.
if (isValidElement(row[key])) {
return row[key];
}
if (typeof row[key]?.value === 'string' || typeof row[key]?.value === 'number') {
return row[key]?.value ?? '';
}
return '';
},
header: value?.alias ?? '',
Cell: ({ cell }) => getCellValue(cell.getValue() as string),
Header: ({ column }) => getTableHeader(column.columnDef.header),
maxSize: 120,
});
// Do not show internal geoviewID field
if (value?.alias !== 'geoviewID')
columnList.push({
id: key,
accessorFn: (row) => {
// check if row is valid react element.
if (isValidElement(row[key])) {
return row[key];
}
if (typeof row[key]?.value === 'string' || typeof row[key]?.value === 'number') {
return row[key]?.value ?? '';
}
return '';
},
header: value?.alias ?? '',
Cell: ({ cell }) => getCellValue(cell.getValue() as string),
Header: ({ column }) => getTableHeader(column.columnDef.header),
maxSize: 120,
});
});

return columnList;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export default function FeatureDetailModal(): JSX.Element {
const nameFieldValueTmp = feature.fieldInfo[feature.nameField !== null ? feature.nameField : 0];
setNameFieldValue(nameFieldValueTmp !== undefined ? (nameFieldValueTmp.value as string) : '');

return Object.keys(feature?.fieldInfo ?? {}).map((fieldName) => {
const featureInfo = Object.keys(feature?.fieldInfo ?? {}).map((fieldName) => {
return {
fieldKey: feature.fieldInfo[fieldName]!.fieldKey,
value: feature.fieldInfo[fieldName]!.value,
Expand All @@ -49,6 +49,11 @@ export default function FeatureDetailModal(): JSX.Element {
domain: null,
};
});

// Remove last item who is the geoviewID
featureInfo.pop();

return featureInfo;
}, [feature]);

return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,20 @@ export function FeatureInfo({ features, currentFeatureIndex }: TypeFeatureInfoPr
logger.logTraceUseMemo('DETAILS PANEL - Feature Info new - featureInfoList');

const featureInfo = Object.keys(feature?.fieldInfo ?? {}).map((fieldName) => {
// We have few service WMS from BC where fields name are extremely long and separated by .
// for WMS and WFS we should only keep the last item. If we see this with other type of services,
// we may need to remove the check and apply all the time.
// TODO: should we do this at the root when sourceinfo is define?
const alias =
feature.geoviewLayerType !== 'ogcWms' && feature.geoviewLayerType !== 'ogcWfs'
? feature.fieldInfo[fieldName]?.alias || fieldName
: (feature.fieldInfo[fieldName]?.alias || fieldName).split('.').pop() || '';

return {
fieldKey: feature.fieldInfo[fieldName]!.fieldKey,
value: feature.fieldInfo[fieldName]!.value,
dataType: feature.fieldInfo[fieldName]!.dataType,
alias: feature.fieldInfo[fieldName]!.alias ? feature.fieldInfo[fieldName]!.alias : fieldName,
alias,
domain: null,
};
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,16 @@ export function DeleteUndoButton(props: DeleteUndoButtonProps): JSX.Element {
}
};

// Make sure there is no pending state on unmount. If not, it can stay in progress forever...
// If user switch panel when action is in progress
useEffect(() => {
return () => {
setInUndoState(false);
setLayerDeleteInProgress(false);
};
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);

useEffect(() => {
if (progress === 100) {
deleteLayer(layer.layerPath);
Expand Down
3 changes: 2 additions & 1 deletion packages/geoview-core/src/core/utils/date-mgt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -718,7 +718,8 @@ export abstract class DateMgt {
* @returns {string} The date format.
*/
static deduceDateFormat(dateString: string): string {
let dateFormat = dateString !== null ? dateString.toUpperCase().replaceAll('/', '-').replaceAll(' ', 'T') : 'YYYY-MM-DD';
let dateFormat =
dateString !== null && dateString !== undefined ? dateString.toUpperCase().replaceAll('/', '-').replaceAll(' ', 'T') : 'YYYY-MM-DD';
dateFormat = dateFormat
.replace(/\d{4}/, 'YYYY')
.replace(/^\d{1,2}(?=-\d{1,2}-YYYY)|((?<=^YYYY-\d-)|(?<=^YYYY-\d\d-))\d{1,2}/, 'DD')
Expand Down

0 comments on commit 13a555b

Please sign in to comment.