Skip to content
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
25 changes: 24 additions & 1 deletion app/components/forms/orders/attendee-list.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import classic from 'ember-classic-decorator';
import Component from '@ember/component';
import { computed } from '@ember/object';
import { action, computed } from '@ember/object';
import { groupBy } from 'lodash-es';
import { or } from '@ember/object/computed';

Expand All @@ -23,4 +23,27 @@ export default class AttendeeList extends Component {
get allFields() {
return groupBy(this.fields.toArray(), field => field.form);
}

@action
downloadTicketForAttendee(eventName, orderId, attendeeId) {
this.loader.downloadFile(`/orders/attendees/${attendeeId}.pdf`)
.then(res => {
const anchor = document.createElement('a');
anchor.style.display = 'none';
anchor.href = URL.createObjectURL(new Blob([res], { type: 'application/pdf' }));
anchor.download = `${eventName}-Ticket-${orderId}-${attendeeId}.pdf`;
document.body.appendChild(anchor);
anchor.click();
this.notify.success(this.l10n.t('Here is your ticket'),
{
id: 'tick_pdf'
});
document.body.removeChild(anchor);
})
.catch(e => {
console.error('Error while downloading tickets', e);
})
.finally(() => {
});
}
}
6 changes: 6 additions & 0 deletions app/templates/components/forms/orders/attendee-list.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,13 @@
<div class="inline field">
<i class="user icon"></i>
<label>{{t 'Ticket Holder '}}{{t ' -for- '}}{{holder.ticket.name}}</label>
<button class="ui right floated button {{if this.device.isMobile 'fluid'}} button"
{{action this.downloadTicketForAttendee @event.name holder.order.id holder.id }}>
<i class="ticket icon"></i>
{{t 'Download Ticket'}}
</button>
</div>

{{# each this.allFields.attendee as |field|}}
{{#if field.isIncluded}}
<div class="field">
Expand Down