Skip to content
16 changes: 14 additions & 2 deletions app/components/explore/side-bar.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ export default class SideBar extends Component {
@tracked showFilters = false;
isMapVisible = true;

@computed('category', 'sub_category', 'event_type', 'startDate', 'endDate', 'location', 'ticket_type', 'cfs', 'event_name', 'is_online', 'is_location', 'is_mixed', 'has_logo', 'has_image', 'is_past')
@computed('category', 'sub_category', 'event_type', 'startDate', 'endDate', 'location', 'ticket_type', 'cfs', 'event_name', 'is_online', 'is_location', 'is_mixed', 'has_logo', 'has_image', 'is_past', 'is_upcoming')
get hideDefaultFilters() {
return !(this.category || this.sub_category || this.event_type || this.startDate || this.endDate || this.location || this.ticket_type || this.cfs || this.event_name || this.is_online || this.is_location || this.is_mixed || this.has_logo || this.has_image || this.is_past);
return !(this.category || this.sub_category || this.event_type || this.startDate || this.endDate || this.location || this.ticket_type || this.cfs || this.event_name || this.is_online || this.is_location || this.is_mixed || this.has_logo || this.has_image || this.is_past || this.is_upcoming);
}

@computed('category', 'sub_category')
Expand Down Expand Up @@ -62,9 +62,19 @@ export default class SideBar extends Component {
this.set('startDate', null);
this.set('endDate', null);
this.set('dateType', null);
this.set('is_upcoming', null);
this.set('is_past', this.is_past === val ? null : val);
}

@action
enableUpcomingEvents(val) {
this.set('startDate', null);
this.set('endDate', null);
this.set('dateType', null);
this.set('is_past', null);
this.set('is_upcoming', this.is_upcoming === val ? null : val);
}

@action
setSettingFilter(filter) {
if (this.is_online === null && this.is_location === null && this.is_mixed === null) {
Expand Down Expand Up @@ -131,6 +141,7 @@ export default class SideBar extends Component {
break;

case 'all_dates':
newStartDate = 'all_date';
break;

case 'today':
Expand Down Expand Up @@ -169,6 +180,7 @@ export default class SideBar extends Component {
this.set('startDate', newStartDate);
this.set('endDate', newEndDate);
this.set('is_past', null);
this.set('is_upcoming', null);
}

@action
Expand Down
9 changes: 7 additions & 2 deletions app/controllers/explore.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@ import Controller from '@ember/controller';

@classic
export default class ExploreController extends Controller {
queryParams = ['category', 'sub_category', 'event_type', 'start_date', 'end_date', 'location', 'ticket_type', 'cfs', 'event_name', 'is_online', 'is_location', 'is_mixed', 'has_logo', 'has_image', 'is_past'];
queryParams = ['category', 'sub_category', 'event_type', 'start_date', 'end_date', 'location', 'ticket_type', 'cfs', 'event_name', 'is_online', 'is_location', 'is_mixed', 'has_logo', 'has_image', 'is_past', 'is_upcoming'];
event_name = null;
is_online = null;
is_location = null;
is_mixed = null;
is_past = null;
is_upcoming = null;
has_logo = null;
has_image = null;
category = null;
Expand Down Expand Up @@ -50,6 +51,9 @@ export default class ExploreController extends Controller {
if (filterType === 'is_past') {
this.set('is_past', null);
}
if (filterType === 'is_upcoming') {
this.set('is_upcoming', null);
}
if (filterType === 'start_date') {
this.set('startDate', null);
}
Expand Down Expand Up @@ -93,7 +97,8 @@ export default class ExploreController extends Controller {
is_mixed : null,
has_image : null,
has_logo : null,
is_past : null
is_past : null,
is_upcoming : null
});
}
}
53 changes: 38 additions & 15 deletions app/routes/explore.js
Original file line number Diff line number Diff line change
Expand Up @@ -223,20 +223,37 @@ export default class ExploreRoute extends Route {
]
});
} else if (params.start_date) {
filterOptions.push({
or: [
{
name : 'starts-at',
op : 'ge',
val : params.start_date
},
{
name : 'ends-at',
op : 'ge',
val : params.start_date
}
]
});
if (params.start_date === 'all_date') {
filterOptions.push({
or: [
{
name : 'starts-at',
op : 'le',
val : moment().toISOString()
},
{
name : 'ends-at',
op : 'ge',
val : moment().toISOString()
}
]
});
} else {
filterOptions.push({
or: [
{
name : 'starts-at',
op : 'ge',
val : params.start_date
},
{
name : 'ends-at',
op : 'ge',
val : params.start_date
}
]
});
}
} else if (params.is_past) {
filterOptions.push({
and: [
Expand All @@ -252,6 +269,12 @@ export default class ExploreRoute extends Route {
}
]
});
} else if (params.is_upcoming) {
filterOptions.push({
name : 'starts-at',
op : 'ge',
val : moment().toISOString()
});
} else {
filterOptions.push({
or: [
Expand All @@ -272,7 +295,7 @@ export default class ExploreRoute extends Route {
return this.infinity.model('event', {
include : 'event-topic,event-sub-topic,event-type',
filter : filterOptions,
sort : params.is_past ? '-starts-at' : 'starts-at',
sort : params.is_past || (params.start_date === 'all_date') ? '-starts-at' : 'starts-at',
perPage : 6,
startingPage : 1,
perPageParam : 'page[size]',
Expand Down
7 changes: 7 additions & 0 deletions app/templates/components/explore/side-bar.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,13 @@
</div>
{{/if}}
{{/each}}
<div class="field">
<UiCheckbox
@label={{t "All Upcoming"}}
@class="ui checkbox"
@checked={{if (eq this.is_upcoming "true") true}}
@onChange={{action "enableUpcomingEvents" "true"}} />
</div>
<UiCheckbox
@label={{t "Past"}}
@class="ui checkbox"
Expand Down
4 changes: 2 additions & 2 deletions app/templates/explore.hbs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<div class="ui stackable grid">
<div class="three wide column">
<Explore::SideBar @model={{this.model}} @clearQueryParams={{this.clearAllFilters}} @category={{this.category}} @sub_category={{this.sub_category}} @event_type={{this.event_type}} @startDate={{this.start_date}} @endDate={{this.end_date}} @event_name={{this.event_name}} @is_past={{this.is_past}} @is_online={{this.is_online}} @is_location={{this.is_location}} @is_mixed={{this.is_mixed}} @has_logo={{this.has_logo}} @has_image={{this.has_image}} @location={{this.location}} @ticket_type={{this.ticket_type}} @cfs={{this.cfs}} />
<Explore::SideBar @model={{this.model}} @clearQueryParams={{this.clearAllFilters}} @category={{this.category}} @sub_category={{this.sub_category}} @event_type={{this.event_type}} @startDate={{this.start_date}} @endDate={{this.end_date}} @event_name={{this.event_name}} @is_upcoming={{this.is_upcoming}} @is_past={{this.is_past}} @is_online={{this.is_online}} @is_location={{this.is_location}} @is_mixed={{this.is_mixed}} @has_logo={{this.has_logo}} @has_image={{this.has_image}} @location={{this.location}} @ticket_type={{this.ticket_type}} @cfs={{this.cfs}} />
</div>
<div class="thirteen wide column">
<h1 class="ui header">{{t 'Events'}}</h1>
Expand All @@ -23,7 +23,7 @@
<a href="#" role="button" {{action 'clearFilter' 'event_type'}}><i class="icon close"></i></a>
</div>
{{/if}}
{{#if this.filters.start_date}}
{{#if (and this.filters.start_date (not-eq this.filters.start_date "all_date"))}}
<div class="ui mini label">
{{general-date this.filters.start_date 'date-short'}}
<a href="#" role="button" {{action 'clearFilter' 'start_date'}}><i class="icon close"></i></a>
Expand Down