Skip to content

Commit d202c4b

Browse files
kushthedudeiamareebjamal
authored andcommitted
feat: Show "promoted to front page" posts on front page before regular events (#3820)
* feat: Show only promoted to front page posts on front page * Promoted event before regular
1 parent 96653af commit d202c4b

File tree

6 files changed

+45
-2
lines changed

6 files changed

+45
-2
lines changed

app/controllers/admin/events/list.js

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,11 +85,21 @@ export default class extends Controller.extend(EmberTableControllerMixin) {
8585
name : 'Featured Event',
8686
valuePath : 'id',
8787
extraValuePaths : ['isFeatured'],
88-
cellComponent : 'ui-table/cell/admin/event-is-featured',
88+
cellComponent : 'ui-table/cell/admin/events/event-is-featured',
8989
width : 80,
9090
actions : {
9191
toggleFeatured: this.toggleFeatured.bind(this)
9292
}
93+
},
94+
{
95+
name : 'Promoted Event',
96+
valuePath : 'id',
97+
extraValuePaths : ['isPromoted'],
98+
cellComponent : 'ui-table/cell/admin/events/event-is-promoted',
99+
width : 80,
100+
actions : {
101+
togglePromoted: this.togglePromoted.bind(this)
102+
}
93103
}
94104
];
95105
}
@@ -178,4 +188,25 @@ export default class extends Controller.extend(EmberTableControllerMixin) {
178188
}
179189
this.set('isLoading', false);
180190
}
191+
192+
@action
193+
async togglePromoted(event_id) {
194+
this.set('isLoading', true);
195+
try {
196+
let event = this.store.peekRecord('event', event_id, { backgroundReload: false });
197+
event.toggleProperty('isPromoted');
198+
await event.save();
199+
this.notify.success(this.l10n.t(`Event ${event.isPromoted ? 'Promoted' : 'unpromoted'} Successfully`),
200+
{
201+
id: 'event_detail_changed'
202+
});
203+
} catch (e) {
204+
console.warn(e);
205+
this.notify.error(this.l10n.t('An unexpected error has occurred.'),
206+
{
207+
id: 'event_det_error'
208+
});
209+
}
210+
this.set('isLoading', false);
211+
}
181212
}

app/controllers/index.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,14 @@ export default Controller.extend({
2626

2727
featuredEvents: computed('filteredEvents.[]', function() {
2828
return this.filteredEvents ? this.filteredEvents.filter(event => {return event.isFeatured}) : null;
29+
}),
30+
31+
promotedEvents: computed('filteredEvents.[]', function() {
32+
return this.filteredEvents ? this.filteredEvents.filter(event => {return event.isPromoted}) : null;
33+
}),
2934

35+
upcomingEvents: computed('filteredEvents.[]', function() {
36+
return this.filteredEvents ? this.filteredEvents.filter(event => {return !event.isPromoted}) : null;
3037
}),
3138

3239
actions: {

app/models/event.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ export default ModelBase.extend(CustomPrimaryKeyMixin, {
5050
isTicketFormEnabled : attr('boolean', { defaultValue: false }),
5151
isSessionsSpeakersEnabled : attr('boolean', { defaultValue: false }),
5252
isFeatured : attr('boolean', { defaultValue: false }),
53+
isPromoted : attr('boolean', { defaultValue: false }),
5354
isBillingInfoMandatory : attr('boolean', { defaultValue: false }),
5455

5556
isTaxEnabled : attr('boolean', { defaultValue: false }),
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{{ui-checkbox class='toggle' checked=extraRecords.isPromoted onChange=(action props.actions.togglePromoted record)}}

app/templates/index.hbs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,10 @@
1212
{{#if filteredEvents}}
1313
<h2 class="main-heading">{{t 'Upcoming Events'}}</h2>
1414
<div class="ui stackable three column grid">
15-
{{#each filteredEvents as |event|}}
15+
{{#each promotedEvents as |event|}}
16+
{{event-card event=event shareEvent=(action 'shareEvent')}}
17+
{{/each}}
18+
{{#each upcomingEvents as |event|}}
1619
{{event-card event=event shareEvent=(action 'shareEvent')}}
1720
{{/each}}
1821
</div>

0 commit comments

Comments
 (0)