diff --git a/angular/projects/admin-nrpti/src/app/records/records-resolver.spec.ts b/angular/projects/admin-nrpti/src/app/records/records-resolver.spec.ts index f67b0efae..c691df445 100644 --- a/angular/projects/admin-nrpti/src/app/records/records-resolver.spec.ts +++ b/angular/projects/admin-nrpti/src/app/records/records-resolver.spec.ts @@ -6,21 +6,18 @@ import { of } from 'rxjs'; import { ActivatedRouteSnapshot } from '@angular/router'; import { TableObject } from 'nrpti-angular-components'; import { EpicProjectIds } from '../../../../common/src/app/utils/record-constants'; -import { RecordUtils } from './utils/record-utils'; describe('RecordsResolver', () => { const spyFactoryService = jasmine.createSpyObj('FactoryService', ['getRecords']); const spyTableTemplateUtils = jasmine.createSpyObj('TableTemplateUtils', [ 'updateTableObjectWithUrlParams' ]); - const spyRecordUtils = jasmine.createSpyObj('RecordUtils', ['appendActCodesToActNames']); beforeEach(() => { TestBed.configureTestingModule({ providers: [ { provide: FactoryService, useValue: spyFactoryService }, - { provide: TableTemplateUtils, useValue: spyTableTemplateUtils }, - { provide: RecordUtils, useValue: spyRecordUtils } + { provide: TableTemplateUtils, useValue: spyTableTemplateUtils } ] }).compileComponents(); }); @@ -28,9 +25,8 @@ describe('RecordsResolver', () => { it('should create', async(() => { const factoryService = TestBed.get(FactoryService); const tableTemplateUtils = TestBed.get(TableTemplateUtils); - const recordUtils = TestBed.get(RecordUtils); - const recordsResolver = new RecordsResolver(factoryService, tableTemplateUtils, recordUtils); + const recordsResolver = new RecordsResolver(factoryService, tableTemplateUtils); expect(recordsResolver).toBeTruthy(); })); @@ -38,7 +34,6 @@ describe('RecordsResolver', () => { describe('resolve', () => { let factoryServiceSpy: jasmine.SpyObj; let tableTemplateUtilsSpy: jasmine.SpyObj; - let recordUtilsSpy: jasmine.SpyObj; describe('with empty/null route parameters', () => { const activatedRouteSnapshot: ActivatedRouteSnapshot = { @@ -62,13 +57,12 @@ describe('RecordsResolver', () => { beforeAll(async(() => { factoryServiceSpy = TestBed.get(FactoryService); tableTemplateUtilsSpy = TestBed.get(TableTemplateUtils); - recordUtilsSpy = TestBed.get(RecordUtils); factoryServiceSpy.getRecords.calls.reset(); factoryServiceSpy.getRecords.and.returnValue(of({})); tableTemplateUtilsSpy.updateTableObjectWithUrlParams.and.returnValue({ currentPage: 1, pageSize: 25 }); - const recordsResolver = new RecordsResolver(factoryServiceSpy, tableTemplateUtilsSpy, recordUtilsSpy); + const recordsResolver = new RecordsResolver(factoryServiceSpy, tableTemplateUtilsSpy); recordsResolver.resolve(activatedRouteSnapshot); })); @@ -139,13 +133,12 @@ describe('RecordsResolver', () => { beforeAll(async(() => { factoryServiceSpy = TestBed.get(FactoryService); tableTemplateUtilsSpy = TestBed.get(TableTemplateUtils); - recordUtilsSpy = TestBed.get(RecordUtils); factoryServiceSpy.getRecords.calls.reset(); factoryServiceSpy.getRecords.and.returnValue(of({})); tableTemplateUtilsSpy.updateTableObjectWithUrlParams.and.returnValue({ currentPage: 1, pageSize: 25 }); - const recordsResolver = new RecordsResolver(factoryServiceSpy, tableTemplateUtilsSpy, recordUtilsSpy); + const recordsResolver = new RecordsResolver(factoryServiceSpy, tableTemplateUtilsSpy); recordsResolver.resolve(activatedRouteSnapshot); })); @@ -216,13 +209,12 @@ describe('RecordsResolver', () => { beforeAll(async(() => { factoryServiceSpy = TestBed.get(FactoryService); tableTemplateUtilsSpy = TestBed.get(TableTemplateUtils); - recordUtilsSpy = TestBed.get(RecordUtils); factoryServiceSpy.getRecords.calls.reset(); factoryServiceSpy.getRecords.and.returnValue(of({})); tableTemplateUtilsSpy.updateTableObjectWithUrlParams.and.returnValue({ currentPage: 1, pageSize: 25 }); - const recordsResolver = new RecordsResolver(factoryServiceSpy, tableTemplateUtilsSpy, recordUtilsSpy); + const recordsResolver = new RecordsResolver(factoryServiceSpy, tableTemplateUtilsSpy); recordsResolver.resolve(activatedRouteSnapshot); })); @@ -293,13 +285,12 @@ describe('RecordsResolver', () => { beforeAll(async(() => { factoryServiceSpy = TestBed.get(FactoryService); tableTemplateUtilsSpy = TestBed.get(TableTemplateUtils); - recordUtilsSpy = TestBed.get(RecordUtils); factoryServiceSpy.getRecords.calls.reset(); factoryServiceSpy.getRecords.and.returnValue(of({})); tableTemplateUtilsSpy.updateTableObjectWithUrlParams.and.returnValue({ currentPage: 1, pageSize: 25 }); - const recordsResolver = new RecordsResolver(factoryServiceSpy, tableTemplateUtilsSpy, recordUtilsSpy); + const recordsResolver = new RecordsResolver(factoryServiceSpy, tableTemplateUtilsSpy); recordsResolver.resolve(activatedRouteSnapshot); })); @@ -370,13 +361,12 @@ describe('RecordsResolver', () => { beforeAll(async(() => { factoryServiceSpy = TestBed.get(FactoryService); tableTemplateUtilsSpy = TestBed.get(TableTemplateUtils); - recordUtilsSpy = TestBed.get(RecordUtils); factoryServiceSpy.getRecords.calls.reset(); factoryServiceSpy.getRecords.and.returnValue(of({})); tableTemplateUtilsSpy.updateTableObjectWithUrlParams.and.returnValue({ currentPage: 1, pageSize: 25 }); - const recordsResolver = new RecordsResolver(factoryServiceSpy, tableTemplateUtilsSpy, recordUtilsSpy); + const recordsResolver = new RecordsResolver(factoryServiceSpy, tableTemplateUtilsSpy); recordsResolver.resolve(activatedRouteSnapshot); })); @@ -447,13 +437,12 @@ describe('RecordsResolver', () => { beforeAll(async(() => { factoryServiceSpy = TestBed.get(FactoryService); tableTemplateUtilsSpy = TestBed.get(TableTemplateUtils); - recordUtilsSpy = TestBed.get(RecordUtils); factoryServiceSpy.getRecords.calls.reset(); factoryServiceSpy.getRecords.and.returnValue(of({})); tableTemplateUtilsSpy.updateTableObjectWithUrlParams.and.returnValue({ currentPage: 1, pageSize: 25 }); - const recordsResolver = new RecordsResolver(factoryServiceSpy, tableTemplateUtilsSpy, recordUtilsSpy); + const recordsResolver = new RecordsResolver(factoryServiceSpy, tableTemplateUtilsSpy); recordsResolver.resolve(activatedRouteSnapshot); })); diff --git a/angular/projects/admin-nrpti/src/app/records/records-resolver.ts b/angular/projects/admin-nrpti/src/app/records/records-resolver.ts index 8f0703653..c38248758 100644 --- a/angular/projects/admin-nrpti/src/app/records/records-resolver.ts +++ b/angular/projects/admin-nrpti/src/app/records/records-resolver.ts @@ -4,14 +4,12 @@ import { Observable } from 'rxjs/Observable'; import { TableTemplateUtils, TableObject } from 'nrpti-angular-components'; import { FactoryService } from '../services/factory.service'; import { EpicProjectIds, SchemaLists } from '../../../../common/src/app/utils/record-constants'; -import { RecordUtils } from './utils/record-utils'; @Injectable() export class RecordsResolver implements Resolve> { constructor( private factoryService: FactoryService, - private tableTemplateUtils: TableTemplateUtils, - private recordUtils: RecordUtils + private tableTemplateUtils: TableTemplateUtils ) {} resolve(route: ActivatedRouteSnapshot): Observable { @@ -59,7 +57,7 @@ export class RecordsResolver implements Resolve> { } if (params.act) { - or['legislation.act'] = this.recordUtils.appendActCodesToActNames(params.act, this.factoryService); + or['legislation.act'] = params.act; } if (params.regulation) { diff --git a/angular/projects/admin-nrpti/src/app/records/utils/record-utils.ts b/angular/projects/admin-nrpti/src/app/records/utils/record-utils.ts index 3f9b6b417..3ec13b205 100644 --- a/angular/projects/admin-nrpti/src/app/records/utils/record-utils.ts +++ b/angular/projects/admin-nrpti/src/app/records/utils/record-utils.ts @@ -273,24 +273,6 @@ export class RecordUtils { record.legislation[0].act = actCode; } - /** - * Adds the act code to a list of act names for a search query - * @param {Object} actsSTring - a string of comma-seperated act names. - * @param {ServiceFactory} factoryService - The service factory used to create data service instances. - * @returns {string} a string with comma-serparated act names followed by comma sperated act codes - */ - appendActCodesToActNames(actsString, factoryService) { - const dataservice = new ActDataServiceNRPTI(factoryService); - const actList = actsString.split(','); - actList.forEach(actName => { - const actCode = dataservice.getCodeFromTitle(actName); - if (actCode) { - actsString += ',' + actCode; - } - }); - return actsString; - } - /** * Replaces the 'act' value in the given record object with a corresponding act code. * @param {string} actCode - an intermediate code mapped to a title diff --git a/angular/projects/public-nrpti/src/app/records/utils/record-utils.ts b/angular/projects/public-nrpti/src/app/records/utils/record-utils.ts index 3a189c642..4ac6603f7 100644 --- a/angular/projects/public-nrpti/src/app/records/utils/record-utils.ts +++ b/angular/projects/public-nrpti/src/app/records/utils/record-utils.ts @@ -11,7 +11,6 @@ import { CourtConvictionDetailComponent } from '../court-convictions/court-convi import { Penalty } from '../../../../../common/src/app/models/master/common-models/penalty'; import { AgencyDataService } from '../../../../../global/src/lib/utils/agency-data-service-nrced'; import { FactoryService } from '../../services/factory.service'; -import { ActDataServiceNRCED } from '../../../../../global/src/lib/utils/act-data-service-nrced'; export class RecordUtils { /** * Given a record type, return the matching detail component type, or null if no matching component found. @@ -190,23 +189,6 @@ export class RecordUtils { download(`nrced-export-${moment().format('YYYY-MM-DD')}.csv`, output); } - /** - * Adds the act code to a list of act names for a search query - * @param {Object} actsSTring - a string of comma-seperated act names. - * @param {ServiceFactory} factoryService - The service factory used to create data service instances. - * @returns {string} a string with comma-serparated act names followed by comma sperated act codes - */ - static appendActCodesToActNames(actsString, factoryService) { - const dataservice = new ActDataServiceNRCED(factoryService); - const actList = actsString.split(','); - actList.forEach(actName => { - const actCode = dataservice.getCodeFromTitle(actName); - if (actCode) { - actsString += ',' + actCode; - } - }); - return actsString; - } } /**