From 8ee523103461d3d6f84e4d5d66474b29a1dad3b6 Mon Sep 17 00:00:00 2001
From: rhenck <richard.henck@iqb.hu-berlin.de>
Date: Tue, 16 Nov 2021 22:47:50 +0100
Subject: [PATCH] [editor] Fix likert column edit dialog to set values only on
 save

---
 .../dialogs/likert-column-edit-dialog.component.ts   | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/projects/editor/src/app/components/dialogs/likert-column-edit-dialog.component.ts b/projects/editor/src/app/components/dialogs/likert-column-edit-dialog.component.ts
index 9b16ec040..09bd9e901 100644
--- a/projects/editor/src/app/components/dialogs/likert-column-edit-dialog.component.ts
+++ b/projects/editor/src/app/components/dialogs/likert-column-edit-dialog.component.ts
@@ -14,13 +14,12 @@ import { FileService } from '../../../../../common/file.service';
       <input #imageUpload type="file" hidden (click)="loadImage()">
       <button mat-raised-button (click)="imageUpload.click()">{{ 'loadImage' | translate }}</button>
       <button mat-raised-button (click)="data.column.imgSrc = null">{{ 'removeImage' | translate }}</button>
-      <img [src]="data.column.imgSrc"
+      <img [src]="imgSrc"
            [style.object-fit]="'scale-down'"
            [width]="200">
       <mat-form-field appearance="fill">
         <mat-label>{{'position' | translate }}</mat-label>
-        <mat-select [value]="data.column.position"
-                    (selectionChange)="this.data.column.position = $event.value">
+        <mat-select #positionSelect [value]="data.column.position">
           <mat-option *ngFor="let option of ['above', 'below']"
                       [value]="option">
             {{ option | translate }}
@@ -31,8 +30,8 @@ import { FileService } from '../../../../../common/file.service';
     <mat-dialog-actions>
       <button mat-button [mat-dialog-close]="{
                          text: textInput.value,
-                         imgSrc: data.column.imgSrc,
-                         position: data.column.position }">
+                         imgSrc: imgSrc,
+                         position: positionSelect.value }">
         {{'save' | translate }}
       </button>
       <button mat-button mat-dialog-close>{{'cancel' | translate }}</button>
@@ -41,8 +40,9 @@ import { FileService } from '../../../../../common/file.service';
 })
 export class LikertColumnEditDialogComponent {
   constructor(@Inject(MAT_DIALOG_DATA) public data: { column: LikertColumn }) { }
+  imgSrc: string | null = this.data.column.imgSrc;
 
   async loadImage(): Promise<void> {
-    this.data.column.imgSrc = await FileService.loadImage();
+    this.imgSrc = await FileService.loadImage();
   }
 }
-- 
GitLab