From 5505d1edee57ce5a88fe157dd8f17f5c7ead299e Mon Sep 17 00:00:00 2001
From: rhenck <richard.henck@iqb.hu-berlin.de>
Date: Mon, 21 Oct 2024 17:14:36 +0200
Subject: [PATCH] [editor] Add another text to audio template

This is meant for source of the audio.
---
 .../dialogs/wizards/audio.dialog.component.ts | 10 ++++++++++
 .../src/app/services/template.service.ts      | 20 +++++++++++++++----
 2 files changed, 26 insertions(+), 4 deletions(-)

diff --git a/projects/editor/src/app/components/dialogs/wizards/audio.dialog.component.ts b/projects/editor/src/app/components/dialogs/wizards/audio.dialog.component.ts
index 1eccded25..933024646 100644
--- a/projects/editor/src/app/components/dialogs/wizards/audio.dialog.component.ts
+++ b/projects/editor/src/app/components/dialogs/wizards/audio.dialog.component.ts
@@ -44,6 +44,10 @@ import { AudioRowComponent } from 'editor/src/app/components/dialogs/wizards/aud
           <h3>Audio</h3>
           <aspect-editor-wizard-audio [src]="src1" [(maxRuns)]="maxRuns1" (changeMediaSrc)="changeMediaSrc('src1')">
           </aspect-editor-wizard-audio>
+          <h3>Quelle</h3>
+          <aspect-rich-text-editor class="text2" [(content)]="text2" [showReducedControls]="true"
+                                   [placeholder]="'Hier steht die Quelle.'">
+          </aspect-rich-text-editor>
         </mat-expansion-panel>
 
         <mat-expansion-panel (afterExpand)="variant = 'b'" (closed)="variant = undefined">
@@ -59,6 +63,11 @@ import { AudioRowComponent } from 'editor/src/app/components/dialogs/wizards/aud
           <aspect-editor-wizard-audio [src]="src2" [(maxRuns)]="maxRuns2" (changeMediaSrc)="changeMediaSrc('src2')">
           </aspect-editor-wizard-audio>
 
+          <h3>Quelle</h3>
+          <aspect-rich-text-editor class="text2" [(content)]="text2" [showReducedControls]="true"
+                                   [placeholder]="'Hier steht die Quelle.'">
+          </aspect-rich-text-editor>
+
           <h3>Sprache</h3>
           <mat-form-field [matTooltip]="'Mit dieser Einstellung werden kurze Texte oberhalb des Audios generiert.'">
             <mat-label>Sprache auswählen</mat-label>
@@ -100,6 +109,7 @@ export class AudioWizardDialogComponent {
   src2: string | undefined;
   maxRuns2: number = 2;
   lang: 'german' | 'english' | 'french' | undefined;
+  text2: string = '';
   text: string = '<p style="padding-left: 0px; text-indent: 0px; margin-bottom: 10px; margin-top: 0"' +
     ' indentsize="20"><span style="color: black; font-size: 20px">Hier steht die Situierung.</span></p>' +
     '<p style="padding-left: 0px; text-indent: 0px; margin-bottom: 10px; margin-top: 0" indent="0" ' +
diff --git a/projects/editor/src/app/services/template.service.ts b/projects/editor/src/app/services/template.service.ts
index 363c8f8c8..caaeceb38 100644
--- a/projects/editor/src/app/services/template.service.ts
+++ b/projects/editor/src/app/services/template.service.ts
@@ -111,7 +111,7 @@ export class TemplateService {
           this.dialog.open(AudioWizardDialogComponent, { autoFocus: false })
             .afterClosed().subscribe((result: {
               variant: 'a' | 'b', src1: string, maxRuns1: number, src2: string, maxRuns2: number
-              lang: 'german' | 'english' | 'french', text: string }) => {
+              lang: 'german' | 'english' | 'french', text: string, text2: string }) => {
               if (result?.variant === 'a') resolve(this.createAudioSectionA(result));
               if (result?.variant === 'b') resolve(this.createAudioSectionB(result));
             });
@@ -359,7 +359,7 @@ export class TemplateService {
   }
 
   private createAudioSectionA(config: { src1: string, maxRuns1: number, src2: string, maxRuns2: number,
-    lang: 'german' | 'english' | 'french' | undefined, text: string })
+    lang: 'german' | 'english' | 'french' | undefined, text: string, text2: string })
   {
     const sectionElements = [
       this.createElement(
@@ -377,14 +377,19 @@ export class TemplateService {
             showRestRuns: config.maxRuns1 > 1,
             ...TemplateService.getAudioSettings()
           } as PlayerProperties
-        })
+        }),
+      this.createElement(
+        'text',
+        { gridRow: 3, gridColumn: 1 },
+        { text: config.text2, styling: { fontSize: 14, lineHeight: 100 } }
+      )
     ];
     const section = new Section();
     sectionElements.forEach(el => section.addElement(el));
     return section;
   }
 
-  private createAudioSectionB(config: { src1: string, maxRuns1: number, src2: string, maxRuns2: number, lang: 'german' | 'english' | 'french', text: string }) {
+  private createAudioSectionB(config: { src1: string, maxRuns1: number, src2: string, maxRuns2: number, lang: 'german' | 'english' | 'french', text: string, text2: string }) {
     const sectionElements = [];
     sectionElements.push(this.createElement(
       'text',
@@ -443,6 +448,13 @@ export class TemplateService {
         } as PlayerProperties
       }
     ));
+
+    sectionElements.push(this.createElement(
+      'text',
+      { gridRow: 6, gridColumn: 1 },
+      { text: config.text2, styling: { fontSize: 14, lineHeight: 100 } }
+    ));
+
     const section = new Section();
     sectionElements.forEach(el => section.addElement(el));
     return section;
-- 
GitLab