Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG][NRPTI-1235] Check legislation act codes during CSV export #1236

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,7 @@ import { EpicProjectIds, SchemaLists } from '../../../../common/src/app/utils/re

@Injectable()
export class RecordsResolver implements Resolve<Observable<object>> {
constructor(
private factoryService: FactoryService,
private tableTemplateUtils: TableTemplateUtils
) {}
constructor(private factoryService: FactoryService, private tableTemplateUtils: TableTemplateUtils) {}

resolve(route: ActivatedRouteSnapshot): Observable<object> {
const params = { ...route.params };
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ 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.
Expand Down Expand Up @@ -127,6 +128,7 @@ export class RecordUtils {
output = `${csvHeaders.join(',')}\n`;

const agencyDataService = new AgencyDataService(factoryService);
const dataService = new ActDataServiceNRCED(factoryService);

for (const row of data) {
let line = [];
Expand All @@ -150,7 +152,14 @@ export class RecordUtils {
const legislation = Array.isArray(row['legislation']) ? row['legislation'][0] : row['legislation'];

if (legislation) {
line.push(escapeCsvString(legislation['act']));
if (legislation['act'] && legislation['act'].startsWith('ACT_')) {
const actTitle = dataService.displayActTitleFull(legislation['act']);
if (actTitle) {
line.push(escapeCsvString(actTitle));
}
} else {
line.push(escapeCsvString(legislation['act']));
}
line.push(escapeCsvString(legislation['regulation']));
line.push(escapeCsvString(legislation['section']));
line.push(escapeCsvString(legislation['subSection']));
Expand Down Expand Up @@ -188,7 +197,6 @@ export class RecordUtils {

download(`nrced-export-${moment().format('YYYY-MM-DD')}.csv`, output);
}

}

/**
Expand Down
Loading