Skip to content
Merged
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
8 changes: 1 addition & 7 deletions src/app/app-routing.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ import { GroupContactSelectComponent } from './project/project-groups/group-cont
import { LinkOrganizationComponent } from './shared/components/link-organization/link-organization.component';
import { LoginComponent } from './login/login.component';
import { MapComponent } from './map/map.component';
import { MetricsComponent } from './metrics/metrics.component';
import { MilestonesComponent } from './project/milestones/milestones.component';
import { NotAuthorizedComponent } from './not-authorized/not-authorized.component';
import { OrganizationsComponent } from './organizations/organizations.component';
Expand Down Expand Up @@ -114,17 +113,12 @@ export const routes: Routes = [
canActivate: [AuthGuard],
},

// Map & Metrics & Search
// Map & Search
{
path: 'map',
component: MapComponent,
canActivate: [AuthGuard]
},
{
path: 'metrics',
component: MetricsComponent,
canActivate: [AuthGuard]
},
{
path: 'search',
component: SearchComponent,
Expand Down
206 changes: 0 additions & 206 deletions src/app/metrics/metrics.component.css

This file was deleted.

29 changes: 0 additions & 29 deletions src/app/metrics/metrics.component.html

This file was deleted.

13 changes: 0 additions & 13 deletions src/app/metrics/metrics.component.ts

This file was deleted.

20 changes: 20 additions & 0 deletions src/app/models/demi/project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,23 @@ export interface DemiProject {
pins?: DemiPin[];
[field: string]: unknown;
}

/** A project list multi-select: the URL holds each picked item's `by`; DEMI filter `api` gets each item's `apiKey`. */
export interface ProjectFilter {
by: string;
api: string;
apiKey: string;
}

/**
* Project list filters by URL param name, for the project list and search pages.
* DEMI region List rows have no code, and DEMI filters proponents by name.
*/
export const PROJECT_FILTERS: Record<'region' | 'CEAAInvolvement' | 'proponent' | 'eacDecision' | 'type' | 'projectPhase', ProjectFilter> = {
region: { by: 'name', api: 'region', apiKey: 'name' },
CEAAInvolvement: { by: 'id', api: 'CEAAInvolvement', apiKey: 'id' },
proponent: { by: 'id', api: 'proponentName', apiKey: 'name' },
eacDecision: { by: 'id', api: 'eacDecision', apiKey: 'id' },
type: { by: 'name', api: 'projectType', apiKey: 'name' },
projectPhase: { by: 'id', api: 'currentPhaseName', apiKey: 'id' }
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import { TestBed } from '@angular/core/testing';
import { ApplicationSortTableRowsComponent } from './application-sort-table-rows.component';
import { StorageService } from 'src/app/services/storage.service';

describe('ApplicationSortTableRowsComponent', () => {
let state: { editedDocs: any[] };
let component: ApplicationSortTableRowsComponent;

beforeEach(() => {
state = { editedDocs: [] };
TestBed.configureTestingModule({
imports: [ApplicationSortTableRowsComponent],
providers: [{ provide: StorageService, useValue: { state } }]
});
component = TestBed.createComponent(ApplicationSortTableRowsComponent).componentInstance;
});

it('keeps every edited row that has no Eagle id', () => {
component.updateSelectedCount({ id: 'uuid-1', _id: null, sortOrder: 1 });
component.updateSelectedCount({ id: 'uuid-2', _id: null, sortOrder: 2 });

expect(state.editedDocs.map(doc => doc.id)).toEqual(['uuid-1', 'uuid-2']);
});

it('keeps the latest edit of a row seen again on a later page load', () => {
component.updateSelectedCount({ id: 'doc-1', _id: 'doc-1', sortOrder: 5 });
component.updateSelectedCount({ id: 'doc-1', _id: 'doc-1', sortOrder: 7 });

expect(state.editedDocs.map(doc => doc.sortOrder)).toEqual([7]);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -38,20 +38,14 @@ export class ApplicationSortTableRowsComponent implements OnInit, TableComponent

updateSelectedCount(editedDoc: any): void {
this.selectedCount.emit(editedDoc);
if (Array.isArray(this.storageService.state.editedDocs)) {
// check if it exists already
let docWasEditedPreviously = false;
this.storageService.state.editedDocs.forEach((previouslyEditedDoc: any) => {
if (previouslyEditedDoc._id === editedDoc._id) {
// update entry
previouslyEditedDoc = editedDoc;
docWasEditedPreviously = true;
return;
}
});

if (!docWasEditedPreviously) {
this.storageService.state.editedDocs.push(editedDoc);
const edited = this.storageService.state.editedDocs;
if (Array.isArray(edited)) {
// By `id`: rows not in Eagle yet all have no `_id`.
const index = edited.findIndex((doc: any) => doc.id === editedDoc.id);
if (index === -1) {
edited.push(editedDoc);
} else {
edited[index] = editedDoc;
}
}
}
Expand Down
Loading
Loading