From ee9b1b89a9dfbe842276158487b8e08270148dcc Mon Sep 17 00:00:00 2001 From: Axel Peter Date: Fri, 2 Nov 2018 16:14:15 +0100 Subject: [PATCH] feat(oui-autocomplete): add oui-autocomplete directive --- .../controllers/autocomplete.controller.js | 8 + .../controllers/data/autocomplete.data.json | 492 ++++++++++++++++++ src/ovh-ui-angular/controllers/index.js | 2 + .../controllers/search.controller.js | 3 + src/ovh-ui-angular/ovh-ui-angular.config.json | 4 + 5 files changed, 509 insertions(+) create mode 100644 src/ovh-ui-angular/controllers/autocomplete.controller.js create mode 100644 src/ovh-ui-angular/controllers/data/autocomplete.data.json diff --git a/src/ovh-ui-angular/controllers/autocomplete.controller.js b/src/ovh-ui-angular/controllers/autocomplete.controller.js new file mode 100644 index 0000000..796d7e0 --- /dev/null +++ b/src/ovh-ui-angular/controllers/autocomplete.controller.js @@ -0,0 +1,8 @@ +import data from "./data/autocomplete.data.json"; + +export default class { + $onInit () { + this.suggestionStrings = angular.copy(data.strings); + this.suggestionObjects = angular.copy(data.objects); + } +} diff --git a/src/ovh-ui-angular/controllers/data/autocomplete.data.json b/src/ovh-ui-angular/controllers/data/autocomplete.data.json new file mode 100644 index 0000000..6549aef --- /dev/null +++ b/src/ovh-ui-angular/controllers/data/autocomplete.data.json @@ -0,0 +1,492 @@ +{ + "strings": [ + "Afghanistan", + "Åland Islands", + "Albania", + "Algeria", + "American Samoa", + "AndorrA", + "Angola", + "Anguilla", + "Antarctica", + "Antigua and Barbuda", + "Argentina", + "Armenia", + "Aruba", + "Australia", + "Austria", + "Azerbaijan", + "Bahamas", + "Bahrain", + "Bangladesh", + "Barbados", + "Belarus", + "Belgium", + "Belize", + "Benin", + "Bermuda", + "Bhutan", + "Bolivia", + "Bosnia and Herzegovina", + "Botswana", + "Bouvet Island", + "Brazil", + "British Indian Ocean Territory", + "Brunei Darussalam", + "Bulgaria", + "Burkina Faso", + "Burundi", + "Cambodia", + "Cameroon", + "Canada", + "Cape Verde", + "Cayman Islands", + "Central African Republic", + "Chad", + "Chile", + "China", + "Christmas Island", + "Cocos (Keeling) Islands", + "Colombia", + "Comoros", + "Congo", + "Congo, The Democratic Republic of the", + "Cook Islands", + "Costa Rica", + "Cote D'Ivoire", + "Croatia", + "Cuba", + "Cyprus", + "Czech Republic", + "Denmark", + "Djibouti", + "Dominica", + "Dominican Republic", + "Ecuador", + "Egypt", + "El Salvador", + "Equatorial Guinea", + "Eritrea", + "Estonia", + "Ethiopia", + "Falkland Islands (Malvinas", + "Faroe Islands", + "Fiji", + "Finland", + "France", + "French Guiana", + "French Polynesia", + "French Southern Territories", + "Gabon", + "Gambia", + "Georgia", + "Germany", + "Ghana", + "Gibraltar", + "Greece", + "Greenland", + "Grenada", + "Guadeloupe", + "Guam", + "Guatemala", + "Guernsey", + "Guinea", + "Guinea-Bissau", + "Guyana", + "Haiti", + "Heard Island and Mcdonald Islands", + "Holy See (Vatican City State", + "Honduras", + "Hong Kong", + "Hungary", + "Iceland", + "India", + "Indonesia", + "Iran, Islamic Republic Of", + "Iraq", + "Ireland", + "Isle of Man", + "Israel", + "Italy", + "Jamaica", + "Japan", + "Jersey", + "Jordan", + "Kazakhstan", + "Kenya", + "Kiribati", + "Korea, Democratic People's Republic of", + "Korea, Republic of", + "Kuwait", + "Kyrgyzstan", + "Lao People's Democratic Republic", + "Latvia", + "Lebanon", + "Lesotho", + "Liberia", + "Libyan Arab Jamahiriya", + "Liechtenstein", + "Lithuania", + "Luxembourg", + "Macao", + "Macedonia, The Former Yugoslav Republic of", + "Madagascar", + "Malawi", + "Malaysia", + "Maldives", + "Mali", + "Malta", + "Marshall Islands", + "Martinique", + "Mauritania", + "Mauritius", + "Mayotte", + "Mexico", + "Micronesia, Federated States of", + "Moldova, Republic of", + "Monaco", + "Mongolia", + "Montserrat", + "Morocco", + "Mozambique", + "Myanmar", + "Namibia", + "Nauru", + "Nepal", + "Netherlands", + "Netherlands Antilles", + "New Caledonia", + "New Zealand", + "Nicaragua", + "Niger", + "Nigeria", + "Niue", + "Norfolk Island", + "Northern Mariana Islands", + "Norway", + "Oman", + "Pakistan", + "Palau", + "Palestinian Territory, Occupied", + "Panama", + "Papua New Guinea", + "Paraguay", + "Peru", + "Philippines", + "Pitcairn", + "Poland", + "Portugal", + "Puerto Rico", + "Qatar", + "Reunion", + "Romania", + "Russian Federation", + "RWANDA", + "Saint Helena", + "Saint Kitts and Nevis", + "Saint Lucia", + "Saint Pierre and Miquelon", + "Saint Vincent and the Grenadines", + "Samoa", + "San Marino", + "Sao Tome and Principe", + "Saudi Arabia", + "Senegal", + "Serbia and Montenegro", + "Seychelles", + "Sierra Leone", + "Singapore", + "Slovakia", + "Slovenia", + "Solomon Islands", + "Somalia", + "South Africa", + "South Georgia and the South Sandwich Islands", + "Spain", + "Sri Lanka", + "Sudan", + "Suriname", + "Svalbard and Jan Mayen", + "Swaziland", + "Sweden", + "Switzerland", + "Syrian Arab Republic", + "Taiwan, Province of China", + "Tajikistan", + "Tanzania, United Republic of", + "Thailand", + "Timor-Leste", + "Togo", + "Tokelau", + "Tonga", + "Trinidad and Tobago", + "Tunisia", + "Turkey", + "Turkmenistan", + "Turks and Caicos Islands", + "Tuvalu", + "Uganda", + "Ukraine", + "United Arab Emirates", + "United Kingdom", + "United States", + "United States Minor Outlying Islands", + "Uruguay", + "Uzbekistan", + "Vanuatu", + "Venezuela", + "Viet Nam", + "Virgin Islands, British", + "Virgin Islands, U.S", + "Wallis and Futuna", + "Western Sahara", + "Yemen", + "Zambia", + "Zimbabwe" + ], + "objects": [ + { "country": { "name": "Afghanistan", "code": "AF" } }, + { "country": { "name": "Åland Islands", "code": "AX" } }, + { "country": { "name": "Albania", "code": "AL" } }, + { "country": { "name": "Algeria", "code": "DZ" } }, + { "country": { "name": "American Samoa", "code": "AS" } }, + { "country": { "name": "AndorrA", "code": "AD" } }, + { "country": { "name": "Angola", "code": "AO" } }, + { "country": { "name": "Anguilla", "code": "AI" } }, + { "country": { "name": "Antarctica", "code": "AQ" } }, + { "country": { "name": "Antigua and Barbuda", "code": "AG" } }, + { "country": { "name": "Argentina", "code": "AR" } }, + { "country": { "name": "Armenia", "code": "AM" } }, + { "country": { "name": "Aruba", "code": "AW" } }, + { "country": { "name": "Australia", "code": "AU" } }, + { "country": { "name": "Austria", "code": "AT" } }, + { "country": { "name": "Azerbaijan", "code": "AZ" } }, + { "country": { "name": "Bahamas", "code": "BS" } }, + { "country": { "name": "Bahrain", "code": "BH" } }, + { "country": { "name": "Bangladesh", "code": "BD" } }, + { "country": { "name": "Barbados", "code": "BB" } }, + { "country": { "name": "Belarus", "code": "BY" } }, + { "country": { "name": "Belgium", "code": "BE" } }, + { "country": { "name": "Belize", "code": "BZ" } }, + { "country": { "name": "Benin", "code": "BJ" } }, + { "country": { "name": "Bermuda", "code": "BM" } }, + { "country": { "name": "Bhutan", "code": "BT" } }, + { "country": { "name": "Bolivia", "code": "BO" } }, + { "country": { "name": "Bosnia and Herzegovina", "code": "BA" } }, + { "country": { "name": "Botswana", "code": "BW" } }, + { "country": { "name": "Bouvet Island", "code": "BV" } }, + { "country": { "name": "Brazil", "code": "BR" } }, + { "country": { "name": "British Indian Ocean Territory", "code": "IO" } }, + { "country": { "name": "Brunei Darussalam", "code": "BN" } }, + { "country": { "name": "Bulgaria", "code": "BG" } }, + { "country": { "name": "Burkina Faso", "code": "BF" } }, + { "country": { "name": "Burundi", "code": "BI" } }, + { "country": { "name": "Cambodia", "code": "KH" } }, + { "country": { "name": "Cameroon", "code": "CM" } }, + { "country": { "name": "Canada", "code": "CA" } }, + { "country": { "name": "Cape Verde", "code": "CV" } }, + { "country": { "name": "Cayman Islands", "code": "KY" } }, + { "country": { "name": "Central African Republic", "code": "CF" } }, + { "country": { "name": "Chad", "code": "TD" } }, + { "country": { "name": "Chile", "code": "CL" } }, + { "country": { "name": "China", "code": "CN" } }, + { "country": { "name": "Christmas Island", "code": "CX" } }, + { "country": { "name": "Cocos (Keeling) Islands", "code": "CC" } }, + { "country": { "name": "Colombia", "code": "CO" } }, + { "country": { "name": "Comoros", "code": "KM" } }, + { "country": { "name": "Congo", "code": "CG" } }, + { "country": { "name": "Congo, The Democratic Republic of the", "code": "CD" } }, + { "country": { "name": "Cook Islands", "code": "CK" } }, + { "country": { "name": "Costa Rica", "code": "CR" } }, + { "country": { "name": "Cote D'Ivoire", "code": "CI" } }, + { "country": { "name": "Croatia", "code": "HR" } }, + { "country": { "name": "Cuba", "code": "CU" } }, + { "country": { "name": "Cyprus", "code": "CY" } }, + { "country": { "name": "Czech Republic", "code": "CZ" } }, + { "country": { "name": "Denmark", "code": "DK" } }, + { "country": { "name": "Djibouti", "code": "DJ" } }, + { "country": { "name": "Dominica", "code": "DM" } }, + { "country": { "name": "Dominican Republic", "code": "DO" } }, + { "country": { "name": "Ecuador", "code": "EC" } }, + { "country": { "name": "Egypt", "code": "EG" } }, + { "country": { "name": "El Salvador", "code": "SV" } }, + { "country": { "name": "Equatorial Guinea", "code": "GQ" } }, + { "country": { "name": "Eritrea", "code": "ER" } }, + { "country": { "name": "Estonia", "code": "EE" } }, + { "country": { "name": "Ethiopia", "code": "ET" } }, + { "country": { "name": "Falkland Islands (Malvinas", "code": "FK" } }, + { "country": { "name": "Faroe Islands", "code": "FO" } }, + { "country": { "name": "Fiji", "code": "FJ" } }, + { "country": { "name": "Finland", "code": "FI" } }, + { "country": { "name": "France", "code": "FR" } }, + { "country": { "name": "French Guiana", "code": "GF" } }, + { "country": { "name": "French Polynesia", "code": "PF" } }, + { "country": { "name": "French Southern Territories", "code": "TF" } }, + { "country": { "name": "Gabon", "code": "GA" } }, + { "country": { "name": "Gambia", "code": "GM" } }, + { "country": { "name": "Georgia", "code": "GE" } }, + { "country": { "name": "Germany", "code": "DE" } }, + { "country": { "name": "Ghana", "code": "GH" } }, + { "country": { "name": "Gibraltar", "code": "GI" } }, + { "country": { "name": "Greece", "code": "GR" } }, + { "country": { "name": "Greenland", "code": "GL" } }, + { "country": { "name": "Grenada", "code": "GD" } }, + { "country": { "name": "Guadeloupe", "code": "GP" } }, + { "country": { "name": "Guam", "code": "GU" } }, + { "country": { "name": "Guatemala", "code": "GT" } }, + { "country": { "name": "Guernsey", "code": "GG" } }, + { "country": { "name": "Guinea", "code": "GN" } }, + { "country": { "name": "Guinea-Bissau", "code": "GW" } }, + { "country": { "name": "Guyana", "code": "GY" } }, + { "country": { "name": "Haiti", "code": "HT" } }, + { "country": { "name": "Heard Island and Mcdonald Islands", "code": "HM" } }, + { "country": { "name": "Holy See (Vatican City State", "code": "VA" } }, + { "country": { "name": "Honduras", "code": "HN" } }, + { "country": { "name": "Hong Kong", "code": "HK" } }, + { "country": { "name": "Hungary", "code": "HU" } }, + { "country": { "name": "Iceland", "code": "IS" } }, + { "country": { "name": "India", "code": "IN" } }, + { "country": { "name": "Indonesia", "code": "ID" } }, + { "country": { "name": "Iran, Islamic Republic Of", "code": "IR" } }, + { "country": { "name": "Iraq", "code": "IQ" } }, + { "country": { "name": "Ireland", "code": "IE" } }, + { "country": { "name": "Isle of Man", "code": "IM" } }, + { "country": { "name": "Israel", "code": "IL" } }, + { "country": { "name": "Italy", "code": "IT" } }, + { "country": { "name": "Jamaica", "code": "JM" } }, + { "country": { "name": "Japan", "code": "JP" } }, + { "country": { "name": "Jersey", "code": "JE" } }, + { "country": { "name": "Jordan", "code": "JO" } }, + { "country": { "name": "Kazakhstan", "code": "KZ" } }, + { "country": { "name": "Kenya", "code": "KE" } }, + { "country": { "name": "Kiribati", "code": "KI" } }, + { "country": { "name": "Korea, Democratic People's Republic of", "code": "KP" } }, + { "country": { "name": "Korea, Republic of", "code": "KR" } }, + { "country": { "name": "Kuwait", "code": "KW" } }, + { "country": { "name": "Kyrgyzstan", "code": "KG" } }, + { "country": { "name": "Lao People's Democratic Republic", "code": "LA" } }, + { "country": { "name": "Latvia", "code": "LV" } }, + { "country": { "name": "Lebanon", "code": "LB" } }, + { "country": { "name": "Lesotho", "code": "LS" } }, + { "country": { "name": "Liberia", "code": "LR" } }, + { "country": { "name": "Libyan Arab Jamahiriya", "code": "LY" } }, + { "country": { "name": "Liechtenstein", "code": "LI" } }, + { "country": { "name": "Lithuania", "code": "LT" } }, + { "country": { "name": "Luxembourg", "code": "LU" } }, + { "country": { "name": "Macao", "code": "MO" } }, + { "country": { "name": "Macedonia, The Former Yugoslav Republic of", "code": "MK" } }, + { "country": { "name": "Madagascar", "code": "MG" } }, + { "country": { "name": "Malawi", "code": "MW" } }, + { "country": { "name": "Malaysia", "code": "MY" } }, + { "country": { "name": "Maldives", "code": "MV" } }, + { "country": { "name": "Mali", "code": "ML" } }, + { "country": { "name": "Malta", "code": "MT" } }, + { "country": { "name": "Marshall Islands", "code": "MH" } }, + { "country": { "name": "Martinique", "code": "MQ" } }, + { "country": { "name": "Mauritania", "code": "MR" } }, + { "country": { "name": "Mauritius", "code": "MU" } }, + { "country": { "name": "Mayotte", "code": "YT" } }, + { "country": { "name": "Mexico", "code": "MX" } }, + { "country": { "name": "Micronesia, Federated States of", "code": "FM" } }, + { "country": { "name": "Moldova, Republic of", "code": "MD" } }, + { "country": { "name": "Monaco", "code": "MC" } }, + { "country": { "name": "Mongolia", "code": "MN" } }, + { "country": { "name": "Montserrat", "code": "MS" } }, + { "country": { "name": "Morocco", "code": "MA" } }, + { "country": { "name": "Mozambique", "code": "MZ" } }, + { "country": { "name": "Myanmar", "code": "MM" } }, + { "country": { "name": "Namibia", "code": "NA" } }, + { "country": { "name": "Nauru", "code": "NR" } }, + { "country": { "name": "Nepal", "code": "NP" } }, + { "country": { "name": "Netherlands", "code": "NL" } }, + { "country": { "name": "Netherlands Antilles", "code": "AN" } }, + { "country": { "name": "New Caledonia", "code": "NC" } }, + { "country": { "name": "New Zealand", "code": "NZ" } }, + { "country": { "name": "Nicaragua", "code": "NI" } }, + { "country": { "name": "Niger", "code": "NE" } }, + { "country": { "name": "Nigeria", "code": "NG" } }, + { "country": { "name": "Niue", "code": "NU" } }, + { "country": { "name": "Norfolk Island", "code": "NF" } }, + { "country": { "name": "Northern Mariana Islands", "code": "MP" } }, + { "country": { "name": "Norway", "code": "NO" } }, + { "country": { "name": "Oman", "code": "OM" } }, + { "country": { "name": "Pakistan", "code": "PK" } }, + { "country": { "name": "Palau", "code": "PW" } }, + { "country": { "name": "Palestinian Territory, Occupied", "code": "PS" } }, + { "country": { "name": "Panama", "code": "PA" } }, + { "country": { "name": "Papua New Guinea", "code": "PG" } }, + { "country": { "name": "Paraguay", "code": "PY" } }, + { "country": { "name": "Peru", "code": "PE" } }, + { "country": { "name": "Philippines", "code": "PH" } }, + { "country": { "name": "Pitcairn", "code": "PN" } }, + { "country": { "name": "Poland", "code": "PL" } }, + { "country": { "name": "Portugal", "code": "PT" } }, + { "country": { "name": "Puerto Rico", "code": "PR" } }, + { "country": { "name": "Qatar", "code": "QA" } }, + { "country": { "name": "Reunion", "code": "RE" } }, + { "country": { "name": "Romania", "code": "RO" } }, + { "country": { "name": "Russian Federation", "code": "RU" } }, + { "country": { "name": "RWANDA", "code": "RW" } }, + { "country": { "name": "Saint Helena", "code": "SH" } }, + { "country": { "name": "Saint Kitts and Nevis", "code": "KN" } }, + { "country": { "name": "Saint Lucia", "code": "LC" } }, + { "country": { "name": "Saint Pierre and Miquelon", "code": "PM" } }, + { "country": { "name": "Saint Vincent and the Grenadines", "code": "VC" } }, + { "country": { "name": "Samoa", "code": "WS" } }, + { "country": { "name": "San Marino", "code": "SM" } }, + { "country": { "name": "Sao Tome and Principe", "code": "ST" } }, + { "country": { "name": "Saudi Arabia", "code": "SA" } }, + { "country": { "name": "Senegal", "code": "SN" } }, + { "country": { "name": "Serbia and Montenegro", "code": "CS" } }, + { "country": { "name": "Seychelles", "code": "SC" } }, + { "country": { "name": "Sierra Leone", "code": "SL" } }, + { "country": { "name": "Singapore", "code": "SG" } }, + { "country": { "name": "Slovakia", "code": "SK" } }, + { "country": { "name": "Slovenia", "code": "SI" } }, + { "country": { "name": "Solomon Islands", "code": "SB" } }, + { "country": { "name": "Somalia", "code": "SO" } }, + { "country": { "name": "South Africa", "code": "ZA" } }, + { "country": { "name": "South Georgia and the South Sandwich Islands", "code": "GS" } }, + { "country": { "name": "Spain", "code": "ES" } }, + { "country": { "name": "Sri Lanka", "code": "LK" } }, + { "country": { "name": "Sudan", "code": "SD" } }, + { "country": { "name": "Suriname", "code": "SR" } }, + { "country": { "name": "Svalbard and Jan Mayen", "code": "SJ" } }, + { "country": { "name": "Swaziland", "code": "SZ" } }, + { "country": { "name": "Sweden", "code": "SE" } }, + { "country": { "name": "Switzerland", "code": "CH" } }, + { "country": { "name": "Syrian Arab Republic", "code": "SY" } }, + { "country": { "name": "Taiwan, Province of China", "code": "TW" } }, + { "country": { "name": "Tajikistan", "code": "TJ" } }, + { "country": { "name": "Tanzania, United Republic of", "code": "TZ" } }, + { "country": { "name": "Thailand", "code": "TH" } }, + { "country": { "name": "Timor-Leste", "code": "TL" } }, + { "country": { "name": "Togo", "code": "TG" } }, + { "country": { "name": "Tokelau", "code": "TK" } }, + { "country": { "name": "Tonga", "code": "TO" } }, + { "country": { "name": "Trinidad and Tobago", "code": "TT" } }, + { "country": { "name": "Tunisia", "code": "TN" } }, + { "country": { "name": "Turkey", "code": "TR" } }, + { "country": { "name": "Turkmenistan", "code": "TM" } }, + { "country": { "name": "Turks and Caicos Islands", "code": "TC" } }, + { "country": { "name": "Tuvalu", "code": "TV" } }, + { "country": { "name": "Uganda", "code": "UG" } }, + { "country": { "name": "Ukraine", "code": "UA" } }, + { "country": { "name": "United Arab Emirates", "code": "AE" } }, + { "country": { "name": "United Kingdom", "code": "GB" } }, + { "country": { "name": "United States", "code": "US" } }, + { "country": { "name": "United States Minor Outlying Islands", "code": "UM" } }, + { "country": { "name": "Uruguay", "code": "UY" } }, + { "country": { "name": "Uzbekistan", "code": "UZ" } }, + { "country": { "name": "Vanuatu", "code": "VU" } }, + { "country": { "name": "Venezuela", "code": "VE" } }, + { "country": { "name": "Viet Nam", "code": "VN" } }, + { "country": { "name": "Virgin Islands, British", "code": "VG" } }, + { "country": { "name": "Virgin Islands, U.S", "code": "VI" } }, + { "country": { "name": "Wallis and Futuna", "code": "WF" } }, + { "country": { "name": "Western Sahara", "code": "EH" } }, + { "country": { "name": "Yemen", "code": "YE" } }, + { "country": { "name": "Zambia", "code": "ZM" } }, + { "country": { "name": "Zimbabwe", "code": "ZW" } } + ] +} diff --git a/src/ovh-ui-angular/controllers/index.js b/src/ovh-ui-angular/controllers/index.js index 4e66b1c..ec06863 100644 --- a/src/ovh-ui-angular/controllers/index.js +++ b/src/ovh-ui-angular/controllers/index.js @@ -1,3 +1,4 @@ +import autocompleteController from "./autocomplete.controller"; import calendarController from "./calendar.controller"; import chipsController from "./chips.controller"; import criteriaAdderController from "./criteria-adder.controller"; @@ -14,6 +15,7 @@ import showCurrentValueInPopupController from "./show-current-value-in-popup.con import stepperController from "./stepper.controller"; angular.module("app") + .controller("AutocompleteCtrl", autocompleteController) .controller("CalendarCtrl", calendarController) .controller("CriteriaAdderCtrl", criteriaAdderController) .controller("ChipsCtrl", chipsController) diff --git a/src/ovh-ui-angular/controllers/search.controller.js b/src/ovh-ui-angular/controllers/search.controller.js index bae1aa0..58fe82f 100644 --- a/src/ovh-ui-angular/controllers/search.controller.js +++ b/src/ovh-ui-angular/controllers/search.controller.js @@ -1,6 +1,9 @@ +import data from "./data/autocomplete.data.json"; + export default class { $onInit () { this.resetCount = 0; + this.autocomplete = data.objects; } onSearchChange (modelValue) { diff --git a/src/ovh-ui-angular/ovh-ui-angular.config.json b/src/ovh-ui-angular/ovh-ui-angular.config.json index c4246d8..0b738db 100644 --- a/src/ovh-ui-angular/ovh-ui-angular.config.json +++ b/src/ovh-ui-angular/ovh-ui-angular.config.json @@ -2,6 +2,10 @@ "action-menu": { "group": "components" }, + "autocomplete": { + "controller": "AutocompleteCtrl", + "group": "components" + }, "back-button": { "group": "components" },