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

feat: Add new wizard step - attendee form #2961

Merged
merged 12 commits into from Jun 21, 2019
@@ -0,0 +1,25 @@
import Component from '@ember/component';
import FormMixin from 'open-event-frontend/mixins/form';

export default Component.extend(FormMixin, {
actions: {
saveDraft() {
this.onValid(() => {
this.set('data.event.state', 'draft');
this.sendAction('save', this.data);
});
},
move(direction) {
this.onValid(() => {
this.sendAction('move', direction, this.data);
});
},
publish() {
this.onValid(() => {
this.set('data.event.state', 'published');
this.sendAction('save', this.data);
});
}
}

});
@@ -12,7 +12,7 @@ export default Controller.extend(EventWizardMixin, {
},
move() {
this.saveEventDataAndRedirectTo(
'events.view.edit.sponsors',
'events.view.edit.ticket-buyer-form',
['tickets', 'socialLinks', 'copyright', 'tax', 'stripeAuthorization']
);
}
@@ -11,7 +11,7 @@ export default Controller.extend(EventWizardMixin, {
},
move() {
this.saveEventDataAndRedirectTo(
'events.view.edit.sponsors',
'events.view.edit.ticket-buyer-form',
['tickets', 'socialLinks', 'copyright', 'tax', 'stripeAuthorization']
);
}
@@ -12,7 +12,7 @@ export default Controller.extend(EventWizardMixin, {
},
move(direction) {
this.saveEventDataAndRedirectTo(
direction === 'forwards' ? 'events.view.edit.sessions-speakers' : 'events.view.edit.basic-details',
direction === 'forwards' ? 'events.view.edit.sessions-speakers' : 'events.view.edit.ticket-buyer-form',
['sponsors']
);
}
@@ -0,0 +1,27 @@
import Controller from '@ember/controller';
import EventWizardMixin from 'open-event-frontend/mixins/event-wizard';

export default Controller.extend(EventWizardMixin, {
async saveForms(data) {
for (const customForm of data.customForms ? data.customForms.toArray() : []) {
await customForm.save();
}
return data;
},
actions: {
save(data) {
this.saveForms(data);
this.saveEventDataAndRedirectTo(
'events.view.index',
[]
);
},
move(direction, data) {
this.saveForms(data);
this.saveEventDataAndRedirectTo(
direction === 'forwards' ? 'events.view.edit.sponsors' : 'events.view.edit.basic-details',
[]
);
}
}
});
@@ -19,6 +19,12 @@ export default Mixin.create(MutableArray, CustomFormMixin, {
icon : 'info icon',
route : 'events.view.edit.basic-details'
},
{
title : this.get('l10n').t('Attendee Form'),
description : this.get('l10n').t('Know your audience'),
icon : 'list icon',
route : 'events.view.edit.ticket-buyer-form'
},
{
title : this.get('l10n').t('Sponsors'),
description : this.get('l10n').t('Advertise your sponsors'),
@@ -47,6 +47,7 @@ export default ModelBase.extend(CustomPrimaryKeyMixin, {

isMapShown : attr('boolean', { defaultValue: true }),
isSponsorsEnabled : attr('boolean', { defaultValue: false }),
isTicketFormEnabled : attr('boolean', { defaultValue: false }),
isTicketingEnabled : attr('boolean', { defaultValue: true }),
isSessionsSpeakersEnabled : attr('boolean', { defaultValue: false }),
isFeatured : attr('boolean', { defaultValue: false }),
@@ -64,6 +64,7 @@ router.map(function() {
this.route('basic-details');
this.route('sponsors');
this.route('sessions-speakers');
this.route('ticket-buyer-form');
});
this.route('export');
this.route('sessions', function() {
@@ -0,0 +1,47 @@
import Route from '@ember/routing/route';
import EventWizardMixin from 'open-event-frontend/mixins/event-wizard';
import { A } from '@ember/array';
export default Route.extend(EventWizardMixin, {

titleToken() {
return this.get('l10n').t('Ticket Buyer Form');
This conversation was marked as resolved by uds5501

This comment has been minimized.

Copy link
@CosmicCoder96

CosmicCoder96 May 23, 2019

Collaborator

ES6 getters.

},

async model() {
let filterOptions = [{
name : 'form',
op : 'eq',
val : 'attendee'
}];

let data = {
event: this.modelFor('events.view')
};
data.customForms = await data.event.query('customForms', {
filter : filterOptions,
sort : 'id',
'page[size]' : 50
});

return data;
},
afterModel(data) {
/**
* Create the additional custom forms if only the compulsory forms exist.
*/
if (data.customForms.length === 3) {
let customForms = A();
for (const customForm of data.customForms ? data.customForms.toArray() : []) {
customForms.pushObject(customForm);
}

const createdCustomForms = this.getCustomAttendeeForm(data.event);

for (const customForm of createdCustomForms ? createdCustomForms : []) {
customForms.pushObject(customForm);
}

data.customForms = customForms;
}
}
});
@@ -0,0 +1,115 @@
<form class="ui form {{if isLoading 'loading'}}" autocomplete="off" {{action 'move' 'forwards' on='submit' preventDefault=true}}>

<div class="ui centered grid">
<div class="column">
<div class="ui {{if data.event.isTicketFormEnabled 'basic'}} segment">
<div class="center aligned text">
<div class=" field">
<div class="ui slider checkbox">
{{input type='checkbox' checked=data.event.isTicketFormEnabled}}
<label class="weight-300" style="font-size: large">
{{if data.event.isTicketFormEnabled (t 'Turn off') (t 'Turn on')}}
{{t 'Ticket Form'}}
</label>
</div>
</div>
</div>
</div>
</div>
</div>

{{#if data.event.isTicketFormEnabled}}
<div class="ui hidden divider"></div>
<h3 class="ui dividing header">
<i class="checkmark box icon"></i>
<div class="content">
{{t 'Information to Collect'}}
</div>
</h3>
<div class="ui two column stackable grid">
<div class="column">
<table class="ui selectable celled table">
<thead>
<tr>
{{#if device.isMobile}}
<th class="center aligned">
{{t 'Options'}}
</th>
{{else}}
<th class="right aligned">
{{t 'Option'}}
</th>
<th class="center aligned">
{{t 'Include'}}
</th>
<th class="center aligned">
{{t 'Require'}}
</th>
{{/if}}
</tr>
</thead>
<tbody>
{{#each data.customForms as |field|}}
<tr class="{{if field.isIncluded 'positive'}}">
<td class="{{if device.isMobile 'center' 'right'}} aligned">
<label class="{{if field.isFixed 'required'}}">
{{field.name}}
</label>
</td>
<td class="center aligned">
{{ui-checkbox class='slider'
checked=field.isIncluded
disabled=field.isFixed
onChange=(action (mut field.isIncluded))
label=(if device.isMobile (t 'Include'))}}
</td>
<td class="center aligned">
{{ui-checkbox class='slider'
checked=field.isRequired
disabled=field.isFixed
onChange=(action (mut field.isRequired))
label=(if device.isMobile (t 'Require'))}}
</td>
</tr>
{{/each}}
</tbody>
</table>
</div>
</div>
<h3 class="ui dividing header">
<i class="options box icon"></i>
<div class="content">
{{t 'Registration Options'}}
</div>
</h3>
<div class="field">
<label>{{t 'REGISTRATION TIME LIMIT'}}</label>
<div class="{{unless device.isMobile 'two wide'}} field">
{{input type='number' id='orderExpiryTime' value=data.event.orderExpiryTime min="1" max="60" step="1"}}
</div>
</div>
{{/if}}
<div class="spacer-50"></div>

<div class="{{if device.isMobile 'mini four' 'right floated large'}} ui fields buttons">
<button class="ui three field left labeled icon button {{if isLoading 'disabled'}}" type="button" {{action 'move' 'backwards'}}>
{{t 'Previous'}}
<i class="left chevron icon"></i>
</button>
<button class="ui three field right labeled icon button {{if isLoading 'disabled'}}" type="button" {{action 'move' 'forwards'}}>
{{t 'Forward'}}
<i class="right chevron icon"></i>
</button>
<button class="blue ui three field right labeled icon button {{if isLoading 'disabled'}}" type="button" {{action 'saveDraft'}}>
{{t 'Save draft'}}
<i class="save icon"></i>
</button>
{{#if data.event.locationName}}
<button class="green ui three field right labeled icon button {{if isLoading 'disabled'}}" type="button" {{action 'publish'}}>
{{t 'Publish'}}
<i class="check icon"></i>
</button>
{{/if}}
</div>

</form>
@@ -0,0 +1 @@
{{forms/wizard/ticket-buyer-form data=model move='move' save='save' isLoading=isLoading}}
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.