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

fix planning area assignment #352

Merged
merged 1 commit into from
Jul 27, 2021
Merged
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
11 changes: 7 additions & 4 deletions api/apps/api/src/modules/projects/projects-crud.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ export class ProjectsCrudService extends AppBaseService<
*/
const project = await super.setDataCreate(create, info);
project.createdBy = info?.authenticatedUser?.id!;
project.planningAreaGeometryId = create.planningAreaId;
Copy link
Contributor

Choose a reason for hiding this comment

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

🙈 is geometry the same as area?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I didn't want to change the api contract, and it looked like setting planningAreaId is used to set a custom planning area, whereas planningAreaId is a generic calculated field in the entity, and planningAreaGeometryId is a actual column in the entity representing the assigned custom planning area


const bbox = await this.planningAreasService.getPlanningAreaBBox({
...create,
Expand Down Expand Up @@ -209,10 +210,12 @@ export class ProjectsCrudService extends AppBaseService<
...update,
planningAreaGeometryId: update.planningAreaId,
});
if (bbox) {
const modelWithBbox = await super.setDataUpdate(model, update, _);
modelWithBbox.bbox = bbox;
return modelWithBbox;
if (bbox || update.planningAreaId !== undefined) {
const updatedModel = await super.setDataUpdate(model, update, _);
if (bbox) updatedModel.bbox = bbox;
if (update.planningAreaId !== undefined)
updatedModel.planningAreaGeometryId = update.planningAreaId;
return updatedModel;
}
return model;
}
Expand Down