From aff19eb20f1d64c79a0f605425cd7cc9ddb0e20d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mark=20Lis=C3=A9?= Date: Wed, 12 Aug 2020 16:17:33 -0700 Subject: [PATCH 1/2] NRPT-262: Associating mine records. Fixing unit tests, code cleanup. --- .../admin-nrpti/src/app/app.component.spec.ts | 19 ++- .../admin-nrpti/src/app/app.component.ts | 109 +++++++++++++++++- .../src/app/confirm/confirm.component.spec.ts | 4 +- .../src/app/footer/footer.component.spec.ts | 4 +- .../src/app/header/header.component.spec.ts | 4 +- .../src/app/home/home.component.spec.ts | 4 +- .../import-csv/import-csv.component.spec.ts | 87 +++++++------- .../import-table-rows.component.ts | 2 +- .../mines-add-edit.component.spec.ts | 4 +- ...ollection-detail-record-row.component.html | 2 +- ...ection-detail-record-row.component.spec.ts | 4 +- .../mines-collection-detail.component.spec.ts | 4 +- ...nes-collections-add-edit.component.spec.ts | 6 +- .../mines-collections-list-resolver.spec.ts | 10 +- .../mines-collections-list.component.spec.ts | 4 +- ...es-collections-table-row.component.spec.ts | 4 +- .../mines-detail.component.spec.ts | 4 +- .../src/app/mines/mines-list-resolver.spec.ts | 8 +- .../mines-list/mines-list.component.spec.ts | 4 +- .../mines-records-detail.component.spec.ts | 4 +- .../mines/mines-records-list-resolver.spec.ts | 10 +- .../mines-records-list.component.spec.ts | 4 +- .../mines-records-table-row.component.spec.ts | 4 +- .../mines-table-row.component.spec.ts | 4 +- ...trative-penalty-add-edit.component.spec.ts | 16 ++- ...ministrative-penalty-detail.component.html | 2 +- ...istrative-penalty-detail.component.spec.ts | 16 ++- ...ative-penalty-lng-detail.component.spec.ts | 17 ++- ...ive-penalty-nrced-detail.component.spec.ts | 17 ++- ...rative-sanction-add-edit.component.spec.ts | 16 ++- ...inistrative-sanction-detail.component.html | 2 +- ...strative-sanction-detail.component.spec.ts | 16 ++- ...tive-sanction-lng-detail.component.spec.ts | 17 ++- ...ve-sanction-nrced-detail.component.spec.ts | 17 ++- .../agreement-add-edit.component.spec.ts | 16 ++- .../agreement-detail.component.html | 2 +- .../agreement-detail.component.spec.ts | 16 ++- .../agreement-lng-detail.component.spec.ts | 17 ++- .../annual-report-add-edit.component.html | 7 ++ .../annual-report-add-edit.component.spec.ts | 17 ++- .../annual-report-add-edit.component.ts | 31 ++++- ...nnual-report-bcmi-detail.component.spec.ts | 17 ++- .../annual-report-detail.component.html | 2 +- .../annual-report-detail.component.spec.ts | 16 ++- ...ificate-amendments-add-edit.component.html | 32 ++--- ...cate-amendments-add-edit.component.spec.ts | 16 ++- ...rtificate-amendments-add-edit.component.ts | 31 ++++- ...e-amendments-bcmi-detail.component.spec.ts | 19 ++- ...ficate-amendments-bcmi-detail.component.ts | 2 +- ...rtificate-amendments-detail.component.html | 2 +- ...ficate-amendments-detail.component.spec.ts | 16 ++- ...te-amendments-lng-detail.component.spec.ts | 17 ++- ...ificate-amendments-lng-detail.component.ts | 2 +- .../certificate-add-edit.component.html | 31 +---- .../certificate-add-edit.component.spec.ts | 16 ++- .../certificate-add-edit.component.ts | 31 ++++- .../certificate-detail.component.html | 2 +- .../certificate-detail.component.spec.ts | 16 ++- .../certificate-lng-detail.component.spec.ts | 17 ++- .../construction-plan-add-edit.component.html | 33 ++---- ...nstruction-plan-add-edit.component.spec.ts | 16 ++- .../construction-plan-add-edit.component.ts | 31 ++++- .../construction-plan-detail.component.html | 2 +- ...construction-plan-detail.component.spec.ts | 16 ++- ...truction-plan-lng-detail.component.spec.ts | 4 +- .../correspondence-add-edit.component.html | 32 ++--- .../correspondence-add-edit.component.spec.ts | 17 ++- .../correspondence-add-edit.component.ts | 31 ++++- ...rrespondence-bcmi-detail.component.spec.ts | 17 ++- .../correspondence-detail.component.html | 2 +- .../correspondence-detail.component.spec.ts | 16 ++- ...respondence-nrced-detail.component.spec.ts | 4 +- ...ourt-conviction-add-edit.component.spec.ts | 4 +- .../court-conviction-detail.component.html | 2 +- .../court-conviction-detail.component.spec.ts | 4 +- ...rt-conviction-lng-detail.component.spec.ts | 4 +- ...-conviction-nrced-detail.component.spec.ts | 4 +- ...-safety-inspection-add-edit.component.html | 32 ++--- ...fety-inspection-add-edit.component.spec.ts | 16 ++- ...am-safety-inspection-add-edit.component.ts | 31 ++++- ...y-inspection-bcmi-detail.component.spec.ts | 13 ++- ...am-safety-inspection-detail.component.html | 2 +- ...safety-inspection-detail.component.spec.ts | 16 ++- ...-inspection-nrced-detail.component.spec.ts | 4 +- .../inspection-add-edit.component.html | 32 ++--- .../inspection-add-edit.component.spec.ts | 16 ++- .../inspection-add-edit.component.ts | 31 ++++- .../inspection-detail.component.html | 2 +- .../inspection-detail.component.spec.ts | 13 ++- .../inspection-lng-detail.component.spec.ts | 4 +- .../inspection-nrced-detail.component.spec.ts | 4 +- .../management-plan-add-edit.component.html | 34 ++---- ...management-plan-add-edit.component.spec.ts | 16 ++- .../management-plan-add-edit.component.ts | 31 ++++- .../management-plan-detail.component.html | 2 +- .../management-plan-detail.component.spec.ts | 16 ++- ...nagement-plan-lng-detail.component.spec.ts | 17 ++- .../order-add-edit.component.html | 32 ++--- .../order-add-edit.component.spec.ts | 16 ++- .../order-add-edit.component.ts | 31 ++++- .../order-detail/order-detail.component.html | 2 +- .../order-detail.component.spec.ts | 16 ++- .../order-lng-detail.component.spec.ts | 17 ++- .../order-nrced-detail.component.spec.ts | 17 ++- .../permit-add-edit.component.html | 32 +---- .../permit-add-edit.component.spec.ts | 16 ++- .../permit-add-edit.component.ts | 60 +++++----- .../permit-detail.component.html | 2 +- .../permit-detail.component.spec.ts | 16 ++- .../permit-lng-detail.component.spec.ts | 17 ++- .../report-add-edit.component.html | 32 ++--- .../report-add-edit.component.spec.ts | 16 ++- .../report-add-edit.component.ts | 31 ++++- .../report-bcmi-detail.component.spec.ts | 17 ++- .../report-detail.component.html | 2 +- .../report-detail.component.spec.ts | 16 ++- .../report-nrced-detail.component.spec.ts | 17 ++- ...orative-justice-add-edit.component.spec.ts | 16 ++- .../restorative-justice-detail.component.html | 2 +- ...storative-justice-detail.component.spec.ts | 16 ++- ...ative-justice-lng-detail.component.spec.ts | 17 ++- ...ive-justice-nrced-detail.component.spec.ts | 17 ++- .../self-report-add-edit.component.spec.ts | 16 ++- .../self-report-detail.component.html | 2 +- .../self-report-detail.component.spec.ts | 16 ++- .../self-report-lng-detail.component.spec.ts | 17 ++- .../ticket-add-edit.component.spec.ts | 16 ++- .../ticket-detail.component.html | 2 +- .../ticket-detail.component.spec.ts | 16 ++- .../ticket-lng-detail.component.spec.ts | 17 ++- .../ticket-nrced-detail.component.spec.ts | 16 ++- .../warning-add-edit.component.spec.ts | 4 +- .../warning-detail.component.html | 2 +- .../warning-detail.component.spec.ts | 4 +- .../warning-lng-detail.component.spec.ts | 4 +- .../warning-nrced-detail.component.spec.ts | 4 +- .../src/app/services/factory.service.spec.ts | 4 +- .../src/app/sidebar/sidebar.component.spec.ts | 4 +- .../projects/common/src/app/common.module.ts | 8 +- .../document-edit.component.spec.ts | 4 +- .../document-link-staging.component.spec.ts | 4 +- .../document-read-only.component.spec.ts | 4 +- .../entity-add-edit.component.spec.ts | 4 +- .../entity-detail.component.spec.ts | 4 +- .../file-upload/file-upload.component.spec.ts | 4 +- .../legislation-add-edit.component.spec.ts | 4 +- .../link-add-edit.component.spec.ts | 4 +- .../penalty-add-edit.component.spec.ts | 4 +- .../penalty-detail.component.spec.ts | 4 +- .../penalty-detail.component.spec.ts | 4 +- .../record-association-edit.component.html | 24 ++++ .../record-association-edit.component.scss | 54 +++++++++ .../record-association-edit.component.spec.ts | 34 ++++++ .../record-association-edit.component.ts | 43 +++++++ .../search-filter-template.component.spec.ts | 4 +- .../button-spinner.component.spec.ts | 4 +- .../page-count-display.component.spec.ts | 4 +- .../page-size-picker.component.spec.ts | 4 +- .../auto-grow-textarea.directive.spec.ts | 4 +- .../digit-only/digit-only.directive.spec.ts | 4 +- .../lib/services/loading-screen.service.ts | 4 +- .../src/lib/services/store.service.spec.ts | 4 +- .../global/src/lib/services/store.service.ts | 4 +- .../src/app/contact/contact.component.spec.ts | 4 +- .../src/app/faq/faq.component.spec.ts | 4 +- .../src/app/app.component.spec.ts | 2 +- .../src/app/confirm/confirm.component.spec.ts | 4 +- .../src/app/footer/footer.component.spec.ts | 4 +- .../src/app/header/header.component.spec.ts | 4 +- .../src/app/home/home.component.spec.ts | 4 +- ...istrative-penalty-detail.component.spec.ts | 4 +- ...strative-sanction-detail.component.spec.ts | 4 +- .../court-conviction-detail.component.spec.ts | 4 +- .../inspection-detail.component.spec.ts | 4 +- .../order-detail.component.spec.ts | 4 +- .../records-list.component.spec.ts | 4 +- .../search-filters.component.spec.ts | 4 +- ...storative-justice-detail.component.spec.ts | 4 +- .../ticket-detail.component.spec.ts | 4 +- .../warning-detail.component.spec.ts | 4 +- .../src/app/services/factory.service.spec.ts | 4 +- api/src/integrations/epic/datasource.js | 20 +++- api/src/models/epicProject.js | 14 +++ api/src/models/index.js | 1 + api/src/utils/query-actions.js | 6 - 185 files changed, 1636 insertions(+), 746 deletions(-) create mode 100644 angular/projects/common/src/app/record-association/record-association-edit.component.html create mode 100644 angular/projects/common/src/app/record-association/record-association-edit.component.scss create mode 100644 angular/projects/common/src/app/record-association/record-association-edit.component.spec.ts create mode 100644 angular/projects/common/src/app/record-association/record-association-edit.component.ts create mode 100644 api/src/models/epicProject.js diff --git a/angular/projects/admin-nrpti/src/app/app.component.spec.ts b/angular/projects/admin-nrpti/src/app/app.component.spec.ts index 165a070bd..c3397a035 100644 --- a/angular/projects/admin-nrpti/src/app/app.component.spec.ts +++ b/angular/projects/admin-nrpti/src/app/app.component.spec.ts @@ -1,4 +1,4 @@ -import { TestBed, async } from '@angular/core/testing'; +import { TestBed } from '@angular/core/testing'; import { RouterTestingModule } from '@angular/router/testing'; import { AppComponent } from './app.component'; @@ -11,14 +11,14 @@ import { HttpClientTestingModule } from '@angular/common/http/testing'; import { SidebarComponent } from './sidebar/sidebar.component'; import { ToggleButtonComponent } from './toggle-button/toggle-button.component'; import { - BreadcrumbComponent, StoreService, + GlobalModule, LoadingScreenService } from 'nrpti-angular-components'; -import { of } from 'rxjs'; +import { EventEmitter } from 'events'; describe('AppComponent', () => { - beforeEach(async(() => { + beforeEach((() => { const mockKeycloakService = { isValidForSite: () => { return true; @@ -26,8 +26,8 @@ describe('AppComponent', () => { }; const mockStoreService = { - stateChange: of(), - toggleSideNave: () => { } + getItem: () => { }, + stateChange: new EventEmitter() }; const mockLoadingScreenService = { @@ -40,10 +40,9 @@ describe('AppComponent', () => { HeaderComponent, FooterComponent, SidebarComponent, - ToggleButtonComponent, - BreadcrumbComponent + ToggleButtonComponent ], - imports: [RouterTestingModule, HttpClientTestingModule, BrowserAnimationsModule], + imports: [GlobalModule, RouterTestingModule, HttpClientTestingModule, BrowserAnimationsModule], providers: [ ApiService, { provide: LoadingScreenService, useValue: mockLoadingScreenService }, @@ -53,7 +52,7 @@ describe('AppComponent', () => { }).compileComponents(); })); - it('should create the app', async(() => { + it('should create the app', (() => { const fixture = TestBed.createComponent(AppComponent); const app = fixture.debugElement.componentInstance; expect(app).toBeTruthy(); diff --git a/angular/projects/admin-nrpti/src/app/app.component.ts b/angular/projects/admin-nrpti/src/app/app.component.ts index 56c4e454f..70be31ec3 100644 --- a/angular/projects/admin-nrpti/src/app/app.component.ts +++ b/angular/projects/admin-nrpti/src/app/app.component.ts @@ -1,17 +1,25 @@ -import { Component, OnInit, HostListener, ChangeDetectorRef } from '@angular/core'; +import { Component, OnInit, HostListener, ChangeDetectorRef, OnDestroy } from '@angular/core'; import { Router } from '@angular/router'; import { IBreadcrumb, StoreService, LoadingScreenService } from 'nrpti-angular-components'; +import { FactoryService } from './services/factory.service'; +import { Subscription } from 'rxjs/internal/Subscription'; +import { interval } from 'rxjs/internal/observable/interval'; +import { takeWhile, switchMap } from 'rxjs/operators'; @Component({ selector: 'app-root', templateUrl: './app.component.html', styleUrls: ['./app.component.scss'] }) -export class AppComponent implements OnInit { +export class AppComponent implements OnInit, OnDestroy { + private alive = true; public currentWindowWidth = window.innerWidth; public showSideContent = this.currentWindowWidth > 768 ? true : false; public userClosedSideContent = false; + mineSubscription: Subscription; + epicProjectSubscription: Subscription; + public breadcrumbs: IBreadcrumb[]; public activeBreadcrumb: IBreadcrumb; @@ -21,6 +29,7 @@ export class AppComponent implements OnInit { constructor( private router: Router, private loadingScreenService: LoadingScreenService, + private factoryService: FactoryService, private storeService: StoreService, private _changeDetectionRef: ChangeDetectorRef ) { @@ -28,6 +37,14 @@ export class AppComponent implements OnInit { } ngOnInit() { + if (this.mineSubscription) { + this.mineSubscription.unsubscribe(); + } + + if (this.epicProjectSubscription) { + this.epicProjectSubscription.unsubscribe(); + } + this.storeService.stateChange.subscribe((state: object) => { if (state && state.hasOwnProperty('userClosedSideContent')) { this.userClosedSideContent = state['userClosedSideContent']; @@ -52,6 +69,90 @@ export class AppComponent implements OnInit { } this._changeDetectionRef.detectChanges(); }); + + // Subscribe to updates on specific models + this.updateMines(); + this.updateEpicProjects(); + } + + private updateMines() { + // Fetch initially + const minesSub = this.factoryService.searchService.getSearchResults( + this.factoryService.apiService.pathAPI, + '', + ['MineBCMI'], + [], + 1, + 100000, + '+name' + ).subscribe((mineResults: any[]) => { + this.setStoreServiceItem('mines', mineResults[0].data.searchResults); + minesSub.unsubscribe(); + }); + + // Update every 4 hours + this.mineSubscription = interval(1000 * 60 * 60 * 4) + .pipe( + takeWhile(() => this.alive), + switchMap(() => this.factoryService.searchService.getSearchResults( + this.factoryService.apiService.pathAPI, + '', + ['MineBCMI'], + [], + 1, + 100000, + '+name' + )), + ) + .subscribe((mineResults: any[]) => { + this.setStoreServiceItem('mines', mineResults[0].data.searchResults); + }); + } + + private updateEpicProjects() { + // Fetch initially + const epicSub = this.factoryService.searchService.getSearchResults( + this.factoryService.apiService.pathAPI, + '', + ['EPICProject'], + [], + 1, + 100000, + '+name' + ).subscribe((epicProjectResults: any[]) => { + this.setStoreServiceItem('epicProjects', epicProjectResults[0].data.searchResults); + epicSub.unsubscribe(); + }); + + // Update every 4 hours + this.epicProjectSubscription = interval(1000 * 60 * 60 * 4) + .pipe( + takeWhile(() => this.alive), + switchMap(() => this.factoryService.searchService.getSearchResults( + this.factoryService.apiService.pathAPI, + '', + ['EPICProject'], + [], + 1, + 100000, + '+name' + )), + ) + .subscribe((epicProjectResults: any[]) => { + this.setStoreServiceItem('epicProjects', epicProjectResults[0].data.searchResults); + }); + } + + // Sets a store service list item, but unshifts a null-based element first. + private setStoreServiceItem(key, list) { + // First unshift an item into the list. + list.unshift({_id: null, name: 'None'}); + + // Set the object in the store service + // tslint:disable-next-line: prefer-const + let newObject = {}; + newObject[key] = list; + this.storeService.setItem(newObject); } public navigateBreadcrumb(breadcrumbData) { @@ -82,4 +183,8 @@ export class AppComponent implements OnInit { this.currentWindowWidth = window.innerWidth; } + + ngOnDestroy() { + this.alive = false; + } } diff --git a/angular/projects/admin-nrpti/src/app/confirm/confirm.component.spec.ts b/angular/projects/admin-nrpti/src/app/confirm/confirm.component.spec.ts index cc9219ec7..9f81361ea 100644 --- a/angular/projects/admin-nrpti/src/app/confirm/confirm.component.spec.ts +++ b/angular/projects/admin-nrpti/src/app/confirm/confirm.component.spec.ts @@ -1,4 +1,4 @@ -import { async, ComponentFixture, TestBed } from '@angular/core/testing'; +import { ComponentFixture, TestBed } from '@angular/core/testing'; import { ConfirmComponent } from './confirm.component'; import { DialogService } from 'ng2-bootstrap-modal'; @@ -7,7 +7,7 @@ describe('ConfirmComponent', () => { let component: ConfirmComponent; let fixture: ComponentFixture; - beforeEach(async(() => { + beforeEach((() => { TestBed.configureTestingModule({ declarations: [ConfirmComponent], providers: [DialogService] diff --git a/angular/projects/admin-nrpti/src/app/footer/footer.component.spec.ts b/angular/projects/admin-nrpti/src/app/footer/footer.component.spec.ts index 6cf81a828..26cee1db8 100644 --- a/angular/projects/admin-nrpti/src/app/footer/footer.component.spec.ts +++ b/angular/projects/admin-nrpti/src/app/footer/footer.component.spec.ts @@ -1,4 +1,4 @@ -import { async, ComponentFixture, TestBed } from '@angular/core/testing'; +import { ComponentFixture, TestBed } from '@angular/core/testing'; import { FooterComponent } from './footer.component'; @@ -6,7 +6,7 @@ describe('FooterComponent', () => { let component: FooterComponent; let fixture: ComponentFixture; - beforeEach(async(() => { + beforeEach((() => { TestBed.configureTestingModule({ declarations: [FooterComponent] }).compileComponents(); diff --git a/angular/projects/admin-nrpti/src/app/header/header.component.spec.ts b/angular/projects/admin-nrpti/src/app/header/header.component.spec.ts index 1519c18ec..73bbf9a18 100644 --- a/angular/projects/admin-nrpti/src/app/header/header.component.spec.ts +++ b/angular/projects/admin-nrpti/src/app/header/header.component.spec.ts @@ -1,4 +1,4 @@ -import { async, TestBed } from '@angular/core/testing'; +import { TestBed } from '@angular/core/testing'; import { HeaderComponent } from './header.component'; import { BrowserAnimationsModule } from '@angular/platform-browser/animations'; @@ -16,7 +16,7 @@ describe('HeaderComponent', () => { const mockRouter = jasmine.createSpyObj('Router', ['navigate', 'events']); - beforeEach(async(() => { + beforeEach((() => { TestBed.configureTestingModule({ imports: [BrowserAnimationsModule], declarations: [HeaderComponent], diff --git a/angular/projects/admin-nrpti/src/app/home/home.component.spec.ts b/angular/projects/admin-nrpti/src/app/home/home.component.spec.ts index aac0d233f..5bb6bf00d 100644 --- a/angular/projects/admin-nrpti/src/app/home/home.component.spec.ts +++ b/angular/projects/admin-nrpti/src/app/home/home.component.spec.ts @@ -1,4 +1,4 @@ -import { async, ComponentFixture, TestBed } from '@angular/core/testing'; +import { ComponentFixture, TestBed } from '@angular/core/testing'; import { HomeComponent } from './home.component'; import { RouterTestingModule } from '@angular/router/testing'; @@ -18,7 +18,7 @@ describe('HomeComponent', () => { } }; - beforeEach(async(() => { + beforeEach((() => { TestBed.configureTestingModule({ declarations: [HomeComponent], imports: [RouterTestingModule], diff --git a/angular/projects/admin-nrpti/src/app/import/import-csv/import-csv.component.spec.ts b/angular/projects/admin-nrpti/src/app/import/import-csv/import-csv.component.spec.ts index d227bcf75..308532a48 100644 --- a/angular/projects/admin-nrpti/src/app/import/import-csv/import-csv.component.spec.ts +++ b/angular/projects/admin-nrpti/src/app/import/import-csv/import-csv.component.spec.ts @@ -1,4 +1,4 @@ -import { TestBed, async } from '@angular/core/testing'; +import { TestBed } from '@angular/core/testing'; import { RouterTestingModule } from '@angular/router/testing'; import { HttpClientTestingModule } from '@angular/common/http/testing'; import { FormsModule } from '@angular/forms'; @@ -15,7 +15,7 @@ describe('ImportCSVComponent', () => { const spyFactoryService = jasmine.createSpyObj('FactoryService', ['startTask']); - beforeEach(async(() => { + beforeEach((() => { TestBed.configureTestingModule({ declarations: [ImportCSVComponent], imports: [RouterTestingModule, HttpClientTestingModule, FormsModule, CommonModule], @@ -23,14 +23,14 @@ describe('ImportCSVComponent', () => { }).compileComponents(); })); - it('should create', async(() => { + it('should create', (() => { const { component } = testBedHelper.createComponent(); expect(component).toBeTruthy(); })); describe('onFileDelete', () => { - it('does nothing if required file parameter is null', async(() => { + it('does nothing if required file parameter is null', (() => { const { component } = testBedHelper.createComponent(); // set initial component state @@ -46,7 +46,7 @@ describe('ImportCSVComponent', () => { expect(component.csvFileErrors).toEqual(['an error']); })); - it('does nothing if file parameter does not match any existing files', async(() => { + it('does nothing if file parameter does not match any existing files', (() => { const { component } = testBedHelper.createComponent(); // set initial component state @@ -64,7 +64,7 @@ describe('ImportCSVComponent', () => { expect(component.csvFileErrors).toEqual(['an error']); })); - it('removes the file, sets flags, resets errors when valid file provided', async(() => { + it('removes the file, sets flags, resets errors when valid file provided', (() => { const { component } = testBedHelper.createComponent(); // set initial component state @@ -83,7 +83,7 @@ describe('ImportCSVComponent', () => { }); describe('readCsvFile', () => { - it('does nothing if this.dataSourceType is null', async(() => { + it('does nothing if this.dataSourceType is null', (() => { const { component } = testBedHelper.createComponent(); // set initial component state @@ -101,7 +101,7 @@ describe('ImportCSVComponent', () => { expect(mockFileReader.readAsText).toHaveBeenCalledTimes(0); })); - it('does nothing if this.recordType is null', async(() => { + it('does nothing if this.recordType is null', (() => { const { component } = testBedHelper.createComponent(); // set initial component state @@ -119,7 +119,7 @@ describe('ImportCSVComponent', () => { expect(mockFileReader.readAsText).toHaveBeenCalledTimes(0); })); - it('does nothing if this.csvFiles[0] is null', async(() => { + it('does nothing if this.csvFiles[0] is null', (() => { const { component } = testBedHelper.createComponent(); // set initial component state @@ -137,7 +137,7 @@ describe('ImportCSVComponent', () => { expect(mockFileReader.readAsText).toHaveBeenCalledTimes(0); })); - it('calls validateCsvFile with file data', async(() => { + it('calls validateCsvFile with file data', (() => { const { component } = testBedHelper.createComponent(); // set initial component state @@ -163,7 +163,7 @@ describe('ImportCSVComponent', () => { }); describe('validateCsvFile', () => { - it('adds error to errors array if csvData is null', async(() => { + it('adds error to errors array if csvData is null', (() => { const { component } = testBedHelper.createComponent(); // set initial component state @@ -174,7 +174,7 @@ describe('ImportCSVComponent', () => { expect(component.csvFileErrors).toEqual(['Error reading csv file: fileA']); })); - it('parses the csv data and calls validation methods', async(() => { + it('parses the csv data and calls validation methods', (() => { const { component } = testBedHelper.createComponent(); // set initial component state @@ -200,7 +200,7 @@ describe('ImportCSVComponent', () => { expect(component.csvFileErrors).toEqual([]); })); - it('parses the csv data, calls validation methods and does not set csvFileValidated if errors found', async(() => { + it('parses the csv data, calls validation methods and does not set csvFileValidated if errors found', (() => { const { component } = testBedHelper.createComponent(); // set initial component state @@ -228,7 +228,7 @@ describe('ImportCSVComponent', () => { }); describe('validateRequiredHeaders', () => { - it('adds an error to the errors array if csvHeaderRowValuesArray is null', async(() => { + it('adds an error to the errors array if csvHeaderRowValuesArray is null', (() => { const { component } = testBedHelper.createComponent(); component.csvFiles = [new File([], 'fileA', {})]; @@ -238,7 +238,7 @@ describe('ImportCSVComponent', () => { expect(component.csvFileErrors).toEqual(['Error parsing csv file: fileA']); })); - it('adds an error to the errors array if csvHeaderRowValuesArray is empty', async(() => { + it('adds an error to the errors array if csvHeaderRowValuesArray is empty', (() => { const { component } = testBedHelper.createComponent(); component.csvFiles = [new File([], 'fileA', {})]; @@ -248,7 +248,7 @@ describe('ImportCSVComponent', () => { expect(component.csvFileErrors).toEqual(['Error parsing csv file: fileA']); })); - it('adds an error to the errors array if any required headers are missing', async(() => { + it('adds an error to the errors array if any required headers are missing', (() => { const { component } = testBedHelper.createComponent(); component.dataSourceType = 'cors-csv'; @@ -282,7 +282,7 @@ describe('ImportCSVComponent', () => { ]); })); - it('adds no errors to the errors array if no required headers are missing', async(() => { + it('adds no errors to the errors array if no required headers are missing', (() => { const { component } = testBedHelper.createComponent(); component.dataSourceType = 'cors-csv'; @@ -296,7 +296,7 @@ describe('ImportCSVComponent', () => { }); describe('validateFields', () => { - it('adds an error to the errors array if csvRows is null', async(() => { + it('adds an error to the errors array if csvRows is null', (() => { const { component } = testBedHelper.createComponent(); component.csvFiles = [new File([], 'fileA', {})]; @@ -306,7 +306,7 @@ describe('ImportCSVComponent', () => { expect(component.csvFileErrors).toEqual(['Error parsing csv file: fileA']); })); - it('adds an error to the errors array if csvRows is empty', async(() => { + it('adds an error to the errors array if csvRows is empty', (() => { const { component } = testBedHelper.createComponent(); component.csvFiles = [new File([], 'fileA', {})]; @@ -316,7 +316,7 @@ describe('ImportCSVComponent', () => { expect(component.csvFileErrors).toEqual(['Error parsing csv file: fileA']); })); - it('calls validation methods', async(() => { + it('calls validation methods', (() => { const { component } = testBedHelper.createComponent(); component.dataSourceType = 'cors-csv'; @@ -365,7 +365,7 @@ describe('ImportCSVComponent', () => { }); describe('validateRequiredFields', () => { - it('adds an error to the errors array if any required fields are missing', async(() => { + it('adds an error to the errors array if any required fields are missing', (() => { const { component } = testBedHelper.createComponent(); component.validateRequiredFields( @@ -378,7 +378,7 @@ describe('ImportCSVComponent', () => { expect(component.csvFileErrors).toEqual(['CSV row 1 is missing required fields: headerC,headerE']); })); - it('adds no errors to the errors array if no fields are required', async(() => { + it('adds no errors to the errors array if no fields are required', (() => { const { component } = testBedHelper.createComponent(); component.validateRequiredFields(['a', 'b', 'c', 'e'], [], ['headerA', 'headerB', 'headerC', 'headerE'], 1); @@ -386,7 +386,7 @@ describe('ImportCSVComponent', () => { expect(component.csvFileErrors).toEqual([]); })); - it('adds no errors to the errors array if no required fields are missing', async(() => { + it('adds no errors to the errors array if no required fields are missing', (() => { const { component } = testBedHelper.createComponent(); component.validateRequiredFields( @@ -401,7 +401,7 @@ describe('ImportCSVComponent', () => { }); describe('validateRequiredFormats', () => { - it('adds an error to the errors array if any fields are missing the required format', async(() => { + it('adds an error to the errors array if any fields are missing the required format', (() => { const { component } = testBedHelper.createComponent(); component.validateRequiredFormats( @@ -420,7 +420,7 @@ describe('ImportCSVComponent', () => { ]); })); - it('adds no errors to the errors array if no fields are missing the required format', async(() => { + it('adds no errors to the errors array if no fields are missing the required format', (() => { const { component } = testBedHelper.createComponent(); component.validateRequiredFormats( @@ -438,7 +438,7 @@ describe('ImportCSVComponent', () => { }); describe('transformFields', () => { - it('calls validation methods', async(() => { + it('calls validation methods', (() => { const { component } = testBedHelper.createComponent(); // mock component methods @@ -471,7 +471,7 @@ describe('ImportCSVComponent', () => { }); describe('transformDateFields', () => { - it('transforms dates to iso strings', async(() => { + it('transforms dates to iso strings', (() => { const { component } = testBedHelper.createComponent(); const transformedRow: string[] = component.transformDateFields( @@ -494,12 +494,12 @@ describe('ImportCSVComponent', () => { describe('startJob', () => { let factoryServiceSpy: jasmine.SpyObj; - beforeEach(async(() => { + beforeEach((() => { factoryServiceSpy = TestBed.get(FactoryService); factoryServiceSpy.startTask.calls.reset(); })); - it('does nothing if this.dataSourceType is null', async(async () => { + it('does nothing if this.dataSourceType is null', ( () => { const { component } = testBedHelper.createComponent(); // set initial component state @@ -507,12 +507,13 @@ describe('ImportCSVComponent', () => { component.recordType = 'recordType'; component.csvFiles = [new File([], 'fileA', {})]; - await component.startJob(); + component.startJob().then(() => { + expect(factoryServiceSpy.startTask).toHaveBeenCalledTimes(0); + }); - expect(factoryServiceSpy.startTask).toHaveBeenCalledTimes(0); })); - it('does nothing if this.recordType is null', async(async () => { + it('does nothing if this.recordType is null', ( () => { const { component } = testBedHelper.createComponent(); // set initial component state @@ -520,12 +521,12 @@ describe('ImportCSVComponent', () => { component.recordType = null; component.csvFiles = [new File([], 'fileA', {})]; - await component.startJob(); - - expect(factoryServiceSpy.startTask).toHaveBeenCalledTimes(0); + component.startJob().then(() => { + expect(factoryServiceSpy.startTask).toHaveBeenCalledTimes(0); + }); })); - it('does nothing if this.csvFiles is null or empty', async(async () => { + it('does nothing if this.csvFiles is null or empty', ( () => { const { component } = testBedHelper.createComponent(); // set initial component state @@ -533,12 +534,12 @@ describe('ImportCSVComponent', () => { component.recordType = 'recordType'; component.csvFiles = []; - await component.startJob(); - - expect(factoryServiceSpy.startTask).toHaveBeenCalledTimes(0); + component.startJob().then(() => { + expect(factoryServiceSpy.startTask).toHaveBeenCalledTimes(0); + }); })); - it('calls FactoryService.startTask', async(async () => { + it('calls FactoryService.startTask', ( () => { // set FactoryService mock behaviour factoryServiceSpy.startTask.and.returnValue(of()); @@ -555,9 +556,9 @@ describe('ImportCSVComponent', () => { // mock component methods component.onFileDelete = jasmine.createSpy('onFileDelete'); - await component.startJob(); - - expect(component.onFileDelete).toHaveBeenCalledWith(fileA); + component.startJob().then(() => { + expect(factoryServiceSpy.startTask).toHaveBeenCalledTimes(1); + }); expect(factoryServiceSpy.startTask).toHaveBeenCalledWith({ dataSourceType: 'dataSourceType', diff --git a/angular/projects/admin-nrpti/src/app/import/import-rows/import-table-rows.component.ts b/angular/projects/admin-nrpti/src/app/import/import-rows/import-table-rows.component.ts index 239f67f57..1f6b88bd6 100644 --- a/angular/projects/admin-nrpti/src/app/import/import-rows/import-table-rows.component.ts +++ b/angular/projects/admin-nrpti/src/app/import/import-rows/import-table-rows.component.ts @@ -17,7 +17,7 @@ export class ImportTableRowsComponent extends TableRowComponent implements OnIni super(); } - async ngOnInit() {} + ngOnInit() {} ngOnDestroy() { this.ngUnsubscribe.next(); diff --git a/angular/projects/admin-nrpti/src/app/mines/mines-add-edit/mines-add-edit.component.spec.ts b/angular/projects/admin-nrpti/src/app/mines/mines-add-edit/mines-add-edit.component.spec.ts index ccfb015fd..177681154 100644 --- a/angular/projects/admin-nrpti/src/app/mines/mines-add-edit/mines-add-edit.component.spec.ts +++ b/angular/projects/admin-nrpti/src/app/mines/mines-add-edit/mines-add-edit.component.spec.ts @@ -1,5 +1,5 @@ import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core'; -import { async, TestBed } from '@angular/core/testing'; +import { TestBed } from '@angular/core/testing'; import { FormControl, FormGroup, FormsModule, ReactiveFormsModule, FormArray } from '@angular/forms'; import { ActivatedRoute, Router } from '@angular/router'; import { RouterTestingModule } from '@angular/router/testing'; @@ -25,7 +25,7 @@ describe('MinesAddEditComponent', () => { } }; - beforeEach(async(() => { + beforeEach((() => { TestBed.configureTestingModule({ imports: [ RouterTestingModule, diff --git a/angular/projects/admin-nrpti/src/app/mines/mines-collection-detail/mines-collection-detail-record-row/mines-collection-detail-record-row.component.html b/angular/projects/admin-nrpti/src/app/mines/mines-collection-detail/mines-collection-detail-record-row/mines-collection-detail-record-row.component.html index 2e5823974..f8fff06d7 100644 --- a/angular/projects/admin-nrpti/src/app/mines/mines-collection-detail/mines-collection-detail-record-row/mines-collection-detail-record-row.component.html +++ b/angular/projects/admin-nrpti/src/app/mines/mines-collection-detail/mines-collection-detail-record-row/mines-collection-detail-record-row.component.html @@ -1,5 +1,5 @@ {{ rowData.recordName || '-' }} -{{ rowData.sourceSystemRef || '-' }} +{{ rowData && rowData.sourceSystemRef || '-' }} {{ (rowData.dateIssued && formatDate(rowData.dateIssued)) || '-' }}
diff --git a/angular/projects/admin-nrpti/src/app/mines/mines-collection-detail/mines-collection-detail-record-row/mines-collection-detail-record-row.component.spec.ts b/angular/projects/admin-nrpti/src/app/mines/mines-collection-detail/mines-collection-detail-record-row/mines-collection-detail-record-row.component.spec.ts index 358a374c0..17b7ed650 100644 --- a/angular/projects/admin-nrpti/src/app/mines/mines-collection-detail/mines-collection-detail-record-row/mines-collection-detail-record-row.component.spec.ts +++ b/angular/projects/admin-nrpti/src/app/mines/mines-collection-detail/mines-collection-detail-record-row/mines-collection-detail-record-row.component.spec.ts @@ -1,4 +1,4 @@ -import { async, TestBed } from '@angular/core/testing'; +import { TestBed } from '@angular/core/testing'; import { Router } from '@angular/router'; import { RouterTestingModule } from '@angular/router/testing'; import { MinesCollectionRecordTableRowComponent } from './mines-collection-detail-record-row.component'; @@ -14,7 +14,7 @@ describe('MinesTableRowComponent', () => { // component constructor mocks const mockRouter = jasmine.createSpyObj('Router', ['navigate']); - beforeEach(async(() => { + beforeEach((() => { TestBed.configureTestingModule({ imports: [RouterTestingModule, CommonModule, GlobalModule], declarations: [MinesCollectionRecordTableRowComponent], diff --git a/angular/projects/admin-nrpti/src/app/mines/mines-collection-detail/mines-collection-detail.component.spec.ts b/angular/projects/admin-nrpti/src/app/mines/mines-collection-detail/mines-collection-detail.component.spec.ts index a5b0ac941..151c863f7 100644 --- a/angular/projects/admin-nrpti/src/app/mines/mines-collection-detail/mines-collection-detail.component.spec.ts +++ b/angular/projects/admin-nrpti/src/app/mines/mines-collection-detail/mines-collection-detail.component.spec.ts @@ -1,4 +1,4 @@ -import { async, TestBed } from '@angular/core/testing'; +import { TestBed } from '@angular/core/testing'; import { MinesCollectionDetailComponent } from './mines-collection-detail.component'; import { TestBedHelper, ActivatedRouteStub } from '../../../../../common/src/app/spec/spec-utils'; import { RouterTestingModule } from '@angular/router/testing'; @@ -17,7 +17,7 @@ describe('MinesCollectionDetailComponent', () => { const mockRouter = jasmine.createSpyObj('Router', ['navigate']); const mockActivatedRoute = new ActivatedRouteStub(); - beforeEach(async(() => { + beforeEach((() => { TestBed.configureTestingModule({ imports: [ RouterTestingModule, diff --git a/angular/projects/admin-nrpti/src/app/mines/mines-collections-add-edit/mines-collections-add-edit.component.spec.ts b/angular/projects/admin-nrpti/src/app/mines/mines-collections-add-edit/mines-collections-add-edit.component.spec.ts index b830c73a2..92f23259d 100644 --- a/angular/projects/admin-nrpti/src/app/mines/mines-collections-add-edit/mines-collections-add-edit.component.spec.ts +++ b/angular/projects/admin-nrpti/src/app/mines/mines-collections-add-edit/mines-collections-add-edit.component.spec.ts @@ -1,4 +1,4 @@ -import { async, TestBed } from '@angular/core/testing'; +import { TestBed } from '@angular/core/testing'; import { FormsModule, ReactiveFormsModule } from '@angular/forms'; import { MatSlideToggleModule } from '@angular/material'; import { ActivatedRoute, Router } from '@angular/router'; @@ -34,7 +34,7 @@ describe('MinesCollectionsAddEditComponent', () => { } }; - beforeEach(async(() => { + beforeEach((() => { TestBed.configureTestingModule({ imports: [ RouterTestingModule, @@ -61,7 +61,7 @@ describe('MinesCollectionsAddEditComponent', () => { }).compileComponents(); })); - it('should create', async(() => { + it('should create', (() => { const { component } = testBedHelper.createComponent(); expect(component).toBeTruthy(); diff --git a/angular/projects/admin-nrpti/src/app/mines/mines-collections-list-resolver.spec.ts b/angular/projects/admin-nrpti/src/app/mines/mines-collections-list-resolver.spec.ts index 9f63fbad8..2a359f8e3 100644 --- a/angular/projects/admin-nrpti/src/app/mines/mines-collections-list-resolver.spec.ts +++ b/angular/projects/admin-nrpti/src/app/mines/mines-collections-list-resolver.spec.ts @@ -1,4 +1,4 @@ -import { async, TestBed } from '@angular/core/testing'; +import { TestBed } from '@angular/core/testing'; import { ActivatedRouteSnapshot } from '@angular/router'; import { TableObject, TableTemplateUtils } from 'nrpti-angular-components'; import { of } from 'rxjs'; @@ -11,7 +11,7 @@ describe('MinesCollectionsListResolver', () => { 'updateTableObjectWithUrlParams' ]); - beforeEach(async(() => { + beforeEach((() => { TestBed.configureTestingModule({ providers: [ { provide: FactoryService, useValue: spyFactoryService }, @@ -20,7 +20,7 @@ describe('MinesCollectionsListResolver', () => { }).compileComponents(); })); - it('should create', async(() => { + it('should create', (() => { const factoryService = TestBed.get(FactoryService); const tableTemplateUtils = TestBed.get(TableTemplateUtils); @@ -52,7 +52,7 @@ describe('MinesCollectionsListResolver', () => { queryParamMap: null }; - beforeAll(async(() => { + beforeAll((() => { factoryServiceSpy = TestBed.get(FactoryService); tableTemplateUtilsSpy = TestBed.get(TableTemplateUtils); @@ -62,7 +62,7 @@ describe('MinesCollectionsListResolver', () => { const minesCollectionsListResolver = new MinesCollectionsListResolver(factoryServiceSpy, tableTemplateUtilsSpy); - minesCollectionsListResolver.resolve(activatedRouteSnapshot); + minesCollectionsListResolver.resolve(activatedRouteSnapshot); })); it('calls tableTemplateUtils.updateTableObjectWithUrlParams', () => { diff --git a/angular/projects/admin-nrpti/src/app/mines/mines-collections-list/mines-collections-list.component.spec.ts b/angular/projects/admin-nrpti/src/app/mines/mines-collections-list/mines-collections-list.component.spec.ts index 82ea4a8a0..c007c84e7 100644 --- a/angular/projects/admin-nrpti/src/app/mines/mines-collections-list/mines-collections-list.component.spec.ts +++ b/angular/projects/admin-nrpti/src/app/mines/mines-collections-list/mines-collections-list.component.spec.ts @@ -1,6 +1,6 @@ // TODO: see if test can be fixed. Using routerLink creates errors with blank paths. See bug: https://github.com/angular/angular/issues/27674 -// import { async, TestBed } from '@angular/core/testing'; +// import { TestBed } from '@angular/core/testing'; // import { FormsModule, ReactiveFormsModule } from '@angular/forms'; // import { ActivatedRoute, Router } from '@angular/router'; // import { RouterTestingModule } from '@angular/router/testing'; @@ -25,7 +25,7 @@ // setLoadingState: () => {} // }; -// beforeEach(async(() => { +// beforeEach((() => { // TestBed.configureTestingModule({ // imports: [ // RouterTestingModule, diff --git a/angular/projects/admin-nrpti/src/app/mines/mines-collections-rows/mines-collections-table-row.component.spec.ts b/angular/projects/admin-nrpti/src/app/mines/mines-collections-rows/mines-collections-table-row.component.spec.ts index 3ad9bb4c6..100eb3091 100644 --- a/angular/projects/admin-nrpti/src/app/mines/mines-collections-rows/mines-collections-table-row.component.spec.ts +++ b/angular/projects/admin-nrpti/src/app/mines/mines-collections-rows/mines-collections-table-row.component.spec.ts @@ -1,4 +1,4 @@ -import { async, TestBed } from '@angular/core/testing'; +import { TestBed } from '@angular/core/testing'; import { Router, ActivatedRoute } from '@angular/router'; import { RouterTestingModule } from '@angular/router/testing'; import { DialogService } from 'ng2-bootstrap-modal'; @@ -15,7 +15,7 @@ describe('MinesCollectionsTableRowComponent', () => { const mockRouter = jasmine.createSpyObj('Router', ['navigate']); const mockActivatedRoute = new ActivatedRouteStub(); - beforeEach(async(() => { + beforeEach((() => { TestBed.configureTestingModule({ imports: [RouterTestingModule, SharedModule, CommonModule, GlobalModule], declarations: [MinesCollectionsTableRowComponent], diff --git a/angular/projects/admin-nrpti/src/app/mines/mines-detail/mines-detail.component.spec.ts b/angular/projects/admin-nrpti/src/app/mines/mines-detail/mines-detail.component.spec.ts index 3c70be570..fb5af44d6 100644 --- a/angular/projects/admin-nrpti/src/app/mines/mines-detail/mines-detail.component.spec.ts +++ b/angular/projects/admin-nrpti/src/app/mines/mines-detail/mines-detail.component.spec.ts @@ -1,4 +1,4 @@ -import { async, TestBed } from '@angular/core/testing'; +import { TestBed } from '@angular/core/testing'; import { MinesDetailComponent } from './mines-detail.component'; import { TestBedHelper, ActivatedRouteStub } from '../../../../../common/src/app/spec/spec-utils'; import { RouterTestingModule } from '@angular/router/testing'; @@ -17,7 +17,7 @@ describe('MinesDetailComponent', () => { const mockRouter = jasmine.createSpyObj('Router', ['navigate']); const mockActivatedRoute = new ActivatedRouteStub(); - beforeEach(async(() => { + beforeEach((() => { TestBed.configureTestingModule({ imports: [ RouterTestingModule, diff --git a/angular/projects/admin-nrpti/src/app/mines/mines-list-resolver.spec.ts b/angular/projects/admin-nrpti/src/app/mines/mines-list-resolver.spec.ts index 247da70a2..d8edcf3b8 100644 --- a/angular/projects/admin-nrpti/src/app/mines/mines-list-resolver.spec.ts +++ b/angular/projects/admin-nrpti/src/app/mines/mines-list-resolver.spec.ts @@ -1,4 +1,4 @@ -import { TestBed, async } from '@angular/core/testing'; +import { TestBed } from '@angular/core/testing'; import { FactoryService } from '../services/factory.service'; import { TableTemplateUtils } from 'nrpti-angular-components'; import { MinesListResolver } from './mines-list-resolver'; @@ -12,7 +12,7 @@ describe('MinesListResolver', () => { 'updateTableObjectWithUrlParams' ]); - beforeEach(async(() => { + beforeEach((() => { TestBed.configureTestingModule({ providers: [ { provide: FactoryService, useValue: spyFactoryService }, @@ -21,7 +21,7 @@ describe('MinesListResolver', () => { }).compileComponents(); })); - it('should create', async(() => { + it('should create', (() => { const factoryService = TestBed.get(FactoryService); const tableTemplateUtils = TestBed.get(TableTemplateUtils); @@ -53,7 +53,7 @@ describe('MinesListResolver', () => { queryParamMap: null }; - beforeAll(async(() => { + beforeAll((() => { factoryServiceSpy = TestBed.get(FactoryService); tableTemplateUtilsSpy = TestBed.get(TableTemplateUtils); diff --git a/angular/projects/admin-nrpti/src/app/mines/mines-list/mines-list.component.spec.ts b/angular/projects/admin-nrpti/src/app/mines/mines-list/mines-list.component.spec.ts index 93f29e79c..853ed5d7a 100644 --- a/angular/projects/admin-nrpti/src/app/mines/mines-list/mines-list.component.spec.ts +++ b/angular/projects/admin-nrpti/src/app/mines/mines-list/mines-list.component.spec.ts @@ -1,4 +1,4 @@ -import { async, TestBed } from '@angular/core/testing'; +import { TestBed } from '@angular/core/testing'; import { Router, ActivatedRoute } from '@angular/router'; import { RouterTestingModule } from '@angular/router/testing'; import { NgxPaginationModule } from 'ngx-pagination'; @@ -22,7 +22,7 @@ describe('MinesListComponent', () => { setLoadingState: () => {} }; - beforeEach(async(() => { + beforeEach((() => { TestBed.configureTestingModule({ imports: [RouterTestingModule, CommonModule, GlobalModule, NgxPaginationModule, FormsModule], declarations: [MinesListComponent], diff --git a/angular/projects/admin-nrpti/src/app/mines/mines-records-detail/mines-records-detail.component.spec.ts b/angular/projects/admin-nrpti/src/app/mines/mines-records-detail/mines-records-detail.component.spec.ts index f8c942c69..b191eafd9 100644 --- a/angular/projects/admin-nrpti/src/app/mines/mines-records-detail/mines-records-detail.component.spec.ts +++ b/angular/projects/admin-nrpti/src/app/mines/mines-records-detail/mines-records-detail.component.spec.ts @@ -1,4 +1,4 @@ -import { async, TestBed } from '@angular/core/testing'; +import { TestBed } from '@angular/core/testing'; import { MatSlideToggleModule } from '@angular/material'; import { MinesRecordDetailComponent } from './mines-records-detail.component'; import { TestBedHelper } from '../../../../../common/src/app/spec/spec-utils'; @@ -11,7 +11,7 @@ describe('MinesRecordDetailComponent', () => { const testBedHelper = new TestBedHelper(MinesRecordDetailComponent); - beforeEach(async(() => { + beforeEach((() => { TestBed.configureTestingModule({ imports: [RouterTestingModule, GlobalModule, CommonModule, MatSlideToggleModule], declarations: [MinesRecordDetailComponent], diff --git a/angular/projects/admin-nrpti/src/app/mines/mines-records-list-resolver.spec.ts b/angular/projects/admin-nrpti/src/app/mines/mines-records-list-resolver.spec.ts index c835e98f5..514d49793 100644 --- a/angular/projects/admin-nrpti/src/app/mines/mines-records-list-resolver.spec.ts +++ b/angular/projects/admin-nrpti/src/app/mines/mines-records-list-resolver.spec.ts @@ -1,4 +1,4 @@ -import { async, TestBed } from '@angular/core/testing'; +import { TestBed } from '@angular/core/testing'; import { ActivatedRouteSnapshot } from '@angular/router'; import { TableObject, TableTemplateUtils } from 'nrpti-angular-components'; import { of } from 'rxjs'; @@ -11,7 +11,7 @@ describe('MinesRecordsListResolver', () => { 'updateTableObjectWithUrlParams' ]); - beforeEach(async(() => { + beforeEach((() => { TestBed.configureTestingModule({ providers: [ { provide: FactoryService, useValue: spyFactoryService }, @@ -20,7 +20,7 @@ describe('MinesRecordsListResolver', () => { }).compileComponents(); })); - it('should create', async(() => { + it('should create', (() => { const factoryService = TestBed.get(FactoryService); const tableTemplateUtils = TestBed.get(TableTemplateUtils); @@ -52,7 +52,7 @@ describe('MinesRecordsListResolver', () => { queryParamMap: null }; - beforeAll(async(() => { + beforeAll((() => { factoryServiceSpy = TestBed.get(FactoryService); tableTemplateUtilsSpy = TestBed.get(TableTemplateUtils); @@ -130,7 +130,7 @@ describe('MinesRecordsListResolver', () => { queryParamMap: null }; - beforeAll(async(() => { + beforeAll((() => { factoryServiceSpy = TestBed.get(FactoryService); tableTemplateUtilsSpy = TestBed.get(TableTemplateUtils); diff --git a/angular/projects/admin-nrpti/src/app/mines/mines-records-list/mines-records-list.component.spec.ts b/angular/projects/admin-nrpti/src/app/mines/mines-records-list/mines-records-list.component.spec.ts index c9818d429..ee0977fec 100644 --- a/angular/projects/admin-nrpti/src/app/mines/mines-records-list/mines-records-list.component.spec.ts +++ b/angular/projects/admin-nrpti/src/app/mines/mines-records-list/mines-records-list.component.spec.ts @@ -1,6 +1,6 @@ // TODO: see if test can be fixed. Using routerLink creates errors with blank paths. See bug: https://github.com/angular/angular/issues/27674 -// import { async, TestBed } from '@angular/core/testing'; +// import { TestBed } from '@angular/core/testing'; // import { FormsModule, ReactiveFormsModule } from '@angular/forms'; // import { ActivatedRoute } from '@angular/router'; // import { RouterTestingModule } from '@angular/router/testing'; @@ -25,7 +25,7 @@ // setLoadingState: () => {} // }; -// beforeEach(async(() => { +// beforeEach((() => { // TestBed.configureTestingModule({ // imports: [ // RouterTestingModule, diff --git a/angular/projects/admin-nrpti/src/app/mines/mines-records-rows/mines-records-table-row.component.spec.ts b/angular/projects/admin-nrpti/src/app/mines/mines-records-rows/mines-records-table-row.component.spec.ts index f1b72014e..64edb733f 100644 --- a/angular/projects/admin-nrpti/src/app/mines/mines-records-rows/mines-records-table-row.component.spec.ts +++ b/angular/projects/admin-nrpti/src/app/mines/mines-records-rows/mines-records-table-row.component.spec.ts @@ -1,7 +1,7 @@ // TODO: see if test can be fixed. Using routerLink creates errors with blank paths. See bug: https://github.com/angular/angular/issues/27674 // TODO: see if test can be fixed. Using routerLink creates errors with blank paths. See bug: https://github.com/angular/angular/issues/27674 -// import { async, TestBed } from '@angular/core/testing'; +// import { TestBed } from '@angular/core/testing'; // import { Router } from '@angular/router'; // import { RouterTestingModule } from '@angular/router/testing'; // import { MinesRecordsTableRowComponent } from './mines-records-table-row.component'; @@ -16,7 +16,7 @@ // // component constructor mocks // const mockRouter = jasmine.createSpyObj('Router', ['navigate']); -// beforeEach(async(() => { +// beforeEach((() => { // TestBed.configureTestingModule({ // imports: [RouterTestingModule, SharedModule, CommonModule, GlobalModule], // declarations: [MinesRecordsTableRowComponent], diff --git a/angular/projects/admin-nrpti/src/app/mines/mines-rows/mines-table-row.component.spec.ts b/angular/projects/admin-nrpti/src/app/mines/mines-rows/mines-table-row.component.spec.ts index d729bc47a..ad221bdf6 100644 --- a/angular/projects/admin-nrpti/src/app/mines/mines-rows/mines-table-row.component.spec.ts +++ b/angular/projects/admin-nrpti/src/app/mines/mines-rows/mines-table-row.component.spec.ts @@ -1,4 +1,4 @@ -import { async, TestBed } from '@angular/core/testing'; +import { TestBed } from '@angular/core/testing'; import { Router } from '@angular/router'; import { RouterTestingModule } from '@angular/router/testing'; import { MinesTableRowComponent } from './mines-table-row.component'; @@ -12,7 +12,7 @@ describe('MinesTableRowComponent', () => { // component constructor mocks const mockRouter = jasmine.createSpyObj('Router', ['navigate']); - beforeEach(async(() => { + beforeEach((() => { TestBed.configureTestingModule({ imports: [RouterTestingModule, CommonModule, GlobalModule], declarations: [MinesTableRowComponent], diff --git a/angular/projects/admin-nrpti/src/app/records/administrative-penalties/administrative-penalty-add-edit/administrative-penalty-add-edit.component.spec.ts b/angular/projects/admin-nrpti/src/app/records/administrative-penalties/administrative-penalty-add-edit/administrative-penalty-add-edit.component.spec.ts index ae00d1fe2..58effe715 100644 --- a/angular/projects/admin-nrpti/src/app/records/administrative-penalties/administrative-penalty-add-edit/administrative-penalty-add-edit.component.spec.ts +++ b/angular/projects/admin-nrpti/src/app/records/administrative-penalties/administrative-penalty-add-edit/administrative-penalty-add-edit.component.spec.ts @@ -1,11 +1,11 @@ -import { async, TestBed } from '@angular/core/testing'; +import { TestBed } from '@angular/core/testing'; import { NgbModule } from '@ng-bootstrap/ng-bootstrap'; import { FormsModule, ReactiveFormsModule } from '@angular/forms'; import { AdministrativePenaltyAddEditComponent } from './administrative-penalty-add-edit.component'; import { TestBedHelper, ActivatedRouteStub } from '../../../../../../common/src/app/spec/spec-utils'; import { RouterTestingModule } from '@angular/router/testing'; import { Router, ActivatedRoute } from '@angular/router'; -import { GlobalModule } from 'nrpti-angular-components'; +import { GlobalModule, StoreService } from 'nrpti-angular-components'; import { NgxPaginationModule } from 'ngx-pagination'; import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core'; import { Utils } from 'nrpti-angular-components'; @@ -14,12 +14,14 @@ import { CommonModule } from '../../../../../../common/src/app/common.module'; import { MatSlideToggleModule } from '@angular/material'; import { LoadingScreenService } from 'nrpti-angular-components'; import { FactoryService } from '../../../services/factory.service'; +import { EventEmitter } from '@angular/core'; describe('AdministrativePenaltyAddEditComponent', () => { const testBedHelper = new TestBedHelper(AdministrativePenaltyAddEditComponent); - const mockFactoryService = jasmine.createSpyObj('FactoryService', ['userInLngRole', 'userInNrcedRole']); + const mockFactoryService = jasmine.createSpyObj('FactoryService', ['userInLngRole', 'userInBcmiRole', 'userInNrcedRole']); mockFactoryService.userInLngRole.and.returnValue(true); + mockFactoryService.userInBcmiRole.and.returnValue(true); mockFactoryService.userInNrcedRole.and.returnValue(true); // component constructor mocks @@ -27,6 +29,11 @@ describe('AdministrativePenaltyAddEditComponent', () => { const mockRouter = jasmine.createSpyObj('Router', ['navigate']); const mockActivatedRoute = new ActivatedRouteStub(); + const mockStoreService = { + getItem: () => { }, + stateChange: new EventEmitter() + }; + const mockLoadingScreenService = { isLoading: false, setLoadingState: () => { @@ -34,7 +41,7 @@ describe('AdministrativePenaltyAddEditComponent', () => { } }; - beforeEach(async(() => { + beforeEach((() => { TestBed.configureTestingModule({ imports: [ RouterTestingModule, @@ -51,6 +58,7 @@ describe('AdministrativePenaltyAddEditComponent', () => { Utils, RecordUtils, { provide: LoadingScreenService, useValue: mockLoadingScreenService }, + { provide: StoreService, useValue: mockStoreService }, { provide: Location, useValue: mockLocation }, { provide: Router, useValue: mockRouter }, { provide: ActivatedRoute, useValue: mockActivatedRoute }, diff --git a/angular/projects/admin-nrpti/src/app/records/administrative-penalties/administrative-penalty-detail/administrative-penalty-detail.component.html b/angular/projects/admin-nrpti/src/app/records/administrative-penalties/administrative-penalty-detail/administrative-penalty-detail.component.html index a92bc603b..3ce93c16f 100644 --- a/angular/projects/admin-nrpti/src/app/records/administrative-penalties/administrative-penalty-detail/administrative-penalty-detail.component.html +++ b/angular/projects/admin-nrpti/src/app/records/administrative-penalties/administrative-penalty-detail/administrative-penalty-detail.component.html @@ -52,7 +52,7 @@

Shared Data [Master]

- {{ (data && data._master.sourceSystemRef) || '-' }} + {{ (data && data._master && data._master.sourceSystemRef) || '-' }}
diff --git a/angular/projects/admin-nrpti/src/app/records/administrative-penalties/administrative-penalty-detail/administrative-penalty-detail.component.spec.ts b/angular/projects/admin-nrpti/src/app/records/administrative-penalties/administrative-penalty-detail/administrative-penalty-detail.component.spec.ts index c25c06b2f..b545c55ae 100644 --- a/angular/projects/admin-nrpti/src/app/records/administrative-penalties/administrative-penalty-detail/administrative-penalty-detail.component.spec.ts +++ b/angular/projects/admin-nrpti/src/app/records/administrative-penalties/administrative-penalty-detail/administrative-penalty-detail.component.spec.ts @@ -1,15 +1,16 @@ -import { async, TestBed } from '@angular/core/testing'; +import { TestBed } from '@angular/core/testing'; import { AdministrativePenaltyDetailComponent } from './administrative-penalty-detail.component'; import { TestBedHelper, ActivatedRouteStub } from '../../../../../../common/src/app/spec/spec-utils'; import { RouterTestingModule } from '@angular/router/testing'; import { Router, ActivatedRoute } from '@angular/router'; -import { GlobalModule } from 'nrpti-angular-components'; +import { GlobalModule, StoreService } from 'nrpti-angular-components'; import { RecordDetailDirective } from '../../utils/record-detail.directive'; import { DatePipe } from '@angular/common'; import { CommonModule } from '../../../../../../common/src/app/common.module'; import { DocumentAuthenticatedReadOnlyComponent } from '../../../documents/document-authenticated-read-only/document-authenticated-read-only.component'; import { S3SignedUrlAnchorComponent } from '../../../documents/s3-signed-url-anchor/s3-signed-url-anchor.component'; import { FactoryService } from '../../../services/factory.service'; +import { EventEmitter } from '@angular/core'; describe('AdministrativePenaltyDetailComponent', () => { const testBedHelper = new TestBedHelper(AdministrativePenaltyDetailComponent); @@ -18,11 +19,17 @@ describe('AdministrativePenaltyDetailComponent', () => { const mockRouter = jasmine.createSpyObj('Router', ['navigate']); const mockActivatedRoute = new ActivatedRouteStub(); - const mockFactoryService = jasmine.createSpyObj('FactoryService', ['userInLngRole', 'userInNrcedRole']); + const mockFactoryService = jasmine.createSpyObj('FactoryService', ['userInLngRole', 'userInBcmiRole', 'userInNrcedRole']); mockFactoryService.userInLngRole.and.returnValue(true); + mockFactoryService.userInBcmiRole.and.returnValue(true); mockFactoryService.userInNrcedRole.and.returnValue(true); - beforeEach(async(() => { + const mockStoreService = { + getItem: () => { }, + stateChange: new EventEmitter() + }; + + beforeEach((() => { TestBed.configureTestingModule({ imports: [RouterTestingModule, GlobalModule, CommonModule], declarations: [ @@ -34,6 +41,7 @@ describe('AdministrativePenaltyDetailComponent', () => { providers: [ DatePipe, { provide: Router, useValue: mockRouter }, + { provide: StoreService, useValue: mockStoreService }, { provide: ActivatedRoute, useValue: mockActivatedRoute }, { provide: FactoryService, useValue: mockFactoryService } ] diff --git a/angular/projects/admin-nrpti/src/app/records/administrative-penalties/administrative-penalty-lng-detail/administrative-penalty-lng-detail.component.spec.ts b/angular/projects/admin-nrpti/src/app/records/administrative-penalties/administrative-penalty-lng-detail/administrative-penalty-lng-detail.component.spec.ts index 19eef4386..90851f4e7 100644 --- a/angular/projects/admin-nrpti/src/app/records/administrative-penalties/administrative-penalty-lng-detail/administrative-penalty-lng-detail.component.spec.ts +++ b/angular/projects/admin-nrpti/src/app/records/administrative-penalties/administrative-penalty-lng-detail/administrative-penalty-lng-detail.component.spec.ts @@ -1,11 +1,12 @@ -import { async, TestBed } from '@angular/core/testing'; +import { TestBed } from '@angular/core/testing'; import { AdministrativePenaltyLNGDetailComponent } from './administrative-penalty-lng-detail.component'; import { TestBedHelper, ActivatedRouteStub } from '../../../../../../common/src/app/spec/spec-utils'; import { RouterTestingModule } from '@angular/router/testing'; import { Router, ActivatedRoute } from '@angular/router'; -import { GlobalModule } from 'nrpti-angular-components'; +import { GlobalModule, StoreService } from 'nrpti-angular-components'; import { DatePipe } from '@angular/common'; import { FactoryService } from '../../../services/factory.service'; +import { EventEmitter } from '@angular/core'; describe('AdministrativePenaltyLNGDetailComponent', () => { const testBedHelper = new TestBedHelper( @@ -16,16 +17,24 @@ describe('AdministrativePenaltyLNGDetailComponent', () => { const mockRouter = jasmine.createSpyObj('Router', ['navigate']); const mockActivatedRoute = new ActivatedRouteStub(); - const mockFactoryService = jasmine.createSpyObj('FactoryService', ['userInLngRole']); + const mockFactoryService = jasmine.createSpyObj('FactoryService', ['userInLngRole', 'userInBcmiRole', 'userInNrcedRole']); mockFactoryService.userInLngRole.and.returnValue(true); + mockFactoryService.userInBcmiRole.and.returnValue(true); + mockFactoryService.userInNrcedRole.and.returnValue(true); - beforeEach(async(() => { + const mockStoreService = { + getItem: () => { }, + stateChange: new EventEmitter() + }; + + beforeEach((() => { TestBed.configureTestingModule({ imports: [RouterTestingModule, GlobalModule], declarations: [AdministrativePenaltyLNGDetailComponent], providers: [ DatePipe, { provide: Router, useValue: mockRouter }, + { provide: StoreService, useValue: mockStoreService }, { provide: ActivatedRoute, useValue: mockActivatedRoute }, { provide: FactoryService, useValue: mockFactoryService } ] diff --git a/angular/projects/admin-nrpti/src/app/records/administrative-penalties/administrative-penalty-nrced-detail/administrative-penalty-nrced-detail.component.spec.ts b/angular/projects/admin-nrpti/src/app/records/administrative-penalties/administrative-penalty-nrced-detail/administrative-penalty-nrced-detail.component.spec.ts index 4643a8c76..b4cf12152 100644 --- a/angular/projects/admin-nrpti/src/app/records/administrative-penalties/administrative-penalty-nrced-detail/administrative-penalty-nrced-detail.component.spec.ts +++ b/angular/projects/admin-nrpti/src/app/records/administrative-penalties/administrative-penalty-nrced-detail/administrative-penalty-nrced-detail.component.spec.ts @@ -1,25 +1,33 @@ -import { async, TestBed } from '@angular/core/testing'; +import { TestBed } from '@angular/core/testing'; import { AdministrativePenaltyNRCEDDetailComponent } from './administrative-penalty-nrced-detail.component'; import { TestBedHelper, ActivatedRouteStub } from '../../../../../../common/src/app/spec/spec-utils'; import { RouterTestingModule } from '@angular/router/testing'; import { Router, ActivatedRoute } from '@angular/router'; -import { GlobalModule } from 'nrpti-angular-components'; +import { GlobalModule, StoreService } from 'nrpti-angular-components'; import { DatePipe } from '@angular/common'; import { FactoryService } from '../../../services/factory.service'; +import { EventEmitter } from '@angular/core'; describe('AdministrativePenaltyNRCEDDetailComponent', () => { const testBedHelper = new TestBedHelper( AdministrativePenaltyNRCEDDetailComponent ); - const mockFactoryService = jasmine.createSpyObj('FactoryService', ['userInNrcedRole']); + const mockFactoryService = jasmine.createSpyObj('FactoryService', ['userInLngRole', 'userInBcmiRole', 'userInNrcedRole']); + mockFactoryService.userInLngRole.and.returnValue(true); + mockFactoryService.userInBcmiRole.and.returnValue(true); mockFactoryService.userInNrcedRole.and.returnValue(true); // component constructor mocks const mockRouter = jasmine.createSpyObj('Router', ['navigate']); const mockActivatedRoute = new ActivatedRouteStub(); - beforeEach(async(() => { + const mockStoreService = { + getItem: () => { }, + stateChange: new EventEmitter() + }; + + beforeEach((() => { TestBed.configureTestingModule({ imports: [RouterTestingModule, GlobalModule], @@ -27,6 +35,7 @@ describe('AdministrativePenaltyNRCEDDetailComponent', () => { providers: [ DatePipe, { provide: Router, useValue: mockRouter }, + { provide: StoreService, useValue: mockStoreService }, { provide: ActivatedRoute, useValue: mockActivatedRoute }, { provide: FactoryService, useValue: mockFactoryService } ] diff --git a/angular/projects/admin-nrpti/src/app/records/administrative-sanctions/administrative-sanction-add-edit/administrative-sanction-add-edit.component.spec.ts b/angular/projects/admin-nrpti/src/app/records/administrative-sanctions/administrative-sanction-add-edit/administrative-sanction-add-edit.component.spec.ts index c692a3c97..e0453df86 100644 --- a/angular/projects/admin-nrpti/src/app/records/administrative-sanctions/administrative-sanction-add-edit/administrative-sanction-add-edit.component.spec.ts +++ b/angular/projects/admin-nrpti/src/app/records/administrative-sanctions/administrative-sanction-add-edit/administrative-sanction-add-edit.component.spec.ts @@ -1,11 +1,11 @@ -import { async, TestBed } from '@angular/core/testing'; +import { TestBed } from '@angular/core/testing'; import { NgbModule } from '@ng-bootstrap/ng-bootstrap'; import { FormsModule, ReactiveFormsModule } from '@angular/forms'; import { AdministrativeSanctionAddEditComponent } from './administrative-sanction-add-edit.component'; import { TestBedHelper, ActivatedRouteStub } from '../../../../../../common/src/app/spec/spec-utils'; import { RouterTestingModule } from '@angular/router/testing'; import { Router, ActivatedRoute } from '@angular/router'; -import { GlobalModule } from 'nrpti-angular-components'; +import { GlobalModule, StoreService } from 'nrpti-angular-components'; import { NgxPaginationModule } from 'ngx-pagination'; import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core'; import { Utils } from 'nrpti-angular-components'; @@ -14,6 +14,7 @@ import { CommonModule } from '../../../../../../common/src/app/common.module'; import { MatSlideToggleModule } from '@angular/material'; import { LoadingScreenService } from 'nrpti-angular-components'; import { FactoryService } from '../../../services/factory.service'; +import { EventEmitter } from '@angular/core'; describe('AdministrativeSanctionAddEditComponent', () => { const testBedHelper = new TestBedHelper( @@ -24,8 +25,9 @@ describe('AdministrativeSanctionAddEditComponent', () => { const mockLocation = jasmine.createSpyObj('Location', ['go']); const mockRouter = jasmine.createSpyObj('Router', ['navigate']); const mockActivatedRoute = new ActivatedRouteStub(); - const mockFactoryService = jasmine.createSpyObj('FactoryService', ['userInLngRole', 'userInNrcedRole']); + const mockFactoryService = jasmine.createSpyObj('FactoryService', ['userInLngRole', 'userInBcmiRole', 'userInNrcedRole']); mockFactoryService.userInLngRole.and.returnValue(true); + mockFactoryService.userInBcmiRole.and.returnValue(true); mockFactoryService.userInNrcedRole.and.returnValue(true); const mockLoadingScreenService = { @@ -35,7 +37,12 @@ describe('AdministrativeSanctionAddEditComponent', () => { } }; - beforeEach(async(() => { + const mockStoreService = { + getItem: () => { }, + stateChange: new EventEmitter() + }; + + beforeEach((() => { TestBed.configureTestingModule({ imports: [ RouterTestingModule, @@ -52,6 +59,7 @@ describe('AdministrativeSanctionAddEditComponent', () => { Utils, RecordUtils, { provide: LoadingScreenService, useValue: mockLoadingScreenService }, + { provide: StoreService, useValue: mockStoreService }, { provide: Location, useValue: mockLocation }, { provide: Router, useValue: mockRouter }, { provide: ActivatedRoute, useValue: mockActivatedRoute }, diff --git a/angular/projects/admin-nrpti/src/app/records/administrative-sanctions/administrative-sanction-detail/administrative-sanction-detail.component.html b/angular/projects/admin-nrpti/src/app/records/administrative-sanctions/administrative-sanction-detail/administrative-sanction-detail.component.html index b9739121d..1b58d417a 100644 --- a/angular/projects/admin-nrpti/src/app/records/administrative-sanctions/administrative-sanction-detail/administrative-sanction-detail.component.html +++ b/angular/projects/admin-nrpti/src/app/records/administrative-sanctions/administrative-sanction-detail/administrative-sanction-detail.component.html @@ -52,7 +52,7 @@

Shared Data [Master]

- {{ (data && data._master.sourceSystemRef) || '-' }} + {{ (data && data._master && data._master.sourceSystemRef) || '-' }}
diff --git a/angular/projects/admin-nrpti/src/app/records/administrative-sanctions/administrative-sanction-detail/administrative-sanction-detail.component.spec.ts b/angular/projects/admin-nrpti/src/app/records/administrative-sanctions/administrative-sanction-detail/administrative-sanction-detail.component.spec.ts index 7c4981f4d..2dfe5567b 100644 --- a/angular/projects/admin-nrpti/src/app/records/administrative-sanctions/administrative-sanction-detail/administrative-sanction-detail.component.spec.ts +++ b/angular/projects/admin-nrpti/src/app/records/administrative-sanctions/administrative-sanction-detail/administrative-sanction-detail.component.spec.ts @@ -1,28 +1,35 @@ -import { async, TestBed } from '@angular/core/testing'; +import { TestBed } from '@angular/core/testing'; import { AdministrativeSanctionDetailComponent } from './administrative-sanction-detail.component'; import { TestBedHelper, ActivatedRouteStub } from '../../../../../../common/src/app/spec/spec-utils'; import { RouterTestingModule } from '@angular/router/testing'; import { Router, ActivatedRoute } from '@angular/router'; -import { GlobalModule } from 'nrpti-angular-components'; +import { GlobalModule, StoreService } from 'nrpti-angular-components'; import { RecordDetailDirective } from '../../utils/record-detail.directive'; import { DatePipe } from '@angular/common'; import { CommonModule } from '../../../../../../common/src/app/common.module'; import { DocumentAuthenticatedReadOnlyComponent } from '../../../documents/document-authenticated-read-only/document-authenticated-read-only.component'; import { S3SignedUrlAnchorComponent } from '../../../documents/s3-signed-url-anchor/s3-signed-url-anchor.component'; import { FactoryService } from '../../../services/factory.service'; +import { EventEmitter } from '@angular/core'; describe('AdministrativeSanctionDetailComponent', () => { const testBedHelper = new TestBedHelper(AdministrativeSanctionDetailComponent); - const mockFactoryService = jasmine.createSpyObj('FactoryService', ['userInLngRole', 'userInNrcedRole']); + const mockFactoryService = jasmine.createSpyObj('FactoryService', ['userInLngRole', 'userInBcmiRole', 'userInNrcedRole']); mockFactoryService.userInLngRole.and.returnValue(true); + mockFactoryService.userInBcmiRole.and.returnValue(true); mockFactoryService.userInNrcedRole.and.returnValue(true); // component constructor mocks const mockRouter = jasmine.createSpyObj('Router', ['navigate']); const mockActivatedRoute = new ActivatedRouteStub(); - beforeEach(async(() => { + const mockStoreService = { + getItem: () => { }, + stateChange: new EventEmitter() + }; + + beforeEach((() => { TestBed.configureTestingModule({ imports: [RouterTestingModule, GlobalModule, CommonModule], declarations: [ @@ -34,6 +41,7 @@ describe('AdministrativeSanctionDetailComponent', () => { providers: [ DatePipe, { provide: Router, useValue: mockRouter }, + { provide: StoreService, useValue: mockStoreService }, { provide: ActivatedRoute, useValue: mockActivatedRoute }, { provide: FactoryService, useValue: mockFactoryService } ] diff --git a/angular/projects/admin-nrpti/src/app/records/administrative-sanctions/administrative-sanction-lng-detail/administrative-sanction-lng-detail.component.spec.ts b/angular/projects/admin-nrpti/src/app/records/administrative-sanctions/administrative-sanction-lng-detail/administrative-sanction-lng-detail.component.spec.ts index 3bd5505a6..93e9d0c6d 100644 --- a/angular/projects/admin-nrpti/src/app/records/administrative-sanctions/administrative-sanction-lng-detail/administrative-sanction-lng-detail.component.spec.ts +++ b/angular/projects/admin-nrpti/src/app/records/administrative-sanctions/administrative-sanction-lng-detail/administrative-sanction-lng-detail.component.spec.ts @@ -1,31 +1,40 @@ -import { async, TestBed } from '@angular/core/testing'; +import { TestBed } from '@angular/core/testing'; import { AdministrativeSanctionLNGDetailComponent } from './administrative-sanction-lng-detail.component'; import { TestBedHelper, ActivatedRouteStub } from '../../../../../../common/src/app/spec/spec-utils'; import { RouterTestingModule } from '@angular/router/testing'; import { Router, ActivatedRoute } from '@angular/router'; -import { GlobalModule } from 'nrpti-angular-components'; +import { GlobalModule, StoreService } from 'nrpti-angular-components'; import { DatePipe } from '@angular/common'; import { FactoryService } from '../../../services/factory.service'; +import { EventEmitter } from '@angular/core'; describe('AdministrativeSanctionLNGDetailComponent', () => { const testBedHelper = new TestBedHelper( AdministrativeSanctionLNGDetailComponent ); - const mockFactoryService = jasmine.createSpyObj('FactoryService', ['userInLngRole']); + const mockFactoryService = jasmine.createSpyObj('FactoryService', ['userInLngRole', 'userInBcmiRole', 'userInNrcedRole']); mockFactoryService.userInLngRole.and.returnValue(true); + mockFactoryService.userInBcmiRole.and.returnValue(true); + mockFactoryService.userInNrcedRole.and.returnValue(true); // component constructor mocks const mockRouter = jasmine.createSpyObj('Router', ['navigate']); const mockActivatedRoute = new ActivatedRouteStub(); - beforeEach(async(() => { + const mockStoreService = { + getItem: () => { }, + stateChange: new EventEmitter() + }; + + beforeEach((() => { TestBed.configureTestingModule({ imports: [RouterTestingModule, GlobalModule], declarations: [AdministrativeSanctionLNGDetailComponent], providers: [ DatePipe, { provide: Router, useValue: mockRouter }, + { provide: StoreService, useValue: mockStoreService }, { provide: ActivatedRoute, useValue: mockActivatedRoute }, { provide: FactoryService, useValue: mockFactoryService } ] diff --git a/angular/projects/admin-nrpti/src/app/records/administrative-sanctions/administrative-sanction-nrced-detail/administrative-sanction-nrced-detail.component.spec.ts b/angular/projects/admin-nrpti/src/app/records/administrative-sanctions/administrative-sanction-nrced-detail/administrative-sanction-nrced-detail.component.spec.ts index d964d7684..a3b04422d 100644 --- a/angular/projects/admin-nrpti/src/app/records/administrative-sanctions/administrative-sanction-nrced-detail/administrative-sanction-nrced-detail.component.spec.ts +++ b/angular/projects/admin-nrpti/src/app/records/administrative-sanctions/administrative-sanction-nrced-detail/administrative-sanction-nrced-detail.component.spec.ts @@ -1,31 +1,40 @@ -import { async, TestBed } from '@angular/core/testing'; +import { TestBed } from '@angular/core/testing'; import { AdministrativeSanctionNRCEDDetailComponent } from './administrative-sanction-nrced-detail.component'; import { TestBedHelper, ActivatedRouteStub } from '../../../../../../common/src/app/spec/spec-utils'; import { RouterTestingModule } from '@angular/router/testing'; import { Router, ActivatedRoute } from '@angular/router'; -import { GlobalModule } from 'nrpti-angular-components'; +import { GlobalModule, StoreService } from 'nrpti-angular-components'; import { DatePipe } from '@angular/common'; import { FactoryService } from '../../../services/factory.service'; +import { EventEmitter } from '@angular/core'; describe('AdministrativeSanctionNRCEDDetailComponent', () => { const testBedHelper = new TestBedHelper( AdministrativeSanctionNRCEDDetailComponent ); - const mockFactoryService = jasmine.createSpyObj('FactoryService', ['userInNrcedRole']); + const mockFactoryService = jasmine.createSpyObj('FactoryService', ['userInLngRole', 'userInBcmiRole', 'userInNrcedRole']); + mockFactoryService.userInLngRole.and.returnValue(true); + mockFactoryService.userInBcmiRole.and.returnValue(true); mockFactoryService.userInNrcedRole.and.returnValue(true); // component constructor mocks const mockRouter = jasmine.createSpyObj('Router', ['navigate']); const mockActivatedRoute = new ActivatedRouteStub(); - beforeEach(async(() => { + const mockStoreService = { + getItem: () => { }, + stateChange: new EventEmitter() + }; + + beforeEach((() => { TestBed.configureTestingModule({ imports: [RouterTestingModule, GlobalModule], declarations: [AdministrativeSanctionNRCEDDetailComponent], providers: [ DatePipe, { provide: Router, useValue: mockRouter }, + { provide: StoreService, useValue: mockStoreService }, { provide: ActivatedRoute, useValue: mockActivatedRoute }, { provide: FactoryService, useValue: mockFactoryService } ] diff --git a/angular/projects/admin-nrpti/src/app/records/agreements/agreement-add-edit/agreement-add-edit.component.spec.ts b/angular/projects/admin-nrpti/src/app/records/agreements/agreement-add-edit/agreement-add-edit.component.spec.ts index e128f0eb7..4c09fff10 100644 --- a/angular/projects/admin-nrpti/src/app/records/agreements/agreement-add-edit/agreement-add-edit.component.spec.ts +++ b/angular/projects/admin-nrpti/src/app/records/agreements/agreement-add-edit/agreement-add-edit.component.spec.ts @@ -1,17 +1,18 @@ -import { async, TestBed } from '@angular/core/testing'; +import { TestBed } from '@angular/core/testing'; import { NgbModule } from '@ng-bootstrap/ng-bootstrap'; import { FormsModule, ReactiveFormsModule } from '@angular/forms'; import { AgreementAddEditComponent } from './agreement-add-edit.component'; import { TestBedHelper, ActivatedRouteStub } from '../../../../../../common/src/app/spec/spec-utils'; import { RouterTestingModule } from '@angular/router/testing'; import { Router, ActivatedRoute } from '@angular/router'; -import { GlobalModule } from 'nrpti-angular-components'; +import { GlobalModule, StoreService } from 'nrpti-angular-components'; import { NgxPaginationModule } from 'ngx-pagination'; import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core'; import { Utils } from 'nrpti-angular-components'; import { RecordUtils } from '../../utils/record-utils'; import { LoadingScreenService } from 'nrpti-angular-components'; import { FactoryService } from '../../../services/factory.service'; +import { EventEmitter } from '@angular/core'; describe('AgreementAddEditComponent', () => { const testBedHelper = new TestBedHelper(AgreementAddEditComponent); @@ -20,8 +21,9 @@ describe('AgreementAddEditComponent', () => { const mockLocation = jasmine.createSpyObj('Location', ['go']); const mockRouter = jasmine.createSpyObj('Router', ['navigate']); const mockActivatedRoute = new ActivatedRouteStub(); - const mockFactoryService = jasmine.createSpyObj('FactoryService', ['userInLngRole', 'userInNrcedRole']); + const mockFactoryService = jasmine.createSpyObj('FactoryService', ['userInLngRole', 'userInBcmiRole', 'userInNrcedRole']); mockFactoryService.userInLngRole.and.returnValue(true); + mockFactoryService.userInBcmiRole.and.returnValue(true); mockFactoryService.userInNrcedRole.and.returnValue(true); const mockLoadingScreenService = { @@ -31,7 +33,12 @@ describe('AgreementAddEditComponent', () => { } }; - beforeEach(async(() => { + const mockStoreService = { + getItem: () => { }, + stateChange: new EventEmitter() + }; + + beforeEach((() => { TestBed.configureTestingModule({ imports: [ RouterTestingModule, @@ -46,6 +53,7 @@ describe('AgreementAddEditComponent', () => { Utils, RecordUtils, { provide: LoadingScreenService, useValue: mockLoadingScreenService }, + { provide: StoreService, useValue: mockStoreService }, { provide: Location, useValue: mockLocation }, { provide: Router, useValue: mockRouter }, { provide: ActivatedRoute, useValue: mockActivatedRoute }, diff --git a/angular/projects/admin-nrpti/src/app/records/agreements/agreement-detail/agreement-detail.component.html b/angular/projects/admin-nrpti/src/app/records/agreements/agreement-detail/agreement-detail.component.html index 16d33950e..cb14615c4 100644 --- a/angular/projects/admin-nrpti/src/app/records/agreements/agreement-detail/agreement-detail.component.html +++ b/angular/projects/admin-nrpti/src/app/records/agreements/agreement-detail/agreement-detail.component.html @@ -40,7 +40,7 @@

Shared Data [Master]

- {{ (data && data._master.sourceSystemRef) || '-' }} + {{ (data && data._master && data._master.sourceSystemRef) || '-' }}
diff --git a/angular/projects/admin-nrpti/src/app/records/agreements/agreement-detail/agreement-detail.component.spec.ts b/angular/projects/admin-nrpti/src/app/records/agreements/agreement-detail/agreement-detail.component.spec.ts index 1413e515b..8d6acde9b 100644 --- a/angular/projects/admin-nrpti/src/app/records/agreements/agreement-detail/agreement-detail.component.spec.ts +++ b/angular/projects/admin-nrpti/src/app/records/agreements/agreement-detail/agreement-detail.component.spec.ts @@ -1,13 +1,14 @@ -import { async, TestBed } from '@angular/core/testing'; +import { TestBed } from '@angular/core/testing'; import { AgreementDetailComponent } from './agreement-detail.component'; import { TestBedHelper, ActivatedRouteStub } from '../../../../../../common/src/app/spec/spec-utils'; import { RouterTestingModule } from '@angular/router/testing'; import { Router, ActivatedRoute } from '@angular/router'; -import { GlobalModule } from 'nrpti-angular-components'; +import { GlobalModule, StoreService } from 'nrpti-angular-components'; import { RecordDetailDirective } from '../../utils/record-detail.directive'; import { DatePipe } from '@angular/common'; import { CommonModule } from '../../../../../../common/src/app/common.module'; import { FactoryService } from '../../../services/factory.service'; +import { EventEmitter } from '@angular/core'; describe('AgreementDetailComponent', () => { const testBedHelper = new TestBedHelper(AgreementDetailComponent); @@ -15,17 +16,24 @@ describe('AgreementDetailComponent', () => { // component constructor mocks const mockRouter = jasmine.createSpyObj('Router', ['navigate']); const mockActivatedRoute = new ActivatedRouteStub(); - const mockFactoryService = jasmine.createSpyObj('FactoryService', ['userInLngRole', 'userInNrcedRole']); + const mockFactoryService = jasmine.createSpyObj('FactoryService', ['userInLngRole', 'userInBcmiRole', 'userInNrcedRole']); mockFactoryService.userInLngRole.and.returnValue(true); + mockFactoryService.userInBcmiRole.and.returnValue(true); mockFactoryService.userInNrcedRole.and.returnValue(true); - beforeEach(async(() => { + const mockStoreService = { + getItem: () => { }, + stateChange: new EventEmitter() + }; + + beforeEach((() => { TestBed.configureTestingModule({ imports: [RouterTestingModule, GlobalModule, CommonModule], declarations: [AgreementDetailComponent, RecordDetailDirective], providers: [ DatePipe, { provide: Router, useValue: mockRouter }, + { provide: StoreService, useValue: mockStoreService }, { provide: ActivatedRoute, useValue: mockActivatedRoute }, { provide: FactoryService, useValue: mockFactoryService } ] diff --git a/angular/projects/admin-nrpti/src/app/records/agreements/agreement-lng-detail/agreement-lng-detail.component.spec.ts b/angular/projects/admin-nrpti/src/app/records/agreements/agreement-lng-detail/agreement-lng-detail.component.spec.ts index 48ae367af..df0ed0373 100644 --- a/angular/projects/admin-nrpti/src/app/records/agreements/agreement-lng-detail/agreement-lng-detail.component.spec.ts +++ b/angular/projects/admin-nrpti/src/app/records/agreements/agreement-lng-detail/agreement-lng-detail.component.spec.ts @@ -1,11 +1,12 @@ -import { async, TestBed } from '@angular/core/testing'; +import { TestBed } from '@angular/core/testing'; import { AgreementLNGDetailComponent } from './agreement-lng-detail.component'; import { TestBedHelper, ActivatedRouteStub } from '../../../../../../common/src/app/spec/spec-utils'; import { RouterTestingModule } from '@angular/router/testing'; import { Router, ActivatedRoute } from '@angular/router'; -import { GlobalModule } from 'nrpti-angular-components'; +import { GlobalModule, StoreService } from 'nrpti-angular-components'; import { DatePipe } from '@angular/common'; import { FactoryService } from '../../../services/factory.service'; +import { EventEmitter } from '@angular/core'; describe('AgreementLNGDetailComponent', () => { const testBedHelper = new TestBedHelper(AgreementLNGDetailComponent); @@ -14,16 +15,24 @@ describe('AgreementLNGDetailComponent', () => { const mockRouter = jasmine.createSpyObj('Router', ['navigate']); const mockActivatedRoute = new ActivatedRouteStub(); - const mockFactoryService = jasmine.createSpyObj('FactoryService', ['userInLngRole']); + const mockFactoryService = jasmine.createSpyObj('FactoryService', ['userInLngRole', 'userInBcmiRole', 'userInNrcedRole']); mockFactoryService.userInLngRole.and.returnValue(true); + mockFactoryService.userInBcmiRole.and.returnValue(true); + mockFactoryService.userInNrcedRole.and.returnValue(true); - beforeEach(async(() => { + const mockStoreService = { + getItem: () => { }, + stateChange: new EventEmitter() + }; + + beforeEach((() => { TestBed.configureTestingModule({ imports: [RouterTestingModule, GlobalModule], declarations: [AgreementLNGDetailComponent], providers: [ DatePipe, { provide: Router, useValue: mockRouter }, + { provide: StoreService, useValue: mockStoreService }, { provide: ActivatedRoute, useValue: mockActivatedRoute }, { provide: FactoryService, useValue: mockFactoryService } ] diff --git a/angular/projects/admin-nrpti/src/app/records/annual-reports/annual-report-add-edit/annual-report-add-edit.component.html b/angular/projects/admin-nrpti/src/app/records/annual-reports/annual-report-add-edit/annual-report-add-edit.component.html index ccdbe8757..b58ad5e89 100644 --- a/angular/projects/admin-nrpti/src/app/records/annual-reports/annual-report-add-edit/annual-report-add-edit.component.html +++ b/angular/projects/admin-nrpti/src/app/records/annual-reports/annual-report-add-edit/annual-report-add-edit.component.html @@ -95,6 +95,13 @@

Legislation

Issued To

+ + +
diff --git a/angular/projects/admin-nrpti/src/app/records/annual-reports/annual-report-add-edit/annual-report-add-edit.component.spec.ts b/angular/projects/admin-nrpti/src/app/records/annual-reports/annual-report-add-edit/annual-report-add-edit.component.spec.ts index 2793c750e..08283d87d 100644 --- a/angular/projects/admin-nrpti/src/app/records/annual-reports/annual-report-add-edit/annual-report-add-edit.component.spec.ts +++ b/angular/projects/admin-nrpti/src/app/records/annual-reports/annual-report-add-edit/annual-report-add-edit.component.spec.ts @@ -1,4 +1,4 @@ -import { async, TestBed } from '@angular/core/testing'; +import { TestBed } from '@angular/core/testing'; import { NgbModule } from '@ng-bootstrap/ng-bootstrap'; import { FormsModule, ReactiveFormsModule } from '@angular/forms'; import { AnnualReportAddEditComponent } from './annual-report-add-edit.component'; @@ -10,8 +10,9 @@ import { NgxPaginationModule } from 'ngx-pagination'; import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core'; import { Utils } from 'nrpti-angular-components'; import { RecordUtils } from '../../utils/record-utils'; -import { LoadingScreenService } from 'nrpti-angular-components'; +import { LoadingScreenService, StoreService } from 'nrpti-angular-components'; import { FactoryService } from '../../../services/factory.service'; +import { EventEmitter } from '@angular/core'; describe('AnnualReportAddEditComponent', () => { const testBedHelper = new TestBedHelper(AnnualReportAddEditComponent); @@ -20,8 +21,15 @@ describe('AnnualReportAddEditComponent', () => { const mockLocation = jasmine.createSpyObj('Location', ['go']); const mockRouter = jasmine.createSpyObj('Router', ['navigate']); const mockActivatedRoute = new ActivatedRouteStub(); - const mockFactoryService = jasmine.createSpyObj('FactoryService', ['userInBcmiRole']); + const mockFactoryService = jasmine.createSpyObj('FactoryService', ['userInLngRole', 'userInBcmiRole', 'userInNrcedRole']); + mockFactoryService.userInLngRole.and.returnValue(true); mockFactoryService.userInBcmiRole.and.returnValue(true); + mockFactoryService.userInNrcedRole.and.returnValue(true); + + const mockStoreService = { + getItem: () => { }, + stateChange: new EventEmitter() + }; const mockLoadingScreenService = { isLoading: false, @@ -30,7 +38,7 @@ describe('AnnualReportAddEditComponent', () => { } }; - beforeEach(async(() => { + beforeEach((() => { TestBed.configureTestingModule({ imports: [ RouterTestingModule, @@ -45,6 +53,7 @@ describe('AnnualReportAddEditComponent', () => { Utils, RecordUtils, { provide: LoadingScreenService, useValue: mockLoadingScreenService }, + { provide: StoreService, useValue: mockStoreService }, { provide: Location, useValue: mockLocation }, { provide: Router, useValue: mockRouter }, { provide: ActivatedRoute, useValue: mockActivatedRoute }, diff --git a/angular/projects/admin-nrpti/src/app/records/annual-reports/annual-report-add-edit/annual-report-add-edit.component.ts b/angular/projects/admin-nrpti/src/app/records/annual-reports/annual-report-add-edit/annual-report-add-edit.component.ts index c0a4cdcbc..751fe7cfc 100644 --- a/angular/projects/admin-nrpti/src/app/records/annual-reports/annual-report-add-edit/annual-report-add-edit.component.ts +++ b/angular/projects/admin-nrpti/src/app/records/annual-reports/annual-report-add-edit/annual-report-add-edit.component.ts @@ -9,7 +9,7 @@ import { FactoryService } from '../../../services/factory.service'; import { Utils } from 'nrpti-angular-components'; import { Utils as CommonUtils } from '../../../../../../common/src/app/utils/utils'; import { RecordUtils } from '../../utils/record-utils'; -import { LoadingScreenService } from 'nrpti-angular-components'; +import { LoadingScreenService, StoreService } from 'nrpti-angular-components'; @Component({ selector: 'app-annual-report-add-edit', @@ -40,6 +40,7 @@ export class AnnualReportAddEditComponent implements OnInit, OnDestroy { public route: ActivatedRoute, public router: Router, private recordUtils: RecordUtils, + private storeService: StoreService, private factoryService: FactoryService, private loadingScreenService: LoadingScreenService, private utils: Utils, @@ -228,6 +229,17 @@ export class AnnualReportAddEditComponent implements OnInit, OnDestroy { publishBcmi: new FormControl({ value: (this.currentRecord && this.bcmiFlavour && this.bcmiFlavour.read.includes('public')) || false, disabled: !this.factoryService.userInBcmiRole() + }), + + association: new FormGroup({ + _epicProjectId: new FormControl({ + value: this.currentRecord && this.currentRecord._epicProjectId || null, + disabled: this.currentRecord && this.currentRecord.sourceSystemRef !== 'nrpti' + }), + mineGuid: new FormControl({ + value: this.currentRecord && this.currentRecord.mineGuid || null, + disabled: this.currentRecord && this.currentRecord.sourceSystemRef !== 'nrpti' + }) }) }); } @@ -320,6 +332,23 @@ export class AnnualReportAddEditComponent implements OnInit, OnDestroy { annualReport['AnnualReportBCMI']['removeRole'] = 'public'; } + if (this.myForm.get('association._epicProjectId').dirty) { + annualReport['_epicProjectId'] = this.myForm.get('association._epicProjectId').value; + } + + if (this.myForm.get('association.mineGuid').dirty) { + annualReport['mineGuid'] = this.myForm.get('association.mineGuid').value; + } + + // Set the friendly name of projectName + const epicProjectList = this.storeService.getItem('epicProjects'); + const filterResult = epicProjectList.filter(item => { + return item._id === annualReport['_epicProjectId']; + }); + if (filterResult && filterResult[0] && filterResult[0].name) { + annualReport['projectName'] = filterResult[0].name; + } + if (!this.isEditing) { this.factoryService.writeRecord(annualReport, 'annualReports', true).subscribe(async res => { this.recordUtils.parseResForErrors(res); diff --git a/angular/projects/admin-nrpti/src/app/records/annual-reports/annual-report-bcmi-detail/annual-report-bcmi-detail.component.spec.ts b/angular/projects/admin-nrpti/src/app/records/annual-reports/annual-report-bcmi-detail/annual-report-bcmi-detail.component.spec.ts index 55b516bdb..e62ea012d 100644 --- a/angular/projects/admin-nrpti/src/app/records/annual-reports/annual-report-bcmi-detail/annual-report-bcmi-detail.component.spec.ts +++ b/angular/projects/admin-nrpti/src/app/records/annual-reports/annual-report-bcmi-detail/annual-report-bcmi-detail.component.spec.ts @@ -1,11 +1,12 @@ -import { async, TestBed } from '@angular/core/testing'; +import { TestBed } from '@angular/core/testing'; import { AnnualReportBCMIDetailComponent } from './annual-report-bcmi-detail.component'; import { TestBedHelper, ActivatedRouteStub } from '../../../../../../common/src/app/spec/spec-utils'; import { RouterTestingModule } from '@angular/router/testing'; import { Router, ActivatedRoute } from '@angular/router'; -import { GlobalModule } from 'nrpti-angular-components'; +import { GlobalModule, StoreService } from 'nrpti-angular-components'; import { DatePipe } from '@angular/common'; import { FactoryService } from '../../../services/factory.service'; +import { EventEmitter } from '@angular/core'; describe('AnnualReportBCMIDetailComponent', () => { const testBedHelper = new TestBedHelper @@ -14,16 +15,24 @@ describe('AnnualReportBCMIDetailComponent', () => { // component constructor mocks const mockRouter = jasmine.createSpyObj('Router', ['navigate']); const mockActivatedRoute = new ActivatedRouteStub(); - const mockFactoryService = jasmine.createSpyObj('FactoryService', ['userInBcmiRole']); + const mockFactoryService = jasmine.createSpyObj('FactoryService', ['userInLngRole', 'userInBcmiRole', 'userInNrcedRole']); + mockFactoryService.userInLngRole.and.returnValue(true); mockFactoryService.userInBcmiRole.and.returnValue(true); + mockFactoryService.userInNrcedRole.and.returnValue(true); - beforeEach(async(() => { + const mockStoreService = { + getItem: () => { }, + stateChange: new EventEmitter() + }; + + beforeEach((() => { TestBed.configureTestingModule({ imports: [RouterTestingModule, GlobalModule], declarations: [AnnualReportBCMIDetailComponent], providers: [ DatePipe, { provide: Router, useValue: mockRouter }, + { provide: StoreService, useValue: mockStoreService }, { provide: ActivatedRoute, useValue: mockActivatedRoute }, { provide: FactoryService, useValue: mockFactoryService } ] diff --git a/angular/projects/admin-nrpti/src/app/records/annual-reports/annual-report-detail/annual-report-detail.component.html b/angular/projects/admin-nrpti/src/app/records/annual-reports/annual-report-detail/annual-report-detail.component.html index 77eef6f78..f0cca4476 100644 --- a/angular/projects/admin-nrpti/src/app/records/annual-reports/annual-report-detail/annual-report-detail.component.html +++ b/angular/projects/admin-nrpti/src/app/records/annual-reports/annual-report-detail/annual-report-detail.component.html @@ -48,7 +48,7 @@

Shared Data [Master]

- {{ (data && data._master.sourceSystemRef) || '-' }} + {{ (data && data._master && data._master.sourceSystemRef) || '-' }}
diff --git a/angular/projects/admin-nrpti/src/app/records/annual-reports/annual-report-detail/annual-report-detail.component.spec.ts b/angular/projects/admin-nrpti/src/app/records/annual-reports/annual-report-detail/annual-report-detail.component.spec.ts index 4a6481016..399139cf6 100644 --- a/angular/projects/admin-nrpti/src/app/records/annual-reports/annual-report-detail/annual-report-detail.component.spec.ts +++ b/angular/projects/admin-nrpti/src/app/records/annual-reports/annual-report-detail/annual-report-detail.component.spec.ts @@ -1,13 +1,14 @@ -import { async, TestBed } from '@angular/core/testing'; +import { TestBed } from '@angular/core/testing'; import { AnnualReportDetailComponent } from './annual-report-detail.component'; import { TestBedHelper, ActivatedRouteStub } from '../../../../../../common/src/app/spec/spec-utils'; import { RouterTestingModule } from '@angular/router/testing'; import { Router, ActivatedRoute } from '@angular/router'; -import { GlobalModule } from 'nrpti-angular-components'; +import { GlobalModule, StoreService } from 'nrpti-angular-components'; import { RecordDetailDirective } from '../../utils/record-detail.directive'; import { DatePipe } from '@angular/common'; import { CommonModule } from '../../../../../../common/src/app/common.module'; import { FactoryService } from '../../../services/factory.service'; +import { EventEmitter } from '@angular/core'; describe('ReportDetailComponent', () => { const testBedHelper = new TestBedHelper(AnnualReportDetailComponent); @@ -15,17 +16,24 @@ describe('ReportDetailComponent', () => { // component constructor mocks const mockRouter = jasmine.createSpyObj('Router', ['navigate']); const mockActivatedRoute = new ActivatedRouteStub(); - const mockFactoryService = jasmine.createSpyObj('FactoryService', ['userInBcmiRole', 'userInNrcedRole']); + const mockFactoryService = jasmine.createSpyObj('FactoryService', ['userInLngRole', 'userInBcmiRole', 'userInNrcedRole']); + mockFactoryService.userInLngRole.and.returnValue(true); mockFactoryService.userInBcmiRole.and.returnValue(true); mockFactoryService.userInNrcedRole.and.returnValue(true); - beforeEach(async(() => { + const mockStoreService = { + getItem: () => { }, + stateChange: new EventEmitter() + }; + + beforeEach((() => { TestBed.configureTestingModule({ imports: [RouterTestingModule, GlobalModule, CommonModule], declarations: [AnnualReportDetailComponent, RecordDetailDirective], providers: [ DatePipe, { provide: Router, useValue: mockRouter }, + { provide: StoreService, useValue: mockStoreService }, { provide: ActivatedRoute, useValue: mockActivatedRoute }, { provide: FactoryService, useValue: mockFactoryService } ] diff --git a/angular/projects/admin-nrpti/src/app/records/certificate-amendments/certificate-amendments-add-edit/certificate-amendments-add-edit.component.html b/angular/projects/admin-nrpti/src/app/records/certificate-amendments/certificate-amendments-add-edit/certificate-amendments-add-edit.component.html index 35a8c7bdc..58acedbe1 100644 --- a/angular/projects/admin-nrpti/src/app/records/certificate-amendments/certificate-amendments-add-edit/certificate-amendments-add-edit.component.html +++ b/angular/projects/admin-nrpti/src/app/records/certificate-amendments/certificate-amendments-add-edit/certificate-amendments-add-edit.component.html @@ -100,32 +100,14 @@

Legislation

Issued To

-
-
- - (If Applicable) -
-
- - -
-
- - -
-
- - -
-
-
-
+ + +
diff --git a/angular/projects/admin-nrpti/src/app/records/certificate-amendments/certificate-amendments-add-edit/certificate-amendments-add-edit.component.spec.ts b/angular/projects/admin-nrpti/src/app/records/certificate-amendments/certificate-amendments-add-edit/certificate-amendments-add-edit.component.spec.ts index 2f8b65b80..eb9a2a856 100644 --- a/angular/projects/admin-nrpti/src/app/records/certificate-amendments/certificate-amendments-add-edit/certificate-amendments-add-edit.component.spec.ts +++ b/angular/projects/admin-nrpti/src/app/records/certificate-amendments/certificate-amendments-add-edit/certificate-amendments-add-edit.component.spec.ts @@ -1,17 +1,18 @@ -import { async, TestBed } from '@angular/core/testing'; +import { TestBed } from '@angular/core/testing'; import { NgbModule } from '@ng-bootstrap/ng-bootstrap'; import { FormsModule, ReactiveFormsModule } from '@angular/forms'; import { CertificateAmendmentAddEditComponent } from './certificate-amendments-add-edit.component'; import { TestBedHelper, ActivatedRouteStub } from '../../../../../../common/src/app/spec/spec-utils'; import { RouterTestingModule } from '@angular/router/testing'; import { Router, ActivatedRoute } from '@angular/router'; -import { GlobalModule } from 'nrpti-angular-components'; +import { GlobalModule, StoreService } from 'nrpti-angular-components'; import { NgxPaginationModule } from 'ngx-pagination'; import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core'; import { Utils } from 'nrpti-angular-components'; import { RecordUtils } from '../../utils/record-utils'; import { LoadingScreenService } from 'nrpti-angular-components'; import { FactoryService } from '../../../services/factory.service'; +import { EventEmitter } from '@angular/core'; describe('CertificateAddEditComponent', () => { const testBedHelper = new TestBedHelper(CertificateAmendmentAddEditComponent); @@ -20,9 +21,15 @@ describe('CertificateAddEditComponent', () => { const mockLocation = jasmine.createSpyObj('Location', ['go']); const mockRouter = jasmine.createSpyObj('Router', ['navigate']); const mockActivatedRoute = new ActivatedRouteStub(); - const mockFactoryService = jasmine.createSpyObj('FactoryService', ['userInLngRole', 'userInBcmiRole']); + const mockFactoryService = jasmine.createSpyObj('FactoryService', ['userInLngRole', 'userInBcmiRole', 'userInNrcedRole']); mockFactoryService.userInLngRole.and.returnValue(true); mockFactoryService.userInBcmiRole.and.returnValue(true); + mockFactoryService.userInNrcedRole.and.returnValue(true); + + const mockStoreService = { + getItem: () => { }, + stateChange: new EventEmitter() + }; const mockLoadingScreenService = { isLoading: false, @@ -31,7 +38,7 @@ describe('CertificateAddEditComponent', () => { } }; - beforeEach(async(() => { + beforeEach((() => { TestBed.configureTestingModule({ imports: [ RouterTestingModule, @@ -46,6 +53,7 @@ describe('CertificateAddEditComponent', () => { Utils, RecordUtils, { provide: LoadingScreenService, useValue: mockLoadingScreenService }, + { provide: StoreService, useValue: mockStoreService }, { provide: Location, useValue: mockLocation }, { provide: Router, useValue: mockRouter }, { provide: ActivatedRoute, useValue: mockActivatedRoute }, diff --git a/angular/projects/admin-nrpti/src/app/records/certificate-amendments/certificate-amendments-add-edit/certificate-amendments-add-edit.component.ts b/angular/projects/admin-nrpti/src/app/records/certificate-amendments/certificate-amendments-add-edit/certificate-amendments-add-edit.component.ts index a6ee2b904..fe21115df 100644 --- a/angular/projects/admin-nrpti/src/app/records/certificate-amendments/certificate-amendments-add-edit/certificate-amendments-add-edit.component.ts +++ b/angular/projects/admin-nrpti/src/app/records/certificate-amendments/certificate-amendments-add-edit/certificate-amendments-add-edit.component.ts @@ -9,7 +9,7 @@ import { FactoryService } from '../../../services/factory.service'; import { Utils } from 'nrpti-angular-components'; import { Utils as CommonUtils } from '../../../../../../common/src/app/utils/utils'; import { RecordUtils } from '../../utils/record-utils'; -import { LoadingScreenService } from 'nrpti-angular-components'; +import { LoadingScreenService, StoreService } from 'nrpti-angular-components'; @Component({ selector: 'app-certificate-amendment-add-edit', @@ -43,6 +43,7 @@ export class CertificateAmendmentAddEditComponent implements OnInit, OnDestroy { public route: ActivatedRoute, public router: Router, private recordUtils: RecordUtils, + private storeService: StoreService, private factoryService: FactoryService, private loadingScreenService: LoadingScreenService, private utils: Utils, @@ -257,6 +258,17 @@ export class CertificateAmendmentAddEditComponent implements OnInit, OnDestroy { publishBcmi: new FormControl({ value: (this.currentRecord && this.bcmiFlavour && this.bcmiFlavour.read.includes('public')) || false, disabled: !this.factoryService.userInBcmiRole() + }), + + association: new FormGroup({ + _epicProjectId: new FormControl({ + value: this.currentRecord && this.currentRecord._epicProjectId || null, + disabled: this.currentRecord && this.currentRecord.sourceSystemRef !== 'nrpti' + }), + mineGuid: new FormControl({ + value: this.currentRecord && this.currentRecord.mineGuid || null, + disabled: this.currentRecord && this.currentRecord.sourceSystemRef !== 'nrpti' + }) }) }); } @@ -378,6 +390,23 @@ export class CertificateAmendmentAddEditComponent implements OnInit, OnDestroy { certificateAmendment['CertificateAmendmentBCMI']['removeRole'] = 'public'; } + if (this.myForm.get('association._epicProjectId').dirty) { + certificateAmendment['_epicProjectId'] = this.myForm.get('association._epicProjectId').value; + } + + if (this.myForm.get('association.mineGuid').dirty) { + certificateAmendment['mineGuid'] = this.myForm.get('association.mineGuid').value; + } + + // Set the friendly name of projectName + const epicProjectList = this.storeService.getItem('epicProjects'); + const filterResult = epicProjectList.filter(item => { + return item._id === certificateAmendment['_epicProjectId']; + }); + if (filterResult && filterResult[0] && filterResult[0].name) { + certificateAmendment['projectName'] = filterResult[0].name; + } + if (!this.isEditing) { this.factoryService.writeRecord(certificateAmendment, 'certificateAmendments', true).subscribe(async res => { this.recordUtils.parseResForErrors(res); diff --git a/angular/projects/admin-nrpti/src/app/records/certificate-amendments/certificate-amendments-bcmi-detail/certificate-amendments-bcmi-detail.component.spec.ts b/angular/projects/admin-nrpti/src/app/records/certificate-amendments/certificate-amendments-bcmi-detail/certificate-amendments-bcmi-detail.component.spec.ts index f5e5f68aa..9b5629883 100644 --- a/angular/projects/admin-nrpti/src/app/records/certificate-amendments/certificate-amendments-bcmi-detail/certificate-amendments-bcmi-detail.component.spec.ts +++ b/angular/projects/admin-nrpti/src/app/records/certificate-amendments/certificate-amendments-bcmi-detail/certificate-amendments-bcmi-detail.component.spec.ts @@ -1,29 +1,38 @@ -import { async, TestBed } from '@angular/core/testing'; +import { TestBed } from '@angular/core/testing'; import { CertificateAmendmentBCMIDetailComponent } from './certificate-amendments-bcmi-detail.component'; import { TestBedHelper, ActivatedRouteStub } from '../../../../../../common/src/app/spec/spec-utils'; import { RouterTestingModule } from '@angular/router/testing'; import { Router, ActivatedRoute } from '@angular/router'; -import { GlobalModule } from 'nrpti-angular-components'; +import { GlobalModule, StoreService } from 'nrpti-angular-components'; import { DatePipe } from '@angular/common'; import { FactoryService } from '../../../services/factory.service'; +import { EventEmitter } from '@angular/core'; -describe('CertificateLNGDetailComponent', () => { +describe('CertificateAmendmentBCMIDetailComponent', () => { const testBedHelper = new TestBedHelper (CertificateAmendmentBCMIDetailComponent); // component constructor mocks const mockRouter = jasmine.createSpyObj('Router', ['navigate']); const mockActivatedRoute = new ActivatedRouteStub(); - const mockFactoryService = jasmine.createSpyObj('FactoryService', ['userInBcmiRole']); + const mockFactoryService = jasmine.createSpyObj('FactoryService', ['userInLngRole', 'userInBcmiRole', 'userInNrcedRole']); + mockFactoryService.userInLngRole.and.returnValue(true); mockFactoryService.userInBcmiRole.and.returnValue(true); + mockFactoryService.userInNrcedRole.and.returnValue(true); - beforeEach(async(() => { + const mockStoreService = { + getItem: () => { }, + stateChange: new EventEmitter() + }; + + beforeEach((() => { TestBed.configureTestingModule({ imports: [RouterTestingModule, GlobalModule], declarations: [CertificateAmendmentBCMIDetailComponent], providers: [ DatePipe, { provide: Router, useValue: mockRouter }, + { provide: StoreService, useValue: mockStoreService }, { provide: ActivatedRoute, useValue: mockActivatedRoute }, { provide: FactoryService, useValue: mockFactoryService } ] diff --git a/angular/projects/admin-nrpti/src/app/records/certificate-amendments/certificate-amendments-bcmi-detail/certificate-amendments-bcmi-detail.component.ts b/angular/projects/admin-nrpti/src/app/records/certificate-amendments/certificate-amendments-bcmi-detail/certificate-amendments-bcmi-detail.component.ts index 7dc50057b..aece2bd50 100644 --- a/angular/projects/admin-nrpti/src/app/records/certificate-amendments/certificate-amendments-bcmi-detail/certificate-amendments-bcmi-detail.component.ts +++ b/angular/projects/admin-nrpti/src/app/records/certificate-amendments/certificate-amendments-bcmi-detail/certificate-amendments-bcmi-detail.component.ts @@ -31,7 +31,7 @@ export class CertificateAmendmentBCMIDetailComponent extends RecordComponent imp if (!this.data) { this.route.data.pipe(takeUntil(this.ngUnsubscribe)).subscribe((res: any) => { if (!res || !res.records) { - alert("Uh-oh, couldn't load Certificate amendment"); + alert("Uh-oh, couldn't load Certificate amendment for BCMI Component"); this.router.navigate(['/']); return; } diff --git a/angular/projects/admin-nrpti/src/app/records/certificate-amendments/certificate-amendments-detail/certificate-amendments-detail.component.html b/angular/projects/admin-nrpti/src/app/records/certificate-amendments/certificate-amendments-detail/certificate-amendments-detail.component.html index b3b6d7195..db1c7e3e0 100644 --- a/angular/projects/admin-nrpti/src/app/records/certificate-amendments/certificate-amendments-detail/certificate-amendments-detail.component.html +++ b/angular/projects/admin-nrpti/src/app/records/certificate-amendments/certificate-amendments-detail/certificate-amendments-detail.component.html @@ -52,7 +52,7 @@

Shared Data [Master]

- {{ (data && data._master.sourceSystemRef) || '-' }} + {{ (data && data._master && data._master.sourceSystemRef) || '-' }}
diff --git a/angular/projects/admin-nrpti/src/app/records/certificate-amendments/certificate-amendments-detail/certificate-amendments-detail.component.spec.ts b/angular/projects/admin-nrpti/src/app/records/certificate-amendments/certificate-amendments-detail/certificate-amendments-detail.component.spec.ts index e4ceb398d..e9d84a4fe 100644 --- a/angular/projects/admin-nrpti/src/app/records/certificate-amendments/certificate-amendments-detail/certificate-amendments-detail.component.spec.ts +++ b/angular/projects/admin-nrpti/src/app/records/certificate-amendments/certificate-amendments-detail/certificate-amendments-detail.component.spec.ts @@ -1,13 +1,14 @@ -import { async, TestBed } from '@angular/core/testing'; +import { TestBed } from '@angular/core/testing'; import { CertificateAmendmentDetailComponent } from './certificate-amendments-detail.component'; import { TestBedHelper, ActivatedRouteStub } from '../../../../../../common/src/app/spec/spec-utils'; import { RouterTestingModule } from '@angular/router/testing'; import { Router, ActivatedRoute } from '@angular/router'; -import { GlobalModule } from 'nrpti-angular-components'; +import { GlobalModule, StoreService } from 'nrpti-angular-components'; import { RecordDetailDirective } from '../../utils/record-detail.directive'; import { DatePipe } from '@angular/common'; import { CommonModule } from '../../../../../../common/src/app/common.module'; import { FactoryService } from '../../../services/factory.service'; +import { EventEmitter } from '@angular/core'; describe('CertificateDetailComponent', () => { const testBedHelper = new TestBedHelper(CertificateAmendmentDetailComponent); @@ -15,17 +16,24 @@ describe('CertificateDetailComponent', () => { // component constructor mocks const mockRouter = jasmine.createSpyObj('Router', ['navigate']); const mockActivatedRoute = new ActivatedRouteStub(); - const mockFactoryService = jasmine.createSpyObj('FactoryService', ['userInLngRole', 'userInBcmiRole']); + const mockFactoryService = jasmine.createSpyObj('FactoryService', ['userInLngRole', 'userInBcmiRole', 'userInNrcedRole']); mockFactoryService.userInLngRole.and.returnValue(true); mockFactoryService.userInBcmiRole.and.returnValue(true); + mockFactoryService.userInNrcedRole.and.returnValue(true); - beforeEach(async(() => { + const mockStoreService = { + getItem: () => { }, + stateChange: new EventEmitter() + }; + + beforeEach((() => { TestBed.configureTestingModule({ imports: [RouterTestingModule, GlobalModule, CommonModule], declarations: [CertificateAmendmentDetailComponent, RecordDetailDirective], providers: [ DatePipe, { provide: Router, useValue: mockRouter }, + { provide: StoreService, useValue: mockStoreService }, { provide: ActivatedRoute, useValue: mockActivatedRoute }, { provide: FactoryService, useValue: mockFactoryService } ] diff --git a/angular/projects/admin-nrpti/src/app/records/certificate-amendments/certificate-amendments-lng-detail/certificate-amendments-lng-detail.component.spec.ts b/angular/projects/admin-nrpti/src/app/records/certificate-amendments/certificate-amendments-lng-detail/certificate-amendments-lng-detail.component.spec.ts index dcd1a4f07..3238c8939 100644 --- a/angular/projects/admin-nrpti/src/app/records/certificate-amendments/certificate-amendments-lng-detail/certificate-amendments-lng-detail.component.spec.ts +++ b/angular/projects/admin-nrpti/src/app/records/certificate-amendments/certificate-amendments-lng-detail/certificate-amendments-lng-detail.component.spec.ts @@ -1,11 +1,12 @@ -import { async, TestBed } from '@angular/core/testing'; +import { TestBed } from '@angular/core/testing'; import { CertificateAmendmentLNGDetailComponent } from './certificate-amendments-lng-detail.component'; import { TestBedHelper, ActivatedRouteStub } from '../../../../../../common/src/app/spec/spec-utils'; import { RouterTestingModule } from '@angular/router/testing'; import { Router, ActivatedRoute } from '@angular/router'; -import { GlobalModule } from 'nrpti-angular-components'; +import { GlobalModule, StoreService } from 'nrpti-angular-components'; import { DatePipe } from '@angular/common'; import { FactoryService } from '../../../services/factory.service'; +import { EventEmitter } from '@angular/core'; describe('CertificateLNGDetailComponent', () => { const testBedHelper = new TestBedHelper @@ -14,16 +15,24 @@ describe('CertificateLNGDetailComponent', () => { // component constructor mocks const mockRouter = jasmine.createSpyObj('Router', ['navigate']); const mockActivatedRoute = new ActivatedRouteStub(); - const mockFactoryService = jasmine.createSpyObj('FactoryService', ['userInLngRole']); + const mockFactoryService = jasmine.createSpyObj('FactoryService', ['userInLngRole', 'userInBcmiRole', 'userInNrcedRole']); mockFactoryService.userInLngRole.and.returnValue(true); + mockFactoryService.userInBcmiRole.and.returnValue(true); + mockFactoryService.userInNrcedRole.and.returnValue(true); - beforeEach(async(() => { + const mockStoreService = { + getItem: () => { }, + stateChange: new EventEmitter() + }; + + beforeEach((() => { TestBed.configureTestingModule({ imports: [RouterTestingModule, GlobalModule], declarations: [CertificateAmendmentLNGDetailComponent], providers: [ DatePipe, { provide: Router, useValue: mockRouter }, + { provide: StoreService, useValue: mockStoreService }, { provide: ActivatedRoute, useValue: mockActivatedRoute }, { provide: FactoryService, useValue: mockFactoryService } ] diff --git a/angular/projects/admin-nrpti/src/app/records/certificate-amendments/certificate-amendments-lng-detail/certificate-amendments-lng-detail.component.ts b/angular/projects/admin-nrpti/src/app/records/certificate-amendments/certificate-amendments-lng-detail/certificate-amendments-lng-detail.component.ts index fedd82329..d349a3b34 100644 --- a/angular/projects/admin-nrpti/src/app/records/certificate-amendments/certificate-amendments-lng-detail/certificate-amendments-lng-detail.component.ts +++ b/angular/projects/admin-nrpti/src/app/records/certificate-amendments/certificate-amendments-lng-detail/certificate-amendments-lng-detail.component.ts @@ -31,7 +31,7 @@ export class CertificateAmendmentLNGDetailComponent extends RecordComponent impl if (!this.data) { this.route.data.pipe(takeUntil(this.ngUnsubscribe)).subscribe((res: any) => { if (!res || !res.records) { - alert("Uh-oh, couldn't load Certificate Amendment"); + alert("Uh-oh, couldn't load Certificate Amendment for LNG Component"); this.router.navigate(['/']); return; } diff --git a/angular/projects/admin-nrpti/src/app/records/certificates/certificate-add-edit/certificate-add-edit.component.html b/angular/projects/admin-nrpti/src/app/records/certificates/certificate-add-edit/certificate-add-edit.component.html index 0f64c5449..db9bae5f2 100644 --- a/angular/projects/admin-nrpti/src/app/records/certificates/certificate-add-edit/certificate-add-edit.component.html +++ b/angular/projects/admin-nrpti/src/app/records/certificates/certificate-add-edit/certificate-add-edit.component.html @@ -100,31 +100,12 @@

Legislation

Issued To

-
-
- - (If Applicable) -
-
- - -
-
- - -
-
- - -
-
-
-
+ +
diff --git a/angular/projects/admin-nrpti/src/app/records/certificates/certificate-add-edit/certificate-add-edit.component.spec.ts b/angular/projects/admin-nrpti/src/app/records/certificates/certificate-add-edit/certificate-add-edit.component.spec.ts index e5106476f..d15b98091 100644 --- a/angular/projects/admin-nrpti/src/app/records/certificates/certificate-add-edit/certificate-add-edit.component.spec.ts +++ b/angular/projects/admin-nrpti/src/app/records/certificates/certificate-add-edit/certificate-add-edit.component.spec.ts @@ -1,4 +1,4 @@ -import { async, TestBed } from '@angular/core/testing'; +import { TestBed } from '@angular/core/testing'; import { NgbModule } from '@ng-bootstrap/ng-bootstrap'; import { FormsModule, ReactiveFormsModule } from '@angular/forms'; import { CertificateAddEditComponent } from './certificate-add-edit.component'; @@ -10,8 +10,9 @@ import { NgxPaginationModule } from 'ngx-pagination'; import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core'; import { Utils } from 'nrpti-angular-components'; import { RecordUtils } from '../../utils/record-utils'; -import { LoadingScreenService } from 'nrpti-angular-components'; +import { LoadingScreenService, StoreService } from 'nrpti-angular-components'; import { FactoryService } from '../../../services/factory.service'; +import { EventEmitter } from '@angular/core'; describe('CertificateAddEditComponent', () => { const testBedHelper = new TestBedHelper(CertificateAddEditComponent); @@ -20,10 +21,16 @@ describe('CertificateAddEditComponent', () => { const mockLocation = jasmine.createSpyObj('Location', ['go']); const mockRouter = jasmine.createSpyObj('Router', ['navigate']); const mockActivatedRoute = new ActivatedRouteStub(); - const mockFactoryService = jasmine.createSpyObj('FactoryService', ['userInLngRole', 'userInNrcedRole']); + const mockFactoryService = jasmine.createSpyObj('FactoryService', ['userInLngRole', 'userInBcmiRole', 'userInNrcedRole']); mockFactoryService.userInLngRole.and.returnValue(true); + mockFactoryService.userInBcmiRole.and.returnValue(true); mockFactoryService.userInNrcedRole.and.returnValue(true); + const mockStoreService = { + getItem: () => { }, + stateChange: new EventEmitter() + }; + const mockLoadingScreenService = { isLoading: false, setLoadingState: () => { @@ -31,7 +38,7 @@ describe('CertificateAddEditComponent', () => { } }; - beforeEach(async(() => { + beforeEach((() => { TestBed.configureTestingModule({ imports: [ RouterTestingModule, @@ -46,6 +53,7 @@ describe('CertificateAddEditComponent', () => { Utils, RecordUtils, { provide: LoadingScreenService, useValue: mockLoadingScreenService }, + { provide: StoreService, useValue: mockStoreService }, { provide: Location, useValue: mockLocation }, { provide: Router, useValue: mockRouter }, { provide: ActivatedRoute, useValue: mockActivatedRoute }, diff --git a/angular/projects/admin-nrpti/src/app/records/certificates/certificate-add-edit/certificate-add-edit.component.ts b/angular/projects/admin-nrpti/src/app/records/certificates/certificate-add-edit/certificate-add-edit.component.ts index 816d7b385..b3fa0169c 100644 --- a/angular/projects/admin-nrpti/src/app/records/certificates/certificate-add-edit/certificate-add-edit.component.ts +++ b/angular/projects/admin-nrpti/src/app/records/certificates/certificate-add-edit/certificate-add-edit.component.ts @@ -9,7 +9,7 @@ import { FactoryService } from '../../../services/factory.service'; import { Utils } from 'nrpti-angular-components'; import { Utils as CommonUtils } from '../../../../../../common/src/app/utils/utils'; import { RecordUtils } from '../../utils/record-utils'; -import { LoadingScreenService } from 'nrpti-angular-components'; +import { LoadingScreenService, StoreService } from 'nrpti-angular-components'; @Component({ selector: 'app-certificate-add-edit', @@ -41,6 +41,7 @@ export class CertificateAddEditComponent implements OnInit, OnDestroy { public route: ActivatedRoute, public router: Router, private recordUtils: RecordUtils, + private storeService: StoreService, private factoryService: FactoryService, private loadingScreenService: LoadingScreenService, private utils: Utils, @@ -194,6 +195,17 @@ export class CertificateAddEditComponent implements OnInit, OnDestroy { publishLng: new FormControl({ value: (this.currentRecord && this.lngFlavour && this.lngFlavour.read.includes('public')) || false, disabled: !this.factoryService.userInLngRole() + }), + + association: new FormGroup({ + _epicProjectId: new FormControl({ + value: this.currentRecord && this.currentRecord._epicProjectId || null, + disabled: this.currentRecord && this.currentRecord.sourceSystemRef !== 'nrpti' + }), + mineGuid: new FormControl({ + value: this.currentRecord && this.currentRecord.mineGuid || null, + disabled: this.currentRecord && this.currentRecord.sourceSystemRef !== 'nrpti' + }) }) }); } @@ -279,6 +291,23 @@ export class CertificateAddEditComponent implements OnInit, OnDestroy { certificate['CertificateLNG']['removeRole'] = 'public'; } + if (this.myForm.get('association._epicProjectId').dirty) { + certificate['_epicProjectId'] = this.myForm.get('association._epicProjectId').value; + } + + if (this.myForm.get('association.mineGuid').dirty) { + certificate['mineGuid'] = this.myForm.get('association.mineGuid').value; + } + + // Set the friendly name of projectName + const epicProjectList = this.storeService.getItem('epicProjects'); + const filterResult = epicProjectList.filter(item => { + return item._id === certificate['_epicProjectId']; + }); + if (filterResult && filterResult[0] && filterResult[0].name) { + certificate['projectName'] = filterResult[0].name; + } + if (!this.isEditing) { this.factoryService.writeRecord(certificate, 'certificates', true).subscribe(async res => { this.recordUtils.parseResForErrors(res); diff --git a/angular/projects/admin-nrpti/src/app/records/certificates/certificate-detail/certificate-detail.component.html b/angular/projects/admin-nrpti/src/app/records/certificates/certificate-detail/certificate-detail.component.html index aa99fea97..400e8d990 100644 --- a/angular/projects/admin-nrpti/src/app/records/certificates/certificate-detail/certificate-detail.component.html +++ b/angular/projects/admin-nrpti/src/app/records/certificates/certificate-detail/certificate-detail.component.html @@ -52,7 +52,7 @@

Shared Data [Master]

- {{ (data && data._master.sourceSystemRef) || '-' }} + {{ (data && data._master && data._master.sourceSystemRef) || '-' }}
diff --git a/angular/projects/admin-nrpti/src/app/records/certificates/certificate-detail/certificate-detail.component.spec.ts b/angular/projects/admin-nrpti/src/app/records/certificates/certificate-detail/certificate-detail.component.spec.ts index 71b8c8ac4..16e44ae38 100644 --- a/angular/projects/admin-nrpti/src/app/records/certificates/certificate-detail/certificate-detail.component.spec.ts +++ b/angular/projects/admin-nrpti/src/app/records/certificates/certificate-detail/certificate-detail.component.spec.ts @@ -1,13 +1,14 @@ -import { async, TestBed } from '@angular/core/testing'; +import { TestBed } from '@angular/core/testing'; import { CertificateDetailComponent } from './certificate-detail.component'; import { TestBedHelper, ActivatedRouteStub } from '../../../../../../common/src/app/spec/spec-utils'; import { RouterTestingModule } from '@angular/router/testing'; import { Router, ActivatedRoute } from '@angular/router'; -import { GlobalModule } from 'nrpti-angular-components'; +import { GlobalModule, StoreService } from 'nrpti-angular-components'; import { RecordDetailDirective } from '../../utils/record-detail.directive'; import { DatePipe } from '@angular/common'; import { CommonModule } from '../../../../../../common/src/app/common.module'; import { FactoryService } from '../../../services/factory.service'; +import { EventEmitter } from '@angular/core'; describe('CertificateDetailComponent', () => { const testBedHelper = new TestBedHelper(CertificateDetailComponent); @@ -15,17 +16,24 @@ describe('CertificateDetailComponent', () => { // component constructor mocks const mockRouter = jasmine.createSpyObj('Router', ['navigate']); const mockActivatedRoute = new ActivatedRouteStub(); - const mockFactoryService = jasmine.createSpyObj('FactoryService', ['userInLngRole', 'userInNrcedRole']); + const mockFactoryService = jasmine.createSpyObj('FactoryService', ['userInLngRole', 'userInBcmiRole', 'userInNrcedRole']); mockFactoryService.userInLngRole.and.returnValue(true); + mockFactoryService.userInBcmiRole.and.returnValue(true); mockFactoryService.userInNrcedRole.and.returnValue(true); - beforeEach(async(() => { + const mockStoreService = { + getItem: () => { }, + stateChange: new EventEmitter() + }; + + beforeEach((() => { TestBed.configureTestingModule({ imports: [RouterTestingModule, GlobalModule, CommonModule], declarations: [CertificateDetailComponent, RecordDetailDirective], providers: [ DatePipe, { provide: Router, useValue: mockRouter }, + { provide: StoreService, useValue: mockStoreService }, { provide: ActivatedRoute, useValue: mockActivatedRoute }, { provide: FactoryService, useValue: mockFactoryService } ] diff --git a/angular/projects/admin-nrpti/src/app/records/certificates/certificate-lng-detail/certificate-lng-detail.component.spec.ts b/angular/projects/admin-nrpti/src/app/records/certificates/certificate-lng-detail/certificate-lng-detail.component.spec.ts index 8b9331012..13cfe7486 100644 --- a/angular/projects/admin-nrpti/src/app/records/certificates/certificate-lng-detail/certificate-lng-detail.component.spec.ts +++ b/angular/projects/admin-nrpti/src/app/records/certificates/certificate-lng-detail/certificate-lng-detail.component.spec.ts @@ -1,11 +1,12 @@ -import { async, TestBed } from '@angular/core/testing'; +import { TestBed } from '@angular/core/testing'; import { CertificateLNGDetailComponent } from './certificate-lng-detail.component'; import { TestBedHelper, ActivatedRouteStub } from '../../../../../../common/src/app/spec/spec-utils'; import { RouterTestingModule } from '@angular/router/testing'; import { Router, ActivatedRoute } from '@angular/router'; -import { GlobalModule } from 'nrpti-angular-components'; +import { GlobalModule, StoreService } from 'nrpti-angular-components'; import { DatePipe } from '@angular/common'; import { FactoryService } from '../../../services/factory.service'; +import { EventEmitter } from '@angular/core'; describe('CertificateLNGDetailComponent', () => { const testBedHelper = new TestBedHelper(CertificateLNGDetailComponent); @@ -13,16 +14,24 @@ describe('CertificateLNGDetailComponent', () => { // component constructor mocks const mockRouter = jasmine.createSpyObj('Router', ['navigate']); const mockActivatedRoute = new ActivatedRouteStub(); - const mockFactoryService = jasmine.createSpyObj('FactoryService', ['userInLngRole']); + const mockFactoryService = jasmine.createSpyObj('FactoryService', ['userInLngRole', 'userInBcmiRole', 'userInNrcedRole']); mockFactoryService.userInLngRole.and.returnValue(true); + mockFactoryService.userInBcmiRole.and.returnValue(true); + mockFactoryService.userInNrcedRole.and.returnValue(true); - beforeEach(async(() => { + const mockStoreService = { + getItem: () => { }, + stateChange: new EventEmitter() + }; + + beforeEach((() => { TestBed.configureTestingModule({ imports: [RouterTestingModule, GlobalModule], declarations: [CertificateLNGDetailComponent], providers: [ DatePipe, { provide: Router, useValue: mockRouter }, + { provide: StoreService, useValue: mockStoreService }, { provide: ActivatedRoute, useValue: mockActivatedRoute }, { provide: FactoryService, useValue: mockFactoryService } ] diff --git a/angular/projects/admin-nrpti/src/app/records/construction-plans/construction-plan-add-edit/construction-plan-add-edit.component.html b/angular/projects/admin-nrpti/src/app/records/construction-plans/construction-plan-add-edit/construction-plan-add-edit.component.html index 93d5763c4..8260151e0 100644 --- a/angular/projects/admin-nrpti/src/app/records/construction-plans/construction-plan-add-edit/construction-plan-add-edit.component.html +++ b/angular/projects/admin-nrpti/src/app/records/construction-plans/construction-plan-add-edit/construction-plan-add-edit.component.html @@ -76,32 +76,19 @@

Basic Information

+
+

Issued To

+ + +
+

Location Details

-
- - (If Applicable) -
-
- - -
-
- - -
-
- - -
-
-
diff --git a/angular/projects/admin-nrpti/src/app/records/construction-plans/construction-plan-add-edit/construction-plan-add-edit.component.spec.ts b/angular/projects/admin-nrpti/src/app/records/construction-plans/construction-plan-add-edit/construction-plan-add-edit.component.spec.ts index 947f6c2a7..204f5786a 100644 --- a/angular/projects/admin-nrpti/src/app/records/construction-plans/construction-plan-add-edit/construction-plan-add-edit.component.spec.ts +++ b/angular/projects/admin-nrpti/src/app/records/construction-plans/construction-plan-add-edit/construction-plan-add-edit.component.spec.ts @@ -1,4 +1,4 @@ -import { async, TestBed } from '@angular/core/testing'; +import { TestBed } from '@angular/core/testing'; import { NgbModule } from '@ng-bootstrap/ng-bootstrap'; import { FormsModule, ReactiveFormsModule } from '@angular/forms'; import { ConstructionPlanAddEditComponent } from './construction-plan-add-edit.component'; @@ -10,8 +10,9 @@ import { NgxPaginationModule } from 'ngx-pagination'; import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core'; import { Utils } from 'nrpti-angular-components'; import { RecordUtils } from '../../utils/record-utils'; -import { LoadingScreenService } from 'nrpti-angular-components'; +import { LoadingScreenService, StoreService } from 'nrpti-angular-components'; import { FactoryService } from '../../../services/factory.service'; +import { EventEmitter } from '@angular/core'; describe('ConstructionPlanAddEditComponent', () => { const testBedHelper = new TestBedHelper(ConstructionPlanAddEditComponent); @@ -20,10 +21,16 @@ describe('ConstructionPlanAddEditComponent', () => { const mockLocation = jasmine.createSpyObj('Location', ['go']); const mockRouter = jasmine.createSpyObj('Router', ['navigate']); const mockActivatedRoute = new ActivatedRouteStub(); - const mockFactoryService = jasmine.createSpyObj('FactoryService', ['userInLngRole', 'userInNrcedRole']); + const mockFactoryService = jasmine.createSpyObj('FactoryService', ['userInLngRole', 'userInBcmiRole', 'userInNrcedRole']); mockFactoryService.userInLngRole.and.returnValue(true); + mockFactoryService.userInBcmiRole.and.returnValue(true); mockFactoryService.userInNrcedRole.and.returnValue(true); + const mockStoreService = { + getItem: () => { }, + stateChange: new EventEmitter() + }; + const mockLoadingScreenService = { isLoading: false, setLoadingState: () => { @@ -31,7 +38,7 @@ describe('ConstructionPlanAddEditComponent', () => { } }; - beforeEach(async(() => { + beforeEach((() => { TestBed.configureTestingModule({ imports: [ RouterTestingModule, @@ -46,6 +53,7 @@ describe('ConstructionPlanAddEditComponent', () => { Utils, RecordUtils, { provide: LoadingScreenService, useValue: mockLoadingScreenService }, + { provide: StoreService, useValue: mockStoreService }, { provide: Location, useValue: mockLocation }, { provide: Router, useValue: mockRouter }, { provide: ActivatedRoute, useValue: mockActivatedRoute }, diff --git a/angular/projects/admin-nrpti/src/app/records/construction-plans/construction-plan-add-edit/construction-plan-add-edit.component.ts b/angular/projects/admin-nrpti/src/app/records/construction-plans/construction-plan-add-edit/construction-plan-add-edit.component.ts index d3db8139f..005ee1528 100644 --- a/angular/projects/admin-nrpti/src/app/records/construction-plans/construction-plan-add-edit/construction-plan-add-edit.component.ts +++ b/angular/projects/admin-nrpti/src/app/records/construction-plans/construction-plan-add-edit/construction-plan-add-edit.component.ts @@ -8,7 +8,7 @@ import { FactoryService } from '../../../services/factory.service'; import { Utils } from 'nrpti-angular-components'; import { Utils as CommonUtils } from '../../../../../../common/src/app/utils/utils'; import { RecordUtils } from '../../utils/record-utils'; -import { LoadingScreenService } from 'nrpti-angular-components'; +import { LoadingScreenService, StoreService } from 'nrpti-angular-components'; @Component({ selector: 'app-construction-plan-add-edit', @@ -40,6 +40,7 @@ export class ConstructionPlanAddEditComponent implements OnInit, OnDestroy { public route: ActivatedRoute, public router: Router, private recordUtils: RecordUtils, + private storeService: StoreService, private factoryService: FactoryService, private loadingScreenService: LoadingScreenService, private utils: Utils, @@ -142,6 +143,17 @@ export class ConstructionPlanAddEditComponent implements OnInit, OnDestroy { publishLng: new FormControl({ value: (this.currentRecord && this.lngFlavour && this.lngFlavour.read.includes('public')) || false, disabled: !this.factoryService.userInLngRole() + }), + + association: new FormGroup({ + _epicProjectId: new FormControl({ + value: this.currentRecord && this.currentRecord._epicProjectId || null, + disabled: this.currentRecord && this.currentRecord.sourceSystemRef !== 'nrpti' + }), + mineGuid: new FormControl({ + value: this.currentRecord && this.currentRecord.mineGuid || null, + disabled: this.currentRecord && this.currentRecord.sourceSystemRef !== 'nrpti' + }) }) }); } @@ -213,6 +225,23 @@ export class ConstructionPlanAddEditComponent implements OnInit, OnDestroy { constructionPlan['ConstructionPlanLNG']['removeRole'] = 'public'; } + if (this.myForm.get('association._epicProjectId').dirty) { + constructionPlan['_epicProjectId'] = this.myForm.get('association._epicProjectId').value; + } + + if (this.myForm.get('association.mineGuid').dirty) { + constructionPlan['mineGuid'] = this.myForm.get('association.mineGuid').value; + } + + // Set the friendly name of projectName + const epicProjectList = this.storeService.getItem('epicProjects'); + const filterResult = epicProjectList.filter(item => { + return item._id === constructionPlan['_epicProjectId']; + }); + if (filterResult && filterResult[0] && filterResult[0].name) { + constructionPlan['projectName'] = filterResult[0].name; + } + if (!this.isEditing) { this.factoryService.writeRecord(constructionPlan, 'constructionPlans', true).subscribe(async res => { this.recordUtils.parseResForErrors(res); diff --git a/angular/projects/admin-nrpti/src/app/records/construction-plans/construction-plan-detail/construction-plan-detail.component.html b/angular/projects/admin-nrpti/src/app/records/construction-plans/construction-plan-detail/construction-plan-detail.component.html index 2e8be3eee..c8bcc3318 100644 --- a/angular/projects/admin-nrpti/src/app/records/construction-plans/construction-plan-detail/construction-plan-detail.component.html +++ b/angular/projects/admin-nrpti/src/app/records/construction-plans/construction-plan-detail/construction-plan-detail.component.html @@ -44,7 +44,7 @@

Shared Data [Master]

- {{ (data && data._master.sourceSystemRef) || '-' }} + {{ (data && data._master && data._master.sourceSystemRef) || '-' }}
diff --git a/angular/projects/admin-nrpti/src/app/records/construction-plans/construction-plan-detail/construction-plan-detail.component.spec.ts b/angular/projects/admin-nrpti/src/app/records/construction-plans/construction-plan-detail/construction-plan-detail.component.spec.ts index e6a6691fe..4c6496765 100644 --- a/angular/projects/admin-nrpti/src/app/records/construction-plans/construction-plan-detail/construction-plan-detail.component.spec.ts +++ b/angular/projects/admin-nrpti/src/app/records/construction-plans/construction-plan-detail/construction-plan-detail.component.spec.ts @@ -1,13 +1,14 @@ -import { async, TestBed } from '@angular/core/testing'; +import { TestBed } from '@angular/core/testing'; import { ConstructionPlanDetailComponent } from './construction-plan-detail.component'; import { TestBedHelper, ActivatedRouteStub } from '../../../../../../common/src/app/spec/spec-utils'; import { RouterTestingModule } from '@angular/router/testing'; import { Router, ActivatedRoute } from '@angular/router'; -import { GlobalModule } from 'nrpti-angular-components'; +import { GlobalModule, StoreService } from 'nrpti-angular-components'; import { RecordDetailDirective } from '../../utils/record-detail.directive'; import { DatePipe } from '@angular/common'; import { CommonModule } from '../../../../../../common/src/app/common.module'; import { FactoryService } from '../../../services/factory.service'; +import { EventEmitter } from '@angular/core'; describe('ConstructionPlanDetailComponent', () => { const testBedHelper = new TestBedHelper(ConstructionPlanDetailComponent); @@ -15,17 +16,24 @@ describe('ConstructionPlanDetailComponent', () => { // component constructor mocks const mockRouter = jasmine.createSpyObj('Router', ['navigate']); const mockActivatedRoute = new ActivatedRouteStub(); - const mockFactoryService = jasmine.createSpyObj('FactoryService', ['userInLngRole', 'userInNrcedRole']); + const mockFactoryService = jasmine.createSpyObj('FactoryService', ['userInLngRole', 'userInBcmiRole', 'userInNrcedRole']); mockFactoryService.userInLngRole.and.returnValue(true); + mockFactoryService.userInBcmiRole.and.returnValue(true); mockFactoryService.userInNrcedRole.and.returnValue(true); - beforeEach(async(() => { + const mockStoreService = { + getItem: () => { }, + stateChange: new EventEmitter() + }; + + beforeEach((() => { TestBed.configureTestingModule({ imports: [RouterTestingModule, GlobalModule, CommonModule], declarations: [ConstructionPlanDetailComponent, RecordDetailDirective], providers: [ DatePipe, { provide: Router, useValue: mockRouter }, + { provide: StoreService, useValue: mockStoreService }, { provide: ActivatedRoute, useValue: mockActivatedRoute }, { provide: FactoryService, useValue: mockFactoryService } ] diff --git a/angular/projects/admin-nrpti/src/app/records/construction-plans/construction-plan-lng-detail/construction-plan-lng-detail.component.spec.ts b/angular/projects/admin-nrpti/src/app/records/construction-plans/construction-plan-lng-detail/construction-plan-lng-detail.component.spec.ts index 2a494ea56..ae53f75eb 100644 --- a/angular/projects/admin-nrpti/src/app/records/construction-plans/construction-plan-lng-detail/construction-plan-lng-detail.component.spec.ts +++ b/angular/projects/admin-nrpti/src/app/records/construction-plans/construction-plan-lng-detail/construction-plan-lng-detail.component.spec.ts @@ -1,4 +1,4 @@ -import { async, TestBed } from '@angular/core/testing'; +import { TestBed } from '@angular/core/testing'; import { ConstructionPlanLNGDetailComponent } from './construction-plan-lng-detail.component'; import { TestBedHelper, ActivatedRouteStub } from '../../../../../../common/src/app/spec/spec-utils'; import { RouterTestingModule } from '@angular/router/testing'; @@ -16,7 +16,7 @@ describe('ConstructionPlanLNGDetailComponent', () => { const mockFactoryService = jasmine.createSpyObj('FactoryService', ['userInLngRole']); mockFactoryService.userInLngRole.and.returnValue(true); - beforeEach(async(() => { + beforeEach((() => { TestBed.configureTestingModule({ imports: [RouterTestingModule, GlobalModule], declarations: [ConstructionPlanLNGDetailComponent], diff --git a/angular/projects/admin-nrpti/src/app/records/correspondences/correspondence-add-edit/correspondence-add-edit.component.html b/angular/projects/admin-nrpti/src/app/records/correspondences/correspondence-add-edit/correspondence-add-edit.component.html index f15880d08..e7a388350 100644 --- a/angular/projects/admin-nrpti/src/app/records/correspondences/correspondence-add-edit/correspondence-add-edit.component.html +++ b/angular/projects/admin-nrpti/src/app/records/correspondences/correspondence-add-edit/correspondence-add-edit.component.html @@ -94,32 +94,14 @@

Legislation

Issued To

-
-
- - (If Applicable) -
-
- - -
-
- - -
-
- - -
-
-
-
+ + +
diff --git a/angular/projects/admin-nrpti/src/app/records/correspondences/correspondence-add-edit/correspondence-add-edit.component.spec.ts b/angular/projects/admin-nrpti/src/app/records/correspondences/correspondence-add-edit/correspondence-add-edit.component.spec.ts index 94a67b51a..bb10d9b3e 100644 --- a/angular/projects/admin-nrpti/src/app/records/correspondences/correspondence-add-edit/correspondence-add-edit.component.spec.ts +++ b/angular/projects/admin-nrpti/src/app/records/correspondences/correspondence-add-edit/correspondence-add-edit.component.spec.ts @@ -1,17 +1,17 @@ -import { async, TestBed } from '@angular/core/testing'; +import { TestBed } from '@angular/core/testing'; import { NgbModule } from '@ng-bootstrap/ng-bootstrap'; import { FormsModule, ReactiveFormsModule } from '@angular/forms'; import { CorrespondenceAddEditComponent } from './correspondence-add-edit.component'; import { TestBedHelper, ActivatedRouteStub } from '../../../../../../common/src/app/spec/spec-utils'; import { RouterTestingModule } from '@angular/router/testing'; import { Router, ActivatedRoute } from '@angular/router'; -import { GlobalModule } from 'nrpti-angular-components'; import { NgxPaginationModule } from 'ngx-pagination'; import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core'; import { Utils } from 'nrpti-angular-components'; import { RecordUtils } from '../../utils/record-utils'; -import { LoadingScreenService } from 'nrpti-angular-components'; +import { GlobalModule, LoadingScreenService, StoreService } from 'nrpti-angular-components'; import { FactoryService } from '../../../services/factory.service'; +import { EventEmitter } from '@angular/core'; describe('CorrespondenceAddEditComponent', () => { const testBedHelper = new TestBedHelper(CorrespondenceAddEditComponent); @@ -20,10 +20,16 @@ describe('CorrespondenceAddEditComponent', () => { const mockLocation = jasmine.createSpyObj('Location', ['go']); const mockRouter = jasmine.createSpyObj('Router', ['navigate']); const mockActivatedRoute = new ActivatedRouteStub(); - const mockFactoryService = jasmine.createSpyObj('FactoryService', ['userInBcmiRole', 'userInNrcedRole']); + const mockFactoryService = jasmine.createSpyObj('FactoryService', ['userInLngRole', 'userInBcmiRole', 'userInNrcedRole']); + mockFactoryService.userInLngRole.and.returnValue(true); mockFactoryService.userInBcmiRole.and.returnValue(true); mockFactoryService.userInNrcedRole.and.returnValue(true); + const mockStoreService = { + getItem: () => { }, + stateChange: new EventEmitter() + }; + const mockLoadingScreenService = { isLoading: false, setLoadingState: () => { @@ -31,7 +37,7 @@ describe('CorrespondenceAddEditComponent', () => { } }; - beforeEach(async(() => { + beforeEach((() => { TestBed.configureTestingModule({ imports: [ RouterTestingModule, @@ -46,6 +52,7 @@ describe('CorrespondenceAddEditComponent', () => { Utils, RecordUtils, { provide: LoadingScreenService, useValue: mockLoadingScreenService }, + { provide: StoreService, useValue: mockStoreService }, { provide: Location, useValue: mockLocation }, { provide: Router, useValue: mockRouter }, { provide: ActivatedRoute, useValue: mockActivatedRoute }, diff --git a/angular/projects/admin-nrpti/src/app/records/correspondences/correspondence-add-edit/correspondence-add-edit.component.ts b/angular/projects/admin-nrpti/src/app/records/correspondences/correspondence-add-edit/correspondence-add-edit.component.ts index 94a969726..f419b6854 100644 --- a/angular/projects/admin-nrpti/src/app/records/correspondences/correspondence-add-edit/correspondence-add-edit.component.ts +++ b/angular/projects/admin-nrpti/src/app/records/correspondences/correspondence-add-edit/correspondence-add-edit.component.ts @@ -9,7 +9,7 @@ import { FactoryService } from '../../../services/factory.service'; import { Utils } from 'nrpti-angular-components'; import { Utils as CommonUtils } from '../../../../../../common/src/app/utils/utils'; import { RecordUtils } from '../../utils/record-utils'; -import { LoadingScreenService } from 'nrpti-angular-components'; +import { LoadingScreenService, StoreService } from 'nrpti-angular-components'; @Component({ selector: 'app-correspondence-add-edit', @@ -42,6 +42,7 @@ export class CorrespondenceAddEditComponent implements OnInit, OnDestroy { public route: ActivatedRoute, public router: Router, private recordUtils: RecordUtils, + private storeService: StoreService, private factoryService: FactoryService, private loadingScreenService: LoadingScreenService, private utils: Utils, @@ -254,6 +255,17 @@ export class CorrespondenceAddEditComponent implements OnInit, OnDestroy { publishBcmi: new FormControl({ value: (this.currentRecord && this.bcmiFlavour && this.bcmiFlavour.read.includes('public')) || false, disabled: !this.factoryService.userInBcmiRole() + }), + + association: new FormGroup({ + _epicProjectId: new FormControl({ + value: this.currentRecord && this.currentRecord._epicProjectId || null, + disabled: this.currentRecord && this.currentRecord.sourceSystemRef !== 'nrpti' + }), + mineGuid: new FormControl({ + value: this.currentRecord && this.currentRecord.mineGuid || null, + disabled: this.currentRecord && this.currentRecord.sourceSystemRef !== 'nrpti' + }) }) }); } @@ -373,6 +385,23 @@ export class CorrespondenceAddEditComponent implements OnInit, OnDestroy { correspondence['CorrespondenceBCMI']['removeRole'] = 'public'; } + if (this.myForm.get('association._epicProjectId').dirty) { + correspondence['_epicProjectId'] = this.myForm.get('association._epicProjectId').value; + } + + if (this.myForm.get('association.mineGuid').dirty) { + correspondence['mineGuid'] = this.myForm.get('association.mineGuid').value; + } + + // Set the friendly name of projectName + const epicProjectList = this.storeService.getItem('epicProjects'); + const filterResult = epicProjectList.filter(item => { + return item._id === correspondence['_epicProjectId']; + }); + if (filterResult && filterResult[0] && filterResult[0].name) { + correspondence['projectName'] = filterResult[0].name; + } + if (!this.isEditing) { this.factoryService.writeRecord(correspondence, 'correspondences', true).subscribe(async res => { this.recordUtils.parseResForErrors(res); diff --git a/angular/projects/admin-nrpti/src/app/records/correspondences/correspondence-bcmi-detail/correspondence-bcmi-detail.component.spec.ts b/angular/projects/admin-nrpti/src/app/records/correspondences/correspondence-bcmi-detail/correspondence-bcmi-detail.component.spec.ts index 7c8ab5bfa..7307913c0 100644 --- a/angular/projects/admin-nrpti/src/app/records/correspondences/correspondence-bcmi-detail/correspondence-bcmi-detail.component.spec.ts +++ b/angular/projects/admin-nrpti/src/app/records/correspondences/correspondence-bcmi-detail/correspondence-bcmi-detail.component.spec.ts @@ -1,11 +1,12 @@ -import { async, TestBed } from '@angular/core/testing'; +import { TestBed } from '@angular/core/testing'; import { CorrespondenceBCMIDetailComponent } from './correspondence-bcmi-detail.component'; import { TestBedHelper, ActivatedRouteStub } from '../../../../../../common/src/app/spec/spec-utils'; import { RouterTestingModule } from '@angular/router/testing'; import { Router, ActivatedRoute } from '@angular/router'; -import { GlobalModule } from 'nrpti-angular-components'; +import { GlobalModule, StoreService } from 'nrpti-angular-components'; import { DatePipe } from '@angular/common'; import { FactoryService } from '../../../services/factory.service'; +import { EventEmitter } from '@angular/core'; describe('CorrespondenceBCMIDetailComponent', () => { const testBedHelper = new TestBedHelper @@ -14,16 +15,24 @@ describe('CorrespondenceBCMIDetailComponent', () => { // component constructor mocks const mockRouter = jasmine.createSpyObj('Router', ['navigate']); const mockActivatedRoute = new ActivatedRouteStub(); - const mockFactoryService = jasmine.createSpyObj('FactoryService', ['userInBcmiRole']); + const mockFactoryService = jasmine.createSpyObj('FactoryService', ['userInLngRole', 'userInBcmiRole', 'userInNrcedRole']); + mockFactoryService.userInLngRole.and.returnValue(true); mockFactoryService.userInBcmiRole.and.returnValue(true); + mockFactoryService.userInNrcedRole.and.returnValue(true); - beforeEach(async(() => { + const mockStoreService = { + getItem: () => { }, + stateChange: new EventEmitter() + }; + + beforeEach((() => { TestBed.configureTestingModule({ imports: [RouterTestingModule, GlobalModule], declarations: [CorrespondenceBCMIDetailComponent], providers: [ DatePipe, { provide: Router, useValue: mockRouter }, + { provide: StoreService, useValue: mockStoreService }, { provide: ActivatedRoute, useValue: mockActivatedRoute }, { provide: FactoryService, useValue: mockFactoryService } ] diff --git a/angular/projects/admin-nrpti/src/app/records/correspondences/correspondence-detail/correspondence-detail.component.html b/angular/projects/admin-nrpti/src/app/records/correspondences/correspondence-detail/correspondence-detail.component.html index 77eef6f78..f0cca4476 100644 --- a/angular/projects/admin-nrpti/src/app/records/correspondences/correspondence-detail/correspondence-detail.component.html +++ b/angular/projects/admin-nrpti/src/app/records/correspondences/correspondence-detail/correspondence-detail.component.html @@ -48,7 +48,7 @@

Shared Data [Master]

- {{ (data && data._master.sourceSystemRef) || '-' }} + {{ (data && data._master && data._master.sourceSystemRef) || '-' }}
diff --git a/angular/projects/admin-nrpti/src/app/records/correspondences/correspondence-detail/correspondence-detail.component.spec.ts b/angular/projects/admin-nrpti/src/app/records/correspondences/correspondence-detail/correspondence-detail.component.spec.ts index efefdae94..a0dde4874 100644 --- a/angular/projects/admin-nrpti/src/app/records/correspondences/correspondence-detail/correspondence-detail.component.spec.ts +++ b/angular/projects/admin-nrpti/src/app/records/correspondences/correspondence-detail/correspondence-detail.component.spec.ts @@ -1,13 +1,14 @@ -import { async, TestBed } from '@angular/core/testing'; +import { TestBed } from '@angular/core/testing'; import { CorrespondenceDetailComponent } from './correspondence-detail.component'; import { TestBedHelper, ActivatedRouteStub } from '../../../../../../common/src/app/spec/spec-utils'; import { RouterTestingModule } from '@angular/router/testing'; import { Router, ActivatedRoute } from '@angular/router'; -import { GlobalModule } from 'nrpti-angular-components'; +import { GlobalModule, StoreService } from 'nrpti-angular-components'; import { RecordDetailDirective } from '../../utils/record-detail.directive'; import { DatePipe } from '@angular/common'; import { CommonModule } from '../../../../../../common/src/app/common.module'; import { FactoryService } from '../../../services/factory.service'; +import { EventEmitter } from '@angular/core'; describe('CorrespondenceDetailComponent', () => { const testBedHelper = new TestBedHelper(CorrespondenceDetailComponent); @@ -15,17 +16,24 @@ describe('CorrespondenceDetailComponent', () => { // component constructor mocks const mockRouter = jasmine.createSpyObj('Router', ['navigate']); const mockActivatedRoute = new ActivatedRouteStub(); - const mockFactoryService = jasmine.createSpyObj('FactoryService', ['userInBcmiRole', 'userInNrcedRole']); + const mockFactoryService = jasmine.createSpyObj('FactoryService', ['userInLngRole', 'userInBcmiRole', 'userInNrcedRole']); + mockFactoryService.userInLngRole.and.returnValue(true); mockFactoryService.userInBcmiRole.and.returnValue(true); mockFactoryService.userInNrcedRole.and.returnValue(true); - beforeEach(async(() => { + const mockStoreService = { + getItem: () => { }, + stateChange: new EventEmitter() + }; + + beforeEach((() => { TestBed.configureTestingModule({ imports: [RouterTestingModule, GlobalModule, CommonModule], declarations: [CorrespondenceDetailComponent, RecordDetailDirective], providers: [ DatePipe, { provide: Router, useValue: mockRouter }, + { provide: StoreService, useValue: mockStoreService }, { provide: ActivatedRoute, useValue: mockActivatedRoute }, { provide: FactoryService, useValue: mockFactoryService } ] diff --git a/angular/projects/admin-nrpti/src/app/records/correspondences/correspondence-nrced-detail/correspondence-nrced-detail.component.spec.ts b/angular/projects/admin-nrpti/src/app/records/correspondences/correspondence-nrced-detail/correspondence-nrced-detail.component.spec.ts index 13b509280..adce44a5c 100644 --- a/angular/projects/admin-nrpti/src/app/records/correspondences/correspondence-nrced-detail/correspondence-nrced-detail.component.spec.ts +++ b/angular/projects/admin-nrpti/src/app/records/correspondences/correspondence-nrced-detail/correspondence-nrced-detail.component.spec.ts @@ -1,4 +1,4 @@ -import { async, TestBed } from '@angular/core/testing'; +import { TestBed } from '@angular/core/testing'; import { CorrespondenceNRCEDDetailComponent } from './correspondence-nrced-detail.component'; import { TestBedHelper, ActivatedRouteStub } from '../../../../../../common/src/app/spec/spec-utils'; import { RouterTestingModule } from '@angular/router/testing'; @@ -17,7 +17,7 @@ describe('CorrespondenceNRCEDDetailComponent', () => { const mockFactoryService = jasmine.createSpyObj('FactoryService', ['userInNrcedRole']); mockFactoryService.userInNrcedRole.and.returnValue(true); - beforeEach(async(() => { + beforeEach((() => { TestBed.configureTestingModule({ imports: [RouterTestingModule, GlobalModule], declarations: [CorrespondenceNRCEDDetailComponent], diff --git a/angular/projects/admin-nrpti/src/app/records/court-convictions/court-conviction-add-edit/court-conviction-add-edit.component.spec.ts b/angular/projects/admin-nrpti/src/app/records/court-convictions/court-conviction-add-edit/court-conviction-add-edit.component.spec.ts index fabe30ad6..02f32620f 100644 --- a/angular/projects/admin-nrpti/src/app/records/court-convictions/court-conviction-add-edit/court-conviction-add-edit.component.spec.ts +++ b/angular/projects/admin-nrpti/src/app/records/court-convictions/court-conviction-add-edit/court-conviction-add-edit.component.spec.ts @@ -1,4 +1,4 @@ -import { async, TestBed } from '@angular/core/testing'; +import { TestBed } from '@angular/core/testing'; import { NgbModule } from '@ng-bootstrap/ng-bootstrap'; import { FormsModule, ReactiveFormsModule } from '@angular/forms'; import { CourtConvictionAddEditComponent } from './court-conviction-add-edit.component'; @@ -25,7 +25,7 @@ describe('CourtConvictionAddEditComponent', () => { mockFactoryService.userInLngRole.and.returnValue(true); mockFactoryService.userInNrcedRole.and.returnValue(true); - beforeEach(async(() => { + beforeEach((() => { TestBed.configureTestingModule({ imports: [ RouterTestingModule, diff --git a/angular/projects/admin-nrpti/src/app/records/court-convictions/court-conviction-detail/court-conviction-detail.component.html b/angular/projects/admin-nrpti/src/app/records/court-convictions/court-conviction-detail/court-conviction-detail.component.html index d5abf69c5..eb39b2c62 100644 --- a/angular/projects/admin-nrpti/src/app/records/court-convictions/court-conviction-detail/court-conviction-detail.component.html +++ b/angular/projects/admin-nrpti/src/app/records/court-convictions/court-conviction-detail/court-conviction-detail.component.html @@ -52,7 +52,7 @@

Shared Data [Master]

- {{ (data && data._master.sourceSystemRef) || '-' }} + {{ (data && data._master && data._master.sourceSystemRef) || '-' }}
diff --git a/angular/projects/admin-nrpti/src/app/records/court-convictions/court-conviction-detail/court-conviction-detail.component.spec.ts b/angular/projects/admin-nrpti/src/app/records/court-convictions/court-conviction-detail/court-conviction-detail.component.spec.ts index cf96ec6b6..e75ca8dcc 100644 --- a/angular/projects/admin-nrpti/src/app/records/court-convictions/court-conviction-detail/court-conviction-detail.component.spec.ts +++ b/angular/projects/admin-nrpti/src/app/records/court-convictions/court-conviction-detail/court-conviction-detail.component.spec.ts @@ -1,4 +1,4 @@ -import { async, TestBed } from '@angular/core/testing'; +import { TestBed } from '@angular/core/testing'; import { CourtConvictionDetailComponent } from './court-conviction-detail.component'; import { TestBedHelper, ActivatedRouteStub } from '../../../../../../common/src/app/spec/spec-utils'; import { RouterTestingModule } from '@angular/router/testing'; @@ -21,7 +21,7 @@ describe('CourtConvictionDetailComponent', () => { mockFactoryService.userInLngRole.and.returnValue(true); mockFactoryService.userInNrcedRole.and.returnValue(true); - beforeEach(async(() => { + beforeEach((() => { TestBed.configureTestingModule({ imports: [RouterTestingModule, GlobalModule, CommonModule], declarations: [ diff --git a/angular/projects/admin-nrpti/src/app/records/court-convictions/court-conviction-lng-detail/court-conviction-lng-detail.component.spec.ts b/angular/projects/admin-nrpti/src/app/records/court-convictions/court-conviction-lng-detail/court-conviction-lng-detail.component.spec.ts index dca4cb5f9..8f50e1042 100644 --- a/angular/projects/admin-nrpti/src/app/records/court-convictions/court-conviction-lng-detail/court-conviction-lng-detail.component.spec.ts +++ b/angular/projects/admin-nrpti/src/app/records/court-convictions/court-conviction-lng-detail/court-conviction-lng-detail.component.spec.ts @@ -1,4 +1,4 @@ -import { async, TestBed } from '@angular/core/testing'; +import { TestBed } from '@angular/core/testing'; import { CourtConvictionLNGDetailComponent } from './court-conviction-lng-detail.component'; import { TestBedHelper, ActivatedRouteStub } from '../../../../../../common/src/app/spec/spec-utils'; import { RouterTestingModule } from '@angular/router/testing'; @@ -16,7 +16,7 @@ describe('CourtConvictionLNGDetailComponent', () => { const mockFactoryService = jasmine.createSpyObj('FactoryService', ['userInLngRole']); mockFactoryService.userInLngRole.and.returnValue(true); - beforeEach(async(() => { + beforeEach((() => { TestBed.configureTestingModule({ imports: [RouterTestingModule, GlobalModule], declarations: [CourtConvictionLNGDetailComponent], diff --git a/angular/projects/admin-nrpti/src/app/records/court-convictions/court-conviction-nrced-detail/court-conviction-nrced-detail.component.spec.ts b/angular/projects/admin-nrpti/src/app/records/court-convictions/court-conviction-nrced-detail/court-conviction-nrced-detail.component.spec.ts index 871b9c0b7..aadad9d3a 100644 --- a/angular/projects/admin-nrpti/src/app/records/court-convictions/court-conviction-nrced-detail/court-conviction-nrced-detail.component.spec.ts +++ b/angular/projects/admin-nrpti/src/app/records/court-convictions/court-conviction-nrced-detail/court-conviction-nrced-detail.component.spec.ts @@ -1,4 +1,4 @@ -import { async, TestBed } from '@angular/core/testing'; +import { TestBed } from '@angular/core/testing'; import { CourtConvictionNRCEDDetailComponent } from './court-conviction-nrced-detail.component'; import { TestBedHelper, ActivatedRouteStub } from '../../../../../../common/src/app/spec/spec-utils'; import { RouterTestingModule } from '@angular/router/testing'; @@ -16,7 +16,7 @@ describe('CourtConvictionNRCEDDetailComponent', () => { const mockFactoryService = jasmine.createSpyObj('FactoryService', ['userInNrcedRole']); mockFactoryService.userInNrcedRole.and.returnValue(true); - beforeEach(async(() => { + beforeEach((() => { TestBed.configureTestingModule({ imports: [RouterTestingModule, GlobalModule], declarations: [CourtConvictionNRCEDDetailComponent], diff --git a/angular/projects/admin-nrpti/src/app/records/dam-safety-inspections/dam-safety-inspection-add-edit/dam-safety-inspection-add-edit.component.html b/angular/projects/admin-nrpti/src/app/records/dam-safety-inspections/dam-safety-inspection-add-edit/dam-safety-inspection-add-edit.component.html index 14337f8dc..97ba8b68f 100644 --- a/angular/projects/admin-nrpti/src/app/records/dam-safety-inspections/dam-safety-inspection-add-edit/dam-safety-inspection-add-edit.component.html +++ b/angular/projects/admin-nrpti/src/app/records/dam-safety-inspections/dam-safety-inspection-add-edit/dam-safety-inspection-add-edit.component.html @@ -94,32 +94,14 @@

Legislation

Issued To

-
-
- - (If Applicable) -
-
- - -
-
- - -
-
- - -
-
-
-
+ + +
diff --git a/angular/projects/admin-nrpti/src/app/records/dam-safety-inspections/dam-safety-inspection-add-edit/dam-safety-inspection-add-edit.component.spec.ts b/angular/projects/admin-nrpti/src/app/records/dam-safety-inspections/dam-safety-inspection-add-edit/dam-safety-inspection-add-edit.component.spec.ts index b4c873cb3..eee607177 100644 --- a/angular/projects/admin-nrpti/src/app/records/dam-safety-inspections/dam-safety-inspection-add-edit/dam-safety-inspection-add-edit.component.spec.ts +++ b/angular/projects/admin-nrpti/src/app/records/dam-safety-inspections/dam-safety-inspection-add-edit/dam-safety-inspection-add-edit.component.spec.ts @@ -1,4 +1,4 @@ -import { async, TestBed } from '@angular/core/testing'; +import { TestBed } from '@angular/core/testing'; import { NgbModule } from '@ng-bootstrap/ng-bootstrap'; import { FormsModule, ReactiveFormsModule } from '@angular/forms'; import { DamSafetyInspectionAddEditComponent } from './dam-safety-inspection-add-edit.component'; @@ -10,8 +10,9 @@ import { NgxPaginationModule } from 'ngx-pagination'; import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core'; import { Utils } from 'nrpti-angular-components'; import { RecordUtils } from '../../utils/record-utils'; -import { LoadingScreenService } from 'nrpti-angular-components'; +import { LoadingScreenService, StoreService } from 'nrpti-angular-components'; import { FactoryService } from '../../../services/factory.service'; +import { EventEmitter } from '@angular/core'; describe('DamSafetyInspectionAddEditComponent', () => { const testBedHelper = new TestBedHelper(DamSafetyInspectionAddEditComponent); @@ -20,10 +21,16 @@ describe('DamSafetyInspectionAddEditComponent', () => { const mockLocation = jasmine.createSpyObj('Location', ['go']); const mockRouter = jasmine.createSpyObj('Router', ['navigate']); const mockActivatedRoute = new ActivatedRouteStub(); - const mockFactoryService = jasmine.createSpyObj('FactoryService', ['userInBcmiRole', 'userInNrcedRole']); + const mockFactoryService = jasmine.createSpyObj('FactoryService', ['userInLngRole', 'userInBcmiRole', 'userInNrcedRole']); + mockFactoryService.userInLngRole.and.returnValue(true); mockFactoryService.userInBcmiRole.and.returnValue(true); mockFactoryService.userInNrcedRole.and.returnValue(true); + const mockStoreService = { + getItem: () => { }, + stateChange: new EventEmitter() + }; + const mockLoadingScreenService = { isLoading: false, setLoadingState: () => { @@ -31,7 +38,7 @@ describe('DamSafetyInspectionAddEditComponent', () => { } }; - beforeEach(async(() => { + beforeEach((() => { TestBed.configureTestingModule({ imports: [ RouterTestingModule, @@ -46,6 +53,7 @@ describe('DamSafetyInspectionAddEditComponent', () => { Utils, RecordUtils, { provide: LoadingScreenService, useValue: mockLoadingScreenService }, + { provide: StoreService, useValue: mockStoreService }, { provide: Location, useValue: mockLocation }, { provide: Router, useValue: mockRouter }, { provide: ActivatedRoute, useValue: mockActivatedRoute }, diff --git a/angular/projects/admin-nrpti/src/app/records/dam-safety-inspections/dam-safety-inspection-add-edit/dam-safety-inspection-add-edit.component.ts b/angular/projects/admin-nrpti/src/app/records/dam-safety-inspections/dam-safety-inspection-add-edit/dam-safety-inspection-add-edit.component.ts index f36ac8061..c9dc0dd76 100644 --- a/angular/projects/admin-nrpti/src/app/records/dam-safety-inspections/dam-safety-inspection-add-edit/dam-safety-inspection-add-edit.component.ts +++ b/angular/projects/admin-nrpti/src/app/records/dam-safety-inspections/dam-safety-inspection-add-edit/dam-safety-inspection-add-edit.component.ts @@ -9,7 +9,7 @@ import { FactoryService } from '../../../services/factory.service'; import { Utils } from 'nrpti-angular-components'; import { Utils as CommonUtils } from '../../../../../../common/src/app/utils/utils'; import { RecordUtils } from '../../utils/record-utils'; -import { LoadingScreenService } from 'nrpti-angular-components'; +import { LoadingScreenService, StoreService } from 'nrpti-angular-components'; @Component({ selector: 'app-dam-safety-inspection-add-edit', @@ -42,6 +42,7 @@ export class DamSafetyInspectionAddEditComponent implements OnInit, OnDestroy { public route: ActivatedRoute, public router: Router, private recordUtils: RecordUtils, + private storeService: StoreService, private factoryService: FactoryService, private loadingScreenService: LoadingScreenService, private utils: Utils, @@ -254,6 +255,17 @@ export class DamSafetyInspectionAddEditComponent implements OnInit, OnDestroy { publishBcmi: new FormControl({ value: (this.currentRecord && this.bcmiFlavour && this.bcmiFlavour.read.includes('public')) || false, disabled: !this.factoryService.userInBcmiRole() + }), + + association: new FormGroup({ + _epicProjectId: new FormControl({ + value: this.currentRecord && this.currentRecord._epicProjectId || null, + disabled: this.currentRecord && this.currentRecord.sourceSystemRef !== 'nrpti' + }), + mineGuid: new FormControl({ + value: this.currentRecord && this.currentRecord.mineGuid || null, + disabled: this.currentRecord && this.currentRecord.sourceSystemRef !== 'nrpti' + }) }) }); } @@ -373,6 +385,23 @@ export class DamSafetyInspectionAddEditComponent implements OnInit, OnDestroy { damSafetyInspection['DamSafetyInspectionBCMI']['removeRole'] = 'public'; } + if (this.myForm.get('association._epicProjectId').dirty) { + damSafetyInspection['_epicProjectId'] = this.myForm.get('association._epicProjectId').value; + } + + if (this.myForm.get('association.mineGuid').dirty) { + damSafetyInspection['mineGuid'] = this.myForm.get('association.mineGuid').value; + } + + // Set the friendly name of projectName + const epicProjectList = this.storeService.getItem('epicProjects'); + const filterResult = epicProjectList.filter(item => { + return item._id === damSafetyInspection['_epicProjectId']; + }); + if (filterResult && filterResult[0] && filterResult[0].name) { + damSafetyInspection['projectName'] = filterResult[0].name; + } + if (!this.isEditing) { this.factoryService.writeRecord(damSafetyInspection, 'damSafetyInspections', true).subscribe(async res => { this.recordUtils.parseResForErrors(res); diff --git a/angular/projects/admin-nrpti/src/app/records/dam-safety-inspections/dam-safety-inspection-bcmi-detail/dam-safety-inspection-bcmi-detail.component.spec.ts b/angular/projects/admin-nrpti/src/app/records/dam-safety-inspections/dam-safety-inspection-bcmi-detail/dam-safety-inspection-bcmi-detail.component.spec.ts index 87e6fdba2..9b8255231 100644 --- a/angular/projects/admin-nrpti/src/app/records/dam-safety-inspections/dam-safety-inspection-bcmi-detail/dam-safety-inspection-bcmi-detail.component.spec.ts +++ b/angular/projects/admin-nrpti/src/app/records/dam-safety-inspections/dam-safety-inspection-bcmi-detail/dam-safety-inspection-bcmi-detail.component.spec.ts @@ -1,11 +1,12 @@ -import { async, TestBed } from '@angular/core/testing'; +import { TestBed } from '@angular/core/testing'; import { DamSafetyInspectionBCMIDetailComponent } from './dam-safety-inspection-bcmi-detail.component'; import { TestBedHelper, ActivatedRouteStub } from '../../../../../../common/src/app/spec/spec-utils'; import { RouterTestingModule } from '@angular/router/testing'; import { Router, ActivatedRoute } from '@angular/router'; -import { GlobalModule } from 'nrpti-angular-components'; +import { GlobalModule, StoreService } from 'nrpti-angular-components'; import { DatePipe } from '@angular/common'; import { FactoryService } from '../../../services/factory.service'; +import { EventEmitter } from '@angular/core'; describe('CorrespondenceBCMIDetailComponent', () => { const testBedHelper = new TestBedHelper @@ -17,13 +18,19 @@ describe('CorrespondenceBCMIDetailComponent', () => { const mockFactoryService = jasmine.createSpyObj('FactoryService', ['userInBcmiRole']); mockFactoryService.userInBcmiRole.and.returnValue(true); - beforeEach(async(() => { + const mockStoreService = { + getItem: () => { }, + stateChange: new EventEmitter() + }; + + beforeEach((() => { TestBed.configureTestingModule({ imports: [RouterTestingModule, GlobalModule], declarations: [DamSafetyInspectionBCMIDetailComponent], providers: [ DatePipe, { provide: Router, useValue: mockRouter }, + { provide: StoreService, useValue: mockStoreService }, { provide: ActivatedRoute, useValue: mockActivatedRoute }, { provide: FactoryService, useValue: mockFactoryService } ] diff --git a/angular/projects/admin-nrpti/src/app/records/dam-safety-inspections/dam-safety-inspection-detail/dam-safety-inspection-detail.component.html b/angular/projects/admin-nrpti/src/app/records/dam-safety-inspections/dam-safety-inspection-detail/dam-safety-inspection-detail.component.html index 77eef6f78..f0cca4476 100644 --- a/angular/projects/admin-nrpti/src/app/records/dam-safety-inspections/dam-safety-inspection-detail/dam-safety-inspection-detail.component.html +++ b/angular/projects/admin-nrpti/src/app/records/dam-safety-inspections/dam-safety-inspection-detail/dam-safety-inspection-detail.component.html @@ -48,7 +48,7 @@

Shared Data [Master]

- {{ (data && data._master.sourceSystemRef) || '-' }} + {{ (data && data._master && data._master.sourceSystemRef) || '-' }}
diff --git a/angular/projects/admin-nrpti/src/app/records/dam-safety-inspections/dam-safety-inspection-detail/dam-safety-inspection-detail.component.spec.ts b/angular/projects/admin-nrpti/src/app/records/dam-safety-inspections/dam-safety-inspection-detail/dam-safety-inspection-detail.component.spec.ts index a45b0be22..00aa0f409 100644 --- a/angular/projects/admin-nrpti/src/app/records/dam-safety-inspections/dam-safety-inspection-detail/dam-safety-inspection-detail.component.spec.ts +++ b/angular/projects/admin-nrpti/src/app/records/dam-safety-inspections/dam-safety-inspection-detail/dam-safety-inspection-detail.component.spec.ts @@ -1,13 +1,14 @@ -import { async, TestBed } from '@angular/core/testing'; +import { TestBed } from '@angular/core/testing'; import { DamSafetyInspectionDetailComponent } from './dam-safety-inspection-detail.component'; import { TestBedHelper, ActivatedRouteStub } from '../../../../../../common/src/app/spec/spec-utils'; import { RouterTestingModule } from '@angular/router/testing'; import { Router, ActivatedRoute } from '@angular/router'; -import { GlobalModule } from 'nrpti-angular-components'; +import { GlobalModule, StoreService } from 'nrpti-angular-components'; import { RecordDetailDirective } from '../../utils/record-detail.directive'; import { DatePipe } from '@angular/common'; import { CommonModule } from '../../../../../../common/src/app/common.module'; import { FactoryService } from '../../../services/factory.service'; +import { EventEmitter } from '@angular/core'; describe('DamSafetyInspectionDetailComponent', () => { const testBedHelper = new TestBedHelper(DamSafetyInspectionDetailComponent); @@ -15,17 +16,24 @@ describe('DamSafetyInspectionDetailComponent', () => { // component constructor mocks const mockRouter = jasmine.createSpyObj('Router', ['navigate']); const mockActivatedRoute = new ActivatedRouteStub(); - const mockFactoryService = jasmine.createSpyObj('FactoryService', ['userInBcmiRole', 'userInNrcedRole']); + const mockFactoryService = jasmine.createSpyObj('FactoryService', ['userInLngRole', 'userInBcmiRole', 'userInNrcedRole']); + mockFactoryService.userInLngRole.and.returnValue(true); mockFactoryService.userInBcmiRole.and.returnValue(true); mockFactoryService.userInNrcedRole.and.returnValue(true); - beforeEach(async(() => { + const mockStoreService = { + getItem: () => { }, + stateChange: new EventEmitter() + }; + + beforeEach((() => { TestBed.configureTestingModule({ imports: [RouterTestingModule, GlobalModule, CommonModule], declarations: [DamSafetyInspectionDetailComponent, RecordDetailDirective], providers: [ DatePipe, { provide: Router, useValue: mockRouter }, + { provide: StoreService, useValue: mockStoreService }, { provide: ActivatedRoute, useValue: mockActivatedRoute }, { provide: FactoryService, useValue: mockFactoryService } ] diff --git a/angular/projects/admin-nrpti/src/app/records/dam-safety-inspections/dam-safety-inspection-nrced-detail/dam-safety-inspection-nrced-detail.component.spec.ts b/angular/projects/admin-nrpti/src/app/records/dam-safety-inspections/dam-safety-inspection-nrced-detail/dam-safety-inspection-nrced-detail.component.spec.ts index 375fc26d3..aac99aea0 100644 --- a/angular/projects/admin-nrpti/src/app/records/dam-safety-inspections/dam-safety-inspection-nrced-detail/dam-safety-inspection-nrced-detail.component.spec.ts +++ b/angular/projects/admin-nrpti/src/app/records/dam-safety-inspections/dam-safety-inspection-nrced-detail/dam-safety-inspection-nrced-detail.component.spec.ts @@ -1,4 +1,4 @@ -import { async, TestBed } from '@angular/core/testing'; +import { TestBed } from '@angular/core/testing'; import { DamSafetyInspectionNRCEDDetailComponent } from './dam-safety-inspection-nrced-detail.component'; import { TestBedHelper, ActivatedRouteStub } from '../../../../../../common/src/app/spec/spec-utils'; import { RouterTestingModule } from '@angular/router/testing'; @@ -17,7 +17,7 @@ describe('CorrespondenceNRCEDDetailComponent', () => { const mockFactoryService = jasmine.createSpyObj('FactoryService', ['userInNrcedRole']); mockFactoryService.userInNrcedRole.and.returnValue(true); - beforeEach(async(() => { + beforeEach((() => { TestBed.configureTestingModule({ imports: [RouterTestingModule, GlobalModule], declarations: [DamSafetyInspectionNRCEDDetailComponent], diff --git a/angular/projects/admin-nrpti/src/app/records/inspections/inspection-add-edit/inspection-add-edit.component.html b/angular/projects/admin-nrpti/src/app/records/inspections/inspection-add-edit/inspection-add-edit.component.html index f0716c5fc..0ae094117 100644 --- a/angular/projects/admin-nrpti/src/app/records/inspections/inspection-add-edit/inspection-add-edit.component.html +++ b/angular/projects/admin-nrpti/src/app/records/inspections/inspection-add-edit/inspection-add-edit.component.html @@ -100,32 +100,14 @@

Legislation

Issued To

-
-
- - (If Applicable) -
-
- - -
-
- - -
-
- - -
-
-
-
+ + +
diff --git a/angular/projects/admin-nrpti/src/app/records/inspections/inspection-add-edit/inspection-add-edit.component.spec.ts b/angular/projects/admin-nrpti/src/app/records/inspections/inspection-add-edit/inspection-add-edit.component.spec.ts index 72f58ec22..2dac59eb0 100644 --- a/angular/projects/admin-nrpti/src/app/records/inspections/inspection-add-edit/inspection-add-edit.component.spec.ts +++ b/angular/projects/admin-nrpti/src/app/records/inspections/inspection-add-edit/inspection-add-edit.component.spec.ts @@ -1,4 +1,4 @@ -import { async, TestBed } from '@angular/core/testing'; +import { TestBed } from '@angular/core/testing'; import { NgbModule } from '@ng-bootstrap/ng-bootstrap'; import { FormsModule, ReactiveFormsModule } from '@angular/forms'; import { InspectionAddEditComponent } from './inspection-add-edit.component'; @@ -12,8 +12,9 @@ import { Utils } from 'nrpti-angular-components'; import { RecordUtils } from '../../utils/record-utils'; import { CommonModule } from '../../../../../../common/src/app/common.module'; import { MatSlideToggleModule } from '@angular/material'; -import { LoadingScreenService } from 'nrpti-angular-components'; +import { LoadingScreenService, StoreService } from 'nrpti-angular-components'; import { FactoryService } from '../../../services/factory.service'; +import { EventEmitter } from '@angular/core'; describe('InspectionAddEditComponent', () => { const testBedHelper = new TestBedHelper(InspectionAddEditComponent); @@ -22,10 +23,16 @@ describe('InspectionAddEditComponent', () => { const mockLocation = jasmine.createSpyObj('Location', ['go']); const mockRouter = jasmine.createSpyObj('Router', ['navigate']); const mockActivatedRoute = new ActivatedRouteStub(); - const mockFactoryService = jasmine.createSpyObj('FactoryService', ['userInLngRole', 'userInNrcedRole']); + const mockFactoryService = jasmine.createSpyObj('FactoryService', ['userInLngRole', 'userInBcmiRole', 'userInNrcedRole']); mockFactoryService.userInLngRole.and.returnValue(true); + mockFactoryService.userInBcmiRole.and.returnValue(true); mockFactoryService.userInNrcedRole.and.returnValue(true); + const mockStoreService = { + getItem: () => { }, + stateChange: new EventEmitter() + }; + const mockLoadingScreenService = { isLoading: false, setLoadingState: () => { @@ -33,7 +40,7 @@ describe('InspectionAddEditComponent', () => { } }; - beforeEach(async(() => { + beforeEach((() => { TestBed.configureTestingModule({ imports: [ RouterTestingModule, @@ -50,6 +57,7 @@ describe('InspectionAddEditComponent', () => { Utils, RecordUtils, { provide: LoadingScreenService, useValue: mockLoadingScreenService }, + { provide: StoreService, useValue: mockStoreService }, { provide: Location, useValue: mockLocation }, { provide: Router, useValue: mockRouter }, { provide: ActivatedRoute, useValue: mockActivatedRoute }, diff --git a/angular/projects/admin-nrpti/src/app/records/inspections/inspection-add-edit/inspection-add-edit.component.ts b/angular/projects/admin-nrpti/src/app/records/inspections/inspection-add-edit/inspection-add-edit.component.ts index f9a130e90..15576dab5 100644 --- a/angular/projects/admin-nrpti/src/app/records/inspections/inspection-add-edit/inspection-add-edit.component.ts +++ b/angular/projects/admin-nrpti/src/app/records/inspections/inspection-add-edit/inspection-add-edit.component.ts @@ -9,7 +9,7 @@ import { FactoryService } from '../../../services/factory.service'; import { Utils } from 'nrpti-angular-components'; import { Utils as CommonUtils } from '../../../../../../common/src/app/utils/utils'; import { RecordUtils } from '../../utils/record-utils'; -import { LoadingScreenService } from 'nrpti-angular-components'; +import { LoadingScreenService, StoreService } from 'nrpti-angular-components'; @Component({ selector: 'app-inspection-add-edit', @@ -45,6 +45,7 @@ export class InspectionAddEditComponent implements OnInit, OnDestroy { public route: ActivatedRoute, public router: Router, private recordUtils: RecordUtils, + private storeService: StoreService, private factoryService: FactoryService, private loadingScreenService: LoadingScreenService, private utils: Utils, @@ -268,6 +269,17 @@ export class InspectionAddEditComponent implements OnInit, OnDestroy { publishLng: new FormControl({ value: (this.currentRecord && this.lngFlavour && this.lngFlavour.read.includes('public')) || false, disabled: !this.factoryService.userInLngRole() + }), + + association: new FormGroup({ + _epicProjectId: new FormControl({ + value: this.currentRecord && this.currentRecord._epicProjectId || null, + disabled: this.currentRecord && this.currentRecord.sourceSystemRef !== 'nrpti' + }), + mineGuid: new FormControl({ + value: this.currentRecord && this.currentRecord.mineGuid || null, + disabled: this.currentRecord && this.currentRecord.sourceSystemRef !== 'nrpti' + }) }) }); } @@ -390,6 +402,23 @@ export class InspectionAddEditComponent implements OnInit, OnDestroy { inspection['InspectionLNG']['removeRole'] = 'public'; } + if (this.myForm.get('association._epicProjectId').dirty) { + inspection['_epicProjectId'] = this.myForm.get('association._epicProjectId').value; + } + + if (this.myForm.get('association.mineGuid').dirty) { + inspection['mineGuid'] = this.myForm.get('association.mineGuid').value; + } + + // Set the friendly name of projectName + const epicProjectList = this.storeService.getItem('epicProjects'); + const filterResult = epicProjectList.filter(item => { + return item._id === inspection['_epicProjectId']; + }); + if (filterResult && filterResult[0] && filterResult[0].name) { + inspection['projectName'] = filterResult[0].name; + } + if (!this.isEditing) { this.factoryService.writeRecord(inspection, 'inspections', true).subscribe(async res => { this.recordUtils.parseResForErrors(res); diff --git a/angular/projects/admin-nrpti/src/app/records/inspections/inspection-detail/inspection-detail.component.html b/angular/projects/admin-nrpti/src/app/records/inspections/inspection-detail/inspection-detail.component.html index 55a2af988..928c88e0d 100644 --- a/angular/projects/admin-nrpti/src/app/records/inspections/inspection-detail/inspection-detail.component.html +++ b/angular/projects/admin-nrpti/src/app/records/inspections/inspection-detail/inspection-detail.component.html @@ -52,7 +52,7 @@

Shared Data [Master]

- {{ (data && data._master.sourceSystemRef) || '-' }} + {{ (data && data._master && data._master.sourceSystemRef) || '-' }}
diff --git a/angular/projects/admin-nrpti/src/app/records/inspections/inspection-detail/inspection-detail.component.spec.ts b/angular/projects/admin-nrpti/src/app/records/inspections/inspection-detail/inspection-detail.component.spec.ts index ff1263a60..5398a2bf7 100644 --- a/angular/projects/admin-nrpti/src/app/records/inspections/inspection-detail/inspection-detail.component.spec.ts +++ b/angular/projects/admin-nrpti/src/app/records/inspections/inspection-detail/inspection-detail.component.spec.ts @@ -1,15 +1,16 @@ -import { async, TestBed } from '@angular/core/testing'; +import { TestBed } from '@angular/core/testing'; import { InspectionDetailComponent } from './inspection-detail.component'; import { TestBedHelper, ActivatedRouteStub } from '../../../../../../common/src/app/spec/spec-utils'; import { RouterTestingModule } from '@angular/router/testing'; import { Router, ActivatedRoute } from '@angular/router'; -import { GlobalModule } from 'nrpti-angular-components'; +import { GlobalModule, StoreService } from 'nrpti-angular-components'; import { RecordDetailDirective } from '../../utils/record-detail.directive'; import { DatePipe } from '@angular/common'; import { CommonModule } from '../../../../../../common/src/app/common.module'; import { DocumentAuthenticatedReadOnlyComponent } from '../../../documents/document-authenticated-read-only/document-authenticated-read-only.component'; import { S3SignedUrlAnchorComponent } from '../../../documents/s3-signed-url-anchor/s3-signed-url-anchor.component'; import { FactoryService } from '../../../services/factory.service'; +import { EventEmitter } from '@angular/core'; describe('InspectionDetailComponent', () => { const testBedHelper = new TestBedHelper(InspectionDetailComponent); @@ -21,7 +22,12 @@ describe('InspectionDetailComponent', () => { mockFactoryService.userInLngRole.and.returnValue(true); mockFactoryService.userInNrcedRole.and.returnValue(true); - beforeEach(async(() => { + const mockStoreService = { + getItem: () => { }, + stateChange: new EventEmitter() + }; + + beforeEach((() => { TestBed.configureTestingModule({ imports: [RouterTestingModule, GlobalModule, CommonModule], declarations: [ @@ -33,6 +39,7 @@ describe('InspectionDetailComponent', () => { providers: [ DatePipe, { provide: Router, useValue: mockRouter }, + { provide: StoreService, useValue: mockStoreService }, { provide: ActivatedRoute, useValue: mockActivatedRoute }, { provide: FactoryService, useValue: mockFactoryService } ] diff --git a/angular/projects/admin-nrpti/src/app/records/inspections/inspection-lng-detail/inspection-lng-detail.component.spec.ts b/angular/projects/admin-nrpti/src/app/records/inspections/inspection-lng-detail/inspection-lng-detail.component.spec.ts index 3acf24012..8bbc949dd 100644 --- a/angular/projects/admin-nrpti/src/app/records/inspections/inspection-lng-detail/inspection-lng-detail.component.spec.ts +++ b/angular/projects/admin-nrpti/src/app/records/inspections/inspection-lng-detail/inspection-lng-detail.component.spec.ts @@ -1,4 +1,4 @@ -import { async, TestBed } from '@angular/core/testing'; +import { TestBed } from '@angular/core/testing'; import { InspectionLNGDetailComponent } from './inspection-lng-detail.component'; import { TestBedHelper, ActivatedRouteStub } from '../../../../../../common/src/app/spec/spec-utils'; import { RouterTestingModule } from '@angular/router/testing'; @@ -16,7 +16,7 @@ describe('InspectionLNGDetailComponent', () => { const mockFactoryService = jasmine.createSpyObj('FactoryService', ['userInLngRole']); mockFactoryService.userInLngRole.and.returnValue(true); - beforeEach(async(() => { + beforeEach((() => { TestBed.configureTestingModule({ imports: [RouterTestingModule, GlobalModule], declarations: [InspectionLNGDetailComponent], diff --git a/angular/projects/admin-nrpti/src/app/records/inspections/inspection-nrced-detail/inspection-nrced-detail.component.spec.ts b/angular/projects/admin-nrpti/src/app/records/inspections/inspection-nrced-detail/inspection-nrced-detail.component.spec.ts index 1dff278a2..fb6a34deb 100644 --- a/angular/projects/admin-nrpti/src/app/records/inspections/inspection-nrced-detail/inspection-nrced-detail.component.spec.ts +++ b/angular/projects/admin-nrpti/src/app/records/inspections/inspection-nrced-detail/inspection-nrced-detail.component.spec.ts @@ -1,4 +1,4 @@ -import { async, TestBed } from '@angular/core/testing'; +import { TestBed } from '@angular/core/testing'; import { InspectionNRCEDDetailComponent } from './inspection-nrced-detail.component'; import { TestBedHelper, ActivatedRouteStub } from '../../../../../../common/src/app/spec/spec-utils'; import { RouterTestingModule } from '@angular/router/testing'; @@ -16,7 +16,7 @@ describe('InspectionNRCEDDetailComponent', () => { const mockFactoryService = jasmine.createSpyObj('FactoryService', ['userInNrcedRole']); mockFactoryService.userInNrcedRole.and.returnValue(true); - beforeEach(async(() => { + beforeEach((() => { TestBed.configureTestingModule({ imports: [RouterTestingModule, GlobalModule], declarations: [InspectionNRCEDDetailComponent], diff --git a/angular/projects/admin-nrpti/src/app/records/management-plans/management-plan-add-edit/management-plan-add-edit.component.html b/angular/projects/admin-nrpti/src/app/records/management-plans/management-plan-add-edit/management-plan-add-edit.component.html index 32ce08620..555829ea4 100644 --- a/angular/projects/admin-nrpti/src/app/records/management-plans/management-plan-add-edit/management-plan-add-edit.component.html +++ b/angular/projects/admin-nrpti/src/app/records/management-plans/management-plan-add-edit/management-plan-add-edit.component.html @@ -70,32 +70,20 @@

Basic Information

+
+

Issued To

+ + + +
+

Location Details

-
- - (If Applicable) -
-
- - -
-
- - -
-
- - -
-
-
diff --git a/angular/projects/admin-nrpti/src/app/records/management-plans/management-plan-add-edit/management-plan-add-edit.component.spec.ts b/angular/projects/admin-nrpti/src/app/records/management-plans/management-plan-add-edit/management-plan-add-edit.component.spec.ts index 8b9861df8..a35f8ff55 100644 --- a/angular/projects/admin-nrpti/src/app/records/management-plans/management-plan-add-edit/management-plan-add-edit.component.spec.ts +++ b/angular/projects/admin-nrpti/src/app/records/management-plans/management-plan-add-edit/management-plan-add-edit.component.spec.ts @@ -1,4 +1,4 @@ -import { async, TestBed } from '@angular/core/testing'; +import { TestBed } from '@angular/core/testing'; import { NgbModule } from '@ng-bootstrap/ng-bootstrap'; import { FormsModule, ReactiveFormsModule } from '@angular/forms'; import { ManagementPlanAddEditComponent } from './management-plan-add-edit.component'; @@ -10,8 +10,9 @@ import { NgxPaginationModule } from 'ngx-pagination'; import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core'; import { Utils } from 'nrpti-angular-components'; import { RecordUtils } from '../../utils/record-utils'; -import { LoadingScreenService } from 'nrpti-angular-components'; +import { LoadingScreenService, StoreService } from 'nrpti-angular-components'; import { FactoryService } from '../../../services/factory.service'; +import { EventEmitter } from '@angular/core'; describe('ManagementPlanAddEditComponent', () => { const testBedHelper = new TestBedHelper(ManagementPlanAddEditComponent); @@ -20,10 +21,16 @@ describe('ManagementPlanAddEditComponent', () => { const mockLocation = jasmine.createSpyObj('Location', ['go']); const mockRouter = jasmine.createSpyObj('Router', ['navigate']); const mockActivatedRoute = new ActivatedRouteStub(); - const mockFactoryService = jasmine.createSpyObj('FactoryService', ['userInLngRole', 'userInNrcedRole']); + const mockFactoryService = jasmine.createSpyObj('FactoryService', ['userInLngRole', 'userInBcmiRole', 'userInNrcedRole']); mockFactoryService.userInLngRole.and.returnValue(true); + mockFactoryService.userInBcmiRole.and.returnValue(true); mockFactoryService.userInNrcedRole.and.returnValue(true); + const mockStoreService = { + getItem: () => { }, + stateChange: new EventEmitter() + }; + const mockLoadingScreenService = { isLoading: false, setLoadingState: () => { @@ -31,7 +38,7 @@ describe('ManagementPlanAddEditComponent', () => { } }; - beforeEach(async(() => { + beforeEach((() => { TestBed.configureTestingModule({ imports: [ RouterTestingModule, @@ -46,6 +53,7 @@ describe('ManagementPlanAddEditComponent', () => { Utils, RecordUtils, { provide: LoadingScreenService, useValue: mockLoadingScreenService }, + { provide: StoreService, useValue: mockStoreService }, { provide: Location, useValue: mockLocation }, { provide: Router, useValue: mockRouter }, { provide: ActivatedRoute, useValue: mockActivatedRoute }, diff --git a/angular/projects/admin-nrpti/src/app/records/management-plans/management-plan-add-edit/management-plan-add-edit.component.ts b/angular/projects/admin-nrpti/src/app/records/management-plans/management-plan-add-edit/management-plan-add-edit.component.ts index 6b147789b..1144f4917 100644 --- a/angular/projects/admin-nrpti/src/app/records/management-plans/management-plan-add-edit/management-plan-add-edit.component.ts +++ b/angular/projects/admin-nrpti/src/app/records/management-plans/management-plan-add-edit/management-plan-add-edit.component.ts @@ -8,7 +8,7 @@ import { FactoryService } from '../../../services/factory.service'; import { Utils } from 'nrpti-angular-components'; import { Utils as CommonUtils } from '../../../../../../common/src/app/utils/utils'; import { RecordUtils } from '../../utils/record-utils'; -import { LoadingScreenService } from 'nrpti-angular-components'; +import { LoadingScreenService, StoreService } from 'nrpti-angular-components'; @Component({ selector: 'app-management-plan-add-edit', @@ -40,6 +40,7 @@ export class ManagementPlanAddEditComponent implements OnInit, OnDestroy { public route: ActivatedRoute, public router: Router, private recordUtils: RecordUtils, + private storeService: StoreService, private factoryService: FactoryService, private loadingScreenService: LoadingScreenService, private utils: Utils, @@ -144,6 +145,17 @@ export class ManagementPlanAddEditComponent implements OnInit, OnDestroy { publishLng: new FormControl({ value: (this.currentRecord && this.lngFlavour && this.lngFlavour.read.includes('public')) || false, disabled: !this.factoryService.userInLngRole() + }), + + association: new FormGroup({ + _epicProjectId: new FormControl({ + value: this.currentRecord && this.currentRecord._epicProjectId || null, + disabled: this.currentRecord && this.currentRecord.sourceSystemRef !== 'nrpti' + }), + mineGuid: new FormControl({ + value: this.currentRecord && this.currentRecord.mineGuid || null, + disabled: this.currentRecord && this.currentRecord.sourceSystemRef !== 'nrpti' + }) }) }); } @@ -214,6 +226,23 @@ export class ManagementPlanAddEditComponent implements OnInit, OnDestroy { managementPlan['ManagementPlanLNG']['removeRole'] = 'public'; } + if (this.myForm.get('association._epicProjectId').dirty) { + managementPlan['_epicProjectId'] = this.myForm.get('association._epicProjectId').value; + } + + if (this.myForm.get('association.mineGuid').dirty) { + managementPlan['mineGuid'] = this.myForm.get('association.mineGuid').value; + } + + // Set the friendly name of projectName + const epicProjectList = this.storeService.getItem('epicProjects'); + const filterResult = epicProjectList.filter(item => { + return item._id === managementPlan['_epicProjectId']; + }); + if (filterResult && filterResult[0] && filterResult[0].name) { + managementPlan['projectName'] = filterResult[0].name; + } + if (!this.isEditing) { this.factoryService.writeRecord(managementPlan, 'managementPlans', true).subscribe(async res => { this.recordUtils.parseResForErrors(res); diff --git a/angular/projects/admin-nrpti/src/app/records/management-plans/management-plan-detail/management-plan-detail.component.html b/angular/projects/admin-nrpti/src/app/records/management-plans/management-plan-detail/management-plan-detail.component.html index 2e8be3eee..c8bcc3318 100644 --- a/angular/projects/admin-nrpti/src/app/records/management-plans/management-plan-detail/management-plan-detail.component.html +++ b/angular/projects/admin-nrpti/src/app/records/management-plans/management-plan-detail/management-plan-detail.component.html @@ -44,7 +44,7 @@

Shared Data [Master]

- {{ (data && data._master.sourceSystemRef) || '-' }} + {{ (data && data._master && data._master.sourceSystemRef) || '-' }}
diff --git a/angular/projects/admin-nrpti/src/app/records/management-plans/management-plan-detail/management-plan-detail.component.spec.ts b/angular/projects/admin-nrpti/src/app/records/management-plans/management-plan-detail/management-plan-detail.component.spec.ts index 523422628..6060905ca 100644 --- a/angular/projects/admin-nrpti/src/app/records/management-plans/management-plan-detail/management-plan-detail.component.spec.ts +++ b/angular/projects/admin-nrpti/src/app/records/management-plans/management-plan-detail/management-plan-detail.component.spec.ts @@ -1,13 +1,14 @@ -import { async, TestBed } from '@angular/core/testing'; +import { TestBed } from '@angular/core/testing'; import { ManagementPlanDetailComponent } from './management-plan-detail.component'; import { TestBedHelper, ActivatedRouteStub } from '../../../../../../common/src/app/spec/spec-utils'; import { RouterTestingModule } from '@angular/router/testing'; import { Router, ActivatedRoute } from '@angular/router'; -import { GlobalModule } from 'nrpti-angular-components'; +import { GlobalModule, StoreService } from 'nrpti-angular-components'; import { RecordDetailDirective } from '../../utils/record-detail.directive'; import { DatePipe } from '@angular/common'; import { CommonModule } from '../../../../../../common/src/app/common.module'; import { FactoryService } from '../../../services/factory.service'; +import { EventEmitter } from '@angular/core'; describe('ManagementPlanDetailComponent', () => { const testBedHelper = new TestBedHelper(ManagementPlanDetailComponent); @@ -15,17 +16,24 @@ describe('ManagementPlanDetailComponent', () => { // component constructor mocks const mockRouter = jasmine.createSpyObj('Router', ['navigate']); const mockActivatedRoute = new ActivatedRouteStub(); - const mockFactoryService = jasmine.createSpyObj('FactoryService', ['userInLngRole', 'userInNrcedRole']); + const mockFactoryService = jasmine.createSpyObj('FactoryService', ['userInLngRole', 'userInBcmiRole', 'userInNrcedRole']); mockFactoryService.userInLngRole.and.returnValue(true); + mockFactoryService.userInBcmiRole.and.returnValue(true); mockFactoryService.userInNrcedRole.and.returnValue(true); - beforeEach(async(() => { + const mockStoreService = { + getItem: () => { }, + stateChange: new EventEmitter() + }; + + beforeEach((() => { TestBed.configureTestingModule({ imports: [RouterTestingModule, GlobalModule, CommonModule], declarations: [ManagementPlanDetailComponent, RecordDetailDirective], providers: [ DatePipe, { provide: Router, useValue: mockRouter }, + { provide: StoreService, useValue: mockStoreService }, { provide: ActivatedRoute, useValue: mockActivatedRoute }, { provide: FactoryService, useValue: mockFactoryService } ] diff --git a/angular/projects/admin-nrpti/src/app/records/management-plans/management-plan-lng-detail/management-plan-lng-detail.component.spec.ts b/angular/projects/admin-nrpti/src/app/records/management-plans/management-plan-lng-detail/management-plan-lng-detail.component.spec.ts index e50de67fb..cc75129be 100644 --- a/angular/projects/admin-nrpti/src/app/records/management-plans/management-plan-lng-detail/management-plan-lng-detail.component.spec.ts +++ b/angular/projects/admin-nrpti/src/app/records/management-plans/management-plan-lng-detail/management-plan-lng-detail.component.spec.ts @@ -1,11 +1,12 @@ -import { async, TestBed } from '@angular/core/testing'; +import { TestBed } from '@angular/core/testing'; import { ManagementPlanLNGDetailComponent } from './management-plan-lng-detail.component'; import { TestBedHelper, ActivatedRouteStub } from '../../../../../../common/src/app/spec/spec-utils'; import { RouterTestingModule } from '@angular/router/testing'; import { Router, ActivatedRoute } from '@angular/router'; -import { GlobalModule } from 'nrpti-angular-components'; +import { GlobalModule, StoreService } from 'nrpti-angular-components'; import { DatePipe } from '@angular/common'; import { FactoryService } from '../../../services/factory.service'; +import { EventEmitter } from '@angular/core'; describe('ManagementPlanLNGDetailComponent', () => { const testBedHelper = new TestBedHelper(ManagementPlanLNGDetailComponent); @@ -13,16 +14,24 @@ describe('ManagementPlanLNGDetailComponent', () => { // component constructor mocks const mockRouter = jasmine.createSpyObj('Router', ['navigate']); const mockActivatedRoute = new ActivatedRouteStub(); - const mockFactoryService = jasmine.createSpyObj('FactoryService', ['userInLngRole']); + const mockFactoryService = jasmine.createSpyObj('FactoryService', ['userInLngRole', 'userInBcmiRole', 'userInNrcedRole']); mockFactoryService.userInLngRole.and.returnValue(true); + mockFactoryService.userInBcmiRole.and.returnValue(true); + mockFactoryService.userInNrcedRole.and.returnValue(true); - beforeEach(async(() => { + const mockStoreService = { + getItem: () => { }, + stateChange: new EventEmitter() + }; + + beforeEach((() => { TestBed.configureTestingModule({ imports: [RouterTestingModule, GlobalModule], declarations: [ManagementPlanLNGDetailComponent], providers: [ DatePipe, { provide: Router, useValue: mockRouter }, + { provide: StoreService, useValue: mockStoreService }, { provide: ActivatedRoute, useValue: mockActivatedRoute }, { provide: FactoryService, useValue: mockFactoryService } ] diff --git a/angular/projects/admin-nrpti/src/app/records/orders/order-add-edit/order-add-edit.component.html b/angular/projects/admin-nrpti/src/app/records/orders/order-add-edit/order-add-edit.component.html index b26469674..83b6b8983 100644 --- a/angular/projects/admin-nrpti/src/app/records/orders/order-add-edit/order-add-edit.component.html +++ b/angular/projects/admin-nrpti/src/app/records/orders/order-add-edit/order-add-edit.component.html @@ -106,32 +106,14 @@

Legislation

Issued To

-
-
- - (If Applicable) -
-
- - -
-
- - -
-
- - -
-
-
-
+ + +
diff --git a/angular/projects/admin-nrpti/src/app/records/orders/order-add-edit/order-add-edit.component.spec.ts b/angular/projects/admin-nrpti/src/app/records/orders/order-add-edit/order-add-edit.component.spec.ts index 9b24bee84..e1e06b2ca 100644 --- a/angular/projects/admin-nrpti/src/app/records/orders/order-add-edit/order-add-edit.component.spec.ts +++ b/angular/projects/admin-nrpti/src/app/records/orders/order-add-edit/order-add-edit.component.spec.ts @@ -1,4 +1,4 @@ -import { async, TestBed } from '@angular/core/testing'; +import { TestBed } from '@angular/core/testing'; import { NgbModule } from '@ng-bootstrap/ng-bootstrap'; import { FormsModule, ReactiveFormsModule } from '@angular/forms'; import { OrderAddEditComponent } from './order-add-edit.component'; @@ -12,8 +12,9 @@ import { Utils } from 'nrpti-angular-components'; import { RecordUtils } from '../../utils/record-utils'; import { CommonModule } from '../../../../../../common/src/app/common.module'; import { MatSlideToggleModule } from '@angular/material'; -import { LoadingScreenService } from 'nrpti-angular-components'; +import { LoadingScreenService, StoreService } from 'nrpti-angular-components'; import { FactoryService } from '../../../services/factory.service'; +import { EventEmitter } from '@angular/core'; describe('OrderAddEditComponent', () => { const testBedHelper = new TestBedHelper(OrderAddEditComponent); @@ -22,10 +23,16 @@ describe('OrderAddEditComponent', () => { const mockLocation = jasmine.createSpyObj('Location', ['go']); const mockRouter = jasmine.createSpyObj('Router', ['navigate']); const mockActivatedRoute = new ActivatedRouteStub(); - const mockFactoryService = jasmine.createSpyObj('FactoryService', ['userInLngRole', 'userInNrcedRole']); + const mockFactoryService = jasmine.createSpyObj('FactoryService', ['userInLngRole', 'userInBcmiRole', 'userInNrcedRole']); mockFactoryService.userInLngRole.and.returnValue(true); + mockFactoryService.userInBcmiRole.and.returnValue(true); mockFactoryService.userInNrcedRole.and.returnValue(true); + const mockStoreService = { + getItem: () => { }, + stateChange: new EventEmitter() + }; + const mockLoadingScreenService = { isLoading: false, setLoadingState: () => { @@ -33,7 +40,7 @@ describe('OrderAddEditComponent', () => { } }; - beforeEach(async(() => { + beforeEach((() => { TestBed.configureTestingModule({ imports: [ RouterTestingModule, @@ -50,6 +57,7 @@ describe('OrderAddEditComponent', () => { Utils, RecordUtils, { provide: LoadingScreenService, useValue: mockLoadingScreenService }, + { provide: StoreService, useValue: mockStoreService }, { provide: Location, useValue: mockLocation }, { provide: Router, useValue: mockRouter }, { provide: ActivatedRoute, useValue: mockActivatedRoute }, diff --git a/angular/projects/admin-nrpti/src/app/records/orders/order-add-edit/order-add-edit.component.ts b/angular/projects/admin-nrpti/src/app/records/orders/order-add-edit/order-add-edit.component.ts index 99f93bc62..a51af5f82 100644 --- a/angular/projects/admin-nrpti/src/app/records/orders/order-add-edit/order-add-edit.component.ts +++ b/angular/projects/admin-nrpti/src/app/records/orders/order-add-edit/order-add-edit.component.ts @@ -9,7 +9,7 @@ import { FactoryService } from '../../../services/factory.service'; import { Utils } from 'nrpti-angular-components'; import { Utils as CommonUtils } from '../../../../../../common/src/app/utils/utils'; import { RecordUtils } from '../../utils/record-utils'; -import { LoadingScreenService } from 'nrpti-angular-components'; +import { LoadingScreenService, StoreService} from 'nrpti-angular-components'; @Component({ selector: 'app-order-add-edit', @@ -47,6 +47,7 @@ export class OrderAddEditComponent implements OnInit, OnDestroy { public router: Router, private recordUtils: RecordUtils, private factoryService: FactoryService, + private storeService: StoreService, private loadingScreenService: LoadingScreenService, private utils: Utils, private _changeDetectionRef: ChangeDetectorRef @@ -273,6 +274,17 @@ export class OrderAddEditComponent implements OnInit, OnDestroy { publishLng: new FormControl({ value: (this.currentRecord && this.lngFlavour && this.lngFlavour.read.includes('public')) || false, disabled: !this.factoryService.userInLngRole() + }), + + association: new FormGroup({ + _epicProjectId: new FormControl({ + value: this.currentRecord && this.currentRecord._epicProjectId || null, + disabled: this.currentRecord && this.currentRecord.sourceSystemRef !== 'nrpti' + }), + mineGuid: new FormControl({ + value: this.currentRecord && this.currentRecord.mineGuid || null, + disabled: this.currentRecord && this.currentRecord.sourceSystemRef !== 'nrpti' + }) }) }); } @@ -395,6 +407,23 @@ export class OrderAddEditComponent implements OnInit, OnDestroy { order['OrderLNG']['removeRole'] = 'public'; } + if (this.myForm.get('association._epicProjectId').dirty) { + order['_epicProjectId'] = this.myForm.get('association._epicProjectId').value; + } + + if (this.myForm.get('association.mineGuid').dirty) { + order['mineGuid'] = this.myForm.get('association.mineGuid').value; + } + + // Set the friendly name of projectName + const epicProjectList = this.storeService.getItem('epicProjects'); + const filterResult = epicProjectList.filter(item => { + return item._id === order['_epicProjectId']; + }); + if (filterResult && filterResult[0] && filterResult[0].name) { + order['projectName'] = filterResult[0].name; + } + if (!this.isEditing) { this.factoryService.writeRecord(order, 'orders', true).subscribe(async res => { this.recordUtils.parseResForErrors(res); diff --git a/angular/projects/admin-nrpti/src/app/records/orders/order-detail/order-detail.component.html b/angular/projects/admin-nrpti/src/app/records/orders/order-detail/order-detail.component.html index 5854cd872..e5d3164c6 100644 --- a/angular/projects/admin-nrpti/src/app/records/orders/order-detail/order-detail.component.html +++ b/angular/projects/admin-nrpti/src/app/records/orders/order-detail/order-detail.component.html @@ -56,7 +56,7 @@

Shared Data [Master]

- {{ (data && data._master.sourceSystemRef) || '-' }} + {{ (data && data._master && data._master.sourceSystemRef) || '-' }}
diff --git a/angular/projects/admin-nrpti/src/app/records/orders/order-detail/order-detail.component.spec.ts b/angular/projects/admin-nrpti/src/app/records/orders/order-detail/order-detail.component.spec.ts index 9a6ef9aaf..c1e73e238 100644 --- a/angular/projects/admin-nrpti/src/app/records/orders/order-detail/order-detail.component.spec.ts +++ b/angular/projects/admin-nrpti/src/app/records/orders/order-detail/order-detail.component.spec.ts @@ -1,15 +1,16 @@ -import { async, TestBed } from '@angular/core/testing'; +import { TestBed } from '@angular/core/testing'; import { OrderDetailComponent } from './order-detail.component'; import { TestBedHelper, ActivatedRouteStub } from '../../../../../../common/src/app/spec/spec-utils'; import { RouterTestingModule } from '@angular/router/testing'; import { Router, ActivatedRoute } from '@angular/router'; -import { GlobalModule } from 'nrpti-angular-components'; +import { GlobalModule, StoreService } from 'nrpti-angular-components'; import { RecordDetailDirective } from '../../utils/record-detail.directive'; import { DatePipe } from '@angular/common'; import { CommonModule } from '../../../../../../common/src/app/common.module'; import { DocumentAuthenticatedReadOnlyComponent } from '../../../documents/document-authenticated-read-only/document-authenticated-read-only.component'; import { S3SignedUrlAnchorComponent } from '../../../documents/s3-signed-url-anchor/s3-signed-url-anchor.component'; import { FactoryService } from '../../../services/factory.service'; +import { EventEmitter } from '@angular/core'; describe('OrderDetailComponent', () => { const testBedHelper = new TestBedHelper(OrderDetailComponent); @@ -17,11 +18,17 @@ describe('OrderDetailComponent', () => { // component constructor mocks const mockRouter = jasmine.createSpyObj('Router', ['navigate']); const mockActivatedRoute = new ActivatedRouteStub(); - const mockFactoryService = jasmine.createSpyObj('FactoryService', ['userInLngRole', 'userInNrcedRole']); + const mockFactoryService = jasmine.createSpyObj('FactoryService', ['userInLngRole', 'userInBcmiRole', 'userInNrcedRole']); mockFactoryService.userInLngRole.and.returnValue(true); + mockFactoryService.userInBcmiRole.and.returnValue(true); mockFactoryService.userInNrcedRole.and.returnValue(true); - beforeEach(async(() => { + const mockStoreService = { + getItem: () => { }, + stateChange: new EventEmitter() + }; + + beforeEach((() => { TestBed.configureTestingModule({ imports: [RouterTestingModule, GlobalModule, CommonModule], declarations: [ @@ -33,6 +40,7 @@ describe('OrderDetailComponent', () => { providers: [ DatePipe, { provide: Router, useValue: mockRouter }, + { provide: StoreService, useValue: mockStoreService }, { provide: ActivatedRoute, useValue: mockActivatedRoute }, { provide: FactoryService, useValue: mockFactoryService } ] diff --git a/angular/projects/admin-nrpti/src/app/records/orders/order-lng-detail/order-lng-detail.component.spec.ts b/angular/projects/admin-nrpti/src/app/records/orders/order-lng-detail/order-lng-detail.component.spec.ts index 45413e205..b0e2a7a05 100644 --- a/angular/projects/admin-nrpti/src/app/records/orders/order-lng-detail/order-lng-detail.component.spec.ts +++ b/angular/projects/admin-nrpti/src/app/records/orders/order-lng-detail/order-lng-detail.component.spec.ts @@ -1,11 +1,12 @@ -import { async, TestBed } from '@angular/core/testing'; +import { TestBed } from '@angular/core/testing'; import { OrderLNGDetailComponent } from './order-lng-detail.component'; import { TestBedHelper, ActivatedRouteStub } from '../../../../../../common/src/app/spec/spec-utils'; import { RouterTestingModule } from '@angular/router/testing'; import { Router, ActivatedRoute } from '@angular/router'; -import { GlobalModule } from 'nrpti-angular-components'; +import { GlobalModule, StoreService } from 'nrpti-angular-components'; import { DatePipe } from '@angular/common'; import { FactoryService } from '../../../services/factory.service'; +import { EventEmitter } from '@angular/core'; describe('OrderLNGDetailComponent', () => { const testBedHelper = new TestBedHelper(OrderLNGDetailComponent); @@ -13,16 +14,24 @@ describe('OrderLNGDetailComponent', () => { // component constructor mocks const mockRouter = jasmine.createSpyObj('Router', ['navigate']); const mockActivatedRoute = new ActivatedRouteStub(); - const mockFactoryService = jasmine.createSpyObj('FactoryService', ['userInLngRole']); + const mockFactoryService = jasmine.createSpyObj('FactoryService', ['userInLngRole', 'userInBcmiRole', 'userInNrcedRole']); mockFactoryService.userInLngRole.and.returnValue(true); + mockFactoryService.userInBcmiRole.and.returnValue(true); + mockFactoryService.userInNrcedRole.and.returnValue(true); - beforeEach(async(() => { + const mockStoreService = { + getItem: () => { }, + stateChange: new EventEmitter() + }; + + beforeEach((() => { TestBed.configureTestingModule({ imports: [RouterTestingModule, GlobalModule], declarations: [OrderLNGDetailComponent], providers: [ DatePipe, { provide: Router, useValue: mockRouter }, + { provide: StoreService, useValue: mockStoreService }, { provide: ActivatedRoute, useValue: mockActivatedRoute }, { provide: FactoryService, useValue: mockFactoryService } ] diff --git a/angular/projects/admin-nrpti/src/app/records/orders/order-nrced-detail/order-nrced-detail.component.spec.ts b/angular/projects/admin-nrpti/src/app/records/orders/order-nrced-detail/order-nrced-detail.component.spec.ts index 85eff6648..b64bcf01b 100644 --- a/angular/projects/admin-nrpti/src/app/records/orders/order-nrced-detail/order-nrced-detail.component.spec.ts +++ b/angular/projects/admin-nrpti/src/app/records/orders/order-nrced-detail/order-nrced-detail.component.spec.ts @@ -1,11 +1,12 @@ -import { async, TestBed } from '@angular/core/testing'; +import { TestBed } from '@angular/core/testing'; import { OrderNRCEDDetailComponent } from './order-nrced-detail.component'; import { TestBedHelper, ActivatedRouteStub } from '../../../../../../common/src/app/spec/spec-utils'; import { RouterTestingModule } from '@angular/router/testing'; import { Router, ActivatedRoute } from '@angular/router'; -import { GlobalModule } from 'nrpti-angular-components'; +import { GlobalModule, StoreService } from 'nrpti-angular-components'; import { DatePipe } from '@angular/common'; import { FactoryService } from '../../../services/factory.service'; +import { EventEmitter } from '@angular/core'; describe('OrderNRCEDDetailComponent', () => { const testBedHelper = new TestBedHelper(OrderNRCEDDetailComponent); @@ -13,16 +14,24 @@ describe('OrderNRCEDDetailComponent', () => { // component constructor mocks const mockRouter = jasmine.createSpyObj('Router', ['navigate']); const mockActivatedRoute = new ActivatedRouteStub(); - const mockFactoryService = jasmine.createSpyObj('FactoryService', ['userInNrcedRole']); + const mockFactoryService = jasmine.createSpyObj('FactoryService', ['userInLngRole', 'userInBcmiRole', 'userInNrcedRole']); + mockFactoryService.userInLngRole.and.returnValue(true); + mockFactoryService.userInBcmiRole.and.returnValue(true); mockFactoryService.userInNrcedRole.and.returnValue(true); - beforeEach(async(() => { + const mockStoreService = { + getItem: () => { }, + stateChange: new EventEmitter() + }; + + beforeEach((() => { TestBed.configureTestingModule({ imports: [RouterTestingModule, GlobalModule], declarations: [OrderNRCEDDetailComponent], providers: [ DatePipe, { provide: Router, useValue: mockRouter }, + { provide: StoreService, useValue: mockStoreService }, { provide: ActivatedRoute, useValue: mockActivatedRoute }, { provide: FactoryService, useValue: mockFactoryService } ] diff --git a/angular/projects/admin-nrpti/src/app/records/permits/permit-add-edit/permit-add-edit.component.html b/angular/projects/admin-nrpti/src/app/records/permits/permit-add-edit/permit-add-edit.component.html index c8ef0e728..00687cc4c 100644 --- a/angular/projects/admin-nrpti/src/app/records/permits/permit-add-edit/permit-add-edit.component.html +++ b/angular/projects/admin-nrpti/src/app/records/permits/permit-add-edit/permit-add-edit.component.html @@ -94,32 +94,12 @@

Legislation

-

Issued To

-
-
- - (If Applicable) -
-
- - -
-
- - -
-
- - -
-
-
-
+ +
diff --git a/angular/projects/admin-nrpti/src/app/records/permits/permit-add-edit/permit-add-edit.component.spec.ts b/angular/projects/admin-nrpti/src/app/records/permits/permit-add-edit/permit-add-edit.component.spec.ts index e8503b33e..a270df10e 100644 --- a/angular/projects/admin-nrpti/src/app/records/permits/permit-add-edit/permit-add-edit.component.spec.ts +++ b/angular/projects/admin-nrpti/src/app/records/permits/permit-add-edit/permit-add-edit.component.spec.ts @@ -1,4 +1,4 @@ -import { async, TestBed } from '@angular/core/testing'; +import { TestBed } from '@angular/core/testing'; import { NgbModule } from '@ng-bootstrap/ng-bootstrap'; import { FormsModule, ReactiveFormsModule } from '@angular/forms'; import { PermitAddEditComponent } from './permit-add-edit.component'; @@ -10,8 +10,9 @@ import { NgxPaginationModule } from 'ngx-pagination'; import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core'; import { Utils } from 'nrpti-angular-components'; import { RecordUtils } from '../../utils/record-utils'; -import { LoadingScreenService } from 'nrpti-angular-components'; +import { LoadingScreenService, StoreService } from 'nrpti-angular-components'; import { FactoryService } from '../../../services/factory.service'; +import { EventEmitter } from '@angular/core'; describe('PermitAddEditComponent', () => { const testBedHelper = new TestBedHelper(PermitAddEditComponent); @@ -20,10 +21,16 @@ describe('PermitAddEditComponent', () => { const mockLocation = jasmine.createSpyObj('Location', ['go']); const mockRouter = jasmine.createSpyObj('Router', ['navigate']); const mockActivatedRoute = new ActivatedRouteStub(); - const mockFactoryService = jasmine.createSpyObj('FactoryService', ['userInLngRole', 'userInNrcedRole']); + const mockFactoryService = jasmine.createSpyObj('FactoryService', ['userInLngRole', 'userInBcmiRole', 'userInNrcedRole']); mockFactoryService.userInLngRole.and.returnValue(true); + mockFactoryService.userInBcmiRole.and.returnValue(true); mockFactoryService.userInNrcedRole.and.returnValue(true); + const mockStoreService = { + getItem: () => { }, + stateChange: new EventEmitter() + }; + const mockLoadingScreenService = { isLoading: false, setLoadingState: () => { @@ -31,7 +38,7 @@ describe('PermitAddEditComponent', () => { } }; - beforeEach(async(() => { + beforeEach((() => { TestBed.configureTestingModule({ imports: [ RouterTestingModule, @@ -46,6 +53,7 @@ describe('PermitAddEditComponent', () => { Utils, RecordUtils, { provide: LoadingScreenService, useValue: mockLoadingScreenService }, + { provide: StoreService, useValue: mockStoreService }, { provide: Location, useValue: mockLocation }, { provide: Router, useValue: mockRouter }, { provide: ActivatedRoute, useValue: mockActivatedRoute }, diff --git a/angular/projects/admin-nrpti/src/app/records/permits/permit-add-edit/permit-add-edit.component.ts b/angular/projects/admin-nrpti/src/app/records/permits/permit-add-edit/permit-add-edit.component.ts index f33eb5c73..e971bfa6a 100644 --- a/angular/projects/admin-nrpti/src/app/records/permits/permit-add-edit/permit-add-edit.component.ts +++ b/angular/projects/admin-nrpti/src/app/records/permits/permit-add-edit/permit-add-edit.component.ts @@ -3,13 +3,13 @@ import { ActivatedRoute, Router } from '@angular/router'; import { takeUntil } from 'rxjs/operators'; import { Subject } from 'rxjs'; import { FormGroup, FormControl } from '@angular/forms'; -import { Picklists, EpicProjectIds } from '../../../../../../common/src/app/utils/record-constants'; +import { Picklists } from '../../../../../../common/src/app/utils/record-constants'; import { Legislation } from '../../../../../../common/src/app/models/master/common-models/legislation'; import { FactoryService } from '../../../services/factory.service'; import { Utils } from 'nrpti-angular-components'; import { Utils as CommonUtils } from '../../../../../../common/src/app/utils/utils'; import { RecordUtils } from '../../utils/record-utils'; -import { LoadingScreenService } from 'nrpti-angular-components'; +import { LoadingScreenService, StoreService} from 'nrpti-angular-components'; @Component({ selector: 'app-permit-add-edit', @@ -43,6 +43,7 @@ export class PermitAddEditComponent implements OnInit, OnDestroy { public router: Router, private recordUtils: RecordUtils, private factoryService: FactoryService, + private storeService: StoreService, private loadingScreenService: LoadingScreenService, private utils: Utils, private _changeDetectionRef: ChangeDetectorRef @@ -196,7 +197,18 @@ export class PermitAddEditComponent implements OnInit, OnDestroy { publishLng: new FormControl({ value: (this.currentRecord && this.lngFlavour && this.lngFlavour.read.includes('public')) || false, disabled: !this.factoryService.userInLngRole() - }) + }), + + association: new FormGroup({ + _epicProjectId: new FormControl({ + value: this.currentRecord && this.currentRecord._epicProjectId || null, + disabled: this.currentRecord && this.currentRecord.sourceSystemRef !== 'nrpti' + }), + mineGuid: new FormControl({ + value: this.currentRecord && this.currentRecord.mineGuid || null, + disabled: this.currentRecord && this.currentRecord.sourceSystemRef !== 'nrpti' + }) + }), }); } @@ -217,12 +229,6 @@ export class PermitAddEditComponent implements OnInit, OnDestroy { async submit() { this.loadingScreenService.setLoadingState(true, 'main'); - // TODO - // _epicProjectId - // _sourceRefId - // _epicMilestoneId - // legislation - // projectName const permit = {}; this.myForm.controls.recordName.dirty && (permit['recordName'] = this.myForm.controls.recordName.value); @@ -249,19 +255,6 @@ export class PermitAddEditComponent implements OnInit, OnDestroy { this.myForm.controls.legislationDescription.dirty && (permit['legislationDescription'] = this.myForm.controls.legislationDescription.value); - // Project name logic - // If LNG Canada or Coastal Gaslink are selected we need to put it their corresponding OIDs - if (this.myForm.controls.projectName.dirty) { - permit['projectName'] = this.myForm.controls.projectName.value; - if (permit['projectName'] === 'LNG Canada') { - permit['_epicProjectId'] = EpicProjectIds.lngCanadaId; - } else if (permit['projectName'] === 'Coastal Gaslink') { - permit['_epicProjectId'] = EpicProjectIds.coastalGaslinkId; - } else { - permit['_epicProjectId'] = null; - } - } - this.myForm.controls.location.dirty && (permit['location'] = this.myForm.controls.location.value); (this.myForm.controls.latitude.dirty || this.myForm.controls.longitude.dirty) && (permit['centroid'] = [this.myForm.controls.longitude.value, this.myForm.controls.latitude.value]); @@ -278,6 +271,23 @@ export class PermitAddEditComponent implements OnInit, OnDestroy { permit['PermitLNG']['removeRole'] = 'public'; } + if (this.myForm.get('association._epicProjectId').dirty) { + permit['_epicProjectId'] = this.myForm.get('association._epicProjectId').value; + } + + if (this.myForm.get('association.mineGuid').dirty) { + permit['mineGuid'] = this.myForm.get('association.mineGuid').value; + } + + // Set the friendly name of projectName + const epicProjectList = this.storeService.getItem('epicProjects'); + const filterResult = epicProjectList.filter(item => { + return item._id === permit['_epicProjectId']; + }); + if (filterResult && filterResult[0] && filterResult[0].name) { + permit['projectName'] = filterResult[0].name; + } + if (!this.isEditing) { this.factoryService.writeRecord(permit, 'permits', true).subscribe(async res => { this.recordUtils.parseResForErrors(res); @@ -288,7 +298,7 @@ export class PermitAddEditComponent implements OnInit, OnDestroy { _id = res[0][0].object._id; } - const docResponse = await this.recordUtils.handleDocumentChanges( + await this.recordUtils.handleDocumentChanges( this.links, this.documents, this.documentsToDelete, @@ -296,7 +306,6 @@ export class PermitAddEditComponent implements OnInit, OnDestroy { this.factoryService ); - console.log(docResponse); this.loadingScreenService.setLoadingState(false, 'main'); this.router.navigate(['records']); }); @@ -314,7 +323,7 @@ export class PermitAddEditComponent implements OnInit, OnDestroy { this.factoryService.writeRecord(permit, 'permits', false).subscribe(async res => { this.recordUtils.parseResForErrors(res); - const docResponse = await this.recordUtils.handleDocumentChanges( + await this.recordUtils.handleDocumentChanges( this.links, this.documents, this.documentsToDelete, @@ -322,7 +331,6 @@ export class PermitAddEditComponent implements OnInit, OnDestroy { this.factoryService ); - console.log(docResponse); this.loadingScreenService.setLoadingState(false, 'main'); this.router.navigate(['records', 'permits', this.currentRecord._id, 'detail']); }); diff --git a/angular/projects/admin-nrpti/src/app/records/permits/permit-detail/permit-detail.component.html b/angular/projects/admin-nrpti/src/app/records/permits/permit-detail/permit-detail.component.html index 3034b163d..a76473e32 100644 --- a/angular/projects/admin-nrpti/src/app/records/permits/permit-detail/permit-detail.component.html +++ b/angular/projects/admin-nrpti/src/app/records/permits/permit-detail/permit-detail.component.html @@ -52,7 +52,7 @@

Shared Data [Master]

- {{ (data && data._master.sourceSystemRef) || '-' }} + {{ (data && data._master && data._master.sourceSystemRef) || '-' }}
diff --git a/angular/projects/admin-nrpti/src/app/records/permits/permit-detail/permit-detail.component.spec.ts b/angular/projects/admin-nrpti/src/app/records/permits/permit-detail/permit-detail.component.spec.ts index 926566398..8e3a17e82 100644 --- a/angular/projects/admin-nrpti/src/app/records/permits/permit-detail/permit-detail.component.spec.ts +++ b/angular/projects/admin-nrpti/src/app/records/permits/permit-detail/permit-detail.component.spec.ts @@ -1,13 +1,14 @@ -import { async, TestBed } from '@angular/core/testing'; +import { TestBed } from '@angular/core/testing'; import { PermitDetailComponent } from './permit-detail.component'; import { TestBedHelper, ActivatedRouteStub } from '../../../../../../common/src/app/spec/spec-utils'; import { RouterTestingModule } from '@angular/router/testing'; import { Router, ActivatedRoute } from '@angular/router'; -import { GlobalModule } from 'nrpti-angular-components'; +import { GlobalModule, StoreService } from 'nrpti-angular-components'; import { RecordDetailDirective } from '../../utils/record-detail.directive'; import { DatePipe } from '@angular/common'; import { CommonModule } from '../../../../../../common/src/app/common.module'; import { FactoryService } from '../../../services/factory.service'; +import { EventEmitter } from '@angular/core'; describe('PermitDetailComponent', () => { const testBedHelper = new TestBedHelper(PermitDetailComponent); @@ -15,17 +16,24 @@ describe('PermitDetailComponent', () => { // component constructor mocks const mockRouter = jasmine.createSpyObj('Router', ['navigate']); const mockActivatedRoute = new ActivatedRouteStub(); - const mockFactoryService = jasmine.createSpyObj('FactoryService', ['userInLngRole', 'userInNrcedRole']); + const mockFactoryService = jasmine.createSpyObj('FactoryService', ['userInLngRole', 'userInBcmiRole', 'userInNrcedRole']); mockFactoryService.userInLngRole.and.returnValue(true); + mockFactoryService.userInBcmiRole.and.returnValue(true); mockFactoryService.userInNrcedRole.and.returnValue(true); - beforeEach(async(() => { + const mockStoreService = { + getItem: () => { }, + stateChange: new EventEmitter() + }; + + beforeEach((() => { TestBed.configureTestingModule({ imports: [RouterTestingModule, GlobalModule, CommonModule], declarations: [PermitDetailComponent, RecordDetailDirective], providers: [ DatePipe, { provide: Router, useValue: mockRouter }, + { provide: StoreService, useValue: mockStoreService }, { provide: ActivatedRoute, useValue: mockActivatedRoute }, { provide: FactoryService, useValue: mockFactoryService } ] diff --git a/angular/projects/admin-nrpti/src/app/records/permits/permit-lng-detail/permit-lng-detail.component.spec.ts b/angular/projects/admin-nrpti/src/app/records/permits/permit-lng-detail/permit-lng-detail.component.spec.ts index 9c1293202..4e08eac9c 100644 --- a/angular/projects/admin-nrpti/src/app/records/permits/permit-lng-detail/permit-lng-detail.component.spec.ts +++ b/angular/projects/admin-nrpti/src/app/records/permits/permit-lng-detail/permit-lng-detail.component.spec.ts @@ -1,11 +1,12 @@ -import { async, TestBed } from '@angular/core/testing'; +import { TestBed } from '@angular/core/testing'; import { PermitLNGDetailComponent } from './permit-lng-detail.component'; import { TestBedHelper, ActivatedRouteStub } from '../../../../../../common/src/app/spec/spec-utils'; import { RouterTestingModule } from '@angular/router/testing'; import { Router, ActivatedRoute } from '@angular/router'; -import { GlobalModule } from 'nrpti-angular-components'; +import { GlobalModule, StoreService } from 'nrpti-angular-components'; import { DatePipe } from '@angular/common'; import { FactoryService } from '../../../services/factory.service'; +import { EventEmitter } from '@angular/core'; describe('PermitLNGDetailComponent', () => { const testBedHelper = new TestBedHelper(PermitLNGDetailComponent); @@ -13,16 +14,24 @@ describe('PermitLNGDetailComponent', () => { // component constructor mocks const mockRouter = jasmine.createSpyObj('Router', ['navigate']); const mockActivatedRoute = new ActivatedRouteStub(); - const mockFactoryService = jasmine.createSpyObj('FactoryService', ['userInLngRole']); + const mockFactoryService = jasmine.createSpyObj('FactoryService', ['userInLngRole', 'userInBcmiRole', 'userInNrcedRole']); mockFactoryService.userInLngRole.and.returnValue(true); + mockFactoryService.userInBcmiRole.and.returnValue(true); + mockFactoryService.userInNrcedRole.and.returnValue(true); - beforeEach(async(() => { + const mockStoreService = { + getItem: () => { }, + stateChange: new EventEmitter() + }; + + beforeEach((() => { TestBed.configureTestingModule({ imports: [RouterTestingModule, GlobalModule], declarations: [PermitLNGDetailComponent], providers: [ DatePipe, { provide: Router, useValue: mockRouter }, + { provide: StoreService, useValue: mockStoreService }, { provide: ActivatedRoute, useValue: mockActivatedRoute }, { provide: FactoryService, useValue: mockFactoryService } ] diff --git a/angular/projects/admin-nrpti/src/app/records/reports/report-add-edit/report-add-edit.component.html b/angular/projects/admin-nrpti/src/app/records/reports/report-add-edit/report-add-edit.component.html index f7d8fe45e..7b005c52e 100644 --- a/angular/projects/admin-nrpti/src/app/records/reports/report-add-edit/report-add-edit.component.html +++ b/angular/projects/admin-nrpti/src/app/records/reports/report-add-edit/report-add-edit.component.html @@ -94,32 +94,14 @@

Legislation

Issued To

-
-
- - (If Applicable) -
-
- - -
-
- - -
-
- - -
-
-
-
+ + +
diff --git a/angular/projects/admin-nrpti/src/app/records/reports/report-add-edit/report-add-edit.component.spec.ts b/angular/projects/admin-nrpti/src/app/records/reports/report-add-edit/report-add-edit.component.spec.ts index 4da047e0c..a01caaf0d 100644 --- a/angular/projects/admin-nrpti/src/app/records/reports/report-add-edit/report-add-edit.component.spec.ts +++ b/angular/projects/admin-nrpti/src/app/records/reports/report-add-edit/report-add-edit.component.spec.ts @@ -1,4 +1,4 @@ -import { async, TestBed } from '@angular/core/testing'; +import { TestBed } from '@angular/core/testing'; import { NgbModule } from '@ng-bootstrap/ng-bootstrap'; import { FormsModule, ReactiveFormsModule } from '@angular/forms'; import { ReportAddEditComponent } from './report-add-edit.component'; @@ -10,8 +10,9 @@ import { NgxPaginationModule } from 'ngx-pagination'; import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core'; import { Utils } from 'nrpti-angular-components'; import { RecordUtils } from '../../utils/record-utils'; -import { LoadingScreenService } from 'nrpti-angular-components'; +import { LoadingScreenService, StoreService } from 'nrpti-angular-components'; import { FactoryService } from '../../../services/factory.service'; +import { EventEmitter } from '@angular/core'; describe('ReportAddEditComponent', () => { const testBedHelper = new TestBedHelper(ReportAddEditComponent); @@ -20,10 +21,16 @@ describe('ReportAddEditComponent', () => { const mockLocation = jasmine.createSpyObj('Location', ['go']); const mockRouter = jasmine.createSpyObj('Router', ['navigate']); const mockActivatedRoute = new ActivatedRouteStub(); - const mockFactoryService = jasmine.createSpyObj('FactoryService', ['userInBcmiRole', 'userInNrcedRole']); + const mockFactoryService = jasmine.createSpyObj('FactoryService', ['userInLngRole', 'userInBcmiRole', 'userInNrcedRole']); + mockFactoryService.userInLngRole.and.returnValue(true); mockFactoryService.userInBcmiRole.and.returnValue(true); mockFactoryService.userInNrcedRole.and.returnValue(true); + const mockStoreService = { + getItem: () => { }, + stateChange: new EventEmitter() + }; + const mockLoadingScreenService = { isLoading: false, setLoadingState: () => { @@ -31,7 +38,7 @@ describe('ReportAddEditComponent', () => { } }; - beforeEach(async(() => { + beforeEach((() => { TestBed.configureTestingModule({ imports: [ RouterTestingModule, @@ -46,6 +53,7 @@ describe('ReportAddEditComponent', () => { Utils, RecordUtils, { provide: LoadingScreenService, useValue: mockLoadingScreenService }, + { provide: StoreService, useValue: mockStoreService }, { provide: Location, useValue: mockLocation }, { provide: Router, useValue: mockRouter }, { provide: ActivatedRoute, useValue: mockActivatedRoute }, diff --git a/angular/projects/admin-nrpti/src/app/records/reports/report-add-edit/report-add-edit.component.ts b/angular/projects/admin-nrpti/src/app/records/reports/report-add-edit/report-add-edit.component.ts index 833eaeecc..5bafc25d2 100644 --- a/angular/projects/admin-nrpti/src/app/records/reports/report-add-edit/report-add-edit.component.ts +++ b/angular/projects/admin-nrpti/src/app/records/reports/report-add-edit/report-add-edit.component.ts @@ -9,7 +9,7 @@ import { FactoryService } from '../../../services/factory.service'; import { Utils } from 'nrpti-angular-components'; import { Utils as CommonUtils } from '../../../../../../common/src/app/utils/utils'; import { RecordUtils } from '../../utils/record-utils'; -import { LoadingScreenService } from 'nrpti-angular-components'; +import { LoadingScreenService, StoreService } from 'nrpti-angular-components'; @Component({ selector: 'app-report-add-edit', @@ -42,6 +42,7 @@ export class ReportAddEditComponent implements OnInit, OnDestroy { public route: ActivatedRoute, public router: Router, private recordUtils: RecordUtils, + private storeService: StoreService, private factoryService: FactoryService, private loadingScreenService: LoadingScreenService, private utils: Utils, @@ -254,6 +255,17 @@ export class ReportAddEditComponent implements OnInit, OnDestroy { publishBcmi: new FormControl({ value: (this.currentRecord && this.bcmiFlavour && this.bcmiFlavour.read.includes('public')) || false, disabled: !this.factoryService.userInBcmiRole() + }), + + association: new FormGroup({ + _epicProjectId: new FormControl({ + value: this.currentRecord && this.currentRecord._epicProjectId || null, + disabled: this.currentRecord && this.currentRecord.sourceSystemRef !== 'nrpti' + }), + mineGuid: new FormControl({ + value: this.currentRecord && this.currentRecord.mineGuid || null, + disabled: this.currentRecord && this.currentRecord.sourceSystemRef !== 'nrpti' + }) }) }); } @@ -373,6 +385,23 @@ export class ReportAddEditComponent implements OnInit, OnDestroy { report['ReportBCMI']['removeRole'] = 'public'; } + if (this.myForm.get('association._epicProjectId').dirty) { + report['_epicProjectId'] = this.myForm.get('association._epicProjectId').value; + } + + if (this.myForm.get('association.mineGuid').dirty) { + report['mineGuid'] = this.myForm.get('association.mineGuid').value; + } + + // Set the friendly name of projectName + const epicProjectList = this.storeService.getItem('epicProjects'); + const filterResult = epicProjectList.filter(item => { + return item._id === report['_epicProjectId']; + }); + if (filterResult && filterResult[0] && filterResult[0].name) { + report['projectName'] = filterResult[0].name; + } + if (!this.isEditing) { this.factoryService.writeRecord(report, 'reports', true).subscribe(async res => { this.recordUtils.parseResForErrors(res); diff --git a/angular/projects/admin-nrpti/src/app/records/reports/report-bcmi-detail/report-bcmi-detail.component.spec.ts b/angular/projects/admin-nrpti/src/app/records/reports/report-bcmi-detail/report-bcmi-detail.component.spec.ts index 530026bad..7f67d9786 100644 --- a/angular/projects/admin-nrpti/src/app/records/reports/report-bcmi-detail/report-bcmi-detail.component.spec.ts +++ b/angular/projects/admin-nrpti/src/app/records/reports/report-bcmi-detail/report-bcmi-detail.component.spec.ts @@ -1,11 +1,12 @@ -import { async, TestBed } from '@angular/core/testing'; +import { TestBed } from '@angular/core/testing'; import { ReportBCMIDetailComponent } from './report-bcmi-detail.component'; import { TestBedHelper, ActivatedRouteStub } from '../../../../../../common/src/app/spec/spec-utils'; import { RouterTestingModule } from '@angular/router/testing'; import { Router, ActivatedRoute } from '@angular/router'; -import { GlobalModule } from 'nrpti-angular-components'; +import { GlobalModule, StoreService } from 'nrpti-angular-components'; import { DatePipe } from '@angular/common'; import { FactoryService } from '../../../services/factory.service'; +import { EventEmitter } from '@angular/core'; describe('CorrespondenceBCMIDetailComponent', () => { const testBedHelper = new TestBedHelper @@ -14,16 +15,24 @@ describe('CorrespondenceBCMIDetailComponent', () => { // component constructor mocks const mockRouter = jasmine.createSpyObj('Router', ['navigate']); const mockActivatedRoute = new ActivatedRouteStub(); - const mockFactoryService = jasmine.createSpyObj('FactoryService', ['userInBcmiRole']); + const mockFactoryService = jasmine.createSpyObj('FactoryService', ['userInLngRole', 'userInBcmiRole', 'userInNrcedRole']); + mockFactoryService.userInLngRole.and.returnValue(true); mockFactoryService.userInBcmiRole.and.returnValue(true); + mockFactoryService.userInNrcedRole.and.returnValue(true); - beforeEach(async(() => { + const mockStoreService = { + getItem: () => { }, + stateChange: new EventEmitter() + }; + + beforeEach((() => { TestBed.configureTestingModule({ imports: [RouterTestingModule, GlobalModule], declarations: [ReportBCMIDetailComponent], providers: [ DatePipe, { provide: Router, useValue: mockRouter }, + { provide: StoreService, useValue: mockStoreService }, { provide: ActivatedRoute, useValue: mockActivatedRoute }, { provide: FactoryService, useValue: mockFactoryService } ] diff --git a/angular/projects/admin-nrpti/src/app/records/reports/report-detail/report-detail.component.html b/angular/projects/admin-nrpti/src/app/records/reports/report-detail/report-detail.component.html index 77eef6f78..f0cca4476 100644 --- a/angular/projects/admin-nrpti/src/app/records/reports/report-detail/report-detail.component.html +++ b/angular/projects/admin-nrpti/src/app/records/reports/report-detail/report-detail.component.html @@ -48,7 +48,7 @@

Shared Data [Master]

- {{ (data && data._master.sourceSystemRef) || '-' }} + {{ (data && data._master && data._master.sourceSystemRef) || '-' }}
diff --git a/angular/projects/admin-nrpti/src/app/records/reports/report-detail/report-detail.component.spec.ts b/angular/projects/admin-nrpti/src/app/records/reports/report-detail/report-detail.component.spec.ts index ea68c0e5c..3d8ee66dd 100644 --- a/angular/projects/admin-nrpti/src/app/records/reports/report-detail/report-detail.component.spec.ts +++ b/angular/projects/admin-nrpti/src/app/records/reports/report-detail/report-detail.component.spec.ts @@ -1,13 +1,14 @@ -import { async, TestBed } from '@angular/core/testing'; +import { TestBed } from '@angular/core/testing'; import { ReportDetailComponent } from './report-detail.component'; import { TestBedHelper, ActivatedRouteStub } from '../../../../../../common/src/app/spec/spec-utils'; import { RouterTestingModule } from '@angular/router/testing'; import { Router, ActivatedRoute } from '@angular/router'; -import { GlobalModule } from 'nrpti-angular-components'; +import { GlobalModule, StoreService } from 'nrpti-angular-components'; import { RecordDetailDirective } from '../../utils/record-detail.directive'; import { DatePipe } from '@angular/common'; import { CommonModule } from '../../../../../../common/src/app/common.module'; import { FactoryService } from '../../../services/factory.service'; +import { EventEmitter } from '@angular/core'; describe('ReportDetailComponent', () => { const testBedHelper = new TestBedHelper(ReportDetailComponent); @@ -15,17 +16,24 @@ describe('ReportDetailComponent', () => { // component constructor mocks const mockRouter = jasmine.createSpyObj('Router', ['navigate']); const mockActivatedRoute = new ActivatedRouteStub(); - const mockFactoryService = jasmine.createSpyObj('FactoryService', ['userInBcmiRole', 'userInNrcedRole']); + const mockFactoryService = jasmine.createSpyObj('FactoryService', ['userInLngRole', 'userInBcmiRole', 'userInNrcedRole']); + mockFactoryService.userInLngRole.and.returnValue(true); mockFactoryService.userInBcmiRole.and.returnValue(true); mockFactoryService.userInNrcedRole.and.returnValue(true); - beforeEach(async(() => { + const mockStoreService = { + getItem: () => { }, + stateChange: new EventEmitter() + }; + + beforeEach((() => { TestBed.configureTestingModule({ imports: [RouterTestingModule, GlobalModule, CommonModule], declarations: [ReportDetailComponent, RecordDetailDirective], providers: [ DatePipe, { provide: Router, useValue: mockRouter }, + { provide: StoreService, useValue: mockStoreService }, { provide: ActivatedRoute, useValue: mockActivatedRoute }, { provide: FactoryService, useValue: mockFactoryService } ] diff --git a/angular/projects/admin-nrpti/src/app/records/reports/report-nrced-detail/report-nrced-detail.component.spec.ts b/angular/projects/admin-nrpti/src/app/records/reports/report-nrced-detail/report-nrced-detail.component.spec.ts index 66b76ed01..331fa7291 100644 --- a/angular/projects/admin-nrpti/src/app/records/reports/report-nrced-detail/report-nrced-detail.component.spec.ts +++ b/angular/projects/admin-nrpti/src/app/records/reports/report-nrced-detail/report-nrced-detail.component.spec.ts @@ -1,11 +1,12 @@ -import { async, TestBed } from '@angular/core/testing'; +import { TestBed } from '@angular/core/testing'; import { ReportNRCEDDetailComponent } from './report-nrced-detail.component'; import { TestBedHelper, ActivatedRouteStub } from '../../../../../../common/src/app/spec/spec-utils'; import { RouterTestingModule } from '@angular/router/testing'; import { Router, ActivatedRoute } from '@angular/router'; -import { GlobalModule } from 'nrpti-angular-components'; +import { GlobalModule, StoreService } from 'nrpti-angular-components'; import { DatePipe } from '@angular/common'; import { FactoryService } from '../../../services/factory.service'; +import { EventEmitter } from '@angular/core'; describe('CorrespondenceNRCEDDetailComponent', () => { const testBedHelper = new TestBedHelper @@ -14,16 +15,24 @@ describe('CorrespondenceNRCEDDetailComponent', () => { // component constructor mocks const mockRouter = jasmine.createSpyObj('Router', ['navigate']); const mockActivatedRoute = new ActivatedRouteStub(); - const mockFactoryService = jasmine.createSpyObj('FactoryService', ['userInNrcedRole']); + const mockFactoryService = jasmine.createSpyObj('FactoryService', ['userInLngRole', 'userInBcmiRole', 'userInNrcedRole']); + mockFactoryService.userInLngRole.and.returnValue(true); + mockFactoryService.userInBcmiRole.and.returnValue(true); mockFactoryService.userInNrcedRole.and.returnValue(true); - beforeEach(async(() => { + const mockStoreService = { + getItem: () => { }, + stateChange: new EventEmitter() + }; + + beforeEach((() => { TestBed.configureTestingModule({ imports: [RouterTestingModule, GlobalModule], declarations: [ReportNRCEDDetailComponent], providers: [ DatePipe, { provide: Router, useValue: mockRouter }, + { provide: StoreService, useValue: mockStoreService }, { provide: ActivatedRoute, useValue: mockActivatedRoute }, { provide: FactoryService, useValue: mockFactoryService } ] diff --git a/angular/projects/admin-nrpti/src/app/records/restorative-justices/restorative-justice-add-edit/restorative-justice-add-edit.component.spec.ts b/angular/projects/admin-nrpti/src/app/records/restorative-justices/restorative-justice-add-edit/restorative-justice-add-edit.component.spec.ts index 47c56eb5f..7de55f6a8 100644 --- a/angular/projects/admin-nrpti/src/app/records/restorative-justices/restorative-justice-add-edit/restorative-justice-add-edit.component.spec.ts +++ b/angular/projects/admin-nrpti/src/app/records/restorative-justices/restorative-justice-add-edit/restorative-justice-add-edit.component.spec.ts @@ -1,11 +1,11 @@ -import { async, TestBed } from '@angular/core/testing'; +import { TestBed } from '@angular/core/testing'; import { NgbModule } from '@ng-bootstrap/ng-bootstrap'; import { FormsModule, ReactiveFormsModule } from '@angular/forms'; import { RestorativeJusticeAddEditComponent } from './restorative-justice-add-edit.component'; import { TestBedHelper, ActivatedRouteStub } from '../../../../../../common/src/app/spec/spec-utils'; import { RouterTestingModule } from '@angular/router/testing'; import { Router, ActivatedRoute } from '@angular/router'; -import { GlobalModule } from 'nrpti-angular-components'; +import { GlobalModule, StoreService } from 'nrpti-angular-components'; import { NgxPaginationModule } from 'ngx-pagination'; import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core'; import { Utils } from 'nrpti-angular-components'; @@ -14,6 +14,7 @@ import { CommonModule } from '../../../../../../common/src/app/common.module'; import { MatSlideToggleModule } from '@angular/material'; import { LoadingScreenService } from 'nrpti-angular-components'; import { FactoryService } from '../../../services/factory.service'; +import { EventEmitter } from '@angular/core'; describe('RestorativeJusticeAddEditComponent', () => { const testBedHelper = new TestBedHelper(RestorativeJusticeAddEditComponent); @@ -22,8 +23,9 @@ describe('RestorativeJusticeAddEditComponent', () => { const mockLocation = jasmine.createSpyObj('Location', ['go']); const mockRouter = jasmine.createSpyObj('Router', ['navigate']); const mockActivatedRoute = new ActivatedRouteStub(); - const mockFactoryService = jasmine.createSpyObj('FactoryService', ['userInLngRole', 'userInNrcedRole']); + const mockFactoryService = jasmine.createSpyObj('FactoryService', ['userInLngRole', 'userInBcmiRole', 'userInNrcedRole']); mockFactoryService.userInLngRole.and.returnValue(true); + mockFactoryService.userInBcmiRole.and.returnValue(true); mockFactoryService.userInNrcedRole.and.returnValue(true); const mockLoadingScreenService = { @@ -33,7 +35,12 @@ describe('RestorativeJusticeAddEditComponent', () => { } }; - beforeEach(async(() => { + const mockStoreService = { + getItem: () => { }, + stateChange: new EventEmitter() + }; + + beforeEach((() => { TestBed.configureTestingModule({ imports: [ RouterTestingModule, @@ -50,6 +57,7 @@ describe('RestorativeJusticeAddEditComponent', () => { Utils, RecordUtils, { provide: LoadingScreenService, useValue: mockLoadingScreenService }, + { provide: StoreService, useValue: mockStoreService }, { provide: Location, useValue: mockLocation }, { provide: Router, useValue: mockRouter }, { provide: ActivatedRoute, useValue: mockActivatedRoute }, diff --git a/angular/projects/admin-nrpti/src/app/records/restorative-justices/restorative-justice-detail/restorative-justice-detail.component.html b/angular/projects/admin-nrpti/src/app/records/restorative-justices/restorative-justice-detail/restorative-justice-detail.component.html index a92bc603b..3ce93c16f 100644 --- a/angular/projects/admin-nrpti/src/app/records/restorative-justices/restorative-justice-detail/restorative-justice-detail.component.html +++ b/angular/projects/admin-nrpti/src/app/records/restorative-justices/restorative-justice-detail/restorative-justice-detail.component.html @@ -52,7 +52,7 @@

Shared Data [Master]

- {{ (data && data._master.sourceSystemRef) || '-' }} + {{ (data && data._master && data._master.sourceSystemRef) || '-' }}
diff --git a/angular/projects/admin-nrpti/src/app/records/restorative-justices/restorative-justice-detail/restorative-justice-detail.component.spec.ts b/angular/projects/admin-nrpti/src/app/records/restorative-justices/restorative-justice-detail/restorative-justice-detail.component.spec.ts index 8d3a22b69..d47e0261a 100644 --- a/angular/projects/admin-nrpti/src/app/records/restorative-justices/restorative-justice-detail/restorative-justice-detail.component.spec.ts +++ b/angular/projects/admin-nrpti/src/app/records/restorative-justices/restorative-justice-detail/restorative-justice-detail.component.spec.ts @@ -1,15 +1,16 @@ -import { async, TestBed } from '@angular/core/testing'; +import { TestBed } from '@angular/core/testing'; import { RestorativeJusticeDetailComponent } from './restorative-justice-detail.component'; import { TestBedHelper, ActivatedRouteStub } from '../../../../../../common/src/app/spec/spec-utils'; import { RouterTestingModule } from '@angular/router/testing'; import { Router, ActivatedRoute } from '@angular/router'; -import { GlobalModule } from 'nrpti-angular-components'; +import { GlobalModule, StoreService } from 'nrpti-angular-components'; import { RecordDetailDirective } from '../../utils/record-detail.directive'; import { DatePipe } from '@angular/common'; import { CommonModule } from '../../../../../../common/src/app/common.module'; import { DocumentAuthenticatedReadOnlyComponent } from '../../../documents/document-authenticated-read-only/document-authenticated-read-only.component'; import { S3SignedUrlAnchorComponent } from '../../../documents/s3-signed-url-anchor/s3-signed-url-anchor.component'; import { FactoryService } from '../../../services/factory.service'; +import { EventEmitter } from '@angular/core'; describe('RestorativeJusticeDetailComponent', () => { const testBedHelper = new TestBedHelper(RestorativeJusticeDetailComponent); @@ -17,11 +18,17 @@ describe('RestorativeJusticeDetailComponent', () => { // component constructor mocks const mockRouter = jasmine.createSpyObj('Router', ['navigate']); const mockActivatedRoute = new ActivatedRouteStub(); - const mockFactoryService = jasmine.createSpyObj('FactoryService', ['userInLngRole', 'userInNrcedRole']); + const mockFactoryService = jasmine.createSpyObj('FactoryService', ['userInLngRole', 'userInBcmiRole', 'userInNrcedRole']); mockFactoryService.userInLngRole.and.returnValue(true); + mockFactoryService.userInBcmiRole.and.returnValue(true); mockFactoryService.userInNrcedRole.and.returnValue(true); - beforeEach(async(() => { + const mockStoreService = { + getItem: () => { }, + stateChange: new EventEmitter() + }; + + beforeEach((() => { TestBed.configureTestingModule({ imports: [RouterTestingModule, GlobalModule, CommonModule], declarations: [ @@ -33,6 +40,7 @@ describe('RestorativeJusticeDetailComponent', () => { providers: [ DatePipe, { provide: Router, useValue: mockRouter }, + { provide: StoreService, useValue: mockStoreService }, { provide: ActivatedRoute, useValue: mockActivatedRoute }, { provide: FactoryService, useValue: mockFactoryService } ] diff --git a/angular/projects/admin-nrpti/src/app/records/restorative-justices/restorative-justice-lng-detail/restorative-justice-lng-detail.component.spec.ts b/angular/projects/admin-nrpti/src/app/records/restorative-justices/restorative-justice-lng-detail/restorative-justice-lng-detail.component.spec.ts index a48b344d6..e90419be5 100644 --- a/angular/projects/admin-nrpti/src/app/records/restorative-justices/restorative-justice-lng-detail/restorative-justice-lng-detail.component.spec.ts +++ b/angular/projects/admin-nrpti/src/app/records/restorative-justices/restorative-justice-lng-detail/restorative-justice-lng-detail.component.spec.ts @@ -1,11 +1,12 @@ -import { async, TestBed } from '@angular/core/testing'; +import { TestBed } from '@angular/core/testing'; import { RestorativeJusticeLNGDetailComponent } from './restorative-justice-lng-detail.component'; import { TestBedHelper, ActivatedRouteStub } from '../../../../../../common/src/app/spec/spec-utils'; import { RouterTestingModule } from '@angular/router/testing'; import { Router, ActivatedRoute } from '@angular/router'; -import { GlobalModule } from 'nrpti-angular-components'; +import { GlobalModule, StoreService } from 'nrpti-angular-components'; import { DatePipe } from '@angular/common'; import { FactoryService } from '../../../services/factory.service'; +import { EventEmitter } from '@angular/core'; describe('RestorativeJusticeLNGDetailComponent', () => { const testBedHelper = new TestBedHelper(RestorativeJusticeLNGDetailComponent); @@ -13,16 +14,24 @@ describe('RestorativeJusticeLNGDetailComponent', () => { // component constructor mocks const mockRouter = jasmine.createSpyObj('Router', ['navigate']); const mockActivatedRoute = new ActivatedRouteStub(); - const mockFactoryService = jasmine.createSpyObj('FactoryService', ['userInLngRole']); + const mockFactoryService = jasmine.createSpyObj('FactoryService', ['userInLngRole', 'userInBcmiRole', 'userInNrcedRole']); mockFactoryService.userInLngRole.and.returnValue(true); + mockFactoryService.userInBcmiRole.and.returnValue(true); + mockFactoryService.userInNrcedRole.and.returnValue(true); - beforeEach(async(() => { + const mockStoreService = { + getItem: () => { }, + stateChange: new EventEmitter() + }; + + beforeEach((() => { TestBed.configureTestingModule({ imports: [RouterTestingModule, GlobalModule], declarations: [RestorativeJusticeLNGDetailComponent], providers: [ DatePipe, { provide: Router, useValue: mockRouter }, + { provide: StoreService, useValue: mockStoreService }, { provide: ActivatedRoute, useValue: mockActivatedRoute }, { provide: FactoryService, useValue: mockFactoryService } ] diff --git a/angular/projects/admin-nrpti/src/app/records/restorative-justices/restorative-justice-nrced-detail/restorative-justice-nrced-detail.component.spec.ts b/angular/projects/admin-nrpti/src/app/records/restorative-justices/restorative-justice-nrced-detail/restorative-justice-nrced-detail.component.spec.ts index abaffc0df..7910e4bbd 100644 --- a/angular/projects/admin-nrpti/src/app/records/restorative-justices/restorative-justice-nrced-detail/restorative-justice-nrced-detail.component.spec.ts +++ b/angular/projects/admin-nrpti/src/app/records/restorative-justices/restorative-justice-nrced-detail/restorative-justice-nrced-detail.component.spec.ts @@ -1,11 +1,12 @@ -import { async, TestBed } from '@angular/core/testing'; +import { TestBed } from '@angular/core/testing'; import { RestorativeJusticeNRCEDDetailComponent } from './restorative-justice-nrced-detail.component'; import { TestBedHelper, ActivatedRouteStub } from '../../../../../../common/src/app/spec/spec-utils'; import { RouterTestingModule } from '@angular/router/testing'; import { Router, ActivatedRoute } from '@angular/router'; -import { GlobalModule } from 'nrpti-angular-components'; +import { GlobalModule, StoreService } from 'nrpti-angular-components'; import { DatePipe } from '@angular/common'; import { FactoryService } from '../../../services/factory.service'; +import { EventEmitter } from '@angular/core'; describe('RestorativeJusticeNRCEDDetailComponent', () => { const testBedHelper = new TestBedHelper( @@ -15,16 +16,24 @@ describe('RestorativeJusticeNRCEDDetailComponent', () => { // component constructor mocks const mockRouter = jasmine.createSpyObj('Router', ['navigate']); const mockActivatedRoute = new ActivatedRouteStub(); - const mockFactoryService = jasmine.createSpyObj('FactoryService', ['userInNrcedRole']); + const mockFactoryService = jasmine.createSpyObj('FactoryService', ['userInLngRole', 'userInBcmiRole', 'userInNrcedRole']); + mockFactoryService.userInLngRole.and.returnValue(true); + mockFactoryService.userInBcmiRole.and.returnValue(true); mockFactoryService.userInNrcedRole.and.returnValue(true); - beforeEach(async(() => { + const mockStoreService = { + getItem: () => { }, + stateChange: new EventEmitter() + }; + + beforeEach((() => { TestBed.configureTestingModule({ imports: [RouterTestingModule, GlobalModule], declarations: [RestorativeJusticeNRCEDDetailComponent], providers: [ DatePipe, { provide: Router, useValue: mockRouter }, + { provide: StoreService, useValue: mockStoreService }, { provide: ActivatedRoute, useValue: mockActivatedRoute }, { provide: FactoryService, useValue: mockFactoryService } ] diff --git a/angular/projects/admin-nrpti/src/app/records/self-reports/self-report-add-edit/self-report-add-edit.component.spec.ts b/angular/projects/admin-nrpti/src/app/records/self-reports/self-report-add-edit/self-report-add-edit.component.spec.ts index 0fa3f876f..274d8fea4 100644 --- a/angular/projects/admin-nrpti/src/app/records/self-reports/self-report-add-edit/self-report-add-edit.component.spec.ts +++ b/angular/projects/admin-nrpti/src/app/records/self-reports/self-report-add-edit/self-report-add-edit.component.spec.ts @@ -1,17 +1,18 @@ -import { async, TestBed } from '@angular/core/testing'; +import { TestBed } from '@angular/core/testing'; import { NgbModule } from '@ng-bootstrap/ng-bootstrap'; import { FormsModule, ReactiveFormsModule } from '@angular/forms'; import { SelfReportAddEditComponent } from './self-report-add-edit.component'; import { TestBedHelper, ActivatedRouteStub } from '../../../../../../common/src/app/spec/spec-utils'; import { RouterTestingModule } from '@angular/router/testing'; import { Router, ActivatedRoute } from '@angular/router'; -import { GlobalModule } from 'nrpti-angular-components'; +import { GlobalModule, StoreService } from 'nrpti-angular-components'; import { NgxPaginationModule } from 'ngx-pagination'; import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core'; import { Utils } from 'nrpti-angular-components'; import { RecordUtils } from '../../utils/record-utils'; import { LoadingScreenService } from 'nrpti-angular-components'; import { FactoryService } from '../../../services/factory.service'; +import { EventEmitter } from '@angular/core'; describe('SelfReportAddEditComponent', () => { const testBedHelper = new TestBedHelper(SelfReportAddEditComponent); @@ -20,8 +21,9 @@ describe('SelfReportAddEditComponent', () => { const mockLocation = jasmine.createSpyObj('Location', ['go']); const mockRouter = jasmine.createSpyObj('Router', ['navigate']); const mockActivatedRoute = new ActivatedRouteStub(); - const mockFactoryService = jasmine.createSpyObj('FactoryService', ['userInLngRole', 'userInNrcedRole']); + const mockFactoryService = jasmine.createSpyObj('FactoryService', ['userInLngRole', 'userInBcmiRole', 'userInNrcedRole']); mockFactoryService.userInLngRole.and.returnValue(true); + mockFactoryService.userInBcmiRole.and.returnValue(true); mockFactoryService.userInNrcedRole.and.returnValue(true); const mockLoadingScreenService = { @@ -31,7 +33,12 @@ describe('SelfReportAddEditComponent', () => { } }; - beforeEach(async(() => { + const mockStoreService = { + getItem: () => { }, + stateChange: new EventEmitter() + }; + + beforeEach((() => { TestBed.configureTestingModule({ imports: [ RouterTestingModule, @@ -46,6 +53,7 @@ describe('SelfReportAddEditComponent', () => { Utils, RecordUtils, { provide: LoadingScreenService, useValue: mockLoadingScreenService }, + { provide: StoreService, useValue: mockStoreService }, { provide: Location, useValue: mockLocation }, { provide: Router, useValue: mockRouter }, { provide: ActivatedRoute, useValue: mockActivatedRoute }, diff --git a/angular/projects/admin-nrpti/src/app/records/self-reports/self-report-detail/self-report-detail.component.html b/angular/projects/admin-nrpti/src/app/records/self-reports/self-report-detail/self-report-detail.component.html index 102671702..078410e91 100644 --- a/angular/projects/admin-nrpti/src/app/records/self-reports/self-report-detail/self-report-detail.component.html +++ b/angular/projects/admin-nrpti/src/app/records/self-reports/self-report-detail/self-report-detail.component.html @@ -52,7 +52,7 @@

Shared Data [Master]

- {{ (data && data._master.sourceSystemRef) || '-' }} + {{ (data && data._master && data._master.sourceSystemRef) || '-' }}
diff --git a/angular/projects/admin-nrpti/src/app/records/self-reports/self-report-detail/self-report-detail.component.spec.ts b/angular/projects/admin-nrpti/src/app/records/self-reports/self-report-detail/self-report-detail.component.spec.ts index 4c0120f5a..3840f8b6c 100644 --- a/angular/projects/admin-nrpti/src/app/records/self-reports/self-report-detail/self-report-detail.component.spec.ts +++ b/angular/projects/admin-nrpti/src/app/records/self-reports/self-report-detail/self-report-detail.component.spec.ts @@ -1,13 +1,14 @@ -import { async, TestBed } from '@angular/core/testing'; +import { TestBed } from '@angular/core/testing'; import { SelfReportDetailComponent } from './self-report-detail.component'; import { TestBedHelper, ActivatedRouteStub } from '../../../../../../common/src/app/spec/spec-utils'; import { RouterTestingModule } from '@angular/router/testing'; import { Router, ActivatedRoute } from '@angular/router'; -import { GlobalModule } from 'nrpti-angular-components'; +import { GlobalModule, StoreService } from 'nrpti-angular-components'; import { RecordDetailDirective } from '../../utils/record-detail.directive'; import { DatePipe } from '@angular/common'; import { CommonModule } from '../../../../../../common/src/app/common.module'; import { FactoryService } from '../../../services/factory.service'; +import { EventEmitter } from '@angular/core'; describe('SelfReportDetailComponent', () => { const testBedHelper = new TestBedHelper(SelfReportDetailComponent); @@ -15,17 +16,24 @@ describe('SelfReportDetailComponent', () => { // component constructor mocks const mockRouter = jasmine.createSpyObj('Router', ['navigate']); const mockActivatedRoute = new ActivatedRouteStub(); - const mockFactoryService = jasmine.createSpyObj('FactoryService', ['userInLngRole', 'userInNrcedRole']); + const mockFactoryService = jasmine.createSpyObj('FactoryService', ['userInLngRole', 'userInBcmiRole', 'userInNrcedRole']); mockFactoryService.userInLngRole.and.returnValue(true); + mockFactoryService.userInBcmiRole.and.returnValue(true); mockFactoryService.userInNrcedRole.and.returnValue(true); - beforeEach(async(() => { + const mockStoreService = { + getItem: () => { }, + stateChange: new EventEmitter() + }; + + beforeEach((() => { TestBed.configureTestingModule({ imports: [RouterTestingModule, GlobalModule, CommonModule], declarations: [SelfReportDetailComponent, RecordDetailDirective], providers: [ DatePipe, { provide: Router, useValue: mockRouter }, + { provide: StoreService, useValue: mockStoreService }, { provide: ActivatedRoute, useValue: mockActivatedRoute }, { provide: FactoryService, useValue: mockFactoryService } ] diff --git a/angular/projects/admin-nrpti/src/app/records/self-reports/self-report-lng-detail/self-report-lng-detail.component.spec.ts b/angular/projects/admin-nrpti/src/app/records/self-reports/self-report-lng-detail/self-report-lng-detail.component.spec.ts index c648b931c..be2033e28 100644 --- a/angular/projects/admin-nrpti/src/app/records/self-reports/self-report-lng-detail/self-report-lng-detail.component.spec.ts +++ b/angular/projects/admin-nrpti/src/app/records/self-reports/self-report-lng-detail/self-report-lng-detail.component.spec.ts @@ -1,11 +1,12 @@ -import { async, TestBed } from '@angular/core/testing'; +import { TestBed } from '@angular/core/testing'; import { SelfReportLNGDetailComponent } from './self-report-lng-detail.component'; import { TestBedHelper, ActivatedRouteStub } from '../../../../../../common/src/app/spec/spec-utils'; import { RouterTestingModule } from '@angular/router/testing'; import { Router, ActivatedRoute } from '@angular/router'; -import { GlobalModule } from 'nrpti-angular-components'; +import { GlobalModule, StoreService } from 'nrpti-angular-components'; import { DatePipe } from '@angular/common'; import { FactoryService } from '../../../services/factory.service'; +import { EventEmitter } from '@angular/core'; describe('SelfReportLNGDetailComponent', () => { const testBedHelper = new TestBedHelper(SelfReportLNGDetailComponent); @@ -13,16 +14,24 @@ describe('SelfReportLNGDetailComponent', () => { // component constructor mocks const mockRouter = jasmine.createSpyObj('Router', ['navigate']); const mockActivatedRoute = new ActivatedRouteStub(); - const mockFactoryService = jasmine.createSpyObj('FactoryService', ['userInLngRole']); + const mockFactoryService = jasmine.createSpyObj('FactoryService', ['userInLngRole', 'userInBcmiRole', 'userInNrcedRole']); mockFactoryService.userInLngRole.and.returnValue(true); + mockFactoryService.userInBcmiRole.and.returnValue(true); + mockFactoryService.userInNrcedRole.and.returnValue(true); - beforeEach(async(() => { + const mockStoreService = { + getItem: () => { }, + stateChange: new EventEmitter() + }; + + beforeEach((() => { TestBed.configureTestingModule({ imports: [RouterTestingModule, GlobalModule], declarations: [SelfReportLNGDetailComponent], providers: [ DatePipe, { provide: Router, useValue: mockRouter }, + { provide: StoreService, useValue: mockStoreService }, { provide: ActivatedRoute, useValue: mockActivatedRoute }, { provide: FactoryService, useValue: mockFactoryService } ] diff --git a/angular/projects/admin-nrpti/src/app/records/tickets/ticket-add-edit/ticket-add-edit.component.spec.ts b/angular/projects/admin-nrpti/src/app/records/tickets/ticket-add-edit/ticket-add-edit.component.spec.ts index a0c7414c3..d95700751 100644 --- a/angular/projects/admin-nrpti/src/app/records/tickets/ticket-add-edit/ticket-add-edit.component.spec.ts +++ b/angular/projects/admin-nrpti/src/app/records/tickets/ticket-add-edit/ticket-add-edit.component.spec.ts @@ -1,11 +1,11 @@ -import { async, TestBed } from '@angular/core/testing'; +import { TestBed } from '@angular/core/testing'; import { NgbModule } from '@ng-bootstrap/ng-bootstrap'; import { FormsModule, ReactiveFormsModule } from '@angular/forms'; import { TicketAddEditComponent } from './ticket-add-edit.component'; import { TestBedHelper, ActivatedRouteStub } from '../../../../../../common/src/app/spec/spec-utils'; import { RouterTestingModule } from '@angular/router/testing'; import { Router, ActivatedRoute } from '@angular/router'; -import { GlobalModule } from 'nrpti-angular-components'; +import { GlobalModule, StoreService } from 'nrpti-angular-components'; import { NgxPaginationModule } from 'ngx-pagination'; import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core'; import { Utils } from 'nrpti-angular-components'; @@ -14,6 +14,7 @@ import { CommonModule } from '../../../../../../common/src/app/common.module'; import { MatSlideToggleModule } from '@angular/material'; import { LoadingScreenService } from 'nrpti-angular-components'; import { FactoryService } from '../../../services/factory.service'; +import { EventEmitter } from '@angular/core'; describe('TicketAddEditComponent', () => { const testBedHelper = new TestBedHelper(TicketAddEditComponent); @@ -22,8 +23,9 @@ describe('TicketAddEditComponent', () => { const mockLocation = jasmine.createSpyObj('Location', ['go']); const mockRouter = jasmine.createSpyObj('Router', ['navigate']); const mockActivatedRoute = new ActivatedRouteStub(); - const mockFactoryService = jasmine.createSpyObj('FactoryService', ['userInLngRole', 'userInNrcedRole']); + const mockFactoryService = jasmine.createSpyObj('FactoryService', ['userInLngRole', 'userInBcmiRole', 'userInNrcedRole']); mockFactoryService.userInLngRole.and.returnValue(true); + mockFactoryService.userInBcmiRole.and.returnValue(true); mockFactoryService.userInNrcedRole.and.returnValue(true); const mockLoadingScreenService = { @@ -33,7 +35,12 @@ describe('TicketAddEditComponent', () => { } }; - beforeEach(async(() => { + const mockStoreService = { + getItem: () => { }, + stateChange: new EventEmitter() + }; + + beforeEach((() => { TestBed.configureTestingModule({ imports: [ RouterTestingModule, @@ -50,6 +57,7 @@ describe('TicketAddEditComponent', () => { Utils, RecordUtils, { provide: LoadingScreenService, useValue: mockLoadingScreenService }, + { provide: StoreService, useValue: mockStoreService }, { provide: Location, useValue: mockLocation }, { provide: Router, useValue: mockRouter }, { provide: ActivatedRoute, useValue: mockActivatedRoute }, diff --git a/angular/projects/admin-nrpti/src/app/records/tickets/ticket-detail/ticket-detail.component.html b/angular/projects/admin-nrpti/src/app/records/tickets/ticket-detail/ticket-detail.component.html index a92bc603b..3ce93c16f 100644 --- a/angular/projects/admin-nrpti/src/app/records/tickets/ticket-detail/ticket-detail.component.html +++ b/angular/projects/admin-nrpti/src/app/records/tickets/ticket-detail/ticket-detail.component.html @@ -52,7 +52,7 @@

Shared Data [Master]

- {{ (data && data._master.sourceSystemRef) || '-' }} + {{ (data && data._master && data._master.sourceSystemRef) || '-' }}
diff --git a/angular/projects/admin-nrpti/src/app/records/tickets/ticket-detail/ticket-detail.component.spec.ts b/angular/projects/admin-nrpti/src/app/records/tickets/ticket-detail/ticket-detail.component.spec.ts index 27cb1af82..ed812ca52 100644 --- a/angular/projects/admin-nrpti/src/app/records/tickets/ticket-detail/ticket-detail.component.spec.ts +++ b/angular/projects/admin-nrpti/src/app/records/tickets/ticket-detail/ticket-detail.component.spec.ts @@ -1,15 +1,16 @@ -import { async, TestBed } from '@angular/core/testing'; +import { TestBed } from '@angular/core/testing'; import { TicketDetailComponent } from './ticket-detail.component'; import { TestBedHelper, ActivatedRouteStub } from '../../../../../../common/src/app/spec/spec-utils'; import { RouterTestingModule } from '@angular/router/testing'; import { Router, ActivatedRoute } from '@angular/router'; -import { GlobalModule } from 'nrpti-angular-components'; +import { GlobalModule, StoreService } from 'nrpti-angular-components'; import { RecordDetailDirective } from '../../utils/record-detail.directive'; import { DatePipe } from '@angular/common'; import { CommonModule } from '../../../../../../common/src/app/common.module'; import { DocumentAuthenticatedReadOnlyComponent } from '../../../documents/document-authenticated-read-only/document-authenticated-read-only.component'; import { S3SignedUrlAnchorComponent } from '../../../documents/s3-signed-url-anchor/s3-signed-url-anchor.component'; import { FactoryService } from '../../../services/factory.service'; +import { EventEmitter } from '@angular/core'; describe('TicketDetailComponent', () => { const testBedHelper = new TestBedHelper(TicketDetailComponent); @@ -17,11 +18,17 @@ describe('TicketDetailComponent', () => { // component constructor mocks const mockRouter = jasmine.createSpyObj('Router', ['navigate']); const mockActivatedRoute = new ActivatedRouteStub(); - const mockFactoryService = jasmine.createSpyObj('FactoryService', ['userInLngRole', 'userInNrcedRole']); + const mockFactoryService = jasmine.createSpyObj('FactoryService', ['userInLngRole', 'userInBcmiRole', 'userInNrcedRole']); mockFactoryService.userInLngRole.and.returnValue(true); + mockFactoryService.userInBcmiRole.and.returnValue(true); mockFactoryService.userInNrcedRole.and.returnValue(true); - beforeEach(async(() => { + const mockStoreService = { + getItem: () => { }, + stateChange: new EventEmitter() + }; + + beforeEach((() => { TestBed.configureTestingModule({ imports: [RouterTestingModule, GlobalModule, CommonModule], declarations: [ @@ -33,6 +40,7 @@ describe('TicketDetailComponent', () => { providers: [ DatePipe, { provide: Router, useValue: mockRouter }, + { provide: StoreService, useValue: mockStoreService }, { provide: ActivatedRoute, useValue: mockActivatedRoute }, { provide: FactoryService, useValue: mockFactoryService } ] diff --git a/angular/projects/admin-nrpti/src/app/records/tickets/ticket-lng-detail/ticket-lng-detail.component.spec.ts b/angular/projects/admin-nrpti/src/app/records/tickets/ticket-lng-detail/ticket-lng-detail.component.spec.ts index c5c4fc01b..f6853809b 100644 --- a/angular/projects/admin-nrpti/src/app/records/tickets/ticket-lng-detail/ticket-lng-detail.component.spec.ts +++ b/angular/projects/admin-nrpti/src/app/records/tickets/ticket-lng-detail/ticket-lng-detail.component.spec.ts @@ -1,11 +1,12 @@ -import { async, TestBed } from '@angular/core/testing'; +import { TestBed } from '@angular/core/testing'; import { TicketLNGDetailComponent } from './ticket-lng-detail.component'; import { TestBedHelper, ActivatedRouteStub } from '../../../../../../common/src/app/spec/spec-utils'; import { RouterTestingModule } from '@angular/router/testing'; import { Router, ActivatedRoute } from '@angular/router'; -import { GlobalModule } from 'nrpti-angular-components'; +import { GlobalModule, StoreService } from 'nrpti-angular-components'; import { DatePipe } from '@angular/common'; import { FactoryService } from '../../../services/factory.service'; +import { EventEmitter } from '@angular/core'; describe('TicketLNGDetailComponent', () => { const testBedHelper = new TestBedHelper(TicketLNGDetailComponent); @@ -13,16 +14,24 @@ describe('TicketLNGDetailComponent', () => { // component constructor mocks const mockRouter = jasmine.createSpyObj('Router', ['navigate']); const mockActivatedRoute = new ActivatedRouteStub(); - const mockFactoryService = jasmine.createSpyObj('FactoryService', ['userInLngRole']); + const mockFactoryService = jasmine.createSpyObj('FactoryService', ['userInLngRole', 'userInBcmiRole', 'userInNrcedRole']); mockFactoryService.userInLngRole.and.returnValue(true); + mockFactoryService.userInBcmiRole.and.returnValue(true); + mockFactoryService.userInNrcedRole.and.returnValue(true); - beforeEach(async(() => { + const mockStoreService = { + getItem: () => { }, + stateChange: new EventEmitter() + }; + + beforeEach((() => { TestBed.configureTestingModule({ imports: [RouterTestingModule, GlobalModule], declarations: [TicketLNGDetailComponent], providers: [ DatePipe, { provide: Router, useValue: mockRouter }, + { provide: StoreService, useValue: mockStoreService }, { provide: ActivatedRoute, useValue: mockActivatedRoute }, { provide: FactoryService, useValue: mockFactoryService } ] diff --git a/angular/projects/admin-nrpti/src/app/records/tickets/ticket-nrced-detail/ticket-nrced-detail.component.spec.ts b/angular/projects/admin-nrpti/src/app/records/tickets/ticket-nrced-detail/ticket-nrced-detail.component.spec.ts index 38ed3e833..2efff66de 100644 --- a/angular/projects/admin-nrpti/src/app/records/tickets/ticket-nrced-detail/ticket-nrced-detail.component.spec.ts +++ b/angular/projects/admin-nrpti/src/app/records/tickets/ticket-nrced-detail/ticket-nrced-detail.component.spec.ts @@ -1,11 +1,12 @@ -import { async, TestBed } from '@angular/core/testing'; +import { TestBed } from '@angular/core/testing'; import { TicketNRCEDDetailComponent } from './ticket-nrced-detail.component'; import { TestBedHelper, ActivatedRouteStub } from '../../../../../../common/src/app/spec/spec-utils'; import { RouterTestingModule } from '@angular/router/testing'; import { Router, ActivatedRoute } from '@angular/router'; -import { GlobalModule } from 'nrpti-angular-components'; +import { GlobalModule, StoreService } from 'nrpti-angular-components'; import { DatePipe } from '@angular/common'; import { FactoryService } from '../../../services/factory.service'; +import { EventEmitter } from '@angular/core'; describe('TicketNRCEDDetailComponent', () => { const testBedHelper = new TestBedHelper(TicketNRCEDDetailComponent); @@ -13,17 +14,24 @@ describe('TicketNRCEDDetailComponent', () => { // component constructor mocks const mockRouter = jasmine.createSpyObj('Router', ['navigate']); const mockActivatedRoute = new ActivatedRouteStub(); - const mockFactoryService = jasmine.createSpyObj('FactoryService', ['userInLngRole', 'userInNrcedRole']); + const mockFactoryService = jasmine.createSpyObj('FactoryService', ['userInLngRole', 'userInBcmiRole', 'userInNrcedRole']); mockFactoryService.userInLngRole.and.returnValue(true); + mockFactoryService.userInBcmiRole.and.returnValue(true); mockFactoryService.userInNrcedRole.and.returnValue(true); - beforeEach(async(() => { + const mockStoreService = { + getItem: () => { }, + stateChange: new EventEmitter() + }; + + beforeEach((() => { TestBed.configureTestingModule({ imports: [RouterTestingModule, GlobalModule], declarations: [TicketNRCEDDetailComponent], providers: [ DatePipe, { provide: Router, useValue: mockRouter }, + { provide: StoreService, useValue: mockStoreService }, { provide: ActivatedRoute, useValue: mockActivatedRoute }, { provide: FactoryService, useValue: mockFactoryService } ] diff --git a/angular/projects/admin-nrpti/src/app/records/warnings/warning-add-edit/warning-add-edit.component.spec.ts b/angular/projects/admin-nrpti/src/app/records/warnings/warning-add-edit/warning-add-edit.component.spec.ts index 0c835baf4..8561b4d3c 100644 --- a/angular/projects/admin-nrpti/src/app/records/warnings/warning-add-edit/warning-add-edit.component.spec.ts +++ b/angular/projects/admin-nrpti/src/app/records/warnings/warning-add-edit/warning-add-edit.component.spec.ts @@ -1,4 +1,4 @@ -import { async, TestBed } from '@angular/core/testing'; +import { TestBed } from '@angular/core/testing'; import { NgbModule } from '@ng-bootstrap/ng-bootstrap'; import { FormsModule, ReactiveFormsModule } from '@angular/forms'; import { WarningAddEditComponent } from './warning-add-edit.component'; @@ -33,7 +33,7 @@ describe('WarningAddEditComponent', () => { } }; - beforeEach(async(() => { + beforeEach((() => { TestBed.configureTestingModule({ imports: [ RouterTestingModule, diff --git a/angular/projects/admin-nrpti/src/app/records/warnings/warning-detail/warning-detail.component.html b/angular/projects/admin-nrpti/src/app/records/warnings/warning-detail/warning-detail.component.html index 62b7f98f8..74747af44 100644 --- a/angular/projects/admin-nrpti/src/app/records/warnings/warning-detail/warning-detail.component.html +++ b/angular/projects/admin-nrpti/src/app/records/warnings/warning-detail/warning-detail.component.html @@ -52,7 +52,7 @@

Shared Data [Master]

- {{ (data && data._master.sourceSystemRef) || '-' }} + {{ (data && data._master && data._master.sourceSystemRef) || '-' }}
diff --git a/angular/projects/admin-nrpti/src/app/records/warnings/warning-detail/warning-detail.component.spec.ts b/angular/projects/admin-nrpti/src/app/records/warnings/warning-detail/warning-detail.component.spec.ts index e9f03820f..afc800b50 100644 --- a/angular/projects/admin-nrpti/src/app/records/warnings/warning-detail/warning-detail.component.spec.ts +++ b/angular/projects/admin-nrpti/src/app/records/warnings/warning-detail/warning-detail.component.spec.ts @@ -1,4 +1,4 @@ -import { async, TestBed } from '@angular/core/testing'; +import { TestBed } from '@angular/core/testing'; import { WarningDetailComponent } from './warning-detail.component'; import { TestBedHelper, ActivatedRouteStub } from '../../../../../../common/src/app/spec/spec-utils'; import { RouterTestingModule } from '@angular/router/testing'; @@ -21,7 +21,7 @@ describe('WarningDetailComponent', () => { mockFactoryService.userInLngRole.and.returnValue(true); mockFactoryService.userInNrcedRole.and.returnValue(true); - beforeEach(async(() => { + beforeEach((() => { TestBed.configureTestingModule({ imports: [RouterTestingModule, GlobalModule, CommonModule], declarations: [ diff --git a/angular/projects/admin-nrpti/src/app/records/warnings/warning-lng-detail/warning-lng-detail.component.spec.ts b/angular/projects/admin-nrpti/src/app/records/warnings/warning-lng-detail/warning-lng-detail.component.spec.ts index 507fe0988..4d553cba9 100644 --- a/angular/projects/admin-nrpti/src/app/records/warnings/warning-lng-detail/warning-lng-detail.component.spec.ts +++ b/angular/projects/admin-nrpti/src/app/records/warnings/warning-lng-detail/warning-lng-detail.component.spec.ts @@ -1,4 +1,4 @@ -import { async, TestBed } from '@angular/core/testing'; +import { TestBed } from '@angular/core/testing'; import { WarningLNGDetailComponent } from './warning-lng-detail.component'; import { TestBedHelper, ActivatedRouteStub } from '../../../../../../common/src/app/spec/spec-utils'; import { RouterTestingModule } from '@angular/router/testing'; @@ -16,7 +16,7 @@ describe('WarningLNGDetailComponent', () => { const mockFactoryService = jasmine.createSpyObj('FactoryService', ['userInLngRole']); mockFactoryService.userInLngRole.and.returnValue(true); - beforeEach(async(() => { + beforeEach((() => { TestBed.configureTestingModule({ imports: [RouterTestingModule, GlobalModule], declarations: [WarningLNGDetailComponent], diff --git a/angular/projects/admin-nrpti/src/app/records/warnings/warning-nrced-detail/warning-nrced-detail.component.spec.ts b/angular/projects/admin-nrpti/src/app/records/warnings/warning-nrced-detail/warning-nrced-detail.component.spec.ts index 435b0d7c1..61c38723a 100644 --- a/angular/projects/admin-nrpti/src/app/records/warnings/warning-nrced-detail/warning-nrced-detail.component.spec.ts +++ b/angular/projects/admin-nrpti/src/app/records/warnings/warning-nrced-detail/warning-nrced-detail.component.spec.ts @@ -1,4 +1,4 @@ -import { async, TestBed } from '@angular/core/testing'; +import { TestBed } from '@angular/core/testing'; import { WarningNRCEDDetailComponent } from './warning-nrced-detail.component'; import { TestBedHelper, ActivatedRouteStub } from '../../../../../../common/src/app/spec/spec-utils'; import { RouterTestingModule } from '@angular/router/testing'; @@ -16,7 +16,7 @@ describe('WarningNRCEDDetailComponent', () => { const mockFactoryService = jasmine.createSpyObj('FactoryService', ['userInNrcedRole']); mockFactoryService.userInNrcedRole.and.returnValue(true); - beforeEach(async(() => { + beforeEach((() => { TestBed.configureTestingModule({ imports: [RouterTestingModule, GlobalModule], declarations: [WarningNRCEDDetailComponent], diff --git a/angular/projects/admin-nrpti/src/app/services/factory.service.spec.ts b/angular/projects/admin-nrpti/src/app/services/factory.service.spec.ts index f36e25e88..76da27eb2 100644 --- a/angular/projects/admin-nrpti/src/app/services/factory.service.spec.ts +++ b/angular/projects/admin-nrpti/src/app/services/factory.service.spec.ts @@ -1,10 +1,10 @@ -import { async, TestBed } from '@angular/core/testing'; +import { TestBed } from '@angular/core/testing'; import { HttpClientTestingModule } from '@angular/common/http/testing'; import { FactoryService } from './factory.service'; describe('FactoryService', () => { - beforeEach(async(() => { + beforeEach((() => { TestBed.configureTestingModule({ imports: [HttpClientTestingModule] }).compileComponents(); diff --git a/angular/projects/admin-nrpti/src/app/sidebar/sidebar.component.spec.ts b/angular/projects/admin-nrpti/src/app/sidebar/sidebar.component.spec.ts index 5f22cd952..b56dc7e10 100644 --- a/angular/projects/admin-nrpti/src/app/sidebar/sidebar.component.spec.ts +++ b/angular/projects/admin-nrpti/src/app/sidebar/sidebar.component.spec.ts @@ -1,4 +1,4 @@ -import { async, TestBed } from '@angular/core/testing'; +import { TestBed } from '@angular/core/testing'; import { Router, RouterEvent } from '@angular/router'; import { RouterTestingModule } from '@angular/router/testing'; import { ReplaySubject, of } from 'rxjs'; @@ -23,7 +23,7 @@ describe('SidebarComponent', () => { } }; - beforeEach(async(() => { + beforeEach((() => { TestBed.configureTestingModule({ imports: [RouterTestingModule], declarations: [SidebarComponent], diff --git a/angular/projects/common/src/app/common.module.ts b/angular/projects/common/src/app/common.module.ts index 71c6078f3..ccc6f41ef 100644 --- a/angular/projects/common/src/app/common.module.ts +++ b/angular/projects/common/src/app/common.module.ts @@ -23,7 +23,9 @@ import { PenaltyDetailComponent as PenaltyDetailAdminComponent } from './penalty import { PenaltyDetailComponent as PenaltyDetailPublicComponent } from './penalty/penalty-detail-public/penalty-detail.component'; import { LinkAddEditComponent } from './link-add-edit/link-add-edit.component'; import { SearchFilterTemplateComponent } from './search-filter-template/search-filter-template.component'; +import { RecordAssociationEditComponent } from './record-association/record-association-edit.component'; import { CallbackPipe } from './autocomplete-multi-select/callback.pipe'; +import { StoreService } from 'nrpti-angular-components'; // services @@ -42,6 +44,7 @@ import { CallbackPipe } from './autocomplete-multi-select/callback.pipe'; PenaltyDetailPublicComponent, LinkAddEditComponent, SearchFilterTemplateComponent, + RecordAssociationEditComponent, CallbackPipe ], imports: [ @@ -60,7 +63,7 @@ import { CallbackPipe } from './autocomplete-multi-select/callback.pipe'; DragDropModule, MatTooltipModule ], - providers: [MatChipList], + providers: [MatChipList, StoreService], exports: [ FileUploadComponent, DocumentLinkStagingComponent, @@ -74,7 +77,8 @@ import { CallbackPipe } from './autocomplete-multi-select/callback.pipe'; PenaltyDetailAdminComponent, PenaltyDetailPublicComponent, LinkAddEditComponent, - SearchFilterTemplateComponent + SearchFilterTemplateComponent, + RecordAssociationEditComponent ] }) export class CommonModule {} diff --git a/angular/projects/common/src/app/document-edit/document-edit.component.spec.ts b/angular/projects/common/src/app/document-edit/document-edit.component.spec.ts index 63456828e..8cb943f2e 100644 --- a/angular/projects/common/src/app/document-edit/document-edit.component.spec.ts +++ b/angular/projects/common/src/app/document-edit/document-edit.component.spec.ts @@ -1,4 +1,4 @@ -import { async, ComponentFixture, TestBed } from '@angular/core/testing'; +import { ComponentFixture, TestBed } from '@angular/core/testing'; import { DocumentEditComponent } from './document-edit.component'; import { NgbModule } from '@ng-bootstrap/ng-bootstrap'; import { FileUploadComponent } from '../file-upload/file-upload.component'; @@ -8,7 +8,7 @@ describe('DocumentEditComponent', () => { let component: DocumentEditComponent; let fixture: ComponentFixture; - beforeEach(async(() => { + beforeEach((() => { TestBed.configureTestingModule({ declarations: [DocumentEditComponent, FileUploadComponent], imports: [FormsModule, NgbModule] diff --git a/angular/projects/common/src/app/document-link-staging/document-link-staging.component.spec.ts b/angular/projects/common/src/app/document-link-staging/document-link-staging.component.spec.ts index 3505abc53..4a9e0125e 100644 --- a/angular/projects/common/src/app/document-link-staging/document-link-staging.component.spec.ts +++ b/angular/projects/common/src/app/document-link-staging/document-link-staging.component.spec.ts @@ -1,4 +1,4 @@ -import { async, ComponentFixture, TestBed } from '@angular/core/testing'; +import { ComponentFixture, TestBed } from '@angular/core/testing'; import { DocumentLinkStagingComponent } from './document-link-staging.component'; import { NgbModule } from '@ng-bootstrap/ng-bootstrap'; import { FileUploadComponent } from '../file-upload/file-upload.component'; @@ -8,7 +8,7 @@ describe('DocumentLinkStagingComponent', () => { let component: DocumentLinkStagingComponent; let fixture: ComponentFixture; - beforeEach(async(() => { + beforeEach((() => { TestBed.configureTestingModule({ declarations: [DocumentLinkStagingComponent, FileUploadComponent], imports: [FormsModule, NgbModule] diff --git a/angular/projects/common/src/app/document-read-only/document-read-only.component.spec.ts b/angular/projects/common/src/app/document-read-only/document-read-only.component.spec.ts index 8453c5c1c..946aeb6b2 100644 --- a/angular/projects/common/src/app/document-read-only/document-read-only.component.spec.ts +++ b/angular/projects/common/src/app/document-read-only/document-read-only.component.spec.ts @@ -1,4 +1,4 @@ -import { async, ComponentFixture, TestBed } from '@angular/core/testing'; +import { ComponentFixture, TestBed } from '@angular/core/testing'; import { DocumentReadOnlyComponent } from './document-read-only.component'; import { NgbModule } from '@ng-bootstrap/ng-bootstrap'; import { FormsModule } from '@angular/forms'; @@ -7,7 +7,7 @@ describe('DocumentEditComponent', () => { let component: DocumentReadOnlyComponent; let fixture: ComponentFixture; - beforeEach(async(() => { + beforeEach((() => { TestBed.configureTestingModule({ declarations: [DocumentReadOnlyComponent], imports: [FormsModule, NgbModule] diff --git a/angular/projects/common/src/app/entity/entity-add-edit/entity-add-edit.component.spec.ts b/angular/projects/common/src/app/entity/entity-add-edit/entity-add-edit.component.spec.ts index b309f55a2..97c5b581d 100644 --- a/angular/projects/common/src/app/entity/entity-add-edit/entity-add-edit.component.spec.ts +++ b/angular/projects/common/src/app/entity/entity-add-edit/entity-add-edit.component.spec.ts @@ -1,4 +1,4 @@ -import { async, TestBed } from '@angular/core/testing'; +import { TestBed } from '@angular/core/testing'; import { ReactiveFormsModule, FormGroup, FormControl } from '@angular/forms'; import { MatSlideToggleModule } from '@angular/material'; import { TestBedHelper } from '../../spec/spec-utils'; @@ -8,7 +8,7 @@ import { NgbModule } from '@ng-bootstrap/ng-bootstrap'; describe('EntityAddEditComponent', () => { const testBedHelper = new TestBedHelper(EntityAddEditComponent); - beforeEach(async(() => { + beforeEach((() => { TestBed.configureTestingModule({ imports: [ReactiveFormsModule, MatSlideToggleModule, NgbModule.forRoot()], declarations: [EntityAddEditComponent] diff --git a/angular/projects/common/src/app/entity/entity-detail/entity-detail.component.spec.ts b/angular/projects/common/src/app/entity/entity-detail/entity-detail.component.spec.ts index 63dc59a30..01ca59cb3 100644 --- a/angular/projects/common/src/app/entity/entity-detail/entity-detail.component.spec.ts +++ b/angular/projects/common/src/app/entity/entity-detail/entity-detail.component.spec.ts @@ -1,4 +1,4 @@ -import { async, TestBed } from '@angular/core/testing'; +import { TestBed } from '@angular/core/testing'; import { TestBedHelper } from '../../spec/spec-utils'; import { EntityDetailComponent } from './entity-detail.component'; import { MatSlideToggleModule } from '@angular/material'; @@ -7,7 +7,7 @@ import { NgbModule } from '@ng-bootstrap/ng-bootstrap'; describe('EntityDetailComponent', () => { const testBedHelper = new TestBedHelper(EntityDetailComponent); - beforeEach(async(() => { + beforeEach((() => { TestBed.configureTestingModule({ imports: [MatSlideToggleModule, NgbModule.forRoot()], declarations: [EntityDetailComponent] diff --git a/angular/projects/common/src/app/file-upload/file-upload.component.spec.ts b/angular/projects/common/src/app/file-upload/file-upload.component.spec.ts index ad6202edd..9accf4776 100644 --- a/angular/projects/common/src/app/file-upload/file-upload.component.spec.ts +++ b/angular/projects/common/src/app/file-upload/file-upload.component.spec.ts @@ -1,11 +1,11 @@ -import { async, ComponentFixture, TestBed } from '@angular/core/testing'; +import { ComponentFixture, TestBed } from '@angular/core/testing'; import { FileUploadComponent } from './file-upload.component'; describe('FileUploadComponent', () => { let component: FileUploadComponent; let fixture: ComponentFixture; - beforeEach(async(() => { + beforeEach((() => { TestBed.configureTestingModule({ declarations: [FileUploadComponent] }).compileComponents(); diff --git a/angular/projects/common/src/app/legislation-add-edit/legislation-add-edit.component.spec.ts b/angular/projects/common/src/app/legislation-add-edit/legislation-add-edit.component.spec.ts index a589046f1..4f4a26058 100644 --- a/angular/projects/common/src/app/legislation-add-edit/legislation-add-edit.component.spec.ts +++ b/angular/projects/common/src/app/legislation-add-edit/legislation-add-edit.component.spec.ts @@ -1,4 +1,4 @@ -import { async, TestBed } from '@angular/core/testing'; +import { TestBed } from '@angular/core/testing'; import { ReactiveFormsModule, FormGroup, FormControl } from '@angular/forms'; import { MatAutocompleteModule } from '@angular/material'; import { TestBedHelper } from '../spec/spec-utils'; @@ -8,7 +8,7 @@ import { Utils } from 'nrpti-angular-components'; describe('LegislationAddEditComponent', () => { const testBedHelper = new TestBedHelper(LegislationAddEditComponent); - beforeEach(async(() => { + beforeEach((() => { TestBed.configureTestingModule({ declarations: [LegislationAddEditComponent], imports: [ReactiveFormsModule, MatAutocompleteModule], diff --git a/angular/projects/common/src/app/link-add-edit/link-add-edit.component.spec.ts b/angular/projects/common/src/app/link-add-edit/link-add-edit.component.spec.ts index d1daa9515..4050b68b3 100644 --- a/angular/projects/common/src/app/link-add-edit/link-add-edit.component.spec.ts +++ b/angular/projects/common/src/app/link-add-edit/link-add-edit.component.spec.ts @@ -1,4 +1,4 @@ -import { async, TestBed } from '@angular/core/testing'; +import { TestBed } from '@angular/core/testing'; import { LinkAddEditComponent } from './link-add-edit.component'; import { NgbModule } from '@ng-bootstrap/ng-bootstrap'; import { FormsModule, FormGroup, FormArray, FormControl, ReactiveFormsModule } from '@angular/forms'; @@ -7,7 +7,7 @@ import { TestBedHelper } from '../../../../common/src/app/spec/spec-utils'; describe('LinkAddEditComponent', () => { const testBedHelper = new TestBedHelper(LinkAddEditComponent); - beforeEach(async(() => { + beforeEach((() => { TestBed.configureTestingModule({ declarations: [LinkAddEditComponent], imports: [FormsModule, ReactiveFormsModule, NgbModule.forRoot()] diff --git a/angular/projects/common/src/app/penalty/penalty-add-edit/penalty-add-edit.component.spec.ts b/angular/projects/common/src/app/penalty/penalty-add-edit/penalty-add-edit.component.spec.ts index b86484f11..38597aee1 100644 --- a/angular/projects/common/src/app/penalty/penalty-add-edit/penalty-add-edit.component.spec.ts +++ b/angular/projects/common/src/app/penalty/penalty-add-edit/penalty-add-edit.component.spec.ts @@ -1,4 +1,4 @@ -import { async, TestBed } from '@angular/core/testing'; +import { TestBed } from '@angular/core/testing'; import { ReactiveFormsModule, FormGroup, FormControl, FormArray } from '@angular/forms'; import { MatAutocompleteModule } from '@angular/material'; import { TestBedHelper } from '../../spec/spec-utils'; @@ -8,7 +8,7 @@ import { GlobalModule, Utils } from 'nrpti-angular-components'; describe('PenaltyAddEditComponent', () => { const testBedHelper = new TestBedHelper(PenaltyAddEditComponent); - beforeEach(async(() => { + beforeEach((() => { TestBed.configureTestingModule({ imports: [ReactiveFormsModule, MatAutocompleteModule, GlobalModule], providers: [Utils], diff --git a/angular/projects/common/src/app/penalty/penalty-detail-admin/penalty-detail.component.spec.ts b/angular/projects/common/src/app/penalty/penalty-detail-admin/penalty-detail.component.spec.ts index 13442af6c..689d26e69 100644 --- a/angular/projects/common/src/app/penalty/penalty-detail-admin/penalty-detail.component.spec.ts +++ b/angular/projects/common/src/app/penalty/penalty-detail-admin/penalty-detail.component.spec.ts @@ -1,4 +1,4 @@ -import { async, TestBed } from '@angular/core/testing'; +import { TestBed } from '@angular/core/testing'; import { ReactiveFormsModule } from '@angular/forms'; import { MatAutocompleteModule } from '@angular/material'; import { TestBedHelper } from '../../spec/spec-utils'; @@ -8,7 +8,7 @@ import { Penalty } from '../../models/master/common-models/penalty'; describe('PenaltyDetailComponent', () => { const testBedHelper = new TestBedHelper(PenaltyDetailComponent); - beforeEach(async(() => { + beforeEach((() => { TestBed.configureTestingModule({ declarations: [PenaltyDetailComponent], imports: [ReactiveFormsModule, MatAutocompleteModule] diff --git a/angular/projects/common/src/app/penalty/penalty-detail-public/penalty-detail.component.spec.ts b/angular/projects/common/src/app/penalty/penalty-detail-public/penalty-detail.component.spec.ts index 0307670f1..f21e7aab2 100644 --- a/angular/projects/common/src/app/penalty/penalty-detail-public/penalty-detail.component.spec.ts +++ b/angular/projects/common/src/app/penalty/penalty-detail-public/penalty-detail.component.spec.ts @@ -1,4 +1,4 @@ -import { async, ComponentFixture, TestBed } from '@angular/core/testing'; +import { ComponentFixture, TestBed } from '@angular/core/testing'; import { PenaltyDetailComponent } from './penalty-detail.component'; import { ActivatedRoute, Router } from '@angular/router'; @@ -12,7 +12,7 @@ describe('PenaltyDetailComponent', () => { const activedRouteStub = new ActivatedRouteStub(); const mockRouter = jasmine.createSpyObj('Router', ['navigate']); - beforeEach(async(() => { + beforeEach((() => { TestBed.configureTestingModule({ imports: [GlobalModule], declarations: [PenaltyDetailComponent], diff --git a/angular/projects/common/src/app/record-association/record-association-edit.component.html b/angular/projects/common/src/app/record-association/record-association-edit.component.html new file mode 100644 index 000000000..aed9b86f2 --- /dev/null +++ b/angular/projects/common/src/app/record-association/record-association-edit.component.html @@ -0,0 +1,24 @@ +
+
+
+
+ + +
+
+
+
+ + +
+
+
+
\ No newline at end of file diff --git a/angular/projects/common/src/app/record-association/record-association-edit.component.scss b/angular/projects/common/src/app/record-association/record-association-edit.component.scss new file mode 100644 index 000000000..2581003cd --- /dev/null +++ b/angular/projects/common/src/app/record-association/record-association-edit.component.scss @@ -0,0 +1,54 @@ +@import '../../assets/styles/base/base.scss'; +@import '../../assets/styles/components/drag-drop.scss'; + +$link-label-font-size-sm: 0.875rem; +$link-label-font-size-md: 1rem; + +$link-body-font-weight-sm: 400; +$link-body-font-weight-md: 700; + +$link-delete-font-color: #d8292f; +$link-delete-hover-font-color: #ff4a4a; +$link-info-font-color: #949494; + +form { + input { + font-size: $link-label-font-size-md; + font-weight: $link-body-font-weight-sm; + } + + label { + font-size: $link-label-font-size-sm; + font-weight: $link-body-font-weight-sm; + } +} + +.btn-remove { + i { + color: $link-delete-font-color; + vertical-align: none; + } + + &:hover { + color: $link-delete-hover-font-color; + background-color: transparent; + } +} + +.btn-drag { + i { + color: $link-info-font-color; + vertical-align: none; + } + + &:hover { + color: $link-delete-hover-font-color; + background-color: transparent; + } +} + +.validation-error { + font-size: $validator-font-size; + font-weight: $validator-font-weight; + color: $validator-font-color; +} diff --git a/angular/projects/common/src/app/record-association/record-association-edit.component.spec.ts b/angular/projects/common/src/app/record-association/record-association-edit.component.spec.ts new file mode 100644 index 000000000..1eb8904cd --- /dev/null +++ b/angular/projects/common/src/app/record-association/record-association-edit.component.spec.ts @@ -0,0 +1,34 @@ +import { TestBed } from '@angular/core/testing'; +import { RecordAssociationEditComponent } from './record-association-edit.component'; +import { NgbModule } from '@ng-bootstrap/ng-bootstrap'; +import { FormsModule, ReactiveFormsModule } from '@angular/forms'; +import { TestBedHelper } from '../spec/spec-utils'; +import { StoreService } from 'nrpti-angular-components'; +import { EventEmitter } from '@angular/core'; + +describe('RecordAssociationEditComponent', () => { + const testBedHelper = new TestBedHelper(RecordAssociationEditComponent); + + const mockStoreService = { + getItem: () => { }, + stateChange: new EventEmitter() + }; + + beforeEach((() => { + TestBed.configureTestingModule({ + declarations: [RecordAssociationEditComponent], + imports: [FormsModule, ReactiveFormsModule, NgbModule.forRoot()], + providers: [ + { provide: StoreService, useValue: mockStoreService } + ] + }).compileComponents(); + })); + + it('should create', () => { + const { component, fixture } = testBedHelper.createComponent(false); + + fixture.detectChanges(); + + expect(component).toBeTruthy(); + }); +}); diff --git a/angular/projects/common/src/app/record-association/record-association-edit.component.ts b/angular/projects/common/src/app/record-association/record-association-edit.component.ts new file mode 100644 index 000000000..fbdfe0b66 --- /dev/null +++ b/angular/projects/common/src/app/record-association/record-association-edit.component.ts @@ -0,0 +1,43 @@ +import { Component, Input, OnInit } from '@angular/core'; +import { FormGroup, FormControl } from '@angular/forms'; +import { FactoryService } from '../../../../admin-nrpti/src/app/services/factory.service'; +import { StoreService} from 'nrpti-angular-components'; + +/** + * Handles editing the Record Association form section. + * + * @export + * @class RecordAssociationEditComponent + */ +@Component({ + selector: 'record-association-edit', + templateUrl: './record-association-edit.component.html', + styleUrls: ['./record-association-edit.component.scss'] +}) +export class RecordAssociationEditComponent implements OnInit { + @Input() formGroup: FormGroup; + @Input() mines: any[]; + @Input() epicProjects: any[]; + + constructor( + public factoryService: FactoryService, + private storeService: StoreService + ) { + this.formGroup = new FormGroup({ + _epicProjectId: new FormControl({}), + mineGuid: new FormControl({}) + }); + } + + ngOnInit() { + this.storeService.stateChange.subscribe((state: object) => { + if (state && state.hasOwnProperty('mines')) { + this.mines = state['mines']; + } + + if (state && state.hasOwnProperty('epicProjects')) { + this.mines = state['epicProjects']; + } + }); + } +} diff --git a/angular/projects/common/src/app/search-filter-template/search-filter-template.component.spec.ts b/angular/projects/common/src/app/search-filter-template/search-filter-template.component.spec.ts index b57aefc9b..ff84d7550 100644 --- a/angular/projects/common/src/app/search-filter-template/search-filter-template.component.spec.ts +++ b/angular/projects/common/src/app/search-filter-template/search-filter-template.component.spec.ts @@ -1,4 +1,4 @@ -import { async, TestBed } from '@angular/core/testing'; +import { TestBed } from '@angular/core/testing'; import { ReactiveFormsModule, FormsModule } from '@angular/forms'; import { MatAutocompleteModule, MatTooltipModule, MatSelectModule, MatCheckboxModule, MatSlideToggleModule, MatChipsModule, MatIconModule } from '@angular/material'; import { TestBedHelper } from '../spec/spec-utils'; @@ -11,7 +11,7 @@ import { CallbackPipe } from '../autocomplete-multi-select/callback.pipe'; describe('SearchFilterTemplateComponent', () => { const testBedHelper = new TestBedHelper(SearchFilterTemplateComponent); - beforeEach(async(() => { + beforeEach((() => { TestBed.configureTestingModule({ imports: [ ReactiveFormsModule, diff --git a/angular/projects/global/src/lib/components/buttons/button-spinner/button-spinner.component.spec.ts b/angular/projects/global/src/lib/components/buttons/button-spinner/button-spinner.component.spec.ts index c20915d41..5cc40bd82 100644 --- a/angular/projects/global/src/lib/components/buttons/button-spinner/button-spinner.component.spec.ts +++ b/angular/projects/global/src/lib/components/buttons/button-spinner/button-spinner.component.spec.ts @@ -1,11 +1,11 @@ -import { async, TestBed } from '@angular/core/testing'; +import { TestBed } from '@angular/core/testing'; import { ButtonSpinnerComponent } from './button-spinner.component'; import { TestBedHelper } from '../../../../../../common/src/app/spec/spec-utils'; describe('ButtonSpinnerComponent', () => { const testBedHelper = new TestBedHelper(ButtonSpinnerComponent); - beforeEach(async(() => { + beforeEach((() => { TestBed.configureTestingModule({ declarations: [ButtonSpinnerComponent] }).compileComponents(); diff --git a/angular/projects/global/src/lib/components/page-count-display/page-count-display.component.spec.ts b/angular/projects/global/src/lib/components/page-count-display/page-count-display.component.spec.ts index 1f299d3a1..c86b296dc 100644 --- a/angular/projects/global/src/lib/components/page-count-display/page-count-display.component.spec.ts +++ b/angular/projects/global/src/lib/components/page-count-display/page-count-display.component.spec.ts @@ -1,11 +1,11 @@ -import { async, TestBed } from '@angular/core/testing'; +import { TestBed } from '@angular/core/testing'; import { PageCountDisplayComponent } from './page-count-display.component'; import { TestBedHelper } from '../../../../../common/src/app/spec/spec-utils'; describe('PageCountDisplayComponent', () => { const testBedHelper = new TestBedHelper(PageCountDisplayComponent); - beforeEach(async(() => { + beforeEach((() => { TestBed.configureTestingModule({ declarations: [PageCountDisplayComponent] }).compileComponents(); diff --git a/angular/projects/global/src/lib/components/page-size-picker/page-size-picker.component.spec.ts b/angular/projects/global/src/lib/components/page-size-picker/page-size-picker.component.spec.ts index f3ff7a4fa..bbbb80592 100644 --- a/angular/projects/global/src/lib/components/page-size-picker/page-size-picker.component.spec.ts +++ b/angular/projects/global/src/lib/components/page-size-picker/page-size-picker.component.spec.ts @@ -1,11 +1,11 @@ -import { async, TestBed } from '@angular/core/testing'; +import { TestBed } from '@angular/core/testing'; import { PageSizePickerComponent } from './page-size-picker.component'; import { TestBedHelper } from '../../../../../common/src/app/spec/spec-utils'; describe('PageSizePickerComponent', () => { const testBedHelper = new TestBedHelper(PageSizePickerComponent); - beforeEach(async(() => { + beforeEach((() => { TestBed.configureTestingModule({ declarations: [PageSizePickerComponent] }).compileComponents(); diff --git a/angular/projects/global/src/lib/directives/auto-grow-textarea/auto-grow-textarea.directive.spec.ts b/angular/projects/global/src/lib/directives/auto-grow-textarea/auto-grow-textarea.directive.spec.ts index ed5f3b7e5..f65d9d4c3 100644 --- a/angular/projects/global/src/lib/directives/auto-grow-textarea/auto-grow-textarea.directive.spec.ts +++ b/angular/projects/global/src/lib/directives/auto-grow-textarea/auto-grow-textarea.directive.spec.ts @@ -1,4 +1,4 @@ -import { async, TestBed } from '@angular/core/testing'; +import { TestBed } from '@angular/core/testing'; import { Component } from '@angular/core'; import { AutoGrowTextAreaDirective } from './auto-grow-textarea.directive'; import { TestBedHelper } from '../../../../../common/src/app/spec/spec-utils'; @@ -14,7 +14,7 @@ class TestComponent {} describe('AutoGrowTextAreaDirective', () => { const testBedHelper = new TestBedHelper(TestComponent); - beforeEach(async(() => { + beforeEach((() => { TestBed.configureTestingModule({ providers: [Utils], declarations: [AutoGrowTextAreaDirective, TestComponent] diff --git a/angular/projects/global/src/lib/directives/digit-only/digit-only.directive.spec.ts b/angular/projects/global/src/lib/directives/digit-only/digit-only.directive.spec.ts index e0980af71..580ae0d69 100644 --- a/angular/projects/global/src/lib/directives/digit-only/digit-only.directive.spec.ts +++ b/angular/projects/global/src/lib/directives/digit-only/digit-only.directive.spec.ts @@ -1,4 +1,4 @@ -import { async, TestBed } from '@angular/core/testing'; +import { TestBed } from '@angular/core/testing'; import { Component } from '@angular/core'; import { DigitOnlyDirective } from './digit-only.directive'; import { TestBedHelper } from '../../../../../common/src/app/spec/spec-utils'; @@ -13,7 +13,7 @@ class TestComponent {} describe('DigitOnlyDirective', () => { const testBedHelper = new TestBedHelper(TestComponent); - beforeEach(async(() => { + beforeEach((() => { TestBed.configureTestingModule({ declarations: [DigitOnlyDirective, TestComponent] }).compileComponents(); diff --git a/angular/projects/global/src/lib/services/loading-screen.service.ts b/angular/projects/global/src/lib/services/loading-screen.service.ts index b77dde221..cc641ce2e 100644 --- a/angular/projects/global/src/lib/services/loading-screen.service.ts +++ b/angular/projects/global/src/lib/services/loading-screen.service.ts @@ -1,7 +1,7 @@ -import { Output, EventEmitter } from '@angular/core'; +import { EventEmitter } from '@angular/core'; export class LoadingScreenService { - @Output() stateChange: EventEmitter = new EventEmitter(); + stateChange: EventEmitter = new EventEmitter(); constructor() { } diff --git a/angular/projects/global/src/lib/services/store.service.spec.ts b/angular/projects/global/src/lib/services/store.service.spec.ts index 44f81c801..592e81fe2 100644 --- a/angular/projects/global/src/lib/services/store.service.spec.ts +++ b/angular/projects/global/src/lib/services/store.service.spec.ts @@ -1,9 +1,9 @@ -import { async, TestBed } from '@angular/core/testing'; +import { TestBed } from '@angular/core/testing'; import { StoreService } from './store.service'; describe('StoreService', () => { - beforeEach(async(() => { + beforeEach((() => { TestBed.configureTestingModule({ providers: [StoreService] }); diff --git a/angular/projects/global/src/lib/services/store.service.ts b/angular/projects/global/src/lib/services/store.service.ts index 1e1e943ef..5d5ced1e2 100644 --- a/angular/projects/global/src/lib/services/store.service.ts +++ b/angular/projects/global/src/lib/services/store.service.ts @@ -1,4 +1,4 @@ -import { Output, EventEmitter } from '@angular/core'; +import { EventEmitter } from '@angular/core'; /** * An object containing a single key value pair. @@ -11,7 +11,7 @@ export interface IStateItem { } export class StoreService { - @Output() stateChange: EventEmitter = new EventEmitter(); + public stateChange: EventEmitter = new EventEmitter(); private currentState: object; diff --git a/angular/projects/public-lng/src/app/contact/contact.component.spec.ts b/angular/projects/public-lng/src/app/contact/contact.component.spec.ts index 6ad6a095d..b4f319ae6 100644 --- a/angular/projects/public-lng/src/app/contact/contact.component.spec.ts +++ b/angular/projects/public-lng/src/app/contact/contact.component.spec.ts @@ -1,11 +1,11 @@ -import { async, ComponentFixture, TestBed } from '@angular/core/testing'; +import { ComponentFixture, TestBed } from '@angular/core/testing'; import { ContactComponent } from './contact.component'; describe('ContactComponent', () => { let component: ContactComponent; let fixture: ComponentFixture; - beforeEach(async(() => { + beforeEach((() => { TestBed.configureTestingModule({ declarations: [ContactComponent] }).compileComponents(); diff --git a/angular/projects/public-lng/src/app/faq/faq.component.spec.ts b/angular/projects/public-lng/src/app/faq/faq.component.spec.ts index 803c2361d..8b1a179d5 100644 --- a/angular/projects/public-lng/src/app/faq/faq.component.spec.ts +++ b/angular/projects/public-lng/src/app/faq/faq.component.spec.ts @@ -1,4 +1,4 @@ -import { async, ComponentFixture, TestBed } from '@angular/core/testing'; +import { ComponentFixture, TestBed } from '@angular/core/testing'; import { FaqComponent } from './faq.component'; @@ -6,7 +6,7 @@ describe('FaqComponent', () => { let component: FaqComponent; let fixture: ComponentFixture; - beforeEach(async(() => { + beforeEach((() => { TestBed.configureTestingModule({ declarations: [FaqComponent] }).compileComponents(); diff --git a/angular/projects/public-nrpti/src/app/app.component.spec.ts b/angular/projects/public-nrpti/src/app/app.component.spec.ts index 82ecb54d4..d2c5a933c 100644 --- a/angular/projects/public-nrpti/src/app/app.component.spec.ts +++ b/angular/projects/public-nrpti/src/app/app.component.spec.ts @@ -15,7 +15,7 @@ import { import { of } from 'rxjs'; describe('AppComponent', () => { - beforeEach(async(() => { + beforeEach((() => { const mockStoreService = { change: of(), toggleSideNave: () => { } diff --git a/angular/projects/public-nrpti/src/app/confirm/confirm.component.spec.ts b/angular/projects/public-nrpti/src/app/confirm/confirm.component.spec.ts index cc9219ec7..9f81361ea 100644 --- a/angular/projects/public-nrpti/src/app/confirm/confirm.component.spec.ts +++ b/angular/projects/public-nrpti/src/app/confirm/confirm.component.spec.ts @@ -1,4 +1,4 @@ -import { async, ComponentFixture, TestBed } from '@angular/core/testing'; +import { ComponentFixture, TestBed } from '@angular/core/testing'; import { ConfirmComponent } from './confirm.component'; import { DialogService } from 'ng2-bootstrap-modal'; @@ -7,7 +7,7 @@ describe('ConfirmComponent', () => { let component: ConfirmComponent; let fixture: ComponentFixture; - beforeEach(async(() => { + beforeEach((() => { TestBed.configureTestingModule({ declarations: [ConfirmComponent], providers: [DialogService] diff --git a/angular/projects/public-nrpti/src/app/footer/footer.component.spec.ts b/angular/projects/public-nrpti/src/app/footer/footer.component.spec.ts index 6cf81a828..26cee1db8 100644 --- a/angular/projects/public-nrpti/src/app/footer/footer.component.spec.ts +++ b/angular/projects/public-nrpti/src/app/footer/footer.component.spec.ts @@ -1,4 +1,4 @@ -import { async, ComponentFixture, TestBed } from '@angular/core/testing'; +import { ComponentFixture, TestBed } from '@angular/core/testing'; import { FooterComponent } from './footer.component'; @@ -6,7 +6,7 @@ describe('FooterComponent', () => { let component: FooterComponent; let fixture: ComponentFixture; - beforeEach(async(() => { + beforeEach((() => { TestBed.configureTestingModule({ declarations: [FooterComponent] }).compileComponents(); diff --git a/angular/projects/public-nrpti/src/app/header/header.component.spec.ts b/angular/projects/public-nrpti/src/app/header/header.component.spec.ts index 1519c18ec..73bbf9a18 100644 --- a/angular/projects/public-nrpti/src/app/header/header.component.spec.ts +++ b/angular/projects/public-nrpti/src/app/header/header.component.spec.ts @@ -1,4 +1,4 @@ -import { async, TestBed } from '@angular/core/testing'; +import { TestBed } from '@angular/core/testing'; import { HeaderComponent } from './header.component'; import { BrowserAnimationsModule } from '@angular/platform-browser/animations'; @@ -16,7 +16,7 @@ describe('HeaderComponent', () => { const mockRouter = jasmine.createSpyObj('Router', ['navigate', 'events']); - beforeEach(async(() => { + beforeEach((() => { TestBed.configureTestingModule({ imports: [BrowserAnimationsModule], declarations: [HeaderComponent], diff --git a/angular/projects/public-nrpti/src/app/home/home.component.spec.ts b/angular/projects/public-nrpti/src/app/home/home.component.spec.ts index 902a83e5b..ef1688ef6 100644 --- a/angular/projects/public-nrpti/src/app/home/home.component.spec.ts +++ b/angular/projects/public-nrpti/src/app/home/home.component.spec.ts @@ -1,4 +1,4 @@ -import { async, ComponentFixture, TestBed } from '@angular/core/testing'; +import { ComponentFixture, TestBed } from '@angular/core/testing'; import { HomeComponent } from './home.component'; import { RouterTestingModule } from '@angular/router/testing'; @@ -7,7 +7,7 @@ describe('HomeComponent', () => { let component: HomeComponent; let fixture: ComponentFixture; - beforeEach(async(() => { + beforeEach((() => { TestBed.configureTestingModule({ declarations: [HomeComponent], imports: [RouterTestingModule] diff --git a/angular/projects/public-nrpti/src/app/records/administrative-penalties/administrative-penalty-detail/administrative-penalty-detail.component.spec.ts b/angular/projects/public-nrpti/src/app/records/administrative-penalties/administrative-penalty-detail/administrative-penalty-detail.component.spec.ts index 8083eb194..e34140275 100644 --- a/angular/projects/public-nrpti/src/app/records/administrative-penalties/administrative-penalty-detail/administrative-penalty-detail.component.spec.ts +++ b/angular/projects/public-nrpti/src/app/records/administrative-penalties/administrative-penalty-detail/administrative-penalty-detail.component.spec.ts @@ -1,4 +1,4 @@ -import { async, ComponentFixture, TestBed } from '@angular/core/testing'; +import { ComponentFixture, TestBed } from '@angular/core/testing'; import { AdministrativePenaltyDetailComponent } from './administrative-penalty-detail.component'; import { ActivatedRoute, Router } from '@angular/router'; @@ -13,7 +13,7 @@ describe('AdministrativePenaltyDetailComponent', () => { const activedRouteStub = new ActivatedRouteStub(); const mockRouter = jasmine.createSpyObj('Router', ['navigate']); - beforeEach(async(() => { + beforeEach((() => { TestBed.configureTestingModule({ imports: [GlobalModule, CommonModule], declarations: [AdministrativePenaltyDetailComponent], diff --git a/angular/projects/public-nrpti/src/app/records/administrative-sanctions/administrative-sanction-detail/administrative-sanction-detail.component.spec.ts b/angular/projects/public-nrpti/src/app/records/administrative-sanctions/administrative-sanction-detail/administrative-sanction-detail.component.spec.ts index d155d1dd3..451e49f60 100644 --- a/angular/projects/public-nrpti/src/app/records/administrative-sanctions/administrative-sanction-detail/administrative-sanction-detail.component.spec.ts +++ b/angular/projects/public-nrpti/src/app/records/administrative-sanctions/administrative-sanction-detail/administrative-sanction-detail.component.spec.ts @@ -1,4 +1,4 @@ -import { async, ComponentFixture, TestBed } from '@angular/core/testing'; +import { ComponentFixture, TestBed } from '@angular/core/testing'; import { AdministrativeSanctionDetailComponent } from './administrative-sanction-detail.component'; import { ActivatedRoute, Router } from '@angular/router'; @@ -13,7 +13,7 @@ describe('AdministrativeSanctionDetailComponent', () => { const activedRouteStub = new ActivatedRouteStub(); const mockRouter = jasmine.createSpyObj('Router', ['navigate']); - beforeEach(async(() => { + beforeEach((() => { TestBed.configureTestingModule({ imports: [GlobalModule, CommonModule], declarations: [AdministrativeSanctionDetailComponent], diff --git a/angular/projects/public-nrpti/src/app/records/court-convictions/court-conviction-detail/court-conviction-detail.component.spec.ts b/angular/projects/public-nrpti/src/app/records/court-convictions/court-conviction-detail/court-conviction-detail.component.spec.ts index 275ff37f4..4b29b9e20 100644 --- a/angular/projects/public-nrpti/src/app/records/court-convictions/court-conviction-detail/court-conviction-detail.component.spec.ts +++ b/angular/projects/public-nrpti/src/app/records/court-convictions/court-conviction-detail/court-conviction-detail.component.spec.ts @@ -1,4 +1,4 @@ -import { async, ComponentFixture, TestBed } from '@angular/core/testing'; +import { ComponentFixture, TestBed } from '@angular/core/testing'; import { CourtConvictionDetailComponent } from './court-conviction-detail.component'; import { ActivatedRoute, Router } from '@angular/router'; @@ -13,7 +13,7 @@ describe('CourtConvictionDetailComponent', () => { const activedRouteStub = new ActivatedRouteStub(); const mockRouter = jasmine.createSpyObj('Router', ['navigate']); - beforeEach(async(() => { + beforeEach((() => { TestBed.configureTestingModule({ imports: [GlobalModule, CommonModule], declarations: [CourtConvictionDetailComponent], diff --git a/angular/projects/public-nrpti/src/app/records/inspections/inspection-detail/inspection-detail.component.spec.ts b/angular/projects/public-nrpti/src/app/records/inspections/inspection-detail/inspection-detail.component.spec.ts index fbf4d1dac..c981771ac 100644 --- a/angular/projects/public-nrpti/src/app/records/inspections/inspection-detail/inspection-detail.component.spec.ts +++ b/angular/projects/public-nrpti/src/app/records/inspections/inspection-detail/inspection-detail.component.spec.ts @@ -1,4 +1,4 @@ -import { async, ComponentFixture, TestBed } from '@angular/core/testing'; +import { ComponentFixture, TestBed } from '@angular/core/testing'; import { InspectionDetailComponent } from './inspection-detail.component'; import { ActivatedRoute, Router } from '@angular/router'; @@ -12,7 +12,7 @@ describe('InspectionDetailComponent', () => { const activedRouteStub = new ActivatedRouteStub(); const mockRouter = jasmine.createSpyObj('Router', ['navigate']); - beforeEach(async(() => { + beforeEach((() => { TestBed.configureTestingModule({ imports: [GlobalModule], declarations: [InspectionDetailComponent], diff --git a/angular/projects/public-nrpti/src/app/records/orders/order-detail/order-detail.component.spec.ts b/angular/projects/public-nrpti/src/app/records/orders/order-detail/order-detail.component.spec.ts index 706e6f1e2..7888dcbc5 100644 --- a/angular/projects/public-nrpti/src/app/records/orders/order-detail/order-detail.component.spec.ts +++ b/angular/projects/public-nrpti/src/app/records/orders/order-detail/order-detail.component.spec.ts @@ -1,4 +1,4 @@ -import { async, ComponentFixture, TestBed } from '@angular/core/testing'; +import { ComponentFixture, TestBed } from '@angular/core/testing'; import { OrderDetailComponent } from './order-detail.component'; import { ActivatedRoute, Router } from '@angular/router'; @@ -12,7 +12,7 @@ describe('OrderDetailComponent', () => { const activedRouteStub = new ActivatedRouteStub(); const mockRouter = jasmine.createSpyObj('Router', ['navigate']); - beforeEach(async(() => { + beforeEach((() => { TestBed.configureTestingModule({ imports: [GlobalModule], declarations: [OrderDetailComponent], diff --git a/angular/projects/public-nrpti/src/app/records/records-list/records-list.component.spec.ts b/angular/projects/public-nrpti/src/app/records/records-list/records-list.component.spec.ts index 206aa5068..0cc9aa29b 100644 --- a/angular/projects/public-nrpti/src/app/records/records-list/records-list.component.spec.ts +++ b/angular/projects/public-nrpti/src/app/records/records-list/records-list.component.spec.ts @@ -1,4 +1,4 @@ -import { async, TestBed } from '@angular/core/testing'; +import { TestBed } from '@angular/core/testing'; import { Router, ActivatedRoute } from '@angular/router'; import { RouterTestingModule } from '@angular/router/testing'; import { FormsModule, ReactiveFormsModule } from '@angular/forms'; @@ -27,7 +27,7 @@ describe('RecordsListComponent', () => { setLoadingState: () => { } }; - beforeEach(async(() => { + beforeEach((() => { TestBed.configureTestingModule({ imports: [ RouterTestingModule, diff --git a/angular/projects/public-nrpti/src/app/records/records-list/search-filters/search-filters.component.spec.ts b/angular/projects/public-nrpti/src/app/records/records-list/search-filters/search-filters.component.spec.ts index 8c575b620..22de1f0c3 100644 --- a/angular/projects/public-nrpti/src/app/records/records-list/search-filters/search-filters.component.spec.ts +++ b/angular/projects/public-nrpti/src/app/records/records-list/search-filters/search-filters.component.spec.ts @@ -1,4 +1,4 @@ -import { async, TestBed } from '@angular/core/testing'; +import { TestBed } from '@angular/core/testing'; import { RouterTestingModule } from '@angular/router/testing'; import { Router, ActivatedRoute } from '@angular/router'; import { FormsModule, ReactiveFormsModule, FormGroup, FormControl } from '@angular/forms'; @@ -17,7 +17,7 @@ describe('SearchFiltersComponent', () => { const mockRouter = jasmine.createSpyObj('Router', ['navigate']); const mockActivatedRoute = new ActivatedRouteStub(); - beforeEach(async(() => { + beforeEach((() => { TestBed.configureTestingModule({ imports: [ RouterTestingModule, diff --git a/angular/projects/public-nrpti/src/app/records/restorative-justices/restorative-justice-detail/restorative-justice-detail.component.spec.ts b/angular/projects/public-nrpti/src/app/records/restorative-justices/restorative-justice-detail/restorative-justice-detail.component.spec.ts index a3b28e97c..3b125408b 100644 --- a/angular/projects/public-nrpti/src/app/records/restorative-justices/restorative-justice-detail/restorative-justice-detail.component.spec.ts +++ b/angular/projects/public-nrpti/src/app/records/restorative-justices/restorative-justice-detail/restorative-justice-detail.component.spec.ts @@ -1,4 +1,4 @@ -import { async, ComponentFixture, TestBed } from '@angular/core/testing'; +import { ComponentFixture, TestBed } from '@angular/core/testing'; import { RestorativeJusticeDetailComponent } from './restorative-justice-detail.component'; import { ActivatedRoute, Router } from '@angular/router'; @@ -13,7 +13,7 @@ describe('RestorativeJusticeDetailComponent', () => { const activedRouteStub = new ActivatedRouteStub(); const mockRouter = jasmine.createSpyObj('Router', ['navigate']); - beforeEach(async(() => { + beforeEach((() => { TestBed.configureTestingModule({ imports: [GlobalModule, CommonModule], declarations: [RestorativeJusticeDetailComponent], diff --git a/angular/projects/public-nrpti/src/app/records/tickets/ticket-detail/ticket-detail.component.spec.ts b/angular/projects/public-nrpti/src/app/records/tickets/ticket-detail/ticket-detail.component.spec.ts index 801f7a40b..b7036a455 100644 --- a/angular/projects/public-nrpti/src/app/records/tickets/ticket-detail/ticket-detail.component.spec.ts +++ b/angular/projects/public-nrpti/src/app/records/tickets/ticket-detail/ticket-detail.component.spec.ts @@ -1,4 +1,4 @@ -import { async, ComponentFixture, TestBed } from '@angular/core/testing'; +import { ComponentFixture, TestBed } from '@angular/core/testing'; import { TicketDetailComponent } from './ticket-detail.component'; import { ActivatedRoute, Router } from '@angular/router'; @@ -13,7 +13,7 @@ describe('TicketDetailComponent', () => { const activedRouteStub = new ActivatedRouteStub(); const mockRouter = jasmine.createSpyObj('Router', ['navigate']); - beforeEach(async(() => { + beforeEach((() => { TestBed.configureTestingModule({ imports: [GlobalModule, CommonModule], declarations: [TicketDetailComponent], diff --git a/angular/projects/public-nrpti/src/app/records/warnings/warning-detail/warning-detail.component.spec.ts b/angular/projects/public-nrpti/src/app/records/warnings/warning-detail/warning-detail.component.spec.ts index c85642ce0..d638b40a3 100644 --- a/angular/projects/public-nrpti/src/app/records/warnings/warning-detail/warning-detail.component.spec.ts +++ b/angular/projects/public-nrpti/src/app/records/warnings/warning-detail/warning-detail.component.spec.ts @@ -1,4 +1,4 @@ -import { async, ComponentFixture, TestBed } from '@angular/core/testing'; +import { ComponentFixture, TestBed } from '@angular/core/testing'; import { WarningDetailComponent } from './warning-detail.component'; import { ActivatedRoute, Router } from '@angular/router'; @@ -12,7 +12,7 @@ describe('WarningDetailComponent', () => { const activedRouteStub = new ActivatedRouteStub(); const mockRouter = jasmine.createSpyObj('Router', ['navigate']); - beforeEach(async(() => { + beforeEach((() => { TestBed.configureTestingModule({ imports: [GlobalModule], declarations: [WarningDetailComponent], diff --git a/angular/projects/public-nrpti/src/app/services/factory.service.spec.ts b/angular/projects/public-nrpti/src/app/services/factory.service.spec.ts index f36e25e88..76da27eb2 100644 --- a/angular/projects/public-nrpti/src/app/services/factory.service.spec.ts +++ b/angular/projects/public-nrpti/src/app/services/factory.service.spec.ts @@ -1,10 +1,10 @@ -import { async, TestBed } from '@angular/core/testing'; +import { TestBed } from '@angular/core/testing'; import { HttpClientTestingModule } from '@angular/common/http/testing'; import { FactoryService } from './factory.service'; describe('FactoryService', () => { - beforeEach(async(() => { + beforeEach((() => { TestBed.configureTestingModule({ imports: [HttpClientTestingModule] }).compileComponents(); diff --git a/api/src/integrations/epic/datasource.js b/api/src/integrations/epic/datasource.js index 1167b88fa..79ca87f1e 100644 --- a/api/src/integrations/epic/datasource.js +++ b/api/src/integrations/epic/datasource.js @@ -1,6 +1,7 @@ 'use strict'; const QS = require('qs'); +const mongoose = require('mongoose'); const integrationUtils = require('../integration-utils'); const defaultLog = require('../../utils/logger')('epic-datasource'); const EPIC_RECORD_TYPE = require('./epic-record-type-enum'); @@ -341,9 +342,26 @@ class DataSource { const response = await integrationUtils.getRecords(url); if (!response || !response[0]) { - throw Error('getRecordProject - failed to fetch Project.'); + // This isn't always a problem, sometimes the projects will not have any documents that satisfy the criteria. + throw Error('getRecordProject - failed to fetch Project:' + url.href); } + // Save/update this id's name in our DB + const EPICProjectModel = mongoose.model('EPICProject'); + await EPICProjectModel.findOneAndUpdate( + { _id: mongoose.Types.ObjectId(response[0]._id) }, + { + _id: mongoose.Types.ObjectId(response[0]._id), + _schemaName: "EPICProject", + name: response[0].name, + read: ['sysadmin', 'public'], + write: ['sysadmin'] + }, + { + upsert: true + } + ); + return response[0]; } } diff --git a/api/src/models/epicProject.js b/api/src/models/epicProject.js new file mode 100644 index 000000000..6864164d0 --- /dev/null +++ b/api/src/models/epicProject.js @@ -0,0 +1,14 @@ +'use strict'; + +module.exports = require('../utils/model-schema-generator')( + 'EPICProject', + { + _schemaName: { type: String, default: 'EPICProject', index: true }, + _epicProjectId: { type: 'ObjectId', default: null, index: true }, + name: { type: String, trim: true, default: 'sysadmin' }, + + read: [{ type: String, trim: true, default: 'sysadmin' }], + write: [{ type: String, trim: true, default: 'sysadmin' }], + }, + 'nrpti' +); diff --git a/api/src/models/index.js b/api/src/models/index.js index 0b81e5c8f..55132a8eb 100644 --- a/api/src/models/index.js +++ b/api/src/models/index.js @@ -4,6 +4,7 @@ exports.audit = require('./audit'); exports.task = require('./task'); exports.document = require('./document'); +exports.epicProject = require('./epicProject'); // master require('./master'); diff --git a/api/src/utils/query-actions.js b/api/src/utils/query-actions.js index ec979bc54..8603c6415 100644 --- a/api/src/utils/query-actions.js +++ b/api/src/utils/query-actions.js @@ -1,7 +1,5 @@ 'use strict'; -const defaultLog = require('./logger')('queryActions'); - /** * Publish the obj: add 'public' to the 'read' field. * @@ -13,8 +11,6 @@ exports.publish = async function(obj, auth_payload) { return new Promise(async function(resolve, reject) { // Object was already published? if (self.isPublished(obj)) { - defaultLog.info(`publish - HTTP 409 - Object already published: ${JSON.stringify(obj)}`); - resolve({ code: 409, message: 'Object already published' @@ -84,8 +80,6 @@ exports.unPublish = async function(obj, auth_payload) { return new Promise(async function(resolve, reject) { // Object wasn't already published? if (!self.isPublished(obj)) { - defaultLog.info(`unPublish - HTTP 409 - Object already unpublished: ${JSON.stringify(obj)}`); - resolve({ code: 409, message: 'Object already unpublished' From 445d09ab30be839ed7fa3d0d92dde0742f0ed4cb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mark=20Lis=C3=A9?= Date: Fri, 14 Aug 2020 13:34:34 -0700 Subject: [PATCH 2/2] CodeReview: Fix object initialization. --- angular/projects/admin-nrpti/src/app/app.component.ts | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/angular/projects/admin-nrpti/src/app/app.component.ts b/angular/projects/admin-nrpti/src/app/app.component.ts index 70be31ec3..a8d2d5f5d 100644 --- a/angular/projects/admin-nrpti/src/app/app.component.ts +++ b/angular/projects/admin-nrpti/src/app/app.component.ts @@ -149,9 +149,7 @@ export class AppComponent implements OnInit, OnDestroy { list.unshift({_id: null, name: 'None'}); // Set the object in the store service - // tslint:disable-next-line: prefer-const - let newObject = {}; - newObject[key] = list; + const newObject = { [key]: list }; this.storeService.setItem(newObject); }