Skip to content
Snippets Groups Projects
Commit 98878fa1 authored by Thomas Lenz's avatar Thomas Lenz
Browse files

Add content-delete component to all content components

parent 9050ceec
No related merge requests found
Showing
with 74 additions and 50 deletions
import { Component, Inject, OnInit } from '@angular/core';
import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material';
import { RoomService } from '../../../services/http/room.service';
import { Router } from '@angular/router';
import { NotificationService } from '../../../services/util/notification.service';
import { ContentChoiceCreatorComponent } from '../../fragments/content-choice-creator/content-choice-creator.component';
import { ContentLikertCreatorComponent } from '../../fragments/content-likert-creator/content-likert-creator.component';
import { ContentYesNoCreatorComponent } from '../../fragments/content-yes-no-creator/content-yes-no-creator.component';
import { ContentTextCreatorComponent } from '../../fragments/content-text-creator/content-text-creator.component';
import { ContentType } from '../../../models/content-type.enum';
import { Content } from '../../../models/content';
......@@ -20,52 +15,18 @@ export class ContentDeleteComponent implements OnInit {
format: ContentType;
content: Content;
constructor(private roomService: RoomService,
private router: Router,
constructor(private router: Router,
private notification: NotificationService,
public dialogRef: MatDialogRef<ContentChoiceCreatorComponent>,
public dialogRefLikert: MatDialogRef<ContentLikertCreatorComponent>,
public dialogRefYesNo: MatDialogRef<ContentYesNoCreatorComponent>,
public dialogRefText: MatDialogRef<ContentTextCreatorComponent>,
public dialogRef: MatDialogRef<any>,
@Inject(MAT_DIALOG_DATA) public data: any) {
}
onNoClick(): void {
switch (this.format) {
case ContentType.CHOICE:
this.dialogRef.close();
break;
case ContentType.SCALE:
this.dialogRefLikert.close();
break;
case ContentType.BINARY:
this.dialogRefYesNo.close();
break;
case ContentType.TEXT:
this.dialogRefText.close();
break;
default:
return;
}
this.dialogRef.close('abort');
}
closeDialog(action: string) {
switch (this.format) {
case ContentType.CHOICE:
this.dialogRef.close(action);
break;
case ContentType.SCALE:
this.dialogRefLikert.close(action);
break;
case ContentType.BINARY:
this.dialogRefYesNo.close(action);
break;
case ContentType.TEXT:
this.dialogRefText.close(action);
break;
default:
return;
}
this.dialogRef.close(action);
}
ngOnInit() {
......
......@@ -85,7 +85,7 @@
<div *ngIf="editDialogMode">
<button mat-raised-button (click)="editDialogClose($event,'edit')" color="primary">Update</button>
<button mat-raised-button (click)="editDialogClose($event,'abort')" color="primary">Abort</button>
<button mat-raised-button (click)="editDialogClose($event,'delete')" color="warn">Delete</button>
<button mat-raised-button (click)="openDeletionContentDialog($event)" color="warn">Delete</button>
</div>
</div>
</form>
......@@ -8,6 +8,7 @@ import { AnswerEditComponent } from '../../dialogs/answer-edit/answer-edit.compo
import { ContentType } from '../../../models/content-type.enum';
import { ActivatedRoute } from '@angular/router';
import { ContentListComponent } from '../content-list/content-list.component';
import { ContentDeleteComponent } from '../../dialogs/content-delete/content-delete.component';
export class DisplayAnswer {
answerOption: AnswerOption;
......@@ -267,4 +268,18 @@ export class ContentChoiceCreatorComponent implements OnInit {
onNoClick(): void {
this.dialogRef.close();
}
openDeletionContentDialog($event): void {
$event.preventDefault();
const dialogRef = this.dialog.open(ContentDeleteComponent, {
width: '400px'
});
dialogRef.componentInstance.content = this.content;
dialogRef.afterClosed()
.subscribe(result => {
if (result === 'delete') {
this.dialogRef.close(result);
}
});
}
}
......@@ -26,6 +26,6 @@
<div *ngIf="editDialogMode">
<button mat-raised-button (click)="editDialogClose($event,'edit')" color="primary">Update</button>
<button mat-raised-button (click)="editDialogClose($event,'abort')" color="primary">Abort</button>
<button mat-raised-button (click)="editDialogClose($event,'delete')" color="warn">Delete</button>
<button mat-raised-button (click)="openDeletionContentDialog($event)" color="warn">Delete</button>
</div>
</form>
......@@ -6,8 +6,9 @@ import { ContentType } from '../../../models/content-type.enum';
import { ContentService } from '../../../services/http/content.service';
import { NotificationService } from '../../../services/util/notification.service';
import { ActivatedRoute } from '@angular/router';
import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material';
import { MAT_DIALOG_DATA, MatDialog, MatDialogRef } from '@angular/material';
import { ContentListComponent } from '../content-list/content-list.component';
import { ContentDeleteComponent } from '../../dialogs/content-delete/content-delete.component';
@Component({
selector: 'app-content-likert-creator',
......@@ -44,6 +45,7 @@ export class ContentLikertCreatorComponent implements OnInit {
constructor(private contentService: ContentService,
private notificationService: NotificationService,
private route: ActivatedRoute,
public dialog: MatDialog,
public dialogRef: MatDialogRef<ContentListComponent>,
@Inject(MAT_DIALOG_DATA) public data: any) {
}
......@@ -95,4 +97,18 @@ export class ContentLikertCreatorComponent implements OnInit {
onNoClick(): void {
this.dialogRef.close();
}
openDeletionContentDialog($event): void {
$event.preventDefault();
const dialogRef = this.dialog.open(ContentDeleteComponent, {
width: '400px'
});
dialogRef.componentInstance.content = this.content;
dialogRef.afterClosed()
.subscribe(result => {
if (result === 'delete') {
this.dialogRef.close(result);
}
});
}
}
......@@ -11,6 +11,6 @@
<div *ngIf="editDialogMode">
<button mat-raised-button (click)="editDialogClose($event,'edit')" color="primary">Update</button>
<button mat-raised-button (click)="editDialogClose($event,'abort')" color="primary">Abort</button>
<button mat-raised-button (click)="editDialogClose($event,'delete')" color="warn">Delete</button>
<button mat-raised-button (click)="openDeletionContentDialog($event)" color="warn">Delete</button>
</div>
</form>
......@@ -3,8 +3,9 @@ import { ContentText } from '../../../models/content-text';
import { ContentService } from '../../../services/http/content.service';
import { ActivatedRoute } from '@angular/router';
import { NotificationService } from '../../../services/util/notification.service';
import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material';
import { MAT_DIALOG_DATA, MatDialog, MatDialogRef } from '@angular/material';
import { ContentListComponent } from '../content-list/content-list.component';
import { ContentDeleteComponent } from '../../dialogs/content-delete/content-delete.component';
@Component({
selector: 'app-content-text-creator',
......@@ -25,6 +26,7 @@ export class ContentTextCreatorComponent implements OnInit {
constructor(private contentService: ContentService,
private notificationService: NotificationService,
private route: ActivatedRoute,
public dialog: MatDialog,
public dialogRef: MatDialogRef<ContentListComponent>,
@Inject(MAT_DIALOG_DATA) public data: any) {
}
......@@ -62,4 +64,18 @@ export class ContentTextCreatorComponent implements OnInit {
onNoClick(): void {
this.dialogRef.close();
}
openDeletionContentDialog($event): void {
$event.preventDefault();
const dialogRef = this.dialog.open(ContentDeleteComponent, {
width: '400px'
});
dialogRef.componentInstance.content = this.content;
dialogRef.afterClosed()
.subscribe(result => {
if (result === 'delete') {
this.dialogRef.close(result);
}
});
}
}
......@@ -29,6 +29,6 @@
<div *ngIf="editDialogMode">
<button mat-raised-button (click)="editDialogClose($event,'edit')" color="primary">Update</button>
<button mat-raised-button (click)="editDialogClose($event,'abort')" color="primary">Abort</button>
<button mat-raised-button (click)="editDialogClose($event,'delete')" color="warn">Delete</button>
<button mat-raised-button (click)="openDeletionContentDialog($event)" color="warn">Delete</button>
</div>
</form>
......@@ -6,8 +6,9 @@ import { NotificationService } from '../../../services/util/notification.service
import { ContentType } from '../../../models/content-type.enum';
import { ContentService } from '../../../services/http/content.service';
import { ActivatedRoute } from '@angular/router';
import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material';
import { MAT_DIALOG_DATA, MatDialog, MatDialogRef } from '@angular/material';
import { ContentListComponent } from '../content-list/content-list.component';
import { ContentDeleteComponent } from '../../dialogs/content-delete/content-delete.component';
@Component({
selector: 'app-content-yes-no-creator',
......@@ -41,6 +42,7 @@ export class ContentYesNoCreatorComponent implements OnInit {
constructor(private contentService: ContentService,
private route: ActivatedRoute,
private notificationService: NotificationService,
public dialog: MatDialog,
public dialogRef: MatDialogRef<ContentListComponent>,
@Inject(MAT_DIALOG_DATA) public data: any) {
}
......@@ -110,4 +112,18 @@ export class ContentYesNoCreatorComponent implements OnInit {
onNoClick(): void {
this.dialogRef.close();
}
openDeletionContentDialog($event): void {
$event.preventDefault();
const dialogRef = this.dialog.open(ContentDeleteComponent, {
width: '400px'
});
dialogRef.componentInstance.content = this.content;
dialogRef.afterClosed()
.subscribe(result => {
if (result === 'delete') {
this.dialogRef.close(result);
}
});
}
}
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