From 0c249d571dd99fcf6d3996462de0b57898a65082 Mon Sep 17 00:00:00 2001
From: rhenck <richard.henck@iqb.hu-berlin.de>
Date: Tue, 9 Aug 2022 19:35:17 +0200
Subject: [PATCH] Refactor label edit dialog

---
 projects/editor/src/app/app.module.ts         |  5 ++-
 .../dialogs/label-edit-dialog.component.ts    | 36 ++++++-------------
 2 files changed, 13 insertions(+), 28 deletions(-)

diff --git a/projects/editor/src/app/app.module.ts b/projects/editor/src/app/app.module.ts
index 26f903e64..1d9127584 100644
--- a/projects/editor/src/app/app.module.ts
+++ b/projects/editor/src/app/app.module.ts
@@ -82,7 +82,7 @@ import { InputElementPropertiesComponent } from './components/properties-panel/m
 import { PresetValuePropertiesComponent } from './components/properties-panel/model-properties-tab/input-groups/preset-value-properties.component';
 import { OptionListPanelComponent } from './components/properties-panel/option-list-panel.component';
 import { LikertRowLabelPipe } from './components/properties-panel/likert-row-label.pipe';
-import { LabelEditDialogComponent, SaveLabelPipe } from './components/dialogs/label-edit-dialog.component';
+import { LabelEditDialogComponent } from './components/dialogs/label-edit-dialog.component';
 
 @NgModule({
   declarations: [
@@ -130,8 +130,7 @@ import { LabelEditDialogComponent, SaveLabelPipe } from './components/dialogs/la
     PresetValuePropertiesComponent,
     OptionListPanelComponent,
     LikertRowLabelPipe,
-    LabelEditDialogComponent,
-    SaveLabelPipe
+    LabelEditDialogComponent
   ],
   imports: [
     BrowserModule,
diff --git a/projects/editor/src/app/components/dialogs/label-edit-dialog.component.ts b/projects/editor/src/app/components/dialogs/label-edit-dialog.component.ts
index bdd01bc72..255393fd2 100644
--- a/projects/editor/src/app/components/dialogs/label-edit-dialog.component.ts
+++ b/projects/editor/src/app/components/dialogs/label-edit-dialog.component.ts
@@ -1,29 +1,22 @@
-// eslint-disable-next-line max-classes-per-file
-import {
-  Component, Inject, Pipe, PipeTransform
-} from '@angular/core';
+import { Component, Inject } from '@angular/core';
 import { MAT_DIALOG_DATA } from '@angular/material/dialog';
-import { Label, TextImageLabel } from 'common/models/elements/element';
+import { TextImageLabel } from 'common/models/elements/element';
 import { FileService } from 'common/services/file.service';
 
 @Component({
   selector: 'aspect-label-edit-dialog',
   template: `
-    <mat-dialog-content>
-      <div>
-        <aspect-rich-text-editor-simple [(content)]="newLabel.text">
-        </aspect-rich-text-editor-simple>
-      </div>
-
-      <mat-divider [style.margin.px]="15"></mat-divider>
+    <mat-dialog-content fxLayout="column" fxLayoutGap="20px">
+      <aspect-rich-text-editor-simple [(content)]="newLabel.text">
+      </aspect-rich-text-editor-simple>
 
-      <div *ngIf="newLabel.imgSrc !== undefined" fxLayout="row" fxLayoutAlign="space-between center" >
+      <div *ngIf="newLabel.imgSrc !== undefined" fxLayout="row" fxLayoutAlign="space-between center">
         <div fxLayout="column" fxLayoutGap="10px">
           <button mat-raised-button (click)="loadImage()">{{ 'loadImage' | translate }}</button>
           <button mat-raised-button (click)="newLabel.imgSrc = null">{{ 'removeImage' | translate }}</button>
           <mat-form-field>
             <mat-label>{{'imagePosition' | translate }}</mat-label>
-            <mat-select #positionSelect [value]="newLabel.imgPosition"
+            <mat-select [value]="newLabel.imgPosition"
                         [disabled]="newLabel.imgSrc == null">
               <mat-option *ngFor="let option of ['above', 'below', 'left', 'right']"
                           [value]="option">
@@ -42,7 +35,10 @@ import { FileService } from 'common/services/file.service';
       <button mat-button [mat-dialog-close]="newLabel">{{'save' | translate }}</button>
       <button mat-button mat-dialog-close>{{'cancel' | translate }}</button>
     </mat-dialog-actions>
-  `
+  `,
+  styles: [
+    'aspect-rich-text-editor-simple {margin-bottom: 20px;}'
+  ]
 })
 export class LabelEditDialogComponent {
   newLabel = { ...this.data.label };
@@ -53,13 +49,3 @@ export class LabelEditDialogComponent {
     this.newLabel.imgSrc = await FileService.loadImage();
   }
 }
-
-@Pipe({
-  name: 'saveLabel'
-})
-export class SaveLabelPipe implements PipeTransform {
-  // eslint-disable-next-line class-methods-use-this
-  transform(labelText: string, label: Label): Label {
-    return { ...label, text: labelText };
-  }
-}
-- 
GitLab