Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Psp 9940 - correct issue with map display when jumping to boundaries #4648

Merged
merged 3 commits into from
Feb 11, 2025
Merged
Show file tree
Hide file tree
Changes from 2 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
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ const featureViewStates = {
SET_FILE_PROPERTY_LOCATIONS: {
actions: [
assign({ filePropertyLocations: (_, event: any) => event.locations }),
raise('REQUEST_FIT_BOUNDS'),
raise('REQUEST_FIT_FILE_BOUNDS'),
],
},
},
Expand All @@ -62,7 +62,7 @@ const featureViewStates = {
SET_FILE_PROPERTY_LOCATIONS: {
actions: [
assign({ filePropertyLocations: (_, event: any) => event.locations }),
raise('REQUEST_FIT_BOUNDS'),
raise('REQUEST_FIT_FILE_BOUNDS'),
],
},
},
Expand Down Expand Up @@ -168,9 +168,7 @@ const mapRequestStates = {
context?.mapFeatureData?.pimsLocationFeatures?.features ?? [];

// business logic, if there are file properties, use those, otherwise, zoom to a single feature if there is only one, or all features if there are more than one.
if (context.filePropertyLocations.length > 0) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unfortunately this logic doesn't work - as this method has no context who called it. As a result, efforts to send a fileProperties of [], result in the else clause of this function to be executed.

suggested solution - keep the file boundary logic separate from the map load/ map search logic.

return latLngBounds(context.filePropertyLocations);
} else if (pimsLocationFeatures.length + fullyAttributedFeatures.length === 1) {
if (pimsLocationFeatures.length + fullyAttributedFeatures.length === 1) {
// if there is exactly one pims or pmbc feature, use that feature
const features = [...pimsLocationFeatures, ...fullyAttributedFeatures];
return geoJSON(features[0]).getBounds();
Expand Down Expand Up @@ -207,6 +205,17 @@ const mapRequestStates = {
target: 'pendingFitBounds',
},
},
REQUEST_FIT_FILE_BOUNDS: {
actions: assign({
requestedFitBounds: (context: MachineContext) => {
// business logic, if there are file properties, use those, otherwise, zoom to a single feature if there is only one, or all features if there are more than one.
if (context.filePropertyLocations.length > 0) {
return latLngBounds(context.filePropertyLocations);
}
},
}),
target: 'pendingFitBounds',
},
},
pendingFlyTo: {
on: {
Expand Down Expand Up @@ -377,7 +386,7 @@ const sideBarStates = {
assign({
filePropertyLocations: (_: MachineContext, event: any) => event.locations || [],
}),
raise('REQUEST_FIT_BOUNDS'),
raise('REQUEST_FIT_FILE_BOUNDS'),
],
},

Expand Down
2 changes: 1 addition & 1 deletion source/frontend/src/features/documents/ComposedDocument.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ export class BatchUploadResponseModel {
if (exists(apiResponse)) {
if (isApiError(apiResponse)) {
this.isSuccess = false;
this.errorMessage = (apiResponse as IApiError).details;
this.errorMessage = (apiResponse as IApiError).error;
} else {
this.isSuccess = true;
}
Expand Down
Loading