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,24 @@
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.attendee',
['tickets', 'socialLinks', 'copyright', 'tax', 'stripeAuthorization']
);
}
@@ -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 comment has been minimized.

Copy link
@niranjan94

niranjan94 Jun 18, 2019

Member

Why are you not handling the errors ?

This comment has been minimized.

Copy link
@uds5501

uds5501 Jun 18, 2019

Author Contributor

@niranjan94 The errors are being handled by the functions saveForms and saveEventDataAndRedirectTo themselves.

This comment has been minimized.

Copy link
@niranjan94

niranjan94 Jun 19, 2019

Member

No. They are not. I'm not talking about the form validation errors. Lets say customForm.save fails with an error. How is that being handled ?

This comment has been minimized.

Copy link
@shreyanshdwivedi

shreyanshdwivedi Jun 19, 2019

Member

@uds5501 maybe you can use try-catch to handle such errors

This comment has been minimized.

Copy link
@uds5501

uds5501 Jun 19, 2019

Author Contributor

@niranjan94 @shreyanshdwivedi Alright, will work on it tonight

this.saveEventDataAndRedirectTo(
'events.view.index',
[]
);
},
move(direction, data) {

This comment has been minimized.

Copy link
@mrsaicharan1

mrsaicharan1 Jun 20, 2019

Member

Use try/catch blocks here as well

This comment has been minimized.

Copy link
@uds5501

uds5501 Jun 20, 2019

Author Contributor

@mrsaicharan1 They already have error handling implemented. (see EventMixin)

this.saveForms(data);

This comment has been minimized.

Copy link
@niranjan94

niranjan94 Jun 18, 2019

Member

Why are you not handling the errors ?

this.saveEventDataAndRedirectTo(

This comment has been minimized.

Copy link
@niranjan94

niranjan94 Jun 20, 2019

Member

Do not do this if there was an error.

This comment has been minimized.

Copy link
@uds5501

uds5501 Jun 20, 2019

Author Contributor

@niranjan94 What should be done in case of error? 😅

This comment has been minimized.

Copy link
@shreyanshdwivedi

shreyanshdwivedi Jun 20, 2019

Member

@uds5501 you can shift function on line 29 to try block.

This comment has been minimized.

Copy link
@uds5501

uds5501 Jun 20, 2019

Author Contributor

@shreyanshdwivedi OH! Okay, modifying the function!

This comment has been minimized.

Copy link
@uds5501

uds5501 Jun 20, 2019

Author Contributor

@shreyanshdwivedi @niranjan94 review now please

direction === 'forwards' ? 'events.view.edit.sponsors' : 'events.view.edit.basic-details',
[]
);
}
}
});
@@ -11,7 +11,7 @@ export default Controller.extend(EventWizardMixin, {
},
move() {
this.saveEventDataAndRedirectTo(
'events.view.edit.sponsors',
'events.view.edit.attendee',
['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.attendee',
['sponsors']
);
}
@@ -19,6 +19,12 @@ export default Mixin.create(MutableArray, CustomFormMixin, {
icon : 'info icon',
route : 'events.view.edit.basic-details'
},
{
title : this.l10n.t('Attendee Form'),
description : this.l10n.t('Know your audience'),
icon : 'list icon',
route : 'events.view.edit.attendee'
},
{
title : this.l10n.t('Sponsors'),
description : this.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 }),
@@ -68,6 +68,7 @@ router.map(function() {
this.route('basic-details');
this.route('sponsors');
this.route('sessions-speakers');
this.route('attendee');
});
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.l10n.t('Attendee Form');
},

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

This comment has been minimized.

Copy link
@mrsaicharan1

mrsaicharan1 Jun 20, 2019

Member

Is the page[size] same for other forms as well?

This comment has been minimized.

Copy link
@uds5501

uds5501 Jun 20, 2019

Author Contributor
});

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>

This comment has been minimized.

Copy link
@Anupam-dagar

Anupam-dagar Jun 20, 2019

Member

A little less priority but I guess we can get rid of the extra line at Line 114 and 93.

</form>
@@ -0,0 +1 @@
{{forms/wizard/attendee-step 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.