-
Update Issuing Agency
+
Update Agencies
diff --git a/angular/projects/admin-nrpti/src/app/utils/constants/misc.ts b/angular/projects/admin-nrpti/src/app/utils/constants/misc.ts
index 4687d0e78..579c6943d 100644
--- a/angular/projects/admin-nrpti/src/app/utils/constants/misc.ts
+++ b/angular/projects/admin-nrpti/src/app/utils/constants/misc.ts
@@ -49,7 +49,7 @@ export class Constants {
ENTITIES: 'Entities',
IMPORTS: 'Imports',
COMMUNICATIONS: 'Communications',
- UPDATE_ISSUING_AGENCY: 'Update Issuing Agency'
+ AGENCIES: 'Agencies'
};
public static readonly RecordTypes: any = {
From c6528bf6d5637738b2517e5fa61e322c7696630e Mon Sep 17 00:00:00 2001
From: David <62899351+davidclaveau@users.noreply.github.com>
Date: Mon, 25 Sep 2023 15:02:11 -0700
Subject: [PATCH 36/77] update to agencies in components and modules
---
.../agencies.component.html} | 0
.../agencies.component.scss} | 0
.../agencies.component.ts} | 10 +++++-----
.../agencies.module.ts} | 12 ++++++------
.../agencies.resolver.ts} | 2 +-
.../admin-nrpti/src/app/app-routing.module.ts | 10 +++++-----
angular/projects/admin-nrpti/src/app/app.module.ts | 4 ++--
.../src/app/sidebar/sidebar.component.html | 8 ++++----
8 files changed, 23 insertions(+), 23 deletions(-)
rename angular/projects/admin-nrpti/src/app/{update-issuing-agency/update-issuing-agency.component.html => agencies/agencies.component.html} (100%)
rename angular/projects/admin-nrpti/src/app/{update-issuing-agency/update-issuing-agency.component.scss => agencies/agencies.component.scss} (100%)
rename angular/projects/admin-nrpti/src/app/{update-issuing-agency/update-issuing-agency.component.ts => agencies/agencies.component.ts} (91%)
rename angular/projects/admin-nrpti/src/app/{update-issuing-agency/update-issuing-agency.module.ts => agencies/agencies.module.ts} (73%)
rename angular/projects/admin-nrpti/src/app/{update-issuing-agency/update-issuing-agency.resolver.ts => agencies/agencies.resolver.ts} (75%)
diff --git a/angular/projects/admin-nrpti/src/app/update-issuing-agency/update-issuing-agency.component.html b/angular/projects/admin-nrpti/src/app/agencies/agencies.component.html
similarity index 100%
rename from angular/projects/admin-nrpti/src/app/update-issuing-agency/update-issuing-agency.component.html
rename to angular/projects/admin-nrpti/src/app/agencies/agencies.component.html
diff --git a/angular/projects/admin-nrpti/src/app/update-issuing-agency/update-issuing-agency.component.scss b/angular/projects/admin-nrpti/src/app/agencies/agencies.component.scss
similarity index 100%
rename from angular/projects/admin-nrpti/src/app/update-issuing-agency/update-issuing-agency.component.scss
rename to angular/projects/admin-nrpti/src/app/agencies/agencies.component.scss
diff --git a/angular/projects/admin-nrpti/src/app/update-issuing-agency/update-issuing-agency.component.ts b/angular/projects/admin-nrpti/src/app/agencies/agencies.component.ts
similarity index 91%
rename from angular/projects/admin-nrpti/src/app/update-issuing-agency/update-issuing-agency.component.ts
rename to angular/projects/admin-nrpti/src/app/agencies/agencies.component.ts
index f1a649b72..3c857232d 100644
--- a/angular/projects/admin-nrpti/src/app/update-issuing-agency/update-issuing-agency.component.ts
+++ b/angular/projects/admin-nrpti/src/app/agencies/agencies.component.ts
@@ -3,14 +3,14 @@ import { IssuingAgencyService } from '../services/issuingagency.service';
import { LoggerService } from 'nrpti-angular-components';
import { Constants } from '../utils/constants/misc';
import { ToastService } from '../services/toast.service';
-import { FactoryService } from '../../../../admin-nrpti/src/app/services/factory.service';
+import { FactoryService } from '../services/factory.service';
@Component({
- selector: 'app-update-issuing-agency',
- templateUrl: './update-issuing-agency.component.html',
- styleUrls: ['./update-issuing-agency.component.scss']
+ selector: 'app-agencies',
+ templateUrl: './agencies.component.html',
+ styleUrls: ['./agencies.component.scss']
})
-export class UpdateIssuingAgencyComponent implements OnInit {
+export class AgenciesComponent implements OnInit {
public loading = false;
selectedAgency: string = ''; // Initialize the selectedAgency
choiceMade = false;
diff --git a/angular/projects/admin-nrpti/src/app/update-issuing-agency/update-issuing-agency.module.ts b/angular/projects/admin-nrpti/src/app/agencies/agencies.module.ts
similarity index 73%
rename from angular/projects/admin-nrpti/src/app/update-issuing-agency/update-issuing-agency.module.ts
rename to angular/projects/admin-nrpti/src/app/agencies/agencies.module.ts
index 21d5f6955..fad361202 100644
--- a/angular/projects/admin-nrpti/src/app/update-issuing-agency/update-issuing-agency.module.ts
+++ b/angular/projects/admin-nrpti/src/app/agencies/agencies.module.ts
@@ -9,8 +9,8 @@ import { EditorModule } from '@tinymce/tinymce-angular';
import { GlobalModule } from 'nrpti-angular-components';
import { CommonModule as NrptiCommonModule } from '../../../../common/src/app/common.module';
-import { UpdateIssuingAgencyComponent } from './update-issuing-agency.component';
-import { UpdateIssuingAgencyResolver } from './update-issuing-agency.resolver';
+import { AgenciesComponent } from './agencies.component';
+import { AgenciesResolver } from './agencies.resolver';
@NgModule({
@@ -26,14 +26,14 @@ import { UpdateIssuingAgencyResolver } from './update-issuing-agency.resolver';
NgbModule,
],
declarations: [
- UpdateIssuingAgencyComponent
+ AgenciesComponent
],
providers: [
- UpdateIssuingAgencyResolver
+ AgenciesResolver
],
entryComponents: [
- UpdateIssuingAgencyComponent
+ AgenciesComponent
],
exports: []
})
-export class UpdateIssuingAgencyModule {}
+export class AgenciesModule {}
diff --git a/angular/projects/admin-nrpti/src/app/update-issuing-agency/update-issuing-agency.resolver.ts b/angular/projects/admin-nrpti/src/app/agencies/agencies.resolver.ts
similarity index 75%
rename from angular/projects/admin-nrpti/src/app/update-issuing-agency/update-issuing-agency.resolver.ts
rename to angular/projects/admin-nrpti/src/app/agencies/agencies.resolver.ts
index d86e79004..9ff8a6b31 100644
--- a/angular/projects/admin-nrpti/src/app/update-issuing-agency/update-issuing-agency.resolver.ts
+++ b/angular/projects/admin-nrpti/src/app/agencies/agencies.resolver.ts
@@ -4,7 +4,7 @@ import { Observable } from 'rxjs/Observable';
@Injectable()
-export class UpdateIssuingAgencyResolver implements Resolve
> {
+export class AgenciesResolver implements Resolve> {
resolve(route: ActivatedRouteSnapshot): Observable
diff --git a/angular/projects/admin-nrpti/src/app/agencies/agencies.component.ts b/angular/projects/admin-nrpti/src/app/agencies/agencies.component.ts
index 3c857232d..e37c3a823 100644
--- a/angular/projects/admin-nrpti/src/app/agencies/agencies.component.ts
+++ b/angular/projects/admin-nrpti/src/app/agencies/agencies.component.ts
@@ -12,19 +12,19 @@ import { FactoryService } from '../services/factory.service';
})
export class AgenciesComponent implements OnInit {
public loading = false;
- selectedAgency: string = ''; // Initialize the selectedAgency
+ selectedAgency = ''; // Initialize the selectedAgency
choiceMade = false;
- newAgency: string = ''; // Initialize the new agency input field
- agencies: { [key: string]: string } = {"Kyle": "Williams"};
- agencyList: string[] = ["-Select-"]; // Use a string array for agencyList
+ newAgency = ''; // Initialize the new agency input field
+ agencies: { [key: string]: string } = { 'Kyle': 'Williams' };
+ agencyList: string[] = ['-Select-']; // Use a string array for agencyList
updatedData: any = {
- "agencies": []
+ agencies: []
};
constructor(
private issuingAgencyService: IssuingAgencyService,
private logger: LoggerService,
private toastService: ToastService,
- private factoryService: FactoryService,
+ private factoryService: FactoryService
) {}
onSelected(value: string): void {
@@ -32,61 +32,58 @@ export class AgenciesComponent implements OnInit {
this.choiceMade = true;
}
putRecords(agencyCode: any, agencyName: any) {
- this.issuingAgencyService.updateAgency(agencyCode, agencyName)
- .then(() => {
- // Once record is updated, refresh the agencies
- this.refreshAgencies();
- });
+ this.issuingAgencyService.updateAgency(agencyCode, agencyName).then(() => {
+ // Once record is updated, refresh the agencies
+ this.refreshAgencies();
+ });
}
- refreshAgencies (){
+ refreshAgencies() {
this.factoryService.applicationAgencyService.refreshAgencies().subscribe();
}
updateSelectedAgency(): void {
- try{
- if (this.newAgency.trim() !== '') {
- // 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;
+ try {
+ if (this.newAgency.trim() !== '') {
+ // 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;
+ }
+ // Update the selectedAgency with the new value
+ this.selectedAgency = this.newAgency;
+ // Clear the input field
+ this.newAgency = '';
+ this.choiceMade = true;
+ // Update the updatedData object to match the desired layout
+ this.updatedData.agencies.push({
+ agencyCode: matchingCode,
+ agencyName: this.selectedAgency
+ });
+ this.putRecords(matchingCode, this.selectedAgency);
+ this.updatedData.agencies = [];
}
- // Update the selectedAgency with the new value
- this.selectedAgency = this.newAgency;
- // Clear the input field
- this.newAgency = '';
- this.choiceMade = true;
- // Update the updatedData object to match the desired layout
- this.updatedData.agencies.push({
- "agencyCode": matchingCode,
- "agencyName": this.selectedAgency
- });
- this.putRecords(matchingCode, this.selectedAgency);
- this.updatedData.agencies = []
+ this.toastService.addMessage('Agency Successfully Updated', 'Success Updated', Constants.ToastTypes.SUCCESS);
+ } else {
+ this.toastService.addMessage(
+ 'Updated Agency Name Cannot be Empty',
+ 'Save unsuccessful',
+ Constants.ToastTypes.ERROR
+ );
}
- this.toastService.addMessage('Agency Successfully Updated', 'Success Updated', Constants.ToastTypes.SUCCESS);
- }else{
+ } catch (error) {
this.toastService.addMessage(
- 'Updated Agency Name Cannot be Empty',
+ 'An error has occured while saving',
'Save unsuccessful',
Constants.ToastTypes.ERROR
);
}
}
-catch (error) {
- this.toastService.addMessage(
- 'An error has occured while saving',
- 'Save unsuccessful',
- Constants.ToastTypes.ERROR
- );
-}
- }
ngOnInit(): void {
- this.issuingAgencyService.getIssuingAgencies()
+ this.issuingAgencyService
+ .getIssuingAgencies()
.then(response => {
const agencies = {};
if (response && Array.isArray(response)) {
diff --git a/angular/projects/admin-nrpti/src/app/agencies/agencies.module.ts b/angular/projects/admin-nrpti/src/app/agencies/agencies.module.ts
index fad361202..e7fe1d8d8 100644
--- a/angular/projects/admin-nrpti/src/app/agencies/agencies.module.ts
+++ b/angular/projects/admin-nrpti/src/app/agencies/agencies.module.ts
@@ -12,7 +12,6 @@ import { CommonModule as NrptiCommonModule } from '../../../../common/src/app/co
import { AgenciesComponent } from './agencies.component';
import { AgenciesResolver } from './agencies.resolver';
-
@NgModule({
imports: [
BrowserModule,
@@ -23,17 +22,11 @@ import { AgenciesResolver } from './agencies.resolver';
GlobalModule,
NrptiCommonModule,
RouterModule,
- NgbModule,
- ],
- declarations: [
- AgenciesComponent
- ],
- providers: [
- AgenciesResolver
- ],
- entryComponents: [
- AgenciesComponent
+ NgbModule
],
+ declarations: [AgenciesComponent],
+ providers: [AgenciesResolver],
+ entryComponents: [AgenciesComponent],
exports: []
})
export class AgenciesModule {}
diff --git a/angular/projects/admin-nrpti/src/app/agencies/agencies.resolver.ts b/angular/projects/admin-nrpti/src/app/agencies/agencies.resolver.ts
index 9ff8a6b31..c2bfd86e8 100644
--- a/angular/projects/admin-nrpti/src/app/agencies/agencies.resolver.ts
+++ b/angular/projects/admin-nrpti/src/app/agencies/agencies.resolver.ts
@@ -2,7 +2,6 @@ import { Injectable } from '@angular/core';
import { ActivatedRouteSnapshot, Resolve } from '@angular/router';
import { Observable } from 'rxjs/Observable';
-
@Injectable()
export class AgenciesResolver implements Resolve
> {
resolve(route: ActivatedRouteSnapshot): Observable