From e30bd18bcaff17dd0bdece9ef78c967c19eb49b8 Mon Sep 17 00:00:00 2001
From: KASSEM Passam <depysk@gmail.com>
Date: Tue, 18 May 2021 15:33:06 +0200
Subject: [PATCH] [VAS] BUG 7719 : Corrections bugs app utilisateur et app
 group

---
 .../vitamui-autocomplete.component.html       |  4 +-
 .../vitamui-autocomplete.module.ts            | 16 +++--
 .../autocomplete-position.directive.module.ts | 52 +++++++++++++++
 .../autocomplete-position.directive.spec.ts   | 44 +++++++++++++
 .../autocomplete-position.directive.ts        | 63 +++++++++++++++++++
 .../src/app/modules/vitamui-common.module.ts  |  7 ++-
 .../user/user-list/user-list.component.scss   | 10 ++-
 .../user-preview/user-preview.component.html  |  2 +-
 8 files changed, 182 insertions(+), 16 deletions(-)
 create mode 100644 ui/ui-frontend-common/src/app/modules/directives/autocomplete-position/autocomplete-position.directive.module.ts
 create mode 100644 ui/ui-frontend-common/src/app/modules/directives/autocomplete-position/autocomplete-position.directive.spec.ts
 create mode 100644 ui/ui-frontend-common/src/app/modules/directives/autocomplete-position/autocomplete-position.directive.ts

diff --git a/ui/ui-frontend-common/src/app/modules/components/vitamui-autocomplete/vitamui-autocomplete.component.html b/ui/ui-frontend-common/src/app/modules/components/vitamui-autocomplete/vitamui-autocomplete.component.html
index 2dc789e0d..bf2e4e6b1 100644
--- a/ui/ui-frontend-common/src/app/modules/components/vitamui-autocomplete/vitamui-autocomplete.component.html
+++ b/ui/ui-frontend-common/src/app/modules/components/vitamui-autocomplete/vitamui-autocomplete.component.html
@@ -1,10 +1,12 @@
 <div class="vitamui-autocomplete" [class.disabled]="control.disabled" [class.label-up]="labelUp">
   <label class="input-label">{{ placeholder }}</label>
   <input
-      #input
+      #input="matAutocompleteTrigger"
+      matInput
       type="text"
       [formControl]="control"
       [matAutocomplete]="auto"
+      [vitamuiAutocompletePosition]="input"
       (blur)="onBlur()"
       (focus)="onFocus()"
   >
diff --git a/ui/ui-frontend-common/src/app/modules/components/vitamui-autocomplete/vitamui-autocomplete.module.ts b/ui/ui-frontend-common/src/app/modules/components/vitamui-autocomplete/vitamui-autocomplete.module.ts
index 12e5c35ce..f466026c6 100644
--- a/ui/ui-frontend-common/src/app/modules/components/vitamui-autocomplete/vitamui-autocomplete.module.ts
+++ b/ui/ui-frontend-common/src/app/modules/components/vitamui-autocomplete/vitamui-autocomplete.module.ts
@@ -41,14 +41,18 @@ import { MatAutocompleteModule } from '@angular/material/autocomplete';
 import { MatTooltipModule } from '@angular/material/tooltip';
 
 import { VitamUIAutocompleteComponent } from './vitamui-autocomplete.component';
+import {MatInputModule} from "@angular/material/input";
+import {AutocompletePositionDirectiveModule} from "../../directives/autocomplete-position/autocomplete-position.directive.module";
 
 @NgModule({
-  imports: [
-    CommonModule,
-    MatAutocompleteModule,
-    ReactiveFormsModule,
-    MatTooltipModule,
-  ],
+    imports: [
+        CommonModule,
+        MatAutocompleteModule,
+        ReactiveFormsModule,
+        MatTooltipModule,
+        MatInputModule,
+        AutocompletePositionDirectiveModule
+    ],
   declarations: [VitamUIAutocompleteComponent],
   exports: [VitamUIAutocompleteComponent]
 })
