Skip to content

feat: Make Event Saving, Draft Mode, Publishing Clearer #4942

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

Closed
wants to merge 38 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
aeed858
Update basic-details-step.hbs
maze-runnar Sep 2, 2020
829ab7c
Update basic-details-step.js
maze-runnar Sep 2, 2020
6f8af2c
Update event-wizard.js
maze-runnar Sep 2, 2020
76a7bea
removing preview and view buttons, restrcting ublishing a new event
maze-runnar Sep 2, 2020
808af51
adding cancel button
maze-runnar Sep 2, 2020
41f72f0
reverting cancel button
maze-runnar Sep 2, 2020
7f51bcb
adding check for event is for first-time or not
maze-runnar Sep 3, 2020
dbe6946
adding computed function firstTimeEvent
maze-runnar Sep 3, 2020
19470de
commiting suggested changes
maze-runnar Sep 3, 2020
99de279
checking for number of tickets
maze-runnar Sep 3, 2020
2d4c144
adding unpublish action
maze-runnar Sep 3, 2020
b012132
Update attendee-step.js
maze-runnar Sep 3, 2020
0164f63
adding ticket and unpublish action
maze-runnar Sep 3, 2020
17cf7ab
Update sponsors-step.js
maze-runnar Sep 3, 2020
848892d
adding cancel, preview and unpublish
maze-runnar Sep 3, 2020
2c26589
Update basic-details-step.hbs
maze-runnar Sep 3, 2020
15d4ae8
Update other-details-step.hbs
maze-runnar Sep 3, 2020
aed85a0
Update sessions-speakers-step.hbs
maze-runnar Sep 3, 2020
1a8c59d
Update sponsors-step.hbs
maze-runnar Sep 3, 2020
93dae27
Merge branch 'development' into patch-2
maze-runnar Sep 3, 2020
ea1d4f8
Update app/components/forms/wizard/attendee-step.js
maze-runnar Sep 3, 2020
3aa5c8f
Update app/components/forms/wizard/attendee-step.js
maze-runnar Sep 3, 2020
97726f6
making function name useful
maze-runnar Sep 3, 2020
27e3de6
Update other-details-step.js
maze-runnar Sep 3, 2020
3a242ca
Update sessions-speakers-step.js
maze-runnar Sep 3, 2020
83f51ef
making computed property name meaningful
maze-runnar Sep 3, 2020
42a9333
Update attendee-step.hbs
maze-runnar Sep 3, 2020
a84a8f3
Update basic-details-step.hbs
maze-runnar Sep 3, 2020
72cb2cb
Update other-details-step.hbs
maze-runnar Sep 3, 2020
39d4548
Update sessions-speakers-step.hbs
maze-runnar Sep 3, 2020
c656327
Update sponsors-step.hbs
maze-runnar Sep 3, 2020
3dfe4d2
Update app/templates/components/forms/wizard/basic-details-step.hbs
maze-runnar Sep 3, 2020
f997d31
fixing syntax error
maze-runnar Sep 3, 2020
e13a785
fixing codacy
maze-runnar Sep 3, 2020
a218fda
fixing codacy
maze-runnar Sep 3, 2020
243f56a
fixing an unusual syntax error
maze-runnar Sep 3, 2020
7bf19fc
comma
maze-runnar Sep 3, 2020
7c75a5e
trailing space fix
maze-runnar Sep 3, 2020
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
10 changes: 10 additions & 0 deletions app/components/forms/wizard/attendee-step.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ export default Component.extend(FormMixin, {
return this.data.customForms?.filter(field => !field.isFixed);
}),

ticketsPresent: computed('data.event.tickets.@each', function() {
return this.data.event.tickets.length > 0;
}),

showEditColumn: computed('editableFields.@each', function() {
return this.editableFields?.some(field => field.isComplex);
}),
Expand All @@ -33,6 +37,12 @@ export default Component.extend(FormMixin, {
this.set('data.event.state', 'published');
this.sendAction('save', this.data);
});
},
unpublish() {
this.onValid(() => {
this.set('data.event.state', 'draft');
this.sendAction('save', this.data);
});
}
}
});
17 changes: 8 additions & 9 deletions app/components/forms/wizard/basic-details-step.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,14 @@ export default Component.extend(FormMixin, EventWizardMixin, {
return this.data.event.state !== 'published';
}),

ticketsPresent: computed('data.event.tickets.@each', function() {
return this.data.event.tickets.length > 0;
}),

