Skip to content
Snippets Groups Projects
Verified Commit 24becc89 authored by Lukas Maximilian Kimpel's avatar Lukas Maximilian Kimpel
Browse files

Remove short id from room edit/room create

Fix some minor style issues related to room create/room edit
parent 7914d1d4
Branches
Tags
1 merge request!100Resolve "Remove short ID from room creation/room edit"
Pipeline #13776 passed with stage
in 32 seconds
<form (ngSubmit)="addRoom(longRoomName.value, shortRoomName.value, description.value)"> <form (ngSubmit)="addRoom(longRoomName.value, description.value)">
<div fxLayout="column" fxLayoutAlign="center" fxLayoutGap="10px"> <div fxLayout="column" fxLayoutAlign="center" fxLayoutGap="10px">
<mat-form-field> <mat-form-field>
<input (keypress)="resetEmptyInputs()" matInput #longRoomName class="input-block" type="text" placeholder="Name" <input (keypress)="resetEmptyInputs()" matInput #longRoomName class="input-block" type="text" placeholder="Name"
...@@ -11,17 +11,6 @@ ...@@ -11,17 +11,6 @@
<mat-icon>close</mat-icon> <mat-icon>close</mat-icon>
</button> </button>
</mat-form-field> </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> <mat-form-field>
<textarea (keypress)="resetEmptyInputs()" matInput #description type="text" <textarea (keypress)="resetEmptyInputs()" matInput #description type="text"
placeholder="Description" maxlength="255" placeholder="Description" maxlength="255"
......
...@@ -35,16 +35,15 @@ export class RoomCreateComponent implements OnInit { ...@@ -35,16 +35,15 @@ export class RoomCreateComponent implements OnInit {
this.emptyInputs = false; this.emptyInputs = false;
} }
addRoom(longRoomName: string, shortRoomName: string, description: string) { addRoom(longRoomName: string, description: string) {
longRoomName = longRoomName.trim(); longRoomName = longRoomName.trim();
shortRoomName = shortRoomName.trim(); if (!longRoomName) {
if (!longRoomName || !shortRoomName) {
this.emptyInputs = true; this.emptyInputs = true;
return; return;
} }
this.roomService.addRoom({ this.roomService.addRoom({
name: longRoomName, name: longRoomName,
abbreviation: shortRoomName, abbreviation: '00000000',
description: description description: description
} as Room).subscribe(room => { } as Room).subscribe(room => {
this.room = room; this.room = room;
......
<div *ngIf="editRoom"> <div *ngIf="editRoom">
<mat-form-field class="input-block"> <mat-form-field class="input-block">
<input [(ngModel)]="editRoom.name" #roomName matInput/> <input [(ngModel)]="editRoom.name" #roomName matInput placeholder="Room name"/>
</mat-form-field>
<mat-form-field class="input-block">
<input [(ngModel)]="editRoom.abbreviation" #roomAbbreviation matInput/>
</mat-form-field> </mat-form-field>
<mat-form-field class="input-block"> <mat-form-field class="input-block">
<textarea [(ngModel)]="editRoom.description" #roomDescription matInput matTextareaAutosize <textarea [(ngModel)]="editRoom.description" #roomDescription matInput matTextareaAutosize
matAutosizeMinRows="2" matAutosizeMinRows="2" matAutosizeMaxRows="5" placeholder="Description"></textarea>
matAutosizeMaxRows="5"></textarea>
</mat-form-field> </mat-form-field>
<div fxLayout="row" fxLayoutAlign="center" fxLayoutGap="10px"> <div fxLayout="row" fxLayoutAlign="center" fxLayoutGap="10px">
<button (click)="dialogRef.close('abort')" mat-button color="primary"> <button (click)="dialogRef.close('abort')" mat-button color="primary">
Leave Leave
</button> </button>
<button (click)="dialogRef.close('edit')" mat-button color="primary"> <button (click)="dialogRef.close('edit')" mat-raised-button color="primary">
Update Update
</button> </button>
</div> </div>
......
...@@ -22,8 +22,7 @@ export class RoomCreatorPageComponent extends RoomPageComponent implements OnIni ...@@ -22,8 +22,7 @@ export class RoomCreatorPageComponent extends RoomPageComponent implements OnIni
protected notification: NotificationService, protected notification: NotificationService,
protected route: ActivatedRoute, protected route: ActivatedRoute,
protected location: Location, protected location: Location,
public dialog: MatDialog public dialog: MatDialog) {
) {
super(roomService, route, location); super(roomService, route, location);
} }
...@@ -39,18 +38,17 @@ export class RoomCreatorPageComponent extends RoomPageComponent implements OnIni ...@@ -39,18 +38,17 @@ export class RoomCreatorPageComponent extends RoomPageComponent implements OnIni
updateRoom(): void { updateRoom(): void {
if ((this.updRoom.name === this.room.name) && if ((this.updRoom.name === this.room.name) &&
(this.updRoom.shortId === this.room.shortId) &&
(this.updRoom.description === this.room.description) (this.updRoom.description === this.room.description)
) { ) {
this.notification.show('There were no changes'); this.notification.show('There were no changes');
return; return;
} else { } else {
this.notification.show('Changes are made');
this.room.name = this.updRoom.name; this.room.name = this.updRoom.name;
this.room.shortId = this.updRoom.shortId;
this.room.description = this.updRoom.description; this.room.description = this.updRoom.description;
this.roomService.updateRoom(this.room) 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