Skip to content

Commit

Permalink
Merge pull request #42 from interflux-electronics/feature/event-regis…
Browse files Browse the repository at this point in the history
…tration

Event registrations
  • Loading branch information
janwerkhoven authored Apr 7, 2024
2 parents 06ec549 + fd96458 commit b181d9a
Show file tree
Hide file tree
Showing 13 changed files with 346 additions and 14 deletions.
12 changes: 12 additions & 0 deletions app/models/event-attendee.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import Model, { attr, belongsTo } from '@ember-data/model';

export default class EventAttendeeModel extends Model {
@attr('string') firstName;
@attr('string') lastName;
@attr('string') role;
@attr('string') company;
@attr('string') email;

@belongsTo('event') event;
@belongsTo('person') person;
}
15 changes: 14 additions & 1 deletion app/models/event.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import Model, { attr, belongsTo } from '@ember-data/model';
import Model, { attr, belongsTo, hasMany } from '@ember-data/model';

export default class EventModel extends Model {
@attr('string') name;
Expand All @@ -8,8 +8,21 @@ export default class EventModel extends Model {
@attr('string') city;
@attr('string') description;

@attr('boolean') hasRegistrationForm;
@attr('boolean') askFirstName;
@attr('boolean') askLastName;
@attr('boolean') askRole;
@attr('boolean') askCompany;

@attr('string') confirmationEmailSubject;
@attr('string') confirmationEmailBody;
@attr('string') confirmationEmailBcc;

@belongsTo('country') country;

@hasMany('event-attendee') eventAttendees;
@hasMany('permalink') permalinks;

get datesCombined() {
if (!this.startDate) {
return null;
Expand Down
4 changes: 3 additions & 1 deletion app/models/permalink.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import Model, { attr } from '@ember-data/model';
import Model, { attr, belongsTo } from '@ember-data/model';
import ENV from 'interflux/config/environment';

export default class PermalinkModel extends Model {
@attr('string') slug;
@attr('string') redirectTo;
@attr('string') notes;

@belongsTo('event') event;

get redirectFrom() {
return `${ENV.publicHost}/QR/${this.slug}`;
}
Expand Down
1 change: 1 addition & 0 deletions app/pods/components/button/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ button {
}

// Used as save button modal form UIs
// TODO: rename to .button.small.green
&.save {
background: $green-1;
color: white;
Expand Down
3 changes: 1 addition & 2 deletions app/pods/components/dot-dot-dot-menu/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
}
}
}
.dropdown {
.popout {
position: absolute;
height: 0;
top: 50%;
Expand All @@ -77,7 +77,6 @@
button {
display: flex;
align-items: center;
display: flex;
background: white;
height: 40px;
padding: 0;
Expand Down
2 changes: 1 addition & 1 deletion app/pods/components/dot-dot-dot-menu/template.hbs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<div class='dot-dot-dot-menu' {{did-insert this.onInsert}}>
<Button @icon='ellipsis-vertical' @onClick={{this.onClick}} />
{{#if this.showDropdown}}
<div class='dropdown'>
<div class='popout'>
<div class='offset'>
<div class='pane'>
{{yield}}
Expand Down
33 changes: 33 additions & 0 deletions app/pods/components/modal/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,24 @@
> ul.list + h2 {
margin-top: 20px;
}
p + .buttons {
margin-top: 20px;
}
.buttons + .list {
margin-top: 20px;
}
> .error {
margin: 0 40px;
}
.buttons + .error {
margin-top: 20px;
}
.error + ul.list {
margin-top: 20px;
}
p + ul.list {
margin-top: 20px;
}
hr {
border: 0;
border-top: 1px dashed $grey-2;
Expand Down Expand Up @@ -256,6 +274,14 @@
.left {
display: flex;
align-items: center;
&.stacked {
flex-direction: column;
align-items: flex-start;
padding: 10px 14px;
p {
line-height: 150%;
}
}
span.no-link {
line-height: 46px;
padding: 0 15px;
Expand Down Expand Up @@ -355,6 +381,13 @@
padding: 0 4px;
}
}
> .buttons {
padding: 0 40px;
&.horizontal {
display: flex;
gap: 6px;
}
}
}
button.danger-red + p {
margin-top: 20px;
Expand Down
99 changes: 99 additions & 0 deletions app/pods/secure/events/event/controller.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,115 @@
import Controller from '@ember/controller';
import { service } from '@ember/service';
import { action } from '@ember/object';
import { tracked } from '@glimmer/tracking';

export default class EventController extends Controller {
@service store;
@service router;

@tracked error;

get event() {
return this.model.event;
}

get links() {
return this.event.permalinks.rejectBy('isNew').map((link) => {
const languages = {
'interflux.com': 'English',
'interflux.es': 'Spanish',
'interflux.de': 'German',
'interflux.fr': 'French'
};
const language = languages[link.host];

return {
label: `${language} link`,
permalink: link,
language
};
});
}

get hasEnglishLink() {
return this.links.any((link) => link.language === 'English');
}

get hasGermanLink() {
return this.links.any((link) => link.language === 'German');
}

get hasFrenchLink() {
return this.links.any((link) => link.language === 'French');
}

get hasSpanishLink() {
return this.links.any((link) => link.language === 'Spanish');
}

get hasAllLinks() {
return (
this.hasEnglishLink &&
this.hasGermanLink &&
this.hasFrenchLink &&
this.hasSpanishLink
);
}

@action
async destroyRecord() {
console.warn(`destroying record ${this.model.event.id}`);
await this.model.event.destroyRecord();
console.warn('destroyed');
this.router.transitionTo('secure.events');
}

@action
createLink(language) {
console.log(`create permalink for ${language}`);

const hosts = {
English: 'interflux.com',
Spanish: 'interflux.es',
German: 'interflux.de',
French: 'interflux.fr'
};

const properties = {
slug: null, // to be auto-generated by Rails
redirectTo: `https://${hosts[language]}/event/${this.event.id}`,
notes: `This link opens the ${language} registration form for the evenet "${this.event.name}".`,
event: this.event
};

console.log(properties);

const permalink = this.store.createRecord('permalink', properties);

const success = () => {
console.log('success');
};

const fail = (error) => {
console.error('fail', error);
this.error = true;
};

const done = () => {
console.log('done');
// this.isSaving = false;
};

permalink
.save({
adapterOptions: {
whitelist: ['slug', 'redirectTo', 'notes', 'event']
}
})
.then(success)
.catch(fail)
.finally(done);

console.log(permalink);
}
}
2 changes: 1 addition & 1 deletion app/pods/secure/events/event/route.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export default class WebinarRoute extends ModalRoute {
model(params) {
return hash({
event: this.store.findRecord('event', params.id, {
include: ['country'].join(',')
include: ['country', 'permalinks', 'event_attendees'].join(',')
})
});
}
Expand Down
Loading

0 comments on commit b181d9a

Please sign in to comment.