diff --git a/ui/ui-frontend-common/src/app/modules/directives/autocomplete-position/autocomplete-position.directive.module.ts b/ui/ui-frontend-common/src/app/modules/directives/autocomplete-position/autocomplete-position.directive.module.ts
new file mode 100644
index 000000000..709d71369
--- /dev/null
+++ b/ui/ui-frontend-common/src/app/modules/directives/autocomplete-position/autocomplete-position.directive.module.ts
@@ -0,0 +1,52 @@
+/*
+ * Copyright French Prime minister Office/SGMAP/DINSIC/Vitam Program (2019-2020)
+ * and the signatories of the "VITAM - Accord du Contributeur" agreement.
+ *
+ * contact@programmevitam.fr
+ *
+ * This software is a computer program whose purpose is to implement
+ * implement a digital archiving front-office system for the secure and
+ * efficient high volumetry VITAM solution.
+ *
+ * This software is governed by the CeCILL-C license under French law and
+ * abiding by the rules of distribution of free software.  You can  use,
+ * modify and/ or redistribute the software under the terms of the CeCILL-C
+ * license as circulated by CEA, CNRS and INRIA at the following URL
+ * "http://www.cecill.info".
+ *
+ * As a counterpart to the access to the source code and  rights to copy,
+ * modify and redistribute granted by the license, users are provided only
+ * with a limited warranty  and the software's author,  the holder of the
+ * economic rights,  and the successive licensors  have only  limited
+ * liability.
+ *
+ * In this respect, the user's attention is drawn to the risks associated
+ * with loading,  using,  modifying and/or developing or reproducing the
+ * software by the user in light of its specific status of free software,
+ * that may mean  that it is complicated to manipulate,  and  that  also
+ * therefore means  that it is reserved for developers  and  experienced
+ * professionals having in-depth computer knowledge. Users are therefore
+ * encouraged to load and test the software's suitability as regards their
+ * requirements in conditions enabling the security of their systems and/or
+ * data to be ensured and,  more generally, to use and operate it in the
+ * same conditions as regards security.
+ *
+ * The fact that you are presently reading this means that you have had
+ * knowledge of the CeCILL-C license and that you accept its terms.
+ */
+import {CommonModule} from '@angular/common';
+import {NgModule} from '@angular/core';
+import {AutocompletePositionDirective} from "./autocomplete-position.directive";
+
+@NgModule({
+  imports: [
+    CommonModule,
+  ],
+  declarations: [
+    AutocompletePositionDirective
+  ],
+  exports: [
+    AutocompletePositionDirective
+  ]
+})
+export class AutocompletePositionDirectiveModule { }
diff --git a/ui/ui-frontend-common/src/app/modules/directives/autocomplete-position/autocomplete-position.directive.spec.ts b/ui/ui-frontend-common/src/app/modules/directives/autocomplete-position/autocomplete-position.directive.spec.ts
new file mode 100644
index 000000000..7b0b8e134
--- /dev/null
+++ b/ui/ui-frontend-common/src/app/modules/directives/autocomplete-position/autocomplete-position.directive.spec.ts
@@ -0,0 +1,44 @@
+/*
+ * Copyright French Prime minister Office/SGMAP/DINSIC/Vitam Program (2019-2020)
+ * and the signatories of the "VITAM - Accord du Contributeur" agreement.
+ *
+ * contact@programmevitam.fr
+ *
+ * This software is a computer program whose purpose is to implement
+ * implement a digital archiving front-office system for the secure and
+ * efficient high volumetry VITAM solution.
+ *
+ * This software is governed by the CeCILL-C license under French law and
+ * abiding by the rules of distribution of free software.  You can  use,
+ * modify and/ or redistribute the software under the terms of the CeCILL-C
+ * license as circulated by CEA, CNRS and INRIA at the following URL
+ * "http://www.cecill.info".
+ *
+ * As a counterpart to the access to the source code and  rights to copy,
+ * modify and redistribute granted by the license, users are provided only
+ * with a limited warranty  and the software's author,  the holder of the
+ * economic rights,  and the successive licensors  have only  limited
+ * liability.
+ *
+ * In this respect, the user's attention is drawn to the risks associated
+ * with loading,  using,  modifying and/or developing or reproducing the
+ * software by the user in light of its specific status of free software,
+ * that may mean  that it is complicated to manipulate,  and  that  also
+ * therefore means  that it is reserved for developers  and  experienced
+ * professionals having in-depth computer knowledge. Users are therefore
+ * encouraged to load and test the software's suitability as regards their
+ * requirements in conditions enabling the security of their systems and/or
+ * data to be ensured and,  more generally, to use and operate it in the
+ * same conditions as regards security.
+ *
+ * The fact that you are presently reading this means that you have had
+ * knowledge of the CeCILL-C license and that you accept its terms.
+ */
+import {AutocompletePositionDirective} from "./autocomplete-position.directive";
+
+describe('AutocompletePositionDirective', () => {
+  it('should create an instance', () => {
+    const directive = new AutocompletePositionDirective();
+    expect(directive).toBeTruthy();
+  });
+});
diff --git a/ui/ui-frontend-common/src/app/modules/directives/autocomplete-position/autocomplete-position.directive.ts b/ui/ui-frontend-common/src/app/modules/directives/autocomplete-position/autocomplete-position.directive.ts
new file mode 100644
index 000000000..cac864569
--- /dev/null
+++ b/ui/ui-frontend-common/src/app/modules/directives/autocomplete-position/autocomplete-position.directive.ts
@@ -0,0 +1,63 @@
+/*
+ * Copyright French Prime minister Office/SGMAP/DINSIC/Vitam Program (2019-2020)
+ * and the signatories of the "VITAM - Accord du Contributeur" agreement.
+ *
+ * contact@programmevitam.fr
+ *
+ * This software is a computer program whose purpose is to implement
+ * implement a digital archiving front-office system for the secure and
+ * efficient high volumetry VITAM solution.
+ *
+ * This software is governed by the CeCILL-C license under French law and
+ * abiding by the rules of distribution of free software.  You can  use,
+ * modify and/ or redistribute the software under the terms of the CeCILL-C
+ * license as circulated by CEA, CNRS and INRIA at the following URL
+ * "http://www.cecill.info".
+ *
+ * As a counterpart to the access to the source code and  rights to copy,
+ * modify and redistribute granted by the license, users are provided only
+ * with a limited warranty  and the software's author,  the holder of the
+ * economic rights,  and the successive licensors  have only  limited
+ * liability.
+ *
+ * In this respect, the user's attention is drawn to the risks associated
+ * with loading,  using,  modifying and/or developing or reproducing the
+ * software by the user in light of its specific status of free software,
+ * that may mean  that it is complicated to manipulate,  and  that  also
+ * therefore means  that it is reserved for developers  and  experienced
+ * professionals having in-depth computer knowledge. Users are therefore
+ * encouraged to load and test the software's suitability as regards their
+ * requirements in conditions enabling the security of their systems and/or
+ * data to be ensured and,  more generally, to use and operate it in the
+ * same conditions as regards security.
+ *
+ * The fact that you are presently reading this means that you have had
+ * knowledge of the CeCILL-C license and that you accept its terms.
+ */
+import { Directive, Input, OnDestroy } from '@angular/core';
+import { MatAutocompleteTrigger } from '@angular/material/autocomplete';
+
+@Directive({
+  selector: '[vitamuiAutocompletePosition]'
+})
+export class AutocompletePositionDirective implements OnDestroy {
+  private matAutocompleteTrigger: MatAutocompleteTrigger;
+
+  @Input('vitamuiAutocompletePosition') set autocompletePosition(value: MatAutocompleteTrigger) {
+    this.matAutocompleteTrigger = value;
+    window.addEventListener('scroll', this.scrollEvent, true);
+  }
+
+  private scrollEvent = (): void => {
+    if (this.matAutocompleteTrigger == null) {
+      return;
+    }
+    if (this.matAutocompleteTrigger.panelOpen) {
+      this.matAutocompleteTrigger.updatePosition();
+    }
+  };
+
+  ngOnDestroy() {
+    window.removeEventListener('scroll', this.scrollEvent, true);
+  }
+}
diff --git a/ui/ui-frontend-common/src/app/modules/vitamui-common.module.ts b/ui/ui-frontend-common/src/app/modules/vitamui-common.module.ts
index c1923798f..0a442c576 100644
--- a/ui/ui-frontend-common/src/app/modules/vitamui-common.module.ts
+++ b/ui/ui-frontend-common/src/app/modules/vitamui-common.module.ts
@@ -99,6 +99,7 @@ import { StartupService } from './startup.service';
 import { SubrogationModule } from './subrogation/subrogation.module';
 import { VitamUIHttpInterceptor } from './vitamui-http-interceptor';
 import {ResizeSidebarModule} from "./directives/resize-sidebar/resize-sidebar.module";
