Skip to content

Commit

Permalink
[NRPTI-1045][FEATURE] - issuing agency update (#1120)
Browse files Browse the repository at this point in the history
* add menu item and page code - wip

* Updated the front end to display list of agencies from drop down and update values from that list with value from a text box.

* create model and migration for agencies

* fix to model and migration - wip

* update agency code migration, add update issuingAgency

* update model to only add to nrpti collection

* sample api added - list-agencies WIP

* added api to list agencies, schema type

* added get api

* put api added for updating agencies

* New component to make request to new endpoint for issuing agencies

* Options added

* Fixed component to properly display the information returned from get request

* Update the agencyList array with selection from drop down menu. Create the object which will be sent to the api for updating the agencyList. Also worth noting the alerts are being used here for console debugging. My local settings are preventing logging, when I find the reason I will update readme to document process

* First steps of patch logic to the update agency service

* Front end component updates entries in for agency issuers through new endpoint.

* security token enabled, alerts removed, compile issue fixed

* toast added

* button style updated

* Style added to dropdown

* current selected agency removed

* wip - add agency service to app_init, change displayName

* error message added

* removed logging and fixed indentation

* replaced hardcoded agency names with api calls

* api call moved to service layer

* issuing agency in add order replaced with api calls

* add climate action secretariat to migrations

* wip - agencies are updated in factory, prelim update to components

* wip - update picklist to allow dynamic update (admin penalty only)

* wip - make buildForm for admin penalty async

* wip - update to factory service, fix buildForm in admin penalty

* refresh agencies after they are updated

* remove async ngOnInit, no longer needed

* update to more relevant terminology

* update to agencies in components and modules

* agency name translated to agency code on admin penalty save

* update admin penalty to show agency; linting updates

* linting updates

* linting updates

* API unit tests fix

* linting fix for agency-data-service

* Agencies icon changed

* agency code updated

* agency code updated

* issuing agency replaced with api call

* update migration to change 'author' name to code; separate agency_env_epd

* update migration for ENV_EPD and update authors

* linting: white space added

* linting

* Update api/src/models/master/applicationAgency.js

Co-authored-by: Matthew Logan <62873746+LocalNewsTV@users.noreply.github.com>

* Update api/src/swagger/swagger.yaml

crlf

Co-authored-by: Matthew Logan <62873746+LocalNewsTV@users.noreply.github.com>

* Update api/migrations/20230911220312-addApplicationAgenciesModel.js

crlf

Co-authored-by: Matthew Logan <62873746+LocalNewsTV@users.noreply.github.com>

* comments added, unused function removed

* revert migration update

* revert migration; update NRPTI agency filter

* mine record page updated to use agency code

* mines collection updated to use agency code

* update importers to use agencyCodes

* update importer integrations to use agencyCodes

* fix some failing tests

* refactoring

* add documentation to new files and migrations; minor code cleanup

* migration added for bcmi

* fix missing agency codes in integrations; add epic test

* wip - nrced agency swap

* fix to call agency data service on init in nrced

* NRCED records updated with agency api call

* fix agency code transformation for nris-epd, fix tests

* fix issuing agency for nris-epd integration

* update to show ministry name on mines table

* sonarcloud fixes

* fix to show agency name in mines detail components

* show correct agency names in mines enforcement components

---------

Co-authored-by: David <62899351+davidclaveau@users.noreply.github.com>
Co-authored-by: Christopher-walsh22 <106549296+Christopher-walsh22@users.noreply.github.com>
Co-authored-by: Matthew Logan <62873746+LocalNewsTV@users.noreply.github.com>
  • Loading branch information
4 people authored Oct 16, 2023
1 parent 147effc commit 97271a8
Show file tree
Hide file tree
Showing 92 changed files with 747 additions and 259 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,13 @@ export class AgenciesComponent implements OnInit {
this.factoryService.applicationAgencyService.refreshAgencies().subscribe();
}
updateSelectedAgency(): void {
const index = this.agencyList.indexOf(this.selectedAgency);
try {
if (this.newAgency.trim() !== '') {
if (this.newAgency.trim() !== '' && index !== -1) {
// Find the agency code that matches the selected agency name
const matchingCode = Object.keys(this.agencies).find(key => this.agencies[key] === this.selectedAgency);
if (matchingCode) {
// Update the agencyList with the new value at the same index
const index = this.agencyList.indexOf(this.selectedAgency);
if (index !== -1) {
this.agencyList[index] = this.newAgency;
}
Expand All @@ -65,9 +65,12 @@ export class AgenciesComponent implements OnInit {
this.updatedData.agencies = [];
}
this.toastService.addMessage('Agency Successfully Updated', 'Success Updated', Constants.ToastTypes.SUCCESS);
setTimeout(() => {
location.reload();
}, 1500);
} else {
this.toastService.addMessage(
'Updated Agency Name Cannot be Empty',
'Updating/Updated Agency Name Cannot be Empty',
'Save unsuccessful',
Constants.ToastTypes.ERROR
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ <h2 class="border-0 mb-0">{{ (isEditing && 'Edit') || (!isEditing && 'Add') }} C
<label for="collectionAgency">Agency</label>
<select name="collectionAgency" id="collectionAgency" formControlName="collectionAgency" class="form-control">
<option *ngFor="let collectionAgency of collectionAgencies" [ngValue]="collectionAgency">
{{ this.convertAcronyms(collectionAgency) }}
{{ this.displayName(collectionAgency) }}
</option>
</select>
</div>
Expand Down Expand Up @@ -243,4 +243,4 @@ <h3 class="border-0 mb-0">Associated Records</h3>
</div>
</div>
</div>
</main>
</main>
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import { ConfirmComponent } from '../../confirm/confirm.component';
import { FactoryService } from '../../services/factory.service';
import { RecordUtils } from '../../records/utils/record-utils';
import { Constants } from '../../utils/constants/misc';
import { AgencyDataService } from '../../../../../../projects/global/src/lib/utils/agency-data-service';

@Component({
selector: 'app-mines-collections-add-edit',
Expand All @@ -39,7 +40,7 @@ export class MinesCollectionsAddEditComponent implements OnInit, OnDestroy {

// Pick lists
public collectionTypes = Picklists.collectionTypePicklist;
public collectionAgencies = Picklists.collectionAgencyPicklist;
public collectionAgencies = Picklists.collectionAgencyCodePicklist;

// collection add edit state
public collectionState = null;
Expand Down Expand Up @@ -541,6 +542,11 @@ export class MinesCollectionsAddEditComponent implements OnInit, OnDestroy {
return Utils.convertAcronyms(acronym);
}

displayName(agency) {
const agencyDataService = new AgencyDataService(this.factoryService);
return agencyDataService.displayNameFull(agency);
}

ngOnDestroy(): void {
// When the component is destroying, if collectionAddEdit state exists, but the user hadn't clicked the
// 'addRecordsToCollection' button, then remove the collection state from the store.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ <h4>Basic Information</h4>
name="issuingAgency"
id="issuingAgency"
type="text"
value="{{ this.convertAcronyms(defaultAgency) }}"
value="{{ this.displayName(defaultAgency) }}"
class="form-control" />
</div>
<div class="label-pair">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { LoadingScreenService, LoggerService } from 'nrpti-angular-components';
import { Utils, StoreService } from 'nrpti-angular-components';
import { ChangeDetectorRef } from '@angular/core';
import { takeUntil } from 'rxjs/operators';
import { AgencyDataService } from '../../../../../../global/src/lib/utils/agency-data-service';

@Component({
selector: 'app-mines-administrative-penalty-add-edit',
Expand All @@ -16,7 +17,7 @@ import { takeUntil } from 'rxjs/operators';
export class MinesAdministrativePenaltyAddEditComponent extends AdministrativePenaltyAddEditComponent
implements OnInit {
public componentTitle = 'BCMI Administrative Penalty Record';
public defaultAgency = 'Ministry of Energy Mines and Low Carbon Innovation';
public defaultAgency = 'AGENCY_EMLI';
public defaultAuthor = 'BC Government';
public currentRecord = null;

Expand Down Expand Up @@ -103,7 +104,8 @@ export class MinesAdministrativePenaltyAddEditComponent extends AdministrativePe
}

displayName(agency) {
return Utils.displayNameFull(agency);
const agencyDataService = new AgencyDataService(this.factoryService);
return agencyDataService.displayNameFull(agency);
}

cancel() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ import { takeUntil } from 'rxjs/operators';
import { AdministrativePenaltyDetailComponent } from '../../../records/administrative-penalties/administrative-penalty-detail/administrative-penalty-detail.component';
import { RecordUtils } from '../../../records/utils/record-utils';
import { FactoryService } from '../../../services/factory.service';
import { StoreService, Utils } from 'nrpti-angular-components';
import { StoreService } from 'nrpti-angular-components';
import { AgencyDataService } from '../../../../../../global/src/lib/utils/agency-data-service';

@Component({
selector: 'app-mines-administrative-penalty-detail',
Expand Down Expand Up @@ -65,7 +66,8 @@ export class MinesAdministrativePenaltyDetailComponent extends AdministrativePen
}

displayName(agency) {
return Utils.displayNameFull(agency);
const agencyDataService = new AgencyDataService(this.factoryService);
return agencyDataService.displayNameFull(agency);
}

navigateToEditPage() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ <h4>Basic Information</h4>
name="recordType"
id="recordType"
type="text"
[value]="this.convertAcronyms(this.myForm.get('issuingAgency').value)"
[value]="this.displayName(this.myForm.get('issuingAgency').value)"
class="form-control"
/>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { LoadingScreenService, LoggerService } from 'nrpti-angular-components';
import { Utils, StoreService } from 'nrpti-angular-components';
import { ChangeDetectorRef } from '@angular/core';
import { takeUntil } from 'rxjs/operators';
import { AgencyDataService } from '../../../../../../../global/src/lib/utils/agency-data-service';

@Component({
selector: 'app-mines-court-convictions-add-edit',
Expand All @@ -17,7 +18,7 @@ import { takeUntil } from 'rxjs/operators';
})
export class MinesCourtConvictionsAddEditComponent extends CourtConvictionAddEditComponent implements OnInit {
public componentTitle = 'BCMI Administrative Penalty Record';
public defaultAgency = 'Ministry of Energy Mines and Low Carbon Innovation';
public defaultAgency = 'AGENCY_EMLI';
public defaultAuthor = 'BC Government';
public currentRecord = null;

Expand Down Expand Up @@ -152,6 +153,11 @@ export class MinesCourtConvictionsAddEditComponent extends CourtConvictionAddEdi
}
}

displayName(agency) {
const agencyDataService = new AgencyDataService(this.factoryService);
return agencyDataService.displayNameFull(agency);
}

cancel() {
const shouldCancel = confirm(
'Leaving this page will discard unsaved changes. Are you sure you would like to continue?'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ import { takeUntil } from 'rxjs/operators';
import { CourtConvictionDetailComponent } from '../../../../records/court-convictions/court-conviction-detail/court-conviction-detail.component';
import { RecordUtils } from '../../../../records/utils/record-utils';
import { FactoryService } from '../../../../services/factory.service';
import { StoreService, Utils } from 'nrpti-angular-components';
import { StoreService } from 'nrpti-angular-components';
import { AgencyDataService } from '../../../../../../../global/src/lib/utils/agency-data-service';

@Component({
selector: 'app-mines-court-convictions-detail',
Expand Down Expand Up @@ -64,7 +65,8 @@ export class MinesCourtConvictionsDetailComponent extends CourtConvictionDetailC
}

displayName(agency) {
return Utils.displayNameFull(agency);
const agencyDataService = new AgencyDataService(this.factoryService);
return agencyDataService.displayNameFull(agency);
}

navigateToEditPage() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { Picklists } from '../../../../../common/src/app/utils/record-constants'
import { FactoryService } from '../../services/factory.service';
import { RecordUtils } from '../../records/utils/record-utils';
import { Constants } from '../../utils/constants/misc';
import { AgencyDataService } from '../../../../../../projects/global/src/lib/utils/agency-data-service';

@Component({
selector: 'app-mines-record-add',
Expand Down Expand Up @@ -38,7 +39,7 @@ export class MinesRecordAddComponent implements OnInit, OnDestroy {
);

// Pick lists
public recordAgencies = Picklists.collectionAgencyPicklist;
public recordAgencies = Picklists.collectionAgencyCodePicklist;
public recordTypeNamesBCMI = Object.values(Picklists.bcmiRecordTypePicklist).map(item => {
return item.displayName;
}).sort();
Expand Down Expand Up @@ -176,7 +177,8 @@ export class MinesRecordAddComponent implements OnInit, OnDestroy {
}

displayName(agency) {
return Utils.displayNameFull(agency);
const agencyDataService = new AgencyDataService(this.factoryService);
return agencyDataService.displayNameFull(agency);
}

ngOnDestroy(): void {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import { Subject } from 'rxjs';
import { ActivatedRoute, Router } from '@angular/router';
import moment from 'moment';
import { CollectionBCMI } from '../../../../../common/src/app/models/bcmi';
import { Utils } from 'nrpti-angular-components';

import { AgencyDataService } from '../../../../../global/src/lib/utils/agency-data-service';
import { FactoryService } from '../../services/factory.service';
@Component({
selector: 'app-mines-records-detail',
templateUrl: './mines-records-detail.component.html',
Expand All @@ -22,7 +22,8 @@ export class MinesRecordDetailComponent implements OnInit, OnDestroy {
constructor(
public route: ActivatedRoute,
public router: Router,
public changeDetectionRef: ChangeDetectorRef
public changeDetectionRef: ChangeDetectorRef,
public factoryService: FactoryService
) { }

isDisableEdit() {
Expand Down Expand Up @@ -73,7 +74,8 @@ export class MinesRecordDetailComponent implements OnInit, OnDestroy {
}

displayName(agency) {
return Utils.displayNameAcronym(agency);
const agencyDataService = new AgencyDataService(this.factoryService);
return agencyDataService.displayNameFull(agency);
}

ngOnDestroy() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { ConfirmComponent } from '../../confirm/confirm.component';
import { takeUntil, catchError } from 'rxjs/operators';
import { Constants } from '../../utils/constants/misc';
import { ToastService } from '../../services/toast.service';
import { AgencyDataService } from '../../../../../../projects/global/src/lib/utils/agency-data-service';

@Component({
selector: 'app-mines-records-edit',
Expand Down Expand Up @@ -49,7 +50,7 @@ export class MinesRecordsEditComponent implements OnInit {
}).sort();
public permitTypes = ['OGP', 'AMD'];

public recordAgencies = Picklists.collectionAgencyPicklist;
public recordAgencies = Picklists.collectionAgencyCodePicklist;;

// record add edit state
public recordState = null;
Expand Down Expand Up @@ -286,7 +287,8 @@ export class MinesRecordsEditComponent implements OnInit {
}

displayName(agency) {
return Utils.displayNameFull(agency);
const agencyDataService = new AgencyDataService(this.factoryService);
return agencyDataService.displayNameFull(agency);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ import { FilterObject, FilterType, DateFilterDefinition, CheckOrRadioFilterDefin
import { SubsetsObject, SubsetOption } from '../../../../../common/src/app/search-filter-template/subset-object';
import { Mine } from '../../../../../common/src/app/models/bcmi/mine';
import { MiscUtils } from '../../utils/constants/misc';
import { FactoryService } from '../../services/factory.service';
import { AgencyDataService } from '../../../../../global/src/lib/utils/agency-data-service';

/**
* Mine list page component.
Expand Down Expand Up @@ -121,7 +123,8 @@ export class MinesRecordsListComponent implements OnInit, OnDestroy {
public storeService: StoreService,
private loadingScreenService: LoadingScreenService,
private tableTemplateUtils: TableTemplateUtils,
private _changeDetectionRef: ChangeDetectorRef
private _changeDetectionRef: ChangeDetectorRef,
private factoryService: FactoryService
) {
// setup the subset configuration
const subsetOptions = [
Expand Down Expand Up @@ -155,10 +158,16 @@ export class MinesRecordsListComponent implements OnInit, OnDestroy {
'agency',
FilterType.MultiSelect,
'Responsible Agency',
new MultiSelectDefinition(Picklists.agencyPicklist.map(value => {
const displayValue = Utils.displayNameFull(value);
return { value: value, displayValue: displayValue, selected: false, display: true };
}), 'Begin typing to filter agencies...', '')
new MultiSelectDefinition(
Picklists.getAgencyNames(this.factoryService).map(value => {
const agencyDataService = new AgencyDataService(this.factoryService);
const displayValue = agencyDataService.displayNameFull(value);
const picklistCodes = Picklists.getAgencyCode(this.factoryService, value)
return { value: picklistCodes, displayValue: displayValue, selected: false, display: true };
}),
'Begin typing to filter agencies...',
''
)
);

const sourceSystemFilter = new FilterObject(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { FactoryService } from '../../services/factory.service';
import { TableRowComponent } from 'nrpti-angular-components';
import { Router, ActivatedRoute } from '@angular/router';
import { Entity } from '../../../../../common/src/app/models/master/common-models/entity';
import { Utils } from 'nrpti-angular-components';
import { AgencyDataService } from '../../../../../global/src/lib/utils/agency-data-service';

@Component({
selector: 'tr[app-mines-records-table-row]',
Expand Down Expand Up @@ -39,7 +39,8 @@ export class MinesRecordsTableRowComponent extends TableRowComponent implements
}

displayName(agency) {
return Utils.displayNameAcronym(agency);
const agencyDataService = new AgencyDataService(this.factoryService);
return agencyDataService.displayNameFull(agency);
}

private isDisableEdit() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export class AdministrativeSanctionAddEditComponent implements OnInit, OnDestroy
public nrcedPublishSubtext = 'Not published';

// Pick lists
public agencies = Picklists.agencyCodePicklist;
public agencies = Picklists.getAgencyCodes(this.factoryService);
public authors = Picklists.authorPicklist;
private defaultAgency = '';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export class AnnualReportAddEditComponent implements OnInit, OnDestroy {
public bcmiPublishSubtext = 'Not published';

// Pick lists
public agencies = Picklists.agencyCodePicklist;
public agencies = Picklists.getAgencyCodes(this.factoryService);

public datepickerMinDate = Constants.DatepickerMinDate;
public datepickerMaxDate = Constants.DatepickerMaxDate;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export class CertificateAmendmentAddEditComponent implements OnInit, OnDestroy {

// Pick lists
public certificateSubtypes = Picklists.certificateSubtypePicklist;
public agencies = Picklists.agencyCodePicklist;
public agencies = Picklists.getAgencyCodes(this.factoryService);

public datepickerMinDate = Constants.DatepickerMinDate;
public datepickerMaxDate = Constants.DatepickerMaxDate;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export class CertificateAddEditComponent implements OnInit, OnDestroy {

// Pick lists
public certificateSubtypes = Picklists.certificateSubtypePicklist;
public agencies = Picklists.agencyCodePicklist;
public agencies = Picklists.getAgencyCodes(this.factoryService);

public datepickerMinDate = Constants.DatepickerMinDate;
public datepickerMaxDate = Constants.DatepickerMaxDate;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export class ConstructionPlanAddEditComponent implements OnInit, OnDestroy {
public lngPublishSubtext = 'Not published';

// Pick lists
public agencies = Picklists.agencyCodePicklist;
public agencies = Picklists.getAgencyCodes(this.factoryService);

// Documents
public documents = [];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export class CorrespondenceAddEditComponent implements OnInit, OnDestroy {
public bcmiPublishSubtext = 'Not published';

// Pick lists
public agencies = Picklists.agencyCodePicklist;
public agencies = Picklists.getAgencyCodes(this.factoryService);

// Documents
public documents = [];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export class CourtConvictionAddEditComponent implements OnInit, OnDestroy {
public bcmiPublishSubtext = 'Not published';

// Pick lists
public agencies = Picklists.agencyCodePicklist;
public agencies = Picklists.getAgencyCodes(this.factoryService);
public authors = Picklists.authorPicklist;
public courtConvictionSubtypes = Picklists.courtConvictionSubtypePicklist;
protected defaultAgency = '';
Expand Down
Loading

0 comments on commit 97271a8

Please sign in to comment.