Skip to content
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
4 changes: 2 additions & 2 deletions web/src/app/components/edit-survey/edit-survey.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@

<div class="page">
<ground-survey-header
*ngIf="survey; let activeSurvey"
[activeSurvey]="activeSurvey"
*ngIf="activeSurvey()"
[activeSurvey]="activeSurvey()"
></ground-survey-header>

<!-- TODO(#1170): Extract the spinner into a component -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,10 +106,15 @@ describe('EditSurveyComponent', () => {

surveyServiceSpy = jasmine.createSpyObj<SurveyService>('SurveyService', [
'canManageSurvey',
'loadSurvey$',
]);
surveyServiceSpy.loadSurvey$.and.returnValue(of(survey));
surveyServiceSpy.canManageSurvey.and.returnValue(true);

activeSurvey$ = new Subject<Survey>();

surveySubject$ = new BehaviorSubject<Survey>(survey);

draftSurveyServiceSpy = jasmine.createSpyObj<DraftSurveyService>(
'DraftSurveyService',
['init', 'getSurvey$', 'addOrUpdateJob', 'deleteJob', 'getSurvey']
Expand Down
10 changes: 10 additions & 0 deletions web/src/app/components/edit-survey/edit-survey.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ import {
DialogType,
JobDialogComponent,
} from './job-dialog/job-dialog.component';
import { toObservable, toSignal } from '@angular/core/rxjs-interop';
import { switchMap } from 'rxjs';
import { SurveyService } from 'app/services/survey/survey.service';

@Component({
selector: 'edit-survey',
Expand All @@ -48,11 +51,18 @@ export class EditSurveyComponent {
private jobService = inject(JobService);
private draftSurveyService = inject(DraftSurveyService);
private navigationService = inject(NavigationService);
private surveyService = inject(SurveyService);
public dialog = inject(MatDialog);

private editSurveyPageSignal =
this.navigationService.getEditSurveyPageSignal();

surveyId = input<string>();
activeSurvey = toSignal(
toObservable(this.surveyId).pipe(
switchMap(id => (id ? this.surveyService.loadSurvey$(id) : []))
)
);

survey?: Survey;
production = !!(environment as Environment)['production'];
Expand Down
Loading