Merge pull request #2104 from crazyserver/MOBILE-3091
MOBILE-3091 signup: Sort countries by namemain
commit
fc41cbf29f
|
@ -31,7 +31,7 @@
|
|||
<ion-label stacked core-mark-required="true">{{ 'core.wheredoyoulive' | translate }}</ion-label>
|
||||
<ion-select name="country" formControlName="country" [placeholder]="'core.login.selectacountry' | translate">
|
||||
<ion-option value="">{{ 'core.login.selectacountry' | translate }}</ion-option>
|
||||
<ion-option *ngFor="let key of countriesKeys" [value]="key">{{countries[key]}}</ion-option>
|
||||
<ion-option *ngFor="let country of countries" [value]="country.code">{{country.name}}</ion-option>
|
||||
</ion-select>
|
||||
</ion-item>
|
||||
|
||||
|
@ -103,7 +103,7 @@
|
|||
<ion-label stacked id="core-login-signup-country">{{ 'core.user.country' | translate }}</ion-label>
|
||||
<ion-select name="country" formControlName="country" aria-labelledby="core-login-signup-country" [placeholder]="'core.login.selectacountry' | translate">
|
||||
<ion-option value="">{{ 'core.login.selectacountry' | translate }}</ion-option>
|
||||
<ion-option *ngFor="let key of countriesKeys" [value]="key">{{countries[key]}}</ion-option>
|
||||
<ion-option *ngFor="let country of countries" [value]="country.code">{{country.name}}</ion-option>
|
||||
</ion-select>
|
||||
</ion-item>
|
||||
|
||||
|
|
|
@ -43,7 +43,6 @@ export class CoreLoginEmailSignupPage {
|
|||
authInstructions: string;
|
||||
settings: any;
|
||||
countries: any;
|
||||
countriesKeys: any[];
|
||||
categories: any[];
|
||||
settingsLoaded = false;
|
||||
captcha = {
|
||||
|
@ -177,9 +176,8 @@ export class CoreLoginEmailSignupPage {
|
|||
});
|
||||
}
|
||||
|
||||
return this.utils.getCountryList().then((countries) => {
|
||||
return this.utils.getCountryListSorted().then((countries) => {
|
||||
this.countries = countries;
|
||||
this.countriesKeys = Object.keys(countries);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
|
@ -623,6 +623,25 @@ export class CoreUtilsProvider {
|
|||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Get list of countries with their code and translated name. Sorted by the name of the country.
|
||||
*
|
||||
* @return Promise resolved with the list of countries.
|
||||
*/
|
||||
getCountryListSorted(): Promise<any[]> {
|
||||
// Get the keys of the countries.
|
||||
return this.getCountryList().then((countries) => {
|
||||
// Sort translations.
|
||||
const sortedCountries = [];
|
||||
|
||||
Object.keys(countries).sort((a, b) => countries[a].localeCompare(countries[b])).forEach((key) => {
|
||||
sortedCountries.push({code: key, name: countries[key]});
|
||||
});
|
||||
|
||||
return sortedCountries;
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the list of language keys of the countries.
|
||||
*
|
||||
|
|
Loading…
Reference in New Issue