From 3124ed638255fd3cfd79a2f10aff137e6732b1df Mon Sep 17 00:00:00 2001
From: Daviti Gogshelidze <daviti1@mail.com>
Date: Fri, 28 Jun 2019 19:01:24 +0200
Subject: [PATCH] region selection region hierarchy

Includes cookie acknowledgement fix and panel minimise and close buttons fix
---
 .../widgetUnit/widgetUnit.template.html       |  6 ++--
 .../flatTree/flatTree.template.html           |  2 +-
 .../cookieAgreement.template.html             |  4 +--
 .../regionHierarchy.component.ts              | 29 ++++++++++++++++++-
 .../regionHierarchy.template.html             |  1 +
 5 files changed, 35 insertions(+), 7 deletions(-)

diff --git a/src/atlasViewer/widgetUnit/widgetUnit.template.html b/src/atlasViewer/widgetUnit/widgetUnit.template.html
index a7cfd51ef..62600cf8b 100644
--- a/src/atlasViewer/widgetUnit/widgetUnit.template.html
+++ b/src/atlasViewer/widgetUnit/widgetUnit.template.html
@@ -25,7 +25,7 @@
         *ngIf="!isMobile"
         (click)="widgetServices.minimise(this)"
         class="fas fa-window-minimize"
-        hoverable>
+        [hoverable] ="{translateY: -1}">
 
       </i>
       <i *ngIf = "canBeDocked && state === 'floating' && !isMobile"
@@ -34,12 +34,12 @@
         hoverable></i>
       <i *ngIf = "state === 'docked' && !isMobile"
         (click) = "undock($event)" 
-        class = "fas fa-window-restore" 
+        class = "fas fa-window-restore"
         hoverable></i>
       <i *ngIf = "exitable"
         (click) = "exit($event)" 
         class = "fas fa-times" 
-        hoverable></i>
+        [hoverable] ="{translateY: -1}"></i>
     </div>
   </div>
   <div widgetUnitBody body>
diff --git a/src/components/flatTree/flatTree.template.html b/src/components/flatTree/flatTree.template.html
index 3dc560104..903c00ddd 100644
--- a/src/components/flatTree/flatTree.template.html
+++ b/src/components/flatTree/flatTree.template.html
@@ -37,7 +37,7 @@
   *ngIf="useDefaultList"
   class="overflow-auto">
 
-  <div class="overflow-hidden default-container">
+  <div class="overflow-hidden default-container" style="background-color: #dbb556">
     <div
       *ngFor="let flattenedItem of (inputItem | flattenTreePipe : findChildren | filterRowsByVisbilityPipe : findChildren : searchFilter | appendSiblingFlagPipe )" 
       [ngClass]="getClass(flattenedItem.flattenedTreeLevel)"
diff --git a/src/ui/cookieAgreement/cookieAgreement.template.html b/src/ui/cookieAgreement/cookieAgreement.template.html
index d5db16a19..d0b6acdf5 100644
--- a/src/ui/cookieAgreement/cookieAgreement.template.html
+++ b/src/ui/cookieAgreement/cookieAgreement.template.html
@@ -3,7 +3,7 @@
     remember user choices and preferences, and in some instances determine site permissions. Cookies also provide,
     in anonymous form, the number of visitors accessing the HBP Public Website, features users access during website
     visits, and the general location of the user based on IP address.</p>
-  <p>Interactive Viewer uses at least the following cookies:</p>
+  <p>HBP Atlas Viewer uses at least the following cookies:</p>
   <p><strong>connect.sid</strong> : verify login details</p>
   <p>To find out more about cookies, including how to determine the cookies that have been set on
     your computer and how to manage
@@ -23,7 +23,7 @@
       <div>
         <strong>Data controller(s):</strong>
         <span>
-          Interactive Viewer is the data controller for your login information.
+          HBP Atlas Viewer is the data controller for your login information.
         </span>
       </div>
 
diff --git a/src/ui/regionHierachy/regionHierarchy.component.ts b/src/ui/regionHierachy/regionHierarchy.component.ts
index f04dc7b1b..9e629abce 100644
--- a/src/ui/regionHierachy/regionHierarchy.component.ts
+++ b/src/ui/regionHierachy/regionHierarchy.component.ts
@@ -3,6 +3,7 @@ import {  Subscription, Subject, fromEvent } from "rxjs";
 import { buffer, debounceTime } from "rxjs/operators";
 import { FilterNameBySearch } from "./filterNameBySearch.pipe";
 import { generateLabelIndexId } from "src/services/stateStore.service";
+import {promise} from "selenium-webdriver";
 
 const insertHighlight :(name:string, searchTerm:string) => string = (name:string, searchTerm:string = '') => {
   const regex = new RegExp(searchTerm, 'gi')
@@ -62,6 +63,9 @@ export class RegionHierarchy implements OnInit, AfterViewInit{
   @ViewChild('searchTermInput', {read: ElementRef})
   private searchTermInput: ElementRef
 
+  countItemsIntoTheTree: number
+  windowHeight: number
+
   @HostListener('document:click', ['$event'])
   closeRegion(event: MouseEvent) {
     const contains = this.el.nativeElement.contains(event.target)
@@ -70,6 +74,11 @@ export class RegionHierarchy implements OnInit, AfterViewInit{
       this.searchTerm = ''
   }
 
+  @HostListener('window:resize', ['$event'])
+  onResize(event) {
+    this.windowHeight = event.target.innerHeight;
+  }
+
   get regionsLabelIndexMap() {
     return null
   }
@@ -78,7 +87,7 @@ export class RegionHierarchy implements OnInit, AfterViewInit{
     private cdr:ChangeDetectorRef,
     private el:ElementRef
   ){
-
+    this.windowHeight = window.innerHeight;
   }
 
   ngOnChanges(){
@@ -102,6 +111,11 @@ export class RegionHierarchy implements OnInit, AfterViewInit{
   set showRegionTree(flag: boolean){
     this._showRegionTree = flag
     this.showRegionFlagChanged.emit(this._showRegionTree)
+    this.countItemsIntoTheTree = 1
+    if (this.aggregatedRegionTree.children &&
+        this.aggregatedRegionTree.children.length > 0) {
+      this.countItems(this.aggregatedRegionTree)
+    }
   }
 
   ngOnInit(){
@@ -157,6 +171,19 @@ export class RegionHierarchy implements OnInit, AfterViewInit{
 
   }
 
+  countItems(objectToCount) {
+    objectToCount.children.forEach(object => {
+      this.countItemsIntoTheTree += 1
+      if (object.children && object.children.length > 0) this.countItems(object)
+    })
+  }
+  regionHierarchyHeight(){
+    return({
+      'height' : (this.countItemsIntoTheTree * 15 + 60).toString() + 'px',
+      'max-height': (this.windowHeight - 100) + 'px'
+    })
+  }
+
   focusInput(event?:MouseEvent){
     if (event) {
       /**
diff --git a/src/ui/regionHierachy/regionHierarchy.template.html b/src/ui/regionHierachy/regionHierarchy.template.html
index 36ab15e52..b49e04768 100644
--- a/src/ui/regionHierachy/regionHierarchy.template.html
+++ b/src/ui/regionHierachy/regionHierarchy.template.html
@@ -17,6 +17,7 @@
   hideScrollbarContainer>
 
   <div
+    [ngStyle]="regionHierarchyHeight()"
     class="d-flex flex-column"
     treeContainer
     #treeContainer>
-- 
GitLab