From 69ac5b2caeeddc53a4bda068843469f3238ab8ca Mon Sep 17 00:00:00 2001
From: descamps <descamps@cines.fr>
Date: Thu, 10 Jun 2021 18:15:57 +0200
Subject: [PATCH] KDE - 10/06/2021 - WIP - Checkbox valeur fixe

---
 .../file-tree-metadata.component.html         | 13 +++++---
 .../file-tree-metadata.component.ts           | 31 +++++++++++++------
 2 files changed, 30 insertions(+), 14 deletions(-)

diff --git a/ui/ui-frontend/projects/pastis/src/app/profile/edit-profile/file-tree-metadata/file-tree-metadata.component.html b/ui/ui-frontend/projects/pastis/src/app/profile/edit-profile/file-tree-metadata/file-tree-metadata.component.html
index 9b818f6ba..a178e9280 100644
--- a/ui/ui-frontend/projects/pastis/src/app/profile/edit-profile/file-tree-metadata/file-tree-metadata.component.html
+++ b/ui/ui-frontend/projects/pastis/src/app/profile/edit-profile/file-tree-metadata/file-tree-metadata.component.html
@@ -97,11 +97,14 @@
                 </div>
               </ng-container>
               <ng-container *ngSwitchCase="'enumeration'">
-                <mat-select placeholder="Choisissez une valeur" [ngModel]="element.valeurFixe"
-                            (ngModelChange)="setNodeValue(element,$event)" class="mat-select-valeur-fixe">
-                  <mat-option [value]=""></mat-option>
-                  <mat-option *ngFor="let val of element.enumeration" [value]="val">{{val}}</mat-option>
-                </mat-select>
+                  <mat-select  placeholder="Choisissez une valeur" [ngModel]="element.valeurFixe"
+                              class="mat-select-valeur-fixe">
+                    <mat-option [value]=""></mat-option>
+                    <mat-option *ngFor="let val of element.enumeration; let i =index" [value]="val">
+                      <mat-checkbox [checked]="selected === i" (change)="onChange(element,val);selected = i"> {{val}}
+                      </mat-checkbox>
+                    </mat-option>
+                  </mat-select>
               </ng-container>
               <ng-container *ngIf="!checkElementType(element.nomDuChamp)">
                 <!-- <textarea matInput *ngSwitchDefault [ngModel]="element.valeurFixe"
diff --git a/ui/ui-frontend/projects/pastis/src/app/profile/edit-profile/file-tree-metadata/file-tree-metadata.component.ts b/ui/ui-frontend/projects/pastis/src/app/profile/edit-profile/file-tree-metadata/file-tree-metadata.component.ts
index a4f4020fe..a6498f421 100644
--- a/ui/ui-frontend/projects/pastis/src/app/profile/edit-profile/file-tree-metadata/file-tree-metadata.component.ts
+++ b/ui/ui-frontend/projects/pastis/src/app/profile/edit-profile/file-tree-metadata/file-tree-metadata.component.ts
@@ -52,6 +52,7 @@ import { NotificationService } from 'projects/pastis/src/app/core/services/notif
 import { NgxUiLoaderService } from 'ngx-ui-loader';
 import { Router } from '@angular/router';
 import {Subscription} from "rxjs";
+import {MatCheckboxChange} from "@angular/material/checkbox";
 
 
 
@@ -70,6 +71,7 @@ export class FileTreeMetadataComponent {
   dataType = Object.values(DataTypeConstants);
   cardinalityList: string[];
   cardinalityLabels = Object.values(CardinalityConstants)
+  selected = -1;
 
   //Mat table
   matDataSource: MatTableDataSource<MetadataHeaders>;
@@ -236,15 +238,18 @@ export class FileTreeMetadataComponent {
   }
 
   setNodeValue(metadata: MetadataHeaders, newValue: string) {
-    let updatedValue = newValue.length > 0 ? newValue : null
-    if (this.clickedNode.name === metadata.nomDuChamp) {
-      this.clickedNode.value = updatedValue;
-    } else if (this.clickedNode.children.length > 0) {
-      let childNode = this.fileService.getFileNodeById(this.clickedNode, metadata.id);
-      if (childNode) {
-        childNode.value = updatedValue;
-      }
-    }
+    console.log(metadata.cardinalite + "new Value " + newValue)
+   if(newValue != null) {
+     let updatedValue = newValue.length > 0 ? newValue : null
+     if (this.clickedNode.name === metadata.nomDuChamp) {
+       this.clickedNode.value = updatedValue;
+     } else if (this.clickedNode.children.length > 0) {
+       let childNode = this.fileService.getFileNodeById(this.clickedNode, metadata.id);
+       if (childNode) {
+         childNode.value = updatedValue;
+       }
+     }
+   }
   }
 
   setDocumentation(metadata: MetadataHeaders, comment: string) {
@@ -438,4 +443,12 @@ export class FileTreeMetadataComponent {
     }
   }
 
+  onChange(val: any, $event: MatCheckboxChange) {
+
+    console.log("onChange file tree metadata go dans methode setNodeValue" + val + " et event " +$event);
+    // @ts-ignore
+    this.setNodeValue(val,$event);
+
+
+  }
 }
-- 
GitLab