+import {AutocompletePositionDirectiveModule} from "./directives/autocomplete-position/autocomplete-position.directive.module";
 
 export function startupServiceFactory(startupService: StartupService) {
   // leave it like this due to run packagr issue :
@@ -166,7 +167,8 @@ export function startupServiceFactory(startupService: StartupService) {
     UserPhotoModule,
     VitamuiMenuButtonModule,
     VitamuiSidenavHeaderModule,
-    ResizeSidebarModule
+    ResizeSidebarModule,
+    AutocompletePositionDirectiveModule
   ],
   entryComponents: [
     ErrorDialogComponent
@@ -221,7 +223,8 @@ export function startupServiceFactory(startupService: StartupService) {
     CommonTooltipModule,
     VitamuiSidenavHeaderModule,
     VitamuiMenuButtonModule,
-    ResizeSidebarModule
+    ResizeSidebarModule,
+    AutocompletePositionDirectiveModule
   ],
   providers: [
     { provide: SUBROGRATION_REFRESH_RATE_MS, useValue: 10000 },
diff --git a/ui/ui-frontend/projects/identity/src/app/user/user-list/user-list.component.scss b/ui/ui-frontend/projects/identity/src/app/user/user-list/user-list.component.scss
index f3afb4f40..6a520f3f5 100644
--- a/ui/ui-frontend/projects/identity/src/app/user/user-list/user-list.component.scss
+++ b/ui/ui-frontend/projects/identity/src/app/user/user-list/user-list.component.scss
@@ -15,11 +15,9 @@
   height: 16px;
   display: block;
   position: absolute;
-  left: 100%;
-  top: 100%;
-  margin-left: -8px;
-  margin-top: -8px;
-  padding: 2px 3px 3px 4px;
+  margin-left: 15px;
+  margin-top: -9px;
+  padding: 0 3px 3px 4px;
   border-radius: 50%;
   background-color: var(--vitamui-grey-600);
   border: solid 2px $white;
@@ -41,7 +39,7 @@ vitamui-common-table-filter-option .vitamui-icon {
 .table-filter-icon {
   display: flex;
   align-items: center;
-  
+
   span.badge-state {
     color: var(--vitamui-grey-900);
     margin-left: 18px;
diff --git a/ui/ui-frontend/projects/identity/src/app/user/user-preview/user-preview.component.html b/ui/ui-frontend/projects/identity/src/app/user/user-preview/user-preview.component.html
index 09b99b673..31b8652eb 100644
--- a/ui/ui-frontend/projects/identity/src/app/user/user-preview/user-preview.component.html
+++ b/ui/ui-frontend/projects/identity/src/app/user/user-preview/user-preview.component.html
@@ -1,5 +1,5 @@
 <vitamui-common-sidenav-header
-  [badge]="user?.status === 'ENABLED' ? 'green' : (user?.status === 'DISABLED' || user?.status === 'ANONYM' ? 'grey' : 'orange')"
+  [badge]="user?.status === 'ENABLED' ? 'green' : ((user?.status === 'DISABLED' || user?.status === 'ANONYM' || user?.status === 'REMOVED') ? 'grey' : 'orange')"
   [title]="user?.lastname.toUpperCase() + ' ' + user?.firstname"
   [subtitle]="'(' +  user?.identifier + ')'"
   [icon]="'vitamui-icon-user'"
-- 
GitLab