Skip to content

Commit

Permalink
fix: Add global ticket fees settings (#5167)
Browse files Browse the repository at this point in the history
  • Loading branch information
iamareebjamal authored Sep 28, 2020
1 parent cbbbca9 commit d2ee95c
Show file tree
Hide file tree
Showing 3 changed files with 72 additions and 5 deletions.
24 changes: 22 additions & 2 deletions app/components/forms/admin/settings/ticket-fees-form.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,39 @@ export default class TicketFeesForm extends Component {
return orderBy(paymentCurrencies, 'name');
}

@computed('model.[]')
get ticketFees() {
return this.model.filter(fees => fees.country !== 'global');
}

getGlobalFee() {
return this.model.filter(fees => fees.country === 'global')[0];
}

@computed('model')
get globalFees() {
const globalFee = this.getGlobalFee();
if (globalFee) {return globalFee}
const globalFeeItem = this.store.createRecord('ticket-fee', {
country: 'global'
});
this.model.toArray().addObject(globalFeeItem);
return globalFeeItem;
}

@action
addNewTicket() {
const settings = this.model;
const incorrect_settings = settings.filter(function(setting) {
return (!setting.get('currency') || !setting.get('country'));
return (!setting.get('country'));
});
if (incorrect_settings.length > 0) {
this.notify.error(this.l10n.t('Existing items need to be completed before new items can be added.'), {
id: 'existing_item'
});
this.set('isLoading', false);
} else {
this.model.toArray().addObject(this.store.createRecord('ticket-fee', {
this.model.addObject(this.store.createRecord('ticket-fee', {
maximumFee : 0.0,
serviceFee : 0.0
}));
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/admin/settings/ticket-fees.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export default class extends Controller {
this.set('isLoading', true);
const settings = this.model;
const incorrect_settings = settings.filter(function(setting) {
return (!setting.currency || !setting.country);
return (!setting.country);
});
if (incorrect_settings.length > 0) {
this.notify.error(this.l10n.t('Please fill the required fields.'),
Expand Down
51 changes: 49 additions & 2 deletions app/templates/components/forms/admin/settings/ticket-fees-form.hbs
Original file line number Diff line number Diff line change
@@ -1,8 +1,55 @@
<form class="ui form" {{action this.save on='submit' preventDefault=true}}>
<h3 class="ui header">
{{t 'Add Fee Settings for the event'}}
{{t 'Add Fee Settings for the event invoices'}}
</h3>
{{#each this.model as |ticketFee|}}
{{#if this.globalFees}}
<h4 class="ui header">
{{t 'Global Settings'}}
</h4>

<div class="ui five column very relaxed grid">
<div class="ui field four wide column">
<label>
{{t 'Service Fee'}}
</label>
<div class="ui right labeled input">
<Input
@type="number"
@name={{concat this.globalFees.currency "_service"}}
@value={{this.globalFees.serviceFee}}
@step={{0.1}}
@min={{0}}
required />
<div class="ui basic label">
%
</div>
</div>
</div>

<div class="ui field four wide column">
<label>
{{t 'Maximum Fee'}}
</label>
<div class="ui input">
<Input
@type="number"
@name={{concat this.globalFees.currency "_maximum"}}
@value={{this.globalFees.maximumFee}}
@step={{0.1}}
@min={{0}}
required />
</div>
</div>
</div>
{{/if}}

{{#if this.ticketFees}}
<h4 class="ui header">
{{t 'Country-Wise Settings'}}
</h4>
{{/if}}

{{#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>
Expand Down

1 comment on commit d2ee95c

@vercel
Copy link

@vercel vercel bot commented on d2ee95c Sep 28, 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.