Added currency grouping

This commit is contained in:
Peter Zimon 2021-02-25 12:09:06 +01:00
parent 5491ee0d55
commit 7744a78594
3 changed files with 31 additions and 7 deletions

View File

@ -166,7 +166,7 @@
{{one-way-select this.selectedCurrency
id="currency"
name="currency"
options=(readonly this.currencies)
options=(readonly this.allCurrencies)
optionValuePath="value"
optionLabelPath="label"
update=(action "setStripePlansCurrency")

View File

@ -13,7 +13,9 @@ export default Component.extend({
ajax: service(),
settings: service(),
topCurrencies: null,
currencies: null,
allCurrencies: null,
stripePlanInvalidAmount: false,
_scratchStripeYearlyAmount: null,
_scratchStripeMonthlyAmount: null,
@ -67,13 +69,35 @@ export default Component.extend({
init() {
this._super(...arguments);
this.set('currencies', currencies.map((currency) => {
const noOfTopCurrencies = 5;
this.set('topCurrencies', currencies.slice(0, noOfTopCurrencies).map((currency) => {
return {
value: currency.isoCode.toLowerCase(),
label: `${currency.isoCode} - ${currency.name}`,
isoCode: currency.isoCode
};
}));
this.set('currencies', currencies.slice(noOfTopCurrencies, currencies.length).map((currency) => {
return {
value: currency.isoCode.toLowerCase(),
label: `${currency.isoCode} - ${currency.name}`,
isoCode: currency.isoCode
};
}));
this.set('allCurrencies', [
{
groupName: '—',
options: this.get('topCurrencies')
},
{
groupName: '—',
options: this.get('currencies')
}
]);
if (this.get('stripeConnectAccountId')) {
this.set('membersStripeOpen', false);
} else {

View File

@ -1,4 +1,9 @@
export const currencies = [
{isoCode: 'USD', name: 'United States dollar'},
{isoCode: 'EUR', name: 'Euro'},
{isoCode: 'GBP', name: 'Pound sterling'},
{isoCode: 'AUD', name: 'Austrialian dollar'},
{isoCode: 'CAD', name: 'Canadian dollar'},
{isoCode: 'AED', name: 'United Arab Emirates dirham'},
{isoCode: 'AFN', name: 'Afghan afghani'},
{isoCode: 'ALL', name: 'Albanian lek'},
@ -6,7 +11,6 @@ export const currencies = [
{isoCode: 'ANG', name: 'Netherlands Antillean guilder'},
{isoCode: 'AOA', name: 'Angolan kwanza'},
{isoCode: 'ARS', name: 'Argentine peso'},
{isoCode: 'AUD', name: 'Austrialian dollar'},
{isoCode: 'AWG', name: 'Aruban florin'},
{isoCode: 'AZN', name: 'Azerbaijani manat'},
{isoCode: 'BAM', name: 'Bosnia and Herzegovina convertible mark'},
@ -20,7 +24,6 @@ export const currencies = [
{isoCode: 'BSD', name: 'Bahamian dollar'},
{isoCode: 'BWP', name: 'Botswana pula'},
{isoCode: 'BZD', name: 'Belize dollar'},
{isoCode: 'CAD', name: 'Canadian dollar'},
{isoCode: 'CDF', name: 'Congolese franc'},
{isoCode: 'CHF', name: 'Swiss franc'},
{isoCode: 'CNY', name: 'Chinese yuan'},
@ -33,10 +36,8 @@ export const currencies = [
{isoCode: 'DZD', name: 'Algerian dinar'},
{isoCode: 'EGP', name: 'Egyptian pound'},
{isoCode: 'ETB', name: 'Ethiopian birr'},
{isoCode: 'EUR', name: 'Euro'},
{isoCode: 'FJD', name: 'Fiji dollar'},
{isoCode: 'FKP', name: 'Falkland Islands pound'},
{isoCode: 'GBP', name: 'Pound sterling'},
{isoCode: 'GEL', name: 'Georgian lari'},
{isoCode: 'GIP', name: 'Gibraltar pound'},
{isoCode: 'GMD', name: 'Gambian dalasi'},
@ -110,7 +111,6 @@ export const currencies = [
{isoCode: 'TWD', name: 'New Taiwan dollar'},
{isoCode: 'TZS', name: 'Tanzanian shilling'},
{isoCode: 'UAH', name: 'Ukrainian hryvnia'},
{isoCode: 'USD', name: 'United States dollar'},
{isoCode: 'UYU', name: 'Uruauayan peso'},
{isoCode: 'UZS', name: 'Uzbekistan som'},
{isoCode: 'WST', name: 'Samoan tala'},