diff --git a/src/app/core/utils/datatables.ts b/src/app/core/utils/datatables.ts index 1d1ba6ce4..8e48025b1 100644 --- a/src/app/core/utils/datatables.ts +++ b/src/app/core/utils/datatables.ts @@ -148,4 +148,12 @@ export class Datatables { return columnName; } + public isValidUrl(urlString: string): boolean { + try { + return Boolean(new URL(urlString)); + } catch (e) { + return false; + } + } + } diff --git a/src/app/loans/common-resolvers/loan-datatable.resolver.ts b/src/app/loans/common-resolvers/loan-datatable.resolver.ts index bd2b947bc..5a57bbe06 100644 --- a/src/app/loans/common-resolvers/loan-datatable.resolver.ts +++ b/src/app/loans/common-resolvers/loan-datatable.resolver.ts @@ -24,7 +24,7 @@ export class LoanDatatableResolver implements Resolve { * @returns {Observable} */ resolve(route: ActivatedRouteSnapshot): Observable { - 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); } diff --git a/src/app/loans/loans-view/loan-documents-tab/loan-documents-tab.component.ts b/src/app/loans/loans-view/loan-documents-tab/loan-documents-tab.component.ts index cd19306ee..2a0b9a8dc 100644 --- a/src/app/loans/loans-view/loan-documents-tab/loan-documents-tab.component.ts +++ b/src/app/loans/loans-view/loan-documents-tab/loan-documents-tab.component.ts @@ -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() { } diff --git a/src/app/loans/loans-view/notes-tab/notes-tab.component.ts b/src/app/loans/loans-view/notes-tab/notes-tab.component.ts index 0d4eb68aa..7944f713e 100644 --- a/src/app/loans/loans-view/notes-tab/notes-tab.component.ts +++ b/src/app/loans/loans-view/notes-tab/notes-tab.component.ts @@ -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; }); diff --git a/src/app/savings/saving-account-actions/saving-account-actions.component.ts b/src/app/savings/saving-account-actions/saving-account-actions.component.ts index 4c9d82d2a..ea3ce29e5 100644 --- a/src/app/savings/saving-account-actions/saving-account-actions.component.ts +++ b/src/app/savings/saving-account-actions/saving-account-actions.component.ts @@ -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; diff --git a/src/app/savings/savings-account-view/notes-tab/notes-tab.component.ts b/src/app/savings/savings-account-view/notes-tab/notes-tab.component.ts index ec67cdd1e..56da5ddfa 100644 --- a/src/app/savings/savings-account-view/notes-tab/notes-tab.component.ts +++ b/src/app/savings/savings-account-view/notes-tab/notes-tab.component.ts @@ -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; }); diff --git a/src/app/savings/savings-account-view/savings-documents-tab/savings-documents-tab.component.ts b/src/app/savings/savings-account-view/savings-documents-tab/savings-documents-tab.component.ts index 367c12aaf..d728974db 100644 --- a/src/app/savings/savings-account-view/savings-documents-tab/savings-documents-tab.component.ts +++ b/src/app/savings/savings-account-view/savings-documents-tab/savings-documents-tab.component.ts @@ -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); }); diff --git a/src/app/savings/savings-account-view/transactions-tab/transactions-tab.component.ts b/src/app/savings/savings-account-view/transactions-tab/transactions-tab.component.ts index aa5dbbaf1..8464efe7e 100644 --- a/src/app/savings/savings-account-view/transactions-tab/transactions-tab.component.ts +++ b/src/app/savings/savings-account-view/transactions-tab/transactions-tab.component.ts @@ -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; } diff --git a/src/app/shared/tabs/entity-datatable-tab/datatable-single-row/datatable-single-row.component.html b/src/app/shared/tabs/entity-datatable-tab/datatable-single-row/datatable-single-row.component.html index cbad11e6a..34c7e12b5 100644 --- a/src/app/shared/tabs/entity-datatable-tab/datatable-single-row/datatable-single-row.component.html +++ b/src/app/shared/tabs/entity-datatable-tab/datatable-single-row/datatable-single-row.component.html @@ -36,6 +36,12 @@ {{dataObject.data[0].row[i]}} + + + {{dataObject.data[0].row[i]}} diff --git a/src/app/shared/tabs/entity-datatable-tab/datatable-single-row/datatable-single-row.component.scss b/src/app/shared/tabs/entity-datatable-tab/datatable-single-row/datatable-single-row.component.scss index 9a6b89e74..b1f06a1d0 100644 --- a/src/app/shared/tabs/entity-datatable-tab/datatable-single-row/datatable-single-row.component.scss +++ b/src/app/shared/tabs/entity-datatable-tab/datatable-single-row/datatable-single-row.component.scss @@ -26,3 +26,8 @@ word-break: break-all; white-space: normal; } + +.small-icon { + width: 30px; + height: 30px; +} diff --git a/src/app/shared/tabs/entity-datatable-tab/datatable-single-row/datatable-single-row.component.ts b/src/app/shared/tabs/entity-datatable-tab/datatable-single-row/datatable-single-row.component.ts index 21793c31d..908f95cff 100644 --- a/src/app/shared/tabs/entity-datatable-tab/datatable-single-row/datatable-single-row.component.ts +++ b/src/app/shared/tabs/entity-datatable-tab/datatable-single-row/datatable-single-row.component.ts @@ -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'); + } + }