Skip to content
Snippets Groups Projects
Commit dcffffcc authored by David Noah Donges's avatar David Noah Donges
Browse files

Merge branch '141-remove-short-id-from-room-creation-room-edit' into 'master'

Resolve "Remove short ID from room creation/room edit"

Closes #140, #141, and #142

See merge request swtp-block-ws17/arsnova-angular-frontend!100
parents 03f8bc1b 9cacd3f4
1 merge request!100Resolve "Remove short ID from room creation/room edit"
Pipeline #13887 passed with stage
in 33 seconds
<form (ngSubmit)="addRoom(longRoomName.value, shortRoomName.value, description.value)">
<form (ngSubmit)="addRoom(longRoomName.value, description.value)">
<div fxLayout="column" fxLayoutAlign="center" fxLayoutGap="10px">
<mat-form-field>
<input (keypress)="resetEmptyInputs()" matInput #longRoomName class="input-block" type="text" placeholder="Name"
maxlength="50"
[(ngModel)]="longName" name="LongName"/>
<input (keypress)="resetEmptyInputs()" matInput #longRoomName class="input-block" type="text"
placeholder="Room name" maxlength="50" [(ngModel)]="longName" name="roomName"/>
<mat-hint align="start" *ngIf="!emptyInputs"><strong>Max. letters / signs:</strong></mat-hint>
<mat-hint align="end" *ngIf="!emptyInputs">{{longRoomName.value.length}} / 50</mat-hint>
<mat-hint align="start" *ngIf="emptyInputs"><strong>Input is required</strong></mat-hint>
......@@ -11,21 +10,9 @@
<mat-icon>close</mat-icon>
</button>
</mat-form-field>
<mat-form-field>
<input (keypress)="resetEmptyInputs()" matInput #shortRoomName class="input-block" type="text"
placeholder="Short name" maxlength="8"
[(ngModel)]="shortName" name="ShortName"/>
<mat-hint align="start" *ngIf="!emptyInputs"><strong>Max. letters / signs:</strong></mat-hint>
<mat-hint align="end" *ngIf="!emptyInputs">{{shortRoomName.value.length}} / 8</mat-hint>
<mat-hint align="start" *ngIf="emptyInputs"><strong>Input is required</strong></mat-hint>
<button mat-button *ngIf="shortName" matSuffix mat-icon-button aria-label="Clear" (click)="shortName=''">
<mat-icon>close</mat-icon>
</button>
</mat-form-field>
<mat-form-field>
<textarea (keypress)="resetEmptyInputs()" matInput #description type="text"
placeholder="Description" maxlength="255"
[(ngModel)]="shortName"></textarea>
placeholder="Description" maxlength="255" name="description"></textarea>
<mat-hint align="start" *ngIf="!emptyInputs"><strong>Max. letters / signs:</strong></mat-hint>
<mat-hint align="end" *ngIf="!emptyInputs">{{description.value.length}} / 255</mat-hint>
<mat-hint align="start" *ngIf="emptyInputs"><strong>Input is required</strong></mat-hint>
......
......@@ -35,16 +35,15 @@ export class RoomCreateComponent implements OnInit {
this.emptyInputs = false;
}
addRoom(longRoomName: string, shortRoomName: string, description: string) {
addRoom(longRoomName: string, description: string) {
longRoomName = longRoomName.trim();
shortRoomName = shortRoomName.trim();
if (!longRoomName || !shortRoomName) {
if (!longRoomName) {
this.emptyInputs = true;
return;
}
this.roomService.addRoom({
name: longRoomName,
abbreviation: shortRoomName,
abbreviation: '00000000',
description: description
} as Room).subscribe(room => {
this.room = room;
......
<div *ngIf="editRoom">
<mat-form-field class="input-block">
<input [(ngModel)]="editRoom.name" #roomName matInput/>
</mat-form-field>
<mat-form-field class="input-block">
<input [(ngModel)]="editRoom.abbreviation" #roomAbbreviation matInput/>
<input [(ngModel)]="editRoom.name" #roomName matInput placeholder="Room name" name="room-name"/>
</mat-form-field>
<mat-form-field class="input-block">
<textarea [(ngModel)]="editRoom.description" #roomDescription matInput matTextareaAutosize
matAutosizeMinRows="2"
matAutosizeMaxRows="5"></textarea>
matAutosizeMinRows="2" matAutosizeMaxRows="5" placeholder="Description" name="description">
</textarea>
</mat-form-field>
<div fxLayout="row" fxLayoutAlign="center" fxLayoutGap="10px">
<button (click)="dialogRef.close('abort')" mat-button color="primary">
Leave
</button>
<button (click)="dialogRef.close('edit')" mat-button color="primary">
<button (click)="dialogRef.close('edit')" mat-raised-button color="primary">
Update
</button>
</div>
......
......@@ -22,8 +22,7 @@ export class RoomCreatorPageComponent extends RoomPageComponent implements OnIni
protected notification: NotificationService,
protected route: ActivatedRoute,
protected location: Location,
public dialog: MatDialog
) {
public dialog: MatDialog) {
super(roomService, route, location);
}
......@@ -39,18 +38,17 @@ export class RoomCreatorPageComponent extends RoomPageComponent implements OnIni
updateRoom(): void {
if ((this.updRoom.name === this.room.name) &&
(this.updRoom.shortId === this.room.shortId) &&
(this.updRoom.description === this.room.description)
) {
this.notification.show('There were no changes');
return;
} else {
this.notification.show('Changes are made');
this.room.name = this.updRoom.name;
this.room.shortId = this.updRoom.shortId;
this.room.description = this.updRoom.description;
this.roomService.updateRoom(this.room)
.subscribe();
.subscribe(() => {
this.notification.show('Changes are made');
});
}
}
......
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