Skip to content

Commit

Permalink
fix: close dialog after update (#1352)
Browse files Browse the repository at this point in the history
  • Loading branch information
derschnee68 committed Jan 16, 2024
1 parent 9e4fcd3 commit 41d3bb0
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 20 deletions.
@@ -1,11 +1,17 @@
import { Component, Inject, OnInit } from '@angular/core';
import { FormGroup } from '@angular/forms';
import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog';
import { ApiResponseError, CreateResourceClass, KnoraApiConnection, UpdateOntology } from '@dasch-swiss/dsp-js';
import { CreateResourceClass, KnoraApiConnection, UpdateOntology } from '@dasch-swiss/dsp-js';
import { DspApiConnectionToken } from '@dasch-swiss/vre/shared/app-config';
import { NotificationService } from '@dasch-swiss/vre/shared/app-notification';
import { tap } from 'rxjs/operators';

export interface CreateResourceClassDialogProps {
id: string;
title: string;
ontologyId: string;
lastModificationDate: string;
}

@Component({
selector: 'app-create-resource-class-dialog',
template: `
Expand Down Expand Up @@ -37,8 +43,8 @@ export class CreateResourceClassDialogComponent implements OnInit {
@Inject(DspApiConnectionToken)
private _dspApiConnection: KnoraApiConnection,
@Inject(MAT_DIALOG_DATA)
public data: { id: string; title: string; ontologyId: string; lastModificationDate: string },
public dialogRef: MatDialogRef<CreateResourceClassDialogComponent>
public data: CreateResourceClassDialogProps,
public dialogRef: MatDialogRef<CreateResourceClassDialogComponent, boolean>
) {}

ngOnInit() {
Expand Down
Expand Up @@ -10,7 +10,14 @@ import {
UpdateResourceClassLabel,
} from '@dasch-swiss/dsp-js';
import { DspApiConnectionToken } from '@dasch-swiss/vre/shared/app-config';
import { finalize, switchMap, tap } from 'rxjs/operators';
import { switchMap, tap } from 'rxjs/operators';

export interface EditResourceClassDialogProps {
id: string;
title: string;
ontologyId: string;
lastModificationDate: string;
}

@Component({
selector: 'app-edit-resource-class-dialog',
Expand Down Expand Up @@ -44,8 +51,8 @@ export class EditResourceClassDialogComponent implements OnInit {
@Inject(DspApiConnectionToken)
private _dspApiConnection: KnoraApiConnection,
@Inject(MAT_DIALOG_DATA)
public data: { id: string; title: string; ontologyId: string; lastModificationDate: string },
public dialogRef: MatDialogRef<EditResourceClassDialogComponent>
public data: EditResourceClassDialogProps,
public dialogRef: MatDialogRef<EditResourceClassDialogComponent, boolean>
) {}

ngOnInit() {
Expand Down Expand Up @@ -92,7 +99,9 @@ export class EditResourceClassDialogComponent implements OnInit {
this.loading = false;
})
)
.subscribe();
.subscribe(() => {
this.dialogRef.close(true);
});
}

private _deleteResourceComment$() {
Expand Down
33 changes: 21 additions & 12 deletions apps/dsp-app/src/app/project/ontology/ontology.component.ts
Expand Up @@ -58,8 +58,14 @@ import { Observable, Subject, combineLatest } from 'rxjs';
import { map, take, takeUntil } from 'rxjs/operators';
import { DialogComponent, DialogEvent } from '../../main/dialog/dialog.component';
import { ProjectBase } from '../project-base';
import { CreateResourceClassDialogComponent } from './create-resource-class-dialog/create-resource-class-dialog.component';
import { EditResourceClassDialogComponent } from './edit-resource-class-dialog/edit-resource-class-dialog.component';
import {
CreateResourceClassDialogComponent,
CreateResourceClassDialogProps,
} from './create-resource-class-dialog/create-resource-class-dialog.component';
import {
EditResourceClassDialogComponent,
EditResourceClassDialogProps,
} from './edit-resource-class-dialog/edit-resource-class-dialog.component';

@Component({
changeDetection: ChangeDetectionStrategy.OnPush,
Expand Down Expand Up @@ -455,14 +461,17 @@ export class OntologyComponent extends ProjectBase implements OnInit, OnDestroy
const currentOntology = this._store.selectSnapshot(OntologiesSelectors.currentOntology);

this._dialog
.open(CreateResourceClassDialogComponent, {
data: {
id: resClassInfo.iri,
title: resClassInfo.label,
ontologyId: currentOntology.id,
lastModificationDate: currentOntology.lastModificationDate,
},
})
.open<CreateResourceClassDialogComponent, CreateResourceClassDialogProps, null>(
CreateResourceClassDialogComponent,
{
data: {
id: resClassInfo.iri,
title: resClassInfo.label,
ontologyId: currentOntology.id,
lastModificationDate: currentOntology.lastModificationDate,
},
}
)
.afterClosed()
.subscribe(event => {
if (event !== DialogEvent.DialogCanceled) {
Expand All @@ -475,7 +484,7 @@ export class OntologyComponent extends ProjectBase implements OnInit, OnDestroy
const currentOntology = this._store.selectSnapshot(OntologiesSelectors.currentOntology);

this._dialog
.open(EditResourceClassDialogComponent, {
.open<EditResourceClassDialogComponent, EditResourceClassDialogProps, boolean>(EditResourceClassDialogComponent, {
data: {
id: resClassInfo.iri,
title: resClassInfo.label,
Expand All @@ -485,7 +494,7 @@ export class OntologyComponent extends ProjectBase implements OnInit, OnDestroy
})
.afterClosed()
.subscribe(event => {
if (event !== DialogEvent.DialogCanceled) {
if (event === true) {
this.initOntologiesList();
}
});
Expand Down

0 comments on commit 41d3bb0

Please sign in to comment.