diff --git a/app/components/forms/orders/attendee-list.js b/app/components/forms/orders/attendee-list.js index f820a2c591e..6e4863dd5db 100644 --- a/app/components/forms/orders/attendee-list.js +++ b/app/components/forms/orders/attendee-list.js @@ -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'; @@ -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(() => { + }); + } } diff --git a/app/templates/components/forms/orders/attendee-list.hbs b/app/templates/components/forms/orders/attendee-list.hbs index 877f69c42de..1eebd046242 100644 --- a/app/templates/components/forms/orders/attendee-list.hbs +++ b/app/templates/components/forms/orders/attendee-list.hbs @@ -13,7 +13,13 @@
+
+ {{# each this.allFields.attendee as |field|}} {{#if field.isIncluded}}