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

Update URL paths and remove unused code #2118

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,6 @@ describe('JobListItemComponent', () => {

expect(
navigationServiceSpy.selectLocationOfInterest
).toHaveBeenCalledOnceWith(loiId);
).toHaveBeenCalledOnceWith(surveyId, loiId);
});
});
14 changes: 5 additions & 9 deletions web/src/app/components/job-list-item/job-list-item.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,13 +120,6 @@ export class JobListItemComponent implements OnInit, OnDestroy {
);
}

onJobListSelect(): void | undefined {
if (!this.job?.id) {
return;
}
this.navigationService.showLocationOfInterestList(this.job.id);
}

isSelectedLoi(node: DynamicFlatNode): boolean {
return node.loi?.id === this.loiId;
}
Expand All @@ -136,8 +129,11 @@ export class JobListItemComponent implements OnInit, OnDestroy {
}

selectLoi(node: DynamicFlatNode) {
if (this.isLoiNode(node)) {
this.navigationService.selectLocationOfInterest(node.loi!.id);
if (this.surveyId && this.isLoiNode(node)) {
this.navigationService.selectLocationOfInterest(
this.surveyId,
node.loi!.id
);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ describe('MainPageComponent', () => {

const navigationService = {
getSurveyId$: () => NEVER,
getJobId$: () => NEVER,
getLocationOfInterestId$: () => NEVER,
getSubmissionId$: () => NEVER,
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,6 @@ export class MainPageComponent implements OnInit {
id => id === NavigationService.JOB_ID_NEW && this.showTitleDialog()
)
);
// Show job dialog when non-null job id set in URL.
this.subscription.add(
this.navigationService
.getJobId$()
.subscribe(id => id && this.showEditJobDialog(id))
);
// Show loi details when non-null LOI id set in URL.
// Show submission details when submission id set in URL.
this.subscription.add(
Expand Down Expand Up @@ -103,23 +97,6 @@ export class MainPageComponent implements OnInit {
});
}

private showEditJobDialog(jobId: string) {
this.activeSurvey$.pipe(take(1)).subscribe(survey =>
this.dialog.open(JobDialogComponent, {
autoFocus: jobId === NavigationService.JOB_ID_NEW,
data: {
surveyId:
survey.state === SurveyState.UNSAVED
? NavigationService.SURVEY_ID_NEW
: survey.id,
createJob: jobId === NavigationService.SURVEY_ID_NEW,
job: survey.jobs?.get(jobId),
},
panelClass: 'job-dialog-container',
})
);
}

private loadLocationOfInterestDetails(loiId: string) {
this.loiService.selectLocationOfInterest(loiId);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,9 @@ describe('MapComponent', () => {
'job002 name',
/* tasks= */ Map()
);
const surveyId = 'survey001';
const mockSurvey = new Survey(
'survey001',
surveyId,
'title1',
'description1',
/* jobs= */ Map({
Expand Down Expand Up @@ -391,7 +392,7 @@ describe('MapComponent', () => {

expect(
navigationServiceSpy.selectLocationOfInterest
).toHaveBeenCalledOnceWith(poiId1);
).toHaveBeenCalledOnceWith(surveyId, poiId1);
});

it('should select loi when polygon is clicked', () => {
Expand All @@ -402,7 +403,7 @@ describe('MapComponent', () => {

expect(
navigationServiceSpy.selectLocationOfInterest
).toHaveBeenCalledOnceWith(polygonLoiId1);
).toHaveBeenCalledOnceWith(surveyId, polygonLoiId1);
});

it('should enlarge the stroke weight of the polygon when loi is selected', fakeAsync(() => {
Expand Down Expand Up @@ -613,7 +614,7 @@ describe('MapComponent', () => {

expect(
navigationServiceSpy.selectLocationOfInterest
).toHaveBeenCalledOnceWith(polygonLoiId1);
).toHaveBeenCalledOnceWith(surveyId, polygonLoiId1);
}));

it('should add marker when map clicked and edit mode is "AddPoint"', fakeAsync(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,8 @@ export class MapComponent implements AfterViewInit, OnChanges, OnDestroy {
const geometryType = (taskResult?.value as Geometry)?.geometryType;
if (geometryType === GeometryType.POINT) {
const marker = this.addSubmissionMarkerToMap(
this.submission!.loiId!,
this.submission!.id!,
task.id,
taskResult!.value as Point,
this.submission?.job?.color,
Expand All @@ -269,6 +271,8 @@ export class MapComponent implements AfterViewInit, OnChanges, OnDestroy {
this.markers.set(task.id, marker);
} else if (geometryType === GeometryType.POLYGON) {
const polygon = this.addSubmissionPolygonToMap(
this.submission!.loiId!,
this.submission!.id!,
task.id,
taskResult!.value as Polygon,
this.submission?.job?.color
Expand Down Expand Up @@ -323,6 +327,7 @@ export class MapComponent implements AfterViewInit, OnChanges, OnDestroy {
);
if (newLocationOfInterest) {
this.navigationService.selectLocationOfInterest(
this.lastFitSurveyId,
newLocationOfInterest.id
);
}
Expand Down Expand Up @@ -505,28 +510,44 @@ export class MapComponent implements AfterViewInit, OnChanges, OnDestroy {
* Adds new marker that represents a geometry based task submission to existing map
*/
private addSubmissionMarkerToMap(
loiId: string,
submissionId: string,
taskId: string,
geometry: Point,
color: string | undefined,
markerText: string
): google.maps.marker.AdvancedMarkerElement {
const marker = this.addMarkerToMap(taskId, geometry, color, markerText);
marker.addListener('click', () => this.onSubmissionGeometryClick(taskId));
marker.addListener('click', () =>
this.onSubmissionGeometryClick(loiId, submissionId, taskId)
);
return marker;
}

private onLocationOfInterestMarkerClick(loiId: string) {
if (this.disableMapClicks) {
return;
}
this.navigationService.selectLocationOfInterest(loiId);
this.navigationService.selectLocationOfInterest(
this.lastFitSurveyId,
loiId
);
}

private onSubmissionGeometryClick(taskId: string) {
private onSubmissionGeometryClick(
loiId: string,
submissionId: string,
taskId: string
) {
if (this.disableMapClicks) {
return;
}
this.navigationService.showSubmissionDetailWithHighlightedTask(taskId);
this.navigationService.showSubmissionDetailWithHighlightedTask(
this.lastFitSurveyId,
loiId,
submissionId,
taskId
);
}

private onMarkerDragStart(
Expand Down Expand Up @@ -614,6 +635,8 @@ export class MapComponent implements AfterViewInit, OnChanges, OnDestroy {
}

private selectSubmissionTask(taskId: string | null) {
if (!taskId) return;

if (taskId === this.selectedSubmissionTaskId) {
return;
}
Expand Down Expand Up @@ -722,14 +745,18 @@ export class MapComponent implements AfterViewInit, OnChanges, OnDestroy {
* Adds new polygon that represents a geometry based task submission to existing map
*/
private addSubmissionPolygonToMap(
loiId: string,
submissionId: string,
taskId: string,
polygonModel: Polygon,
color: string | undefined
): google.maps.Polygon {
const polygon = this.addPolygonToMap(polygonModel, color);
polygon.set('id', taskId);
polygon.set('color', color);
polygon.addListener('click', () => this.onSubmissionGeometryClick(taskId));
polygon.addListener('click', () =>
this.onSubmissionGeometryClick(loiId, submissionId, taskId)
);
return polygon;
}

Expand Down Expand Up @@ -763,7 +790,11 @@ export class MapComponent implements AfterViewInit, OnChanges, OnDestroy {
const loi = LocationOfInterest.getSmallestByArea(candidateLois);

this.zone.run(() => {
if (loi) this.navigationService.selectLocationOfInterest(loi.id);
if (loi)
this.navigationService.selectLocationOfInterest(
this.lastFitSurveyId,
loi.id
);
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ export class LocationOfInterestPanelComponent implements OnInit, OnDestroy {
name!: string | null;
icon!: string;
iconColor!: string;
surveyId!: string;
submissions!: List<Submission>;
isLoading = true;

Expand All @@ -56,8 +57,9 @@ export class LocationOfInterestPanelComponent implements OnInit, OnDestroy {
this.surveyService
.getActiveSurvey$()
.pipe(
switchMap(survey =>
this.loiService.getSelectedLocationOfInterest$().pipe(
switchMap(survey => {
this.surveyId = survey.id;
return this.loiService.getSelectedLocationOfInterest$().pipe(
switchMap(loi => {
this.iconColor = survey.getJob(loi.jobId)!.color!;
this.loi = loi;
Expand All @@ -66,8 +68,8 @@ export class LocationOfInterestPanelComponent implements OnInit, OnDestroy {

return this.submissionService.getSubmissions$();
})
)
)
);
})
)
.subscribe(submissions => {
this.submissions = submissions;
Expand All @@ -77,7 +79,11 @@ export class LocationOfInterestPanelComponent implements OnInit, OnDestroy {
}

onSelectSubmission(submissionId: string) {
this.navigationService.showSubmissionDetail(this.loi.id, submissionId);
this.navigationService.showSubmissionDetail(
this.surveyId,
this.loi.id,
submissionId
);
}

onClosePanel() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,19 +34,22 @@ export class SecondarySidePanelComponent {
readonly sideNavMode = SideNavMode;
readonly sideNavMode$: Observable<SideNavMode>;

locationOfInterestId = '';
submissionId = '';
locationOfInterestId: string | null = '';
submissionId: string | null = '';

constructor(
private route: ActivatedRoute,
private navigationService: NavigationService
) {
this.subscription.add(
this.route.fragment.subscribe(() => {
this.locationOfInterestId =
this.navigationService.getLocationOfInterestId() || '';
this.navigationService.getLocationOfInterestId$().subscribe(loiId => {
this.locationOfInterestId = loiId;
})
);

this.submissionId = this.navigationService.getSubmissionId() || '';
this.subscription.add(
this.navigationService.getSubmissionId$().subscribe(submissionId => {
this.submissionId = submissionId;
})
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ export class SubmissionPanelComponent implements OnInit, OnDestroy {
submission: Submission | null = null;
tasks?: List<Task>;
selectedTaskId: string | null = null;
surveyId: string | null = null;
firebaseURLs = new Map<string, string>();
isLoading = true;

Expand All @@ -52,6 +53,11 @@ export class SubmissionPanelComponent implements OnInit, OnDestroy {
) {}

ngOnInit() {
this.subscription.add(
this.navigationService.getSurveyId$().subscribe(surveyId => {
this.surveyId = surveyId;
})
);
this.subscription.add(
this.submissionService.getSelectedSubmission$().subscribe(submission => {
if (submission instanceof Submission) {
Expand Down Expand Up @@ -92,7 +98,10 @@ export class SubmissionPanelComponent implements OnInit, OnDestroy {
}

navigateToSubmissionList() {
this.navigationService.selectLocationOfInterest(this.submission!.loiId);
this.navigationService.selectLocationOfInterest(
this.surveyId!,
this.submission!.loiId
);
}

getTaskSubmissionResult({id: taskId}: Task): Result | undefined {
Expand Down Expand Up @@ -147,7 +156,12 @@ export class SubmissionPanelComponent implements OnInit, OnDestroy {
}

selectGeometry(task: Task): void {
this.navigationService.showSubmissionDetailWithHighlightedTask(task.id);
this.navigationService.showSubmissionDetailWithHighlightedTask(
this.surveyId!,
this.submission!.loiId!,
this.submission!.id!,
task.id
);
}

ngOnDestroy(): void {
Expand Down

This file was deleted.

Loading
Loading