diff --git a/src/app/app.module.ts b/src/app/app.module.ts index 52f322a8ae91561bd3d81732b3186c201dba1bca..a93f5b1b557af94cb1f9293f51fa11e77e890475 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -18,8 +18,6 @@ import { ContentService } from './services/http/content.service'; import { ContentAnswerService } from './services/http/content-answer.service'; import { UserActivationComponent } from './components/home/_dialogs/user-activation/user-activation.component'; import { AuthenticationInterceptor } from './interceptors/authentication.interceptor'; -import { GenericDataDialogComponent } from './components/shared/_dialogs/generic-data-dialog/generic-data-dialog.component'; -import { FooterLoginDialogComponent } from './components/shared/_dialogs/footer-login-dialog/footer-login-dialog.component'; import { EssentialsModule } from './components/essentials/essentials.module'; import { SharedModule } from './components/shared/shared.module'; import { BrowserModule } from '@angular/platform-browser'; @@ -36,15 +34,12 @@ export function dialogClose(dialogResult: any) { LoginComponent, PasswordResetComponent, RegisterComponent, - UserActivationComponent, - FooterLoginDialogComponent + UserActivationComponent ], entryComponents: [ RegisterComponent, PasswordResetComponent, - UserActivationComponent, - GenericDataDialogComponent, - FooterLoginDialogComponent + UserActivationComponent ], imports: [ AppRoutingModule, diff --git a/src/app/components/creator/_dialogs/answer-edit/answer-edit.component.html b/src/app/components/creator/_dialogs/answer-edit/answer-edit.component.html index bff24530cb7b8b0fd6dec742c1ef728e57527354..bad88dd8cb1cfca2b0060be4dda91360688e3d51 100644 --- a/src/app/components/creator/_dialogs/answer-edit/answer-edit.component.html +++ b/src/app/components/creator/_dialogs/answer-edit/answer-edit.component.html @@ -1,11 +1,11 @@ <div *ngIf="answer"> <mat-form-field class="input-block"> - <input [(ngModel)]="answer.answerOption.label" #roomName matInput placeholder="{{ 'content.answer' | translate }}" name="answer-label"/> + <input [(ngModel)]="answer.answerOption.label" matInput + placeholder="{{ 'content.answer' | translate }}" name="answer-label"/> </mat-form-field> <mat-form-field class="input-block"> - <textarea [(ngModel)]="answer.answerOption.points" #roomDescription matInput matTextareaAutosize - matAutosizeMinRows="2" matAutosizeMaxRows="5" placeholder="{{ 'content.points' | translate }}" name="points"> - </textarea> + <input [(ngModel)]="answer.answerOption.points" matInput + placeholder="{{ 'content.points' | translate }}" name="points"> </mat-form-field> <div fxLayout="row" fxLayoutAlign="center" fxLayoutGap="10px"> <button (click)="dialogRef.close()" mat-button color="primary"> diff --git a/src/app/components/creator/_dialogs/answer-edit/answer-edit.component.ts b/src/app/components/creator/_dialogs/answer-edit/answer-edit.component.ts index 54f8a3b59356a8cd82f551d4d39f3778683a1894..f3e4028f36c34de85b634477207dfb1403e915c3 100644 --- a/src/app/components/creator/_dialogs/answer-edit/answer-edit.component.ts +++ b/src/app/components/creator/_dialogs/answer-edit/answer-edit.component.ts @@ -16,8 +16,4 @@ export class AnswerEditComponent implements OnInit { ngOnInit() { } - - onNoClick(): void { - this.dialogRef.close(); - } } diff --git a/src/app/components/creator/_dialogs/content-delete/content-delete.component.html b/src/app/components/creator/_dialogs/content-delete/content-delete.component.html index ec9c306b291eb9aeaec466ebedb9865f9605e16b..8794410ab9296300ecb26cca26fbea2839e97ed9 100644 --- a/src/app/components/creator/_dialogs/content-delete/content-delete.component.html +++ b/src/app/components/creator/_dialogs/content-delete/content-delete.component.html @@ -1,10 +1,10 @@ <h3>{{ 'room-page.sure' | translate}}</h3> -<p>Do you really want to delete content <strong>{{content.subject}}</strong>? This action can not be undone.</p> +<p>{{'room-page.reallyContent' | translate}}<strong>{{content.subject}}</strong>{{'room-page.really2' | translate}}</p> <div fxLayout="row" fxLayoutAlign="center" fxLayoutGap="10px"> <button mat-raised-button color="warn" (click)="closeDialog('delete')"> - Delete content + {{'content.delete' | translate}} </button> <button mat-raised-button color="primary" (click)="closeDialog('abort')"> - Abort + {{'content.abort' | translate}} </button> </div> diff --git a/src/app/components/creator/_dialogs/content-edit/content-edit.component.html b/src/app/components/creator/_dialogs/content-edit/content-edit.component.html new file mode 100644 index 0000000000000000000000000000000000000000..fffc5e8954703c0bcf405519ecdfa192f62c0939 --- /dev/null +++ b/src/app/components/creator/_dialogs/content-edit/content-edit.component.html @@ -0,0 +1,33 @@ +<div fxLayout="column" fxLayoutAlign="center" fxLayoutGap="10px"> + <mat-form-field> + <input matInput [(ngModel)]="content.subject" maxlength="20" placeholder="{{'content.subject' | translate}}" name="subject"/> + </mat-form-field> + <mat-form-field> + <textarea matInput [(ngModel)]="content.body" rows="3" maxlength="100" placeholder="{{'content.body' | translate}}" name="body"></textarea> + </mat-form-field> + <h4>{{'content.answers' | translate}}</h4> + <mat-table [dataSource]="displayAnswers"> + <ng-container matColumnDef="label"> + <mat-cell *matCellDef="let answer"> + <mat-form-field class="input-block"> + <input matInput [(ngModel)]="answer.answerOption.label" maxlength="20" name="answer"/> + </mat-form-field> + </mat-cell> + </ng-container> + <ng-container matColumnDef="checked"> + <mat-cell *matCellDef="let answer; let i = index"> + <mat-checkbox color="accent" [(ngModel)]="answer.correct" + [checked]="answer.correct" (ngModelChange)="updateAnswer(i)"></mat-checkbox> + </mat-cell> + </ng-container> + <mat-row *matRowDef="let row; columns: displayedColumns;"></mat-row> + </mat-table> + <div fxLayout="row" fxLayoutAlign="center" fxLayoutGap="10px"> + <button (click)="dialogRef.close('abort')" mat-button color="primary"> + {{ 'room-page.abort' | translate }} + </button> + <button (click)="updateContent()" mat-raised-button color="primary"> + {{ 'room-page.update' | translate }} + </button> + </div> +</div> diff --git a/src/app/components/creator/_dialogs/content-edit/content-edit.component.scss b/src/app/components/creator/_dialogs/content-edit/content-edit.component.scss new file mode 100644 index 0000000000000000000000000000000000000000..79a73c116559964c09c1dcce1a98cf20b60ac3e5 --- /dev/null +++ b/src/app/components/creator/_dialogs/content-edit/content-edit.component.scss @@ -0,0 +1,26 @@ +textarea { + line-height: 120%; +} + +.mat-column-checked { + display: flex; + justify-content: flex-end; + max-width: 30px; +} + +mat-row { + background-color: #bbdefb; + border-color: #bbdefb; +} + +h4 { + margin: 0px !important; + padding-top: 0px; + padding-bottom: 5px; + color: #4db6ac; +} + +mat-cell { + padding-left: 0px!important; + padding-right: 10px!important; +} diff --git a/src/app/components/creator/answers-list/answers-list.component.spec.ts b/src/app/components/creator/_dialogs/content-edit/content-edit.component.spec.ts similarity index 54% rename from src/app/components/creator/answers-list/answers-list.component.spec.ts rename to src/app/components/creator/_dialogs/content-edit/content-edit.component.spec.ts index 6ce3bb35ab546095cbe7530453ee3feaed389dbc..d0b9b23d0e043b6520a30b25fdcb322ba08fa9f3 100644 --- a/src/app/components/creator/answers-list/answers-list.component.spec.ts +++ b/src/app/components/creator/_dialogs/content-edit/content-edit.component.spec.ts @@ -1,20 +1,20 @@ import { async, ComponentFixture, TestBed } from '@angular/core/testing'; -import { AnswersListComponent } from './answers-list.component'; +import { ContentEditComponent } from './content-edit.component'; -describe('AnswersListComponent', () => { - let component: AnswersListComponent; - let fixture: ComponentFixture<AnswersListComponent>; +describe('ContentEditComponent', () => { + let component: ContentEditComponent; + let fixture: ComponentFixture<ContentEditComponent>; beforeEach(async(() => { TestBed.configureTestingModule({ - declarations: [ AnswersListComponent ] + declarations: [ ContentEditComponent ] }) .compileComponents(); })); beforeEach(() => { - fixture = TestBed.createComponent(AnswersListComponent); + fixture = TestBed.createComponent(ContentEditComponent); component = fixture.componentInstance; fixture.detectChanges(); }); diff --git a/src/app/components/creator/_dialogs/content-edit/content-edit.component.ts b/src/app/components/creator/_dialogs/content-edit/content-edit.component.ts new file mode 100644 index 0000000000000000000000000000000000000000..4cdeeb591304253dab6d11829eab4c58242eb0ef --- /dev/null +++ b/src/app/components/creator/_dialogs/content-edit/content-edit.component.ts @@ -0,0 +1,102 @@ +import { Component, Inject, OnInit } from '@angular/core'; +import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material'; +import { ContentListComponent } from '../../content-list/content-list.component'; +import { DisplayAnswer } from '../../content-choice-creator/content-choice-creator.component'; +import { ContentChoice } from '../../../../models/content-choice'; +import { AnswerOption } from '../../../../models/answer-option'; +import { TranslateService } from '@ngx-translate/core'; +import { NotificationService } from '../../../../services/util/notification.service'; + +@Component({ + selector: 'app-content-edit', + templateUrl: './content-edit.component.html', + styleUrls: ['./content-edit.component.scss'] +}) +export class ContentEditComponent implements OnInit { + content: ContentChoice; + displayAnswers: DisplayAnswer[] = []; + displayedColumns = ['label', 'checked']; + ansCounter = 1; + + constructor(private translateService: TranslateService, + private notificationService: NotificationService, + public dialogRef: MatDialogRef<ContentListComponent>, + @Inject(MAT_DIALOG_DATA) public data: any) { + } + + ngOnInit() { + for (let i = 0; i < this.content.options.length; i++) { + let correct: boolean; + correct = this.content.options[i].points > 0; + this.displayAnswers[i] = new DisplayAnswer(new AnswerOption(this.content.options[i].label, this.content.options[i].points), correct); + } + } + + updateAnswer(index: number) { + if (this.displayAnswers[index].correct === true) { + this.ansCounter++; + if ((!this.content.multiple) && this.ansCounter > 1) { + for (let i = 0; i < this.displayAnswers.length; i++) { + if (!(i === index)) { + this.displayAnswers[i].correct = false; + this.content.options[i].points = -10; + } + } + this.ansCounter = 1; + } + this.content.options[index].points = 10; + } else { + this.ansCounter--; + this.content.options[index].points = -10; + } + } + + updateContent() { + let counter = 0; + if (this.content.subject === '' || this.content.body === '') { + this.translateService.get('content.no-empty').subscribe(message => { + this.notificationService.show(message); + }); + return; + } + if (this.displayAnswers.length === 0) { + this.translateService.get('content.need-answers').subscribe(message => { + this.notificationService.show(message); + }); + return; + } + for (let i = 0; i < this.content.options.length; i++) { + if (this.displayAnswers[i].answerOption.label === '') { + this.translateService.get('content.no-empty2').subscribe(message => { + this.notificationService.show(message); + }); + return; + } + if (this.content.options[i].points > 0) { + counter++; + } + } + if (counter <= 0) { + if (this.content.multiple) { + this.translateService.get('content.at-least-one').subscribe(message => { + this.notificationService.show(message); + return; + }); + } else { + this.translateService.get('content.select-one').subscribe(message => { + this.notificationService.show(message); + return; + }); + } + } else { + if ((!this.content.multiple) && counter > 1) { + this.translateService.get('content.select-one').subscribe(message => { + this.notificationService.show(message); + }); + return; + } + this.dialogRef.close('update'); + return; + } + } +} diff --git a/src/app/components/creator/_dialogs/markdown-help-dialog/markdown-help-dialog.component.html b/src/app/components/creator/_dialogs/markdown-help-dialog/markdown-help-dialog.component.html deleted file mode 100644 index 3d4b4ef0450226f73fe386eb000a75f8ac2cd40d..0000000000000000000000000000000000000000 --- a/src/app/components/creator/_dialogs/markdown-help-dialog/markdown-help-dialog.component.html +++ /dev/null @@ -1,5 +0,0 @@ -<p> - You can use <a href="https://guides.github.com/features/mastering-markdown/" title="Markdown GitHub" target="_blank"> - Markdown</a> to style your texts. The shown buttons offer shortcuts to insert commonly used tags. -</p> -<button mat-raised-button (click)="onNoClick();">Okay!</button> diff --git a/src/app/components/creator/_dialogs/markdown-help-dialog/markdown-help-dialog.component.scss b/src/app/components/creator/_dialogs/markdown-help-dialog/markdown-help-dialog.component.scss deleted file mode 100644 index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..0000000000000000000000000000000000000000 diff --git a/src/app/components/creator/_dialogs/markdown-help-dialog/markdown-help-dialog.component.spec.ts b/src/app/components/creator/_dialogs/markdown-help-dialog/markdown-help-dialog.component.spec.ts deleted file mode 100644 index 0a17c707803ce32dd9b7594dd795e925522e9cb4..0000000000000000000000000000000000000000 --- a/src/app/components/creator/_dialogs/markdown-help-dialog/markdown-help-dialog.component.spec.ts +++ /dev/null @@ -1,25 +0,0 @@ -import { async, ComponentFixture, TestBed } from '@angular/core/testing'; - -import { MarkdownHelpDialogComponent } from './markdown-help-dialog.component'; - -describe('MarkdownHelpDialogComponent', () => { - let component: MarkdownHelpDialogComponent; - let fixture: ComponentFixture<MarkdownHelpDialogComponent>; - - beforeEach(async(() => { - TestBed.configureTestingModule({ - declarations: [ MarkdownHelpDialogComponent ] - }) - .compileComponents(); - })); - - beforeEach(() => { - fixture = TestBed.createComponent(MarkdownHelpDialogComponent); - component = fixture.componentInstance; - fixture.detectChanges(); - }); - - it('should create', () => { - expect(component).toBeTruthy(); - }); -}); diff --git a/src/app/components/creator/_dialogs/markdown-help-dialog/markdown-help-dialog.component.ts b/src/app/components/creator/_dialogs/markdown-help-dialog/markdown-help-dialog.component.ts deleted file mode 100644 index 34048ab1f08c06a84dacae246cd0ba3873918f92..0000000000000000000000000000000000000000 --- a/src/app/components/creator/_dialogs/markdown-help-dialog/markdown-help-dialog.component.ts +++ /dev/null @@ -1,17 +0,0 @@ -import { Component } from '@angular/core'; -import { GenericDataDialogComponent } from '../../../shared/_dialogs/generic-data-dialog/generic-data-dialog.component'; -import { MatDialogRef } from '@angular/material'; - -@Component({ - selector: 'app-markdown-help-dialog', - templateUrl: './markdown-help-dialog.component.html', - styleUrls: ['./markdown-help-dialog.component.scss'] -}) -export class MarkdownHelpDialogComponent { - - constructor(public dialogRef: MatDialogRef<GenericDataDialogComponent>) { } - - onNoClick(): void { - this.dialogRef.close(); - } -} diff --git a/src/app/components/creator/_dialogs/room-delete/room-delete.component.html b/src/app/components/creator/_dialogs/room-delete/room-delete.component.html index 91f6a6b88ee8708e0e04fda142aa748f530b1316..388fccfed247ead815b4783b5a0dc7c7e339824b 100644 --- a/src/app/components/creator/_dialogs/room-delete/room-delete.component.html +++ b/src/app/components/creator/_dialogs/room-delete/room-delete.component.html @@ -1,5 +1,5 @@ <h3>{{ 'room-page.sure' | translate }}</h3> -<p>{{ 'room-page.really' | translate}}<strong>{{room.name}}</strong>{{ 'room-page.really2' | translate}}</p> +<p>{{ 'room-page.reallySession' | translate}}<strong>{{room.name}}</strong>{{ 'room-page.really2' | translate}}</p> <div fxLayout="row" fxLayoutAlign="center" fxLayoutGap="10px"> <button mat-raised-button color="warn" (click)="dialogRef.close('delete')"> {{ 'room-page.delete-room' | translate }} diff --git a/src/app/components/creator/_dialogs/room-edit/room-edit.component.html b/src/app/components/creator/_dialogs/room-edit/room-edit.component.html index 0f2338d3c6169677880ad4274b1d78e71b6c66ea..fa34865c28a2ac1a03c5b8ef3fae8daad6634ad4 100644 --- a/src/app/components/creator/_dialogs/room-edit/room-edit.component.html +++ b/src/app/components/creator/_dialogs/room-edit/room-edit.component.html @@ -1,9 +1,9 @@ <div *ngIf="editRoom"> <mat-form-field class="input-block"> - <input [(ngModel)]="editRoom.name" #roomName matInput placeholder="{{ 'session.session-name' | translate}}" name="room-name"/> + <input [(ngModel)]="editRoom.name" matInput placeholder="{{ 'session.session-name' | translate}}" name="room-name"/> </mat-form-field> <mat-form-field class="input-block"> - <textarea [(ngModel)]="editRoom.description" #roomDescription matInput matTextareaAutosize + <textarea [(ngModel)]="editRoom.description" matInput matTextareaAutosize matAutosizeMinRows="2" matAutosizeMaxRows="5" placeholder="{{ 'session.description' | translate}}" name="description"> </textarea> </mat-form-field> diff --git a/src/app/components/creator/_dialogs/room-edit/room-edit.component.ts b/src/app/components/creator/_dialogs/room-edit/room-edit.component.ts index ab1ca500836f7de451e17549801b92b3324f4e7e..cd52da6b55c83b3f913907c2a7f75b9b31254972 100644 --- a/src/app/components/creator/_dialogs/room-edit/room-edit.component.ts +++ b/src/app/components/creator/_dialogs/room-edit/room-edit.component.ts @@ -1,10 +1,7 @@ import { Component, Inject, OnInit } from '@angular/core'; import { Room } from '../../../../models/room'; -import { RoomService } from '../../../../services/http/room.service'; import { RoomCreateComponent } from '../room-create/room-create.component'; import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material'; -import { NotificationService } from '../../../../services/util/notification.service'; -import { Router } from '@angular/router'; @Component({ selector: 'app-room-edit', @@ -14,10 +11,7 @@ import { Router } from '@angular/router'; export class RoomEditComponent implements OnInit { editRoom: Room; - constructor(private roomService: RoomService, - private router: Router, - private notification: NotificationService, - public dialogRef: MatDialogRef<RoomCreateComponent>, + constructor(public dialogRef: MatDialogRef<RoomCreateComponent>, @Inject(MAT_DIALOG_DATA) public data: any) { } diff --git a/src/app/components/creator/answers-list/answers-list.component.html b/src/app/components/creator/answers-list/answers-list.component.html deleted file mode 100644 index d1205e828c48078f9500b29a95674ca9d06dd6e0..0000000000000000000000000000000000000000 --- a/src/app/components/creator/answers-list/answers-list.component.html +++ /dev/null @@ -1,8 +0,0 @@ -<mat-list> - <h3 mat-subheader>Answers</h3> - <mat-list-item *ngFor="let textAnswer of textAnswers"> - <button mat-button routerLink="{{textAnswer.id}}"> - {{textAnswer.body}} - </button> - </mat-list-item> -</mat-list> \ No newline at end of file diff --git a/src/app/components/creator/answers-list/answers-list.component.scss b/src/app/components/creator/answers-list/answers-list.component.scss deleted file mode 100644 index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..0000000000000000000000000000000000000000 diff --git a/src/app/components/creator/answers-list/answers-list.component.ts b/src/app/components/creator/answers-list/answers-list.component.ts deleted file mode 100644 index b7cb7656ab21fd04d031878194d9f21742f5e819..0000000000000000000000000000000000000000 --- a/src/app/components/creator/answers-list/answers-list.component.ts +++ /dev/null @@ -1,33 +0,0 @@ -import { Component, OnInit } from '@angular/core'; -import { ContentAnswerService } from '../../../services/http/content-answer.service'; -import { AnswerText } from '../../../models/answer-text'; -import { ActivatedRoute } from '@angular/router'; -import { ContentService } from '../../../services/http/content.service'; - -@Component({ - selector: 'app-answers-list', - templateUrl: './answers-list.component.html', - styleUrls: ['./answers-list.component.scss'] -}) -export class AnswersListComponent implements OnInit { - textAnswers: AnswerText[]; - - constructor( - private contentService: ContentService, - private contentAnswerService: ContentAnswerService, - private route: ActivatedRoute) { - } - - ngOnInit() { - this.route.params.subscribe(params => { - this.getAnswerTexts(params['contentId']); - }); - } - - getAnswerTexts(contentId: string): void { - this.contentAnswerService.getAnswers(contentId) - .subscribe(textAnswers => { - this.textAnswers = textAnswers; - }); - } -} diff --git a/src/app/components/creator/content-choice-creator/content-choice-creator.component.html b/src/app/components/creator/content-choice-creator/content-choice-creator.component.html index bf302a4be92a51b87a2502f9bba6467f4bbe27d7..0f4b46e6c652c515d64dbf945077722be55ccf1a 100644 --- a/src/app/components/creator/content-choice-creator/content-choice-creator.component.html +++ b/src/app/components/creator/content-choice-creator/content-choice-creator.component.html @@ -1,6 +1,4 @@ <form (ngSubmit)="submitContent()" fxLayout="column" fxLayoutGap="20px"> - <markdown [data]="content.body"></markdown> - <mat-divider></mat-divider> <mat-radio-group [(ngModel)]="singleChoice" [ngModelOptions]="{standalone: true}" fxLayout="row" fxLayoutAlign="center" fxLayoutGap="20px"> <mat-radio-button [value]=true [checked]=true> @@ -11,11 +9,10 @@ </mat-radio-button> </mat-radio-group> - <mat-table #table [dataSource]="displayAnswers"> + <mat-table [dataSource]="displayAnswers"> <ng-container matColumnDef="label"> <mat-header-cell *matHeaderCellDef>{{ 'content.answer' | translate }}</mat-header-cell> <mat-cell *matCellDef="let answer"> - <!-- ToDo: Check ngModel --> <mat-checkbox color="primary" (click)="switchValue(answer.answerOption.label)" [(ngModel)]="answer.correct" [checked]="answer.correct" name="{{ answer.answerOption.label }}">{{ answer.answerOption.label }} @@ -27,12 +24,12 @@ <mat-header-cell *matHeaderCellDef>{{ 'content.actions' | translate }}</mat-header-cell> <mat-cell *matCellDef="let answer"> <button mat-icon-button - (click)="openAnswerModificationDialog($event, answer.answerOption.label, answer.correct)" - color="primary" matTooltip="Edit answer"> + (click)="openAnswerModificationDialog($event, answer.answerOption.label, answer.answerOption.points, answer.correct)" + color="primary" matTooltip="{{ 'content.edit-answer' | translate }}"> <mat-icon>edit</mat-icon> </button> <button mat-icon-button color="primary" (click)="deleteAnswer($event, answer.answerOption.label)" - matTooltip="Delete answer"> + matTooltip="{{ 'content.delete-answer' | translate }}"> <mat-icon>delete</mat-icon> </button> </mat-cell> @@ -42,24 +39,19 @@ <mat-row *matRowDef="let row; columns: displayedColumns;"></mat-row> </mat-table> - <div fxLayout="row" fxLayoutAlign="center" fxLayoutGap="50px"> + <div fxLayout="row" fxLayoutAlign="center" fxLayoutGap="20px"> <mat-form-field class="input-block"> <input matInput #answerLabel [(ngModel)]="newAnswerOptionLabel" placeholder="{{ 'content.answer' | translate }}" name="answer"> </mat-form-field> - <button mat-button type="button" (click)="addAnswer($event); answerLabel.value = '';"> - {{ 'content.add-answer' | translate }} + <button *ngIf="singleChoice" mat-icon-button class="addButton" (click)="addAnswer($event); answerLabel.value = '';" matTooltip="{{'content.add-answer' | translate}}"> + <mat-icon class="addIcon" color="primary">add_circle</mat-icon> + </button> + <button *ngIf="!singleChoice" mat-icon-button (click)="addAnswer($event); answerLabel.value = '';" matTooltip="{{'content.add-answer' | translate}}"> + <mat-icon class="addIcon" color="primary">add_box</mat-icon> </button> </div> - <div *ngIf="!editDialogMode" fxLayout="row" fxLayoutAlign="center" fxLayoutGap="50px"> + <div fxLayout="row" fxLayoutAlign="center" fxLayoutGap="25px"> <button mat-raised-button type="submit" color="accent">{{ 'content.create' | translate }}</button> <button mat-raised-button (click)="reset($event)" color="primary">{{ 'content.reset' | translate }}</button> - <button mat-raised-button *ngIf="lastDeletedDisplayAnswer" (click)="recoverDeletedAnswer($event)" color="primary"> - {{ 'content.undo' | translate}} - </button> - </div> - <div *ngIf="editDialogMode" fxLayout="row" fxLayoutAlign="center" fxLayoutGap="50px"> - <button mat-raised-button (click)="editDialogClose($event,'edit')" color="primary">Update</button> - <button mat-raised-button (click)="editDialogClose($event,'abort')" color="primary">Abort</button> - <button mat-raised-button (click)="openDeletionContentDialog($event)" color="warn">Delete</button> </div> </form> diff --git a/src/app/components/creator/content-choice-creator/content-choice-creator.component.scss b/src/app/components/creator/content-choice-creator/content-choice-creator.component.scss index 3d0e678f5ec7ef58ad3ce0c18847c8e32c158072..4fd9f7dddf9c962105e683e718ff3fa42db9b041 100644 --- a/src/app/components/creator/content-choice-creator/content-choice-creator.component.scss +++ b/src/app/components/creator/content-choice-creator/content-choice-creator.component.scss @@ -1,11 +1,43 @@ form > button { - margin: 20px 0; + margin: 10px; } mat-header-cell { background-color: #ffe0b2; } -mat-cell { +mat-row { background-color: #ffecb3; + + &:last-child { + animation: fadeIn 2s; + } +} + +@keyframes fadeIn { + 0% {background-color: #b2dfdb} + 100% {background-color: #ffecb3} +} + +.addIcon { + line-height: 100%; + height: 100% !important; + width: 100% !important; + font-size: 40px !important; +} + +.addButton { + transition-duration: 0.5s; + + &:focus { + transform: rotate(90deg); + } +} + +.mat-raised-button { + min-width: 120px; +} + +mat-form-field { + min-width: 250px; } diff --git a/src/app/components/creator/content-choice-creator/content-choice-creator.component.ts b/src/app/components/creator/content-choice-creator/content-choice-creator.component.ts index 684eafcafc4071e8df2933eafada1914ee4cd9ae..51a7adab560e8bca162a3e932ac0a61e1b4cb7fd 100644 --- a/src/app/components/creator/content-choice-creator/content-choice-creator.component.ts +++ b/src/app/components/creator/content-choice-creator/content-choice-creator.component.ts @@ -1,13 +1,11 @@ -import { Component, EventEmitter, Inject, Input, OnInit, Output } from '@angular/core'; +import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core'; import { AnswerOption } from '../../../models/answer-option'; import { ContentChoice } from '../../../models/content-choice'; import { ContentService } from '../../../services/http/content.service'; import { NotificationService } from '../../../services/util/notification.service'; -import { MAT_DIALOG_DATA, MatDialog, MatDialogRef } from '@angular/material'; +import { MatDialog } from '@angular/material'; import { AnswerEditComponent } from '../_dialogs/answer-edit/answer-edit.component'; import { ContentType } from '../../../models/content-type.enum'; -import { ContentListComponent } from '../content-list/content-list.component'; -import { ContentDeleteComponent } from '../_dialogs/content-delete/content-delete.component'; import { TranslateService } from '@ngx-translate/core'; export class DisplayAnswer { @@ -58,17 +56,12 @@ export class ContentChoiceCreatorComponent implements OnInit { editDisplayAnswer: DisplayAnswer; originalDisplayAnswer: DisplayAnswer; - editDialogMode = false; - changesAllowed = false; - roomId: string; constructor(private contentService: ContentService, private notificationService: NotificationService, public dialog: MatDialog, - public dialogRef: MatDialogRef<ContentListComponent>, - private translationService: TranslateService, - @Inject(MAT_DIALOG_DATA) public data: any) { + private translationService: TranslateService) { } ngOnInit() { @@ -187,31 +180,6 @@ export class ContentChoiceCreatorComponent implements OnInit { }); } - recoverDeletedAnswer($event) { - $event.preventDefault(); - this.translationService.get('content.answer-recovered').subscribe(message => { this.notificationService.show(message); - }); - for (let i = 0; i < this.content.options.length; i++) { - if (this.content.options[i].label.valueOf() === this.lastDeletedDisplayAnswer.answerOption.label.valueOf()) { - this.translationService.get('content.same-answer').subscribe(message => { - this.notificationService.show(message); - }); - return; - } - } - this.content.options.push(this.lastDeletedDisplayAnswer.answerOption); - if (this.lastDeletedDisplayAnswer.correct) { - if (this.singleChoice && this.content.correctOptionIndexes.length > 0) { - this.translationService.get('content.only-one-true').subscribe(message => { this.notificationService.show(message); - }); - } else { - this.content.correctOptionIndexes.push(this.content.options.length - 1); - } - } - this.lastDeletedDisplayAnswer = null; - this.fillCorrectAnswers(); - } - switchValue(label: string) { const index = this.findAnswerIndexByLabel(label); this.editDisplayAnswer = new DisplayAnswer( @@ -277,10 +245,6 @@ export class ContentChoiceCreatorComponent implements OnInit { this.content.multiple = true; this.content.format = ContentType.CHOICE; } - if (this.editDialogMode) { - this.changesAllowed = true; - return; - } let contentGroup: string; if (this.contentCol === 'Default') { contentGroup = ''; @@ -302,35 +266,4 @@ export class ContentChoiceCreatorComponent implements OnInit { )).subscribe(); this.resetAfterSubmit(); } - - editDialogClose($event, action: string) { - $event.preventDefault(); - if (action.valueOf() === 'edit') { - this.submitContent(); - } - if (action.valueOf() === 'abort') { - this.dialogRef.close(action); - } - if (this.changesAllowed) { - this.dialogRef.close(action); - } - } - - onNoClick(): void { - this.dialogRef.close(); - } - - openDeletionContentDialog($event): void { - $event.preventDefault(); - const dialogRef = this.dialog.open(ContentDeleteComponent, { - width: '400px' - }); - dialogRef.componentInstance.content = this.content; - dialogRef.afterClosed() - .subscribe(result => { - if (result === 'delete') { - this.dialogRef.close(result); - } - }); - } } 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 c4e7185fb21d293608a5dcb0a20674f0c72d8a1a..c09a49856856980c2d252b2be23fe129858f0113 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 @@ -1,4 +1,4 @@ -<div fxLayout="column" fxLayoutAlign="start" fxLayoutGap="20px" fxFill> +<div fxLayout="column" fxLayoutAlign="start" fxLayoutGap="5%" fxFill> <div fxLayout="row" fxLayoutAlign="center"> <mat-tab-group> <mat-tab label="Single / Multiple Choice"> diff --git a/src/app/components/creator/content-create-page/content-create-page.component.scss b/src/app/components/creator/content-create-page/content-create-page.component.scss index ea9c3d93f767262d835e953d031a031e64ad6f42..c40d37584524f6f914cd0e3e7e4b6265f8943abb 100644 --- a/src/app/components/creator/content-create-page/content-create-page.component.scss +++ b/src/app/components/creator/content-create-page/content-create-page.component.scss @@ -4,5 +4,5 @@ mat-tab-group { } .tab-container { - padding: 20px; + padding: 5px; } diff --git a/src/app/components/creator/content-creator/content-creator.component.html b/src/app/components/creator/content-creator/content-creator.component.html index 0510eea61809a09e624a2edd9e4bc5c9800397fb..407b840e6c9cf2cf3acbf0c07b2795914fa95fbd 100644 --- a/src/app/components/creator/content-creator/content-creator.component.html +++ b/src/app/components/creator/content-creator/content-creator.component.html @@ -1,16 +1,15 @@ <form> <mat-form-field class="input-block"> - <input matInput #subject [(ngModel)]="content.subject" placeholder="{{'content.subject' | translate}}" name="subject"> + <input matInput #subject [(ngModel)]="content.subject" placeholder="{{'content.subject' | translate}}" name="subject" + maxlength="20"> </mat-form-field> -<app-markdown-toolbar textareaId="content-text-body"></app-markdown-toolbar> <mat-form-field class="input-block"> <textarea matInput #body [(ngModel)]="content.body" placeholder="{{'content.body' | translate}}" name="body" - matTextareaAutosize matAutosizeMinRows="3" matAutosizeMaxRows="8"></textarea> + matTextareaAutosize matAutosizeMinRows="3" matAutosizeMaxRows="8" maxlength="100"></textarea> </mat-form-field> -<markdown [data]="content.body"></markdown> <mat-form-field> <input matInput #group [formControl]="myControl" [matAutocomplete]="auto" - placeholder="{{'content.collection' | translate}}" value="{{lastCollection}}" /> + placeholder="{{'content.collection' | translate}}" [(ngModel)]="lastCollection" /> <mat-autocomplete #auto="matAutocomplete"> <mat-option *ngFor="let collection of contentGroups" [value]="collection.name"> {{collection.name}} diff --git a/src/app/components/creator/content-creator/content-creator.component.ts b/src/app/components/creator/content-creator/content-creator.component.ts index 39d4e72602977a6e380246c8da20b7ed8ea9faea..c714e60b94ae35cea50abf2df1a15f5bc5606856 100644 --- a/src/app/components/creator/content-creator/content-creator.component.ts +++ b/src/app/components/creator/content-creator/content-creator.component.ts @@ -1,8 +1,6 @@ -import { Component, Inject, Input, OnInit } from '@angular/core'; +import { Component, Input, OnInit } from '@angular/core'; import { ContentText } from '../../../models/content-text'; -import { FormControl } from '@angular/forms'; -import { MAT_DIALOG_DATA, MatDialog, MatDialogRef } from '@angular/material'; -import { ContentListComponent } from '../content-list/content-list.component'; +import { FormControl } from '@angular/forms';; import { Room } from '../../../models/room'; import { TranslateService } from '@ngx-translate/core'; @@ -33,10 +31,7 @@ export class ContentCreatorComponent implements OnInit { editDialogMode = false; - constructor(public dialog: MatDialog, - public dialogRef: MatDialogRef<ContentListComponent>, - private translateService: TranslateService, - @Inject(MAT_DIALOG_DATA) public data: any) { + constructor(private translateService: TranslateService) { } ngOnInit() { diff --git a/src/app/components/creator/content-likert-creator/content-likert-creator.component.html b/src/app/components/creator/content-likert-creator/content-likert-creator.component.html index d5220fee0afede4dbf99bae87ba82af4e7836e62..a79b6e01b407a1aa384d5cf3c90647b3bb7221d4 100644 --- a/src/app/components/creator/content-likert-creator/content-likert-creator.component.html +++ b/src/app/components/creator/content-likert-creator/content-likert-creator.component.html @@ -1,22 +1,16 @@ <form (ngSubmit)="submitContent()" fxLayout="column" fxLayoutGap="20px"> <mat-divider></mat-divider> - <mat-table #table [dataSource]="displayAnswers"> + <mat-table [dataSource]="displayAnswers"> <ng-container matColumnDef="label"> <mat-header-cell *matHeaderCellDef>{{ 'content.answer' | translate }}</mat-header-cell> <mat-cell *matCellDef="let answer"> - <!-- ToDo: Check ngModel --> {{ answer.answerOption.label }} </mat-cell> </ng-container> <mat-header-row *matHeaderRowDef="displayedColumns"></mat-header-row> <mat-row *matRowDef="let row; columns: displayedColumns;"></mat-row> </mat-table> - <div *ngIf="!editDialogMode"> + <div> <button mat-raised-button type="submit" color="accent">{{ 'content.create' | translate }}</button> </div> - <div *ngIf="editDialogMode"> - <button mat-raised-button (click)="editDialogClose($event,'edit')" color="primary">Update</button> - <button mat-raised-button (click)="editDialogClose($event,'abort')" color="primary">Abort</button> - <button mat-raised-button (click)="openDeletionContentDialog($event)" color="warn">Delete</button> - </div> </form> diff --git a/src/app/components/creator/content-likert-creator/content-likert-creator.component.ts b/src/app/components/creator/content-likert-creator/content-likert-creator.component.ts index c37fe12e8386c27e6e31d6457754442b4036744c..057370992c19b7ddc2efb4636f59cce6b4da3325 100644 --- a/src/app/components/creator/content-likert-creator/content-likert-creator.component.ts +++ b/src/app/components/creator/content-likert-creator/content-likert-creator.component.ts @@ -1,13 +1,10 @@ -import { Component, EventEmitter, Inject, Input, OnInit, Output } from '@angular/core'; +import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core'; import { DisplayAnswer } from '../content-choice-creator/content-choice-creator.component'; import { ContentChoice } from '../../../models/content-choice'; import { AnswerOption } from '../../../models/answer-option'; import { ContentType } from '../../../models/content-type.enum'; import { ContentService } from '../../../services/http/content.service'; import { NotificationService } from '../../../services/util/notification.service'; -import { MAT_DIALOG_DATA, MatDialog, MatDialogRef } from '@angular/material'; -import { ContentListComponent } from '../content-list/content-list.component'; -import { ContentDeleteComponent } from '../_dialogs/content-delete/content-delete.component'; import { FormControl } from '@angular/forms'; import { Observable } from 'rxjs'; import { map, startWith } from 'rxjs/operators'; @@ -51,19 +48,10 @@ export class ContentLikertCreatorComponent implements OnInit { displayAnswers: DisplayAnswer[] = []; newAnswerOptionPoints = 0; - collections: string[] = ['ARSnova', 'Angular', 'HTML', 'TypeScript' ]; - myControl = new FormControl(); - filteredOptions: Observable<string[]>; - lastCollection: string; - - editDialogMode = false; constructor(private contentService: ContentService, private notificationService: NotificationService, - public dialog: MatDialog, - public dialogRef: MatDialogRef<ContentListComponent>, - private translationService: TranslateService, - @Inject(MAT_DIALOG_DATA) public data: any) { + private translationService: TranslateService) { } fillCorrectAnswers() { @@ -79,18 +67,6 @@ export class ContentLikertCreatorComponent implements OnInit { for (let i = 0; i < this.likertScale.length; i++) { this.content.options.push(new AnswerOption(this.likertScale[i], this.newAnswerOptionPoints)); } - this.fillCorrectAnswers(); - this.lastCollection = sessionStorage.getItem('collection'); - this.filteredOptions = this.myControl.valueChanges - .pipe( - startWith(''), - map(value => this._filter(value)) - ); - } - - private _filter(value: string): string[] { - const filterValue = value.toLowerCase(); - return this.collections.filter(collection => collection.toLowerCase().includes(filterValue)); } resetAfterSubmit() { @@ -130,27 +106,4 @@ export class ContentLikertCreatorComponent implements OnInit { )).subscribe(); this.resetAfterSubmit(); } - - editDialogClose($event, action: string) { - $event.preventDefault(); - this.dialogRef.close(action); - } - - onNoClick(): void { - this.dialogRef.close(); - } - - openDeletionContentDialog($event): void { - $event.preventDefault(); - const dialogRef = this.dialog.open(ContentDeleteComponent, { - width: '400px' - }); - dialogRef.componentInstance.content = this.content; - dialogRef.afterClosed() - .subscribe(result => { - if (result === 'delete') { - this.dialogRef.close(result); - } - }); - } } diff --git a/src/app/components/creator/content-list/content-list.component.html b/src/app/components/creator/content-list/content-list.component.html index 97a085c2ba2b39ccee65397360286a1a1e4d74b6..ff9b3013530bb8b885206e736564edaf1c825bff 100644 --- a/src/app/components/creator/content-list/content-list.component.html +++ b/src/app/components/creator/content-list/content-list.component.html @@ -1,27 +1,56 @@ -<div fxLayout="row" fxLayoutAlign="center"> - <mat-card> - <h2 fxLayoutAlign="center">{{ 'content.contents' | translate}}</h2> - <mat-divider></mat-divider> - <mat-card-actions> - <button mat-fab color="primary" matTooltip="Fragen präsentieren" - routerLink="/creator/room/{{ roomId }}/contents"> - <mat-icon>school</mat-icon> - </button> - <button mat-fab color="primary" matTooltip="Neue Frage erstellen" +<div fxLayout="row" fxLayoutGap="20px" fxLayoutAlign="center"> + <mat-card> + <mat-card-header> + <mat-card-title> + <h2>{{ collectionName }}</h2> + </mat-card-title> + </mat-card-header> + <mat-divider></mat-divider> + <div *ngIf="isLoading" fxLayout="column" fxLayoutAlign="center" fxLayoutGap="20px" fxFill> + <div fxLayout="row" fxLayoutAlign="center"> + <mat-progress-spinner mode="indeterminate"></mat-progress-spinner> + </div> + </div> + <mat-grid-list cols="3" rowHeight="1:1"> + <mat-grid-tile> + <button class="actionButton" mat-icon-button color="primary" + matTooltip="{{ 'room-page.create-content' | translate}}" routerLink="/creator/room/{{ roomId }}/create-content"> - <mat-icon>note_add</mat-icon> + <mat-icon class="actionIcon">note_add</mat-icon> + </button> + </mat-grid-tile> + <mat-grid-tile> + <button class="actionButton" mat-icon-button color="primary" matTooltip="{{ 'room-page.present' | translate}}" (click)="notAvailable()"> + <mat-icon class="actionIcon">school</mat-icon> + </button> + </mat-grid-tile> + <mat-grid-tile> + <button class="actionButton" mat-icon-button color="primary" + matTooltip="{{ 'room-page.answer-statistics' | translate}}" + routerLink="/creator/room/{{ roomId }}/statistics"> + <mat-icon class="actionIcon">insert_chart</mat-icon> </button> - </mat-card-actions> - <h4>{{ 'content.click-here' | translate}}<mat-icon>create</mat-icon></h4> - <mat-divider></mat-divider> - <mat-list> - <mat-list-item *ngFor="let content of contents" (click)="editContent(content.subject)"> - <h3 mat-line>{{content.subject}}</h3> - <p mat-line> - <span>{{content.body}}</span> - </p> - <mat-divider></mat-divider> - </mat-list-item> - </mat-list> - </mat-card> - </div> + </mat-grid-tile> + </mat-grid-list> + <mat-divider></mat-divider> + <mat-card-content> + <mat-expansion-panel *ngFor="let content of contents"> + <mat-expansion-panel-header> + <button mat-icon-button color="accent" (click)="editContent(content);$event.stopPropagation();"> + <mat-icon>create</mat-icon> + </button> + <button mat-icon-button color="warn" (click)="deleteContent(content);$event.stopPropagation();" + class="deleteButton"> + <mat-icon>delete_forever</mat-icon> + </button> + <mat-panel-title> + {{ content.subject }} + </mat-panel-title> + </mat-expansion-panel-header> + <mat-panel-description> + {{ content.body }} + </mat-panel-description> + </mat-expansion-panel> + </mat-card-content> + </mat-card> +</div> diff --git a/src/app/components/creator/content-list/content-list.component.scss b/src/app/components/creator/content-list/content-list.component.scss index 3fbca6025f91a3b947ddf591d36ca1b2a2253507..f1208e902992f6b59fcfed9e2eae19860249c4cd 100644 --- a/src/app/components/creator/content-list/content-list.component.scss +++ b/src/app/components/creator/content-list/content-list.component.scss @@ -1,24 +1,55 @@ mat-card { - width: 800px; - background-color: #fff8e1; //mat-color($arsnova-warn, 100); + width: 800px; + background-color: #fff8e1; } mat-card-content > :first-child { - margin-top: 16px; + margin-top: 15px; } -mat-card-actions { - margin: 20px; +mat-expansion-panel { + background-color: #bbdefb; + margin-bottom: 5px; } -button { - margin: 20px; +mat-panel-title { + flex-basis: 0; + align-items: center; + font-size: medium; +} + +mat-expansion-panel-header { + background-color: #bbdefb !important; +} + +.mat-expansion-panel-header-title { + word-break: break-all; } h2 { - color: #90a4ae; + font-size: larger; +} + +.actionButton { + margin: 20px; + width: 30%; + + &:hover { + transform: scale(1.25) + } +} + +.deleteButton { + margin-right: 15px; +} + +mat-tooltip-component { + position: relative; } -h3 { - color: #3f51b5; +.actionIcon { + height: 90% !important; + width: 90% !important; + font-size: 48px !important; + text-align: center; } diff --git a/src/app/components/creator/content-list/content-list.component.ts b/src/app/components/creator/content-list/content-list.component.ts index 15538a54769fdf9afbdd385cc6921abd2942cb43..5ff4280607b8d3cc01f98c4a376a732e6fa7bbc5 100644 --- a/src/app/components/creator/content-list/content-list.component.ts +++ b/src/app/components/creator/content-list/content-list.component.ts @@ -2,20 +2,20 @@ import { Component, OnInit } from '@angular/core'; import { ContentService } from '../../../services/http/content.service'; import { Content } from '../../../models/content'; import { ActivatedRoute } from '@angular/router'; +import { Location } from '@angular/common'; import { ContentChoice } from '../../../models/content-choice'; import { ContentText } from '../../../models/content-text'; -import { AnswerOption } from '../../../models/answer-option'; import { ContentType } from '../../../models/content-type.enum'; import { ContentGroup } from '../../../models/content-group'; import { MatDialog } from '@angular/material'; -import { ContentChoiceCreatorComponent } from '../content-choice-creator/content-choice-creator.component'; -import { ContentLikertCreatorComponent } from '../content-likert-creator/content-likert-creator.component'; -import { ContentTextCreatorComponent } from '../content-text-creator/content-text-creator.component'; import { NotificationService } from '../../../services/util/notification.service'; import { Room } from '../../../models/room'; import { RoomService } from '../../../services/http/room.service'; import { TranslateService } from '@ngx-translate/core'; import { LanguageService } from '../../../services/util/language.service'; +import { ContentDeleteComponent } from '../_dialogs/content-delete/content-delete.component'; +import { ContentEditComponent } from '../_dialogs/content-edit/content-edit.component'; + @Component({ selector: 'app-content-list', @@ -30,7 +30,7 @@ export class ContentListComponent implements OnInit { contentBackup: Content; - ContentType: typeof ContentType = ContentType; + contentCBackup: ContentChoice; roomId: string; @@ -38,9 +38,14 @@ export class ContentListComponent implements OnInit { room: Room; + isLoading = true; + + collectionName: string; + constructor(private contentService: ContentService, private roomService: RoomService, private route: ActivatedRoute, + private location: Location, private notificationService: NotificationService, public dialog: MatDialog, private translateService: TranslateService, @@ -60,8 +65,14 @@ export class ContentListComponent implements OnInit { }); this.route.params.subscribe(params => { sessionStorage.setItem('collection', params['contentGroup']); + this.collectionName = params['contentGroup']; }); this.translateService.use(localStorage.getItem('currentLang')); + this.isLoading = false; + } + + notAvailable() { + this.notificationService.show('This feature has not been implemented yet!'); } findIndexOfSubject(subject: string): number { @@ -76,27 +87,16 @@ export class ContentListComponent implements OnInit { } createChoiceContentBackup(content: ContentChoice) { - const answerOptions: Array<AnswerOption> = new Array<AnswerOption> (); - const correctAnswers: number[] = []; - - for (let i = 0; i < content.options.length; i++) { - answerOptions.push(content.options[i]); - } - - for (let i = 0; i < content.correctOptionIndexes.length; i++) { - correctAnswers.push(content.correctOptionIndexes[i]); - } - - this.contentBackup = new ContentChoice( + this.contentCBackup = new ContentChoice( content.id, content.revision, content.roomId, content.subject, content.body, content.round, - [], - answerOptions, - correctAnswers, + content.groups, + content.options, + content.correctOptionIndexes, content.multiple, content.format ); @@ -114,82 +114,30 @@ export class ContentListComponent implements OnInit { ); } - editContent(subject: string) { - const index = this.findIndexOfSubject(subject); - const format = this.contents[index].format; - - if (format === this.ContentType.TEXT) { - this.createTextContentBackup(this.contents[index] as ContentText); - } else { - this.createChoiceContentBackup(this.contents[index] as ContentChoice); - } - - switch (format) { - case this.ContentType.CHOICE: - this.editChoiceContentDialog(index, this.contents[index] as ContentChoice); - break; - case this.ContentType.BINARY: - this.editBinaryContentDialog(index, this.contents[index] as ContentChoice); - break; - case this.ContentType.SCALE: - this.editLikertContentDialog(index, this.contents[index] as ContentChoice); - break; - case this.ContentType.TEXT: - this.editTextContentDialog(index, this.contents[index] as ContentText); - break; - default: - return; - } - } - - editChoiceContentDialog(index: number, content: ContentChoice) { - const dialogRef = this.dialog.open(ContentChoiceCreatorComponent, { - width: '800px' + deleteContent(delContent: Content) { + const index = this.findIndexOfSubject(delContent.subject); + this.createChoiceContentBackup(delContent as ContentChoice); + const dialogRef = this.dialog.open(ContentDeleteComponent, { + width: '400px' }); - if (content.multiple) { - dialogRef.componentInstance.singleChoice = false; - } else { - dialogRef.componentInstance.singleChoice = true; - } - dialogRef.componentInstance.editDialogMode = true; - dialogRef.componentInstance.content = content; + dialogRef.componentInstance.content = delContent; dialogRef.afterClosed() .subscribe(result => { this.updateContentChanges(index, result); }); } - editBinaryContentDialog(index: number, content: ContentChoice) { - const dialogRef = this.dialog.open(ContentChoiceCreatorComponent, { - width: '800px' - }); - dialogRef.componentInstance.editDialogMode = true; - dialogRef.componentInstance.singleChoice = true; - dialogRef.componentInstance.content = content; - dialogRef.afterClosed() - .subscribe(result => { - this.updateContentChanges(index, result); - }); - } - - editLikertContentDialog(index: number, content: ContentChoice) { - const dialogRef = this.dialog.open(ContentLikertCreatorComponent, { - width: '800px' - }); - dialogRef.componentInstance.editDialogMode = true; - dialogRef.componentInstance.content = content; - dialogRef.afterClosed() - .subscribe(result => { - this.updateContentChanges(index, result); - }); - } - - editTextContentDialog(index: number, content: ContentText) { - const dialogRef = this.dialog.open(ContentTextCreatorComponent, { - width: '800px' + editContent(edContent: Content) { + if (edContent.format === ContentType.TEXT) { + this.createTextContentBackup(edContent as ContentText); + } else { + this.createChoiceContentBackup(edContent as ContentChoice); + } + const index = this.findIndexOfSubject(edContent.subject); + const dialogRef = this.dialog.open(ContentEditComponent, { + width: '400px' }); - dialogRef.componentInstance.editDialogMode = true; - dialogRef.componentInstance.content = content; + dialogRef.componentInstance.content = this.contentCBackup; dialogRef.afterClosed() .subscribe(result => { this.updateContentChanges(index, result); @@ -198,19 +146,28 @@ export class ContentListComponent implements OnInit { updateContentChanges(index: number, action: string) { if (!action) { - this.contents[index] = this.contentBackup; + this.contents[index] = this.contentCBackup; } else { - if (action.valueOf() === 'delete') { - this.notificationService.show('Content "' + this.contents[index].subject + '" deleted.'); - this.contentService.deleteContent(this.contents[index].id); - this.contents.splice(index, 1); - } - if (action.valueOf() === 'edit') { - this.notificationService.show('Content "' + this.contents[index].subject + '" updated.'); - this.contentService.updateContent(this.contents[index]); - } - if (action.valueOf() === 'abort') { - this.contents[index] = this.contentBackup; + switch (action.valueOf()) { + case 'delete': + this.translateService.get('content.content-deleted').subscribe(message => { + this.notificationService.show(message); + }); + this.contentService.deleteContent(this.contents[index].id).subscribe(); + this.contents.splice(index, 1); + if (this.contents.length === 0) { + this.location.back(); + } + break; + case 'update': + this.contents[index] = this.contentCBackup; + this.translateService.get('content.content-updated').subscribe(message => { + this.notificationService.show(message); + }); + break; + case 'abort': + this.contents[index] = this.contentCBackup; + break; } } } 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 e7d342d9664fd48b4b2cf554dad8d51a0f579a07..60a77b90de30c8aaff2bd295e8b4561c609fa404 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,10 +1,5 @@ <form (ngSubmit)="submitContent()"> - <div fxLayout="row" fxLayoutAlign="center" fxLayoutGap="5px" *ngIf="!editDialogMode"> + <div fxLayout="row" fxLayoutAlign="center" fxLayoutGap="5px"> <button mat-raised-button type="submit" color="accent">{{'content.create' | translate}}</button> </div> - <div *ngIf="editDialogMode"> - <button mat-raised-button (click)="editDialogClose($event,'edit')" color="primary">Update</button> - <button mat-raised-button (click)="editDialogClose($event,'abort')" color="primary">Abort</button> - <button mat-raised-button (click)="openDeletionContentDialog($event)" color="warn">Delete</button> - </div> </form> 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 fed678afc57e2496929ab9d873a5d86cff7bffee..2a920daa4a097b82c2ac258f7e87fa52b1595f21 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,10 +1,7 @@ -import { Component, EventEmitter, Inject, Input, OnInit, Output } from '@angular/core'; +import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core'; import { ContentText } from '../../../models/content-text'; import { ContentService } from '../../../services/http/content.service'; import { NotificationService } from '../../../services/util/notification.service'; -import { MAT_DIALOG_DATA, MatDialog, MatDialogRef } from '@angular/material'; -import { ContentListComponent } from '../content-list/content-list.component'; -import { ContentDeleteComponent } from '../_dialogs/content-delete/content-delete.component'; import { TranslateService } from '@ngx-translate/core'; @Component({ @@ -33,10 +30,7 @@ export class ContentTextCreatorComponent implements OnInit { constructor(private contentService: ContentService, private notificationService: NotificationService, - public dialog: MatDialog, - public dialogRef: MatDialogRef<ContentListComponent>, - private translationService: TranslateService, - @Inject(MAT_DIALOG_DATA) public data: any) { + private translationService: TranslateService) { } ngOnInit() { @@ -75,27 +69,4 @@ export class ContentTextCreatorComponent implements OnInit { sessionStorage.setItem('collection', this.contentCol); this.resetAfterSubmit(); } - - editDialogClose($event, action: string) { - $event.preventDefault(); - this.dialogRef.close(action); - } - - onNoClick(): void { - this.dialogRef.close(); - } - - openDeletionContentDialog($event): void { - $event.preventDefault(); - const dialogRef = this.dialog.open(ContentDeleteComponent, { - width: '400px' - }); - dialogRef.componentInstance.content = this.content; - dialogRef.afterClosed() - .subscribe(result => { - if (result === 'delete') { - this.dialogRef.close(result); - } - }); - } } diff --git a/src/app/components/creator/content-yes-no-creator/content-yes-no-creator.component.html b/src/app/components/creator/content-yes-no-creator/content-yes-no-creator.component.html index adcc6f37f5e71e002782b4a5f94eca69fbc325b6..839c16c1c8ae2a1904012fc677cba2ddd5d22c60 100644 --- a/src/app/components/creator/content-yes-no-creator/content-yes-no-creator.component.html +++ b/src/app/components/creator/content-yes-no-creator/content-yes-no-creator.component.html @@ -7,12 +7,7 @@ {{ 'content.no' | translate }} </mat-radio-button> </mat-radio-group> - <div *ngIf="!editDialogMode"> + <div> <button mat-raised-button type="submit" color="accent">{{ 'content.create' | translate }}</button> </div> - <div *ngIf="editDialogMode"> - <button mat-raised-button (click)="editDialogClose($event,'edit')" color="primary">Update</button> - <button mat-raised-button (click)="editDialogClose($event,'abort')" color="primary">Abort</button> - <button mat-raised-button (click)="openDeletionContentDialog($event)" color="warn">Delete</button> - </div> </form> diff --git a/src/app/components/creator/content-yes-no-creator/content-yes-no-creator.component.ts b/src/app/components/creator/content-yes-no-creator/content-yes-no-creator.component.ts index 4f5f69d2f5953200001813c6e14e2c01b34562ad..4baebb4d777a246af7e8fc0262e51357f1d9f91b 100644 --- a/src/app/components/creator/content-yes-no-creator/content-yes-no-creator.component.ts +++ b/src/app/components/creator/content-yes-no-creator/content-yes-no-creator.component.ts @@ -1,16 +1,10 @@ -import { Component, EventEmitter, Inject, Input, OnInit, Output } from '@angular/core'; +import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core'; import { ContentChoice } from '../../../models/content-choice'; import { DisplayAnswer } from '../content-choice-creator/content-choice-creator.component'; import { AnswerOption } from '../../../models/answer-option'; import { NotificationService } from '../../../services/util/notification.service'; import { ContentType } from '../../../models/content-type.enum'; import { ContentService } from '../../../services/http/content.service'; -import { MAT_DIALOG_DATA, MatDialog, MatDialogRef } from '@angular/material'; -import { ContentListComponent } from '../content-list/content-list.component'; -import { ContentDeleteComponent } from '../_dialogs/content-delete/content-delete.component'; -import { FormControl } from '@angular/forms'; -import { Observable } from 'rxjs'; -import { map, startWith } from 'rxjs/operators'; import { TranslateService } from '@ngx-translate/core'; @Component({ @@ -47,38 +41,18 @@ export class ContentYesNoCreatorComponent implements OnInit { displayAnswers: DisplayAnswer[] = []; newAnswerOptionPoints = 0; - collections: string[] = ['ARSnova', 'Angular', 'HTML', 'TypeScript' ]; - myControl = new FormControl(); - filteredOptions: Observable<string[]>; - lastCollection: string; - - editDialogMode = false; constructor(private contentService: ContentService, private notificationService: NotificationService, - public dialog: MatDialog, - public dialogRef: MatDialogRef<ContentListComponent>, - private translationService: TranslateService, - @Inject(MAT_DIALOG_DATA) public data: any) { + private translationService: TranslateService) { } ngOnInit() { - this.roomId = localStorage.getItem(`roomId`); + this.roomId = localStorage.getItem('roomId'); for (let i = 0; i < this.answerLabels.length; i++) { this.content.options.push(new AnswerOption(this.answerLabels[i], this.newAnswerOptionPoints)); } this.fillCorrectAnswers(); - this.lastCollection = sessionStorage.getItem('collection'); - this.filteredOptions = this.myControl.valueChanges - .pipe( - startWith(''), - map(value => this._filter(value)) - ); - } - - private _filter(value: string): string[] { - const filterValue = value.toLowerCase(); - return this.collections.filter(collection => collection.toLowerCase().includes(filterValue)); } fillCorrectAnswers() { @@ -130,27 +104,4 @@ export class ContentYesNoCreatorComponent implements OnInit { )).subscribe(); this.resetAfterSubmit(); } - - editDialogClose($event, action: string) { - $event.preventDefault(); - this.dialogRef.close(action); - } - - onNoClick(): void { - this.dialogRef.close(); - } - - openDeletionContentDialog($event): void { - $event.preventDefault(); - const dialogRef = this.dialog.open(ContentDeleteComponent, { - width: '400px' - }); - dialogRef.componentInstance.content = this.content; - dialogRef.afterClosed() - .subscribe(result => { - if (result === 'delete') { - this.dialogRef.close(result); - } - }); - } } diff --git a/src/app/components/creator/creator.module.ts b/src/app/components/creator/creator.module.ts index 4430128da1da0af28607c00235cb5f51f94c80dc..dafab2dc5774102d634182533f6dd58b3d629796 100644 --- a/src/app/components/creator/creator.module.ts +++ b/src/app/components/creator/creator.module.ts @@ -1,14 +1,12 @@ import { NgModule } from '@angular/core'; import { CommonModule } from '@angular/common'; import { CreatorRoutingModule } from './creator-routing.module'; -import { AnswersListComponent } from './answers-list/answers-list.component'; import { ContentChoiceCreatorComponent } from './content-choice-creator/content-choice-creator.component'; import { ContentCreatePageComponent } from './content-create-page/content-create-page.component'; import { ContentLikertCreatorComponent } from './content-likert-creator/content-likert-creator.component'; import { ContentTextCreatorComponent } from './content-text-creator/content-text-creator.component'; import { ContentYesNoCreatorComponent } from './content-yes-no-creator/content-yes-no-creator.component'; import { HomeCreatorPageComponent } from './home-creator-page/home-creator-page.component'; -import { MarkdownToolbarComponent } from './markdown-toolbar/markdown-toolbar.component'; import { RoomCreatorPageComponent } from './room-creator-page/room-creator-page.component'; import { EssentialsModule } from '../essentials/essentials.module'; import { RoomCreateComponent } from './_dialogs/room-create/room-create.component'; @@ -22,6 +20,7 @@ import { HttpClient } from '@angular/common/http'; import { TranslateHttpLoader } from '@ngx-translate/http-loader'; import { ContentCreatorComponent } from './content-creator/content-creator.component'; import { ContentListComponent } from './content-list/content-list.component'; +import { ContentEditComponent } from './_dialogs/content-edit/content-edit.component'; @NgModule({ imports: [ @@ -39,20 +38,19 @@ import { ContentListComponent } from './content-list/content-list.component'; }) ], declarations: [ - AnswersListComponent, ContentChoiceCreatorComponent, ContentCreatePageComponent, ContentLikertCreatorComponent, ContentTextCreatorComponent, ContentYesNoCreatorComponent, HomeCreatorPageComponent, - MarkdownToolbarComponent, RoomCreatorPageComponent, RoomCreateComponent, RoomDeleteComponent, RoomEditComponent, ContentCreatorComponent, - ContentListComponent + ContentListComponent, + ContentEditComponent ], entryComponents: [ RoomCreateComponent, @@ -63,8 +61,8 @@ import { ContentListComponent } from './content-list/content-list.component'; ContentChoiceCreatorComponent, ContentLikertCreatorComponent, ContentTextCreatorComponent, - ContentYesNoCreatorComponent - + ContentYesNoCreatorComponent, + ContentEditComponent ] }) export class CreatorModule { diff --git a/src/app/components/creator/markdown-toolbar/markdown-toolbar.component.html b/src/app/components/creator/markdown-toolbar/markdown-toolbar.component.html deleted file mode 100644 index 4877ff50c41f25fba96a51747d68a38627513dd2..0000000000000000000000000000000000000000 --- a/src/app/components/creator/markdown-toolbar/markdown-toolbar.component.html +++ /dev/null @@ -1,6 +0,0 @@ -<div class="markdown-toolbar"> - <button mat-icon-button *ngFor="let button of buttons" (click)="onClick($event, button);" - matTooltip="{{button.label}}"> - <mat-icon attr.aria-label="{{button.label}}">{{button.icon}}</mat-icon> - </button> -</div> diff --git a/src/app/components/creator/markdown-toolbar/markdown-toolbar.component.scss b/src/app/components/creator/markdown-toolbar/markdown-toolbar.component.scss deleted file mode 100644 index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..0000000000000000000000000000000000000000 diff --git a/src/app/components/creator/markdown-toolbar/markdown-toolbar.component.spec.ts b/src/app/components/creator/markdown-toolbar/markdown-toolbar.component.spec.ts deleted file mode 100644 index 34d8a38f8d2c5a2bc87de211188773c2a1aed3af..0000000000000000000000000000000000000000 --- a/src/app/components/creator/markdown-toolbar/markdown-toolbar.component.spec.ts +++ /dev/null @@ -1,25 +0,0 @@ -import { async, ComponentFixture, TestBed } from '@angular/core/testing'; - -import { MarkdownToolbarComponent } from './markdown-toolbar.component'; - -describe('MarkdownToolbarComponent', () => { - let component: MarkdownToolbarComponent; - let fixture: ComponentFixture<MarkdownToolbarComponent>; - - beforeEach(async(() => { - TestBed.configureTestingModule({ - declarations: [ MarkdownToolbarComponent ] - }) - .compileComponents(); - })); - - beforeEach(() => { - fixture = TestBed.createComponent(MarkdownToolbarComponent); - component = fixture.componentInstance; - fixture.detectChanges(); - }); - - it('should create', () => { - expect(component).toBeTruthy(); - }); -}); diff --git a/src/app/components/creator/markdown-toolbar/markdown-toolbar.component.ts b/src/app/components/creator/markdown-toolbar/markdown-toolbar.component.ts deleted file mode 100644 index efd9e98590786044f933d22165fd799576ebf381..0000000000000000000000000000000000000000 --- a/src/app/components/creator/markdown-toolbar/markdown-toolbar.component.ts +++ /dev/null @@ -1,184 +0,0 @@ -import { Component, Input } from '@angular/core'; -import { MarkdownHelpDialogComponent } from '../_dialogs/markdown-help-dialog/markdown-help-dialog.component'; -import { MatDialog } from '@angular/material'; -import { Data, GenericDataDialogComponent } from '../../shared/_dialogs/generic-data-dialog/generic-data-dialog.component'; - -@Component({ - selector: 'app-markdown-toolbar', - templateUrl: './markdown-toolbar.component.html', - styleUrls: ['./markdown-toolbar.component.scss'] -}) -/** - * Component offering markdown action buttons for a textarea. - * Associated via input attribute containing the textarea's HTML id. - */ -export class MarkdownToolbarComponent { - /** - * HTML id associated to the marked up textarea - */ - @Input() textareaId: string; - /** - * Associated textarea - */ - textarea: HTMLTextAreaElement; - - /** - * Button configuration array used for template generation. See {@link Button} for further information. - * @type {Button[]} - */ - buttons: Button[] = [ - new Button('bold', 'Bold', 'format_bold', '**{{TEXT}}**'), - new Button('italic', 'Italic', 'format_italic', '*{{TEXT}}*'), - new Button('title', 'Title', 'title', '## {{TEXT}}'), - new Button('link', 'Link', 'insert_link', '[{{TEXT}}]({{URL}})'), - new Button('ul', 'Unordered list', 'format_list_bulleted', '* {{TEXT}}'), - new Button('ol', 'Ordered list', 'format_list_numbered', '1. {{TEXT}}'), - new Button('code', 'Code', 'code', '`{{TEXT}}`'), - new Button('quote', 'Quote', 'format_quote', '> {{TEXT}}'), - new Button('image', 'Image', 'insert_photo', ''), - new Button('help', 'Help', 'help', '') - ]; - - constructor(public dialog: MatDialog) { } - - /** - * Gets called in template, run action when a button gets pressed - * @param $event - * @param button - */ - onClick($event, button) { - // Get the associated textarea element. See function documentation for further information - this.updateTextarea(); - - // Prevent all default actions (form submission, ..) - $event.preventDefault(); - if (!this.textarea) { - // Cancel the action click in case there is no associated textarea - console.log(`MarkdownToolbar: textarea with id '${this.textareaId}' not found.`); - return; - } - - // Init formatted string with button's format string, placeholders will be replaced later on - let formattedString = button.format; - // Get offset for cursor position (set the cursor to the beginning of the surrounded text) - const cursorPosition = formattedString.indexOf('{{TEXT}}'); - - // Handle different buttons here - switch (button.id) { - case 'help': - // Open help dialog and prevent default action - this.dialog.open(MarkdownHelpDialogComponent); - break; - case 'link': - case 'image': - // Open a configuration dialog - const dialogRef = this.dialog.open(GenericDataDialogComponent, { - data: [ - new Data('TEXT', 'Text', this.getSelectedText()), - new Data('URL', 'URL') - ] - }); - // Wait for dialog to get closed.. - dialogRef.afterClosed().subscribe(result => { - // Cancel if there is no data (dialog got closed without submitting) - if (result === undefined) { - return; - } - // Loop data entries.. - result.forEach(data => { - // Replace placeholder with data provided by the user - formattedString = formattedString.replace(`{{${data.id}}}`, data.value); - }); - // Insert the formatted string and update the cursor position - this.insertTextAtSelection(formattedString, cursorPosition); - }); - break; - default: - // Replace text placeholder with the selected text (keep surrounding tags empty if there was no selection) - formattedString = formattedString.replace('{{TEXT}}', this.getSelectedText()); - // Insert the text associated to the button and update the cursor position - this.insertTextAtSelection(formattedString, cursorPosition); - } - } - - /** - * Get the selected text of the textarea - * @returns {string} - */ - private getSelectedText() { - return this.textarea.value.slice(this.textarea.selectionStart, this.textarea.selectionEnd); - } - - /** - * Insert the passed string at the cursor position (replaces selected text if there is any) and update the cursor's position to start - * of the inserted text respecting the passed selection offset - * @param {string} formattedString - * @param {number} selectionOffset - */ - private insertTextAtSelection(text: string, selectionOffset: number) { - // Get the textarea's text selection positions (no selection when selectionStart == selectionEnd) - const selectionStart = this.textarea.selectionStart; - const selectionEnd = this.textarea.selectionEnd; - // Get textarea's value - const value = this.textarea.value; - - // Insert the action's text at the cursor's position - this.textarea.value = [value.slice(0, selectionStart), text, value.slice(selectionEnd)].join(''); - // Focus the textarea - this.textarea.focus(); - // Calculate the new cursor position (based on the action's text length and the previous cursor position) - const cursorPosition = selectionStart + selectionOffset; - // Set the cursor to the calculated position - this.textarea.setSelectionRange(cursorPosition, cursorPosition); - } - - /** - * Get the textarea by its id in case it isn't already initialized. - * The angular material tab element uses portal hosts to keep the DOM free of inactive tabs which makes it impossible to retrieve the - * element once in the `AfterViewInit`. As this component gets used in the tab element we retrieve the textarea on button clicks as this - * makes sure the associated area is in the DOM too. - * See https://github.com/angular/material2/issues/731 for reference. - */ - private updateTextarea() { - if (!this.textarea) { - this.textarea = document.getElementById(this.textareaId) as HTMLTextAreaElement; - } - } -} - -/** - * Data class for markdown toolbar action buttons - */ -class Button { - /** - * Id used to identify the action for special behaviour - */ - id: string; - /** - * Label shown to the user - */ - label: string; - /** - * Icon key (material icon font) shown to the user - */ - icon: string; - /** - * Format string - */ - format: string; - - /** - * Constructor for creating an instance of {@link Button} - * - * @param {string} id - * @param {string} label - * @param {string} icon - * @param {string} format - */ - constructor(id: string, label: string, icon: string, format: string) { - this.id = id; - this.label = label; - this.icon = icon; - this.format = format; - } -} diff --git a/src/app/components/creator/room-creator-page/room-creator-page.component.html b/src/app/components/creator/room-creator-page/room-creator-page.component.html index 4c0a2c2043ae4a90d4ec9b1cedac6f2c64105f52..747df67543f8cddae2d7741063a5dff44764012a 100644 --- a/src/app/components/creator/room-creator-page/room-creator-page.component.html +++ b/src/app/components/creator/room-creator-page/room-creator-page.component.html @@ -14,7 +14,7 @@ </mat-card-header> <mat-divider></mat-divider> <mat-card-content fxLayoutAlign="center"> - <mat-expansion-panel *ngIf="!room.description == ''" class="mat-elevation-z0"> + <mat-expansion-panel *ngIf="!(room.description == '')" class="mat-elevation-z0"> <mat-expansion-panel-header> <h4>{{ 'room-page.description' | translate }}</h4> </mat-expansion-panel-header> @@ -37,7 +37,7 @@ </button> </mat-grid-tile> <mat-grid-tile> - <button mat-icon-button *ngIf="!modify" (click)="showEditDialog()" color="accent" + <button mat-icon-button *ngIf="!modify" (click)="showEditDialog()" color="accent" matTooltip="{{ 'room-page.edit-room' | translate}}"> <mat-icon>create</mat-icon> </button> diff --git a/src/app/components/essentials/essentials.module.ts b/src/app/components/essentials/essentials.module.ts index e02a0733dbfea7da68502a38a8997829edb8fa0c..58e4e28f3780cbaa9976106aa0e017a59ca6cf24 100644 --- a/src/app/components/essentials/essentials.module.ts +++ b/src/app/components/essentials/essentials.module.ts @@ -2,7 +2,6 @@ import { NgModule } from '@angular/core'; import { FlexLayoutModule } from '@angular/flex-layout'; import { FormsModule, ReactiveFormsModule } from '@angular/forms'; import { HttpClient, HttpClientModule } from '@angular/common/http'; -import { MarkdownModule } from 'ngx-markdown'; import { MatAutocompleteModule, MatBadgeModule, @@ -86,7 +85,6 @@ import { TranslateHttpLoader } from '@ngx-translate/http-loader'; FlexLayoutModule, FormsModule, HttpClientModule, - MarkdownModule, ReactiveFormsModule ], declarations: [] diff --git a/src/app/components/participant/content-text-participant/content-text-participant.component.html b/src/app/components/participant/content-text-participant/content-text-participant.component.html index 6818fc065bb92bbe1118abb8d743f7755aed6923..33f79b4cd3df91813ee2dac0b5b3f3b1290d8930 100644 --- a/src/app/components/participant/content-text-participant/content-text-participant.component.html +++ b/src/app/components/participant/content-text-participant/content-text-participant.component.html @@ -1,6 +1,5 @@ <form (ngSubmit)="submitAnswer()"> <h1 class="mat-headline">{{ content.subject }}</h1> - <markdown [data]="content.body"></markdown> <mat-divider></mat-divider> <mat-form-field class="input-block"> <textarea matInput [(ngModel)]="textAnswer" name="answer" #answer placeholder="{{ 'answer.your-answer' | translate }}"></textarea> diff --git a/src/app/components/participant/room-participant-page/room-participant-page.component.html b/src/app/components/participant/room-participant-page/room-participant-page.component.html index 2e5954b49e506691ea5056613610fb59f4008145..3309d1ee2aa7906d972f7206a3e106671e543766 100644 --- a/src/app/components/participant/room-participant-page/room-participant-page.component.html +++ b/src/app/components/participant/room-participant-page/room-participant-page.component.html @@ -12,7 +12,7 @@ </mat-card-header> <mat-divider></mat-divider> <mat-card-content fxLayoutAlign="center"> - <mat-expansion-panel *ngIf="!room.description == ''" class="mat-elevation-z0"> + <mat-expansion-panel *ngIf="!(room.description == '')" class="mat-elevation-z0"> <mat-expansion-panel-header> <h4>{{ 'room-page.description' | translate }}</h4> </mat-expansion-panel-header> diff --git a/src/app/components/participant/room-participant-page/room-participant-page.component.scss b/src/app/components/participant/room-participant-page/room-participant-page.component.scss index 9eb82ffda173a04e4bb5d890a7f16d54360c9b86..f8e2b2f3c998cfe38c9e4e08a59638dec4435cd7 100644 --- a/src/app/components/participant/room-participant-page/room-participant-page.component.scss +++ b/src/app/components/participant/room-participant-page/room-participant-page.component.scss @@ -25,6 +25,9 @@ mat-icon{ button { width: 30%; + &:hover { + transform: scale(1.25) + } } p { @@ -63,7 +66,7 @@ mat-expansion-panel { } mat-grid-list { - margin-bottom: 10px !important; + margin-bottom: 20px !important; } mat-tooltip-component { diff --git a/src/app/components/shared/_dialogs/footer-login-dialog/footer-login-dialog.component.html b/src/app/components/shared/_dialogs/footer-login-dialog/footer-login-dialog.component.html deleted file mode 100644 index 045bdd3d15b2d007c63c3b52c8f57cf5ceedbc8e..0000000000000000000000000000000000000000 --- a/src/app/components/shared/_dialogs/footer-login-dialog/footer-login-dialog.component.html +++ /dev/null @@ -1,8 +0,0 @@ -<h3 mat-header>Login as Guest</h3> -<p mat-line>Do you really want to leave the current page and login as a guest?</p> -<p mat-line>You'll be logged out if you are currently logged in</p> - -<mat-action-row> - <button mat-button (click)="dialogRef.close('login')">Login</button> - <button mat-button (click)="onNoClick()">Cancel</button> -</mat-action-row> \ No newline at end of file diff --git a/src/app/components/shared/_dialogs/footer-login-dialog/footer-login-dialog.component.scss b/src/app/components/shared/_dialogs/footer-login-dialog/footer-login-dialog.component.scss deleted file mode 100644 index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..0000000000000000000000000000000000000000 diff --git a/src/app/components/shared/_dialogs/footer-login-dialog/footer-login-dialog.component.spec.ts b/src/app/components/shared/_dialogs/footer-login-dialog/footer-login-dialog.component.spec.ts deleted file mode 100644 index dcb44e78bfb42fc82105489a6ff88778d8f7d8a0..0000000000000000000000000000000000000000 --- a/src/app/components/shared/_dialogs/footer-login-dialog/footer-login-dialog.component.spec.ts +++ /dev/null @@ -1,25 +0,0 @@ -import { async, ComponentFixture, TestBed } from '@angular/core/testing'; - -import { FooterLoginDialogComponent } from './footer-login-dialog.component'; - -describe('FooterLoginDialogComponent', () => { - let component: FooterLoginDialogComponent; - let fixture: ComponentFixture<FooterLoginDialogComponent>; - - beforeEach(async(() => { - TestBed.configureTestingModule({ - declarations: [ FooterLoginDialogComponent ] - }) - .compileComponents(); - })); - - beforeEach(() => { - fixture = TestBed.createComponent(FooterLoginDialogComponent); - component = fixture.componentInstance; - fixture.detectChanges(); - }); - - it('should create', () => { - expect(component).toBeTruthy(); - }); -}); diff --git a/src/app/components/shared/_dialogs/footer-login-dialog/footer-login-dialog.component.ts b/src/app/components/shared/_dialogs/footer-login-dialog/footer-login-dialog.component.ts deleted file mode 100644 index 1cdcd9887f7d41a57d609bdd1f262f81e546219d..0000000000000000000000000000000000000000 --- a/src/app/components/shared/_dialogs/footer-login-dialog/footer-login-dialog.component.ts +++ /dev/null @@ -1,23 +0,0 @@ -import { Component, OnInit, Inject } from '@angular/core'; -import { FooterComponent } from '../../footer/footer.component'; -import { MatDialogRef, MAT_DIALOG_DATA } from '@angular/material'; - -@Component({ - selector: 'app-footer-login-dialog', - templateUrl: './footer-login-dialog.component.html', - styleUrls: ['./footer-login-dialog.component.scss'] -}) -export class FooterLoginDialogComponent implements OnInit { - - constructor( - public dialogRef: MatDialogRef<FooterComponent>, - @Inject(MAT_DIALOG_DATA) public data: any - ) { } - - onNoClick(): void { - this.dialogRef.close(); - } - - ngOnInit() { - } -} diff --git a/src/app/components/shared/_dialogs/generic-data-dialog/generic-data-dialog.component.html b/src/app/components/shared/_dialogs/generic-data-dialog/generic-data-dialog.component.html deleted file mode 100644 index d3266006431a4366608e956eb50606db9151c123..0000000000000000000000000000000000000000 --- a/src/app/components/shared/_dialogs/generic-data-dialog/generic-data-dialog.component.html +++ /dev/null @@ -1,7 +0,0 @@ -<form (ngSubmit)="submit()"> - <mat-form-field class="input-block" *ngFor="let input of data"> - <input matInput name="{{input.id}}" [(ngModel)]="input.value" placeholder="{{input.label}}" /> - </mat-form-field> - - <button mat-raised-button color="primary" type="submit">Submit</button> -</form> diff --git a/src/app/components/shared/_dialogs/generic-data-dialog/generic-data-dialog.component.scss b/src/app/components/shared/_dialogs/generic-data-dialog/generic-data-dialog.component.scss deleted file mode 100644 index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..0000000000000000000000000000000000000000 diff --git a/src/app/components/shared/_dialogs/generic-data-dialog/generic-data-dialog.component.spec.ts b/src/app/components/shared/_dialogs/generic-data-dialog/generic-data-dialog.component.spec.ts deleted file mode 100644 index 0b36dd0c611be58f8eb83968436765f8cc93d736..0000000000000000000000000000000000000000 --- a/src/app/components/shared/_dialogs/generic-data-dialog/generic-data-dialog.component.spec.ts +++ /dev/null @@ -1,25 +0,0 @@ -import { async, ComponentFixture, TestBed } from '@angular/core/testing'; - -import { GenericDataDialogComponent } from './generic-data-dialog.component'; - -describe('GenericDataDialogComponent', () => { - let component: GenericDataDialogComponent; - let fixture: ComponentFixture<GenericDataDialogComponent>; - - beforeEach(async(() => { - TestBed.configureTestingModule({ - declarations: [ GenericDataDialogComponent ] - }) - .compileComponents(); - })); - - beforeEach(() => { - fixture = TestBed.createComponent(GenericDataDialogComponent); - component = fixture.componentInstance; - fixture.detectChanges(); - }); - - it('should create', () => { - expect(component).toBeTruthy(); - }); -}); diff --git a/src/app/components/shared/_dialogs/generic-data-dialog/generic-data-dialog.component.ts b/src/app/components/shared/_dialogs/generic-data-dialog/generic-data-dialog.component.ts deleted file mode 100644 index f802d1c9b8cb5069c0121060090516a3d6d106d4..0000000000000000000000000000000000000000 --- a/src/app/components/shared/_dialogs/generic-data-dialog/generic-data-dialog.component.ts +++ /dev/null @@ -1,30 +0,0 @@ -import { Component, Inject } from '@angular/core'; -import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material'; - -@Component({ - selector: 'app-generic-data-dialog', - templateUrl: './generic-data-dialog.component.html', - styleUrls: ['./generic-data-dialog.component.scss'] -}) -export class GenericDataDialogComponent { - - constructor(public dialogRef: MatDialogRef<GenericDataDialogComponent>, - @Inject(MAT_DIALOG_DATA) public data: Data[]) { - } - - submit(): void { - this.dialogRef.close(this.data); - } -} - -export class Data { - id: string; - label: string; - value: string; - - constructor(id: string, label: string, value?: string) { - this.id = id; - this.label = label; - this.value = value; - } -} diff --git a/src/app/components/shared/footer/footer.component.ts b/src/app/components/shared/footer/footer.component.ts index e924a94adacbf170050219150ee22f694b878589..c2f0e8fe166251a6ef103330f9f6678fc9da1b06 100644 --- a/src/app/components/shared/footer/footer.component.ts +++ b/src/app/components/shared/footer/footer.component.ts @@ -1,9 +1,8 @@ -import { Component, OnInit, Input } from '@angular/core'; +import { Component, OnInit } from '@angular/core'; import { AuthenticationService } from '../../../services/http/authentication.service'; import { NotificationService } from '../../../services/util/notification.service'; import { Router } from '@angular/router'; import { MatDialog } from '@angular/material'; -import { FooterLoginDialogComponent } from '../_dialogs/footer-login-dialog/footer-login-dialog.component'; @Component({ selector: 'app-footer', diff --git a/src/app/components/shared/room-list/room-list.component.html b/src/app/components/shared/room-list/room-list.component.html index 67e04af7a21d246df0daf047ace1d8d9d1e0af11..077c7bc8bb8118cc6921edf75e3d0df01792c15b 100644 --- a/src/app/components/shared/room-list/room-list.component.html +++ b/src/app/components/shared/room-list/room-list.component.html @@ -4,10 +4,8 @@ <mat-panel-description>Session-Id</mat-panel-description> </mat-expansion-panel-header> </mat-expansion-panel> -<mat-divider></mat-divider> -<mat-divider></mat-divider> <mat-expansion-panel *ngFor="let room of rooms" class="matPanel"> - <mat-expansion-panel-header> + <mat-expansion-panel-header class="matPanelListHeader"> <button mat-button color="primary" routerLink="/{{ baseUrl }}/room/{{ room.shortId }}"> <mat-icon>input</mat-icon> </button> @@ -22,3 +20,8 @@ {{ room.description }} </p> </mat-expansion-panel> +<mat-card *ngIf="rooms.length === 0"> + <mat-card-header> + <mat-card-title>Sie haben noch keine Sessions erstellt!</mat-card-title> + </mat-card-header> +</mat-card> diff --git a/src/app/components/shared/room-list/room-list.component.scss b/src/app/components/shared/room-list/room-list.component.scss index e7796dfcc4ac3c66bf55ca929e14719c50bdbf54..a269ce031e7103581728d800bf1c3eee57b7cedd 100644 --- a/src/app/components/shared/room-list/room-list.component.scss +++ b/src/app/components/shared/room-list/room-list.component.scss @@ -9,10 +9,16 @@ button { .matPanel { background-color: #cfd8dc; + margin-bottom: 5px; } .matPanelHeader { background-color: #bbdefb; + margin-bottom: 5px; +} + +.matPanelListHeader { + background-color: #cfd8dc !important; } mat-panel-title { @@ -24,3 +30,12 @@ mat-panel-title { .headerTitle { width: 8%!important; } + +mat-card-title { + text-align: center; +} + +mat-card { + background-color: #cfd8dc; + color: #4db6ac; +} diff --git a/src/app/components/shared/shared.module.ts b/src/app/components/shared/shared.module.ts index d2522ea76cb079519da4b9d2e2c15630fd2f2c01..2fb1fe98c33730a62bb658be69c7993a893c62b8 100644 --- a/src/app/components/shared/shared.module.ts +++ b/src/app/components/shared/shared.module.ts @@ -13,8 +13,6 @@ import { RoomPageComponent } from './room-page/room-page.component'; import { StatisticsPageComponent } from './statistics-page/statistics-page.component'; import { AnswerEditComponent } from '../creator/_dialogs/answer-edit/answer-edit.component'; import { ContentDeleteComponent } from '../creator/_dialogs/content-delete/content-delete.component'; -import { MarkdownHelpDialogComponent } from '../creator/_dialogs/markdown-help-dialog/markdown-help-dialog.component'; -import { GenericDataDialogComponent } from './_dialogs/generic-data-dialog/generic-data-dialog.component'; import { CommentCreatePageComponent } from '../participant/comment-create-page/comment-create-page.component'; import { EssentialsModule } from '../essentials/essentials.module'; import { SharedRoutingModule } from './shared-routing.module'; @@ -39,8 +37,6 @@ import { StatisticComponent } from './statistic/statistic.component'; AnswerEditComponent, ContentDeleteComponent, FeedbackBarometerPageComponent, - MarkdownHelpDialogComponent, - GenericDataDialogComponent, FooterComponent, FooterImprintComponent, FeedbackBarometerPageComponent, @@ -60,18 +56,12 @@ import { StatisticComponent } from './statistic/statistic.component'; AnswerEditComponent, ContentDeleteComponent, FeedbackBarometerPageComponent, - MarkdownHelpDialogComponent, - GenericDataDialogComponent, FooterComponent, FooterImprintComponent, FeedbackBarometerPageComponent, CommentCreatePageComponent, CommentListComponent, StatisticsPageComponent - ], - entryComponents: [ - MarkdownHelpDialogComponent, - GenericDataDialogComponent ] }) export class SharedModule { diff --git a/src/app/services/http/content.service.ts b/src/app/services/http/content.service.ts index 04f53433dd08456cc50f2c6612dfd78288878db3..a917c39bbfda89347d31a738c6b7220f0071ec74 100644 --- a/src/app/services/http/content.service.ts +++ b/src/app/services/http/content.service.ts @@ -75,6 +75,14 @@ export class ContentService extends BaseHttpService { ); } + updateChoiceContent(updatedContent: ContentChoice): Observable<ContentChoice> { + const connectionUrl = this.apiUrl.base + this.apiUrl.content + '/' + updatedContent.id; + return this.http.put(connectionUrl, updatedContent, httpOptions).pipe( + tap(_ => ''), + catchError(this.handleError<any>('updateContentChoice')) + ); + } + deleteContent(contentId: string): Observable<Content> { const connectionUrl = this.apiUrl.base + this.apiUrl.content + '/' + contentId; return this.http.delete<Content>(connectionUrl, httpOptions).pipe( diff --git a/src/assets/i18n/creator/de.json b/src/assets/i18n/creator/de.json index e012bd2cd0d020f88e30835b14e3f012ecc623a8..02f3c070b2eb0677e16da7f6dfdcf6a8355c56d7 100644 --- a/src/assets/i18n/creator/de.json +++ b/src/assets/i18n/creator/de.json @@ -14,12 +14,14 @@ "edit-room": "Session bearbeiten", "delete-room": "Session löschen", "sure": "Sind Sie sicher?", - "really": "Wollen Sie die Session ", + "reallySession": "Wollen Sie die Session ", + "reallyContent": "Wollen Sie die Frage ", "really2": " wirklich löschen? Diese Aktion kann nicht rückgängig gemacht werden.", "abort": "Abbrechen", "update": "Update", "default-content-group": "Standard", - "description": "Beschreibung" + "description": "Beschreibung", + "present": "Präsentieren" }, "content": { "content": "Frage", @@ -31,10 +33,10 @@ "no": "Nein", "add-answer": "Antwort hinzufügen", "answer": "Antwort", + "answers": "Antworten", "actions": "Optionen", "reset": "Zurücksetzen", "contents": "Fragen", - "click-here": "Klicken Sie auf einen Inhalt, um diesen zu editieren", "submitted": "Frage erstellt. Bereit für die Erstellung neuer Fragen.", "no-empty": "Keine leeren Felder erlaubt. Bitte überprüfen sie Thema und Inhalt.", "no-empty2": "Keine leeren Felder erlaubt.", @@ -45,11 +47,17 @@ "answer-recovered": "Antwort wiederhergestellt.", "only-one-true": "Im Single-Modus ist nur eine richtige Antwort erlaubt.", "reset-all": "Alle Eingaben wurden zurückgesetzt.", - "need-answers": "Auswahlfragen brauchen Antworten. Bitte fügen Sie Antworten hinzu", + "need-answers": "Auswahlfragen brauchen Antworten. Bitte fügen Sie Antworten hinzu.", "select-one": "Im Single-Choice-Modus muss es eine richtige Antwort geben.", "at-least-one": "Im Multiple-Choice-Modus muss es mindestens eine richtige Antwort geben.", "undo": "Rückgängig", - "points": "Punkte" + "points": "Punkte", + "delete": "Löschen", + "abort": "Abbrechen", + "delete-answer": "Antwort löschen", + "edit-answer": "Antwort bearteiten", + "content-deleted": "Frage wurde gelöscht.", + "content-updated": "Frage wurde aktualisiert." }, "session": { "session-name": "Name der Session", diff --git a/src/assets/i18n/creator/en.json b/src/assets/i18n/creator/en.json index 54f7cf4bef755bc138e20cb4e5d5ff0a9f0905eb..9850dd2313ba06d4381d953339fef6c188b0fd3c 100644 --- a/src/assets/i18n/creator/en.json +++ b/src/assets/i18n/creator/en.json @@ -13,12 +13,14 @@ "edit-room": "Edit session", "delete-room": "Delete session", "sure": "Are you sure?", - "really": "Do you really want to delete session ", + "reallySession": "Do you really want to delete session ", + "reallyContent": "Do you really want to delete content ", "really2": "? This action can not be undone.", "abort": "Abort", "update": "Update", "default-content-group": "Default", - "description": "Description" + "description": "Description", + "present": "Present" }, "content": { "content": "Content", @@ -30,10 +32,10 @@ "no": "No", "add-answer": "Add answer", "answer": "Answer", + "answers": "Answers", "actions": "Options", "reset": "Reset", "contents": "Contents", - "click-here": "Click on a content to edit it", "submitted": "Content submitted. Ready for creation of new content.", "no-empty": "No empty fields allowed. Please check subject and body.", "no-empty2": "No empty filed allowed.", @@ -48,7 +50,13 @@ "select-one": "In single choice mode you have to select 1 true answer.", "at-least-one": "In multiple choice mode you have to select at least 1 true answer.", "undo": "Undo", - "points": "Points" + "points": "Points", + "delete": "Delete", + "abort": "Abort", + "delete-answer": "Delete answer", + "edit-answer": "Edit answer", + "content-deleted": "Content has been deleted.", + "content-updated": "Content has been updated." }, "session": { "session-name": "Session name", diff --git a/src/theme/_form.scss b/src/theme/_form.scss index 76bd96f8260756d46c661832127c529315922189..1931e193aeab49db2022eba63f3c50a7f08157b7 100644 --- a/src/theme/_form.scss +++ b/src/theme/_form.scss @@ -1,3 +1,7 @@ mat-form-field.input-block { display: block; } + +mat-dialog-container { + background-color: #bbdefb !important; +}