Skip to content
Open
57 changes: 40 additions & 17 deletions web/src/app/components/create-survey/create-survey.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,16 @@
<div class="page">
<ground-header [survey]="survey"></ground-header>
<!-- TODO(#1170): Extract the spinner into a component -->
<div id="loading-spinner" class="loading-spinner" *ngIf="createSurveyPhase === CreateSurveyPhase.LOADING">
<div
id="loading-spinner"
class="loading-spinner"
*ngIf="createSurveyPhase === CreateSurveyPhase.LOADING"
>
<div>
<mat-spinner></mat-spinner>
<p class="loading-label" i18n="@@app.labels.loadingSurvey">Loading survey...</p>
<p class="loading-label" i18n="@@app.labels.loadingSurvey">
Loading survey...
</p>
</div>
</div>

Expand All @@ -34,11 +40,21 @@
/>
<div class="create-survey-content">
<div class="progress-bar-title">{{ progressBarTitle() }}</div>
<mat-progress-bar mode="determinate" [value]="progressBarValue()"></mat-progress-bar>
<mat-progress-bar
mode="determinate"
[value]="progressBarValue()"
></mat-progress-bar>
<ground-step-card
[title]="cardTitle()"
[description]="cardDescription()"
[jobName]="[CreateSurveyPhase.DEFINE_LOIS, CreateSurveyPhase.DEFINE_TASKS].includes(createSurveyPhase) ? jobName() : ''"
[jobName]="
[
CreateSurveyPhase.DEFINE_LOIS,
CreateSurveyPhase.DEFINE_TASKS,
].includes(createSurveyPhase)
? jobName()
: ''
"
>
<ng-container [ngSwitch]="createSurveyPhase">
<survey-details
Expand Down Expand Up @@ -86,10 +102,9 @@
id="back-button"
class="button"
color="primary"
i18n="@@app.labels.back"
(click)="back()"
>
Back
<span i18n="@@app.labels.back">Back</span>
</button>
</div>

Expand All @@ -99,17 +114,25 @@
[surveyId]="surveyId"
></ground-copy-survey-controls>

<button
id="continue-button"
class="continue-button"
mat-flat-button
color="primary"
(click)="continue()"
[disabled]="!canContinue"
>
<span *ngIf="createSurveyPhase === CreateSurveyPhase.SHARE_SURVEY" i18n="@@app.labels.goToSurvey">Go to survey</span>
<span *ngIf="createSurveyPhase !== CreateSurveyPhase.SHARE_SURVEY" i18n="@@app.labels.continue">Continue</span>
</button>
<button
id="continue-button"
class="continue-button"
mat-flat-button
color="primary"
(click)="continue()"
[disabled]="!canContinue"
>
<span
*ngIf="createSurveyPhase === CreateSurveyPhase.SHARE_SURVEY"
i18n="@@app.labels.goToSurvey"
>Go to survey</span
>
<span
*ngIf="createSurveyPhase !== CreateSurveyPhase.SHARE_SURVEY"
i18n="@@app.labels.continue"
>Continue</span
>
</button>
</div>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,19 @@
limitations under the License.
-->

<div *ngIf="loi" class="loi-panel" [ngClass]="{loading: isLoading}">
<div *ngIf="isLoading" class="progress-spinner">
<div class="loi-panel" [ngClass]="{ loading: isLoading() }">
<div *ngIf="isLoading()" class="progress-spinner">
<mat-spinner mode="indeterminate" diameter="50"></mat-spinner>
</div>

<ng-container *ngIf="!isLoading">
<ng-container *ngIf="!isLoading()">
<div class="header">
<div class="header-left">
<mat-icon svgIcon={{icon}} [ngStyle]="{color: iconColor}"></mat-icon>
<div>{{ name }}</div>
<mat-icon
svgIcon="{{ icon() }}"
[ngStyle]="{ color: iconColor() }"
></mat-icon>
<div>{{ name() }}</div>
</div>

<button
Expand All @@ -41,27 +44,37 @@
</button>
</div>

<div *ngIf="submissions && submissions.count() === 0" class="no-lois-container">
<div class="mat-icon-container">
<mat-icon>inbox</mat-icon>
<ng-container *ngIf="submissions() as subs">
<div *ngIf="subs.count() === 0" class="no-lois-container">
<div class="mat-icon-container">
<mat-icon>inbox</mat-icon>
</div>
<span i18n="@@app.loiPanel.noDataForThisSite"
>No data collected for this site</span
>
</div>
No data collected for this site
</div>

<mat-list *ngIf="submissions && submissions.count() > 0">
<div *ngFor="let submission of submissions; let i = index">
<mat-divider *ngIf="i > 0"></mat-divider>
<div class="submission-item">
<mat-list-item (click)="onSelectSubmission(submission.id)">
<mat-icon matListItemIcon class="material-symbols-outlined">text_snippet</mat-icon>
<h3 matListItemTitle>{{ submission.created.user.displayName }}</h3>
<p matListItemLine>{{ submission.created.clientTime | date: 'longDate' }}</p>
</mat-list-item>
<button mat-icon-button (click)="onSelectSubmission(submission.id)">
<mat-icon>chevron_right</mat-icon>
</button>
<mat-list *ngIf="subs.count() > 0">
<div *ngFor="let submission of subs; let i = index">
<mat-divider *ngIf="i > 0"></mat-divider>
<div class="submission-item">
<mat-list-item (click)="onSelectSubmission(submission.id)">
<mat-icon matListItemIcon class="material-symbols-outlined"
>text_snippet</mat-icon
>
<h3 matListItemTitle>
{{ submission.created.user.displayName }}
</h3>
<p matListItemLine>
{{ submission.created.clientTime | date: 'longDate' }}
</p>
</mat-list-item>
<button mat-icon-button (click)="onSelectSubmission(submission.id)">
<mat-icon>chevron_right</mat-icon>
</button>
</div>
</div>
</div>
</mat-list>
</mat-list>
</ng-container>
</ng-container>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,12 @@
*/

import { NO_ERRORS_SCHEMA } from '@angular/core';
import { ComponentFixture, TestBed } from '@angular/core/testing';
import {
ComponentFixture,
TestBed,
fakeAsync,
tick,
} from '@angular/core/testing';
import { MatDialog, MatDialogModule } from '@angular/material/dialog';
import { MatIconModule } from '@angular/material/icon';
import { MatListModule } from '@angular/material/list';
Expand Down Expand Up @@ -111,27 +116,34 @@ describe('LocationOfInterestPanelComponent', () => {
beforeEach(() => {
fixture = TestBed.createComponent(LocationOfInterestPanelComponent);
component = fixture.componentInstance;
});

function setupPanelWithLoi() {
fixture.componentRef.setInput('activeSurvey', mockSurvey);
fixture.componentRef.setInput('selectedLoi', mockLoi);
fixture.detectChanges();
});
tick(100);
fixture.detectChanges();
}

it('should create', () => {
expect(component).toBeTruthy();
});

it('should initialize component state on init', () => {
fixture.componentRef.setInput('lois', List([mockLoi]));
fixture.detectChanges();
it('should initialize component state on init', fakeAsync(() => {
setupPanelWithLoi();

expect(component.loi).toEqual(mockLoi);
expect(component.isLoading()).toBe(false);
expect(component.selectedLoi()).toEqual(mockLoi);
expect(component.iconColor()).toBe('#000');
expect(component.name()).toBe('Unnamed point');
expect(component.submissions).toBeDefined();
expect(component.isLoading).toBe(false);
expect(component.iconColor).toBe('#000');
expect(component.name).toBe('Unnamed point'); // Default name for mockLoi
});
}));

it('should navigate to submission detail on selection', () => {
component.loi = mockLoi;
it('should navigate to submission detail on selection', fakeAsync(() => {
setupPanelWithLoi();

fixture.componentRef.setInput('loi', mockLoi);
const submissionId = 'sub1';
component.onSelectSubmission(submissionId);

Expand All @@ -140,7 +152,7 @@ describe('LocationOfInterestPanelComponent', () => {
mockLoi.id,
submissionId
);
});
}));

it('should clear LOI on close', () => {
component.onClosePanel();
Expand Down
Loading