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: Integrate online events #5012

Merged
merged 2 commits into from
Sep 9, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 45 additions & 0 deletions app/components/forms/wizard/basic-details-step.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,31 @@ export default Component.extend(FormMixin, EventWizardMixin, {

torii: service(),

locationMenuItems: ['Venue', 'Online', 'Mixed', 'To be announced'],

selectedLocationType: 'Venue',

deletedTickets: [],

init() {
this._super(...arguments);
if (this.data.event.online) {
if (this.data.event.locationName) {
this.selectedLocationType = 'Mixed';
} else {
this.selectedLocationType = 'Online';
}
} else if (this.data.event.locationName) {
this.selectedLocationType = 'Venue';
} else {
this.selectedLocationType = 'To be announced';
}
},

isLocationRequired: computed('selectedLocationType', function() {
return ['Venue', 'Mixed'].includes(this.selectedLocationType);
}),

countries: computed(function() {
return orderBy(countries, 'name');
}),
Expand Down Expand Up @@ -364,6 +387,28 @@ export default Component.extend(FormMixin, EventWizardMixin, {
prompt : this.l10n.t('Please select your country')
}
]
},
liveStreamUrl: {
identifier : 'live_stream_url',
optional : true,
rules : [
{
type : 'regExp',
value : protocolLessValidUrlPattern,
prompt : this.l10n.t('Please enter a valid url')
}
]
},
webinarUrl: {
identifier : 'webinar_url',
optional : true,
rules : [
{
type : 'regExp',
value : protocolLessValidUrlPattern,
prompt : this.l10n.t('Please enter a valid url')
}
]
}
}
};
Expand Down
19 changes: 15 additions & 4 deletions app/mixins/event-wizard.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ export default Mixin.create(MutableArray, CustomFormMixin, {
}
}
const numberOfTickets = data.tickets ? data.tickets.length : 0;
if (event.name && event.locationName && event.startsAtDate && event.endsAtDate && numberOfTickets > 0) {
if (event.name && event.startsAtDate && event.endsAtDate && numberOfTickets > 0) {
await event.save();

await Promise.all((data.tickets ? data.tickets.toArray() : []).map(ticket => {
Expand Down Expand Up @@ -205,21 +205,21 @@ export default Mixin.create(MutableArray, CustomFormMixin, {
actions: {
saveDraft() {
this.onValid(() => {
destroyDeletedTickets(this.deletedTickets);
preSaveActions.call(this);
this.set('data.event.state', 'draft');
this.sendAction('save');
});
},
moveForward() {
this.onValid(() => {
destroyDeletedTickets(this.deletedTickets);
preSaveActions.call(this);
this.sendAction('move');
});
},
publish() {
this.onValid(() => {
this.set('data.event.state', 'published');
destroyDeletedTickets(this.deletedTickets);
preSaveActions.call(this);
this.sendAction('save');
});
},
Expand All @@ -244,3 +244,14 @@ function destroyDeletedTickets(deletedTickets) {
ticket.destroyRecord();
});
}

function preSaveActions() {
destroyDeletedTickets(this.deletedTickets);

if (this.selectedLocationType) {
this.set('data.event.online', ['Online', 'Mixed'].includes(this.selectedLocationType));
if (['Online', 'To be announced'].includes(this.selectedLocationType)) {
this.set('data.event.locationName', null);
}
}
}
8 changes: 7 additions & 1 deletion app/models/event.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,10 @@ export default class Event extends ModelBase.extend(CustomPrimaryKeyMixin, {
xcalUrl : attr('string', { readOnly: true }),
icalUrl : attr('string', { readOnly: true }),

online : attr('boolean', { defaultValue: false }),
liveStreamUrl : attr('string'),
webinarUrl : attr('string'),

createdAt : attr('moment', { readOnly: true }),
deletedAt : attr('moment'),

Expand Down Expand Up @@ -153,7 +157,9 @@ export default class Event extends ModelBase.extend(CustomPrimaryKeyMixin, {
endsAtDate : computedDateTimeSplit.bind(this)('endsAt', 'date'),
endsAtTime : computedDateTimeSplit.bind(this)('endsAt', 'time'),

segmentedExternalEventUrl: computedSegmentedLink.bind(this)('externalEventUrl'),
segmentedExternalEventUrl : computedSegmentedLink.bind(this)('externalEventUrl'),
segmentedLiveStreamUrl : computedSegmentedLink.bind(this)('liveStreamUrl'),
segmentedWebinarUrl : computedSegmentedLink.bind(this)('webinarUrl'),

shortLocationName: computed('locationName', function() {
if (!this.locationName) {
Expand Down
2 changes: 1 addition & 1 deletion app/templates/components/forms/wizard/attendee-step.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@
<i class="save icon"></i>
</button>
{{/if}}
{{#if this.data.event.locationName}}
{{#if this.data.event.name}}
<button class="green ui three field right labeled icon button {{if this.isLoading 'disabled'}}" type="button" {{action 'publish'}}>
{{t 'Publish'}}
<i class="check icon"></i>
Expand Down
67 changes: 46 additions & 21 deletions app/templates/components/forms/wizard/basic-details-step.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -6,27 +6,52 @@
@id="name"
@value={{this.data.event.name}} />
</div>
<div class="field">
<label class="required" for="location">{{t 'Location'}}</label>
<Widgets::Forms::LocationInput
@inputId="location"
@lat={{this.data.event.latitude}}
@lng={{this.data.event.longitude}}
@placeName={{this.data.event.locationName}}
@searchableName={{this.data.event.searchableLocationName}}
@zoom={{15}}
@placeholder={{t "Location is required to make this event live"}}>
<div class="inline field">
<div class="ui slider checkbox">
<Input
@id="show_map"
@type="checkbox"
@checked={{this.data.event.isMapShown}} />
<label for="show_map">{{t 'Show map on event page'}}</label>
</div>
</div>
</Widgets::Forms::LocationInput>
<div class="ui secondary pointing menu">
{{#each this.locationMenuItems as |item|}}
<a role="button" href="#" class="{{if (eq item this.selectedLocationType) 'active'}} item" onclick={{action (mut this.selectedLocationType) item}}>
{{t item}}
</a>
{{/each}}
</div>
{{#if (or (eq this.selectedLocationType 'Venue') (eq this.selectedLocationType 'Mixed'))}}
<div class="field">
<label class="{{if this.isLocationRequired 'required'}}" for="location">{{t 'Location'}}</label>
<Widgets::Forms::LocationInput
@inputId="{{if this.isLocationRequired 'location'}}"
@lat={{this.data.event.latitude}}
@lng={{this.data.event.longitude}}
@placeName={{this.data.event.locationName}}
@searchableName={{this.data.event.searchableLocationName}}
@zoom={{15}}
@placeholder={{t "Location is required to make this event live"}}>
<div class="inline field">
<div class="ui slider checkbox">
<Input
@id="show_map"
@type="checkbox"
@checked={{this.data.event.isMapShown}} />
<label for="show_map">{{t 'Show map on event page'}}</label>
</div>
</div>
</Widgets::Forms::LocationInput>
</div>
{{/if}}
{{#if (or (eq this.selectedLocationType 'Online') (eq this.selectedLocationType 'Mixed'))}}
<Widgets::Forms::LinkInput
@hasLinkName={{true}}
@fixedName={{true}}
@linkName={{t "Live Stream URL"}}
@inputId="live_stream_url"
@segmentedLink={{this.data.event.segmentedLiveStreamUrl}}
@canRemoveItem={{false}} />
<Widgets::Forms::LinkInput
@hasLinkName={{true}}
@fixedName={{true}}
@linkName={{t "Webinar URL"}}
@inputId="webinar_url"
@segmentedLink={{this.data.event.segmentedWebinarUrl}}
@canRemoveItem={{false}} />
{{/if}}
<div class="fields">
<div class="five wide field">
<label class="required" for="start_date">{{t 'Starts'}}</label>
Expand Down Expand Up @@ -609,7 +634,7 @@
<i class="save icon"></i>
</button>
{{/if}}
{{#if this.data.event.locationName}}
{{#if this.data.event.name}}
<button class="green ui three field right labeled icon button {{if this.isLoading 'disabled'}}" type="button" {{action 'publish'}}>
{{t 'Publish'}}
<i class="check icon"></i>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@
<i class="save icon"></i>
</button>
{{/if}}
{{#if this.data.event.locationName}}
{{#if this.data.event.name}}
<button class="green ui three field right labeled icon button {{if this.isLoading 'disabled'}}" type="button" {{action 'publish'}}>
{{t 'Publish'}}
<i class="check icon"></i>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@
<i class="save icon"></i>
</button>
{{/if}}
{{#if this.data.event.locationName}}
{{#if this.data.event.name}}
<button class="green ui three field right labeled icon button {{if this.isLoading 'disabled'}}" type="button" {{action 'publish'}}>
{{t 'Publish'}}
<i class="check icon"></i>
Expand Down
2 changes: 1 addition & 1 deletion app/templates/components/forms/wizard/sponsors-step.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@
<i class="save icon"></i>
</button>
{{/if}}
{{#if this.data.event.locationName}}
{{#if this.data.event.name}}
<button class="green ui three field right labeled icon button {{if this.isLoading 'disabled'}}" type="button" {{action 'publish'}}>
{{t 'Publish'}}
<i class="check icon"></i>
Expand Down
30 changes: 14 additions & 16 deletions app/templates/components/public/event-map.hbs
Original file line number Diff line number Diff line change
@@ -1,19 +1,17 @@
{{#if this.event.isMapShown}}
<div class="eight wide column event-map">
<h1>{{t 'Getting Here'}}</h1>
{{#if (eq this.mapConfig.display 'embed') }}
<iframe title="Map" class="g-map" src="https://maps.google.com/maps?q={{this.event.locationName}}&t=&z=15&ie=UTF8&iwloc=&output=embed" frameborder="0" scrolling="no"></iframe>
{{else}}
<GMap @markersFitMode="live" @lat={{37.744}} @lng={{-122.4367}} @address={{this.event.locationName}} @zoom={{2}} @class="google-maps" as |context|>
{{#g-map-address-marker context address=this.event.locationName as |markerContext|}}
{{#g-map-infowindow markerContext}}
{{this.event.locationName}}
{{/g-map-infowindow}}
{{/g-map-address-marker}}
</GMap>
{{/if}}
</div>
{{/if}}
<div class="eight wide column event-map">
<h1>{{t 'Getting Here'}}</h1>
{{#if (eq this.mapConfig.display 'embed') }}
<iframe title="Map" class="g-map" src="https://maps.google.com/maps?q={{this.event.locationName}}&t=&z=15&ie=UTF8&iwloc=&output=embed" frameborder="0" scrolling="no"></iframe>
{{else}}
<GMap @markersFitMode="live" @lat={{37.744}} @lng={{-122.4367}} @address={{this.event.locationName}} @zoom={{2}} @class="google-maps" as |context|>
{{#g-map-address-marker context address=this.event.locationName as |markerContext|}}
{{#g-map-infowindow markerContext}}
{{this.event.locationName}}
{{/g-map-infowindow}}
{{/g-map-address-marker}}
</GMap>
{{/if}}
</div>
<div class="{{if this.event.isMapShown 'eight' 'sixteen'}} wide column address">
<h1>{{t 'Address'}}</h1>
<p>{{this.event.locationName}}</p>
Expand Down
24 changes: 21 additions & 3 deletions app/templates/public/index.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,27 @@
<div class="ui hidden divider"></div>
{{/if}}
<div class="location" id="getting-here">
<Public::EventMap
@event={{this.model.event}}
@mapConfig={{this.model.mapConfig}} />
{{#if this.model.event.locationName}}
<Public::EventMap
@event={{this.model.event}}
@mapConfig={{this.model.mapConfig}} />
{{/if}}
{{#if this.model.event.online}}
<h2>{{t 'Online Event'}}</h2>
{{#if this.model.event.liveStreamUrl}}
<div>
Live Stream: <a href="{{this.model.event.liveStreamUrl}}" target="_blank" rel="noopener noreferrer">{{this.model.event.liveStreamUrl}}</a>
</div>
{{/if}}
{{#if this.model.event.webinarUrl}}
<div>
Webinar: <a href="{{this.model.event.webinarUrl}}" target="_blank" rel="noopener noreferrer">{{this.model.event.webinarUrl}}</a>
</div>
{{/if}}
{{/if}}
{{#if (not (or this.model.event.online this.model.event.locationName))}}
<h2>{{t 'Location to be announced'}}</h2>
{{/if}}
</div>
<div class="ui hidden divider"></div>
{{#if this.model.event.copyright}}
Expand Down