Skip to content

Commit

Permalink
Merge branch 'master' into rfontanarosa/1975/createedit-survey-clicki…
Browse files Browse the repository at this point in the history
…ng-publish-changes-doesnt-bring-user-back-to-the-main-screen
  • Loading branch information
rfontanarosa authored Sep 20, 2024
2 parents 57f0ac7 + e241bb0 commit 49a5ecc
Show file tree
Hide file tree
Showing 9 changed files with 32 additions and 130 deletions.
4 changes: 4 additions & 0 deletions web/src/app/models/survey.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,10 @@ export class Survey extends Copiable {
super();
}

hasJobs(): boolean {
return this.jobs.size > 0;
}

getJob(jobId: string): Job | undefined {
return this.jobs.get(jobId);
}
Expand Down
9 changes: 6 additions & 3 deletions web/src/app/pages/create-survey/create-survey.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,13 @@
(onValidationChange)="onValidationChange($event)"
></data-sharing-terms>
</ground-step-card>
<survey-review
<ground-step-card
*ngSwitchCase="SetupPhase.REVIEW"
#surveyReview
></survey-review>
title="Review survey"
description="Is your survey ready? Share it with collectors and other organizers."
>
<share-survey></share-survey>
</ground-step-card>
</div>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import {ActivatedRoute} from '@angular/router';
import {List, Map} from 'immutable';
import {Observable, Subject} from 'rxjs';

import {ShareSurveyComponent} from 'app/components/share-survey/share-survey.component';
import {Job} from 'app/models/job.model';
import {LocationOfInterest} from 'app/models/loi.model';
import {DataSharingType, Survey, SurveyState} from 'app/models/survey.model';
Expand All @@ -46,8 +47,6 @@ import {SurveyService} from 'app/services/survey/survey.service';
import {TaskService} from 'app/services/task/task.service';
import {ActivatedRouteStub} from 'testing/activated-route-stub';

import {SurveyReviewComponent} from './survey-review/survey-review.component';

describe('CreateSurveyComponent', () => {
let component: CreateSurveyComponent;
let fixture: ComponentFixture<CreateSurveyComponent>;
Expand Down Expand Up @@ -189,7 +188,7 @@ describe('CreateSurveyComponent', () => {
SurveyDetailsComponent,
JobDetailsComponent,
DataSharingTermsComponent,
SurveyReviewComponent,
ShareSurveyComponent,
],
providers: [
{provide: NavigationService, useValue: navigationServiceSpy},
Expand Down
36 changes: 18 additions & 18 deletions web/src/app/pages/create-survey/create-survey.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,21 @@ export class CreateSurveyComponent implements OnInit {

readonly SetupPhase = SetupPhase;

@ViewChild('surveyDetails')
surveyDetails?: SurveyDetailsComponent;

@ViewChild('jobDetails')
jobDetails?: JobDetailsComponent;

@ViewChild('surveyLoi')
surveyLoi?: SurveyLoiComponent;

@ViewChild('taskDetails')
taskDetails?: TaskDetailsComponent;

@ViewChild('dataSharingTerms')
dataSharingTerms?: DataSharingTermsComponent;

constructor(
private surveyService: SurveyService,
private jobService: JobService,
Expand Down Expand Up @@ -125,7 +140,7 @@ export class CreateSurveyComponent implements OnInit {
) {
return SetupPhase.DEFINE_TASKS;
}
if (survey.jobs.size > 0) {
if (survey.hasJobs()) {
return SetupPhase.DEFINE_LOIS;
}
if (this.hasTitle(survey)) {
Expand Down Expand Up @@ -162,7 +177,7 @@ export class CreateSurveyComponent implements OnInit {
}

job(): Job | undefined {
if (this.survey?.jobs.size ?? 0 > 0) {
if (this.survey?.hasJobs()) {
return this.survey?.jobs.values().next().value;
}
return undefined;
Expand Down Expand Up @@ -234,9 +249,6 @@ export class CreateSurveyComponent implements OnInit {
this.survey = this.surveyService.getActiveSurvey();
}

@ViewChild('surveyDetails')
surveyDetails?: SurveyDetailsComponent;

private async saveSurveyTitleAndDescription(): Promise<string | void> {
const [name, description] = this.surveyDetails!.toTitleAndDescription();
if (this.surveyId === NavigationService.SURVEY_ID_NEW) {
Expand All @@ -250,9 +262,6 @@ export class CreateSurveyComponent implements OnInit {
);
}

@ViewChild('jobDetails')
jobDetails?: JobDetailsComponent;

private getFirstJob(): Job {
// there should only be at most one job attached to this survey at this
// point when user is still in the survey creation flow.
Expand All @@ -262,7 +271,7 @@ export class CreateSurveyComponent implements OnInit {
private async saveJobName(): Promise<void> {
const name = this.jobDetails!.toJobName();
let job;
if (this.survey!.jobs.size > 0) {
if (this.survey?.hasJobs()) {
job = this.getFirstJob();
} else {
job = this.jobService.createNewJob();
Expand Down Expand Up @@ -303,15 +312,6 @@ export class CreateSurveyComponent implements OnInit {
await this.surveyService.updateState(SurveyState.READY);
}

@ViewChild('surveyLoi')
surveyLoi?: SurveyLoiComponent;

@ViewChild('taskDetails')
taskDetails?: TaskDetailsComponent;

@ViewChild('dataSharingTerms')
dataSharingTerms?: DataSharingTermsComponent;

ngOnDestroy() {
this.subscription.unsubscribe();
}
Expand Down
4 changes: 2 additions & 2 deletions web/src/app/pages/create-survey/create-survey.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import {MatProgressBarModule} from '@angular/material/progress-bar';
import {MatProgressSpinnerModule} from '@angular/material/progress-spinner';

import {HeaderModule} from 'app/components/header/header.module';
import {ShareSurveyModule} from 'app/components/share-survey/share-survey.module';
import {CreateSurveyComponent} from 'app/pages/create-survey/create-survey.component';
import {DataSharingTermsModule} from 'app/pages/create-survey/data-sharing-terms/data-sharing-terms.module';
import {TaskDetailsModule} from 'app/pages/create-survey/task-details/task-details.module';
Expand All @@ -30,7 +31,6 @@ import {JobDetailsModule} from './job-details/job-details.module';
import {StepCardModule} from './step-card/step-card.module';
import {SurveyDetailsModule} from './survey-details/survey-details.module';
import {SurveyLoiModule} from './survey-loi/survey-loi.module';
import {SurveyReviewModule} from './survey-review/survey-review.module';

@NgModule({
declarations: [CreateSurveyComponent],
Expand All @@ -40,7 +40,7 @@ import {SurveyReviewModule} from './survey-review/survey-review.module';
TaskDetailsModule,
SurveyDetailsModule,
SurveyLoiModule,
SurveyReviewModule,
ShareSurveyModule,
CommonModule,
MatButtonModule,
MatInputModule,
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

0 comments on commit 49a5ecc

Please sign in to comment.