Skip to content
Snippets Groups Projects
Commit dd21fbcb authored by Lukas Mauß's avatar Lukas Mauß
Browse files

Adjust dialog-closing-messanges and use switchCase instead of if

parent 7c407cd6
Branches
Tags
No related merge requests found
......@@ -6,10 +6,10 @@
<textarea matInput [(ngModel)]="content.body" rows="3" maxlength="100" placeholder="Inhalt" name="body"></textarea>
</mat-form-field>
<div fxLayout="row" fxLayoutAlign="center" fxLayoutGap="10px">
<button (click)="dialogRef.close()" mat-button color="primary">
<button (click)="dialogRef.close('abort')" mat-button color="primary">
{{ 'room-page.abort' | translate }}
</button>
<button (click)="dialogRef.close('edit')" mat-raised-button color="primary">
<button (click)="dialogRef.close('update')" mat-raised-button color="primary">
{{ 'room-page.update' | translate }}
</button>
</div>
......
......@@ -113,7 +113,7 @@ export class ContentListComponent implements OnInit {
const index = this.findIndexOfSubject(delContent.subject);
this.contentBackup = delContent;
const dialogRef = this.dialog.open(ContentDeleteComponent, {
width: '800px'
width: '400px'
});
dialogRef.componentInstance.content = delContent;
dialogRef.afterClosed()
......@@ -131,7 +131,7 @@ export class ContentListComponent implements OnInit {
const index = this.findIndexOfSubject(edContent.subject);
const dialogRef = this.dialog.open(ContentEditComponent, {
width: '800px'
width: '400px'
});
dialogRef.componentInstance.content = edContent;
dialogRef.afterClosed()
......@@ -144,20 +144,18 @@ export class ContentListComponent implements OnInit {
if (!action) {
this.contents[index] = this.contentBackup;
} else {
if (action.valueOf() === 'delete') {
this.notificationService.show('Content "' + this.contents[index].subject + '" deleted.');
this.contentService.deleteContent(this.contents[index].id).subscribe();
this.contents.splice(index, 1);
if (this.contents.length === 0) {
this.location.back();
}
}
if (action.valueOf() === 'edit') {
this.notificationService.show('Content "' + this.contents[index].subject + '" updated.');
this.contentService.updateContent(this.contents[index]);
}
if (action.valueOf() === 'abort') {
this.contents[index] = this.contentBackup;
switch (action.valueOf()) {
case 'delete':
this.notificationService.show('Content "' + this.contents[index].subject + '" deleted.');
this.contentService.deleteContent(this.contents[index].id).subscribe();
this.contents.splice(index, 1);
if (this.contents.length === 0) {
this.location.back();
}
break;
case 'abort':
this.contents[index] = this.contentBackup;
break;
}
}
}
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment