-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #42 from interflux-electronics/feature/event-regis…
…tration Event registrations
- Loading branch information
Showing
13 changed files
with
346 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.