ui and feedback updates
This commit is contained in:
parent
7bbb633cd7
commit
882d73c248
@ -9,6 +9,8 @@ export const serverRoutes: ServerRoute[] = [
|
|||||||
{ path: ':appId/preparer', renderMode: RenderMode.Client },
|
{ path: ':appId/preparer', renderMode: RenderMode.Client },
|
||||||
{ path: ':appId/preparer/:id', renderMode: RenderMode.Client },
|
{ path: ':appId/preparer/:id', renderMode: RenderMode.Client },
|
||||||
{ path: ':appId/add-preparer', renderMode: RenderMode.Client },
|
{ path: ':appId/add-preparer', renderMode: RenderMode.Client },
|
||||||
|
{ path: ':appId/table-record', renderMode: RenderMode.Client },
|
||||||
|
{ path: ':appId/add-preparer', renderMode: RenderMode.Client },
|
||||||
{
|
{
|
||||||
path: '**',
|
path: '**',
|
||||||
renderMode: RenderMode.Prerender
|
renderMode: RenderMode.Prerender
|
||||||
|
|||||||
@ -17,6 +17,8 @@ export const routes: Routes = [
|
|||||||
{ path: 'preparer', loadComponent: () => import('./preparer/manage/manage-preparer.component').then(m => m.ManagePreparerComponent) },
|
{ path: 'preparer', loadComponent: () => import('./preparer/manage/manage-preparer.component').then(m => m.ManagePreparerComponent) },
|
||||||
{ path: 'preparer/:id', loadComponent: () => import('./preparer/edit/edit-preparer.component').then(m => m.EditPreparerComponent) },
|
{ path: 'preparer/:id', loadComponent: () => import('./preparer/edit/edit-preparer.component').then(m => m.EditPreparerComponent) },
|
||||||
{ path: 'add-preparer', loadComponent: () => import('./preparer/add/add-preparer.component').then(m => m.AddPreparerComponent) },
|
{ path: 'add-preparer', loadComponent: () => import('./preparer/add/add-preparer.component').then(m => m.AddPreparerComponent) },
|
||||||
|
{ path: 'table-record', loadComponent: () => import('./param/manage-table-record/manage-table-record.component').then(m => m.ManageTableRecordComponent) },
|
||||||
|
{ path: 'param-record/:id', loadComponent: () => import('./param/manage-param-record/manage-param-record.component').then(m => m.ManageParamRecordComponent) },
|
||||||
{ path: '', redirectTo: 'home', pathMatch: 'full' }
|
{ path: '', redirectTo: 'home', pathMatch: 'full' }
|
||||||
],
|
],
|
||||||
canActivate: [AuthGuard, AppIdGuard]
|
canActivate: [AuthGuard, AppIdGuard]
|
||||||
|
|||||||
@ -7,7 +7,7 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="copyright">
|
<div class="copyright">
|
||||||
© {{ currentYear }} USCIB Carnet Portal. All rights reserved.
|
© {{ currentYear }} {{currentServiceProviderName}}. All rights reserved.
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</footer>
|
</footer>
|
||||||
@ -1,6 +1,8 @@
|
|||||||
import { Component, Input } from '@angular/core';
|
import { Component, effect, inject, Input } from '@angular/core';
|
||||||
import { AngularMaterialModule } from '../../shared/module/angular-material.module';
|
import { AngularMaterialModule } from '../../shared/module/angular-material.module';
|
||||||
import { CommonModule } from '@angular/common';
|
import { CommonModule } from '@angular/common';
|
||||||
|
import { User } from '../../core/models/user';
|
||||||
|
import { UserService } from '../../core/services/common/user.service';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-footer',
|
selector: 'app-footer',
|
||||||
@ -10,5 +12,20 @@ import { CommonModule } from '@angular/common';
|
|||||||
})
|
})
|
||||||
export class FooterComponent {
|
export class FooterComponent {
|
||||||
currentYear = new Date().getFullYear();
|
currentYear = new Date().getFullYear();
|
||||||
|
currentServiceProviderName: string = '';
|
||||||
|
userDetails: User | null = {};
|
||||||
|
|
||||||
@Input() isUserLoggedIn = false;
|
@Input() isUserLoggedIn = false;
|
||||||
|
|
||||||
|
private userService = inject(UserService);
|
||||||
|
|
||||||
|
constructor(
|
||||||
|
) {
|
||||||
|
effect(() => {
|
||||||
|
this.userDetails = this.userService.userDetailsSignal();
|
||||||
|
if (this.userDetails?.userDetails) {
|
||||||
|
this.currentServiceProviderName = this.userDetails.userDetails.serviceProviderName || '';
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@ -6,33 +6,14 @@
|
|||||||
|
|
||||||
<div class="navbar-menu">
|
<div class="navbar-menu">
|
||||||
<button mat-button (click)="navigateTo('home')">Home</button>
|
<button mat-button (click)="navigateTo('home')">Home</button>
|
||||||
<button mat-button [matMenuTriggerFor]="users">Users</button>
|
|
||||||
<mat-menu #users="matMenu">
|
|
||||||
<button mat-menu-item (click)="navigateTo('usersettings')">User Settings</button>
|
|
||||||
</mat-menu>
|
|
||||||
<button mat-button [matMenuTriggerFor]="maintenance">Maintenance</button>
|
<button mat-button [matMenuTriggerFor]="maintenance">Maintenance</button>
|
||||||
<mat-menu #maintenance="matMenu">
|
<mat-menu #maintenance="matMenu">
|
||||||
<button mat-menu-item (click)="navigateTo('preparer')">Preparer</button>
|
<button mat-menu-item (click)="navigateTo('preparer')">Preparer</button>
|
||||||
<button mat-menu-item (click)="navigateTo('holder')">Holder</button>
|
<!-- <button mat-menu-item (click)="navigateTo('holder')">Holder</button>
|
||||||
<button mat-menu-item (click)="navigateTo('carnet')">Carnet</button>
|
<button mat-menu-item (click)="navigateTo('carnet')">Carnet</button> -->
|
||||||
</mat-menu>
|
</mat-menu>
|
||||||
<button mat-button [matMenuTriggerFor]="admin">Admin</button>
|
<button mat-button (click)="navigateTo('table-record')">Configurations</button>
|
||||||
<mat-menu #admin="matMenu">
|
|
||||||
<button mat-menu-item (click)="navigateTo('sequence')">Sequence</button>
|
|
||||||
<button mat-menu-item (click)="navigateTo('regions')">Regions</button>
|
|
||||||
<button mat-menu-item (click)="navigateTo('users')">Users</button>
|
|
||||||
</mat-menu>
|
|
||||||
<!--
|
|
||||||
<button mat-icon-button [matMenuTriggerFor]="profile">
|
|
||||||
<mat-icon>account_circle</mat-icon>
|
|
||||||
</button>
|
|
||||||
<mat-menu #profile="matMenu">
|
|
||||||
<button mat-menu-item (click)="logout()">
|
|
||||||
<mat-icon>logout</mat-icon>
|
|
||||||
<span>Logout</span>
|
|
||||||
</button>
|
|
||||||
</mat-menu> -->
|
|
||||||
|
|
||||||
<div class="profile-container">
|
<div class="profile-container">
|
||||||
<button mat-icon-button (click)="toggleProfileMenu()" class="profile-button">
|
<button mat-icon-button (click)="toggleProfileMenu()" class="profile-button">
|
||||||
<mat-icon>account_circle</mat-icon>
|
<mat-icon>account_circle</mat-icon>
|
||||||
@ -44,6 +25,11 @@
|
|||||||
<span>{{ userEmail }}</span>
|
<span>{{ userEmail }}</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<button mat-menu-item (click)="navigateTo('/usersettings')">
|
||||||
|
<mat-icon>settings</mat-icon>
|
||||||
|
<span>User Preferences</span>
|
||||||
|
</button>
|
||||||
|
|
||||||
<button mat-menu-item (click)="logout()">
|
<button mat-menu-item (click)="logout()">
|
||||||
<mat-icon>logout</mat-icon>
|
<mat-icon>logout</mat-icon>
|
||||||
<span>Logout</span>
|
<span>Logout</span>
|
||||||
|
|||||||
22
src/app/core/models/param/parameters.ts
Normal file
22
src/app/core/models/param/parameters.ts
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
|
||||||
|
export interface ParamProperties {
|
||||||
|
paramId?: number;
|
||||||
|
spid?: number;
|
||||||
|
paramType: string;
|
||||||
|
paramDesc: string;
|
||||||
|
paramValue: string;
|
||||||
|
addlParamValue1: string | null;
|
||||||
|
addlParamValue2: string | null;
|
||||||
|
addlParamValue3: string | null;
|
||||||
|
addlParamValue4: string | null;
|
||||||
|
addlParamValue5: string | null;
|
||||||
|
sortSeq?: number;
|
||||||
|
inactiveCodeFlag: 'Y' | 'N' | null;
|
||||||
|
inactiveDate: string | null;
|
||||||
|
createdBy: string;
|
||||||
|
dateCreated: string;
|
||||||
|
lastUpdatedBy: string | null;
|
||||||
|
lastUpdatedDate: string | null;
|
||||||
|
errorMesg: string | null;
|
||||||
|
userId?: string;
|
||||||
|
}
|
||||||
1
src/app/core/models/param/types.ts
Normal file
1
src/app/core/models/param/types.ts
Normal file
@ -0,0 +1 @@
|
|||||||
|
export type TABLE_MODE = 'TABLE-RECORD' | 'PARAM-RECORD';
|
||||||
@ -7,4 +7,5 @@ export interface BasicFee {
|
|||||||
spid?: number;
|
spid?: number;
|
||||||
dateCreated?: Date | null;
|
dateCreated?: Date | null;
|
||||||
createdBy?: string | null;
|
createdBy?: string | null;
|
||||||
|
expired?: boolean;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -6,4 +6,5 @@ export interface CarnetFee {
|
|||||||
spid: number;
|
spid: number;
|
||||||
dateCreated?: Date | null;
|
dateCreated?: Date | null;
|
||||||
createdBy?: string | null;
|
createdBy?: string | null;
|
||||||
|
expired?: boolean;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -7,4 +7,5 @@ export interface ContinuationSheetFee {
|
|||||||
carnetType: string;
|
carnetType: string;
|
||||||
dateCreated?: Date | null;
|
dateCreated?: Date | null;
|
||||||
createdBy?: string | null;
|
createdBy?: string | null;
|
||||||
|
expired?: boolean;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -9,4 +9,5 @@ export interface CounterfoilFee {
|
|||||||
rate: number,
|
rate: number,
|
||||||
dateCreated?: Date | null;
|
dateCreated?: Date | null;
|
||||||
createdBy?: string | null;
|
createdBy?: string | null;
|
||||||
|
expired?: boolean;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -9,4 +9,5 @@ export interface ExpeditedFee {
|
|||||||
effectiveDate: Date;
|
effectiveDate: Date;
|
||||||
dateCreated?: Date | null;
|
dateCreated?: Date | null;
|
||||||
createdBy?: string | null;
|
createdBy?: string | null;
|
||||||
|
expired?: boolean;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -9,4 +9,5 @@ export interface SecurityDeposit {
|
|||||||
spid: number;
|
spid: number;
|
||||||
dateCreated?: Date | null;
|
dateCreated?: Date | null;
|
||||||
createdBy?: string | null;
|
createdBy?: string | null;
|
||||||
|
expired?: boolean;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -17,4 +17,5 @@ export interface UserDetail {
|
|||||||
urlKey: string;
|
urlKey: string;
|
||||||
logoName: string;
|
logoName: string;
|
||||||
themeName: string;
|
themeName: string;
|
||||||
|
serviceProviderName: string;
|
||||||
}
|
}
|
||||||
@ -12,6 +12,7 @@ import { CargoPolicy } from '../../models/cargo-policy';
|
|||||||
import { CargoSurety } from '../../models/cargo-surety';
|
import { CargoSurety } from '../../models/cargo-surety';
|
||||||
import { CarnetStatus } from '../../models/carnet-status';
|
import { CarnetStatus } from '../../models/carnet-status';
|
||||||
import { Country } from '../../models/country';
|
import { Country } from '../../models/country';
|
||||||
|
import { UserService } from './user.service';
|
||||||
|
|
||||||
@Injectable({
|
@Injectable({
|
||||||
providedIn: 'root'
|
providedIn: 'root'
|
||||||
@ -21,9 +22,10 @@ export class CommonService {
|
|||||||
private apiDb = environment.apiDb;
|
private apiDb = environment.apiDb;
|
||||||
|
|
||||||
private http = inject(HttpClient);
|
private http = inject(HttpClient);
|
||||||
|
private userService = inject(UserService);
|
||||||
|
|
||||||
getCountries(spid: number = 0): Observable<Country[]> {
|
getCountries(): Observable<Country[]> {
|
||||||
return this.http.get<any[]>(`${this.apiUrl}/${this.apiDb}/GetParamValues?P_PARAMTYPE=002&P_SPID=0`).pipe(
|
return this.http.get<any[]>(`${this.apiUrl}/${this.apiDb}/GetParamValues?P_PARAMTYPE=002&P_SPID=${this.userService.getUserSpid()}`).pipe(
|
||||||
map((response) =>
|
map((response) =>
|
||||||
response.map((item) => ({
|
response.map((item) => ({
|
||||||
name: item.PARAMDESC,
|
name: item.PARAMDESC,
|
||||||
@ -34,8 +36,8 @@ export class CommonService {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
getStates(country: string, spid: number = 0): Observable<State[]> {
|
getStates(country: string): Observable<State[]> {
|
||||||
return this.http.get<any[]>(`${this.apiUrl}/${this.apiDb}/GetParamValues?P_PARAMTYPE=001&P_SPID=0`).pipe(
|
return this.http.get<any[]>(`${this.apiUrl}/${this.apiDb}/GetParamValues?P_PARAMTYPE=001&P_SPID=${this.userService.getUserSpid()}`).pipe(
|
||||||
map((response) =>
|
map((response) =>
|
||||||
response.map((item) => ({
|
response.map((item) => ({
|
||||||
name: item.PARAMDESC,
|
name: item.PARAMDESC,
|
||||||
@ -63,8 +65,8 @@ export class CommonService {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
getDeliveryTypes(spid: number = 0): Observable<DeliveryType[]> {
|
getDeliveryTypes(): Observable<DeliveryType[]> {
|
||||||
return this.http.get<any[]>(`${this.apiUrl}/${this.apiDb}/GetParamValues?P_PARAMTYPE=006&P_SPID=0`).pipe(
|
return this.http.get<any[]>(`${this.apiUrl}/${this.apiDb}/GetParamValues?P_PARAMTYPE=006&P_SPID=${this.userService.getUserSpid()}`).pipe(
|
||||||
map((response) =>
|
map((response) =>
|
||||||
response.map((item) => ({
|
response.map((item) => ({
|
||||||
name: item.PARAMDESC,
|
name: item.PARAMDESC,
|
||||||
@ -75,8 +77,8 @@ export class CommonService {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
getTimezones(spid: number = 0): Observable<TimeZone[]> {
|
getTimezones(): Observable<TimeZone[]> {
|
||||||
return this.http.get<any[]>(`${this.apiUrl}/${this.apiDb}/GetParamValues?P_PARAMTYPE=010&P_SPID=0`).pipe(
|
return this.http.get<any[]>(`${this.apiUrl}/${this.apiDb}/GetParamValues?P_PARAMTYPE=010&P_SPID=${this.userService.getUserSpid()}`).pipe(
|
||||||
map((response) =>
|
map((response) =>
|
||||||
response.map((item) => ({
|
response.map((item) => ({
|
||||||
name: item.PARAMDESC,
|
name: item.PARAMDESC,
|
||||||
@ -87,8 +89,8 @@ export class CommonService {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
getFeeTypes(spid: number = 0): Observable<FeeType[]> {
|
getFeeTypes(): Observable<FeeType[]> {
|
||||||
return this.http.get<any[]>(`${this.apiUrl}/${this.apiDb}/GetParamValues?P_PARAMTYPE=009&P_SPID=0`).pipe(
|
return this.http.get<any[]>(`${this.apiUrl}/${this.apiDb}/GetParamValues?P_PARAMTYPE=009&P_SPID=${this.userService.getUserSpid()}`).pipe(
|
||||||
map((response) =>
|
map((response) =>
|
||||||
response.map((item) => ({
|
response.map((item) => ({
|
||||||
name: item.PARAMDESC,
|
name: item.PARAMDESC,
|
||||||
@ -99,8 +101,8 @@ export class CommonService {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
getBondSuretys(spid: number = 0): Observable<BondSurety[]> {
|
getBondSuretys(): Observable<BondSurety[]> {
|
||||||
return this.http.get<any[]>(`${this.apiUrl}/${this.apiDb}/GetParamValues?P_PARAMTYPE=003&P_SPID=0`).pipe(
|
return this.http.get<any[]>(`${this.apiUrl}/${this.apiDb}/GetParamValues?P_PARAMTYPE=003&P_SPID=${this.userService.getUserSpid()}`).pipe(
|
||||||
map((response) =>
|
map((response) =>
|
||||||
response.map((item) => ({
|
response.map((item) => ({
|
||||||
name: item.PARAMDESC,
|
name: item.PARAMDESC,
|
||||||
@ -111,8 +113,8 @@ export class CommonService {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
getCargoPolicies(spid: number = 0): Observable<CargoPolicy[]> {
|
getCargoPolicies(): Observable<CargoPolicy[]> {
|
||||||
return this.http.get<any[]>(`${this.apiUrl}/${this.apiDb}/GetParamValues?P_PARAMTYPE=004&P_SPID=0`).pipe(
|
return this.http.get<any[]>(`${this.apiUrl}/${this.apiDb}/GetParamValues?P_PARAMTYPE=004&P_SPID=${this.userService.getUserSpid()}`).pipe(
|
||||||
map((response) =>
|
map((response) =>
|
||||||
response.map((item) => ({
|
response.map((item) => ({
|
||||||
name: item.PARAMDESC,
|
name: item.PARAMDESC,
|
||||||
@ -123,8 +125,8 @@ export class CommonService {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
getCargoSuretys(spid: number = 0): Observable<CargoSurety[]> {
|
getCargoSuretys(): Observable<CargoSurety[]> {
|
||||||
return this.http.get<any[]>(`${this.apiUrl}/${this.apiDb}/GetParamValues?P_PARAMTYPE=005&P_SPID=0`).pipe(
|
return this.http.get<any[]>(`${this.apiUrl}/${this.apiDb}/GetParamValues?P_PARAMTYPE=005&P_SPID=${this.userService.getUserSpid()}`).pipe(
|
||||||
map((response) =>
|
map((response) =>
|
||||||
response.map((item) => ({
|
response.map((item) => ({
|
||||||
name: item.PARAMDESC,
|
name: item.PARAMDESC,
|
||||||
@ -135,8 +137,8 @@ export class CommonService {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
getCarnetStatuses(spid: number = 0): Observable<CarnetStatus[]> {
|
getCarnetStatuses(): Observable<CarnetStatus[]> {
|
||||||
return this.http.get<any[]>(`${this.apiUrl}/${this.apiDb}/GetParamValues?P_PARAMTYPE=011&P_SPID=0`).pipe(
|
return this.http.get<any[]>(`${this.apiUrl}/${this.apiDb}/GetParamValues?P_PARAMTYPE=011&P_SPID=${this.userService.getUserSpid()}`).pipe(
|
||||||
map((response) =>
|
map((response) =>
|
||||||
response.map((item) => ({
|
response.map((item) => ({
|
||||||
name: item.PARAMDESC,
|
name: item.PARAMDESC,
|
||||||
|
|||||||
@ -136,7 +136,8 @@ export class UserService {
|
|||||||
locationid: userDetails.LOCATIONID,
|
locationid: userDetails.LOCATIONID,
|
||||||
urlKey: userDetails.ENCURLKEY,
|
urlKey: userDetails.ENCURLKEY,
|
||||||
logoName: userDetails.LOGONAME,
|
logoName: userDetails.LOGONAME,
|
||||||
themeName: userDetails.THEMENAME
|
themeName: userDetails.THEMENAME,
|
||||||
|
serviceProviderName: userDetails.SPNAME
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -37,7 +37,16 @@ export class HomeService {
|
|||||||
issueDate: item.ISSUEDATE || null,
|
issueDate: item.ISSUEDATE || null,
|
||||||
expiryDate: item.EXPDATE || null,
|
expiryDate: item.EXPDATE || null,
|
||||||
orderType: item.ORDERTYPE,
|
orderType: item.ORDERTYPE,
|
||||||
carnetStatus: item.CARNETSTATUS
|
carnetStatus: item.CARNETSTATUS,
|
||||||
|
HEADERID: item.HEADERID
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
deleteCarnet(headerid: number): Observable<any> {
|
||||||
|
return this.http.patch(`${this.apiUrl}/${this.apiDb}/ReactivateClientContacts/${this.userService.getUserSpid()}/${headerid}/${this.userService.getUser()}`, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
resetCarnet(headerid: number): Observable<any> {
|
||||||
|
return this.http.patch(`${this.apiUrl}/${this.apiDb}/ReactivateClientContacts/${this.userService.getUserSpid()}/${headerid}/${this.userService.getUser()}`, null);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
110
src/app/core/services/param/param.service.ts
Normal file
110
src/app/core/services/param/param.service.ts
Normal file
@ -0,0 +1,110 @@
|
|||||||
|
import { inject, Injectable } from "@angular/core";
|
||||||
|
import { environment } from "../../../../environments/environment";
|
||||||
|
import { HttpClient } from "@angular/common/http";
|
||||||
|
import { UserService } from "../common/user.service";
|
||||||
|
import { ParamProperties } from "../../models/param/parameters";
|
||||||
|
import { map, Observable } from "rxjs";
|
||||||
|
|
||||||
|
@Injectable({
|
||||||
|
providedIn: 'root'
|
||||||
|
})
|
||||||
|
export class ParamService {
|
||||||
|
private apiUrl = environment.apiUrl;
|
||||||
|
private apiDb = environment.apiDb;
|
||||||
|
|
||||||
|
private http = inject(HttpClient);
|
||||||
|
private userService = inject(UserService);
|
||||||
|
|
||||||
|
getParameters(P_PARAMTYPE: string): Observable<ParamProperties[]> {
|
||||||
|
return this.http.get<any[]>(`${this.apiUrl}/${this.apiDb}/GetALLParamValues?P_SPID=${this.userService.getUserSpid()}&P_PARAMTYPE=${P_PARAMTYPE}`).pipe(
|
||||||
|
map(response => this.mapToParamValue(response))
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
private mapToParamValue(data: any[]): ParamProperties[] {
|
||||||
|
return data.map((paramValue: any) => ({
|
||||||
|
paramId: paramValue.PARAMID,
|
||||||
|
spid: paramValue.SPID,
|
||||||
|
paramType: paramValue.PARAMTYPE,
|
||||||
|
paramDesc: paramValue.PARAMDESC,
|
||||||
|
paramValue: paramValue.PARAMVALUE,
|
||||||
|
addlParamValue1: paramValue.ADDLPARAMVALUE1,
|
||||||
|
addlParamValue2: paramValue.ADDLPARAMVALUE2,
|
||||||
|
addlParamValue3: paramValue.ADDLPARAMVALUE3,
|
||||||
|
addlParamValue4: paramValue.ADDLPARAMVALUE4,
|
||||||
|
addlParamValue5: paramValue.ADDLPARAMVALUE5,
|
||||||
|
sortSeq: paramValue.SORTSEQ,
|
||||||
|
inactiveCodeFlag: paramValue.INACTIVECODEFLAG,
|
||||||
|
inactiveDate: paramValue.INACTIVEDATE,
|
||||||
|
createdBy: paramValue.CREATEDBY,
|
||||||
|
dateCreated: paramValue.DATECREATED,
|
||||||
|
lastUpdatedBy: paramValue.LASTUPDATEDBY,
|
||||||
|
lastUpdatedDate: paramValue.LASTUPDATEDDATE,
|
||||||
|
errorMesg: paramValue.ERRORMESG,
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
|
createTableRecord(description: string): Observable<any> {
|
||||||
|
|
||||||
|
const paramDetails = {
|
||||||
|
P_TABLEFULLDESC: description,
|
||||||
|
P_USERID: this.userService.getUser(),
|
||||||
|
};
|
||||||
|
|
||||||
|
return this.http.post(`${this.apiUrl}/${this.apiDb}/CreateTableRecord`, paramDetails);
|
||||||
|
}
|
||||||
|
|
||||||
|
createParamRecord(data: ParamProperties): Observable<any> {
|
||||||
|
|
||||||
|
const paramDetails = {
|
||||||
|
p_spid: this.userService.getUserSpid(),
|
||||||
|
P_PARAMTYPE: data.paramType,
|
||||||
|
P_PARAMDESC: data.paramDesc,
|
||||||
|
P_PARAMVALUE: data.paramValue,
|
||||||
|
P_ADDLPARAMVALUE1: data.addlParamValue1,
|
||||||
|
P_ADDLPARAMVALUE2: data.addlParamValue2,
|
||||||
|
P_ADDLPARAMVALUE3: data.addlParamValue3,
|
||||||
|
P_ADDLPARAMVALUE4: data.addlParamValue4,
|
||||||
|
P_ADDLPARAMVALUE5: data.addlParamValue5,
|
||||||
|
P_SORTSEQ: data.sortSeq,
|
||||||
|
P_USERID: this.userService.getUser(),
|
||||||
|
};
|
||||||
|
|
||||||
|
return this.http.post(`${this.apiUrl}/${this.apiDb}/CreateParamRecord`, paramDetails);
|
||||||
|
}
|
||||||
|
|
||||||
|
updateParamRecord(data: ParamProperties): Observable<any> {
|
||||||
|
|
||||||
|
const paramDetails = {
|
||||||
|
P_SPID: this.userService.getUserSpid(),
|
||||||
|
P_PARAMID: data.paramId,
|
||||||
|
P_PARAMDESC: data.paramDesc,
|
||||||
|
P_ADDLPARAMVALUE1: data.addlParamValue1,
|
||||||
|
P_ADDLPARAMVALUE2: data.addlParamValue2,
|
||||||
|
P_ADDLPARAMVALUE3: data.addlParamValue3,
|
||||||
|
P_ADDLPARAMVALUE4: data.addlParamValue4,
|
||||||
|
P_ADDLPARAMVALUE5: data.addlParamValue5,
|
||||||
|
P_SORTSEQ: data.sortSeq,
|
||||||
|
P_USERID: this.userService.getUser(),
|
||||||
|
};
|
||||||
|
|
||||||
|
return this.http.patch(`${this.apiUrl}/${this.apiDb}/UpdateParamRecord`, paramDetails);
|
||||||
|
}
|
||||||
|
|
||||||
|
inActivateParamRecord(paramId: number) {
|
||||||
|
|
||||||
|
const data = {
|
||||||
|
P_PARAMID: paramId,
|
||||||
|
P_USERID: this.userService.getSafeUser()
|
||||||
|
}
|
||||||
|
return this.http.patch(`${this.apiUrl}/${this.apiDb}/InActivateParamRecord`, data);
|
||||||
|
}
|
||||||
|
|
||||||
|
reActivateParamRecord(paramId: number) {
|
||||||
|
const data = {
|
||||||
|
P_PARAMID: paramId,
|
||||||
|
P_USERID: this.userService.getSafeUser()
|
||||||
|
}
|
||||||
|
return this.http.patch(`${this.apiUrl}/${this.apiDb}/ReActivateParamRecord`, data);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -30,7 +30,8 @@ export class BasicFeeService {
|
|||||||
fees: item.FEES,
|
fees: item.FEES,
|
||||||
effectiveDate: item.EFFDATE,
|
effectiveDate: item.EFFDATE,
|
||||||
createdBy: item.CREATEDBY || null,
|
createdBy: item.CREATEDBY || null,
|
||||||
dateCreated: item.DATECREATED || null
|
dateCreated: item.DATECREATED || null,
|
||||||
|
expired: item.EXPDATE ? new Date(item.EXPDATE) < new Date() : false
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -31,7 +31,8 @@ export class CarnetFeeService {
|
|||||||
effectiveDate: item.EFFDATE,
|
effectiveDate: item.EFFDATE,
|
||||||
spid: item.SPID,
|
spid: item.SPID,
|
||||||
createdBy: item.CREATEDBY || null,
|
createdBy: item.CREATEDBY || null,
|
||||||
dateCreated: item.DATECREATED || null
|
dateCreated: item.DATECREATED || null,
|
||||||
|
expired: item.EXPDATE ? new Date(item.EXPDATE) < new Date() : false
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -80,7 +80,6 @@ export class ContactService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
deleteContact(spContactId: string): Observable<any> {
|
deleteContact(spContactId: string): Observable<any> {
|
||||||
return this.http.post(`${this.apiUrl}/${this.apiDb}/InactivateSPContact/${spContactId}`, null);
|
return this.http.patch(`${this.apiUrl}/${this.apiDb}/InactivateSPContact/${spContactId}`, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -31,7 +31,8 @@ export class ContinuationSheetFeeService {
|
|||||||
effectiveDate: item.EFFDATE,
|
effectiveDate: item.EFFDATE,
|
||||||
rate: item.RATE,
|
rate: item.RATE,
|
||||||
createdBy: item.CREATEDBY || null,
|
createdBy: item.CREATEDBY || null,
|
||||||
dateCreated: item.DATECREATED || null
|
dateCreated: item.DATECREATED || null,
|
||||||
|
expired: item.EXPDATE ? new Date(item.EXPDATE) < new Date() : false
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -33,7 +33,8 @@ export class CounterfoilFeeService {
|
|||||||
effectiveDate: item.EFFDATE,
|
effectiveDate: item.EFFDATE,
|
||||||
rate: item.RATE,
|
rate: item.RATE,
|
||||||
createdBy: item.CREATEDBY || null,
|
createdBy: item.CREATEDBY || null,
|
||||||
dateCreated: item.DATECREATED || null
|
dateCreated: item.DATECREATED || null,
|
||||||
|
expired: item.EXPDATE ? new Date(item.EXPDATE) < new Date() : false
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -34,7 +34,8 @@ export class ExpeditedFeeService {
|
|||||||
effectiveDate: item.EFFDATE,
|
effectiveDate: item.EFFDATE,
|
||||||
spid: item.SPID,
|
spid: item.SPID,
|
||||||
createdBy: item.CREATEDBY || null,
|
createdBy: item.CREATEDBY || null,
|
||||||
dateCreated: item.DATECREATED || null
|
dateCreated: item.DATECREATED || null,
|
||||||
|
expired: item.EXPDATE ? new Date(item.EXPDATE) < new Date() : false
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -33,7 +33,8 @@ export class SecurityDepositService {
|
|||||||
effectiveDate: item.EFFDATE,
|
effectiveDate: item.EFFDATE,
|
||||||
spid: item.SPID,
|
spid: item.SPID,
|
||||||
createdBy: item.CREATEDBY || null,
|
createdBy: item.CREATEDBY || null,
|
||||||
dateCreated: item.DATECREATED || null
|
dateCreated: item.DATECREATED || null,
|
||||||
|
expired: item.EXPDATE ? new Date(item.EXPDATE) < new Date() : false
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -83,6 +83,38 @@
|
|||||||
<td mat-cell *matCellDef="let item">{{ getCarnetStatusLabel(item.carnetStatus) }}</td>
|
<td mat-cell *matCellDef="let item">{{ getCarnetStatusLabel(item.carnetStatus) }}</td>
|
||||||
</ng-container>
|
</ng-container>
|
||||||
|
|
||||||
|
<ng-container matColumnDef="actions">
|
||||||
|
<th mat-header-cell *matHeaderCellDef>Actions</th>
|
||||||
|
<td mat-cell *matCellDef="let item">
|
||||||
|
<button mat-icon-button color="primary" (click)="processCarnet(item)"
|
||||||
|
*ngIf="getCarnetStatusLabel(item.carnetStatus) === 'Submitted'"
|
||||||
|
[hidden]="getCarnetStatusLabel(item.carnetStatus) !== 'Submitted'" matTooltip="Process">
|
||||||
|
<mat-icon>pending_actions</mat-icon>
|
||||||
|
</button>
|
||||||
|
<button mat-icon-button color="primary" (click)="viewCarnet(item)"
|
||||||
|
*ngIf="getCarnetStatusLabel(item.carnetStatus) === 'Submitted'"
|
||||||
|
[hidden]="getCarnetStatusLabel(item.carnetStatus) !== 'Submitted'" matTooltip="View">
|
||||||
|
<mat-icon>article</mat-icon>
|
||||||
|
</button>
|
||||||
|
<button mat-icon-button color="primary" (click)="resetClient(item)"
|
||||||
|
*ngIf="getCarnetStatusLabel(item.carnetStatus) === 'Submitted'"
|
||||||
|
[hidden]="getCarnetStatusLabel(item.carnetStatus) !== 'Submitted'"
|
||||||
|
matTooltip="Reset to Client">
|
||||||
|
<mat-icon>assignment_return</mat-icon>
|
||||||
|
</button>
|
||||||
|
<button mat-icon-button color="primary" (click)="deleteCarnet(item.HEADERID)"
|
||||||
|
*ngIf="getCarnetStatusLabel(item.carnetStatus) === 'Submitted'"
|
||||||
|
[hidden]="getCarnetStatusLabel(item.carnetStatus) !== 'Submitted'" matTooltip="Delete">
|
||||||
|
<mat-icon>delete</mat-icon>
|
||||||
|
</button>
|
||||||
|
<button mat-icon-button color="primary" (click)="printCarnet(item)"
|
||||||
|
*ngIf="getCarnetStatusLabel(item.carnetStatus) === 'Submitted'"
|
||||||
|
[hidden]="getCarnetStatusLabel(item.carnetStatus) !== 'Submitted'" matTooltip="Print">
|
||||||
|
<mat-icon>print</mat-icon>
|
||||||
|
</button>
|
||||||
|
</td>
|
||||||
|
</ng-container>
|
||||||
|
|
||||||
<tr mat-header-row *matHeaderRowDef="displayedColumns"></tr>
|
<tr mat-header-row *matHeaderRowDef="displayedColumns"></tr>
|
||||||
<tr mat-row *matRowDef="let row; columns: displayedColumns;"></tr>
|
<tr mat-row *matRowDef="let row; columns: displayedColumns;"></tr>
|
||||||
|
|
||||||
|
|||||||
@ -14,6 +14,9 @@ import { ApiErrorHandlerService } from '../core/services/common/api-error-handle
|
|||||||
import { CommonService } from '../core/services/common/common.service';
|
import { CommonService } from '../core/services/common/common.service';
|
||||||
import { NotificationService } from '../core/services/common/notification.service';
|
import { NotificationService } from '../core/services/common/notification.service';
|
||||||
import * as XLSX from 'xlsx';
|
import * as XLSX from 'xlsx';
|
||||||
|
import { NavigationService } from '../core/services/common/navigation.service';
|
||||||
|
import { ConfirmDialogComponent } from '../shared/components/confirm-dialog/confirm-dialog.component';
|
||||||
|
import { MatDialog } from '@angular/material/dialog';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-home',
|
selector: 'app-home',
|
||||||
@ -41,12 +44,14 @@ export class HomeComponent {
|
|||||||
this.dataSource.sort = value;
|
this.dataSource.sort = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
displayedColumns: string[] = ['applicationName', 'holderName', 'carnetNumber', 'usSets', 'foreignSets', 'transitSets', 'carnetValue', 'issueDate', 'expiryDate', 'orderType', 'carnetStatus'];
|
displayedColumns: string[] = ['applicationName', 'holderName', 'carnetNumber', 'usSets', 'foreignSets', 'transitSets', 'carnetValue', 'issueDate', 'expiryDate', 'orderType', 'carnetStatus', 'actions'];
|
||||||
|
|
||||||
private homeService = inject(HomeService);
|
private homeService = inject(HomeService);
|
||||||
private errorHandler = inject(ApiErrorHandlerService);
|
private errorHandler = inject(ApiErrorHandlerService);
|
||||||
private notificationService = inject(NotificationService);
|
private notificationService = inject(NotificationService);
|
||||||
private commonService = inject(CommonService);
|
private commonService = inject(CommonService);
|
||||||
|
private navigationService = inject(NavigationService);
|
||||||
|
private dialog = inject(MatDialog);
|
||||||
|
|
||||||
constructor(userPrefenceService: UserPreferencesService) {
|
constructor(userPrefenceService: UserPreferencesService) {
|
||||||
this.userPreferences = userPrefenceService.getPreferences();
|
this.userPreferences = userPrefenceService.getPreferences();
|
||||||
@ -74,6 +79,7 @@ export class HomeComponent {
|
|||||||
next: (data) => {
|
next: (data) => {
|
||||||
this.carnetData = data;
|
this.carnetData = data;
|
||||||
this.isLoading = false;
|
this.isLoading = false;
|
||||||
|
this.defaultCarnetStatusData();
|
||||||
},
|
},
|
||||||
error: (error) => {
|
error: (error) => {
|
||||||
console.error('Error loading carnet data:', error);
|
console.error('Error loading carnet data:', error);
|
||||||
@ -102,6 +108,20 @@ export class HomeComponent {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
defaultCarnetStatusData(): void {
|
||||||
|
// if the carnet data has record with the status 'T' (submitted), then load that data
|
||||||
|
const inProgressData = this.carnetData?.[0]?.CARNETSTATUS?.includes('T');
|
||||||
|
if (inProgressData) {
|
||||||
|
|
||||||
|
let spid = this.carnetData[0].SPID;
|
||||||
|
var carentData = {
|
||||||
|
spid: spid,
|
||||||
|
carnetStatus: 'T'
|
||||||
|
}
|
||||||
|
this.onCarnetStatusClick(carentData);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
exportData() {
|
exportData() {
|
||||||
try {
|
try {
|
||||||
// Prepare worksheet data
|
// Prepare worksheet data
|
||||||
@ -143,4 +163,99 @@ export class HomeComponent {
|
|||||||
const carnetStatus = this.carnetStatuses.find(t => t.value === value);
|
const carnetStatus = this.carnetStatuses.find(t => t.value === value);
|
||||||
return carnetStatus ? carnetStatus.name : value;
|
return carnetStatus ? carnetStatus.name : value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
processCarnet(item: any): void {
|
||||||
|
if (item && item.headerId) {
|
||||||
|
this.navigateTo(['edit-carnet', item.headerId], {
|
||||||
|
queryParams: { applicationname: item.applicationName }
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
this.notificationService.showError('Invalid carnet data');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
viewCarnet(item: any): void {
|
||||||
|
if (item && item.headerId) {
|
||||||
|
this.navigateTo(['view-carnet', item.headerId], {
|
||||||
|
queryParams: { applicationname: item.applicationName }
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
this.notificationService.showError('Invalid carnet data');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
printCarnet(item: any): void {
|
||||||
|
if (item && item.headerId) {
|
||||||
|
} else {
|
||||||
|
this.notificationService.showError('Invalid carnet data');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
deleteCarnet(headerId: number): void {
|
||||||
|
if (headerId) {
|
||||||
|
const dialogRef = this.dialog.open(ConfirmDialogComponent, {
|
||||||
|
width: '350px',
|
||||||
|
data: {
|
||||||
|
title: 'Delete Carnet',
|
||||||
|
message: 'Are you sure you want to delete the carnet?',
|
||||||
|
confirmText: 'Yes',
|
||||||
|
cancelText: 'Cancel'
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
dialogRef.afterClosed().subscribe(result => {
|
||||||
|
if (result) {
|
||||||
|
this.homeService.deleteCarnet(headerId).subscribe({
|
||||||
|
next: () => {
|
||||||
|
this.notificationService.showSuccess('Carnet deleted successfully');
|
||||||
|
this.loadCarnetData();
|
||||||
|
},
|
||||||
|
error: (error) => {
|
||||||
|
let errorMessage = this.errorHandler.handleApiError(error, 'Failed to delete carnet');
|
||||||
|
this.notificationService.showError(errorMessage);
|
||||||
|
console.error('Error deleting carnet:', error);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
this.notificationService.showError('Invalid carnet data');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
resetClient(headerId: number): void {
|
||||||
|
if (headerId) {
|
||||||
|
const dialogRef = this.dialog.open(ConfirmDialogComponent, {
|
||||||
|
width: '350px',
|
||||||
|
data: {
|
||||||
|
title: 'Reset Carnet',
|
||||||
|
message: 'Are you sure you want to reset the carnet to client?',
|
||||||
|
confirmText: 'Yes',
|
||||||
|
cancelText: 'Cancel'
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
dialogRef.afterClosed().subscribe(result => {
|
||||||
|
if (result) {
|
||||||
|
this.homeService.resetCarnet(headerId).subscribe({
|
||||||
|
next: () => {
|
||||||
|
this.notificationService.showSuccess('Carnet reset to client successfully');
|
||||||
|
this.loadCarnetData();
|
||||||
|
},
|
||||||
|
error: (error) => {
|
||||||
|
let errorMessage = this.errorHandler.handleApiError(error, 'Failed to reset carnet client');
|
||||||
|
this.notificationService.showError(errorMessage);
|
||||||
|
console.error('Error resetting carnet client:', error);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
this.notificationService.showError('Invalid carnet data for reset');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
navigateTo(route: any[], extras?: any): void {
|
||||||
|
this.navigationService.navigate(route, extras);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@ -0,0 +1 @@
|
|||||||
|
<app-param-table [table_mode]="table_mode" [paramHeading]="paramHeading"></app-param-table>
|
||||||
@ -0,0 +1,22 @@
|
|||||||
|
import { Component, inject } from '@angular/core';
|
||||||
|
import { TABLE_MODE } from '../../core/models/param/types';
|
||||||
|
import { ParamTableComponent } from '../table/param-table.component';
|
||||||
|
import { ActivatedRoute } from '@angular/router';
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
selector: 'app-manage-param-record',
|
||||||
|
imports: [ParamTableComponent],
|
||||||
|
templateUrl: './manage-param-record.component.html',
|
||||||
|
styleUrl: './manage-param-record.component.scss'
|
||||||
|
})
|
||||||
|
export class ManageParamRecordComponent {
|
||||||
|
table_mode: TABLE_MODE = 'PARAM-RECORD'
|
||||||
|
paramHeading: string = 'Parameters';
|
||||||
|
|
||||||
|
private route = inject(ActivatedRoute);
|
||||||
|
|
||||||
|
ngOnInit() {
|
||||||
|
const param = this.route.snapshot.queryParamMap.get('param');
|
||||||
|
this.paramHeading = param || '';
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1 @@
|
|||||||
|
<app-param-table [table_mode]="table_mode" [paramHeading]="paramHeading"></app-param-table>
|
||||||
@ -0,0 +1,14 @@
|
|||||||
|
import { Component } from '@angular/core';
|
||||||
|
import { ParamTableComponent } from '../table/param-table.component';
|
||||||
|
import { TABLE_MODE } from '../../core/models/param/types';
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
selector: 'app-manage-table-record',
|
||||||
|
imports: [ParamTableComponent],
|
||||||
|
templateUrl: './manage-table-record.component.html',
|
||||||
|
styleUrl: './manage-table-record.component.scss'
|
||||||
|
})
|
||||||
|
export class ManageTableRecordComponent {
|
||||||
|
table_mode: TABLE_MODE = 'TABLE-RECORD';
|
||||||
|
paramHeading: string = 'Table Records';
|
||||||
|
}
|
||||||
266
src/app/param/table/param-table.component.html
Normal file
266
src/app/param/table/param-table.component.html
Normal file
@ -0,0 +1,266 @@
|
|||||||
|
<h2 class="page-header">Manage - {{paramHeading | properCase}}</h2>
|
||||||
|
<div class="manage-container">
|
||||||
|
<div class="search-bar">
|
||||||
|
<mat-form-field appearance="outline" floatLabel="auto" class="full-width">
|
||||||
|
<mat-label>Search</mat-label>
|
||||||
|
<input matInput (keyup)="applyFilter($event)" placeholder="Search record..." />
|
||||||
|
<mat-icon matSuffix>search</mat-icon>
|
||||||
|
</mat-form-field>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="actions-bar">
|
||||||
|
<mat-slide-toggle (change)="toggleShowInactiveData()" *ngIf="isParamRecord" [disabled]="paramData.length === 0">
|
||||||
|
<div class="icon-text">Show Inactive Records</div>
|
||||||
|
</mat-slide-toggle>
|
||||||
|
|
||||||
|
<button mat-raised-button color="primary" (click)="addNewParam()">
|
||||||
|
<mat-icon>add</mat-icon>
|
||||||
|
Add New Record
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="results-section">
|
||||||
|
<div class="loading-shade" *ngIf="isLoading">
|
||||||
|
<mat-spinner diameter="50"></mat-spinner>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<table mat-table [dataSource]="dataSource" matSort>
|
||||||
|
|
||||||
|
<!-- PARAMTYPE Column -->
|
||||||
|
<ng-container matColumnDef="ParamType">
|
||||||
|
<th mat-header-cell *matHeaderCellDef mat-sort-header>Type</th>
|
||||||
|
<td mat-cell *matCellDef="let client">{{ client.paramType }}</td>
|
||||||
|
</ng-container>
|
||||||
|
|
||||||
|
<!-- PARAMDESC Column -->
|
||||||
|
<ng-container matColumnDef="ParamDesc">
|
||||||
|
<th mat-header-cell *matHeaderCellDef mat-sort-header>Description</th>
|
||||||
|
<td mat-cell *matCellDef="let client">{{ client.paramDesc || '--'}}</td>
|
||||||
|
</ng-container>
|
||||||
|
|
||||||
|
<!-- PARAMVALUE Column -->
|
||||||
|
<ng-container matColumnDef="paramvalue">
|
||||||
|
<th mat-header-cell *matHeaderCellDef mat-sort-header>Value</th>
|
||||||
|
<td mat-cell *matCellDef="let client">{{ client.paramValue }}</td>
|
||||||
|
</ng-container>
|
||||||
|
|
||||||
|
<!-- ADDLPARAMVALUE1 Column -->
|
||||||
|
<ng-container matColumnDef="addlparamvalue1">
|
||||||
|
<th mat-header-cell *matHeaderCellDef mat-sort-header>Additional Value 1</th>
|
||||||
|
<td mat-cell *matCellDef="let client">{{ client.addlParamValue1 || '--' }}</td>
|
||||||
|
</ng-container>
|
||||||
|
|
||||||
|
<!-- ADDLPARAMVALUE2 Column -->
|
||||||
|
<ng-container matColumnDef="addlparamvalue2">
|
||||||
|
<th mat-header-cell *matHeaderCellDef mat-sort-header>Additional Value 2</th>
|
||||||
|
<td mat-cell *matCellDef="let client">{{ client.addlParamValue2 || '--'}}</td>
|
||||||
|
</ng-container>
|
||||||
|
|
||||||
|
<!-- ADDLPARAMVALUE3 Column -->
|
||||||
|
<ng-container matColumnDef="addlparamvalue3">
|
||||||
|
<th mat-header-cell *matHeaderCellDef mat-sort-header>Additional Value 3</th>
|
||||||
|
<td mat-cell *matCellDef="let client">{{ client.addlParamValue3 || '--' }}</td>
|
||||||
|
</ng-container>
|
||||||
|
|
||||||
|
<!-- ADDLPARAMVALUE4 Column -->
|
||||||
|
<ng-container matColumnDef="addlparamvalue4">
|
||||||
|
<th mat-header-cell *matHeaderCellDef mat-sort-header>Additional Value 4</th>
|
||||||
|
<td mat-cell *matCellDef="let client">{{ client.addlParamValue4 || '--' }}</td>
|
||||||
|
</ng-container>
|
||||||
|
|
||||||
|
<!-- ADDLPARAMVALUE5 Column -->
|
||||||
|
<ng-container matColumnDef="addlparamvalue5">
|
||||||
|
<th mat-header-cell *matHeaderCellDef mat-sort-header>Additional Value 5</th>
|
||||||
|
<td mat-cell *matCellDef="let client">{{ client.addlParamValue5 || '--'}}</td>
|
||||||
|
</ng-container>
|
||||||
|
|
||||||
|
<!-- Actions Column -->
|
||||||
|
<ng-container matColumnDef="actions">
|
||||||
|
<th mat-header-cell *matHeaderCellDef class="actions-header">Actions</th>
|
||||||
|
<td mat-cell *matCellDef="let client" class="actions-cell">
|
||||||
|
<div class="action-container">
|
||||||
|
<button mat-icon-button color="primary" *ngIf="!isParamRecord"
|
||||||
|
(click)="onRecordClick(client?.paramValue , client?.paramDesc )"
|
||||||
|
[matTooltip]="client.paramDesc ">
|
||||||
|
<mat-icon>chevron_right</mat-icon>
|
||||||
|
</button>
|
||||||
|
|
||||||
|
<button mat-icon-button color="primary" *ngIf="isParamRecord" (click)="onEditParam(client)"
|
||||||
|
[matTooltip]="'edit'">
|
||||||
|
<mat-icon>edit</mat-icon>
|
||||||
|
</button>
|
||||||
|
|
||||||
|
<button mat-icon-button color="warn"
|
||||||
|
*ngIf="isParamRecord && (client.inactiveCodeFlag === 'N' || !client.inactiveCodeFlag)"
|
||||||
|
matTooltip="Inactivate" (click)="inActivateParamRecord(client.paramId)">
|
||||||
|
<mat-icon>delete</mat-icon>
|
||||||
|
</button>
|
||||||
|
|
||||||
|
<button mat-icon-button color="warn" *ngIf="(isParamRecord) && client.inactiveCodeFlag === 'Y'"
|
||||||
|
matTooltip="Reactivate" (click)="reActivateParamRecord(client.paramId)">
|
||||||
|
<mat-icon>delete_outline</mat-icon>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
|
</ng-container>
|
||||||
|
|
||||||
|
<tr mat-header-row *matHeaderRowDef="displayedColumns"></tr>
|
||||||
|
<tr mat-row *matRowDef="let row; columns: displayedColumns;"></tr>
|
||||||
|
|
||||||
|
<tr matNoDataRow *matNoDataRow>
|
||||||
|
<td [attr.colspan]="displayedColumns.length" class="no-data-message">
|
||||||
|
<mat-icon>info</mat-icon>
|
||||||
|
<span>No records found matching your criteria</span>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
<mat-paginator [length]="dataSource.data.length" [pageSizeOptions]="[userPreferences.pageSize || 2]"
|
||||||
|
[hidePageSize]="true" showFirstLastButtons></mat-paginator>
|
||||||
|
</div>
|
||||||
|
<!-- Contact Form -->
|
||||||
|
<div class="form-container" *ngIf="showForm">
|
||||||
|
<form [formGroup]="paramForm" (ngSubmit)="saveRecord()">
|
||||||
|
<div class="form-header">
|
||||||
|
<h3> {{ !isParamRecord ? 'Add New Table' : isEditing ? `Edit Parameter` :
|
||||||
|
`Add New Parameter`}}
|
||||||
|
</h3>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-row">
|
||||||
|
<mat-form-field appearance="outline" *ngIf="isParamRecord">
|
||||||
|
<mat-label>Param Type</mat-label>
|
||||||
|
<input matInput formControlName="paramType" readonly required>
|
||||||
|
<mat-error *ngIf="paramForm.get('paramType')?.errors?.['required']">
|
||||||
|
Param Type is required
|
||||||
|
</mat-error>
|
||||||
|
<mat-error *ngIf="paramForm.get('paramType')?.errors?.['maxlength']">
|
||||||
|
Maximum 10 characters allowed
|
||||||
|
</mat-error>
|
||||||
|
</mat-form-field>
|
||||||
|
|
||||||
|
<mat-form-field appearance="outline">
|
||||||
|
<mat-label>{{!isParamRecord ? 'Description' : 'Description'}}</mat-label>
|
||||||
|
<input matInput formControlName="paramDesc" required>
|
||||||
|
<mat-error *ngIf="paramForm.get('paramDesc')?.errors?.['required']">
|
||||||
|
{{!isParamRecord ? 'Table Description' : 'Param Description'}} is required
|
||||||
|
</mat-error>
|
||||||
|
<mat-error *ngIf="paramForm.get('paramDesc')?.errors?.['maxlength']">
|
||||||
|
Maximum 100 characters allowed
|
||||||
|
</mat-error>
|
||||||
|
</mat-form-field>
|
||||||
|
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-row">
|
||||||
|
|
||||||
|
<mat-form-field appearance="outline" *ngIf="isParamRecord">
|
||||||
|
<mat-label>Value</mat-label>
|
||||||
|
<input matInput formControlName="paramValue" [readonly]="isEditing" required>
|
||||||
|
<mat-error *ngIf="paramForm.get('paramValue')?.errors?.['required']">
|
||||||
|
Param Value is required
|
||||||
|
</mat-error>
|
||||||
|
<mat-error *ngIf="paramForm.get('paramValue')?.errors?.['maxlength']">
|
||||||
|
Maximum 20 characters allowed
|
||||||
|
</mat-error>
|
||||||
|
</mat-form-field>
|
||||||
|
|
||||||
|
<mat-form-field appearance="outline" *ngIf="isParamRecord">
|
||||||
|
<mat-label>Additional Value 1</mat-label>
|
||||||
|
<input matInput formControlName="addlParamValue1">
|
||||||
|
<mat-error *ngIf="paramForm.get('addlParamValue1')?.errors?.['maxlength']">
|
||||||
|
Maximum 20 characters allowed
|
||||||
|
</mat-error>
|
||||||
|
</mat-form-field>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-row">
|
||||||
|
|
||||||
|
<mat-form-field appearance="outline" *ngIf="isParamRecord">
|
||||||
|
<mat-label>Additional Value 2</mat-label>
|
||||||
|
<input matInput formControlName="addlParamValue2">
|
||||||
|
<mat-error *ngIf="paramForm.get('addlParamValue2')?.errors?.['maxlength']">
|
||||||
|
Maximum 20 characters allowed
|
||||||
|
</mat-error>
|
||||||
|
</mat-form-field>
|
||||||
|
|
||||||
|
<mat-form-field appearance="outline" *ngIf="isParamRecord">
|
||||||
|
<mat-label>Additional Value 3</mat-label>
|
||||||
|
<input matInput formControlName="addlParamValue3">
|
||||||
|
<mat-error *ngIf="paramForm.get('addlParamValue3')?.errors?.['maxlength']">
|
||||||
|
Maximum 20 characters allowed
|
||||||
|
</mat-error>
|
||||||
|
</mat-form-field>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-row">
|
||||||
|
|
||||||
|
<mat-form-field appearance="outline" *ngIf="isParamRecord">
|
||||||
|
<mat-label>Additional Value 4</mat-label>
|
||||||
|
<input matInput formControlName="addlParamValue4">
|
||||||
|
<mat-error *ngIf="paramForm.get('addlParamValue4')?.errors?.['maxlength']">
|
||||||
|
Maximum 20 characters allowed
|
||||||
|
</mat-error>
|
||||||
|
</mat-form-field>
|
||||||
|
|
||||||
|
<mat-form-field appearance="outline" *ngIf="isParamRecord">
|
||||||
|
<mat-label>Additional Value 5</mat-label>
|
||||||
|
<input matInput formControlName="addlParamValue5">
|
||||||
|
<mat-error *ngIf="paramForm.get('addlParamValue5')?.errors?.['maxlength']">
|
||||||
|
Maximum 20 characters allowed
|
||||||
|
</mat-error>
|
||||||
|
</mat-form-field>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<div *ngIf="isEditing" class="readonly-section">
|
||||||
|
<div class="readonly-fields">
|
||||||
|
<div class="field-column">
|
||||||
|
<!-- Last Changed By -->
|
||||||
|
<div class="readonly-field">
|
||||||
|
<label>Last Changed By</label>
|
||||||
|
<div class="readonly-value">
|
||||||
|
{{paramReadOnlyFields.lastChangedBy || 'N/A'}}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<!-- Inactive status -->
|
||||||
|
<div class="readonly-field">
|
||||||
|
<label>Inactive Status </label>
|
||||||
|
<div class="readonly-value">
|
||||||
|
{{paramReadOnlyFields.isInactive === true ? 'Yes' : 'No' }}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="field-column">
|
||||||
|
|
||||||
|
<!-- Last Changed Date -->
|
||||||
|
<div class="readonly-field">
|
||||||
|
<label>Last Changed Date</label>
|
||||||
|
<div class="readonly-value">
|
||||||
|
{{(paramReadOnlyFields.lastChangedDate | date:'mediumDate':'UTC') || 'N/A'}}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Inactivated Date -->
|
||||||
|
<div class="readonly-field">
|
||||||
|
<label>Inactivated Date</label>
|
||||||
|
<div class="readonly-value">
|
||||||
|
{{(paramReadOnlyFields.inactivatedDate | date:'mediumDate':'UTC') || 'N/A'}}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-actions">
|
||||||
|
<button mat-raised-button color="primary" type="submit"
|
||||||
|
[disabled]="paramForm.invalid || changeInProgress">
|
||||||
|
{{ isEditing ? 'Update' : 'Save' }}
|
||||||
|
</button>
|
||||||
|
<button mat-button type="button" (click)="cancelEdit()">Cancel</button>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
185
src/app/param/table/param-table.component.scss
Normal file
185
src/app/param/table/param-table.component.scss
Normal file
@ -0,0 +1,185 @@
|
|||||||
|
.page-header {
|
||||||
|
margin: 0.5rem 0px;
|
||||||
|
color: var(--mat-sys-primary);
|
||||||
|
font-weight: 500;
|
||||||
|
}
|
||||||
|
|
||||||
|
.manage-container {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 0.5rem;
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.actions-bar {
|
||||||
|
clear: both;
|
||||||
|
|
||||||
|
mat-slide-toggle {
|
||||||
|
transform: scale(0.8);
|
||||||
|
margin-left: -1rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
button {
|
||||||
|
float: right;
|
||||||
|
}
|
||||||
|
|
||||||
|
.icon-text {
|
||||||
|
padding-left: 10px !important;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.form-container {
|
||||||
|
background-color: white;
|
||||||
|
padding: 24px;
|
||||||
|
border-radius: 8px;
|
||||||
|
margin-top: 16px;
|
||||||
|
|
||||||
|
.form-header {
|
||||||
|
margin-bottom: 24px;
|
||||||
|
|
||||||
|
h3 {
|
||||||
|
margin: 0;
|
||||||
|
color: var(--mat-sys-primary);
|
||||||
|
font-weight: 500;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
form {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 16px;
|
||||||
|
|
||||||
|
.form-row {
|
||||||
|
display: flex;
|
||||||
|
gap: 16px;
|
||||||
|
align-items: start;
|
||||||
|
|
||||||
|
mat-form-field {
|
||||||
|
flex: 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
.small-field {
|
||||||
|
max-width: 120px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.form-actions {
|
||||||
|
display: flex;
|
||||||
|
justify-content: flex-end;
|
||||||
|
gap: 16px;
|
||||||
|
margin-top: 16px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.readonly-section {
|
||||||
|
padding-top: 0.5rem;
|
||||||
|
border-top: 1px solid #eee;
|
||||||
|
|
||||||
|
.readonly-fields {
|
||||||
|
display: flex;
|
||||||
|
gap: 2rem;
|
||||||
|
|
||||||
|
.field-column {
|
||||||
|
flex: 1;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 1.5rem;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.readonly-field {
|
||||||
|
label {
|
||||||
|
display: block;
|
||||||
|
font-size: 0.875rem;
|
||||||
|
color: #666;
|
||||||
|
margin-bottom: 0.25rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.readonly-value {
|
||||||
|
padding: 0.25rem;
|
||||||
|
font-size: 0.875rem;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.results-section {
|
||||||
|
position: relative;
|
||||||
|
overflow: auto;
|
||||||
|
border-radius: 8px;
|
||||||
|
|
||||||
|
.loading-shade {
|
||||||
|
position: absolute;
|
||||||
|
top: 0;
|
||||||
|
left: 0;
|
||||||
|
right: 0;
|
||||||
|
bottom: 0;
|
||||||
|
background: rgba(255, 255, 255, 0.7);
|
||||||
|
z-index: 1;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
mat-table {
|
||||||
|
width: 100%;
|
||||||
|
|
||||||
|
mat-icon {
|
||||||
|
cursor: pointer;
|
||||||
|
transition: all 0.2s ease;
|
||||||
|
|
||||||
|
&:hover {
|
||||||
|
transform: scale(1.1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.mat-column-actions {
|
||||||
|
width: 180px;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.mat-column-defaultContact {
|
||||||
|
width: 80px;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.no-data-message {
|
||||||
|
text-align: center;
|
||||||
|
padding: 0.9rem;
|
||||||
|
color: rgba(0, 0, 0, 0.54);
|
||||||
|
|
||||||
|
mat-icon {
|
||||||
|
font-size: 0.875rem;
|
||||||
|
width: 1rem;
|
||||||
|
height: 1rem;
|
||||||
|
margin-bottom: -3px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
mat-paginator {
|
||||||
|
border-top: 1px solid rgba(0, 0, 0, 0.12);
|
||||||
|
border-radius: 0 0 8px 8px;
|
||||||
|
padding-top: 4px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.action-container {
|
||||||
|
display: flex !important;
|
||||||
|
justify-content: center !important;
|
||||||
|
align-items: center !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.search-bar {
|
||||||
|
display: flex;
|
||||||
|
width: 100%;
|
||||||
|
margin-top: 10px;
|
||||||
|
|
||||||
|
|
||||||
|
.full-width {
|
||||||
|
flex: 1;
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
}
|
||||||
269
src/app/param/table/param-table.component.ts
Normal file
269
src/app/param/table/param-table.component.ts
Normal file
@ -0,0 +1,269 @@
|
|||||||
|
import { Component, inject, Input, ViewChild } from '@angular/core';
|
||||||
|
import { AngularMaterialModule } from '../../shared/module/angular-material.module';
|
||||||
|
import { FormBuilder, FormGroup, ReactiveFormsModule, Validators } from '@angular/forms';
|
||||||
|
import { CommonModule } from '@angular/common';
|
||||||
|
import { MatPaginator } from '@angular/material/paginator';
|
||||||
|
import { MatSort } from '@angular/material/sort';
|
||||||
|
import { UserPreferences } from '../../core/models/user-preference';
|
||||||
|
import { UserPreferencesService } from '../../core/services/user-preference.service';
|
||||||
|
import { MatTableDataSource } from '@angular/material/table';
|
||||||
|
import { MatSlideToggleModule } from '@angular/material/slide-toggle';
|
||||||
|
import { NavigationService } from '../../core/services/common/navigation.service';
|
||||||
|
import { ActivatedRoute } from '@angular/router';
|
||||||
|
import { ParamService } from '../../core/services/param/param.service';
|
||||||
|
import { ParamProperties } from '../../core/models/param/parameters';
|
||||||
|
import { ApiErrorHandlerService } from '../../core/services/common/api-error-handler.service';
|
||||||
|
import { NotificationService } from '../../core/services/common/notification.service';
|
||||||
|
import { TABLE_MODE } from '../../core/models/param/types';
|
||||||
|
import { ProperCasePipe } from '../../shared/pipes/proper-case.pipe';
|
||||||
|
import { finalize } from 'rxjs';
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
selector: 'app-param-table',
|
||||||
|
imports: [AngularMaterialModule, ReactiveFormsModule, CommonModule, MatSlideToggleModule, ProperCasePipe],
|
||||||
|
templateUrl: './param-table.component.html',
|
||||||
|
styleUrl: './param-table.component.scss'
|
||||||
|
})
|
||||||
|
export class ParamTableComponent {
|
||||||
|
@ViewChild(MatPaginator) paginator!: MatPaginator;
|
||||||
|
@ViewChild(MatSort) sort!: MatSort;
|
||||||
|
|
||||||
|
@Input() table_mode: TABLE_MODE = 'TABLE-RECORD';
|
||||||
|
@Input() paramHeading: string = 'Table Records';
|
||||||
|
|
||||||
|
isLoading: boolean = false;
|
||||||
|
changeInProgress: boolean = false;
|
||||||
|
userPreferences: UserPreferences;
|
||||||
|
paramType: string | null = null;
|
||||||
|
paramData: any = [];
|
||||||
|
showInactiveData: boolean = false;
|
||||||
|
isEditing: boolean = false;
|
||||||
|
showForm: boolean = false;
|
||||||
|
currentParamid: number | null = null;
|
||||||
|
|
||||||
|
paramReadOnlyFields: any = {
|
||||||
|
lastChangedDate: null,
|
||||||
|
lastChangedBy: null,
|
||||||
|
isInactive: null,
|
||||||
|
inactivatedDate: null
|
||||||
|
};
|
||||||
|
|
||||||
|
private paramService = inject(ParamService);
|
||||||
|
private errorHandler = inject(ApiErrorHandlerService);
|
||||||
|
private notificationService = inject(NotificationService);
|
||||||
|
|
||||||
|
dataSource = new MatTableDataSource<any>([]);
|
||||||
|
paramForm: FormGroup;
|
||||||
|
|
||||||
|
ngAfterViewInit() {
|
||||||
|
this.dataSource.paginator = this.paginator;
|
||||||
|
this.dataSource.sort = this.sort;
|
||||||
|
this.dataSource.data = this.paramData;
|
||||||
|
}
|
||||||
|
|
||||||
|
displayedColumns: string[] = ['ParamType', 'ParamDesc', 'paramvalue', 'addlparamvalue1', 'addlparamvalue2', 'addlparamvalue3',
|
||||||
|
'addlparamvalue4', 'addlparamvalue5', 'actions'];
|
||||||
|
|
||||||
|
formControls: any = {};
|
||||||
|
|
||||||
|
getForm(): void {
|
||||||
|
if (this.table_mode === 'PARAM-RECORD') {
|
||||||
|
this.formControls = {
|
||||||
|
paramType: ['', [Validators.required, Validators.maxLength(10)]],
|
||||||
|
paramValue: ['', [Validators.required, Validators.maxLength(20)]],
|
||||||
|
paramDesc: ['', [Validators.required, Validators.maxLength(100)]],
|
||||||
|
addlParamValue1: ['', [Validators.maxLength(20)]],
|
||||||
|
addlParamValue2: ['', [Validators.maxLength(20)]],
|
||||||
|
addlParamValue3: ['', [Validators.maxLength(20)]],
|
||||||
|
addlParamValue4: ['', [Validators.maxLength(20)]],
|
||||||
|
addlParamValue5: ['', [Validators.maxLength(20)]],
|
||||||
|
};
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
this.formControls = {
|
||||||
|
paramDesc: ['', [Validators.required, Validators.maxLength(100)]],
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
applyFilter(event: Event) {
|
||||||
|
const filterValue = (event.target as HTMLInputElement).value;
|
||||||
|
this.dataSource.filter = filterValue.trim().toLowerCase();
|
||||||
|
}
|
||||||
|
|
||||||
|
get isParamRecord(): boolean {
|
||||||
|
return this.table_mode === 'PARAM-RECORD';
|
||||||
|
}
|
||||||
|
|
||||||
|
constructor(
|
||||||
|
private userPrefenceService: UserPreferencesService,
|
||||||
|
private navigationService: NavigationService,
|
||||||
|
private fb: FormBuilder,
|
||||||
|
) {
|
||||||
|
this.userPreferences = this.userPrefenceService.getPreferences();
|
||||||
|
this.getForm();
|
||||||
|
this.paramForm = this.fb.group(this.formControls);
|
||||||
|
}
|
||||||
|
|
||||||
|
cancelEdit(): void {
|
||||||
|
this.showForm = false;
|
||||||
|
this.isEditing = false;
|
||||||
|
this.currentParamid = null;
|
||||||
|
this.paramForm.reset();
|
||||||
|
}
|
||||||
|
|
||||||
|
private route = inject(ActivatedRoute);
|
||||||
|
|
||||||
|
ngOnInit(): void {
|
||||||
|
this.paramType = this.route.snapshot.paramMap.get('id');
|
||||||
|
this.getParameters();
|
||||||
|
}
|
||||||
|
|
||||||
|
toggleShowInactiveData(): void {
|
||||||
|
this.showInactiveData = !this.showInactiveData;
|
||||||
|
this.renderParamData();
|
||||||
|
}
|
||||||
|
|
||||||
|
onRecordClick(id: string, paramDesc: string): void {
|
||||||
|
this.navigationService.navigate(['param-record', id], { queryParams: { param: paramDesc } });
|
||||||
|
}
|
||||||
|
|
||||||
|
addNewParam(): void {
|
||||||
|
this.getForm();
|
||||||
|
this.paramForm = this.fb.group(this.formControls);
|
||||||
|
this.showForm = true;
|
||||||
|
this.isEditing = false;
|
||||||
|
this.currentParamid = null;
|
||||||
|
this.paramForm.reset();
|
||||||
|
this.paramForm.get('paramType')?.setValue(this.paramType);
|
||||||
|
}
|
||||||
|
|
||||||
|
onEditParam(param: any): void {
|
||||||
|
this.getForm();
|
||||||
|
this.paramForm = this.fb.group(this.formControls);
|
||||||
|
|
||||||
|
this.showForm = true;
|
||||||
|
this.isEditing = true;
|
||||||
|
this.currentParamid = param.paramId;
|
||||||
|
this.paramForm.patchValue({
|
||||||
|
paramType: param.paramType,
|
||||||
|
paramValue: param.paramValue,
|
||||||
|
paramDesc: param.paramDesc,
|
||||||
|
addlParamValue1: param.addlParamValue1,
|
||||||
|
addlParamValue2: param.addlParamValue2,
|
||||||
|
addlParamValue3: param.addlParamValue3,
|
||||||
|
addlParamValue4: param.addlParamValue4,
|
||||||
|
addlParamValue5: param.addlParamValue5
|
||||||
|
});
|
||||||
|
|
||||||
|
this.paramForm.get('paramType')?.setValue(this.paramType);
|
||||||
|
|
||||||
|
this.paramReadOnlyFields.lastChangedDate = param.lastUpdatedDate ?? param.dateCreated;
|
||||||
|
this.paramReadOnlyFields.lastChangedBy = param.lastUpdatedBy ?? param.createdBy;
|
||||||
|
this.paramReadOnlyFields.isInactive = param.inactiveCodeFlag === 'N' || !param.inactiveCodeFlag ? 'No' : 'Yes';
|
||||||
|
this.paramReadOnlyFields.inactivatedDate = param.inactiveDate;
|
||||||
|
}
|
||||||
|
|
||||||
|
renderParamData() {
|
||||||
|
if (this.showInactiveData && this.table_mode === 'PARAM-RECORD') {
|
||||||
|
this.dataSource.data = this.paramData.filter((data: any) => data?.inactiveCodeFlag === 'Y');
|
||||||
|
}
|
||||||
|
else if (!this.showInactiveData && this.table_mode === 'PARAM-RECORD') {
|
||||||
|
this.dataSource.data = this.paramData.filter((data: any) => data?.inactiveCodeFlag === 'N' || data?.inactiveCodeFlag === null);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
this.dataSource.data = this.paramData;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
getParameters(): void {
|
||||||
|
|
||||||
|
this.isLoading = true;
|
||||||
|
|
||||||
|
const P_PARAMTYPE: string = this.paramType ? this.paramType : '000';
|
||||||
|
|
||||||
|
this.paramService.getParameters(P_PARAMTYPE).pipe(finalize(() => {
|
||||||
|
this.isLoading = false;
|
||||||
|
})).subscribe({
|
||||||
|
next: (paramData: ParamProperties[]) => {
|
||||||
|
this.paramData = paramData;
|
||||||
|
this.renderParamData();
|
||||||
|
},
|
||||||
|
error: (error: any) => {
|
||||||
|
let errorMessage = this.errorHandler.handleApiError(error, 'Failed to search preparers');
|
||||||
|
this.notificationService.showError(errorMessage);
|
||||||
|
console.error('Error loading preparers:', error);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
saveRecord(): void {
|
||||||
|
if (this.paramForm.invalid) {
|
||||||
|
this.paramForm.markAllAsTouched();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const paramData: ParamProperties = this.paramForm.value;
|
||||||
|
|
||||||
|
paramData.paramId = this.currentParamid ?? 0;
|
||||||
|
paramData.sortSeq = 1;
|
||||||
|
|
||||||
|
const saveObservable = this.table_mode === 'TABLE-RECORD' ?
|
||||||
|
this.paramService.createTableRecord(this.paramForm.value.paramDesc)
|
||||||
|
:
|
||||||
|
this.isEditing
|
||||||
|
? this.paramService.updateParamRecord(paramData as ParamProperties)
|
||||||
|
: this.paramService.createParamRecord(paramData as ParamProperties);
|
||||||
|
|
||||||
|
this.changeInProgress = true;
|
||||||
|
saveObservable.pipe(finalize(() => {
|
||||||
|
this.changeInProgress = false;
|
||||||
|
})).subscribe({
|
||||||
|
next: () => {
|
||||||
|
this.notificationService.showSuccess(`Record ${this.isEditing && (this.table_mode !== 'TABLE-RECORD') ? 'updated' : 'added'} successfully`);
|
||||||
|
this.getParameters();
|
||||||
|
if (this.table_mode === 'PARAM-RECORD') {
|
||||||
|
this.cancelEdit();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
error: (error) => {
|
||||||
|
let errorMessage = this.errorHandler.handleApiError(error, `Failed to ${this.isEditing && (this.table_mode !== 'TABLE-RECORD') ? 'update' : 'add'} Record`);
|
||||||
|
this.notificationService.showError(errorMessage);
|
||||||
|
console.error('Error saving Record:', error);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
inActivateParamRecord(paramId: number): void {
|
||||||
|
this.paramService.inActivateParamRecord(paramId).subscribe(
|
||||||
|
{
|
||||||
|
next: (data: any) => {
|
||||||
|
this.notificationService.showSuccess(`Param Inactivated successfully`);
|
||||||
|
this.getParameters();
|
||||||
|
},
|
||||||
|
error: (error: any) => {
|
||||||
|
let errorMessage = this.errorHandler.handleApiError(error, `Failed to Inactivate Param`);
|
||||||
|
this.notificationService.showError(errorMessage);
|
||||||
|
console.error('Error Inactivating Param:', error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
reActivateParamRecord(paramId: number): void {
|
||||||
|
this.paramService.reActivateParamRecord(paramId).subscribe(
|
||||||
|
{
|
||||||
|
next: (data: any) => {
|
||||||
|
this.notificationService.showSuccess(`Param Reactivated successfully`);
|
||||||
|
this.getParameters();
|
||||||
|
},
|
||||||
|
error: (error: any) => {
|
||||||
|
let errorMessage = this.errorHandler.handleApiError(error, `Failed to Reactivate Param`);
|
||||||
|
this.notificationService.showError(errorMessage);
|
||||||
|
console.error('Error Reactivating Param:', error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -7,7 +7,7 @@
|
|||||||
<ng-template matStepLabel>Basic Details</ng-template>
|
<ng-template matStepLabel>Basic Details</ng-template>
|
||||||
|
|
||||||
<app-basic-details [isEditMode]="isEditMode" (clientidCreated)="onBasicDetailsSaved($event)"
|
<app-basic-details [isEditMode]="isEditMode" (clientidCreated)="onBasicDetailsSaved($event)"
|
||||||
(showLocations)="onShowLocations($event)"(locationAdded)="onLocationAdded($event)">
|
(showLocations)="onShowLocations($event)" (locationAdded)="onLocationAdded($event)">
|
||||||
</app-basic-details>
|
</app-basic-details>
|
||||||
</mat-step>
|
</mat-step>
|
||||||
|
|
||||||
@ -16,8 +16,7 @@
|
|||||||
<ng-template matStepLabel>Locations</ng-template>
|
<ng-template matStepLabel>Locations</ng-template>
|
||||||
|
|
||||||
<app-location *ngIf="clientid" [clientid]="clientid" (hasLocations)="onLocationSaved($event)"
|
<app-location *ngIf="clientid" [clientid]="clientid" (hasLocations)="onLocationSaved($event)"
|
||||||
(updated)="onLocationUpdated($event)" [userPreferences]="userPreferences"
|
(updated)="onLocationUpdated($event)" [userPreferences]="userPreferences">
|
||||||
[refreshLocationData]="refreshLocationData">
|
|
||||||
</app-location>
|
</app-location>
|
||||||
</mat-step>
|
</mat-step>
|
||||||
|
|
||||||
@ -26,7 +25,7 @@
|
|||||||
<ng-template matStepLabel>Contacts</ng-template>
|
<ng-template matStepLabel>Contacts</ng-template>
|
||||||
|
|
||||||
<app-contacts *ngIf="clientid" [clientid]="clientid" (hasContacts)="onContactsSaved($event)"
|
<app-contacts *ngIf="clientid" [clientid]="clientid" (hasContacts)="onContactsSaved($event)"
|
||||||
[userPreferences]="userPreferences" [refreshLocationData]="refreshLocationData">
|
[userPreferences]="userPreferences">
|
||||||
</app-contacts>
|
</app-contacts>
|
||||||
</mat-step>
|
</mat-step>
|
||||||
|
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
import { Component, inject } from '@angular/core';
|
import { Component, inject, ViewChild } from '@angular/core';
|
||||||
import { AngularMaterialModule } from '../../shared/module/angular-material.module';
|
import { AngularMaterialModule } from '../../shared/module/angular-material.module';
|
||||||
import { CommonModule } from '@angular/common';
|
import { CommonModule } from '@angular/common';
|
||||||
import { UserPreferences } from '../../core/models/user-preference';
|
import { UserPreferences } from '../../core/models/user-preference';
|
||||||
@ -25,7 +25,12 @@ export class AddPreparerComponent {
|
|||||||
contactsCompleted: boolean = false;
|
contactsCompleted: boolean = false;
|
||||||
locationCompleted: boolean = false;
|
locationCompleted: boolean = false;
|
||||||
showLocation: boolean = false;
|
showLocation: boolean = false;
|
||||||
refreshLocationData: boolean = false;
|
|
||||||
|
@ViewChild(ContactsComponent, { static: false })
|
||||||
|
private contactsComponent!: ContactsComponent;
|
||||||
|
|
||||||
|
@ViewChild(LocationComponent, { static: false })
|
||||||
|
private locationComponent!: LocationComponent;
|
||||||
|
|
||||||
constructor(userPrefenceService: UserPreferencesService) {
|
constructor(userPrefenceService: UserPreferencesService) {
|
||||||
this.userPreferences = userPrefenceService.getPreferences();
|
this.userPreferences = userPrefenceService.getPreferences();
|
||||||
@ -45,7 +50,9 @@ export class AddPreparerComponent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
onLocationUpdated(event: boolean): void {
|
onLocationUpdated(event: boolean): void {
|
||||||
this.refreshLocationData = event;
|
if (event) {
|
||||||
|
this.contactsComponent?.refreshLocationData();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
onShowLocations(event: boolean): void {
|
onShowLocations(event: boolean): void {
|
||||||
@ -53,7 +60,10 @@ export class AddPreparerComponent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
onLocationAdded(event: boolean): void {
|
onLocationAdded(event: boolean): void {
|
||||||
this.refreshLocationData = event;
|
if (event) {
|
||||||
|
this.locationComponent?.refreshLocationData();
|
||||||
|
this.contactsComponent?.refreshLocationData();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
onStepChange(event: StepperSelectionEvent): void {
|
onStepChange(event: StepperSelectionEvent): void {
|
||||||
|
|||||||
@ -147,8 +147,9 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="form-actions">
|
<div class="form-actions">
|
||||||
<button mat-raised-button color="primary" type="submit" [disabled]="basicDetailsForm.invalid">
|
<button mat-raised-button color="primary" type="submit"
|
||||||
Save
|
[disabled]="basicDetailsForm.invalid || changeInProgress">
|
||||||
|
{{ isEditMode ? 'Update' : 'Save' }}
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
import { Component, EventEmitter, inject, Input, OnDestroy, OnInit, Output } from '@angular/core';
|
import { Component, EventEmitter, inject, Input, OnDestroy, OnInit, Output } from '@angular/core';
|
||||||
import { FormBuilder, FormGroup, ReactiveFormsModule, Validators } from '@angular/forms';
|
import { FormBuilder, FormGroup, ReactiveFormsModule, Validators } from '@angular/forms';
|
||||||
import { Subject, takeUntil } from 'rxjs';
|
import { finalize, Subject, takeUntil } from 'rxjs';
|
||||||
import { AngularMaterialModule } from '../../shared/module/angular-material.module';
|
import { AngularMaterialModule } from '../../shared/module/angular-material.module';
|
||||||
import { CommonModule } from '@angular/common';
|
import { CommonModule } from '@angular/common';
|
||||||
import { Country } from '../../core/models/country';
|
import { Country } from '../../core/models/country';
|
||||||
@ -35,6 +35,7 @@ export class BasicDetailsComponent implements OnInit, OnDestroy {
|
|||||||
states: State[] = [];
|
states: State[] = [];
|
||||||
|
|
||||||
isLoading = true;
|
isLoading = true;
|
||||||
|
changeInProgress = false;
|
||||||
countriesHasStates = ['US', 'CA', 'MX'];
|
countriesHasStates = ['US', 'CA', 'MX'];
|
||||||
|
|
||||||
private destroy$ = new Subject<void>();
|
private destroy$ = new Subject<void>();
|
||||||
@ -55,18 +56,18 @@ export class BasicDetailsComponent implements OnInit, OnDestroy {
|
|||||||
// this.spidCreated.emit(this.spid?.toString());
|
// this.spidCreated.emit(this.spid?.toString());
|
||||||
// Patch edit form data
|
// Patch edit form data
|
||||||
if (this.clientid > 0) {
|
if (this.clientid > 0) {
|
||||||
this.basicDetailService.getBasicDetailsById(this.clientid).subscribe({
|
this.basicDetailService.getBasicDetailsById(this.clientid).pipe(finalize(() => {
|
||||||
|
this.isLoading = false;
|
||||||
|
})).subscribe({
|
||||||
next: (basicDetail: BasicDetail) => {
|
next: (basicDetail: BasicDetail) => {
|
||||||
if (basicDetail?.clientid > 0) {
|
if (basicDetail?.clientid > 0) {
|
||||||
this.patchFormData(basicDetail);
|
this.patchFormData(basicDetail);
|
||||||
this.clientName.emit(basicDetail.name);
|
this.clientName.emit(basicDetail.name);
|
||||||
}
|
}
|
||||||
this.isLoading = false;
|
|
||||||
},
|
},
|
||||||
error: (error: any) => {
|
error: (error: any) => {
|
||||||
let errorMessage = this.errorHandler.handleApiError(error, 'Failed to load basic details');
|
let errorMessage = this.errorHandler.handleApiError(error, 'Failed to load basic details');
|
||||||
this.notificationService.showError(errorMessage);
|
this.notificationService.showError(errorMessage);
|
||||||
this.isLoading = false;
|
|
||||||
console.error('Error loading basic details:', error);
|
console.error('Error loading basic details:', error);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -97,7 +98,7 @@ export class BasicDetailsComponent implements OnInit, OnDestroy {
|
|||||||
}
|
}
|
||||||
|
|
||||||
loadLookupData(): void {
|
loadLookupData(): void {
|
||||||
this.commonService.getCountries(0)
|
this.commonService.getCountries()
|
||||||
.pipe(takeUntil(this.destroy$))
|
.pipe(takeUntil(this.destroy$))
|
||||||
.subscribe({
|
.subscribe({
|
||||||
next: (countries) => {
|
next: (countries) => {
|
||||||
@ -105,7 +106,6 @@ export class BasicDetailsComponent implements OnInit, OnDestroy {
|
|||||||
},
|
},
|
||||||
error: (error) => {
|
error: (error) => {
|
||||||
console.error('Failed to load countries', error);
|
console.error('Failed to load countries', error);
|
||||||
this.isLoading = false;
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -118,11 +118,9 @@ export class BasicDetailsComponent implements OnInit, OnDestroy {
|
|||||||
.subscribe({
|
.subscribe({
|
||||||
next: (regions) => {
|
next: (regions) => {
|
||||||
this.regions = regions;
|
this.regions = regions;
|
||||||
this.isLoading = false;
|
|
||||||
},
|
},
|
||||||
error: (error) => {
|
error: (error) => {
|
||||||
console.error('Failed to load regions', error);
|
console.error('Failed to load regions', error);
|
||||||
this.isLoading = false;
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -130,18 +128,17 @@ export class BasicDetailsComponent implements OnInit, OnDestroy {
|
|||||||
loadStates(country: string): void {
|
loadStates(country: string): void {
|
||||||
this.isLoading = true;
|
this.isLoading = true;
|
||||||
country = this.countriesHasStates.includes(country) ? country : 'FN';
|
country = this.countriesHasStates.includes(country) ? country : 'FN';
|
||||||
this.commonService.getStates(country, this.clientid)
|
this.commonService.getStates(country)
|
||||||
.pipe(takeUntil(this.destroy$))
|
.pipe(takeUntil(this.destroy$),
|
||||||
|
finalize(() => this.isLoading = false))
|
||||||
.subscribe({
|
.subscribe({
|
||||||
next: (states) => {
|
next: (states) => {
|
||||||
this.states = states;
|
this.states = states;
|
||||||
this.updateStateControl('state', country);
|
this.updateStateControl('state', country);
|
||||||
this.updateStateControl('revenueLocation', country);
|
this.updateStateControl('revenueLocation', country);
|
||||||
this.isLoading = false;
|
|
||||||
},
|
},
|
||||||
error: (error) => {
|
error: (error) => {
|
||||||
console.error('Failed to load states', error);
|
console.error('Failed to load states', error);
|
||||||
this.isLoading = false;
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -218,13 +215,18 @@ export class BasicDetailsComponent implements OnInit, OnDestroy {
|
|||||||
? this.basicDetailService.updateBasicDetails(this.clientid, basicDetailData)
|
? this.basicDetailService.updateBasicDetails(this.clientid, basicDetailData)
|
||||||
: this.basicDetailService.createBasicDetails(basicDetailData);
|
: this.basicDetailService.createBasicDetails(basicDetailData);
|
||||||
|
|
||||||
saveObservable.subscribe({
|
this.changeInProgress = true;
|
||||||
|
saveObservable.pipe(finalize(() => this.changeInProgress = false)).subscribe({
|
||||||
next: (basicData: any) => {
|
next: (basicData: any) => {
|
||||||
this.notificationService.showSuccess(`Basic details ${this.isEditMode ? 'updated' : 'added'} successfully`);
|
this.notificationService.showSuccess(`Basic details ${this.isEditMode ? 'updated' : 'added'} successfully`);
|
||||||
|
|
||||||
if (!this.isEditMode) {
|
if (!this.isEditMode) {
|
||||||
this.clientidCreated.emit(basicData.CLIENTID);
|
this.clientidCreated.emit(basicData.CLIENTID);
|
||||||
this.saveLocation(basicData.CLIENTID, basicDetailData);
|
this.saveLocation(basicData.CLIENTID, basicDetailData);
|
||||||
|
|
||||||
|
// change to edit mode after creation
|
||||||
|
this.isEditMode = true;
|
||||||
|
this.clientid = basicData.CLIENTID;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.isEditMode) {
|
if (this.isEditMode) {
|
||||||
|
|||||||
@ -69,7 +69,7 @@
|
|||||||
<mat-icon>edit</mat-icon>
|
<mat-icon>edit</mat-icon>
|
||||||
</button>
|
</button>
|
||||||
<button mat-icon-button color="primary" *ngIf="!contact.isInactive || !contact.hasLogin"
|
<button mat-icon-button color="primary" *ngIf="!contact.isInactive || !contact.hasLogin"
|
||||||
[hidden]="contact.isInactive || contact.hasLogin" (click)="createLogin(contact)"
|
[hidden]="contact.isInactive || contact.hasLogin" (click)="createLogin(contact.clientContactId)"
|
||||||
matTooltip="Login">
|
matTooltip="Login">
|
||||||
<mat-icon>person</mat-icon>
|
<mat-icon>person</mat-icon>
|
||||||
</button>
|
</button>
|
||||||
@ -269,53 +269,12 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="form-actions">
|
<div class="form-actions">
|
||||||
<button mat-raised-button color="primary" type="submit" [disabled]="contactForm.invalid">
|
<button mat-raised-button color="primary" type="submit"
|
||||||
|
[disabled]="contactForm.invalid || changeInProgress">
|
||||||
{{ isEditing ? 'Update' : 'Save' }}
|
{{ isEditing ? 'Update' : 'Save' }}
|
||||||
</button>
|
</button>
|
||||||
<button mat-button type="button" (click)="cancelEdit()">Cancel</button>
|
<button mat-button type="button" (click)="cancelEdit()">Cancel</button>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Contact Login Form -->
|
|
||||||
<div class="form-container" *ngIf="showLoginForm">
|
|
||||||
<!-- <form [formGroup]="contactLoginForm" (ngSubmit)="saveLogin()"> -->
|
|
||||||
<form>
|
|
||||||
<div class="form-header">
|
|
||||||
<h3>Create Login</h3>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div *ngIf="isEditing" class="readonly-section">
|
|
||||||
<div class="readonly-fields">
|
|
||||||
<div class="field-column">
|
|
||||||
<!-- Email -->
|
|
||||||
<div class="readonly-field">
|
|
||||||
<label>Email</label>
|
|
||||||
<div class="readonly-value">
|
|
||||||
{{contactLoginReadOnlyFields.email}}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<!--
|
|
||||||
<div class="form-row">
|
|
||||||
<mat-form-field appearance="outline">
|
|
||||||
<mat-label>Password</mat-label>
|
|
||||||
<input matInput formControlName="password" required>
|
|
||||||
<mat-icon matSuffix>lock</mat-icon>
|
|
||||||
<mat-error *ngIf="contactLoginForm.get('password')?.errors?.['required']">
|
|
||||||
Password is required
|
|
||||||
</mat-error>
|
|
||||||
</mat-form-field>
|
|
||||||
</div> -->
|
|
||||||
|
|
||||||
<div class="form-actions">
|
|
||||||
<button mat-raised-button color="primary" type="button" (click)="saveLogin()">
|
|
||||||
Create
|
|
||||||
</button>
|
|
||||||
<button mat-button type="button" (click)="cancelEdit()">Cancel</button>
|
|
||||||
</div>
|
|
||||||
</form>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
@ -1,4 +1,4 @@
|
|||||||
import { Component, EventEmitter, inject, Input, Output, SimpleChanges, ViewChild } from '@angular/core';
|
import { Component, EventEmitter, inject, Input, Output, ViewChild } from '@angular/core';
|
||||||
import { MatPaginator, MatPaginatorIntl } from '@angular/material/paginator';
|
import { MatPaginator, MatPaginatorIntl } from '@angular/material/paginator';
|
||||||
import { CustomPaginator } from '../../shared/custom-paginator';
|
import { CustomPaginator } from '../../shared/custom-paginator';
|
||||||
import { AngularMaterialModule } from '../../shared/module/angular-material.module';
|
import { AngularMaterialModule } from '../../shared/module/angular-material.module';
|
||||||
@ -17,6 +17,7 @@ import { ConfirmDialogComponent } from '../../shared/components/confirm-dialog/c
|
|||||||
import { ContactLogin } from '../../core/models/preparer/contact-login';
|
import { ContactLogin } from '../../core/models/preparer/contact-login';
|
||||||
import { LocationService } from '../../core/services/preparer/location.service';
|
import { LocationService } from '../../core/services/preparer/location.service';
|
||||||
import { Location } from '../../core/models/preparer/location';
|
import { Location } from '../../core/models/preparer/location';
|
||||||
|
import { finalize } from 'rxjs';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-contacts',
|
selector: 'app-contacts',
|
||||||
@ -32,12 +33,12 @@ export class ContactsComponent {
|
|||||||
displayedColumns: string[] = ['firstName', 'lastName', 'title', 'phone', 'mobile', 'email', 'defaultContact', 'actions'];
|
displayedColumns: string[] = ['firstName', 'lastName', 'title', 'phone', 'mobile', 'email', 'defaultContact', 'actions'];
|
||||||
dataSource = new MatTableDataSource<any>();
|
dataSource = new MatTableDataSource<any>();
|
||||||
contactForm: FormGroup;
|
contactForm: FormGroup;
|
||||||
// contactLoginForm: FormGroup;
|
// contactLoginForm: FormGroup;
|
||||||
isEditing = false;
|
isEditing = false;
|
||||||
currentContactId: number | null = null;
|
currentContactId: number | null = null;
|
||||||
isLoading = false;
|
isLoading = false;
|
||||||
|
changeInProgress = false;
|
||||||
showForm = false;
|
showForm = false;
|
||||||
showLoginForm = false
|
|
||||||
showInactiveContacts = false;
|
showInactiveContacts = false;
|
||||||
contacts: Contact[] = [];
|
contacts: Contact[] = [];
|
||||||
locations: Location[] = [];
|
locations: Location[] = [];
|
||||||
@ -55,7 +56,6 @@ export class ContactsComponent {
|
|||||||
|
|
||||||
@Input() clientid: number = 0;
|
@Input() clientid: number = 0;
|
||||||
@Input() userPreferences: UserPreferences = {};
|
@Input() userPreferences: UserPreferences = {};
|
||||||
@Input() refreshLocationData = false;
|
|
||||||
@Output() hasContacts = new EventEmitter<boolean>();
|
@Output() hasContacts = new EventEmitter<boolean>();
|
||||||
|
|
||||||
private fb = inject(FormBuilder);
|
private fb = inject(FormBuilder);
|
||||||
@ -71,9 +71,9 @@ export class ContactsComponent {
|
|||||||
lastName: ['', [Validators.required, Validators.maxLength(50)]],
|
lastName: ['', [Validators.required, Validators.maxLength(50)]],
|
||||||
middleInitial: ['', [Validators.maxLength(1)]],
|
middleInitial: ['', [Validators.maxLength(1)]],
|
||||||
title: ['', [Validators.required, Validators.maxLength(100)]],
|
title: ['', [Validators.required, Validators.maxLength(100)]],
|
||||||
phone: ['', [Validators.required, Validators.pattern(/^[0-9]{10,15}$/)]],
|
phone: ['', [Validators.required, Validators.pattern(/^[0-9\-\(\)]{10,15}$/)]],
|
||||||
mobile: ['', [Validators.required, Validators.pattern(/^[0-9]{10,15}$/)]],
|
mobile: ['', [Validators.required, Validators.pattern(/^[0-9\-\(\)]{10,15}$/)]],
|
||||||
fax: ['', [Validators.pattern(/^[0-9]{10,15}$/)]],
|
fax: ['', [Validators.pattern(/^[0-9\-\(\)]{10,15}$/)]],
|
||||||
email: ['', [Validators.required, Validators.email, Validators.maxLength(100)]],
|
email: ['', [Validators.required, Validators.email, Validators.maxLength(100)]],
|
||||||
locationid: [''],
|
locationid: [''],
|
||||||
defaultContact: [false]
|
defaultContact: [false]
|
||||||
@ -93,24 +93,19 @@ export class ContactsComponent {
|
|||||||
this.dataSource.sort = this.sort;
|
this.dataSource.sort = this.sort;
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnChanges(changes: SimpleChanges) {
|
public refreshLocationData() {
|
||||||
if (changes['refreshLocationData']) {
|
this.loadLocations();
|
||||||
this.loadLocations();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
loadLocations(): void {
|
loadLocations(): void {
|
||||||
this.isLoading = true;
|
|
||||||
this.locationService.getLocationsById(this.clientid).subscribe({
|
this.locationService.getLocationsById(this.clientid).subscribe({
|
||||||
next: (locations: Location[]) => {
|
next: (locations: Location[]) => {
|
||||||
this.locations = locations;
|
this.locations = locations;
|
||||||
this.loadContacts();
|
this.loadContacts();
|
||||||
this.isLoading = false;
|
|
||||||
},
|
},
|
||||||
error: (error: any) => {
|
error: (error: any) => {
|
||||||
let errorMessage = this.errorHandler.handleApiError(error, 'Failed to load locations');
|
let errorMessage = this.errorHandler.handleApiError(error, 'Failed to load locations');
|
||||||
this.notificationService.showError(errorMessage);
|
this.notificationService.showError(errorMessage);
|
||||||
this.isLoading = false;
|
|
||||||
console.error('Error loading locations:', error);
|
console.error('Error loading locations:', error);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -119,16 +114,16 @@ export class ContactsComponent {
|
|||||||
loadContacts(): void {
|
loadContacts(): void {
|
||||||
this.isLoading = true;
|
this.isLoading = true;
|
||||||
|
|
||||||
this.contactService.getContactsById(this.clientid).subscribe({
|
this.contactService.getContactsById(this.clientid).pipe(finalize(() => {
|
||||||
|
this.isLoading = false;
|
||||||
|
})).subscribe({
|
||||||
next: (contacts: Contact[]) => {
|
next: (contacts: Contact[]) => {
|
||||||
this.contacts = contacts;
|
this.contacts = contacts;
|
||||||
this.renderContacts();
|
this.renderContacts();
|
||||||
this.isLoading = false;
|
|
||||||
},
|
},
|
||||||
error: (error: any) => {
|
error: (error: any) => {
|
||||||
let errorMessage = this.errorHandler.handleApiError(error, 'Failed to load contacts');
|
let errorMessage = this.errorHandler.handleApiError(error, 'Failed to load contacts');
|
||||||
this.notificationService.showError(errorMessage);
|
this.notificationService.showError(errorMessage);
|
||||||
this.isLoading = false;
|
|
||||||
console.error('Error loading contacts:', error);
|
console.error('Error loading contacts:', error);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -136,7 +131,6 @@ export class ContactsComponent {
|
|||||||
|
|
||||||
addNewContact(): void {
|
addNewContact(): void {
|
||||||
this.showForm = true;
|
this.showForm = true;
|
||||||
this.showLoginForm = false;
|
|
||||||
this.isEditing = false;
|
this.isEditing = false;
|
||||||
this.currentContactId = null;
|
this.currentContactId = null;
|
||||||
this.contactForm.reset();
|
this.contactForm.reset();
|
||||||
@ -146,7 +140,6 @@ export class ContactsComponent {
|
|||||||
|
|
||||||
editContact(contact: Contact): void {
|
editContact(contact: Contact): void {
|
||||||
this.showForm = true;
|
this.showForm = true;
|
||||||
this.showLoginForm = false;
|
|
||||||
this.isEditing = true;
|
this.isEditing = true;
|
||||||
this.currentContactId = contact.clientContactId;
|
this.currentContactId = contact.clientContactId;
|
||||||
this.contactForm.patchValue({
|
this.contactForm.patchValue({
|
||||||
@ -184,7 +177,8 @@ export class ContactsComponent {
|
|||||||
? this.contactService.updateContact(this.currentContactId!, contactData)
|
? this.contactService.updateContact(this.currentContactId!, contactData)
|
||||||
: this.contactService.createContact(contactData);
|
: this.contactService.createContact(contactData);
|
||||||
|
|
||||||
saveObservable.subscribe({
|
this.changeInProgress = true;
|
||||||
|
saveObservable.pipe(finalize(() => this.changeInProgress = false)).subscribe({
|
||||||
next: () => {
|
next: () => {
|
||||||
this.notificationService.showSuccess(`Contact ${this.isEditing ? 'updated' : 'added'} successfully`);
|
this.notificationService.showSuccess(`Contact ${this.isEditing ? 'updated' : 'added'} successfully`);
|
||||||
this.loadContacts();
|
this.loadContacts();
|
||||||
@ -268,47 +262,44 @@ export class ContactsComponent {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
createLogin(contact: Contact): void {
|
createLogin(contactId: string): void {
|
||||||
this.showForm = false;
|
const dialogRef = this.dialog.open(ConfirmDialogComponent, {
|
||||||
this.showLoginForm = true;
|
width: '350px',
|
||||||
this.isEditing = true;
|
data: {
|
||||||
this.currentContactId = contact.clientContactId;
|
title: 'Confirm Login Creation',
|
||||||
|
message: 'Are you sure you want to create a login for this contact?',
|
||||||
|
confirmText: 'Yes',
|
||||||
|
cancelText: 'Cancel'
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
this.contactLoginReadOnlyFields.email = contact.email;
|
dialogRef.afterClosed().subscribe(result => {
|
||||||
}
|
if (result) {
|
||||||
|
const contactLoginData: ContactLogin = {
|
||||||
saveLogin(): void {
|
clientContactId: +contactId
|
||||||
// if (this.contactLoginForm.invalid) {
|
};
|
||||||
// this.contactLoginForm.markAllAsTouched();
|
this.contactService.createContactLogin(contactLoginData).subscribe({
|
||||||
// return;
|
next: () => {
|
||||||
// }
|
this.notificationService.showSuccess(`Login created successfully`);
|
||||||
|
this.loadContacts();
|
||||||
const contactLoginData: ContactLogin = {
|
this.cancelEdit();
|
||||||
clientContactId: this.currentContactId!,
|
},
|
||||||
// password: this.contactLoginForm.value.password
|
error: (error) => {
|
||||||
};
|
let errorMessage = this.errorHandler.handleApiError(error, `Failed to create login`);
|
||||||
|
this.notificationService.showError(errorMessage);
|
||||||
this.contactService.createContactLogin(contactLoginData).subscribe({
|
console.error('Error saving login:', error);
|
||||||
next: () => {
|
}
|
||||||
this.notificationService.showSuccess(`Login created successfully`);
|
});
|
||||||
this.loadContacts();
|
|
||||||
this.cancelEdit();
|
|
||||||
},
|
|
||||||
error: (error) => {
|
|
||||||
let errorMessage = this.errorHandler.handleApiError(error, `Failed to create login`);
|
|
||||||
this.notificationService.showError(errorMessage);
|
|
||||||
console.error('Error saving login:', error);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
cancelEdit(): void {
|
cancelEdit(): void {
|
||||||
this.showForm = false;
|
this.showForm = false;
|
||||||
this.showLoginForm = false;
|
|
||||||
this.isEditing = false;
|
this.isEditing = false;
|
||||||
this.currentContactId = null;
|
this.currentContactId = null;
|
||||||
this.contactForm.reset();
|
this.contactForm.reset();
|
||||||
// this.contactLoginForm.reset();
|
// this.contactLoginForm.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
// setDefaultContact(contactId: string): void {
|
// setDefaultContact(contactId: string): void {
|
||||||
|
|||||||
@ -26,8 +26,7 @@
|
|||||||
<mat-expansion-panel-header>
|
<mat-expansion-panel-header>
|
||||||
<mat-panel-title> Contacts </mat-panel-title>
|
<mat-panel-title> Contacts </mat-panel-title>
|
||||||
</mat-expansion-panel-header>
|
</mat-expansion-panel-header>
|
||||||
<app-contacts [clientid]="clientid" [userPreferences]="userPreferences"
|
<app-contacts [clientid]="clientid" [userPreferences]="userPreferences"></app-contacts>
|
||||||
[refreshLocationData]="refreshLocationData"></app-contacts>
|
|
||||||
</mat-expansion-panel>
|
</mat-expansion-panel>
|
||||||
|
|
||||||
</mat-accordion>
|
</mat-accordion>
|
||||||
@ -1,4 +1,4 @@
|
|||||||
import { afterNextRender, Component, inject, viewChild } from '@angular/core';
|
import { afterNextRender, Component, inject, ViewChild, viewChild } from '@angular/core';
|
||||||
import { AngularMaterialModule } from '../../shared/module/angular-material.module';
|
import { AngularMaterialModule } from '../../shared/module/angular-material.module';
|
||||||
import { BasicDetailsComponent } from '../basic-details/basic-details.component';
|
import { BasicDetailsComponent } from '../basic-details/basic-details.component';
|
||||||
import { ContactsComponent } from '../contacts/contacts.component';
|
import { ContactsComponent } from '../contacts/contacts.component';
|
||||||
@ -21,7 +21,9 @@ export class EditPreparerComponent {
|
|||||||
clientid = 0;
|
clientid = 0;
|
||||||
clientName: string | null = null;
|
clientName: string | null = null;
|
||||||
userPreferences: UserPreferences;
|
userPreferences: UserPreferences;
|
||||||
refreshLocationData: boolean = false;
|
|
||||||
|
@ViewChild(ContactsComponent, { static: false })
|
||||||
|
private contactsComponent!: ContactsComponent;
|
||||||
|
|
||||||
private route = inject(ActivatedRoute);
|
private route = inject(ActivatedRoute);
|
||||||
|
|
||||||
@ -43,6 +45,8 @@ export class EditPreparerComponent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
onLocationUpdated(updated: boolean): void {
|
onLocationUpdated(updated: boolean): void {
|
||||||
this.refreshLocationData = updated;
|
if (updated) {
|
||||||
|
this.contactsComponent?.refreshLocationData();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -210,7 +210,8 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="form-actions">
|
<div class="form-actions">
|
||||||
<button mat-raised-button color="primary" type="submit" [disabled]="locationForm.invalid">
|
<button mat-raised-button color="primary" type="submit"
|
||||||
|
[disabled]="locationForm.invalid || changeInProgress">
|
||||||
{{ isEditing ? 'Update' : 'Save' }}
|
{{ isEditing ? 'Update' : 'Save' }}
|
||||||
</button>
|
</button>
|
||||||
<button mat-button type="button" (click)="cancelEdit()">Cancel</button>
|
<button mat-button type="button" (click)="cancelEdit()">Cancel</button>
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
import { Component, EventEmitter, inject, Input, Output, SimpleChanges, ViewChild } from '@angular/core';
|
import { Component, EventEmitter, inject, Input, Output, ViewChild } from '@angular/core';
|
||||||
import { AngularMaterialModule } from '../../shared/module/angular-material.module';
|
import { AngularMaterialModule } from '../../shared/module/angular-material.module';
|
||||||
import { CommonModule } from '@angular/common';
|
import { CommonModule } from '@angular/common';
|
||||||
import { FormBuilder, FormGroup, ReactiveFormsModule, Validators } from '@angular/forms';
|
import { FormBuilder, FormGroup, ReactiveFormsModule, Validators } from '@angular/forms';
|
||||||
@ -14,7 +14,7 @@ import { CustomPaginator } from '../../shared/custom-paginator';
|
|||||||
import { ZipCodeValidator } from '../../shared/validators/zipcode-validator';
|
import { ZipCodeValidator } from '../../shared/validators/zipcode-validator';
|
||||||
import { Country } from '../../core/models/country';
|
import { Country } from '../../core/models/country';
|
||||||
import { State } from '../../core/models/state';
|
import { State } from '../../core/models/state';
|
||||||
import { Subject, takeUntil } from 'rxjs';
|
import { finalize, Subject, takeUntil } from 'rxjs';
|
||||||
import { CommonService } from '../../core/services/common/common.service';
|
import { CommonService } from '../../core/services/common/common.service';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
@ -34,6 +34,7 @@ export class LocationComponent {
|
|||||||
isEditing = false;
|
isEditing = false;
|
||||||
currentLocationId: number | null = null;
|
currentLocationId: number | null = null;
|
||||||
isLoading = false;
|
isLoading = false;
|
||||||
|
changeInProgress = false;
|
||||||
showForm = false;
|
showForm = false;
|
||||||
countries: Country[] = [];
|
countries: Country[] = [];
|
||||||
states: State[] = [];
|
states: State[] = [];
|
||||||
@ -47,7 +48,6 @@ export class LocationComponent {
|
|||||||
|
|
||||||
@Input() clientid: number = 0;
|
@Input() clientid: number = 0;
|
||||||
@Input() userPreferences: UserPreferences = {};
|
@Input() userPreferences: UserPreferences = {};
|
||||||
@Input() refreshLocationData: boolean = false;
|
|
||||||
@Output() hasLocations = new EventEmitter<boolean>();
|
@Output() hasLocations = new EventEmitter<boolean>();
|
||||||
@Output() updated = new EventEmitter<boolean>();
|
@Output() updated = new EventEmitter<boolean>();
|
||||||
|
|
||||||
@ -88,24 +88,22 @@ export class LocationComponent {
|
|||||||
this.destroy$.complete();
|
this.destroy$.complete();
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnChanges(changes: SimpleChanges) {
|
public refreshLocationData(): void {
|
||||||
if (changes['refreshLocationData']) {
|
this.loadLocations();
|
||||||
this.loadLocations();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
loadLocations(): void {
|
loadLocations(): void {
|
||||||
this.isLoading = true;
|
this.isLoading = true;
|
||||||
|
|
||||||
this.locationService.getLocationsById(this.clientid).subscribe({
|
this.locationService.getLocationsById(this.clientid).pipe(finalize(() => {
|
||||||
|
this.isLoading = false;
|
||||||
|
})).subscribe({
|
||||||
next: (locations: Location[]) => {
|
next: (locations: Location[]) => {
|
||||||
this.dataSource.data = locations;
|
this.dataSource.data = locations;
|
||||||
this.isLoading = false;
|
|
||||||
},
|
},
|
||||||
error: (error: any) => {
|
error: (error: any) => {
|
||||||
let errorMessage = this.errorHandler.handleApiError(error, 'Failed to load locations');
|
let errorMessage = this.errorHandler.handleApiError(error, 'Failed to load locations');
|
||||||
this.notificationService.showError(errorMessage);
|
this.notificationService.showError(errorMessage);
|
||||||
this.isLoading = false;
|
|
||||||
console.error('Error loading locations:', error);
|
console.error('Error loading locations:', error);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -170,7 +168,8 @@ export class LocationComponent {
|
|||||||
? this.locationService.updateLocation(this.currentLocationId!, locationData)
|
? this.locationService.updateLocation(this.currentLocationId!, locationData)
|
||||||
: this.locationService.createLocation(this.clientid, locationData);
|
: this.locationService.createLocation(this.clientid, locationData);
|
||||||
|
|
||||||
saveObservable.subscribe({
|
this.changeInProgress = true;
|
||||||
|
saveObservable.pipe(finalize(() => this.changeInProgress = false)).subscribe({
|
||||||
next: () => {
|
next: () => {
|
||||||
this.notificationService.showSuccess(`Location ${this.isEditing ? 'updated' : 'added'} successfully`);
|
this.notificationService.showSuccess(`Location ${this.isEditing ? 'updated' : 'added'} successfully`);
|
||||||
this.updated.emit(true); // to update dependent data
|
this.updated.emit(true); // to update dependent data
|
||||||
@ -187,7 +186,7 @@ export class LocationComponent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
loadCountries(): void {
|
loadCountries(): void {
|
||||||
this.commonService.getCountries(this.clientid)
|
this.commonService.getCountries()
|
||||||
.pipe(takeUntil(this.destroy$))
|
.pipe(takeUntil(this.destroy$))
|
||||||
.subscribe({
|
.subscribe({
|
||||||
next: (countries) => {
|
next: (countries) => {
|
||||||
@ -195,7 +194,6 @@ export class LocationComponent {
|
|||||||
},
|
},
|
||||||
error: (error) => {
|
error: (error) => {
|
||||||
console.error('Failed to load countries', error);
|
console.error('Failed to load countries', error);
|
||||||
this.isLoading = false;
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -203,8 +201,10 @@ export class LocationComponent {
|
|||||||
loadStates(country: string): void {
|
loadStates(country: string): void {
|
||||||
this.isLoading = true;
|
this.isLoading = true;
|
||||||
country = this.countriesHasStates.includes(country) ? country : 'FN';
|
country = this.countriesHasStates.includes(country) ? country : 'FN';
|
||||||
this.commonService.getStates(country, this.clientid)
|
this.commonService.getStates(country)
|
||||||
.pipe(takeUntil(this.destroy$))
|
.pipe(takeUntil(this.destroy$), finalize(() => {
|
||||||
|
this.isLoading = false;
|
||||||
|
}))
|
||||||
.subscribe({
|
.subscribe({
|
||||||
next: (states) => {
|
next: (states) => {
|
||||||
this.states = states;
|
this.states = states;
|
||||||
@ -215,11 +215,9 @@ export class LocationComponent {
|
|||||||
stateControl?.disable();
|
stateControl?.disable();
|
||||||
stateControl?.setValue('FN');
|
stateControl?.setValue('FN');
|
||||||
}
|
}
|
||||||
this.isLoading = false;
|
|
||||||
},
|
},
|
||||||
error: (error) => {
|
error: (error) => {
|
||||||
console.error('Failed to load states', error);
|
console.error('Failed to load states', error);
|
||||||
this.isLoading = false;
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@ -176,8 +176,9 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="form-actions">
|
<div class="form-actions">
|
||||||
<button mat-raised-button color="primary" type="submit" [disabled]="basicDetailsForm.invalid">
|
<button mat-raised-button color="primary" type="submit"
|
||||||
Save
|
[disabled]="basicDetailsForm.invalid || changeInProgress">
|
||||||
|
{{ isEditMode ? 'Update' : 'Save' }}
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
import { Component, Input, OnInit, Output, EventEmitter, OnDestroy, inject } from '@angular/core';
|
import { Component, Input, OnInit, Output, EventEmitter, OnDestroy, inject } from '@angular/core';
|
||||||
import { FormBuilder, FormGroup, ReactiveFormsModule, Validators } from '@angular/forms';
|
import { FormBuilder, FormGroup, ReactiveFormsModule, Validators } from '@angular/forms';
|
||||||
import { Subject } from 'rxjs';
|
import { Subject } from 'rxjs';
|
||||||
import { takeUntil } from 'rxjs/operators';
|
import { finalize, takeUntil } from 'rxjs/operators';
|
||||||
import { BasicDetail } from '../../core/models/service-provider/basic-detail';
|
import { BasicDetail } from '../../core/models/service-provider/basic-detail';
|
||||||
import { Country } from '../../core/models/country';
|
import { Country } from '../../core/models/country';
|
||||||
import { Region } from '../../core/models/region';
|
import { Region } from '../../core/models/region';
|
||||||
@ -38,6 +38,7 @@ export class BasicDetailsComponent implements OnInit, OnDestroy {
|
|||||||
cargoPolicies: CargoPolicy[] = [];
|
cargoPolicies: CargoPolicy[] = [];
|
||||||
|
|
||||||
isLoading = true;
|
isLoading = true;
|
||||||
|
changeInProgress = false;
|
||||||
countriesHasStates = ['US', 'CA', 'MX'];
|
countriesHasStates = ['US', 'CA', 'MX'];
|
||||||
|
|
||||||
private destroy$ = new Subject<void>();
|
private destroy$ = new Subject<void>();
|
||||||
@ -57,21 +58,24 @@ export class BasicDetailsComponent implements OnInit, OnDestroy {
|
|||||||
// this.spidCreated.emit(this.spid?.toString());
|
// this.spidCreated.emit(this.spid?.toString());
|
||||||
// Patch edit form data
|
// Patch edit form data
|
||||||
if (this.spid > 0) {
|
if (this.spid > 0) {
|
||||||
this.basicDetailService.getBasicDetailsById(this.spid).subscribe({
|
this.isLoading = true;
|
||||||
|
this.basicDetailService.getBasicDetailsById(this.spid).pipe(finalize(() => {
|
||||||
|
this.isLoading = false;
|
||||||
|
})).subscribe({
|
||||||
next: (basicDetail: BasicDetail) => {
|
next: (basicDetail: BasicDetail) => {
|
||||||
if (basicDetail?.spid > 0) {
|
if (basicDetail?.spid > 0) {
|
||||||
this.patchFormData(basicDetail);
|
this.patchFormData(basicDetail);
|
||||||
this.serviceProviderName.emit(basicDetail.companyName);
|
this.serviceProviderName.emit(basicDetail.companyName);
|
||||||
}
|
}
|
||||||
this.isLoading = false;
|
|
||||||
},
|
},
|
||||||
error: (error: any) => {
|
error: (error: any) => {
|
||||||
let errorMessage = this.errorHandler.handleApiError(error, 'Failed to load basic details');
|
let errorMessage = this.errorHandler.handleApiError(error, 'Failed to load basic details');
|
||||||
this.notificationService.showError(errorMessage);
|
this.notificationService.showError(errorMessage);
|
||||||
this.isLoading = false;
|
|
||||||
console.error('Error loading basic details:', error);
|
console.error('Error loading basic details:', error);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
} else {
|
||||||
|
this.loadStates('US');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -87,7 +91,7 @@ export class BasicDetailsComponent implements OnInit, OnDestroy {
|
|||||||
address1: ['', [Validators.required, Validators.maxLength(100)]],
|
address1: ['', [Validators.required, Validators.maxLength(100)]],
|
||||||
address2: ['', [Validators.maxLength(100)]],
|
address2: ['', [Validators.maxLength(100)]],
|
||||||
city: ['', [Validators.required, Validators.maxLength(50)]],
|
city: ['', [Validators.required, Validators.maxLength(50)]],
|
||||||
country: ['', Validators.required],
|
country: ['US', Validators.required],
|
||||||
state: ['', Validators.required],
|
state: ['', Validators.required],
|
||||||
zip: ['', [Validators.required, ZipCodeValidator('country')]],
|
zip: ['', [Validators.required, ZipCodeValidator('country')]],
|
||||||
issuingRegion: ['', Validators.required],
|
issuingRegion: ['', Validators.required],
|
||||||
@ -99,7 +103,7 @@ export class BasicDetailsComponent implements OnInit, OnDestroy {
|
|||||||
}
|
}
|
||||||
|
|
||||||
loadLookupData(): void {
|
loadLookupData(): void {
|
||||||
this.commonService.getCountries(this.spid)
|
this.commonService.getCountries()
|
||||||
.pipe(takeUntil(this.destroy$))
|
.pipe(takeUntil(this.destroy$))
|
||||||
.subscribe({
|
.subscribe({
|
||||||
next: (countries) => {
|
next: (countries) => {
|
||||||
@ -107,7 +111,6 @@ export class BasicDetailsComponent implements OnInit, OnDestroy {
|
|||||||
},
|
},
|
||||||
error: (error) => {
|
error: (error) => {
|
||||||
console.error('Failed to load countries', error);
|
console.error('Failed to load countries', error);
|
||||||
this.isLoading = false;
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -123,11 +126,9 @@ export class BasicDetailsComponent implements OnInit, OnDestroy {
|
|||||||
.subscribe({
|
.subscribe({
|
||||||
next: (regions) => {
|
next: (regions) => {
|
||||||
this.regions = regions;
|
this.regions = regions;
|
||||||
this.isLoading = false;
|
|
||||||
},
|
},
|
||||||
error: (error) => {
|
error: (error) => {
|
||||||
console.error('Failed to load regions', error);
|
console.error('Failed to load regions', error);
|
||||||
this.isLoading = false;
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -135,9 +136,10 @@ export class BasicDetailsComponent implements OnInit, OnDestroy {
|
|||||||
loadStates(country: string): void {
|
loadStates(country: string): void {
|
||||||
this.isLoading = true;
|
this.isLoading = true;
|
||||||
country = this.countriesHasStates.includes(country) ? country : 'FN';
|
country = this.countriesHasStates.includes(country) ? country : 'FN';
|
||||||
this.commonService.getStates(country, this.spid)
|
this.commonService.getStates(country)
|
||||||
.pipe(takeUntil(this.destroy$))
|
.pipe(takeUntil(this.destroy$), finalize(() => {
|
||||||
.subscribe({
|
this.isLoading = false;
|
||||||
|
})).subscribe({
|
||||||
next: (states) => {
|
next: (states) => {
|
||||||
this.states = states;
|
this.states = states;
|
||||||
const stateControl = this.basicDetailsForm.get('state');
|
const stateControl = this.basicDetailsForm.get('state');
|
||||||
@ -147,11 +149,9 @@ export class BasicDetailsComponent implements OnInit, OnDestroy {
|
|||||||
stateControl?.disable();
|
stateControl?.disable();
|
||||||
stateControl?.setValue('FN');
|
stateControl?.setValue('FN');
|
||||||
}
|
}
|
||||||
this.isLoading = false;
|
|
||||||
},
|
},
|
||||||
error: (error) => {
|
error: (error) => {
|
||||||
console.error('Failed to load states', error);
|
console.error('Failed to load states', error);
|
||||||
this.isLoading = false;
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -162,11 +162,9 @@ export class BasicDetailsComponent implements OnInit, OnDestroy {
|
|||||||
.subscribe({
|
.subscribe({
|
||||||
next: (bondSuretys) => {
|
next: (bondSuretys) => {
|
||||||
this.bondSuretys = bondSuretys;
|
this.bondSuretys = bondSuretys;
|
||||||
this.isLoading = false;
|
|
||||||
},
|
},
|
||||||
error: (error) => {
|
error: (error) => {
|
||||||
console.error('Failed to load bond suretys', error);
|
console.error('Failed to load bond suretys', error);
|
||||||
this.isLoading = false;
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -177,11 +175,9 @@ export class BasicDetailsComponent implements OnInit, OnDestroy {
|
|||||||
.subscribe({
|
.subscribe({
|
||||||
next: (cargoSuretys) => {
|
next: (cargoSuretys) => {
|
||||||
this.cargoSuretys = cargoSuretys;
|
this.cargoSuretys = cargoSuretys;
|
||||||
this.isLoading = false;
|
|
||||||
},
|
},
|
||||||
error: (error) => {
|
error: (error) => {
|
||||||
console.error('Failed to load cargo suretys', error);
|
console.error('Failed to load cargo suretys', error);
|
||||||
this.isLoading = false;
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -192,11 +188,9 @@ export class BasicDetailsComponent implements OnInit, OnDestroy {
|
|||||||
.subscribe({
|
.subscribe({
|
||||||
next: (cargoPolicies) => {
|
next: (cargoPolicies) => {
|
||||||
this.cargoPolicies = cargoPolicies;
|
this.cargoPolicies = cargoPolicies;
|
||||||
this.isLoading = false;
|
|
||||||
},
|
},
|
||||||
error: (error) => {
|
error: (error) => {
|
||||||
console.error('Failed to load cargo policies', error);
|
console.error('Failed to load cargo policies', error);
|
||||||
this.isLoading = false;
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -220,6 +214,8 @@ export class BasicDetailsComponent implements OnInit, OnDestroy {
|
|||||||
|
|
||||||
if (data.country) {
|
if (data.country) {
|
||||||
this.loadStates(data.country);
|
this.loadStates(data.country);
|
||||||
|
} else {
|
||||||
|
this.loadStates('US');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.isEditMode) {
|
if (this.isEditMode) {
|
||||||
@ -270,12 +266,17 @@ export class BasicDetailsComponent implements OnInit, OnDestroy {
|
|||||||
? this.basicDetailService.updateBasicDetails(this.spid, basicDetailData)
|
? this.basicDetailService.updateBasicDetails(this.spid, basicDetailData)
|
||||||
: this.basicDetailService.createBasicDetails(basicDetailData);
|
: this.basicDetailService.createBasicDetails(basicDetailData);
|
||||||
|
|
||||||
saveObservable.subscribe({
|
this.changeInProgress = true;
|
||||||
|
saveObservable.pipe(finalize(() => this.changeInProgress = false)).subscribe({
|
||||||
next: (basicData: any) => {
|
next: (basicData: any) => {
|
||||||
this.notificationService.showSuccess(`Basic details ${this.isEditMode ? 'updated' : 'added'} successfully`);
|
this.notificationService.showSuccess(`Basic details ${this.isEditMode ? 'updated' : 'added'} successfully`);
|
||||||
|
|
||||||
if (!this.isEditMode) {
|
if (!this.isEditMode) {
|
||||||
this.spidCreated.emit(basicData.SPID);
|
this.spidCreated.emit(basicData.SPID);
|
||||||
|
|
||||||
|
// change to edit mode after creation
|
||||||
|
this.isEditMode = true;
|
||||||
|
this.spid = basicData.SPID;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
error: (error) => {
|
error: (error) => {
|
||||||
|
|||||||
@ -1,4 +1,9 @@
|
|||||||
<div class="basic-fee-container">
|
<div class="basic-fee-container">
|
||||||
|
<div class="actions-bar">
|
||||||
|
<mat-slide-toggle (change)="toggleShowExpiredRecords()">
|
||||||
|
Show Expired Records
|
||||||
|
</mat-slide-toggle>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="table-container mat-elevation-z8">
|
<div class="table-container mat-elevation-z8">
|
||||||
<div class="loading-shade" *ngIf="isLoading">
|
<div class="loading-shade" *ngIf="isLoading">
|
||||||
@ -136,7 +141,8 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="form-actions">
|
<div class="form-actions">
|
||||||
<button mat-raised-button color="primary" type="submit" [disabled]="feeForm.invalid">
|
<button mat-raised-button color="primary" type="submit"
|
||||||
|
[disabled]="feeForm.invalid || changeInProgress">
|
||||||
{{ isEditing ? 'Update' : 'Save' }}
|
{{ isEditing ? 'Update' : 'Save' }}
|
||||||
</button>
|
</button>
|
||||||
<button mat-button type="button" (click)="cancelEdit()">Cancel</button>
|
<button mat-button type="button" (click)="cancelEdit()">Cancel</button>
|
||||||
|
|||||||
@ -4,6 +4,16 @@
|
|||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
gap: 24px;
|
gap: 24px;
|
||||||
|
|
||||||
|
.actions-bar {
|
||||||
|
clear: both;
|
||||||
|
margin-bottom: -16px;
|
||||||
|
|
||||||
|
mat-slide-toggle {
|
||||||
|
transform: scale(0.8);
|
||||||
|
margin-left: -0.5rem;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
.table-container {
|
.table-container {
|
||||||
position: relative;
|
position: relative;
|
||||||
overflow: auto;
|
overflow: auto;
|
||||||
|
|||||||
@ -7,7 +7,7 @@ import { AngularMaterialModule } from '../../shared/module/angular-material.modu
|
|||||||
import { FormBuilder, FormGroup, FormsModule, ReactiveFormsModule, Validators } from '@angular/forms';
|
import { FormBuilder, FormGroup, FormsModule, ReactiveFormsModule, Validators } from '@angular/forms';
|
||||||
import { CommonModule } from '@angular/common';
|
import { CommonModule } from '@angular/common';
|
||||||
import { CustomPaginator } from '../../shared/custom-paginator';
|
import { CustomPaginator } from '../../shared/custom-paginator';
|
||||||
import { forkJoin } from 'rxjs';
|
import { finalize, forkJoin } from 'rxjs';
|
||||||
import { UserPreferences } from '../../core/models/user-preference';
|
import { UserPreferences } from '../../core/models/user-preference';
|
||||||
import { ApiErrorHandlerService } from '../../core/services/common/api-error-handler.service';
|
import { ApiErrorHandlerService } from '../../core/services/common/api-error-handler.service';
|
||||||
import { NotificationService } from '../../core/services/common/notification.service';
|
import { NotificationService } from '../../core/services/common/notification.service';
|
||||||
@ -30,7 +30,10 @@ export class BasicFeeComponent {
|
|||||||
isEditing = false;
|
isEditing = false;
|
||||||
currentFeeId: number | null = null;
|
currentFeeId: number | null = null;
|
||||||
isLoading = false;
|
isLoading = false;
|
||||||
|
changeInProgress = false;
|
||||||
showForm = false;
|
showForm = false;
|
||||||
|
showExpiredRecords = false;
|
||||||
|
basicFees: BasicFee[] = [];
|
||||||
|
|
||||||
readOnlyFields: any = {
|
readOnlyFields: any = {
|
||||||
lastChangedDate: null,
|
lastChangedDate: null,
|
||||||
@ -67,11 +70,14 @@ export class BasicFeeComponent {
|
|||||||
|
|
||||||
loadBasicFees(): void {
|
loadBasicFees(): void {
|
||||||
this.isLoading = true;
|
this.isLoading = true;
|
||||||
this.basicFeeService.getBasicFees(this.spid).subscribe({
|
this.basicFeeService.getBasicFees(this.spid).pipe(finalize(() => {
|
||||||
|
this.isLoading = false;
|
||||||
|
})).subscribe({
|
||||||
next: (fees) => {
|
next: (fees) => {
|
||||||
this.dataSource.data = fees;
|
this.basicFees = fees;
|
||||||
|
this.dataSource.data = this.basicFees;
|
||||||
|
this.renderRecods();
|
||||||
this.hasBasicFees.emit(fees.length > 0);
|
this.hasBasicFees.emit(fees.length > 0);
|
||||||
this.isLoading = false;
|
|
||||||
|
|
||||||
if (this.dataSource.data.length == 0) {
|
if (this.dataSource.data.length == 0) {
|
||||||
this.initializeDefaultFees();
|
this.initializeDefaultFees();
|
||||||
@ -80,14 +86,25 @@ export class BasicFeeComponent {
|
|||||||
error: (error) => {
|
error: (error) => {
|
||||||
let errorMessage = this.errorHandler.handleApiError(error, 'Failed to load basic fees');
|
let errorMessage = this.errorHandler.handleApiError(error, 'Failed to load basic fees');
|
||||||
this.notificationService.showError(errorMessage);
|
this.notificationService.showError(errorMessage);
|
||||||
this.isLoading = false;
|
|
||||||
console.error('Error loading basic fees:', error);
|
console.error('Error loading basic fees:', error);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
toggleShowExpiredRecords(): void {
|
||||||
|
this.showExpiredRecords = !this.showExpiredRecords;
|
||||||
|
this.renderRecods();
|
||||||
|
}
|
||||||
|
|
||||||
|
renderRecods(): void {
|
||||||
|
if (this.showExpiredRecords) {
|
||||||
|
this.dataSource.data = this.basicFees;
|
||||||
|
} else {
|
||||||
|
this.dataSource.data = this.basicFees.filter(record => !record.expired);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
initializeDefaultFees(): void {
|
initializeDefaultFees(): void {
|
||||||
this.isLoading = true;
|
|
||||||
const defaultFees: BasicFee[] = [
|
const defaultFees: BasicFee[] = [
|
||||||
{ basicFeeId: 0, startCarnetValue: 1, endCarnetValue: 9999, fees: 255, effectiveDate: new Date() },
|
{ basicFeeId: 0, startCarnetValue: 1, endCarnetValue: 9999, fees: 255, effectiveDate: new Date() },
|
||||||
{ basicFeeId: 0, startCarnetValue: 10000, endCarnetValue: 49999, fees: 300, effectiveDate: new Date() },
|
{ basicFeeId: 0, startCarnetValue: 10000, endCarnetValue: 49999, fees: 300, effectiveDate: new Date() },
|
||||||
@ -102,14 +119,16 @@ export class BasicFeeComponent {
|
|||||||
this.basicFeeService.createBasicFee(this.spid, fee)
|
this.basicFeeService.createBasicFee(this.spid, fee)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
this.changeInProgress = true;
|
||||||
|
|
||||||
// Execute all creations in parallel and wait for all to complete
|
// Execute all creations in parallel and wait for all to complete
|
||||||
forkJoin(creationObservables).subscribe({
|
forkJoin(creationObservables).pipe(finalize(() => {
|
||||||
|
this.changeInProgress = false;
|
||||||
|
})).subscribe({
|
||||||
next: () => {
|
next: () => {
|
||||||
this.loadBasicFees(); // Refresh the list after all creations are done
|
this.loadBasicFees(); // Refresh the list after all creations are done
|
||||||
this.isLoading = false;
|
|
||||||
},
|
},
|
||||||
error: (error) => {
|
error: (error) => {
|
||||||
this.isLoading = false;
|
|
||||||
console.error('Error initializing default fees:', error);
|
console.error('Error initializing default fees:', error);
|
||||||
// Even if some failed, try to load what was created
|
// Even if some failed, try to load what was created
|
||||||
this.loadBasicFees();
|
this.loadBasicFees();
|
||||||
@ -175,7 +194,11 @@ export class BasicFeeComponent {
|
|||||||
? this.basicFeeService.updateBasicFee(this.currentFeeId, feeData)
|
? this.basicFeeService.updateBasicFee(this.currentFeeId, feeData)
|
||||||
: this.basicFeeService.createBasicFee(this.spid, feeData);
|
: this.basicFeeService.createBasicFee(this.spid, feeData);
|
||||||
|
|
||||||
saveObservable.subscribe({
|
this.changeInProgress = true;
|
||||||
|
|
||||||
|
saveObservable.pipe(finalize(() => {
|
||||||
|
this.changeInProgress = false;
|
||||||
|
})).subscribe({
|
||||||
next: () => {
|
next: () => {
|
||||||
this.notificationService.showSuccess(`Basic fee ${this.isEditing ? 'updated' : 'added'} successfully`);
|
this.notificationService.showSuccess(`Basic fee ${this.isEditing ? 'updated' : 'added'} successfully`);
|
||||||
this.loadBasicFees();
|
this.loadBasicFees();
|
||||||
|
|||||||
@ -1,5 +1,8 @@
|
|||||||
<div class="fee-commission-container">
|
<div class="fee-commission-container">
|
||||||
<div class="actions-bar">
|
<div class="actions-bar">
|
||||||
|
<mat-slide-toggle (change)="toggleShowExpiredRecords()">
|
||||||
|
Show Expired Records
|
||||||
|
</mat-slide-toggle>
|
||||||
<button mat-raised-button color="primary" *ngIf="!isEditMode" (click)="addNewFeeCommission()">
|
<button mat-raised-button color="primary" *ngIf="!isEditMode" (click)="addNewFeeCommission()">
|
||||||
<mat-icon>add</mat-icon> Add New Fee & Commission
|
<mat-icon>add</mat-icon> Add New Fee & Commission
|
||||||
</button>
|
</button>
|
||||||
@ -123,7 +126,8 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="form-actions">
|
<div class="form-actions">
|
||||||
<button mat-raised-button color="primary" type="submit" [disabled]="feeCommissionForm.invalid">
|
<button mat-raised-button color="primary" type="submit"
|
||||||
|
[disabled]="feeCommissionForm.invalid || changeInProgress">
|
||||||
{{ isEditing ? 'Update' : 'Save' }}
|
{{ isEditing ? 'Update' : 'Save' }}
|
||||||
</button>
|
</button>
|
||||||
<button mat-button type="button" (click)="cancelEdit()">Cancel</button>
|
<button mat-button type="button" (click)="cancelEdit()">Cancel</button>
|
||||||
|
|||||||
@ -8,6 +8,11 @@
|
|||||||
clear: both;
|
clear: both;
|
||||||
margin-bottom: -16px;
|
margin-bottom: -16px;
|
||||||
|
|
||||||
|
mat-slide-toggle {
|
||||||
|
transform: scale(0.8);
|
||||||
|
margin-left: -0.5rem;
|
||||||
|
}
|
||||||
|
|
||||||
button {
|
button {
|
||||||
float: right;
|
float: right;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -14,6 +14,7 @@ import { ApiErrorHandlerService } from '../../core/services/common/api-error-han
|
|||||||
import { CommonService } from '../../core/services/common/common.service';
|
import { CommonService } from '../../core/services/common/common.service';
|
||||||
import { NotificationService } from '../../core/services/common/notification.service';
|
import { NotificationService } from '../../core/services/common/notification.service';
|
||||||
import { CarnetFeeService } from '../../core/services/service-provider/carnet-fee.service';
|
import { CarnetFeeService } from '../../core/services/service-provider/carnet-fee.service';
|
||||||
|
import { finalize } from 'rxjs';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-carnet-fee',
|
selector: 'app-carnet-fee',
|
||||||
@ -33,8 +34,11 @@ export class CarnetFeeComponent implements OnInit {
|
|||||||
isEditing = false;
|
isEditing = false;
|
||||||
currentFeeCommissionId: number | null = null;
|
currentFeeCommissionId: number | null = null;
|
||||||
isLoading = false;
|
isLoading = false;
|
||||||
|
changeInProgress = false;
|
||||||
showForm = false;
|
showForm = false;
|
||||||
feeTypes: FeeType[] = [];
|
feeTypes: FeeType[] = [];
|
||||||
|
showExpiredRecords = false;
|
||||||
|
carnetFees: CarnetFee[] = [];
|
||||||
|
|
||||||
readOnlyFields: any = {
|
readOnlyFields: any = {
|
||||||
lastChangedDate: null,
|
lastChangedDate: null,
|
||||||
@ -72,21 +76,36 @@ export class CarnetFeeComponent implements OnInit {
|
|||||||
|
|
||||||
loadFeeCommissions(): void {
|
loadFeeCommissions(): void {
|
||||||
this.isLoading = true;
|
this.isLoading = true;
|
||||||
this.feeCommissionService.getFeeCommissions(this.spid).subscribe({
|
this.feeCommissionService.getFeeCommissions(this.spid).pipe(finalize(() => {
|
||||||
|
this.isLoading = false;
|
||||||
|
})).subscribe({
|
||||||
next: (fees) => {
|
next: (fees) => {
|
||||||
this.dataSource.data = fees;
|
this.carnetFees = fees;
|
||||||
|
this.dataSource.data = this.carnetFees;
|
||||||
|
this.renderRecods();
|
||||||
this.hasFeeCommissions.emit(fees.length > 0);
|
this.hasFeeCommissions.emit(fees.length > 0);
|
||||||
this.isLoading = false;
|
|
||||||
},
|
},
|
||||||
error: (error) => {
|
error: (error) => {
|
||||||
let errorMessage = this.errorHandler.handleApiError(error, 'Failed to load fee & commission data');
|
let errorMessage = this.errorHandler.handleApiError(error, 'Failed to load fee & commission data');
|
||||||
this.notificationService.showError(errorMessage);
|
this.notificationService.showError(errorMessage);
|
||||||
this.isLoading = false;
|
|
||||||
console.error('Error loading fee & commission data:', error);
|
console.error('Error loading fee & commission data:', error);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
toggleShowExpiredRecords(): void {
|
||||||
|
this.showExpiredRecords = !this.showExpiredRecords;
|
||||||
|
this.renderRecods();
|
||||||
|
}
|
||||||
|
|
||||||
|
renderRecods(): void {
|
||||||
|
if (this.showExpiredRecords) {
|
||||||
|
this.dataSource.data = this.carnetFees;
|
||||||
|
} else {
|
||||||
|
this.dataSource.data = this.carnetFees.filter(record => !record.expired);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
loadFeeTypes(): void {
|
loadFeeTypes(): void {
|
||||||
this.commonService.getFeeTypes().subscribe({
|
this.commonService.getFeeTypes().subscribe({
|
||||||
next: (types) => {
|
next: (types) => {
|
||||||
@ -151,7 +170,10 @@ export class CarnetFeeComponent implements OnInit {
|
|||||||
? this.feeCommissionService.updateFeeCommission(this.currentFeeCommissionId, feeCommissionData)
|
? this.feeCommissionService.updateFeeCommission(this.currentFeeCommissionId, feeCommissionData)
|
||||||
: this.feeCommissionService.createFeeCommission(this.spid, feeCommissionData);
|
: this.feeCommissionService.createFeeCommission(this.spid, feeCommissionData);
|
||||||
|
|
||||||
saveObservable.subscribe({
|
this.changeInProgress
|
||||||
|
saveObservable.pipe(finalize(() => {
|
||||||
|
this.changeInProgress = false;
|
||||||
|
})).subscribe({
|
||||||
next: () => {
|
next: () => {
|
||||||
this.notificationService.showSuccess(`Fee & commission ${this.isEditing ? 'updated' : 'added'} successfully`);
|
this.notificationService.showSuccess(`Fee & commission ${this.isEditing ? 'updated' : 'added'} successfully`);
|
||||||
this.loadFeeCommissions();
|
this.loadFeeCommissions();
|
||||||
|
|||||||
@ -138,7 +138,8 @@
|
|||||||
</mat-error>
|
</mat-error>
|
||||||
|
|
||||||
<div class="form-actions">
|
<div class="form-actions">
|
||||||
<button mat-raised-button color="primary" type="submit" [disabled]="sequenceForm.invalid">
|
<button mat-raised-button color="primary" type="submit"
|
||||||
|
[disabled]="sequenceForm.invalid || changeInProgress">
|
||||||
{{ isEditing ? 'Update' : 'Save' }}
|
{{ isEditing ? 'Update' : 'Save' }}
|
||||||
</button>
|
</button>
|
||||||
<button mat-button type="button" (click)="cancelEdit()">Cancel</button>
|
<button mat-button type="button" (click)="cancelEdit()">Cancel</button>
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
import { Component, EventEmitter, inject, Input, OnInit, Output, ViewChild } from '@angular/core';
|
import { Component, EventEmitter, inject, Input, OnInit, Output, ViewChild } from '@angular/core';
|
||||||
import { FormBuilder, FormGroup, ReactiveFormsModule, Validators } from '@angular/forms';
|
import { FormBuilder, FormGroup, ReactiveFormsModule, Validators } from '@angular/forms';
|
||||||
import { CarnetSequence } from '../../core/models/service-provider/carnet-sequence';
|
import { CarnetSequence } from '../../core/models/service-provider/carnet-sequence';
|
||||||
import { Subject, takeUntil } from 'rxjs';
|
import { finalize, Subject, takeUntil } from 'rxjs';
|
||||||
import { Region } from '../../core/models/region';
|
import { Region } from '../../core/models/region';
|
||||||
import { MatPaginator, MatPaginatorIntl } from '@angular/material/paginator';
|
import { MatPaginator, MatPaginatorIntl } from '@angular/material/paginator';
|
||||||
import { MatSort } from '@angular/material/sort';
|
import { MatSort } from '@angular/material/sort';
|
||||||
@ -32,6 +32,7 @@ export class CarnetSequenceComponent implements OnInit {
|
|||||||
isEditing = false;
|
isEditing = false;
|
||||||
currentSequenceId: string | null = null;
|
currentSequenceId: string | null = null;
|
||||||
isLoading = false;
|
isLoading = false;
|
||||||
|
changeInProgress = false;
|
||||||
showForm = false;
|
showForm = false;
|
||||||
|
|
||||||
carnetTypes = [
|
carnetTypes = [
|
||||||
@ -98,11 +99,9 @@ export class CarnetSequenceComponent implements OnInit {
|
|||||||
.subscribe({
|
.subscribe({
|
||||||
next: (regions) => {
|
next: (regions) => {
|
||||||
this.regions = regions;
|
this.regions = regions;
|
||||||
this.isLoading = false;
|
|
||||||
},
|
},
|
||||||
error: (error) => {
|
error: (error) => {
|
||||||
console.error('Failed to load regions', error);
|
console.error('Failed to load regions', error);
|
||||||
this.isLoading = false;
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -113,17 +112,15 @@ export class CarnetSequenceComponent implements OnInit {
|
|||||||
|
|
||||||
this.isLoading = true;
|
this.isLoading = true;
|
||||||
|
|
||||||
this.carnetSequenceService.getCarnetSequenceById(this.spid).subscribe({
|
this.carnetSequenceService.getCarnetSequenceById(this.spid).pipe(finalize(() => {
|
||||||
|
this.isLoading = false;
|
||||||
|
})).subscribe({
|
||||||
next: (carnetSequences: CarnetSequence[]) => {
|
next: (carnetSequences: CarnetSequence[]) => {
|
||||||
// this.sequences = carnetSequences;
|
|
||||||
this.isLoading = false;
|
|
||||||
this.dataSource.data = carnetSequences;
|
this.dataSource.data = carnetSequences;
|
||||||
this.isLoading = false;
|
|
||||||
},
|
},
|
||||||
error: (error: any) => {
|
error: (error: any) => {
|
||||||
let errorMessage = this.errorHandler.handleApiError(error, 'Failed to load sequences');
|
let errorMessage = this.errorHandler.handleApiError(error, 'Failed to load sequences');
|
||||||
this.notificationService.showError(errorMessage);
|
this.notificationService.showError(errorMessage);
|
||||||
this.isLoading = false;
|
|
||||||
console.error('Error loading sequences:', error);
|
console.error('Error loading sequences:', error);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -141,7 +138,10 @@ export class CarnetSequenceComponent implements OnInit {
|
|||||||
lastNumber: this.sequenceForm.value.startNumber
|
lastNumber: this.sequenceForm.value.startNumber
|
||||||
};
|
};
|
||||||
|
|
||||||
this.carnetSequenceService.createCarnetSequence(sequenceData).subscribe({
|
this.changeInProgress = true;
|
||||||
|
this.carnetSequenceService.createCarnetSequence(sequenceData).pipe(finalize(() => {
|
||||||
|
this.changeInProgress = false;
|
||||||
|
})).subscribe({
|
||||||
next: () => {
|
next: () => {
|
||||||
this.notificationService.showSuccess('Sequence added successfully');
|
this.notificationService.showSuccess('Sequence added successfully');
|
||||||
this.loadSequences();
|
this.loadSequences();
|
||||||
@ -182,7 +182,10 @@ export class CarnetSequenceComponent implements OnInit {
|
|||||||
spid: this.spid
|
spid: this.spid
|
||||||
};
|
};
|
||||||
|
|
||||||
this.carnetSequenceService.createCarnetSequence(sequenceData)
|
this.changeInProgress = true;
|
||||||
|
this.carnetSequenceService.createCarnetSequence(sequenceData).pipe(finalize(() => {
|
||||||
|
this.changeInProgress = false;
|
||||||
|
}))
|
||||||
.subscribe({
|
.subscribe({
|
||||||
next: () => {
|
next: () => {
|
||||||
this.notificationService.showSuccess('Sequence added successfully');
|
this.notificationService.showSuccess('Sequence added successfully');
|
||||||
|
|||||||
@ -4,6 +4,10 @@
|
|||||||
<mat-icon matPrefix>search</mat-icon>
|
<mat-icon matPrefix>search</mat-icon>
|
||||||
<input matInput (keyup)="applyFilter($event)" placeholder="Search contacts...">
|
<input matInput (keyup)="applyFilter($event)" placeholder="Search contacts...">
|
||||||
</mat-form-field> -->
|
</mat-form-field> -->
|
||||||
|
<mat-slide-toggle (change)="toggleShowInactiveContacts()">
|
||||||
|
Show Inactive Contacts
|
||||||
|
</mat-slide-toggle>
|
||||||
|
|
||||||
<button mat-raised-button color="primary" (click)="addNewContact()">
|
<button mat-raised-button color="primary" (click)="addNewContact()">
|
||||||
<mat-icon>add</mat-icon> Add New Contact
|
<mat-icon>add</mat-icon> Add New Contact
|
||||||
</button>
|
</button>
|
||||||
@ -243,7 +247,8 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="form-actions">
|
<div class="form-actions">
|
||||||
<button mat-raised-button color="primary" type="submit" [disabled]="contactForm.invalid">
|
<button mat-raised-button color="primary" type="submit"
|
||||||
|
[disabled]="contactForm.invalid || changeInProgress">
|
||||||
{{ isEditing ? 'Update' : 'Save' }}
|
{{ isEditing ? 'Update' : 'Save' }}
|
||||||
</button>
|
</button>
|
||||||
<button mat-button type="button" (click)="cancelEdit()">Cancel</button>
|
<button mat-button type="button" (click)="cancelEdit()">Cancel</button>
|
||||||
|
|||||||
@ -8,6 +8,11 @@
|
|||||||
clear: both;
|
clear: both;
|
||||||
margin-bottom: -16px;
|
margin-bottom: -16px;
|
||||||
|
|
||||||
|
mat-slide-toggle {
|
||||||
|
transform: scale(0.8);
|
||||||
|
margin-left: -0.5rem;
|
||||||
|
}
|
||||||
|
|
||||||
button {
|
button {
|
||||||
float: right;
|
float: right;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -14,6 +14,7 @@ import { UserPreferences } from '../../core/models/user-preference';
|
|||||||
import { ApiErrorHandlerService } from '../../core/services/common/api-error-handler.service';
|
import { ApiErrorHandlerService } from '../../core/services/common/api-error-handler.service';
|
||||||
import { NotificationService } from '../../core/services/common/notification.service';
|
import { NotificationService } from '../../core/services/common/notification.service';
|
||||||
import { ContactService } from '../../core/services/service-provider/contact.service';
|
import { ContactService } from '../../core/services/service-provider/contact.service';
|
||||||
|
import { finalize } from 'rxjs';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-contacts',
|
selector: 'app-contacts',
|
||||||
@ -32,7 +33,10 @@ export class ContactsComponent implements OnInit {
|
|||||||
isEditing = false;
|
isEditing = false;
|
||||||
currentContactId: number | null = null;
|
currentContactId: number | null = null;
|
||||||
isLoading = false;
|
isLoading = false;
|
||||||
|
changeInProgress = false;
|
||||||
showForm = false;
|
showForm = false;
|
||||||
|
showInactiveContacts = false;
|
||||||
|
contacts: Contact[] = [];
|
||||||
|
|
||||||
contactReadOnlyFields: any = {
|
contactReadOnlyFields: any = {
|
||||||
lastChangedDate: null,
|
lastChangedDate: null,
|
||||||
@ -57,9 +61,9 @@ export class ContactsComponent implements OnInit {
|
|||||||
lastName: ['', [Validators.required, Validators.maxLength(50)]],
|
lastName: ['', [Validators.required, Validators.maxLength(50)]],
|
||||||
middleInitial: ['', [Validators.maxLength(1)]],
|
middleInitial: ['', [Validators.maxLength(1)]],
|
||||||
title: ['', [Validators.required, Validators.maxLength(100)]],
|
title: ['', [Validators.required, Validators.maxLength(100)]],
|
||||||
phone: ['', [Validators.required, Validators.pattern(/^[0-9]{10,15}$/)]],
|
phone: ['', [Validators.required, Validators.pattern(/^[0-9\-\(\)]{10,15}$/)]],
|
||||||
mobile: ['', [Validators.required, Validators.pattern(/^[0-9]{10,15}$/)]],
|
mobile: ['', [Validators.required, Validators.pattern(/^[0-9\-\(\)]{10,15}$/)]],
|
||||||
fax: ['', [Validators.required, Validators.pattern(/^[0-9]{10,15}$/)]],
|
fax: ['', [Validators.required, Validators.pattern(/^[0-9\-\(\)]{10,15}$/)]],
|
||||||
email: ['', [Validators.required, Validators.email, Validators.maxLength(100)]],
|
email: ['', [Validators.required, Validators.email, Validators.maxLength(100)]],
|
||||||
defaultContact: [false]
|
defaultContact: [false]
|
||||||
});
|
});
|
||||||
@ -77,20 +81,34 @@ export class ContactsComponent implements OnInit {
|
|||||||
loadContacts(): void {
|
loadContacts(): void {
|
||||||
this.isLoading = true;
|
this.isLoading = true;
|
||||||
|
|
||||||
this.contactService.getContactsById(this.spid).subscribe({
|
this.contactService.getContactsById(this.spid).pipe(finalize(() => {
|
||||||
|
this.isLoading = false;
|
||||||
|
})).subscribe({
|
||||||
next: (contacts: Contact[]) => {
|
next: (contacts: Contact[]) => {
|
||||||
this.dataSource.data = contacts;
|
this.contacts = contacts;
|
||||||
this.isLoading = false;
|
this.renderContacts();
|
||||||
},
|
},
|
||||||
error: (error: any) => {
|
error: (error: any) => {
|
||||||
let errorMessage = this.errorHandler.handleApiError(error, 'Failed to load contacts');
|
let errorMessage = this.errorHandler.handleApiError(error, 'Failed to load contacts');
|
||||||
this.notificationService.showError(errorMessage);
|
this.notificationService.showError(errorMessage);
|
||||||
this.isLoading = false;
|
|
||||||
console.error('Error loading contacts:', error);
|
console.error('Error loading contacts:', error);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
toggleShowInactiveContacts(): void {
|
||||||
|
this.showInactiveContacts = !this.showInactiveContacts;
|
||||||
|
this.renderContacts();
|
||||||
|
}
|
||||||
|
|
||||||
|
renderContacts(): void {
|
||||||
|
if (this.showInactiveContacts) {
|
||||||
|
this.dataSource.data = this.contacts;
|
||||||
|
} else {
|
||||||
|
this.dataSource.data = this.contacts.filter(contact => !contact.isInactive);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// applyFilter(event: Event): void {
|
// applyFilter(event: Event): void {
|
||||||
// const filterValue = (event.target as HTMLInputElement).value;
|
// const filterValue = (event.target as HTMLInputElement).value;
|
||||||
// this.dataSource.filter = filterValue.trim().toLowerCase();
|
// this.dataSource.filter = filterValue.trim().toLowerCase();
|
||||||
@ -144,7 +162,10 @@ export class ContactsComponent implements OnInit {
|
|||||||
? this.contactService.updateContact(this.currentContactId!, contactData)
|
? this.contactService.updateContact(this.currentContactId!, contactData)
|
||||||
: this.contactService.createContact(this.spid, contactData);
|
: this.contactService.createContact(this.spid, contactData);
|
||||||
|
|
||||||
saveObservable.subscribe({
|
this.changeInProgress = true;
|
||||||
|
saveObservable.pipe(finalize(() => {
|
||||||
|
this.changeInProgress = false;
|
||||||
|
})).subscribe({
|
||||||
next: () => {
|
next: () => {
|
||||||
this.notificationService.showSuccess(`Contact ${this.isEditing ? 'updated' : 'added'} successfully`);
|
this.notificationService.showSuccess(`Contact ${this.isEditing ? 'updated' : 'added'} successfully`);
|
||||||
this.loadContacts();
|
this.loadContacts();
|
||||||
|
|||||||
@ -1,5 +1,8 @@
|
|||||||
<div class="continuation-sheet-container">
|
<div class="continuation-sheet-container">
|
||||||
<div class="actions-bar">
|
<div class="actions-bar">
|
||||||
|
<mat-slide-toggle (change)="toggleShowExpiredRecords()">
|
||||||
|
Show Expired Records
|
||||||
|
</mat-slide-toggle>
|
||||||
<button mat-raised-button color="primary" (click)="addNewContinuationSheet()">
|
<button mat-raised-button color="primary" (click)="addNewContinuationSheet()">
|
||||||
<mat-icon>add</mat-icon> Add New Continuation Sheet
|
<mat-icon>add</mat-icon> Add New Continuation Sheet
|
||||||
</button>
|
</button>
|
||||||
@ -151,7 +154,8 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="form-actions">
|
<div class="form-actions">
|
||||||
<button mat-raised-button color="primary" type="submit" [disabled]="continuationSheetForm.invalid">
|
<button mat-raised-button color="primary" type="submit"
|
||||||
|
[disabled]="continuationSheetForm.invalid || changeInProgress">
|
||||||
{{ isEditing ? 'Update' : 'Save' }}
|
{{ isEditing ? 'Update' : 'Save' }}
|
||||||
</button>
|
</button>
|
||||||
<button mat-button type="button" (click)="cancelEdit()">Cancel</button>
|
<button mat-button type="button" (click)="cancelEdit()">Cancel</button>
|
||||||
|
|||||||
@ -8,6 +8,11 @@
|
|||||||
clear: both;
|
clear: both;
|
||||||
margin-bottom: -16px;
|
margin-bottom: -16px;
|
||||||
|
|
||||||
|
mat-slide-toggle {
|
||||||
|
transform: scale(0.8);
|
||||||
|
margin-left: -0.5rem;
|
||||||
|
}
|
||||||
|
|
||||||
button {
|
button {
|
||||||
float: right;
|
float: right;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -5,7 +5,7 @@ import { MatSort } from '@angular/material/sort';
|
|||||||
import { MatTableDataSource } from '@angular/material/table';
|
import { MatTableDataSource } from '@angular/material/table';
|
||||||
import { AngularMaterialModule } from '../../shared/module/angular-material.module';
|
import { AngularMaterialModule } from '../../shared/module/angular-material.module';
|
||||||
import { CommonModule } from '@angular/common';
|
import { CommonModule } from '@angular/common';
|
||||||
import { of } from 'rxjs';
|
import { finalize, of } from 'rxjs';
|
||||||
import { CustomPaginator } from '../../shared/custom-paginator';
|
import { CustomPaginator } from '../../shared/custom-paginator';
|
||||||
import { UserPreferences } from '../../core/models/user-preference';
|
import { UserPreferences } from '../../core/models/user-preference';
|
||||||
import { ApiErrorHandlerService } from '../../core/services/common/api-error-handler.service';
|
import { ApiErrorHandlerService } from '../../core/services/common/api-error-handler.service';
|
||||||
@ -29,7 +29,10 @@ export class ContinuationSheetFeeComponent implements OnInit {
|
|||||||
isEditing = false;
|
isEditing = false;
|
||||||
currentContinuationSheetId: number | null = null;
|
currentContinuationSheetId: number | null = null;
|
||||||
isLoading = false;
|
isLoading = false;
|
||||||
|
changeInProgress = false;
|
||||||
showForm = false;
|
showForm = false;
|
||||||
|
showExpiredRecords = false;
|
||||||
|
continuationSheets: any[] = [];
|
||||||
|
|
||||||
readOnlyFields: any = {
|
readOnlyFields: any = {
|
||||||
lastChangedDate: null,
|
lastChangedDate: null,
|
||||||
@ -84,20 +87,35 @@ export class ContinuationSheetFeeComponent implements OnInit {
|
|||||||
if (!this.spid) return;
|
if (!this.spid) return;
|
||||||
|
|
||||||
this.isLoading = true;
|
this.isLoading = true;
|
||||||
this.continuationSheetFeeService.getContinuationSheets(this.spid).subscribe({
|
this.continuationSheetFeeService.getContinuationSheets(this.spid).pipe(finalize(() => {
|
||||||
|
this.isLoading = false;
|
||||||
|
})).subscribe({
|
||||||
next: (continuationSheets) => {
|
next: (continuationSheets) => {
|
||||||
this.dataSource.data = continuationSheets;
|
this.continuationSheets = continuationSheets;
|
||||||
this.isLoading = false;
|
this.dataSource.data = this.continuationSheets;
|
||||||
|
this.renderRecods();
|
||||||
},
|
},
|
||||||
error: (error) => {
|
error: (error) => {
|
||||||
let errorMessage = this.errorHandler.handleApiError(error, 'Failed to load continuation sheets');
|
let errorMessage = this.errorHandler.handleApiError(error, 'Failed to load continuation sheets');
|
||||||
this.notificationService.showError(errorMessage);
|
this.notificationService.showError(errorMessage);
|
||||||
this.isLoading = false;
|
|
||||||
return of([]);
|
return of([]);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
toggleShowExpiredRecords(): void {
|
||||||
|
this.showExpiredRecords = !this.showExpiredRecords;
|
||||||
|
this.renderRecods();
|
||||||
|
}
|
||||||
|
|
||||||
|
renderRecods(): void {
|
||||||
|
if (this.showExpiredRecords) {
|
||||||
|
this.dataSource.data = this.continuationSheets;
|
||||||
|
} else {
|
||||||
|
this.dataSource.data = this.continuationSheets.filter(record => !record.expired);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// applyFilter(event: Event): void {
|
// applyFilter(event: Event): void {
|
||||||
// const filterValue = (event.target as HTMLInputElement).value;
|
// const filterValue = (event.target as HTMLInputElement).value;
|
||||||
// this.dataSource.filter = filterValue.trim().toLowerCase();
|
// this.dataSource.filter = filterValue.trim().toLowerCase();
|
||||||
@ -153,7 +171,10 @@ export class ContinuationSheetFeeComponent implements OnInit {
|
|||||||
? this.continuationSheetFeeService.updateContinuationSheet(this.currentContinuationSheetId, continuationSheetData)
|
? this.continuationSheetFeeService.updateContinuationSheet(this.currentContinuationSheetId, continuationSheetData)
|
||||||
: this.continuationSheetFeeService.addContinuationSheet(this.spid, continuationSheetData);
|
: this.continuationSheetFeeService.addContinuationSheet(this.spid, continuationSheetData);
|
||||||
|
|
||||||
saveObservable.subscribe({
|
this.changeInProgress = true;
|
||||||
|
saveObservable.pipe(finalize(() => {
|
||||||
|
this.changeInProgress = false;
|
||||||
|
})).subscribe({
|
||||||
next: () => {
|
next: () => {
|
||||||
this.notificationService.showSuccess(`Continuation Sheet ${this.isEditing ? 'updated' : 'added'} successfully`);
|
this.notificationService.showSuccess(`Continuation Sheet ${this.isEditing ? 'updated' : 'added'} successfully`);
|
||||||
this.loadContinuationSheets();
|
this.loadContinuationSheets();
|
||||||
|
|||||||
@ -1,5 +1,8 @@
|
|||||||
<div class="counterfoil-container">
|
<div class="counterfoil-container">
|
||||||
<div class="actions-bar">
|
<div class="actions-bar">
|
||||||
|
<mat-slide-toggle (change)="toggleShowExpiredRecords()">
|
||||||
|
Show Expired Records
|
||||||
|
</mat-slide-toggle>
|
||||||
<button mat-raised-button color="primary" (click)="addNewCounterfoil()">
|
<button mat-raised-button color="primary" (click)="addNewCounterfoil()">
|
||||||
<mat-icon>add</mat-icon> Add New Counterfoil
|
<mat-icon>add</mat-icon> Add New Counterfoil
|
||||||
</button>
|
</button>
|
||||||
@ -197,7 +200,8 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="form-actions">
|
<div class="form-actions">
|
||||||
<button mat-raised-button color="primary" type="submit" [disabled]="counterfoilForm.invalid">
|
<button mat-raised-button color="primary" type="submit"
|
||||||
|
[disabled]="counterfoilForm.invalid || changeInProgress">
|
||||||
{{ isEditing ? 'Update' : 'Save' }}
|
{{ isEditing ? 'Update' : 'Save' }}
|
||||||
</button>
|
</button>
|
||||||
<button mat-button type="button" (click)="cancelEdit()">Cancel</button>
|
<button mat-button type="button" (click)="cancelEdit()">Cancel</button>
|
||||||
|
|||||||
@ -8,6 +8,11 @@
|
|||||||
clear: both;
|
clear: both;
|
||||||
margin-bottom: -16px;
|
margin-bottom: -16px;
|
||||||
|
|
||||||
|
mat-slide-toggle {
|
||||||
|
transform: scale(0.8);
|
||||||
|
margin-left: -0.5rem;
|
||||||
|
}
|
||||||
|
|
||||||
button {
|
button {
|
||||||
float: right;
|
float: right;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -11,6 +11,7 @@ import { UserPreferences } from '../../core/models/user-preference';
|
|||||||
import { ApiErrorHandlerService } from '../../core/services/common/api-error-handler.service';
|
import { ApiErrorHandlerService } from '../../core/services/common/api-error-handler.service';
|
||||||
import { NotificationService } from '../../core/services/common/notification.service';
|
import { NotificationService } from '../../core/services/common/notification.service';
|
||||||
import { CounterfoilFeeService } from '../../core/services/service-provider/counterfoil-fee.service';
|
import { CounterfoilFeeService } from '../../core/services/service-provider/counterfoil-fee.service';
|
||||||
|
import { finalize } from 'rxjs';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-counterfoil-fee',
|
selector: 'app-counterfoil-fee',
|
||||||
@ -29,7 +30,10 @@ export class CounterfoilFeeComponent implements OnInit {
|
|||||||
isEditing = false;
|
isEditing = false;
|
||||||
currentCounterfoilId: number | null = null;
|
currentCounterfoilId: number | null = null;
|
||||||
isLoading = false;
|
isLoading = false;
|
||||||
|
changeInProgress = false;
|
||||||
showForm = false;
|
showForm = false;
|
||||||
|
showExpiredRecords = false;
|
||||||
|
counterfoilFees: CounterfoilFee[] = [];
|
||||||
|
|
||||||
readOnlyFields: any = {
|
readOnlyFields: any = {
|
||||||
lastChangedDate: null,
|
lastChangedDate: null,
|
||||||
@ -100,22 +104,37 @@ export class CounterfoilFeeComponent implements OnInit {
|
|||||||
if (!this.spid) return;
|
if (!this.spid) return;
|
||||||
|
|
||||||
this.isLoading = true;
|
this.isLoading = true;
|
||||||
this.counterfoilFeeService.getCounterfoils(this.spid)
|
this.counterfoilFeeService.getCounterfoils(this.spid).pipe(finalize(() => {
|
||||||
|
this.isLoading = false;
|
||||||
|
}))
|
||||||
.subscribe({
|
.subscribe({
|
||||||
next: (
|
next: (
|
||||||
counterfoils: CounterfoilFee[]) => {
|
counterfoils: CounterfoilFee[]) => {
|
||||||
this.dataSource.data = counterfoils;
|
this.counterfoilFees = counterfoils;
|
||||||
this.isLoading = false;
|
this.dataSource.data = this.counterfoilFees;
|
||||||
|
this.renderRecods();
|
||||||
},
|
},
|
||||||
error: (error: any) => {
|
error: (error: any) => {
|
||||||
let errorMessage = this.errorHandler.handleApiError(error, 'Failed to load counterfoils');
|
let errorMessage = this.errorHandler.handleApiError(error, 'Failed to load counterfoils');
|
||||||
this.notificationService.showError(errorMessage);
|
this.notificationService.showError(errorMessage);
|
||||||
this.isLoading = false;
|
|
||||||
console.error('Error loading counterfoils:', error);
|
console.error('Error loading counterfoils:', error);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
toggleShowExpiredRecords(): void {
|
||||||
|
this.showExpiredRecords = !this.showExpiredRecords;
|
||||||
|
this.renderRecods();
|
||||||
|
}
|
||||||
|
|
||||||
|
renderRecods(): void {
|
||||||
|
if (this.showExpiredRecords) {
|
||||||
|
this.dataSource.data = this.counterfoilFees;
|
||||||
|
} else {
|
||||||
|
this.dataSource.data = this.counterfoilFees.filter(record => !record.expired);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// applyFilter(event: Event): void {
|
// applyFilter(event: Event): void {
|
||||||
// const filterValue = (event.target as HTMLInputElement).value;
|
// const filterValue = (event.target as HTMLInputElement).value;
|
||||||
// this.dataSource.filter = filterValue.trim().toLowerCase();
|
// this.dataSource.filter = filterValue.trim().toLowerCase();
|
||||||
@ -177,7 +196,10 @@ export class CounterfoilFeeComponent implements OnInit {
|
|||||||
? this.counterfoilFeeService.updateCounterfoil(this.currentCounterfoilId, counterfoilData)
|
? this.counterfoilFeeService.updateCounterfoil(this.currentCounterfoilId, counterfoilData)
|
||||||
: this.counterfoilFeeService.addCounterfoil(this.spid, counterfoilData);
|
: this.counterfoilFeeService.addCounterfoil(this.spid, counterfoilData);
|
||||||
|
|
||||||
saveObservable.subscribe({
|
this.changeInProgress = true;
|
||||||
|
saveObservable.pipe(finalize(() => {
|
||||||
|
this.changeInProgress = false;
|
||||||
|
})).subscribe({
|
||||||
next: () => {
|
next: () => {
|
||||||
this.notificationService.showSuccess(`Counterfoil ${this.isEditing ? 'updated' : 'added'} successfully`);
|
this.notificationService.showSuccess(`Counterfoil ${this.isEditing ? 'updated' : 'added'} successfully`);
|
||||||
this.loadCounterfoils();
|
this.loadCounterfoils();
|
||||||
|
|||||||
@ -1,5 +1,8 @@
|
|||||||
<div class="expedited-fee-container">
|
<div class="expedited-fee-container">
|
||||||
<div class="actions-bar">
|
<div class="actions-bar">
|
||||||
|
<mat-slide-toggle (change)="toggleShowExpiredRecords()">
|
||||||
|
Show Expired Records
|
||||||
|
</mat-slide-toggle>
|
||||||
<button mat-raised-button color="primary" (click)="addNewFee()">
|
<button mat-raised-button color="primary" (click)="addNewFee()">
|
||||||
<mat-icon>add</mat-icon> Add New Expedited Fee
|
<mat-icon>add</mat-icon> Add New Expedited Fee
|
||||||
</button>
|
</button>
|
||||||
@ -195,7 +198,8 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="form-actions">
|
<div class="form-actions">
|
||||||
<button mat-raised-button color="primary" type="submit" [disabled]="feeForm.invalid">
|
<button mat-raised-button color="primary" type="submit"
|
||||||
|
[disabled]="feeForm.invalid || changeInProgress">
|
||||||
{{ isEditing ? 'Update' : 'Save' }}
|
{{ isEditing ? 'Update' : 'Save' }}
|
||||||
</button>
|
</button>
|
||||||
<button mat-button type="button" (click)="cancelEdit()">Cancel</button>
|
<button mat-button type="button" (click)="cancelEdit()">Cancel</button>
|
||||||
|
|||||||
@ -8,6 +8,11 @@
|
|||||||
clear: both;
|
clear: both;
|
||||||
margin-bottom: -16px;
|
margin-bottom: -16px;
|
||||||
|
|
||||||
|
mat-slide-toggle {
|
||||||
|
transform: scale(0.8);
|
||||||
|
margin-left: -0.5rem;
|
||||||
|
}
|
||||||
|
|
||||||
button {
|
button {
|
||||||
float: right;
|
float: right;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -9,7 +9,7 @@ import { CustomPaginator } from '../../shared/custom-paginator';
|
|||||||
import { ExpeditedFee } from '../../core/models/service-provider/expedited-fee';
|
import { ExpeditedFee } from '../../core/models/service-provider/expedited-fee';
|
||||||
import { DeliveryType } from '../../core/models/delivery-type';
|
import { DeliveryType } from '../../core/models/delivery-type';
|
||||||
import { TimeZone } from '../../core/models/timezone';
|
import { TimeZone } from '../../core/models/timezone';
|
||||||
import { Subject, takeUntil } from 'rxjs';
|
import { finalize, Subject, takeUntil } from 'rxjs';
|
||||||
import { UserPreferences } from '../../core/models/user-preference';
|
import { UserPreferences } from '../../core/models/user-preference';
|
||||||
import { ApiErrorHandlerService } from '../../core/services/common/api-error-handler.service';
|
import { ApiErrorHandlerService } from '../../core/services/common/api-error-handler.service';
|
||||||
import { CommonService } from '../../core/services/common/common.service';
|
import { CommonService } from '../../core/services/common/common.service';
|
||||||
@ -34,7 +34,10 @@ export class ExpeditedFeeComponent implements OnInit, OnDestroy {
|
|||||||
isEditing = false;
|
isEditing = false;
|
||||||
currentFeeId: number | null = null;
|
currentFeeId: number | null = null;
|
||||||
isLoading = false;
|
isLoading = false;
|
||||||
|
changeInProgress = false;
|
||||||
showForm = false;
|
showForm = false;
|
||||||
|
showExpiredRecords = false;
|
||||||
|
expeditedFees: ExpeditedFee[] = [];
|
||||||
|
|
||||||
readOnlyFields: any = {
|
readOnlyFields: any = {
|
||||||
lastChangedDate: null,
|
lastChangedDate: null,
|
||||||
@ -99,20 +102,35 @@ export class ExpeditedFeeComponent implements OnInit, OnDestroy {
|
|||||||
loadExpeditedFees(): void {
|
loadExpeditedFees(): void {
|
||||||
this.isLoading = true;
|
this.isLoading = true;
|
||||||
|
|
||||||
this.expeditedFeeService.getExpeditedFees(this.spid).subscribe({
|
this.expeditedFeeService.getExpeditedFees(this.spid).pipe(finalize(() => {
|
||||||
|
this.isLoading = false;
|
||||||
|
})).subscribe({
|
||||||
next: (fees: ExpeditedFee[]) => {
|
next: (fees: ExpeditedFee[]) => {
|
||||||
this.dataSource.data = fees;
|
this.expeditedFees = fees;
|
||||||
this.isLoading = false;
|
this.dataSource.data = this.expeditedFees;
|
||||||
|
this.renderRecods();
|
||||||
},
|
},
|
||||||
error: (error: any) => {
|
error: (error: any) => {
|
||||||
let errorMessage = this.errorHandler.handleApiError(error, 'Failed to load expedited fees');
|
let errorMessage = this.errorHandler.handleApiError(error, 'Failed to load expedited fees');
|
||||||
this.notificationService.showError(errorMessage);
|
this.notificationService.showError(errorMessage);
|
||||||
this.isLoading = false;
|
|
||||||
console.error('Error loading expedited fees:', error);
|
console.error('Error loading expedited fees:', error);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
toggleShowExpiredRecords(): void {
|
||||||
|
this.showExpiredRecords = !this.showExpiredRecords;
|
||||||
|
this.renderRecods();
|
||||||
|
}
|
||||||
|
|
||||||
|
renderRecods(): void {
|
||||||
|
if (this.showExpiredRecords) {
|
||||||
|
this.dataSource.data = this.expeditedFees;
|
||||||
|
} else {
|
||||||
|
this.dataSource.data = this.expeditedFees.filter(record => !record.expired);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
loadLookupData(): void {
|
loadLookupData(): void {
|
||||||
this.loadDeliveryTypes();
|
this.loadDeliveryTypes();
|
||||||
this.loadTimeZones();
|
this.loadTimeZones();
|
||||||
@ -124,17 +142,15 @@ export class ExpeditedFeeComponent implements OnInit, OnDestroy {
|
|||||||
.subscribe({
|
.subscribe({
|
||||||
next: (timeZones) => {
|
next: (timeZones) => {
|
||||||
this.timeZones = timeZones;
|
this.timeZones = timeZones;
|
||||||
this.isLoading = false;
|
|
||||||
},
|
},
|
||||||
error: (error) => {
|
error: (error) => {
|
||||||
console.error('Failed to load time zones', error);
|
console.error('Failed to load time zones', error);
|
||||||
this.isLoading = false;
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
loadDeliveryTypes(): void {
|
loadDeliveryTypes(): void {
|
||||||
this.commonService.getDeliveryTypes(this.spid)
|
this.commonService.getDeliveryTypes()
|
||||||
.pipe(takeUntil(this.destroy$))
|
.pipe(takeUntil(this.destroy$))
|
||||||
.subscribe({
|
.subscribe({
|
||||||
next: (deliveryTypes) => {
|
next: (deliveryTypes) => {
|
||||||
@ -142,7 +158,6 @@ export class ExpeditedFeeComponent implements OnInit, OnDestroy {
|
|||||||
},
|
},
|
||||||
error: (error) => {
|
error: (error) => {
|
||||||
console.error('Failed to load delivery types', error);
|
console.error('Failed to load delivery types', error);
|
||||||
this.isLoading = false;
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -207,7 +222,10 @@ export class ExpeditedFeeComponent implements OnInit, OnDestroy {
|
|||||||
? this.expeditedFeeService.updateExpeditedFee(this.currentFeeId, feeData)
|
? this.expeditedFeeService.updateExpeditedFee(this.currentFeeId, feeData)
|
||||||
: this.expeditedFeeService.createExpeditedFee(this.spid, feeData);
|
: this.expeditedFeeService.createExpeditedFee(this.spid, feeData);
|
||||||
|
|
||||||
saveObservable.subscribe({
|
this.changeInProgress = true;
|
||||||
|
saveObservable.pipe(finalize(() => {
|
||||||
|
this.changeInProgress = false;
|
||||||
|
})).subscribe({
|
||||||
next: () => {
|
next: () => {
|
||||||
this.notificationService.showSuccess(`Expedited fee ${this.isEditing ? 'updated' : 'added'} successfully`);
|
this.notificationService.showSuccess(`Expedited fee ${this.isEditing ? 'updated' : 'added'} successfully`);
|
||||||
this.loadExpeditedFees();
|
this.loadExpeditedFees();
|
||||||
|
|||||||
@ -1,5 +1,8 @@
|
|||||||
<div class="security-deposit-container">
|
<div class="security-deposit-container">
|
||||||
<div class="actions-bar">
|
<div class="actions-bar">
|
||||||
|
<mat-slide-toggle (change)="toggleShowExpiredRecords()">
|
||||||
|
Show Expired Records
|
||||||
|
</mat-slide-toggle>
|
||||||
<button mat-raised-button color="primary" (click)="addNewDeposit()">
|
<button mat-raised-button color="primary" (click)="addNewDeposit()">
|
||||||
<mat-icon>add</mat-icon> Add New Security Deposit
|
<mat-icon>add</mat-icon> Add New Security Deposit
|
||||||
</button>
|
</button>
|
||||||
@ -179,7 +182,8 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="form-actions">
|
<div class="form-actions">
|
||||||
<button mat-raised-button color="primary" type="submit" [disabled]="depositForm.invalid">
|
<button mat-raised-button color="primary" type="submit"
|
||||||
|
[disabled]="depositForm.invalid || changeInProgress">
|
||||||
{{ isEditing ? 'Update' : 'Save' }}
|
{{ isEditing ? 'Update' : 'Save' }}
|
||||||
</button>
|
</button>
|
||||||
<button mat-button type="button" (click)="cancelEdit()">Cancel</button>
|
<button mat-button type="button" (click)="cancelEdit()">Cancel</button>
|
||||||
|
|||||||
@ -8,6 +8,11 @@
|
|||||||
clear: both;
|
clear: both;
|
||||||
margin-bottom: -16px;
|
margin-bottom: -16px;
|
||||||
|
|
||||||
|
mat-slide-toggle {
|
||||||
|
transform: scale(0.8);
|
||||||
|
margin-left: -0.5rem;
|
||||||
|
}
|
||||||
|
|
||||||
button {
|
button {
|
||||||
float: right;
|
float: right;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -13,6 +13,7 @@ import { ApiErrorHandlerService } from '../../core/services/common/api-error-han
|
|||||||
import { CommonService } from '../../core/services/common/common.service';
|
import { CommonService } from '../../core/services/common/common.service';
|
||||||
import { NotificationService } from '../../core/services/common/notification.service';
|
import { NotificationService } from '../../core/services/common/notification.service';
|
||||||
import { SecurityDepositService } from '../../core/services/service-provider/security-deposit.service';
|
import { SecurityDepositService } from '../../core/services/service-provider/security-deposit.service';
|
||||||
|
import { finalize } from 'rxjs';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-security-deposit',
|
selector: 'app-security-deposit',
|
||||||
@ -31,7 +32,10 @@ export class SecurityDepositComponent implements OnInit {
|
|||||||
isEditing = false;
|
isEditing = false;
|
||||||
currentDepositId: number | null = null;
|
currentDepositId: number | null = null;
|
||||||
isLoading = false;
|
isLoading = false;
|
||||||
|
changeInProgress = false;
|
||||||
showForm = false;
|
showForm = false;
|
||||||
|
showExpiredRecords = false;
|
||||||
|
securityDeposits: SecurityDeposit[] = [];
|
||||||
|
|
||||||
readOnlyFields: any = {
|
readOnlyFields: any = {
|
||||||
lastChangedDate: null,
|
lastChangedDate: null,
|
||||||
@ -67,7 +71,7 @@ export class SecurityDepositComponent implements OnInit {
|
|||||||
holderType: ['CORP', Validators.required],
|
holderType: ['CORP', Validators.required],
|
||||||
uscibMember: ['Y', Validators.required],
|
uscibMember: ['Y', Validators.required],
|
||||||
specialCommodity: [''],
|
specialCommodity: [''],
|
||||||
specialCountry: [''],
|
specialCountry: ['US'],
|
||||||
rate: [0, [Validators.required, Validators.min(0)]],
|
rate: [0, [Validators.required, Validators.min(0)]],
|
||||||
effectiveDate: ['', Validators.required]
|
effectiveDate: ['', Validators.required]
|
||||||
});
|
});
|
||||||
@ -85,20 +89,35 @@ export class SecurityDepositComponent implements OnInit {
|
|||||||
|
|
||||||
loadSecurityDeposits(): void {
|
loadSecurityDeposits(): void {
|
||||||
this.isLoading = true;
|
this.isLoading = true;
|
||||||
this.securityDepositService.getSecurityDeposits(this.spid).subscribe({
|
this.securityDepositService.getSecurityDeposits(this.spid).pipe(finalize(() => {
|
||||||
|
this.changeInProgress = false;
|
||||||
|
})).subscribe({
|
||||||
next: (deposits) => {
|
next: (deposits) => {
|
||||||
this.dataSource.data = deposits;
|
this.securityDeposits = deposits;
|
||||||
this.isLoading = false;
|
this.dataSource.data = this.securityDeposits;
|
||||||
|
this.renderRecods();
|
||||||
},
|
},
|
||||||
error: (error) => {
|
error: (error) => {
|
||||||
let errorMessage = this.errorHandler.handleApiError(error, 'Failed to load security deposits');
|
let errorMessage = this.errorHandler.handleApiError(error, 'Failed to load security deposits');
|
||||||
this.notificationService.showError(errorMessage);
|
this.notificationService.showError(errorMessage);
|
||||||
this.isLoading = false;
|
|
||||||
console.error('Error loading security deposits:', error);
|
console.error('Error loading security deposits:', error);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
toggleShowExpiredRecords(): void {
|
||||||
|
this.showExpiredRecords = !this.showExpiredRecords;
|
||||||
|
this.renderRecods();
|
||||||
|
}
|
||||||
|
|
||||||
|
renderRecods(): void {
|
||||||
|
if (this.showExpiredRecords) {
|
||||||
|
this.dataSource.data = this.securityDeposits;
|
||||||
|
} else {
|
||||||
|
this.dataSource.data = this.securityDeposits.filter(record => !record.expired);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
loadCountries(): void {
|
loadCountries(): void {
|
||||||
this.commonService.getCountries().subscribe({
|
this.commonService.getCountries().subscribe({
|
||||||
next: (countries) => {
|
next: (countries) => {
|
||||||
@ -126,6 +145,7 @@ export class SecurityDepositComponent implements OnInit {
|
|||||||
this.depositForm.reset({
|
this.depositForm.reset({
|
||||||
holderType: 'CORP',
|
holderType: 'CORP',
|
||||||
uscibMember: 'N',
|
uscibMember: 'N',
|
||||||
|
specialCountry: 'US',
|
||||||
});
|
});
|
||||||
this.depositForm.patchValue({ rate: 0 });
|
this.depositForm.patchValue({ rate: 0 });
|
||||||
|
|
||||||
@ -174,7 +194,10 @@ export class SecurityDepositComponent implements OnInit {
|
|||||||
? this.securityDepositService.updateSecurityDeposit(this.currentDepositId, depositData)
|
? this.securityDepositService.updateSecurityDeposit(this.currentDepositId, depositData)
|
||||||
: this.securityDepositService.createSecurityDeposit(this.spid, depositData);
|
: this.securityDepositService.createSecurityDeposit(this.spid, depositData);
|
||||||
|
|
||||||
saveObservable.subscribe({
|
this.changeInProgress = true;
|
||||||
|
saveObservable.pipe(finalize(() => {
|
||||||
|
this.changeInProgress = false;
|
||||||
|
})).subscribe({
|
||||||
next: () => {
|
next: () => {
|
||||||
this.notificationService.showSuccess(`Security deposit ${this.isEditing ? 'updated' : 'added'} successfully`);
|
this.notificationService.showSuccess(`Security deposit ${this.isEditing ? 'updated' : 'added'} successfully`);
|
||||||
this.loadSecurityDeposits();
|
this.loadSecurityDeposits();
|
||||||
@ -222,6 +245,7 @@ export class SecurityDepositComponent implements OnInit {
|
|||||||
this.depositForm.reset({
|
this.depositForm.reset({
|
||||||
holderType: 'CORP',
|
holderType: 'CORP',
|
||||||
uscibMember: 'N',
|
uscibMember: 'N',
|
||||||
|
specialCountry: 'US',
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
15
src/app/shared/pipes/proper-case.pipe.ts
Normal file
15
src/app/shared/pipes/proper-case.pipe.ts
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
import { Pipe, PipeTransform } from '@angular/core';
|
||||||
|
|
||||||
|
@Pipe({
|
||||||
|
name: 'properCase'
|
||||||
|
})
|
||||||
|
export class ProperCasePipe implements PipeTransform {
|
||||||
|
|
||||||
|
transform(value: string): string {
|
||||||
|
if (!value) return '';
|
||||||
|
|
||||||
|
return value
|
||||||
|
.toLowerCase()
|
||||||
|
.replace(/\b\w/g, char => char.toUpperCase());
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user