Skip to content

Commit 5b7251b

Browse files
feat: Integrate online events (#5012)
1 parent 9b50dd4 commit 5b7251b

File tree

10 files changed

+152
-49
lines changed

10 files changed

+152
-49
lines changed

app/components/forms/wizard/basic-details-step.js

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,31 @@ export default Component.extend(FormMixin, EventWizardMixin, {
2020

2121
torii: service(),
2222

23+
locationMenuItems: ['Venue', 'Online', 'Mixed', 'To be announced'],
24+
25+
selectedLocationType: 'Venue',
26+
2327
deletedTickets: [],
2428

29+
init() {
30+
this._super(...arguments);
31+
if (this.data.event.online) {
32+
if (this.data.event.locationName) {
33+
this.selectedLocationType = 'Mixed';
34+
} else {
35+
this.selectedLocationType = 'Online';
36+
}
37+
} else if (this.data.event.locationName) {
38+
this.selectedLocationType = 'Venue';
39+
} else {
40+
this.selectedLocationType = 'To be announced';
41+
}
42+
},
43+
44+
isLocationRequired: computed('selectedLocationType', function() {
45+
return ['Venue', 'Mixed'].includes(this.selectedLocationType);
46+
}),
47+
2548
countries: computed(function() {
2649
return orderBy(countries, 'name');
2750
}),
@@ -364,6 +387,28 @@ export default Component.extend(FormMixin, EventWizardMixin, {
364387
prompt : this.l10n.t('Please select your country')
365388
}
366389
]
390+
},
391+
liveStreamUrl: {
392+
identifier : 'live_stream_url',
393+
optional : true,
394+
rules : [
395+
{
396+
type : 'regExp',
397+
value : protocolLessValidUrlPattern,
398+
prompt : this.l10n.t('Please enter a valid url')
399+
}
400+
]
401+
},
402+
webinarUrl: {
403+
identifier : 'webinar_url',
404+
optional : true,
405+
rules : [
406+
{
407+
type : 'regExp',
408+
value : protocolLessValidUrlPattern,
409+
prompt : this.l10n.t('Please enter a valid url')
410+
}
411+
]
367412
}
368413
}
369414
};

