Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Add global ticket fees settings #5167

Merged
merged 2 commits into from
Sep 28, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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