Fix for account id parameter in account tabs (#1711)

Co-authored-by: Jose Alberto Hernandez <alberto@MacBook-Pro.local>
This commit is contained in:
José Alberto Hernández
2023-03-17 22:18:43 -06:00
committed by GitHub
co-authored by Jose Alberto Hernandez
parent 7b9e036f01
commit 0f450262b9
11 changed files with 42 additions and 12 deletions
+8
View File
@@ -148,4 +148,12 @@ export class Datatables {
return columnName;
}
public isValidUrl(urlString: string): boolean {
try {
return Boolean(new URL(urlString));
} catch (e) {
return false;
}
}
}
@@ -24,7 +24,7 @@ export class LoanDatatableResolver implements Resolve<Object> {
* @returns {Observable<any>}
*/
resolve(route: ActivatedRouteSnapshot): Observable<any> {
const loanId = route.paramMap.get('loanId') || route.parent.paramMap.get('loanId');
const loanId = route.paramMap.get('loanId') || route.parent.parent.paramMap.get('loanId');
const datatableName = route.paramMap.get('datatableName');
return this.loansService.getLoanDatatable(loanId, datatableName);
}
@@ -30,11 +30,11 @@ export class LoanDocumentsTabComponent implements OnInit {
constructor(private route: ActivatedRoute,
private loansService: LoansService,
private settingsService: SettingsService) {
this.entityId = this.route.snapshot.params['loanId'];
this.entityId = this.route.parent.snapshot.params['loanId'];
this.route.data.subscribe((data: { loanDocuments: any }) => {
this.getLoanDocumentsData(data.loanDocuments);
});
this.route.data.subscribe((data: { loanDocuments: any }) => {
this.getLoanDocumentsData(data.loanDocuments);
});
}
ngOnInit() { }
@@ -23,7 +23,7 @@ export class NotesTabComponent implements OnInit {
private authenticationService: AuthenticationService) {
const savedCredentials = this.authenticationService.getCredentials();
this.username = savedCredentials.username;
this.entityId = this.route.snapshot.params['loanId'];
this.entityId = this.route.parent.snapshot.params['loanId'];
this.route.data.subscribe((data: { loanNotes: any }) => {
this.entityNotes = data.loanNotes;
});
@@ -56,7 +56,9 @@ export class SavingAccountActionsComponent {
*/
constructor(private route: ActivatedRoute) {
this.route.data.subscribe((data: { savingsAccountActionData: any }) => {
this.currencyCode = data.savingsAccountActionData.currency.code;
if (data.savingsAccountActionData) {
this.currencyCode = data.savingsAccountActionData.currency.code;
}
});
const name = this.route.snapshot.params['name'];
this.actions[name] = true;
@@ -19,7 +19,7 @@ export class NotesTabComponent implements OnInit {
private authenticationService: AuthenticationService) {
const savedCredentials = this.authenticationService.getCredentials();
this.username = savedCredentials.username;
this.entityId = this.route.snapshot.params['savingAccountId'];
this.entityId = this.route.parent.snapshot.params['savingAccountId'];
this.route.data.subscribe((data: { savingAccountNotes: any }) => {
this.entityNotes = data.savingAccountNotes;
});
@@ -30,7 +30,7 @@ export class SavingsDocumentsTabComponent implements OnInit {
this.route.data.subscribe((data: { savingsDocuments: any }) => {
this.setSavingsDocumentsData(data.savingsDocuments);
});
this.entityId = this.route.snapshot.params['savingAccountId'];
this.entityId = this.route.parent.snapshot.paramMap.get('savingAccountId');
}
ngOnInit() {
@@ -53,8 +53,8 @@ export class SavingsDocumentsTabComponent implements OnInit {
this.entityDocuments = data;
}
downloadDocument(parentEntityId: string, documentId: string) {
this.savingsService.downloadSavingsDocument(parentEntityId, documentId).subscribe(res => {
downloadDocument(documentId: string) {
this.savingsService.downloadSavingsDocument(this.entityId, documentId).subscribe(res => {
const url = window.URL.createObjectURL(res);
window.open(url);
});
@@ -42,7 +42,7 @@ export class TransactionsTabComponent implements OnInit {
ngOnInit() {
this.dataSource = new MatTableDataSource(this.transactionsData);
this.accountWithTransactions = (this.transactionsData.length > 0);
this.accountWithTransactions = (this.transactionsData && this.transactionsData.length > 0);
this.dataSource.paginator = this.paginator;
this.dataSource.sort = this.sort;
}
@@ -36,6 +36,12 @@
{{dataObject.data[0].row[i]}}
</span>
<span *ngSwitchDefault>
<span class="m-r-5" *ngIf="isValidUrl(dataObject.data[0].row[i])">
<button mat-icon-button matTooltip="View Link" (click)="openSite(dataObject.data[0].row[i])"
matTooltipPosition="right" class="small-icon">
<fa-icon icon="eye" size="lg"></fa-icon>
</button>
</span>
{{dataObject.data[0].row[i]}}
</span>
</div>
@@ -26,3 +26,8 @@
word-break: break-all;
white-space: normal;
}
.small-icon {
width: 30px;
height: 30px;
}
@@ -133,4 +133,13 @@ export class DatatableSingleRowComponent implements OnInit {
getInputName(attr: string): string {
return this.datatables.getName(attr);
}
isValidUrl(urlString: string): boolean {
return this.datatables.isValidUrl(urlString);
}
openSite(siteUrl: string) {
window.open(siteUrl, '_blank');
}
}