Bläddra i källkod

✨ expose datasets in the adjuster panel

jmacura 4 år sedan
förälder
incheckning
85345ba7a3

+ 5 - 3
src/adjuster/adjuster.component.ts

@@ -14,6 +14,7 @@ export class AdjusterComponent implements HsPanelComponent {
   data: any;
   descriptionVisible: boolean;
   errorMsg: string;
+  //method: string;
   viewRef: ViewRef;
 
   constructor(
@@ -22,6 +23,7 @@ export class AdjusterComponent implements HsPanelComponent {
     public hsLayoutService: HsLayoutService
   ) {
     this.descriptionVisible = false;
+    //this.method = this.adjusterService.method;
     /*this.adjusterEventService.clustersLoaded.subscribe(({success, err}) => {
       if (!success) {
         this.errorMsg = err.message;
@@ -30,14 +32,14 @@ export class AdjusterComponent implements HsPanelComponent {
   }
 
   ngOnInit(): void {
-    //this.adjusterService.init();
+    this.adjusterService.init();
   }
 
   isVisible(): boolean {
     return this.hsLayoutService.panelVisible('adjuster');
   }
 
-  /*noDataSelected(): boolean {
+  noDataSelected(): boolean {
     if (this.adjusterService.factors.length === 0) {
       return true;
     }
@@ -52,7 +54,7 @@ export class AdjusterComponent implements HsPanelComponent {
       ];
     }
     return datasetsEffectivelyTurnedOn.length === 0;
-  }*/
+  }
 
   /*selectMethod(): void {
     this.adjusterService.method = this.method;

+ 34 - 12
src/adjuster/adjuster.directive.html

@@ -1,16 +1,38 @@
 <div [hidden]="!isVisible()" class="card mainpanel">
-    <hs-panel-header name="adjuster" [title]="'ADJUSTER.adjustFactors' | translate"></hs-panel-header>
-    <div class="card-body">
-        <div class="card-body">
-                <div *ngFor="let factor of adjusterService.factors">
-                    <div class="d-flex flex-row">
-                        <div class="p-2 flex-grow-1">
-                            <label>{{factor.name}}</label>
-                        </div>
-                        <div class="p-2">{{(factor.weight * 100).toFixed(0)}}&nbsp;%</div>
-                    </div>
-                    <input type="range" class="custom-range" (change)="adjusterService.apply()" [(ngModel)]="factor.weight" min="0" max="1.0" step="0.05">
-                </div>
+  <hs-panel-header name="adjuster" [title]="'ADJUSTER.adjustFactors' | translate"></hs-panel-header>
+  <div class="card-body">
+    <div class="p-2 center-block">
+      <!-- PLACEHOLDER -->
+    </div>
+    <div *ngFor="let factor of adjusterService.factors; let datasetlistVisible = false">
+      <div class="d-flex flex-row">
+        <div class="p-2 flex-grow-1">
+          <span class="glyphicon cursor-pointer"
+            [ngClass]="datasetlistVisible ? 'icon-chevron-down' : 'icon-chevron-right'"
+            (click)="datasetlistVisible = !datasetlistVisible"></span>
+          <label class="pl-2 cursor-pointer" (click)="datasetlistVisible = !datasetlistVisible">{{factor.name}}</label>
+        </div>
+        <div class="p-2">{{(factor.weight * 100).toFixed(0)}}&nbsp;%</div>
+      </div>
+      <input type="range" class="custom-range" (change)="adjusterService.apply()" [(ngModel)]="factor.weight" min="0"
+        max="1.0" step="0.05">
+      <div [hidden]="!datasetlistVisible">
+        <div *ngFor="let dataset of factor.datasets; let descriptionVisible = false">
+          <button type="button" class="btn btn-sm btn-light hs-lm-item-visibility"
+            [ngClass]="dataset.included ? 'hs-checkmark' : 'hs-uncheckmark'"
+            (click)="dataset.included = !dataset.included;$event.stopPropagation()"></button>
+          <!-- commented because we do not have descriptions yet -->
+          <!--span class="glyphicon cursor-pointer text-secondary"
+            [ngClass]="descriptionVisible ? 'icon-chevron-down' : 'icon-chevron-right'"
+            (click)="descriptionVisible = !descriptionVisible"></span-->
+          <!--label class="pl-2 cursor-pointer text-secondary"
+            (click)="descriptionVisible = !descriptionVisible">{{dataset.name}}</label-->
+            <label class="pl-2 text-secondary">{{dataset.name}}</label>
+          <div class="p-2 mb-2 text-justify text-info" [hidden]="!descriptionVisible">
+            {{dataset.desc}}
+          </div>
         </div>
+      </div>
     </div>
+  </div>
 </div>

+ 0 - 1
src/adjuster/adjuster.service.ts

@@ -23,7 +23,6 @@ export class AdjusterService {
       window.location.hostname === 'localhost'
         ? 'https://jmacura.ml/ws/' // 'http://localhost:3000/'
         : 'https://publish.lesprojekt.cz/nodejs/';
-    this.init();
   }
 
   /**