Skip to content

Commit

Permalink
chore: Linking of asset and contract definition creation workflows (WIP)
Browse files Browse the repository at this point in the history
  • Loading branch information
AnurosePrakash committed Jul 26, 2023
1 parent 5f6ed21 commit 32b181f
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 18 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {Component, OnDestroy} from '@angular/core';
import {MatDialog, MatDialogRef} from '@angular/material/dialog';
import {Observable, Subject} from 'rxjs';
import {distinctUntilChanged, Observable, Subject} from 'rxjs';
import {filter, finalize, map, takeUntil} from 'rxjs/operators';
import {
ConfirmDialogModel,
Expand Down Expand Up @@ -72,11 +72,9 @@ export class AssetCreateDialogComponent implements OnDestroy {
complete: () => {
this.notificationService.showInfo('Successfully created asset');
this.close({refreshList: true});
console.log(assetEntryDto.asset);
this.onAssetCreation(formValue.metadata?.id!);
},
error: (error) => {
console.error('Failed creating asset!', error);
error: () => {
this.notificationService.showError('Failed creating asset!');
this.close({refreshList: true});
console.log(assetEntryDto.asset);
Expand All @@ -90,18 +88,16 @@ export class AssetCreateDialogComponent implements OnDestroy {
}

private onAssetCreation(assetId: string) {
console.log('the asset id is' + assetId);
this.confirmCreate(assetId).subscribe(() => {
complete: () => {
this.confirmCreate(assetId).pipe(distinctUntilChanged()).subscribe(() => {
this.close({refreshList: true});
ContractDefinitionEditorDialog.assetIdFromAssetCreation = assetId;
const dialogRef = this.matDialog.open(ContractDefinitionEditorDialog);
dialogRef
.afterClosed()
.pipe(
map((it) => it as ContractDefinitionEditorDialogResult | null),
filter((it) => !!it?.refreshList),
).subscribe(() => ContractDefinitionPageComponent.fetch$.next(null));
};
dialogRef
.afterClosed()
.pipe(
map((it) => it as ContractDefinitionEditorDialogResult | null),
filter((it) => !!it?.refreshList),
).subscribe(() => ContractDefinitionPageComponent.fetch$.next(null));
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,8 @@ export class ContractDefinitionEditorDialogForm {
assets: [[] as Asset[], Validators.required],
});
}

patchValue(param: { id: string }) {

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ <h1 mat-dialog-title>Create New Contract Definition</h1>
id="form-field-id"
color="accent">
<mat-label>ID</mat-label>
<input matInput autocomplete="new-id" [formControl]="ctrl" />
<input matInput autocomplete="new-id" [formControl]="ctrl"/>
<mat-error *ngIf="ctrl.invalid && ctrl.errors?.pattern">{{
validationMessages.invalidWhitespacesMessage
}}</mat-error>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export class ContractDefinitionEditorDialog implements OnInit, OnDestroy {
policies: PolicyDefinition[] = [];
assets: Asset[] = [];
loading = false;

static assetIdFromAssetCreation: string;
constructor(
public form: ContractDefinitionEditorDialogForm,
private notificationService: NotificationService,
Expand All @@ -40,7 +40,9 @@ export class ContractDefinitionEditorDialog implements OnInit, OnDestroy {
) {}

ngOnInit() {

this.form.patchValue({
id: ContractDefinitionEditorDialog.assetIdFromAssetCreation,
});
this.policyService
.getAllPolicies(0, 10_000_000)
.pipe(takeUntil(this.ngOnDestroy$))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export class ContractDefinitionPageComponent implements OnInit {
searchText = new FormControl<string>('');
deleteBusy = false;

public static fetch$ = new BehaviorSubject(null);
static fetch$ = new BehaviorSubject(null);

constructor(
private contractDefinitionPageService: ContractDefinitionPageService,
Expand Down

0 comments on commit 32b181f

Please sign in to comment.