diff --git a/src/app/components/creator/content-create-page/content-create-page.component.html b/src/app/components/creator/content-create-page/content-create-page.component.html index 5f864effee7e13e389effb2b56c7b25a1f15a7d5..73b7fcc7a52d4408e87502785bb1b1e21d9bcd7d 100644 --- a/src/app/components/creator/content-create-page/content-create-page.component.html +++ b/src/app/components/creator/content-create-page/content-create-page.component.html @@ -3,7 +3,7 @@ <mat-tab-group> <mat-tab label="Text"> <div class="tab-container"> - <app-content-text-creator></app-content-text-creator> + <app-content-creator [format]="'text'"></app-content-creator> </div> </mat-tab> <mat-tab label="Single / Multiple Choice"> diff --git a/src/app/components/creator/content-text-creator/content-text-creator.component.html b/src/app/components/creator/content-text-creator/content-text-creator.component.html index 27c51bdc62c6186a35aa2a54949867c30ae0992a..e7d342d9664fd48b4b2cf554dad8d51a0f579a07 100644 --- a/src/app/components/creator/content-text-creator/content-text-creator.component.html +++ b/src/app/components/creator/content-text-creator/content-text-creator.component.html @@ -1,22 +1,4 @@ -<form (ngSubmit)="submitContent(subject.value, body.value, group.value)"> - <mat-form-field class="input-block"> - <input matInput #subject [(ngModel)]="content.subject" placeholder="{{'content.subject' | translate}}" name="subject"> - </mat-form-field> - <app-markdown-toolbar textareaId="content-text-body"></app-markdown-toolbar> - <mat-form-field class="input-block"> - <textarea matInput #body id="content-text-body" [(ngModel)]="content.body" placeholder="{{'content.body' | translate}}" name="body" - matTextareaAutosize matAutosizeMinRows="3" matAutosizeMaxRows="8"></textarea> - </mat-form-field> - <markdown [data]="content.body"></markdown> - <mat-form-field> - <input matInput #group matInput [formControl]="myControl" [matAutocomplete]="auto" - value={{lastCollection}} placeholder="{{'content.collection' | translate}}"/> - <mat-autocomplete #auto="matAutocomplete"> - <mat-option *ngFor="let collection of filteredOptions | async" [value]="collection"> - {{collection}} - </mat-option> - </mat-autocomplete> - </mat-form-field> +<form (ngSubmit)="submitContent()"> <div fxLayout="row" fxLayoutAlign="center" fxLayoutGap="5px" *ngIf="!editDialogMode"> <button mat-raised-button type="submit" color="accent">{{'content.create' | translate}}</button> </div> diff --git a/src/app/components/creator/content-text-creator/content-text-creator.component.ts b/src/app/components/creator/content-text-creator/content-text-creator.component.ts index 69a8c86ee017d96b822b4dfe4c3a28937d2496cc..11f6ebe6328c4bf6cdf83a3b2ed0fed72752b6bc 100644 --- a/src/app/components/creator/content-text-creator/content-text-creator.component.ts +++ b/src/app/components/creator/content-text-creator/content-text-creator.component.ts @@ -1,4 +1,4 @@ -import { Component, Inject, OnInit } from '@angular/core'; +import { Component, Inject, Input, OnInit } from '@angular/core'; import { ContentText } from '../../../models/content-text'; import { ContentService } from '../../../services/http/content.service'; import { NotificationService } from '../../../services/util/notification.service'; @@ -16,6 +16,9 @@ import { TranslateService } from '@ngx-translate/core'; styleUrls: ['./content-text-creator.component.scss'] }) export class ContentTextCreatorComponent implements OnInit { + @Input() contentSub; + @Input() contentBod; + @Input() contentCol; roomId: string; content: ContentText = new ContentText( @@ -65,23 +68,24 @@ export class ContentTextCreatorComponent implements OnInit { }); } - submitContent(subject: string, body: string, group: string) { + submitContent() { + console.log(this.contentCol) this.contentService.addContent(new ContentText( '1', '1', this.roomId, - subject, - body, + this.contentSub, + this.contentBod, 1, - [group], + [this.contentCol], )).subscribe(); - if (this.content.body.valueOf() === '' || this.content.body.valueOf() === '') { + if (this.contentSub === '' || this.contentBod === '') { this.translationService.get('content.no-empty').subscribe(message => { this.notificationService.show(message); }); return; } - sessionStorage.setItem('collection', group); + sessionStorage.setItem('collection', this.contentCol); this.resetAfterSubmit(); } diff --git a/src/app/components/creator/creator.module.ts b/src/app/components/creator/creator.module.ts index ed9055e526c00c446c9088a00585b24bf2df0eed..3c6b8b3a742e5975ebcfaff35e1f8408fe5c1d02 100644 --- a/src/app/components/creator/creator.module.ts +++ b/src/app/components/creator/creator.module.ts @@ -21,6 +21,7 @@ import { SharedModule } from '../shared/shared.module'; import { TranslateLoader, TranslateModule } from '@ngx-translate/core'; import { HttpClient } from '@angular/common/http'; import { TranslateHttpLoader } from '@ngx-translate/http-loader'; +import { ContentCreatorComponent } from './content-creator/content-creator.component'; @NgModule({ imports: [ @@ -50,7 +51,8 @@ import { TranslateHttpLoader } from '@ngx-translate/http-loader'; RoomCreateComponent, RoomDeleteComponent, RoomEditComponent, - CreatorContentCarouselPageComponent + CreatorContentCarouselPageComponent, + ContentCreatorComponent ], entryComponents: [ RoomCreateComponent,