diff --git a/src/app/components/creator/_dialogs/bonus-token/bonus-token.component.html b/src/app/components/creator/_dialogs/bonus-token/bonus-token.component.html index 0bf87b73ce8ab524580ed75266029ba3ea56fd35..93941b81e6d9602bba6db35352c996fe0a01c722 100644 --- a/src/app/components/creator/_dialogs/bonus-token/bonus-token.component.html +++ b/src/app/components/creator/_dialogs/bonus-token/bonus-token.component.html @@ -1,9 +1,18 @@ <div mat-dialog-content> <h1>{{'room-page.bonus-token-header' | translate }}</h1> <mat-divider></mat-divider> - <div fxLayout="row" *ngFor="let bonusToken of bonusTokens"> - <h2> - {{bonusToken.token}} - </h2> + <div *ngIf="bonusTokens.length >= 1"> + <div fxLayout="row" *ngFor="let bonusToken of bonusTokens"> + <h2> + {{bonusToken.token}} + </h2> + </div> </div> + <div *ngIf="bonusTokens.length === 0"> + <h3>{{'room-page.no-bonus' | translate }}</h3> + </div> + <app-dialog-action-buttons + buttonsLabelSection="content" + [cancelButtonClickAction]="buildDeclineActionCallback()"> + </app-dialog-action-buttons> </div> diff --git a/src/app/components/creator/_dialogs/bonus-token/bonus-token.component.ts b/src/app/components/creator/_dialogs/bonus-token/bonus-token.component.ts index f270f68dcdd1d977265ab74a954be4eae6f1c59d..1b2f03e2de195bce11cfa8371eeff9f0d8a23725 100644 --- a/src/app/components/creator/_dialogs/bonus-token/bonus-token.component.ts +++ b/src/app/components/creator/_dialogs/bonus-token/bonus-token.component.ts @@ -1,6 +1,7 @@ import { Component, OnInit } from '@angular/core'; import { BonusTokenService } from '../../../../services/http/bonus-token.service'; import { BonusToken } from '../../../../models/bonus-token'; +import { MatDialogRef } from '@angular/material'; @Component({ selector: 'app-bonus-token', @@ -11,10 +12,8 @@ export class BonusTokenComponent implements OnInit { roomId: string; bonusTokens: BonusToken[] = []; - constructor( - private bonusTokenService: BonusTokenService - ) { - + constructor(private bonusTokenService: BonusTokenService, + private dialogRef: MatDialogRef<BonusTokenComponent>) { } ngOnInit() { @@ -22,4 +21,11 @@ export class BonusTokenComponent implements OnInit { this.bonusTokens = list; }); } + + /** + * Returns a lambda which closes the dialog on call. + */ + buildDeclineActionCallback(): () => void { + return () => this.dialogRef.close(); + } } diff --git a/src/app/components/creator/_dialogs/comment-settings/comment-settings.component.ts b/src/app/components/creator/_dialogs/comment-settings/comment-settings.component.ts index 34539d348915001ecc452c509f61de6396f45026..9aa54b10971c14e67fa1ab661f807324cb3b38be 100644 --- a/src/app/components/creator/_dialogs/comment-settings/comment-settings.component.ts +++ b/src/app/components/creator/_dialogs/comment-settings/comment-settings.component.ts @@ -100,7 +100,7 @@ export class CommentSettingsComponent implements OnInit { this.comments = comments.map(comment => { const commentWithToken: CommentBonusTokenMixin = <CommentBonusTokenMixin>comment; for (const bt of list) { - if (commentWithToken.creatorId === bt.userId) { + if (commentWithToken.creatorId === bt.userId && comment.favorite) { commentWithToken.bonusToken = bt.token; } } @@ -109,32 +109,31 @@ export class CommentSettingsComponent implements OnInit { const exportComments = JSON.parse(JSON.stringify(this.comments)); let csv: string; let valueFields = ''; - const keyFields = [ - 'Frage', - 'Zeitstempel', - 'Präsentiert', - 'Favorit', - 'Richtig/Falsch', - 'Zugestellt', - 'Score', - 'Bonus Token', - '\r\n' - ]; - exportComments.forEach(element => { - element.body = '"' + element.body.replace(/[\r\n]/g, ' ').replace(/ +/g, ' ').replace(/"/g, '""') + '"'; - valueFields += Object.values(element).slice(3, 4) + delimiter; - let time; - time = Object.values(element).slice(4, 5); - valueFields += time[0].slice(0, 10) + '-' + time[0].slice(11, 16) + delimiter; - valueFields += Object.values(element).slice(5, 10).join(delimiter) + '\r\n'; + const fieldNames = ['room-page.question', 'room-page.timestamp', 'room-page.presented', + 'room-page.favorite', 'room-page.correct/wrong', 'room-page.score', 'room-page.token']; + let keyFields; + this.translationService.get(fieldNames).subscribe(msgs => { + keyFields = [msgs[fieldNames[0]], msgs[fieldNames[1]], msgs[fieldNames[2]], msgs[fieldNames[3]], + msgs[fieldNames[4]], msgs[fieldNames[5]], msgs[fieldNames[6]], '\r\n']; + + exportComments.forEach(element => { + console.log(Object.values(element)); + element.body = '"' + element.body.replace(/[\r\n]/g, ' ').replace(/ +/g, ' ').replace(/"/g, '""') + '"'; + valueFields += Object.values(element).slice(3, 4) + delimiter; + let time; + time = Object.values(element).slice(4, 5); + valueFields += time[0].slice(0, 10) + '-' + time[0].slice(11, 16) + delimiter; + valueFields += Object.values(element).slice(5, 8) + delimiter; + valueFields += Object.values(element).slice(9, 11).join(delimiter) + '\r\n'; + }); + csv = keyFields + valueFields; + const myBlob = new Blob([csv], { type: 'text/csv' }); + const link = document.createElement('a'); + const fileName = 'comments_' + date + '.csv'; + link.setAttribute('download', fileName); + link.href = window.URL.createObjectURL(myBlob); + link.click(); }); - csv = keyFields + valueFields; - const myBlob = new Blob([csv], { type: 'text/csv' }); - const link = document.createElement('a'); - const fileName = 'comments_' + date + '.csv'; - link.setAttribute('download', fileName); - link.href = window.URL.createObjectURL(myBlob); - link.click(); }); }); } diff --git a/src/app/components/shared/_dialogs/user-bonus-token/user-bonus-token.component.html b/src/app/components/shared/_dialogs/user-bonus-token/user-bonus-token.component.html index 6584f5b1de946ac9e3748e70b4b665a5211d10bf..8a2f81a7ac39e602a18b2e691ccf90d2202fc33c 100644 --- a/src/app/components/shared/_dialogs/user-bonus-token/user-bonus-token.component.html +++ b/src/app/components/shared/_dialogs/user-bonus-token/user-bonus-token.component.html @@ -1,9 +1,18 @@ <div mat-dialog-content> - <h1>{{'user-bonus-token-dialog.header' | translate }}</h1> + <h1>{{'header.bonus-token' | translate }}</h1> <mat-divider></mat-divider> - <div fxLayout="row" *ngFor="let bonusToken of bonusTokens"> - <h2> - {{bonusToken.token}} - </h2> + <div *ngIf="bonusTokens.length >= 1"> + <div fxLayout="row" *ngFor="let bonusToken of bonusTokens"> + <h2> + {{bonusToken.token}} + </h2> + </div> </div> + <div *ngIf="bonusTokens.length === 0"> + <h3>{{'header.no-bonus' | translate }}</h3> + </div> + <app-dialog-action-buttons + buttonsLabelSection="introduction" + [cancelButtonClickAction]="buildDeclineActionCallback()"> + </app-dialog-action-buttons> </div> diff --git a/src/app/components/shared/_dialogs/user-bonus-token/user-bonus-token.component.ts b/src/app/components/shared/_dialogs/user-bonus-token/user-bonus-token.component.ts index e9cab7ee728e1424e830fb68aa58f49d3133843e..42c2274c5809d919651717e2260a70860420ee35 100644 --- a/src/app/components/shared/_dialogs/user-bonus-token/user-bonus-token.component.ts +++ b/src/app/components/shared/_dialogs/user-bonus-token/user-bonus-token.component.ts @@ -1,6 +1,7 @@ import { Component, OnInit } from '@angular/core'; import { BonusTokenService } from '../../../../services/http/bonus-token.service'; import { BonusToken } from '../../../../models/bonus-token'; +import { MatDialogRef } from '@angular/material'; @Component({ selector: 'app-user-bonus-token', @@ -11,10 +12,8 @@ export class UserBonusTokenComponent implements OnInit { userId: string; bonusTokens: BonusToken[] = []; - constructor( - private bonusTokenService: BonusTokenService - ) { - + constructor(private bonusTokenService: BonusTokenService, + private dialogRef: MatDialogRef<UserBonusTokenComponent>) { } ngOnInit() { @@ -22,4 +21,11 @@ export class UserBonusTokenComponent implements OnInit { this.bonusTokens = list; }); } + + /** + * Returns a lambda which closes the dialog on call. + */ + buildDeclineActionCallback(): () => void { + return () => this.dialogRef.close(); + } } diff --git a/src/app/components/shared/shared.module.ts b/src/app/components/shared/shared.module.ts index b35a47dba07aca62db06b77f0385f6637b7bf0fa..63a03ad8d45ced9e617aff904f6becb373a7cc03 100644 --- a/src/app/components/shared/shared.module.ts +++ b/src/app/components/shared/shared.module.ts @@ -82,7 +82,8 @@ import { MatRippleModule } from '@angular/material'; CreateCommentComponent, PresentCommentComponent, CommentComponent, - DialogActionButtonsComponent + DialogActionButtonsComponent, + UserBonusTokenComponent ], entryComponents: [ RoomCreateComponent, diff --git a/src/assets/i18n/creator/de.json b/src/assets/i18n/creator/de.json index c166a823f0be3f8fc1e4a256c38c331a326a57b2..20ad4e57bed873c7b506ced9d83589d62a7b8bdc 100644 --- a/src/assets/i18n/creator/de.json +++ b/src/assets/i18n/creator/de.json @@ -163,6 +163,7 @@ "answer-statistics": "Statistiken", "bonus-token": "Tokens für Bonuspunkte", "bonus-token-header": "Tokens für Bonuspunkte", + "no-bonus": "Es wurden noch keine Bonuspunkte vergeben.", "cancel": "Abbrechen", "cancel-description": "Abbrechen", "changes-successful": "Änderungen gespeichert.", @@ -210,7 +211,8 @@ "presented": "Präsentiert", "correct/wrong": "Richtig/Falsch", "score": "Score", - "timestamp": "Zeitstempel" + "timestamp": "Zeitstempel", + "token": "Bonus-Token" }, "session": { "a11y-description": "Gib eine Beschreibung für die Sitzung ein.", diff --git a/src/assets/i18n/creator/en.json b/src/assets/i18n/creator/en.json index 19cc925a3c67616b8f38e90196822586652bebea..224fa8184a276cc2360a5999cf8f5692c5609555 100644 --- a/src/assets/i18n/creator/en.json +++ b/src/assets/i18n/creator/en.json @@ -164,6 +164,7 @@ "answer-statistics": "Statistics", "bonus-token": "Tokens for bonus points", "bonus-token-header": "Tokens for bonus points", + "no-bonus": "No bonus points have been given yet.", "cancel": "Cancel", "cancel-description": "Cancel", "changes-successful": "Successfully updated.", @@ -211,7 +212,8 @@ "presented": "Presented", "correct/wrong": "Correct/Wrong", "score": "Score", - "timestamp": "Timestamp" + "timestamp": "Timestamp", + "token": "Bonus token" }, "session": { "a11y-description": "Enter a description for the session", diff --git a/src/assets/i18n/home/de.json b/src/assets/i18n/home/de.json index 4fe7a1d4bcb84ac317e525236275346ab5cf6f5c..d31f78611bddff521311a5dbb98c45b4838b5bd0 100644 --- a/src/assets/i18n/home/de.json +++ b/src/assets/i18n/home/de.json @@ -60,7 +60,9 @@ "really-delete-account": "Willst du dein Konto mit allen Sitzungen unwiderruflich löschen?", "sure": "Bist du sicher?", "user-bonus-token": "Zu deinen Bonus Tokens", - "visited-sessions": "Besuchte Sitzungen" + "visited-sessions": "Besuchte Sitzungen", + "bonus-token": "Tokens für Bonuspunkte", + "no-bonus": "Noch keine Bonuspunkte erhalten." }, "help": { "cancel": "Schließen", diff --git a/src/assets/i18n/home/en.json b/src/assets/i18n/home/en.json index 7c38513ef3b39a493e481bebfb847865b9779fcb..db38548be01a0937cf4cd837fc5b3fb7495341b8 100644 --- a/src/assets/i18n/home/en.json +++ b/src/assets/i18n/home/en.json @@ -61,7 +61,9 @@ "really-delete-account": "Do you really want to irrevocably delete your account with the associated sessions?", "sure": "Are you sure?", "user-bonus-token": "See your bonus tokens", - "visited-sessions": "Visited sessions" + "visited-sessions": "Visited sessions", + "bonus-token": "Tokens for bonus points", + "no-bonus": "No bonus points earned yet." }, "help": { "cancel": "Close", @@ -71,7 +73,6 @@ "home-page": { "accessibility-create": "Create a new session", "accessibility-join-button": "Enter the session with the specified session key.", - "accessibility-join-input": "Here you can enter the session key of the session you want to join.", "create-session": "New session", "created-1": "Session '", "created-2": "' successfully created", diff --git a/src/assets/i18n/participant/de.json b/src/assets/i18n/participant/de.json index b94578f761cd9698e4397678739bd3649b648154..0846e41c12f4c565c3793f8db55937e8210b354b 100644 --- a/src/assets/i18n/participant/de.json +++ b/src/assets/i18n/participant/de.json @@ -107,7 +107,9 @@ "learn": "Lernen", "live-announcer": "Du befindest dich jetzt in der Sitzung. Um Informationen zu Tastenkombinationen zu erhalten drücke jetzt die Enter-Taste oder rufe die Ansage zu einem späteren Zeitpunkt mit der Escape-Taste auf.", "live-feedback": "Live Feedback", - "session-id": "Code" + "session-id": "Code", + "bonus-token": "Tokens für Bonuspunkte", + "bonus-token-header": "Tokens für Bonuspunkte" }, "statistic": { "abstentions": "Enthaltungen", diff --git a/src/assets/i18n/participant/en.json b/src/assets/i18n/participant/en.json index cd14fcfe3172c88dd8d2582e313caefb8bd9ab4d..7a82927e82929e64b4c08dfdb8d97b74f79e4459 100644 --- a/src/assets/i18n/participant/en.json +++ b/src/assets/i18n/participant/en.json @@ -106,7 +106,9 @@ "learn": "Learn", "live-announcer": "You're in the session now. To get information about key combinations press the Enter key or call the announcement later with the Escape key.", "live-feedback": "Live feedback", - "session-id": "Key" + "session-id": "Key", + "bonus-token": "Tokens for bonus points", + "bonus-token-header": "Tokens for bonus points" }, "statistic": { "abstentions": "Abstentions",