Skip to content

Commit

Permalink
fix: Only show country dropdown without autocomplete (#5652)
Browse files Browse the repository at this point in the history
Co-authored-by: iamareebjamal <jamal.areeb@gmail.com>
  • Loading branch information
DIVYAM TAYAL and iamareebjamal authored Nov 20, 2020
1 parent 9c25bec commit 70c2285
Show file tree
Hide file tree
Showing 11 changed files with 77 additions and 110 deletions.
14 changes: 14 additions & 0 deletions app/components/country-dropdown.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import Component from '@glimmer/component';
import { orderBy, filter } from 'lodash-es';
import { paymentCountries } from 'open-event-frontend/utils/dictionary/payment';
import { countries, Country } from 'open-event-frontend/utils/dictionary/demography';

export default class CountryDropdown extends Component {
get countries(): Country[] {
return orderBy(countries, 'name');
}

get paymentCountries(): Country[] {
return orderBy(filter(countries, country => paymentCountries.includes(country.code)), 'name');
}
}
24 changes: 24 additions & 0 deletions app/templates/components/country-dropdown.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<form class="field">
<label class={{if @required 'required'}}>{{@placeholder}}</label>
<UiDropdown
@class="search selection"
@selected={{@val}}
@forceSelection={{false}}
@fullTextSearch={{true}}>
<Input
@type="hidden"
@autocomplete="no"
@value={{@val}}
@id={{@id}} />
<i class="dropdown icon"></i>
<div class="default text">{{t 'Select country'}}</div>
<div class="menu">
{{#each (if @paymentCountries this.paymentCountries this.countries) as |country|}}
<div class="item" data-value="{{country.name}}">
<i class="{{lowercase country.code}} flag"></i>
{{country.name}}
</div>
{{/each}}
</div>
</UiDropdown>
</form>
21 changes: 5 additions & 16 deletions app/templates/components/forms/admin/settings/billing.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -45,22 +45,11 @@
<label class="required" for="adminBillingPaypalEmail">{{t 'Paypal Email'}}</label>
<Input @type="email" @id="adminBillingPaypalEmail" @value={{this.model.adminBillingPaypalEmail}} />
</div>
<div class="field">
<label class="required">{{t 'Country'}}</label>
<UiDropdown @class="search selection" @selected={{this.model.adminBillingCountry}} @forceSelection={{false}} @fullTextSearch={{true}}>
<Input @type="hidden" @autocomplete="no" @id="adminBillingCountry" @value={{this.model.adminBillingCountry}} />
<i class="dropdown icon"></i>
<div class="default text">{{t 'Select country'}}</div>
<div class="menu">
{{#each this.countries as |country|}}
<div class="item" data-value="{{country.name}}">
<i class="{{lowercase country.code}} flag"></i>
{{country.name}}
</div>
{{/each}}
</div>
</UiDropdown>
</div>
<CountryDropdown
@required={{true}}
@placeholder={{t 'Country'}}
@val={{this.model.adminBillingCountry}}
@id="adminBillingCountry" />
<div class="field">
<label for="adminBillingTaxInfo">{{t 'Tax ID'}}</label>
<Input @type="text" @id="adminBillingTaxInfo" @value={{this.model.adminBillingTaxInfo}} />
Expand Down
26 changes: 5 additions & 21 deletions app/templates/components/forms/admin/settings/ticket-fees-form.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -52,27 +52,11 @@
{{#each this.ticketFees as |ticketFee|}}
<div class="ui five column very relaxed grid">
<div class="ui field three wide column">
<label class="required">{{t 'Select country'}}</label>
<UiDropdown
@class="search selection"
@selected={{ticketFee.country}}
@forceSelection={{false}}
@fullTextSearch={{true}}>
<Input
@type="hidden"
@autocomplete="no"
@value={{ticketFee.country}} />
<i class="dropdown icon"></i>
<div class="default text">{{t 'Select country'}}</div>
<div class="menu">
{{#each this.paymentCountries as |paymentCountry|}}
<div class="item" data-value="{{paymentCountry.name}}">
<i class="{{lowercase paymentCountry.code}} flag"></i>
{{paymentCountry.name}}
</div>
{{/each}}
</div>
</UiDropdown>
<CountryDropdown
@required={{true}}
@paymentCountries={{true}}
@placeholder={{t 'Select country'}}
@val={{ticketFee.country}} />
</div>
<div class="ui field four wide column">
<label class="required">{{t 'Select currency'}}</label>
Expand Down
4 changes: 2 additions & 2 deletions app/templates/components/forms/orders/order-form.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
</div>
{{#each this.allFields.attendee as |field|}}
{{#if field.isIncluded}}
<div class="field">
<form class="field">
<label class="{{if field.isRequired 'required'}}" for="name">{{field.name}}</label>
{{#if (is-input-field field.type) }}
{{#if field.isLongText}}
Expand Down Expand Up @@ -140,7 +140,7 @@
</div>
</UiDropdown>
{{/if}}
</div>
</form>
{{/if}}
{{/each}}
{{/each}}
Expand Down
8 changes: 4 additions & 4 deletions app/templates/components/forms/session-speaker-form.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@
{{#if this.addNewSpeaker}}
{{#each this.allFields.speaker as |field|}}
{{#if field.isIncluded}}
<div class="field">
<form class="field">
<label class="{{if field.isRequired 'required'}}" for="name">{{field.name}}</label>
{{#if (is-input-field field.type) }}
{{#if field.isLongText}}
Expand Down Expand Up @@ -242,7 +242,7 @@
</UiDropdown>
{{/if}}
{{/if}}
</div>
</form>
{{/if}}
{{/each}}
{{/if}}
Expand All @@ -256,7 +256,7 @@
{{/if}}
{{#each this.allFields.speaker as |field|}}
{{#if field.isIncluded}}
<div class="field">
<form class="field">
<label class="{{if field.isRequired 'required'}}" for="name">{{field.name}}</label>
{{#if (is-input-field field.type) }}
{{#if field.isLongText}}
Expand Down Expand Up @@ -364,7 +364,7 @@
</UiDropdown>
{{/if}}
{{/if}}
</div>
</form>
{{/if}}
{{/each}}
{{/if}}
Expand Down
28 changes: 4 additions & 24 deletions app/templates/components/forms/user-payment-info-form.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -54,30 +54,10 @@
@id="state"
@value={{this.userBillingInfo.billingState}} />
</div>
<div class="field">
<label >{{t 'Country'}}</label>
<UiDropdown
@class="search selection"
@selected={{this.userBillingInfo.billingCountry}}
@forceSelection={{false}}
@fullTextSearch={{true}}>
<Input
@type="hidden"
@autocomplete="no"
@id="country"
@value={{this.userBillingInfo.billingCountry}} />
<i class="dropdown icon"></i>
<div class="default text">{{t 'Select country'}}</div>
<div class="menu">
{{#each this.countries as |country|}}
<div class="item" data-value="{{country.name}}">
<i class="{{lowercase country.code}} flag"></i>
{{country.name}}
</div>
{{/each}}
</div>
</UiDropdown>
</div>
<CountryDropdown
@placeholder={{t 'Country'}}
@val={{this.userBillingInfo.billingCountry}}
@id="country" />
<div class="field">
<label for="taxID">{{t 'Tax ID or Business ID'}}</label>
<Input
Expand Down
30 changes: 6 additions & 24 deletions app/templates/components/forms/wizard/basic-details-step.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -315,30 +315,12 @@
<div class="field">
<h4>{{t 'Add Payment Details'}}</h4>
<div class="two fields">
<div class="field">
<label class="required">{{t 'Select country'}}</label>
<UiDropdown
@class="search selection"
@selected={{this.data.event.paymentCountry}}
@forceSelection={{false}}
@fullTextSearch={{true}}>
<Input
@type="hidden"
@autocomplete="no"
@id="payment_country"
@value={{this.data.event.paymentCountry}} />
<i class="dropdown icon"></i>
<div class="default text">{{t 'Select country'}}</div>
<div class="menu">
{{#each this.paymentCountries as |paymentCountry|}}
<div class="item" data-value="{{paymentCountry.name}}">
<i class="{{lowercase paymentCountry.code}} flag"></i>
{{paymentCountry.name}}
</div>
{{/each}}
</div>
</UiDropdown>
</div>
<CountryDropdown
@required={{true}}
@paymentCountries={{true}}
@placeholder={{t 'Select country'}}
@val={{this.data.event.paymentCountry}}
@id={{'payment_country'}} />
<div class="field">
<label class="required">{{t 'Select currency'}}</label>
<UiDropdown
Expand Down
21 changes: 5 additions & 16 deletions app/templates/components/modals/tax-info-modal.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,11 @@
</div>
<div class="y-scrollable scrollable-modal content">
<form class="ui form" autocomplete="off" {{action 'updateTaxInfo' on='submit' preventDefault=true}}>
<div class="field">
<label class="required">{{t 'Choose country'}}</label>
<UiDropdown @class="search selection" @selected={{this.tax.country}} @forceSelection={{false}} @fullTextSearch={{true}}>
<Input @type="hidden" @autocomplete="tax-country" @id="tax_country" @value={{this.tax.country}} />
<i class="dropdown icon"></i>
<div class="default text">{{t 'Select country'}}</div>
<div class="menu">
{{#each this.countries as |country|}}
<div class="item" data-value="{{country.name}}">
<i class="{{lowercase country.code}} flag"></i>
{{country.name}}
</div>
{{/each}}
</div>
</UiDropdown>
</div>
<CountryDropdown
@required={{true}}
@placeholder={{t 'Choose country'}}
@val={{this.tax.country}}
@id="tax_country" />
<div class="field">
<label class="required">{{t 'Tax name'}}</label>
<Input @type="text" @id="tax_name" @value={{this.tax.name}} />
Expand Down
4 changes: 2 additions & 2 deletions app/templates/components/widgets/forms/billing-info.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
@id="zip_code"
@value={{this.data.zipcode}} />
</div>
<div class="field">
<form class="field">
<label class="required">{{t 'Select country'}}</label>
<UiDropdown
@class="search selection"
Expand All @@ -61,4 +61,4 @@
{{/each}}
</div>
</UiDropdown>
</div>
</form>
7 changes: 6 additions & 1 deletion app/utils/dictionary/demography.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
export interface Country {
name: string;
code: string;
}

/**
* Using a lean list of countries instead of an external dependency.
* All the libraries have a lot of extra data which is of no use to us at this point and unnecessarily takes up more space.
*/
export const countries = [
export const countries: Country[] = [
{
name : 'Andorra',
code : 'AD'
Expand Down

1 comment on commit 70c2285

@vercel
Copy link

@vercel vercel bot commented on 70c2285 Nov 20, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.