diff --git a/src/app/domain/domain-obj-modification/domain-obj-modification.service.ts b/src/app/domain/domain-obj-modification/domain-obj-modification.service.ts index 8fd2813c..ff290f63 100644 --- a/src/app/domain/domain-obj-modification/domain-obj-modification.service.ts +++ b/src/app/domain/domain-obj-modification/domain-obj-modification.service.ts @@ -36,7 +36,7 @@ export class DomainObjModificationService { this.errors$.next(e); console.error('Build meta error:', e); }); - this.metaApplicator.errors.subscribe((e) => console.log('Apply meta error:', e)); + this.metaApplicator.errors.subscribe((e) => console.error('Apply meta error:', e)); } init(namespace = 'domain'): Observable { diff --git a/src/app/parties/parties.component.html b/src/app/parties/parties.component.html index 50beb61e..9ee1ec60 100644 --- a/src/app/parties/parties.component.html +++ b/src/app/parties/parties.component.html @@ -9,10 +9,24 @@ + + diff --git a/src/app/sections/party-claims/claims-table/claims-table.component.ts b/src/app/sections/party-claims/claims-table/claims-table.component.ts index c24a4d25..37399e43 100644 --- a/src/app/sections/party-claims/claims-table/claims-table.component.ts +++ b/src/app/sections/party-claims/claims-table/claims-table.component.ts @@ -1,4 +1,5 @@ import { ChangeDetectionStrategy, Component, Input } from '@angular/core'; +import { Router } from '@angular/router'; import { Claim, ClaimID } from '../../../thrift-services/damsel/gen-model/claim_management'; import { PartyID } from '../../../thrift-services/damsel/gen-model/domain'; @@ -22,7 +23,13 @@ export class ClaimsTableComponent { 'actions', ]; + constructor(private router: Router) {} + navigateToClaim(partyID: PartyID, claimID: ClaimID) { - console.log(partyID, claimID.toNumber(), '===========>>>'); + this.router.navigate([`/party/${partyID}/claim/${claimID}`]); + } + + navigateToDeprecatedClaim(partyID: PartyID, claimID: ClaimID) { + this.router.navigate([`/claim-mgt/party/${partyID}/claim/${claimID}`]); } } diff --git a/src/app/sections/party-claims/create-claim.service.ts b/src/app/sections/party-claims/create-claim.service.ts new file mode 100644 index 00000000..c1b7537d --- /dev/null +++ b/src/app/sections/party-claims/create-claim.service.ts @@ -0,0 +1,44 @@ +import { Injectable } from '@angular/core'; +import { MatSnackBar } from '@angular/material/snack-bar'; +import { ActivatedRoute, Router } from '@angular/router'; +import { BehaviorSubject, EMPTY, Observable, Subject } from 'rxjs'; +import { catchError, pluck, switchMap } from 'rxjs/operators'; + +import { ClaimManagementService } from '../../thrift-services/damsel/claim-management.service'; +import { Claim } from '../../thrift-services/damsel/gen-model/claim_management'; + +@Injectable() +export class CreateClaimService { + claimCreation$ = new Subject(); + + claim$: Observable = this.claimCreation$.pipe( + switchMap((partyId) => + this.claimService.createClaim(partyId, []).pipe( + catchError(() => { + this.snackBar.open('An error occurred while claim creation', 'OK'); + this.error$.next({ hasError: true }); + return EMPTY; + }) + ) + ) + ); + + private error$ = new BehaviorSubject({ hasError: false }); + + constructor( + private route: ActivatedRoute, + private router: Router, + private claimService: ClaimManagementService, + private snackBar: MatSnackBar + ) { + this.claim$.subscribe(({ id, party_id }) => { + this.router.navigate([`claim-mgt/party/${party_id}/claim/${id}`]); + }); + } + + createClaim() { + this.route.params.pipe(pluck('partyID')).subscribe((partyID) => { + this.claimCreation$.next(partyID); + }); + } +} diff --git a/src/app/sections/party-claims/party-claims.component.html b/src/app/sections/party-claims/party-claims.component.html index 95fa8cc1..23eb4c1f 100644 --- a/src/app/sections/party-claims/party-claims.component.html +++ b/src/app/sections/party-claims/party-claims.component.html @@ -1,29 +1,34 @@ -
Party claims
-
- - - - - - - - - - - - - +
+
+
Party claims
+ +
+
+ + + + + + + - + + + + + + + +
diff --git a/src/app/sections/party-claims/party-claims.component.ts b/src/app/sections/party-claims/party-claims.component.ts index 408ab30d..76bb1522 100644 --- a/src/app/sections/party-claims/party-claims.component.ts +++ b/src/app/sections/party-claims/party-claims.component.ts @@ -1,12 +1,16 @@ import { ChangeDetectionStrategy, Component, OnInit } from '@angular/core'; +import { MatDialog } from '@angular/material/dialog'; import { MatSnackBar } from '@angular/material/snack-bar'; +import { filter } from 'rxjs/operators'; +import { ConfirmActionDialogComponent } from '../../confirm-action-dialog'; import { SearchFormValue } from '../claim-search-form'; +import { CreateClaimService } from './create-claim.service'; import { PartyClaimsService } from './party-claims.service'; @Component({ templateUrl: 'party-claims.component.html', - providers: [PartyClaimsService], + providers: [PartyClaimsService, CreateClaimService], changeDetection: ChangeDetectionStrategy.OnPush, }) export class PartyClaimsComponent implements OnInit { @@ -14,7 +18,12 @@ export class PartyClaimsComponent implements OnInit { claims$ = this.partyClaimsService.searchResult$; hasMore$ = this.partyClaimsService.hasMore$; - constructor(private partyClaimsService: PartyClaimsService, private snackBar: MatSnackBar) {} + constructor( + private partyClaimsService: PartyClaimsService, + private snackBar: MatSnackBar, + private createClaimService: CreateClaimService, + private dialogRef: MatDialog + ) {} ngOnInit() { this.partyClaimsService.errors$.subscribe((e) => @@ -29,4 +38,14 @@ export class PartyClaimsComponent implements OnInit { search(v: SearchFormValue) { this.partyClaimsService.search(v); } + + createClaim() { + const dialog = this.dialogRef.open(ConfirmActionDialogComponent); + dialog + .afterClosed() + .pipe(filter((r) => r === 'confirm')) + .subscribe(() => { + this.createClaimService.createClaim(); + }); + } } diff --git a/src/app/sections/party/party.module.ts b/src/app/sections/party/party.module.ts index 7ea123fb..60af4c08 100644 --- a/src/app/sections/party/party.module.ts +++ b/src/app/sections/party/party.module.ts @@ -1,6 +1,7 @@ import { CommonModule } from '@angular/common'; import { NgModule } from '@angular/core'; import { FlexModule } from '@angular/flex-layout'; +import { MatButtonModule } from '@angular/material/button'; import { MatTabsModule } from '@angular/material/tabs'; import { SharedModule } from '../../shared/shared.module'; @@ -8,7 +9,14 @@ import { PartyMgtRouting } from './party-routing.module'; import { PartyComponent } from './party.component'; @NgModule({ - imports: [PartyMgtRouting, CommonModule, MatTabsModule, SharedModule, FlexModule], + imports: [ + PartyMgtRouting, + CommonModule, + MatTabsModule, + SharedModule, + FlexModule, + MatButtonModule, + ], declarations: [PartyComponent], }) export class PartyModule {} diff --git a/src/app/sections/search-claims/search-claims.component.html b/src/app/sections/search-claims/search-claims.component.html index ce6eabe7..e7784fbe 100644 --- a/src/app/sections/search-claims/search-claims.component.html +++ b/src/app/sections/search-claims/search-claims.component.html @@ -1,5 +1,5 @@ -
-

Claims

+
+
Claims
diff --git a/src/app/sections/search-claims/search-table/search-table.component.html b/src/app/sections/search-claims/search-table/search-table.component.html index a5ac6045..f92d9392 100644 --- a/src/app/sections/search-claims/search-table/search-table.component.html +++ b/src/app/sections/search-claims/search-table/search-table.component.html @@ -36,6 +36,9 @@ + diff --git a/src/app/sections/search-claims/search-table/search-table.component.ts b/src/app/sections/search-claims/search-table/search-table.component.ts index faeaa8fa..55c075df 100644 --- a/src/app/sections/search-claims/search-table/search-table.component.ts +++ b/src/app/sections/search-claims/search-table/search-table.component.ts @@ -17,6 +17,10 @@ export class SearchTableComponent { constructor(private router: Router) {} navigateToClaim(partyID: string, claimID: number) { - this.router.navigate(['claim-mgt', 'party', partyID, 'claim', claimID + '']); + this.router.navigate([`/claim-mgt/party/${partyID}/claim/${claimID}`]); + } + + navigateToParty(party_id: string) { + this.router.navigate([`/party/${party_id}`]); } } diff --git a/src/main.ts b/src/main.ts index 4f8588b3..207c6dde 100644 --- a/src/main.ts +++ b/src/main.ts @@ -10,4 +10,4 @@ if (environment.production) { platformBrowserDynamic() .bootstrapModule(AppModule) - .catch((err) => console.log(err)); + .catch((err) => console.error(err));