From 11a08396b0678efcc4948652b4c2016b67a36034 Mon Sep 17 00:00:00 2001
From: jojohoch <joachim.hoch@iqb.hu-berlin.de>
Date: Thu, 24 Nov 2022 16:03:40 +0100
Subject: [PATCH] Rename NavigationEvent and displayname of Button

This was necessary because the new text selection action of the button
is not a navigation.
---
 projects/common/components/button/button.component.ts  |  4 ++--
 projects/common/models/elements/button/button.ts       |  6 +++---
 projects/common/models/elements/element.ts             | 10 +++++++---
 .../input-groups/button-properties.component.ts        |  4 ++--
 projects/editor/src/assets/i18n/de.json                |  4 ++--
 .../compound-group-element.component.ts                |  8 +++++---
 .../interactive-group-element.component.ts             |  8 ++++----
 7 files changed, 25 insertions(+), 19 deletions(-)

diff --git a/projects/common/components/button/button.component.ts b/projects/common/components/button/button.component.ts
index 8835d2684..5f5061eb1 100644
--- a/projects/common/components/button/button.component.ts
+++ b/projects/common/components/button/button.component.ts
@@ -2,7 +2,7 @@ import {
   Component, EventEmitter, Input, Output
 } from '@angular/core';
 import { ButtonElement } from 'common/models/elements/button/button';
-import { NavigationEvent } from 'common/models/elements/element';
+import { ButtonEvent } from 'common/models/elements/element';
 import { ElementComponent } from '../../directives/element-component.directive';
 
 @Component({
@@ -69,5 +69,5 @@ import { ElementComponent } from '../../directives/element-component.directive';
 })
 export class ButtonComponent extends ElementComponent {
   @Input() elementModel!: ButtonElement;
-  @Output() navigateTo = new EventEmitter<NavigationEvent>();
+  @Output() navigateTo = new EventEmitter<ButtonEvent>();
 }
diff --git a/projects/common/models/elements/button/button.ts b/projects/common/models/elements/button/button.ts
index 13df35807..3ab6b31de 100644
--- a/projects/common/models/elements/button/button.ts
+++ b/projects/common/models/elements/button/button.ts
@@ -1,6 +1,6 @@
 import { Type } from '@angular/core';
 import {
-  BasicStyles, PositionProperties, UIElement
+  BasicStyles, ButtonAction, PositionProperties, UIElement, UnitNavParam
 } from 'common/models/elements/element';
 import { ButtonComponent } from 'common/components/button/button.component';
 import { ElementComponent } from 'common/directives/element-component.directive';
