From 4f3b0dbe6d068d3eab51b5ca211318cb9948cfc2 Mon Sep 17 00:00:00 2001 From: iamareebjamal Date: Tue, 8 Sep 2020 12:29:51 +0530 Subject: [PATCH 1/2] wip --- .../forms/wizard/basic-details-step.js | 45 +++++++++++++ app/mixins/event-wizard.js | 16 +++-- app/models/event.js | 6 ++ .../forms/wizard/basic-details-step.hbs | 65 +++++++++++++------ 4 files changed, 108 insertions(+), 24 deletions(-) diff --git a/app/components/forms/wizard/basic-details-step.js b/app/components/forms/wizard/basic-details-step.js index 5cde82a3c0d..ddae81a3704 100644 --- a/app/components/forms/wizard/basic-details-step.js +++ b/app/components/forms/wizard/basic-details-step.js @@ -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 anounced'; + } + }, + + isLocationRequired: computed('selectedLocationType', function() { + return ['Venue', 'Mixed'].includes(this.selectedLocationType); + }), + countries: computed(function() { return orderBy(countries, 'name'); }), @@ -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') + } + ] } } }; diff --git a/app/mixins/event-wizard.js b/app/mixins/event-wizard.js index e30e7cbcb12..1b9565662b4 100644 --- a/app/mixins/event-wizard.js +++ b/app/mixins/event-wizard.js @@ -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 => { @@ -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'); }); }, @@ -244,3 +244,11 @@ function destroyDeletedTickets(deletedTickets) { ticket.destroyRecord(); }); } + +function preSaveActions() { + destroyDeletedTickets(this.deletedTickets); + + if (this.selectedLocationType) { + this.set('data.event.online', ['Online', 'Mixed'].includes(this.selectedLocationType)); + } +} diff --git a/app/models/event.js b/app/models/event.js index d0c66c9c4d4..a41e14c1c09 100644 --- a/app/models/event.js +++ b/app/models/event.js @@ -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: true }), + liveStreamUrl : attr('string'), + webinarUrl : attr('string'), + createdAt : attr('moment', { readOnly: true }), deletedAt : attr('moment'), @@ -154,6 +158,8 @@ export default class Event extends ModelBase.extend(CustomPrimaryKeyMixin, { endsAtTime : computedDateTimeSplit.bind(this)('endsAt', 'time'), segmentedExternalEventUrl: computedSegmentedLink.bind(this)('externalEventUrl'), + segmentedLiveStreamUrl: computedSegmentedLink.bind(this)('liveStreamUrl'), + segmentedWebinarEventUrl: computedSegmentedLink.bind(this)('webinarUrl'), shortLocationName: computed('locationName', function() { if (!this.locationName) { diff --git a/app/templates/components/forms/wizard/basic-details-step.hbs b/app/templates/components/forms/wizard/basic-details-step.hbs index ce0a7bded0d..e55734e47a5 100644 --- a/app/templates/components/forms/wizard/basic-details-step.hbs +++ b/app/templates/components/forms/wizard/basic-details-step.hbs @@ -6,27 +6,52 @@ @id="name" @value={{this.data.event.name}} /> -
- - -
-
- - -
-
-
+ + {{#if (or (eq this.selectedLocationType 'Venue') (eq this.selectedLocationType 'Mixed'))}} +
+ + +
+
+ + +
+
+
+
+ {{/if}} + {{#if (or (eq this.selectedLocationType 'Online') (eq this.selectedLocationType 'Mixed'))}} + + + {{/if}}
From 4124789066fd59e001a74fb9ca304bba360f424f Mon Sep 17 00:00:00 2001 From: iamareebjamal Date: Wed, 9 Sep 2020 05:35:22 +0530 Subject: [PATCH 2/2] fix --- .../forms/wizard/basic-details-step.js | 2 +- app/mixins/event-wizard.js | 3 ++ app/models/event.js | 8 ++--- .../components/forms/wizard/attendee-step.hbs | 2 +- .../forms/wizard/basic-details-step.hbs | 4 +-- .../forms/wizard/other-details-step.hbs | 2 +- .../forms/wizard/sessions-speakers-step.hbs | 2 +- .../components/forms/wizard/sponsors-step.hbs | 2 +- app/templates/components/public/event-map.hbs | 30 +++++++++---------- app/templates/public/index.hbs | 24 +++++++++++++-- 10 files changed, 49 insertions(+), 30 deletions(-) diff --git a/app/components/forms/wizard/basic-details-step.js b/app/components/forms/wizard/basic-details-step.js index ddae81a3704..717475ed5be 100644 --- a/app/components/forms/wizard/basic-details-step.js +++ b/app/components/forms/wizard/basic-details-step.js @@ -37,7 +37,7 @@ export default Component.extend(FormMixin, EventWizardMixin, { } else if (this.data.event.locationName) { this.selectedLocationType = 'Venue'; } else { - this.selectedLocationType = 'To be anounced'; + this.selectedLocationType = 'To be announced'; } }, diff --git a/app/mixins/event-wizard.js b/app/mixins/event-wizard.js index 1b9565662b4..2eea33b83c9 100644 --- a/app/mixins/event-wizard.js +++ b/app/mixins/event-wizard.js @@ -250,5 +250,8 @@ function preSaveActions() { 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); + } } } diff --git a/app/models/event.js b/app/models/event.js index a41e14c1c09..7a155666377 100644 --- a/app/models/event.js +++ b/app/models/event.js @@ -88,7 +88,7 @@ export default class Event extends ModelBase.extend(CustomPrimaryKeyMixin, { xcalUrl : attr('string', { readOnly: true }), icalUrl : attr('string', { readOnly: true }), - online : attr('boolean', { defaultValue: true }), + online : attr('boolean', { defaultValue: false }), liveStreamUrl : attr('string'), webinarUrl : attr('string'), @@ -157,9 +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'), - segmentedLiveStreamUrl: computedSegmentedLink.bind(this)('liveStreamUrl'), - segmentedWebinarEventUrl: computedSegmentedLink.bind(this)('webinarUrl'), + segmentedExternalEventUrl : computedSegmentedLink.bind(this)('externalEventUrl'), + segmentedLiveStreamUrl : computedSegmentedLink.bind(this)('liveStreamUrl'), + segmentedWebinarUrl : computedSegmentedLink.bind(this)('webinarUrl'), shortLocationName: computed('locationName', function() { if (!this.locationName) { diff --git a/app/templates/components/forms/wizard/attendee-step.hbs b/app/templates/components/forms/wizard/attendee-step.hbs index 9a36b63ca3e..0468a2534ea 100644 --- a/app/templates/components/forms/wizard/attendee-step.hbs +++ b/app/templates/components/forms/wizard/attendee-step.hbs @@ -75,7 +75,7 @@ {{/if}} - {{#if this.data.event.locationName}} + {{#if this.data.event.name}}