Commit 636b4d22 authored by Lukas Mauß's avatar Lukas Mauß

Add confirmation dialog to room history remove

parent 82ae11a5
Pipeline #36563 passed with stages
in 8 minutes and 16 seconds
......@@ -61,6 +61,7 @@ import { ArsModule } from '../../projects/ars/src/lib/ars.module';
import { QrCodeDialogComponent } from './components/shared/_dialogs/qr-code-dialog/qr-code-dialog.component';
import { MatIconModule } from '@angular/material/icon';
import { HttpClientModule } from '@angular/common/http';
import { RemoveFromHistoryComponent } from './components/shared/_dialogs/remove-from-history/remove-from-history.component';
export function dialogClose(dialogResult: any) {
}
......@@ -106,7 +107,8 @@ export function initializeApp(appConfig: AppConfig) {
DemoVideoComponent,
CookiesComponent,
OverlayComponent,
QrCodeDialogComponent
QrCodeDialogComponent,
RemoveFromHistoryComponent
],
imports: [
AppRoutingModule,
......
<div mat-dialog-content>
<h2 class="oldtypo-h2" tabindex="0">{{ 'header.sure' | translate }}</h2>
<mat-divider></mat-divider>
<p class="oldtypo-p" tabindex="0">{{ 'room-list.really-remove' | translate }}<strong>{{roomName}}</strong>
{{ 'room-list.really-remove-2' | translate }}</p>
<app-dialog-action-buttons
buttonsLabelSection="delete-account"
confirmButtonLabel="delete"
[confirmButtonType]=confirmButtonType
[cancelButtonClickAction]="buildCloseDialogActionCallback()"
[confirmButtonClickAction]="buildDeleteAccountActionCallback()"
></app-dialog-action-buttons>
</div>
/*
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { RemoveFromHistoryComponent } from './remove-from-history.component';
describe('RemoveFromHistoryComponent', () => {
let component: RemoveFromHistoryComponent;
let fixture: ComponentFixture<RemoveFromHistoryComponent>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ RemoveFromHistoryComponent ]
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(RemoveFromHistoryComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});
*/
import { Component, Inject, OnInit } from '@angular/core';
import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material';
import { RoomEditComponent } from '../../../creator/_dialogs/room-edit/room-edit.component';
import { DialogConfirmActionButtonType } from '../../dialog/dialog-action-buttons/dialog-action-buttons.component';
@Component({
selector: 'app-remove-from-history',
templateUrl: './remove-from-history.component.html',
styleUrls: ['./remove-from-history.component.scss']
})
export class RemoveFromHistoryComponent implements OnInit {
confirmButtonType: DialogConfirmActionButtonType = DialogConfirmActionButtonType.Alert;
roomName: string;
constructor(public dialogRef: MatDialogRef<RoomEditComponent>,
@Inject(MAT_DIALOG_DATA) public data: any) { }
ngOnInit() {
}
close(type: string): void {
this.dialogRef.close(type);
}
/**
* Returns a lambda which closes the dialog on call.
*/
buildCloseDialogActionCallback(): () => void {
return () => this.close('abort');
}
/**
* Returns a lambda which executes the dialog dedicated action on call.
*/
buildDeleteAccountActionCallback(): () => void {
return () => this.close('remove');
}
}
......@@ -75,7 +75,7 @@
attr.aria-labelledby="empty">
<button *ngIf="room.role < 3" mat-flat-button type="button"
name="{{ 'room-list.panel-remove-button' | translate }}"
(click)="removeFromHistory(room.id)">
(click)="removeFromHistory(room)">
<mat-icon>delete_forever</mat-icon>
</button>
<button mat-flat-button type="button"
......
......@@ -8,11 +8,12 @@ import { RoomService } from '../../../services/http/room.service';
import { EventService } from '../../../services/util/event.service';
import { AuthenticationService } from '../../../services/http/authentication.service';
import { ModeratorService } from '../../../services/http/moderator.service';
import { MatTableDataSource } from '@angular/material';
import { MatDialog, MatTableDataSource } from '@angular/material';
import { Subscription } from 'rxjs';
import { CommentService } from '../../../services/http/comment.service';
import { NotificationService } from '../../../services/util/notification.service';
import { TranslateService } from '@ngx-translate/core';
import { RemoveFromHistoryComponent } from '../_dialogs/remove-from-history/remove-from-history.component';
@Component({
selector: 'app-room-list',
......@@ -42,7 +43,8 @@ export class RoomListComponent implements OnInit, OnDestroy {
private moderatorService: ModeratorService,
private commentService: CommentService,
public notificationService: NotificationService,
private translateService: TranslateService
private translateService: TranslateService,
public dialog: MatDialog
) {
}
......@@ -104,15 +106,27 @@ export class RoomListComponent implements OnInit, OnDestroy {
}
}
removeFromHistory(roomId: string) {
this.roomService.removeFromHistory(roomId).subscribe( x => {
this.rooms = this.rooms.filter(r => r.id !== roomId);
this.closedRooms = this.closedRooms.filter(r => r.id !== roomId);
this.roomsWithRole = this.roomsWithRole.filter(r => r.id !== roomId);
this.updateTable();
this.translateService.get('room-list.room-successfully-removed').subscribe(message => {
this.notificationService.show(message);
});
removeFromHistory(room: Room) {
const dialogRef = this.dialog.open(RemoveFromHistoryComponent, {
width: '400px'
});
dialogRef.componentInstance.roomName = room.name;
dialogRef.afterClosed().subscribe(result => {
if (result === 'remove') {
this.roomService.removeFromHistory(room.id).subscribe( x => {
this.rooms = this.rooms.filter(r => r.id !== room.id);
this.closedRooms = this.closedRooms.filter(r => r.id !== room.id);
this.roomsWithRole = this.roomsWithRole.filter(r => r.id !== room.id);
this.updateTable();
this.translateService.get('room-list.room-successfully-removed').subscribe(msg => {
this.notificationService.show(msg);
});
});
} else {
this.translateService.get('room-list.canceled-remove').subscribe(msg => {
this.notificationService.show(msg);
});
}
});
}
......
......@@ -25,6 +25,7 @@ import { MatRippleModule } from '@angular/material';
import { QrCodeDialogComponent } from './_dialogs/qr-code-dialog/qr-code-dialog.component';
import { NgxQRCodeModule } from 'ngx-qrcode2';
import { ArsModule } from '../../../../projects/ars/src/lib/ars.module';
import { RemoveFromHistoryComponent } from './_dialogs/remove-from-history/remove-from-history.component';
@NgModule({
imports: [
......@@ -55,7 +56,8 @@ import { ArsModule } from '../../../../projects/ars/src/lib/ars.module';
DeleteAccountComponent,
CommentAnswerTextComponent,
DialogActionButtonsComponent,
QrCodeDialogComponent
QrCodeDialogComponent,
RemoveFromHistoryComponent
],
exports: [
RoomJoinComponent,
......
......@@ -211,7 +211,10 @@
"panel-session-name": "Sitzung",
"panel-user-role": "Rolle",
"participant-role": "Teilnehmer",
"really-remove": "Wollen Sie die Sitzung ",
Please register or sign in to reply
"really-remove-2": " wirklich aus ihrem Verlauf löschen?",
"room-successfully-removed": "Die Sitzung wurde erfolgreich aus dem Verlauf gelöscht.",
"canceled-remove": "Vorgang abgebrochen.",
"session-history": "Dein Sitzungsverlauf enthält {{count}} Sitzungen.",
"session-history-1": "Dein Sitzungsverlauf enthält genau eine Sitzung.",
"session-history-label": "Nachfolgend findest du eine Liste deiner Sitzungen."
......
......@@ -212,7 +212,10 @@
"panel-session-name": "Session",
"panel-user-role": "Role",
"participant-role": "Participant",
"really-remove": "Do you really want to remove the session ",
"really-remove-2": " from your history?",
"room-successfully-removed": "The session was successfully removed from the history.",
"canceled-remove": "Process cancelled.",
"session-history": "Your session history contains {count}} sessions.",
"session-history-1": "Your session history contains one session.",
"session-history-label": "Below you will find a list of your attended sessions."
......
Markdown is supported
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