From 7631ea157e666e772b0e687c2c63a1fe65910056 Mon Sep 17 00:00:00 2001
From: NOUMANE <ahmed.noumane@xelians.fr>
Date: Wed, 6 Jan 2021 20:05:31 +0100
Subject: [PATCH] [US TRTL-647] Input liste disabled fix

---
 .../vitamui-autocomplete.component.scss       |   8 +-
 .../components/inputs/inputs.component.html   |  15 +-
 .../app/components/inputs/inputs.component.ts |  21 +-
 .../app/services/CountryService.service.ts    |  15 ++
 .../starter-kit/src/assets/countries.json     | 247 ++++++++++++++++++
 5 files changed, 294 insertions(+), 12 deletions(-)
 create mode 100644 ui/ui-frontend/projects/starter-kit/src/app/services/CountryService.service.ts
 create mode 100644 ui/ui-frontend/projects/starter-kit/src/assets/countries.json

diff --git a/ui/ui-frontend-common/src/app/modules/components/vitamui-autocomplete/vitamui-autocomplete.component.scss b/ui/ui-frontend-common/src/app/modules/components/vitamui-autocomplete/vitamui-autocomplete.component.scss
index ae27b2436..90a431e9a 100644
--- a/ui/ui-frontend-common/src/app/modules/components/vitamui-autocomplete/vitamui-autocomplete.component.scss
+++ b/ui/ui-frontend-common/src/app/modules/components/vitamui-autocomplete/vitamui-autocomplete.component.scss
@@ -28,9 +28,7 @@ $animation-time: 150ms;
     > input {
       background: var(--vitamui-grey-300);
 
-      &:hover {
-        box-shadow: none !important;
-      }
+      box-shadow: none !important;
     }
 
     > i {
@@ -48,7 +46,7 @@ $animation-time: 150ms;
   }
 
   .input-label {
-  
+
     font-size: 14px;
     font-weight: 700;
     align-items: center;
@@ -70,7 +68,7 @@ $animation-time: 150ms;
 
     > input {
       padding-top: 30px;
-    
+
       font-size: 16px;
       font-weight: 700;
       color: var(--vitamui-grey-900);
diff --git a/ui/ui-frontend/projects/starter-kit/src/app/components/inputs/inputs.component.html b/ui/ui-frontend/projects/starter-kit/src/app/components/inputs/inputs.component.html
index 3fb63a3a8..d46ea4ff2 100644
--- a/ui/ui-frontend/projects/starter-kit/src/app/components/inputs/inputs.component.html
+++ b/ui/ui-frontend/projects/starter-kit/src/app/components/inputs/inputs.component.html
@@ -107,6 +107,15 @@
             </vitamui-common-editable-select>
         </div>
     </div>
+
+    <h4>Auto complete</h4>
+
+    <div class="d-flex justify-content-around">
+        <vitamui-common-vitamui-autocomplete [options]="countries" placeholder="Pays">
+        </vitamui-common-vitamui-autocomplete>
+        <vitamui-common-vitamui-autocomplete [options]="countries" [formControl]="autoCompletSelect" placeholder="Pays" disable="true">
+        </vitamui-common-vitamui-autocomplete>
+    </div>
     <h4>Textarea</h4>
     <div class="d-flex flex-column">
         <div class="row m-0 mt-4">
@@ -150,7 +159,7 @@
             <vitamui-common-slide-toggle class="mr-3" [checked]="true" [disabled]="true">Slide Toggle On disabled</vitamui-common-slide-toggle>
             <vitamui-common-slide-toggle class="mr-3" [checked]="false" [disabled]="true">Slide Toggle Off disabled</vitamui-common-slide-toggle>
         </div>
-       
+
     </div>
     <h4>Toggle Group</h4>
     <div class="d-flex flex-column">
@@ -166,7 +175,7 @@
                     <span>Last</span>
                 </mat-button-toggle>
             </mat-button-toggle-group>
-    
+
             <mat-button-toggle-group disabled [formControl]="control" class="vitamui-button-toggle-group disabled">
                 <mat-button-toggle [value]="'FIRST'">
                     <span>First</span>
@@ -231,4 +240,4 @@
             </vitamui-common-editable-file>
         </div>
     </div>
-</div>
\ No newline at end of file
+</div>
diff --git a/ui/ui-frontend/projects/starter-kit/src/app/components/inputs/inputs.component.ts b/ui/ui-frontend/projects/starter-kit/src/app/components/inputs/inputs.component.ts
index 03c380c52..5d554f20b 100644
--- a/ui/ui-frontend/projects/starter-kit/src/app/components/inputs/inputs.component.ts
+++ b/ui/ui-frontend/projects/starter-kit/src/app/components/inputs/inputs.component.ts
@@ -1,15 +1,18 @@
+import { CountryService } from './../../services/CountryService.service';
 import { Component, OnInit } from '@angular/core';
 import { FormControl, Validators } from '@angular/forms';
+import {Option} from "ui-frontend-common";
 
 @Component({
   selector: 'starter-kit-inputs',
   templateUrl: './inputs.component.html',
-  styleUrls: ['./inputs.component.scss']
+  styleUrls: ['./inputs.component.scss'],
+  providers: [CountryService]
 })
 export class InputsComponent implements OnInit {
 
   public control = new FormControl();
-  
+
   public streetEmpty = new FormControl('', [Validators.maxLength(3)]);
   public streetInvalid = new FormControl('azerty', [Validators.maxLength(3)]);
   public streetDisable = new FormControl('azerty', [Validators.maxLength(6)]);
@@ -25,7 +28,12 @@ export class InputsComponent implements OnInit {
   public duration = new FormControl( {days: 5, hours: 10, minutes: 5});
   public file = new FormControl( new File(['test'], 'test', {type: 'text/plain'}));
 
-  constructor() { }
+  countries: Option[];
+
+  autoCompletSelect = new FormControl();
+
+
+  constructor(private countryService: CountryService) { }
 
   onChange = (_: any) => {};
   onTouched = () => {};
@@ -39,6 +47,11 @@ export class InputsComponent implements OnInit {
     this.onTouched = fn;
   }
 
-  ngOnInit() { }
+  ngOnInit() {
+    this.countryService.getCountries().then(countries => {
+      this.countries = countries;
+  });
+    this.autoCompletSelect.disable({ emitEvent: false });
+  }
 
 }
diff --git a/ui/ui-frontend/projects/starter-kit/src/app/services/CountryService.service.ts b/ui/ui-frontend/projects/starter-kit/src/app/services/CountryService.service.ts
new file mode 100644
index 000000000..eca2424b3
--- /dev/null
+++ b/ui/ui-frontend/projects/starter-kit/src/app/services/CountryService.service.ts
@@ -0,0 +1,15 @@
+import { HttpClient } from '@angular/common/http';
+import { Injectable } from '@angular/core';
+
+@Injectable()
+export class CountryService {
+
+    constructor(private http: HttpClient) { }
+
+    getCountries() {
+    return this.http.get<any>('assets/countries.json')
+      .toPromise()
+      .then(res => <any[]>res.data)
+      .then(data => { return data; });
+    }
+}
diff --git a/ui/ui-frontend/projects/starter-kit/src/assets/countries.json b/ui/ui-frontend/projects/starter-kit/src/assets/countries.json
new file mode 100644
index 000000000..bc841c1d3
--- /dev/null
+++ b/ui/ui-frontend/projects/starter-kit/src/assets/countries.json
@@ -0,0 +1,247 @@
+{
+  "data": [
+    {"label": "Afghanistan","key": "AF"},
+    {"label": "Ã…land Islands","key": "AX"},
+    {"label": "Albania","key": "AL"},
+    {"label": "Algeria","key": "DZ"},
+    {"label": "American Samoa","key": "AS"},
+    {"label": "Andorra","key": "AD"},
+    {"label": "Angola","key": "AO"},
+    {"label": "Anguilla","key": "AI"},
+    {"label": "Antarctica","key": "AQ"},
+    {"label": "Antigua and Barbuda","key": "AG"},
+    {"label": "Argentina","key": "AR"},
+    {"label": "Armenia","key": "AM"},
+    {"label": "Aruba","key": "AW"},
+    {"label": "Australia","key": "AU"},
+    {"label": "Austria","key": "AT"},
+    {"label": "Azerbaijan","key": "AZ"},
+    {"label": "Bahamas","key": "BS"},
+    {"label": "Bahrain","key": "BH"},
+    {"label": "Bangladesh","key": "BD"},
+    {"label": "Barbados","key": "BB"},
+    {"label": "Belarus","key": "BY"},
+    {"label": "Belgium","key": "BE"},
+    {"label": "Belize","key": "BZ"},
+    {"label": "Benin","key": "BJ"},
+    {"label": "Bermuda","key": "BM"},
+    {"label": "Bhutan","key": "BT"},
+    {"label": "Bolivia","key": "BO"},
+    {"label": "Bosnia and Herzegovina","key": "BA"},
+    {"label": "Botswana","key": "BW"},
+    {"label": "Bouvet Island","key": "BV"},
+    {"label": "Brazil","key": "BR"},
+    {"label": "British Indian Ocean Territory","key": "IO"},
+    {"label": "Brunei Darussalam","key": "BN"},
+    {"label": "Bulgaria","key": "BG"},
+    {"label": "Burkina Faso","key": "BF"},
+    {"label": "Burundi","key": "BI"},
+    {"label": "Cambodia","key": "KH"},
+    {"label": "Cameroon","key": "CM"},
+    {"label": "Canada","key": "CA"},
+    {"label": "Cape Verde","key": "CV"},
+    {"label": "Cayman Islands","key": "KY"},
+    {"label": "Central African Republic","key": "CF"},
+    {"label": "Chad","key": "TD"},
+    {"label": "Chile","key": "CL"},
+    {"label": "China","key": "CN"},
+    {"label": "Christmas Island","key": "CX"},
+    {"label": "Cocos (Keeling) Islands","key": "CC"},
+    {"label": "Colombia","key": "CO"},
+    {"label": "Comoros","key": "KM"},
+    {"label": "Congo","key": "CG"},
+    {"label": "Congo, The Democratic Republic of the","key": "CD"},
+    {"label": "Cook Islands","key": "CK"},
+    {"label": "Costa Rica","key": "CR"},
+    {"label": "Cote D\"Ivoire","key": "CI"},
+    {"label": "Croatia","key": "HR"},
+    {"label": "Cuba","key": "CU"},
+    {"label": "Cyprus","key": "CY"},
+    {"label": "Czech Republic","key": "CZ"},
+    {"label": "Denmark","key": "DK"},
+    {"label": "Djibouti","key": "DJ"},
+    {"label": "Dominica","key": "DM"},
+    {"label": "Dominican Republic","key": "DO"},
+    {"label": "Ecuador","key": "EC"},
+    {"label": "Egypt","key": "EG"},
+    {"label": "El Salvador","key": "SV"},
+    {"label": "Equatorial Guinea","key": "GQ"},
+    {"label": "Eritrea","key": "ER"},
+    {"label": "Estonia","key": "EE"},
+    {"label": "Ethiopia","key": "ET"},
+    {"label": "Falkland Islands (Malvinas)","key": "FK"},
+    {"label": "Faroe Islands","key": "FO"},
+    {"label": "Fiji","key": "FJ"},
+    {"label": "Finland","key": "FI"},
+    {"label": "France","key": "FR"},
+    {"label": "French Guiana","key": "GF"},
+    {"label": "French Polynesia","key": "PF"},
+    {"label": "French Southern Territories","key": "TF"},
+    {"label": "Gabon","key": "GA"},
+    {"label": "Gambia","key": "GM"},
+    {"label": "Georgia","key": "GE"},
+    {"label": "Germany","key": "DE"},
+    {"label": "Ghana","key": "GH"},
+    {"label": "Gibraltar","key": "GI"},
+    {"label": "Greece","key": "GR"},
+    {"label": "Greenland","key": "GL"},
+    {"label": "Grenada","key": "GD"},
+    {"label": "Guadeloupe","key": "GP"},
+    {"label": "Guam","key": "GU"},
+    {"label": "Guatemala","key": "GT"},
+    {"label": "Guernsey","key": "GG"},
+    {"label": "Guinea","key": "GN"},
+    {"label": "Guinea-Bissau","key": "GW"},
+    {"label": "Guyana","key": "GY"},
+    {"label": "Haiti","key": "HT"},
+    {"label": "Heard Island and Mcdonald Islands","key": "HM"},
+    {"label": "Holy See (Vatican City State)","key": "VA"},
+    {"label": "Honduras","key": "HN"},
+    {"label": "Hong Kong","key": "HK"},
+    {"label": "Hungary","key": "HU"},
+    {"label": "Iceland","key": "IS"},
+    {"label": "India","key": "IN"},
+    {"label": "Indonesia","key": "ID"},
+    {"label": "Iran, Islamic Republic Of","key": "IR"},
+    {"label": "Iraq","key": "IQ"},
+    {"label": "Ireland","key": "IE"},
+    {"label": "Isle of Man","key": "IM"},
+    {"label": "Israel","key": "IL"},
+    {"label": "Italy","key": "IT"},
+    {"label": "Jamaica","key": "JM"},
+    {"label": "Japan","key": "JP"},
+    {"label": "Jersey","key": "JE"},
+    {"label": "Jordan","key": "JO"},
+    {"label": "Kazakhstan","key": "KZ"},
+    {"label": "Kenya","key": "KE"},
+    {"label": "Kiribati","key": "KI"},
+    {"label": "Korea, Democratic People\"S Republic of","key": "KP"},
+    {"label": "Korea, Republic of","key": "KR"},
+    {"label": "Kuwait","key": "KW"},
+    {"label": "Kyrgyzstan","key": "KG"},
+    {"label": "Lao People\"S Democratic Republic","key": "LA"},
+    {"label": "Latvia","key": "LV"},
+    {"label": "Lebanon","key": "LB"},
+    {"label": "Lesotho","key": "LS"},
+    {"label": "Liberia","key": "LR"},
+    {"label": "Libyan Arab Jamahiriya","key": "LY"},
+    {"label": "Liechtenstein","key": "LI"},
+    {"label": "Lithuania","key": "LT"},
+    {"label": "Luxembourg","key": "LU"},
+    {"label": "Macao","key": "MO"},
+    {"label": "Macedonia, The Former Yugoslav Republic of","key": "MK"},
+    {"label": "Madagascar","key": "MG"},
+    {"label": "Malawi","key": "MW"},
+    {"label": "Malaysia","key": "MY"},
+    {"label": "Maldives","key": "MV"},
+    {"label": "Mali","key": "ML"},
+    {"label": "Malta","key": "MT"},
+    {"label": "Marshall Islands","key": "MH"},
+    {"label": "Martinique","key": "MQ"},
+    {"label": "Mauritania","key": "MR"},
+    {"label": "Mauritius","key": "MU"},
+    {"label": "Mayotte","key": "YT"},
+    {"label": "Mexico","key": "MX"},
+    {"label": "Micronesia, Federated States of","key": "FM"},
+    {"label": "Moldova, Republic of","key": "MD"},
+    {"label": "Monaco","key": "MC"},
+    {"label": "Mongolia","key": "MN"},
+    {"label": "Montserrat","key": "MS"},
+    {"label": "Morocco","key": "MA"},
+    {"label": "Mozambique","key": "MZ"},
+    {"label": "Myanmar","key": "MM"},
+    {"label": "Namibia","key": "NA"},
+    {"label": "Nauru","key": "NR"},
+    {"label": "Nepal","key": "NP"},
+    {"label": "Netherlands","key": "NL"},
+    {"label": "Netherlands Antilles","key": "AN"},
+    {"label": "New Caledonia","key": "NC"},
+    {"label": "New Zealand","key": "NZ"},
+    {"label": "Nicaragua","key": "NI"},
+    {"label": "Niger","key": "NE"},
+    {"label": "Nigeria","key": "NG"},
+    {"label": "Niue","key": "NU"},
+    {"label": "Norfolk Island","key": "NF"},
+    {"label": "Northern Mariana Islands","key": "MP"},
+    {"label": "Norway","key": "NO"},
+    {"label": "Oman","key": "OM"},
+    {"label": "Pakistan","key": "PK"},
+    {"label": "Palau","key": "PW"},
+    {"label": "Palestinian Territory, Occupied","key": "PS"},
+    {"label": "Panama","key": "PA"},
+    {"label": "Papua New Guinea","key": "PG"},
+    {"label": "Paraguay","key": "PY"},
+    {"label": "Peru","key": "PE"},
+    {"label": "Philippines","key": "PH"},
+    {"label": "Pitcairn","key": "PN"},
+    {"label": "Poland","key": "PL"},
+    {"label": "Portugal","key": "PT"},
+    {"label": "Puerto Rico","key": "PR"},
+    {"label": "Qatar","key": "QA"},
+    {"label": "Reunion","key": "RE"},
+    {"label": "Romania","key": "RO"},
+    {"label": "Russian Federation","key": "RU"},
+    {"label": "RWANDA","key": "RW"},
+    {"label": "Saint Helena","key": "SH"},
+    {"label": "Saint Kitts and Nevis","key": "KN"},
+    {"label": "Saint Lucia","key": "LC"},
+    {"label": "Saint Pierre and Miquelon","key": "PM"},
+    {"label": "Saint Vincent and the Grenadines","key": "VC"},
+    {"label": "Samoa","key": "WS"},
+    {"label": "San Marino","key": "SM"},
+    {"label": "Sao Tome and Principe","key": "ST"},
+    {"label": "Saudi Arabia","key": "SA"},
+    {"label": "Senegal","key": "SN"},
+    {"label": "Serbia and Montenegro","key": "CS"},
+    {"label": "Seychelles","key": "SC"},
+    {"label": "Sierra Leone","key": "SL"},
+    {"label": "Singapore","key": "SG"},
+    {"label": "Slovakia","key": "SK"},
+    {"label": "Slovenia","key": "SI"},
+    {"label": "Solomon Islands","key": "SB"},
+    {"label": "Somalia","key": "SO"},
+    {"label": "South Africa","key": "ZA"},
+    {"label": "South Georgia and the South Sandwich Islands","key": "GS"},
+    {"label": "Spain","key": "ES"},
+    {"label": "Sri Lanka","key": "LK"},
+    {"label": "Sudan","key": "SD"},
+    {"label": "Suriname","key": "SR"},
+    {"label": "Svalbard and Jan Mayen","key": "SJ"},
+    {"label": "Swaziland","key": "SZ"},
+    {"label": "Sweden","key": "SE"},
+    {"label": "Switzerland","key": "CH"},
+    {"label": "Syrian Arab Republic","key": "SY"},
+    {"label": "Taiwan, Republic of China","key": "TW"},
+    {"label": "Tajikistan","key": "TJ"},
+    {"label": "Tanzania, United Republic of","key": "TZ"},
+    {"label": "Thailand","key": "TH"},
+    {"label": "Timor-Leste","key": "TL"},
+    {"label": "Togo","key": "TG"},
+    {"label": "Tokelau","key": "TK"},
+    {"label": "Tonga","key": "TO"},
+    {"label": "Trinidad and Tobago","key": "TT"},
+    {"label": "Tunisia","key": "TN"},
+    {"label": "Turkey","key": "TR"},
+    {"label": "Turkmenistan","key": "TM"},
+    {"label": "Turks and Caicos Islands","key": "TC"},
+    {"label": "Tuvalu","key": "TV"},
+    {"label": "Uganda","key": "UG"},
+    {"label": "Ukraine","key": "UA"},
+    {"label": "United Arab Emirates","key": "AE"},
+    {"label": "United Kingdom","key": "GB"},
+    {"label": "United States","key": "US"},
+    {"label": "United States Minor Outlying Islands","key": "UM"},
+    {"label": "Uruguay","key": "UY"},
+    {"label": "Uzbekistan","key": "UZ"},
+    {"label": "Vanuatu","key": "VU"},
+    {"label": "Venezuela","key": "VE"},
+    {"label": "Viet Nam","key": "VN"},
+    {"label": "Virgin Islands, British","key": "VG"},
+    {"label": "Virgin Islands, U.S.","key": "VI"},
+    {"label": "Wallis and Futuna","key": "WF"},
+    {"label": "Western Sahara","key": "EH"},
+    {"label": "Yemen","key": "YE"},
+    {"label": "Zambia","key": "ZM"},
+    {"label": "Zimbabwe","key": "ZW"}
+  ]
+}
\ No newline at end of file
-- 
GitLab