Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
Signed-off-by: simvalery <[email protected]>

Signed-off-by: simvalery <[email protected]>
  • Loading branch information
simvalery committed Oct 9, 2024
1 parent dbb657e commit 4765655
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import { SchemaService } from 'src/app/services/schema.service';
changeDetection: ChangeDetectionStrategy.OnPush
})
export class DocumentViewComponent implements OnInit {
@Input('getByUser') getByUser: boolean = false;
@Input('document') document: any;
@Input('hide-fields') hideFields!: { [x: string]: boolean };
@Input('type') type!: 'VC' | 'VP';
Expand Down Expand Up @@ -92,25 +93,47 @@ export class DocumentViewComponent implements OnInit {
this.ref.detectChanges();
}
if (type) {
this.schemaService.getSchemasByTypeAndUser(type)
.pipe(takeUntil(this.destroy$))
.subscribe((result) => {
if (result) {
try {
this.schemaMap[type] = new Schema(result);
} catch (error) {
if (this.getByUser) {
this.schemaService.getSchemasByTypeAndUser(type)
.pipe(takeUntil(this.destroy$))
.subscribe((result) => {
if (result) {
try {
this.schemaMap[type] = new Schema(result);
} catch (error) {
this.schemaMap[type] = null;
}
} else {
this.schemaMap[type] = null;
}
} else {
this.loading--;
this.ref.detectChanges();
}, (error) => {
this.schemaMap[type] = null;
}
this.loading--;
this.ref.detectChanges();
}, (error) => {
this.schemaMap[type] = null;
this.loading--;
this.ref.detectChanges();
});
this.loading--;
this.ref.detectChanges();
});
} else {
this.schemaService.getSchemasByType(type)
.pipe(takeUntil(this.destroy$))
.subscribe((result) => {
if (result) {
try {
this.schemaMap[type] = new Schema(result);
} catch (error) {
this.schemaMap[type] = null;
}
} else {
this.schemaMap[type] = null;
}
this.loading--;
this.ref.detectChanges();
}, (error) => {
this.schemaMap[type] = null;
this.loading--;
this.ref.detectChanges();
});
}
} else {
this.schemaMap[type] = null;
this.loading--;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
</div>
<div class="view-dialog-content">
<ng-container *ngIf="viewDocument">
<app-document-view [document]="document" [dryRun]="dryRun" [schema]="schema" [type]="type"></app-document-view>
<app-document-view [document]="document" [dryRun]="dryRun" [getByUser]="getByUser" [schema]="schema"
[type]="type"></app-document-view>
</ng-container>
<ng-container *ngIf="!viewDocument">
<div *ngIf="type !== 'TEXT'" class="json">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export class VCViewerDialog {
public toggle: boolean = true;
public schema: any;
public dryRun: boolean = false;
public getByUser: boolean = false;

constructor(
public dialogRef: DynamicDialogRef,
Expand All @@ -46,7 +47,9 @@ export class VCViewerDialog {
schemaId,
topicId,
category,
getByUser
} = this.dialogConfig.data;
this.getByUser = getByUser;
this.id = id;
this.dryRun = !!dryRun;
this.title = title;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -635,6 +635,7 @@ export class RootProfileComponent implements OnInit, OnDestroy {
title,
type: 'VC',
viewDocument: true,
getByUser: true
},
});
dialogRef.onClose.subscribe(async (result) => {
Expand Down

0 comments on commit 4765655

Please sign in to comment.