Skip to content
Snippets Groups Projects
Commit 35501845 authored by Heinrich Marks's avatar Heinrich Marks :hibiscus: Committed by Thomas Lenz
Browse files

Improve content creation html % logic

parent 6611a007
Branches
Tags
No related merge requests found
<form (ngSubmit)="addContent(subjectTitle.value, bodyText.value, roomIdNum.value)">
<form (ngSubmit)="addContent(subjectTitle.value, bodyText.value)">
<div fxLayout="column" fxLayoutAlign="center" fxLayoutGap="10px">
<mat-form-field>
<input class="input-block" #subjectTitle matInput (keypress)="resetEmptyInputs()" placeholder="Subject" [(ngModel)]="subject"
name="Title">
<button mat-button *ngIf="subject" type="text" matSuffix mat-icon-button aria-label="Clear" (click)="subject=''">
<mat-icon>close</mat-icon>
</button>
</mat-form-field>
<mat-form-field>
<input class="input-block" #roomIdNum matInput (keypress)="resetEmptyInputs()" placeholder="Room Id" [(ngModel)]="roomId"
name="Title">
<button mat-button *ngIf="roomId" type="text" matSuffix mat-icon-button aria-label="Clear" (click)="roomId=''">
<mat-icon>close</mat-icon>
</button>
<input class="input-block" #subjectTitle matInput (keypress)="resetEmptyInputs()" placeholder="Subject" [(ngModel)]="subject">
</mat-form-field>
<mat-form-field>
<textarea #bodyText matInput matTextareaAutosize matAutosizeMinRows="3" matAutosizeMaxRows="8" (keypress)="resetEmptyInputs()"
placeholder="Body" [(ngModel)]="body" name="Text"></textarea>
<button mat-button *ngIf="body" type="text" matSuffix mat-icon-button aria-label="Clear" (click)="body=''">
<input class="input-block" #bodyText matInput matTextareaAutosize matAutosizeMinRows="3" matAutosizeMaxRows="8" (keypress)="resetEmptyInputs()"
placeholder="Body" [(ngModel)]="body">
<button mat-button matSuffix mat-icon-button aria-label="Clear" (click)="subject=''; body=''">
<mat-icon>close</mat-icon>
</button>
</mat-form-field>
......@@ -25,6 +14,7 @@
<mat-slide-toggle>Allow absention</mat-slide-toggle>
<mat-slide-toggle>Show hints</mat-slide-toggle>
</div>
<button mat-raised-button color="primary" type="submit">Create content</button>
<button mat-raised-button color="primary" type="submit">Create content
</button>
</div>
</form>
......@@ -16,7 +16,6 @@ export class ContentCreationComponent implements OnInit {
body: string;
roomId: string;
emptyInputs = false;
constructor(
private contentService: ContentService,
private router: Router,
......@@ -36,15 +35,14 @@ export class ContentCreationComponent implements OnInit {
this.emptyInputs = false;
}
addContent(subject: string, body: string, roomId: string) {
addContent(subject: string, body: string) {
subject = subject.trim();
body = body.trim();
roomId = roomId.trim();
if (!subject || !body || !roomId) {
if (!subject || !body) {
this.emptyInputs = true;
return;
}
this.contentService.addContent({ subject: subject, body: body , roomId: roomId } as Content)
this.contentService.addContent({ subject: subject, body: body, this.roomId } as Content)
.subscribe(content => {
this.notification.show(`Content '${content.subject}' successfully created.`);
this.router.navigate([`/creator/room/${content.roomId}/${content.id}`]);
......
......@@ -69,4 +69,4 @@
</mat-card>
<div *ngIf="!isLoading && !room">Error: room could not be found!</div>
</div>
</div>
\ No newline at end of file
</div>
......@@ -22,8 +22,9 @@ export class CreatorRoomComponent extends RoomComponent implements OnInit {
constructor(protected roomService: RoomService,
protected notification: NotificationService,
protected route: ActivatedRoute,
public dialog: MatDialog,
protected location: Location) {
protected location: Location,
public dialog: MatDialog
) {
super(roomService, route, location);
}
......
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