unsavedEvent: computed('data.event.identifier', function() {
return !this.data.event.identifier;
}),

hasPaidTickets: computed('data.event.tickets.@each.type', function() {
return this.data.event.tickets.toArray().filter(ticket => ticket.type === 'paid' || ticket.type === 'donation').length > 0;
}),
Expand Down Expand Up @@ -120,15 +128,6 @@ export default Component.extend(FormMixin, EventWizardMixin, {
}
]
},
location: {
identifier : 'location',
rules : [
{
type : 'empty',
prompt : this.l10n.t('Location is required to save an event')
}
]
},
timezone: {
identifier : 'timezone',
rules : [
Expand Down
10 changes: 10 additions & 0 deletions app/components/forms/wizard/other-details-step.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ export default Component.extend(FormMixin, EventWizardMixin, {
return !!this.data.event.codeOfConduct;
}),

ticketsPresent: computed('data.event.tickets.@each', function() {
return this.data.event.tickets.length > 0;
}),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is present in all 3 components

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

where i should put it?

Copy link
Contributor Author

@maze-runnar maze-runnar Sep 3, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can I put it in event-wizard in mixins? Will it work from there for all these components?


didInsertElement() {
if (!this.isCreate && this.data.event.copyright && !this.data.event.copyright.content) {
this.set('data.event.copyright', this.store.createRecord('event-copyright'));
Expand Down Expand Up @@ -132,6 +136,12 @@ export default Component.extend(FormMixin, EventWizardMixin, {
this.sendAction('save');
});
},
unpublish() {
this.onValid(() => {
this.set('data.event.state', 'draft');
this.sendAction('save');
});
},
onChange() {
this.onValid(() => {});
}
Expand Down
10 changes: 10 additions & 0 deletions app/components/forms/wizard/sessions-speakers-step.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,10 @@ export default Component.extend(EventWizardMixin, FormMixin, {
return this.data.customForms.filterBy('isComplex', true);
}),

ticketsPresent: computed('data.event.tickets.@each', function() {
return this.data.event.tickets.length > 0;
}),

fieldChanged(field) {
if (!field.get('isIncluded')) {
field.set('isRequired', false);
Expand Down Expand Up @@ -181,6 +185,12 @@ export default Component.extend(EventWizardMixin, FormMixin, {
this.sendAction('save');
});
},
unpublish() {
this.onValid(() => {
this.set('data.event.state', 'draft');
this.sendAction('save', this.data);
});
},
addItem(type) {
switch (type) {
case 'sessionType':
Expand Down
11 changes: 10 additions & 1 deletion app/components/forms/wizard/sponsors-step.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ export default Component.extend(FormMixin, {
return this.data.sponsors.filterBy('isDeleted', false);
}),

ticketsPresent: computed('data.event.tickets.@each', function() {
return this.data.event.tickets.length > 0;
}),

actions: {
addSponsor() {
const { sponsors } = this.data;
Expand Down Expand Up @@ -68,9 +72,14 @@ export default Component.extend(FormMixin, {
this.set('data.event.state', 'published');
this.sendAction('save');
});
},
unpublish() {
this.onValid(() => {
this.set('data.event.state', 'draft');
this.sendAction('save', this.data);
});
}
},

didInsertElement() {
if (this.data.sponsors && !this.data.sponsors.length) {
this.data.sponsors.addObject(this.store.createRecord('sponsor'));
Expand Down
9 changes: 8 additions & 1 deletion 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) {
await event.save();

await Promise.all((data.tickets ? data.tickets.toArray() : []).map(ticket => {
Expand Down Expand Up @@ -223,6 +223,13 @@ export default Mixin.create(MutableArray, CustomFormMixin, {
this.sendAction('save');
});
},
unpublish() {
this.onValid(() => {
this.set('data.event.state', 'draft');
destroyDeletedTickets(this.deletedTickets);
this.sendAction('save');
});
},
addItem(type, model) {
if (type === 'socialLinks') {
this.get(`data.event.${type}`).pushObject(this.store.createRecord(model, {
Expand Down
32 changes: 27 additions & 5 deletions app/templates/components/forms/wizard/attendee-step.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@
{{/if}}
<div class="spacer-50"></div>
<div class="{{if this.device.isMobile 'mini four' 'right floated large'}} ui fields buttons">
<LinkTo @route="events.view.index" @model={{this.data.event.identifier}} class="red ui three field right labeled icon button">
{{t 'Cancel'}}<i class="close icon"></i>
</LinkTo>
<button class="ui three field left labeled icon button {{if this.isLoading 'disabled'}}" type="button" {{action 'move' 'backwards'}}>
{{t 'Previous'}}
<i class="left chevron icon"></i>
Expand All @@ -75,11 +78,30 @@
<i class="save icon"></i>
</button>
{{/if}}
{{#if this.data.event.locationName}}
<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>
</button>
</div>
<br><br><br>
<div class="{{if this.device.isMobile 'mini four' 'right floated large'}} ui fields buttons">
{{#if (eq this.data.event.state 'draft')}}
<a href="{{this.data.event.url}}" class="ui three field right labeled icon button">
{{t 'View'}} <i class="hide icon"></i>
</a>
{{else}}
<a href="{{this.data.event.url}}" class="green ui three field right labeled icon button">
{{t 'Preview'}} <i class="unhide icon"></i>
</a>
{{/if}}
{{#if (and this.data.event.locationName ticketsPresent)}}
{{#if (eq this.data.event.state "draft")}}
<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>
</button>
{{else}}
<button class="orange ui three field right labeled icon button {{if this.isLoading 'disabled'}}" type="button" {{action 'unpublish'}}>
{{t 'Unpublish'}}
<i class="ban icon"></i>
</button>
{{/if}}
{{/if}}
</div>
</form>
33 changes: 32 additions & 1 deletion app/templates/components/forms/wizard/basic-details-step.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -595,6 +595,15 @@

<br>
<div class="{{unless this.device.isMobile 'right floated large' 'mini three'}} ui fields {{if this.isUserUnverified 'disabled'}} buttons">
{{#if this.unsavedEvent}}
<LinkTo @route="events.list" @model="live" class="orange ui three field right labeled icon button">
{{t 'Discard'}} <i class="close icon"></i>
</LinkTo>
{{else}}
<LinkTo @route="events.view.index" @model={{this.data.event.identifier}} class="red ui three field right labeled icon button">
{{t 'Cancel'}} <i class="close icon"></i>
</LinkTo>
{{/if}}
<button class="ui three field right labeled icon button {{if this.isLoading 'disabled'}}" type="button" {{action 'moveForward'}}>
{{t 'Forward'}}
<i class="right chevron icon"></i>
Expand All @@ -605,11 +614,33 @@
<i class="save icon"></i>
</button>
{{/if}}
{{#if this.data.event.locationName}}
</div>
<br><br><br>
<div class="{{unless this.device.isMobile 'right floated large' 'mini three'}} ui fields {{if this.isUserUnverified 'disabled'}} buttons">
{{#if (not this.unsavedEvent)}}
{{#if (eq this.data.event.state 'draft')}}
<a href="{{this.data.event.url}}" class="ui three field right labeled icon button">
{{t 'View'}} <i class="hide icon"></i>
</a>
{{else}}
<a href="{{this.data.event.url}}" class="green ui three field right labeled icon button">
{{t 'Preview'}} <i class="unhide icon"></i>
</a>
{{/if}}
{{/if}}
{{#if (and this.data.event.locationName this.ticketsPresent)}}
{{#if (eq this.data.event.state 'draft')}}
<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>
</button>
{{/if}}
{{#if (eq this.data.event.state 'published')}}
<button class="orange ui three field right labeled icon button {{if this.isLoading 'disabled'}}" type="button" {{action 'unpublish'}}>
{{t 'Unpublish'}}
<i class="ban icon"></i>
</button>
{{/if}}
{{/if}}
</div>
</form>
Expand Down
25 changes: 24 additions & 1 deletion app/templates/components/forms/wizard/other-details-step.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,9 @@
</div>
<br>
<div class="{{unless this.device.isMobile 'right floated large' 'mini three'}} ui fields {{if this.isUserUnverified 'disabled'}} buttons">
<LinkTo @route="events.view.index" @model={{this.data.event.identifier}} class="red ui three field right labeled icon button">
{{t 'Cancel'}}<i class="close icon"></i>
</LinkTo>
<button class="ui three field left labeled icon button {{if this.isLoading 'disabled'}}" type="button" {{action 'move' 'backwards'}}>
{{t 'Previous'}}
<i class="left chevron icon"></i>
Expand All @@ -125,11 +128,31 @@
<i class="save icon"></i>
</button>
{{/if}}
{{#if this.data.event.locationName}}
</div>
<br><br><br>
<div class="{{unless this.device.isMobile 'right floated large' 'mini three'}} ui fields {{if this.isUserUnverified 'disabled'}} buttons">
{{#if (eq this.data.event.state 'draft')}}
<a href="{{this.data.event.url}}" class="ui three field right labeled icon button">
{{t 'View'}} <i class="hide icon"></i>
</a>
{{else}}
<a href="{{this.data.event.url}}" class="green ui three field right labeled icon button">
{{t 'Preview'}} <i class="unhide icon"></i>
</a>
{{/if}}
{{#if (and this.data.event.locationName ticketsPresent)}}
{{#if (eq this.data.event.state 'draft')}}
<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>
</button>
{{/if}}
{{#if (eq this.data.event.state 'published')}}
<button class="orange ui three field right labeled icon button {{if this.isLoading 'disabled'}}" type="button" {{action 'unpublish'}}>
{{t 'Unpublish'}}
<i class="ban icon"></i>
</button>
{{/if}}
{{/if}}
</div>
</form>
31 changes: 26 additions & 5 deletions app/templates/components/forms/wizard/sessions-speakers-step.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,9 @@

--}}
<div class="ui fields buttons {{if this.device.isMobile 'mini three' 'right floated large'}}">
<LinkTo @route="events.view.index" @model={{this.data.event.identifier}} class="red ui three field right labeled icon button">
{{t 'Cancel'}}<i class="close icon"></i>
</LinkTo>
<button class="ui three field left labeled icon button {{if this.isLoading 'disabled'}}" type="button" {{action 'move' 'backwards'}}>
{{t 'Previous'}}
<i class="left chevron icon"></i>
Expand All @@ -265,11 +268,29 @@
<i class="save icon"></i>
</button>
{{/if}}
{{#if this.data.event.locationName}}
<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>
</button>
</div><br><br><br>
<div class="ui fields buttons {{if this.device.isMobile 'mini three' 'right floated large'}}">
{{#if (eq this.data.event.state 'draft')}}
<a href="{{this.data.event.url}}" class="ui three field right labeled icon button">
{{t 'View'}} <i class="hide icon"></i>
</a>
{{else}}
<a href="{{this.data.event.url}}" class="green ui three field right labeled icon button">
{{t 'Preview'}} <i class="unhide icon"></i>
</a>
{{/if}}
{{#if (and this.data.event.locationName ticketsPresent)}}
{{#if (eq this.data.event.state "draft")}}
<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>
</button>
{{else}}
<button class="orange ui three field right labeled icon button {{if this.isLoading 'disabled'}}" type="button" {{action 'unpublish'}}>
{{t 'Unpublish'}}
<i class="ban icon"></i>
</button>
{{/if}}
{{/if}}
</div>
</form>
32 changes: 27 additions & 5 deletions app/templates/components/forms/wizard/sponsors-step.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,9 @@
{{/if}}

<div class="{{if this.device.isMobile 'mini four' 'right floated large'}} ui fields buttons">
<LinkTo @route="events.view.index" @model={{this.data.event.identifier}} class="red ui three field right labeled icon button">
{{t 'Cancel'}}<i class="close icon"></i>
</LinkTo>
<button class="ui three field left labeled icon button {{if this.isLoading 'disabled'}}" type="button" {{action 'move' 'backwards'}}>
{{t 'Previous'}}
<i class="left chevron icon"></i>
Expand All @@ -103,11 +106,30 @@
<i class="save icon"></i>
</button>
{{/if}}
{{#if this.data.event.locationName}}
<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>
</button>
</div>
<br><br><br>
<div class="{{if this.device.isMobile 'mini four' 'right floated large'}} ui fields buttons">
{{#if (eq this.data.event.state 'draft')}}
<a href="{{this.data.event.url}}" class="ui three field right labeled icon button">
{{t 'View'}} <i class="hide icon"></i>
</a>
{{else}}
<a href="{{this.data.event.url}}" class="green ui three field right labeled icon button">
{{t 'Preview'}} <i class="unhide icon"></i>
</a>
{{/if}}
{{#if (and this.data.event.locationName ticketsPresent)}}
{{#if (eq this.data.event.state "draft")}}
<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>
</button>
{{else}}
<button class="orange ui three field right labeled icon button {{if this.isLoading 'disabled'}}" type="button" {{action 'unpublish'}}>
{{t 'Unpublish'}}
<i class="ban icon"></i>
</button>
{{/if}}
{{/if}}
</div>
</form>