From 04f33d333054411b6d781bbea28f5d3d881d656b Mon Sep 17 00:00:00 2001 From: Frans-Paul Ruzius Date: Tue, 11 Feb 2020 11:25:08 +0100 Subject: [PATCH 1/2] Chanmged the coutries array to an array of tuples. The first value is the name of the country unaltered. The second value is the name of the country with the 'The' pasted at the end. The second value is also used to sort the array, and the value shown in the dropdown. The first value is the value of the dropdown, so the rest of the code does not break. --- .../app/account/register/register.component.html | 4 ++-- .../app/account/register/register.component.ts | 14 +++++++++++--- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/src/main/webapp/app/account/register/register.component.html b/src/main/webapp/app/account/register/register.component.html index abaa761..b15037d 100644 --- a/src/main/webapp/app/account/register/register.component.html +++ b/src/main/webapp/app/account/register/register.component.html @@ -246,8 +246,8 @@

Registration

diff --git a/src/main/webapp/app/account/register/register.component.ts b/src/main/webapp/app/account/register/register.component.ts index 2a4b45e..6e6ae13 100644 --- a/src/main/webapp/app/account/register/register.component.ts +++ b/src/main/webapp/app/account/register/register.component.ts @@ -18,7 +18,7 @@ export class RegisterComponent implements OnInit, AfterViewInit { errorUserExists: string; success: boolean; modalRef: NgbModalRef; - countries: string[] = []; + countries: [string, string][] = []; registerForm = this.fb.group({ login: ['', [Validators.required, Validators.minLength(1), Validators.maxLength(50), Validators.pattern('^[_.@A-Za-z0-9-]*$')]], @@ -59,10 +59,18 @@ export class RegisterComponent implements OnInit, AfterViewInit { const lookup = require('country-code-lookup'); const countryLookup: any = lookup.countries; - this.countries = new Array(countryLookup.length); + this.countries = new Array<[string, string]>(countryLookup.length); for (let i = 0, len = countryLookup.length; i < len; i++) { - this.countries[i] = countryLookup[i].country; + // initialize empty tuple + this.countries[i] = ['', '']; + // value used as value in the dropdown + this.countries[i][0] = countryLookup[i].country.toString(); + // value used to sort, remove the 'The' at the beginning and put it at the end + this.countries[i][1] = countryLookup[i].country.replace(/^The (.+)$/i, '$1, The'); } + + // sort the countries on the second value, without 'The' + this.countries.sort((a, b) => a[1].localeCompare(b[1])); } setRegistrationValidators() { From 5a527e965236f57bfd41819e2e93854a782702bd Mon Sep 17 00:00:00 2001 From: cyt-mn Date: Tue, 11 Feb 2020 17:27:46 +0100 Subject: [PATCH 2/2] version up --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 44d9a9f..4e26242 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ org.ihiw.management ihiw-management - 1.0.13 + 1.0.14 jar Ihiw Management