@@ -9,8 +9,8 @@ export class ButtonElement extends UIElement {
   label: string = 'Navigationsknopf';
   imageSrc: string | null = null;
   asLink: boolean = false;
-  action: null | 'unitNav' | 'pageNav' | 'scrollTo' = null;
-  actionParam: null | 'previous' | 'next' | 'first' | 'last' | 'end' | number | string = null;
+  action: null | ButtonAction = null;
+  actionParam: null | UnitNavParam | number | string = null;
   position: PositionProperties | undefined;
   styling: BasicStyles & {
     borderRadius: number;
diff --git a/projects/common/models/elements/element.ts b/projects/common/models/elements/element.ts
index d4fbb8959..ece5e82b8 100644
--- a/projects/common/models/elements/element.ts
+++ b/projects/common/models/elements/element.ts
@@ -312,11 +312,15 @@ export interface ValueChangeElement {
   value: InputElementValue;
 }
 
-export interface NavigationEvent {
-  action: 'unitNav' | 'pageNav' | 'scrollTo';
-  param: 'previous' | 'next' | 'first' | 'last' | 'end' | number | string;
+export interface ButtonEvent {
+  action: ButtonAction;
+  param: UnitNavParam | number | string;
 }
 
+export type ButtonAction = 'unitNav' | 'pageNav' | 'highlightText';
+
+export type UnitNavParam = 'previous' | 'next' | 'first' | 'last' | 'end';
+
 export interface OptionElement extends UIElement {
   getNewOptionLabel(optionText: string): Label;
 }
diff --git a/projects/editor/src/app/components/properties-panel/model-properties-tab/input-groups/button-properties.component.ts b/projects/editor/src/app/components/properties-panel/model-properties-tab/input-groups/button-properties.component.ts
index bdf91b685..591e851e4 100644
--- a/projects/editor/src/app/components/properties-panel/model-properties-tab/input-groups/button-properties.component.ts
+++ b/projects/editor/src/app/components/properties-panel/model-properties-tab/input-groups/button-properties.component.ts
@@ -26,7 +26,7 @@ import { SelectionService } from '../../../../services/selection.service';
           <mat-option [value]="null">
             {{ 'propertiesPanel.none' | translate }}
           </mat-option>
-          <mat-option *ngFor="let option of ['unitNav', 'pageNav', 'scrollTo']"
+          <mat-option *ngFor="let option of ['unitNav', 'pageNav', 'highlightText']"
                       [value]="option">
             {{ 'propertiesPanel.' + option | translate }}
           </mat-option>
@@ -57,7 +57,7 @@ import { SelectionService } from '../../../../services/selection.service';
               </mat-option>
             </ng-container>
 
-            <ng-container *ngIf="combinedProperties.action === 'scrollTo'">
+            <ng-container *ngIf="combinedProperties.action === 'highlightText'">
               <mat-option *ngFor="let option of (textComponents | getAnchorIds) "
                           [value]="option">
                 {{ option  }}
diff --git a/projects/editor/src/assets/i18n/de.json b/projects/editor/src/assets/i18n/de.json
index fd9868edb..f702ac364 100644
--- a/projects/editor/src/assets/i18n/de.json
+++ b/projects/editor/src/assets/i18n/de.json
@@ -93,7 +93,7 @@
     "actionParam": "Aktionsparameter",
     "unitNav": "Unitnavigation",
     "pageNav": "Seitennavigation",
-    "scrollTo": "Textabschnitt hervorheben",
+    "highlightText": "Textabschnitt hervorheben",
     "previous": "Vorherige Unit",
     "next": "Nächste Unit",
     "first": "Erste Unit",
@@ -231,7 +231,7 @@
   },
   "toolbox": {
     "text": "Text",
-    "button": "Navigationsknopf",
+    "button": "Knopf",
     "frame": "Rahmen",
     "text-field": "Eingabefeld",
     "text-field-simple": "Eingabefeld",
diff --git a/projects/player/src/app/components/elements/compound-group-element/compound-group-element.component.ts b/projects/player/src/app/components/elements/compound-group-element/compound-group-element.component.ts
index 9c4fdc80a..dd19a3853 100644
--- a/projects/player/src/app/components/elements/compound-group-element/compound-group-element.component.ts
+++ b/projects/player/src/app/components/elements/compound-group-element/compound-group-element.component.ts
@@ -9,7 +9,9 @@ import {
 } from 'common/components/compound-elements/cloze/cloze-child-elements/text-field-simple.component';
 import { ClozeElement } from 'common/models/elements/compound-elements/cloze/cloze';
 import { LikertElement } from 'common/models/elements/compound-elements/likert/likert';
-import { CompoundElement, InputElement, InputElementValue } from 'common/models/elements/element';
+import {
+  CompoundElement, InputElement, InputElementValue, UnitNavParam
+} from 'common/models/elements/element';
 import { ButtonComponent } from 'common/components/button/button.component';
 import { VeronaPostService } from 'player/modules/verona/services/verona-post.service';
 import { NavigationService } from 'player/src/app/services/navigation.service';
@@ -137,13 +139,13 @@ export class CompoundGroupElementComponent extends ElementFormGroupDirective imp
         switch (navigationEvent.action) {
           case 'unitNav':
             this.veronaPostService.sendVopUnitNavigationRequestedNotification(
-              (navigationEvent.param as 'previous' | 'next' | 'first' | 'last' | 'end')
+              (navigationEvent.param as UnitNavParam)
             );
             break;
           case 'pageNav':
             this.navigationService.setPage(navigationEvent.param as number);
             break;
-          case 'scrollTo':
+          case 'highlightText':
             this.anchorService.toggleAnchor(navigationEvent.param as string);
             break;
           default:
diff --git a/projects/player/src/app/components/elements/interactive-group-element/interactive-group-element.component.ts b/projects/player/src/app/components/elements/interactive-group-element/interactive-group-element.component.ts
index af7276565..8a21ac58e 100644
--- a/projects/player/src/app/components/elements/interactive-group-element/interactive-group-element.component.ts
+++ b/projects/player/src/app/components/elements/interactive-group-element/interactive-group-element.component.ts
@@ -5,7 +5,7 @@ import { ElementComponent } from 'common/directives/element-component.directive'
 import { ButtonElement } from 'common/models/elements/button/button';
 import { FrameElement } from 'common/models/elements/frame/frame';
 import { ImageElement } from 'common/models/elements/media-elements/image';
-import { InputElementValue, NavigationEvent } from 'common/models/elements/element';
+import { InputElementValue, ButtonEvent, UnitNavParam } from 'common/models/elements/element';
 import { VeronaPostService } from 'player/modules/verona/services/verona-post.service';
 import { AnchorService } from 'player/src/app/services/anchor.service';
 import { NavigationService } from '../../../services/navigation.service';
@@ -46,17 +46,17 @@ export class InteractiveGroupElementComponent extends ElementGroupDirective impl
       this.pageIndex);
   }
 
-  navigateTo(navigationEvent: NavigationEvent): void {
+  navigateTo(navigationEvent: ButtonEvent): void {
     switch (navigationEvent.action) {
       case 'unitNav':
         this.veronaPostService.sendVopUnitNavigationRequestedNotification(
-          (navigationEvent.param as 'previous' | 'next' | 'first' | 'last' | 'end')
+          (navigationEvent.param as UnitNavParam)
         );
         break;
       case 'pageNav':
         this.navigationService.setPage(navigationEvent.param as number);
         break;
-      case 'scrollTo':
+      case 'highlightText':
         this.anchorService.toggleAnchor(navigationEvent.param as string);
         break;
       default:
-- 
GitLab