app/mixins/event-wizard.js

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ export default Mixin.create(MutableArray, CustomFormMixin, {
7171
}
7272
}
7373
const numberOfTickets = data.tickets ? data.tickets.length : 0;
74-
if (event.name && event.locationName && event.startsAtDate && event.endsAtDate && numberOfTickets > 0) {
74+
if (event.name && event.startsAtDate && event.endsAtDate && numberOfTickets > 0) {
7575
await event.save();
7676

7777
await Promise.all((data.tickets ? data.tickets.toArray() : []).map(ticket => {
@@ -205,21 +205,21 @@ export default Mixin.create(MutableArray, CustomFormMixin, {
205205
actions: {
206206
saveDraft() {
207207
this.onValid(() => {
208-
destroyDeletedTickets(this.deletedTickets);
208+
preSaveActions.call(this);
209209
this.set('data.event.state', 'draft');
210210
this.sendAction('save');
211211
});
212212
},
213213
moveForward() {
214214
this.onValid(() => {
215-
destroyDeletedTickets(this.deletedTickets);
215+
preSaveActions.call(this);
216216
this.sendAction('move');
217217
});
218218
},
219219
publish() {
220220
this.onValid(() => {
221221
this.set('data.event.state', 'published');
222-
destroyDeletedTickets(this.deletedTickets);
222+
preSaveActions.call(this);
223223
this.sendAction('save');
224224
});
225225
},
@@ -244,3 +244,14 @@ function destroyDeletedTickets(deletedTickets) {
244244
ticket.destroyRecord();
245245
});
246246
}
247+
248+
function preSaveActions() {
249+
destroyDeletedTickets(this.deletedTickets);
250+
251+
if (this.selectedLocationType) {
252+
this.set('data.event.online', ['Online', 'Mixed'].includes(this.selectedLocationType));
253+
if (['Online', 'To be announced'].includes(this.selectedLocationType)) {
254+
this.set('data.event.locationName', null);
255+
}
256+
}
257+
}

app/models/event.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,10 @@ export default class Event extends ModelBase.extend(CustomPrimaryKeyMixin, {
8888
xcalUrl : attr('string', { readOnly: true }),
8989
icalUrl : attr('string', { readOnly: true }),
9090

91+
online : attr('boolean', { defaultValue: false }),
92+
liveStreamUrl : attr('string'),
93+
webinarUrl : attr('string'),
94+
9195
createdAt : attr('moment', { readOnly: true }),
9296
deletedAt : attr('moment'),
9397

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

156-
segmentedExternalEventUrl: computedSegmentedLink.bind(this)('externalEventUrl'),
160+
segmentedExternalEventUrl : computedSegmentedLink.bind(this)('externalEventUrl'),
161+
segmentedLiveStreamUrl : computedSegmentedLink.bind(this)('liveStreamUrl'),
162+
segmentedWebinarUrl : computedSegmentedLink.bind(this)('webinarUrl'),
157163

158164
shortLocationName: computed('locationName', function() {
159165
if (!this.locationName) {

app/templates/components/forms/wizard/attendee-step.hbs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@
7575
<i class="save icon"></i>
7676
</button>
7777
{{/if}}
78-
{{#if this.data.event.locationName}}
78+
{{#if this.data.event.name}}
7979
<button class="green ui three field right labeled icon button {{if this.isLoading 'disabled'}}" type="button" {{action 'publish'}}>
8080
{{t 'Publish'}}
8181
<i class="check icon"></i>

app/templates/components/forms/wizard/basic-details-step.hbs

Lines changed: 46 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -6,27 +6,52 @@
66
@id="name"
77
@value={{this.data.event.name}} />
88
</div>
9-
<div class="field">
10-
<label class="required" for="location">{{t 'Location'}}</label>
11-
<Widgets::Forms::LocationInput
12-
@inputId="location"
13-
@lat={{this.data.event.latitude}}
14-
@lng={{this.data.event.longitude}}
15-
@placeName={{this.data.event.locationName}}
16-
@searchableName={{this.data.event.searchableLocationName}}
17-
@zoom={{15}}
18-
@placeholder={{t "Location is required to make this event live"}}>
19-
<div class="inline field">
20-
<div class="ui slider checkbox">
21-
<Input
22-
@id="show_map"
23-
@type="checkbox"
24-
@checked={{this.data.event.isMapShown}} />
25-
<label for="show_map">{{t 'Show map on event page'}}</label>
26-
</div>
27-
</div>
28-
</Widgets::Forms::LocationInput>
9+
<div class="ui secondary pointing menu">
10+
{{#each this.locationMenuItems as |item|}}
11+
<a role="button" href="#" class="{{if (eq item this.selectedLocationType) 'active'}} item" onclick={{action (mut this.selectedLocationType) item}}>
12+
{{t item}}
13+
</a>
14+
{{/each}}
2915
</div>
16+
{{#if (or (eq this.selectedLocationType 'Venue') (eq this.selectedLocationType 'Mixed'))}}
17+
<div class="field">
18+
<label class="{{if this.isLocationRequired 'required'}}" for="location">{{t 'Location'}}</label>
19+
<Widgets::Forms::LocationInput
20+
@inputId="{{if this.isLocationRequired 'location'}}"
21+
@lat={{this.data.event.latitude}}
22+
@lng={{this.data.event.longitude}}
23+
@placeName={{this.data.event.locationName}}
24+
@searchableName={{this.data.event.searchableLocationName}}
25+
@zoom={{15}}
26+
@placeholder={{t "Location is required to make this event live"}}>
27+
<div class="inline field">
28+
<div class="ui slider checkbox">
29+
<Input
30+
@id="show_map"
31+
@type="checkbox"
32+
@checked={{this.data.event.isMapShown}} />
33+
<label for="show_map">{{t 'Show map on event page'}}</label>
34+
</div>
35+
</div>
36+
</Widgets::Forms::LocationInput>
37+
</div>
38+
{{/if}}
39+
{{#if (or (eq this.selectedLocationType 'Online') (eq this.selectedLocationType 'Mixed'))}}
40+
<Widgets::Forms::LinkInput
41+
@hasLinkName={{true}}
42+
@fixedName={{true}}
43+
@linkName={{t "Live Stream URL"}}
44+
@inputId="live_stream_url"
45+
@segmentedLink={{this.data.event.segmentedLiveStreamUrl}}
46+
@canRemoveItem={{false}} />
47+
<Widgets::Forms::LinkInput
48+
@hasLinkName={{true}}
49+
@fixedName={{true}}
50+
@linkName={{t "Webinar URL"}}
51+
@inputId="webinar_url"
52+
@segmentedLink={{this.data.event.segmentedWebinarUrl}}
53+
@canRemoveItem={{false}} />
54+
{{/if}}
3055
<div class="fields">
3156
<div class="five wide field">
3257
<label class="required" for="start_date">{{t 'Starts'}}</label>
@@ -609,7 +634,7 @@
609634
<i class="save icon"></i>
610635
</button>
611636
{{/if}}
612-
{{#if this.data.event.locationName}}
637+
{{#if this.data.event.name}}
613638
<button class="green ui three field right labeled icon button {{if this.isLoading 'disabled'}}" type="button" {{action 'publish'}}>
614639
{{t 'Publish'}}
615640
<i class="check icon"></i>

app/templates/components/forms/wizard/other-details-step.hbs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@
132132
<i class="save icon"></i>
133133
</button>
134134
{{/if}}
135-
{{#if this.data.event.locationName}}
135+
{{#if this.data.event.name}}
136136
<button class="green ui three field right labeled icon button {{if this.isLoading 'disabled'}}" type="button" {{action 'publish'}}>
137137
{{t 'Publish'}}
138138
<i class="check icon"></i>

app/templates/components/forms/wizard/sessions-speakers-step.hbs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@
265265
<i class="save icon"></i>
266266
</button>
267267
{{/if}}
268-
{{#if this.data.event.locationName}}
268+
{{#if this.data.event.name}}
269269
<button class="green ui three field right labeled icon button {{if this.isLoading 'disabled'}}" type="button" {{action 'publish'}}>
270270
{{t 'Publish'}}
271271
<i class="check icon"></i>

app/templates/components/forms/wizard/sponsors-step.hbs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@
103103
<i class="save icon"></i>
104104
</button>
105105
{{/if}}
106-
{{#if this.data.event.locationName}}
106+
{{#if this.data.event.name}}
107107
<button class="green ui three field right labeled icon button {{if this.isLoading 'disabled'}}" type="button" {{action 'publish'}}>
108108
{{t 'Publish'}}
109109
<i class="check icon"></i>

app/templates/components/public/event-map.hbs

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,17 @@
1-
{{#if this.event.isMapShown}}
2-
<div class="eight wide column event-map">
3-
<h1>{{t 'Getting Here'}}</h1>
4-
{{#if (eq this.mapConfig.display 'embed') }}
5-
<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>
6-
{{else}}
7-
<GMap @markersFitMode="live" @lat={{37.744}} @lng={{-122.4367}} @address={{this.event.locationName}} @zoom={{2}} @class="google-maps" as |context|>
8-
{{#g-map-address-marker context address=this.event.locationName as |markerContext|}}
9-
{{#g-map-infowindow markerContext}}
10-
{{this.event.locationName}}
11-
{{/g-map-infowindow}}
12-
{{/g-map-address-marker}}
13-
</GMap>
14-
{{/if}}
15-
</div>
16-
{{/if}}
1+
<div class="eight wide column event-map">
2+
<h1>{{t 'Getting Here'}}</h1>
3+
{{#if (eq this.mapConfig.display 'embed') }}
4+
<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>
5+
{{else}}
6+
<GMap @markersFitMode="live" @lat={{37.744}} @lng={{-122.4367}} @address={{this.event.locationName}} @zoom={{2}} @class="google-maps" as |context|>
7+
{{#g-map-address-marker context address=this.event.locationName as |markerContext|}}
8+
{{#g-map-infowindow markerContext}}
9+
{{this.event.locationName}}
10+
{{/g-map-infowindow}}
11+
{{/g-map-address-marker}}
12+
</GMap>
13+
{{/if}}
14+
</div>
1715
<div class="{{if this.event.isMapShown 'eight' 'sixteen'}} wide column address">
1816
<h1>{{t 'Address'}}</h1>
1917
<p>{{this.event.locationName}}</p>

app/templates/public/index.hbs

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,27 @@
6565
<div class="ui hidden divider"></div>
6666
{{/if}}
6767
<div class="location" id="getting-here">
68-
<Public::EventMap
69-
@event={{this.model.event}}
70-
@mapConfig={{this.model.mapConfig}} />
68+
{{#if this.model.event.locationName}}
69+
<Public::EventMap
70+
@event={{this.model.event}}
71+
@mapConfig={{this.model.mapConfig}} />
72+
{{/if}}
73+
{{#if this.model.event.online}}
74+
<h2>{{t 'Online Event'}}</h2>
75+
{{#if this.model.event.liveStreamUrl}}
76+
<div>
77+
Live Stream: <a href="{{this.model.event.liveStreamUrl}}" target="_blank" rel="noopener noreferrer">{{this.model.event.liveStreamUrl}}</a>
78+
</div>
79+
{{/if}}
80+
{{#if this.model.event.webinarUrl}}
81+
<div>
82+
Webinar: <a href="{{this.model.event.webinarUrl}}" target="_blank" rel="noopener noreferrer">{{this.model.event.webinarUrl}}</a>
83+
</div>
84+
{{/if}}
85+
{{/if}}
86+
{{#if (not (or this.model.event.online this.model.event.locationName))}}
87+
<h2>{{t 'Location to be announced'}}</h2>
88+
{{/if}}
7189
</div>
7290
<div class="ui hidden divider"></div>
7391
{{#if this.model.event.copyright}}

0 commit comments

Comments
 (0)