Skip to content

Commit 6c78c0d

Browse files
feat: Add Past filter to Explore page (#5976)
1 parent f22f886 commit 6c78c0d

File tree

5 files changed

+40
-5
lines changed

5 files changed

+40
-5
lines changed

app/components/explore/side-bar.js

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ export default class SideBar extends Component {
1818
isMapVisible = true;
1919
eventLocationType = null;
2020

21-
@computed('category', 'sub_category', 'event_type', 'startDate', 'endDate', 'location', 'ticket_type', 'cfs', 'event_name', 'is_online', 'has_logo', 'has_image')
21+
@computed('category', 'sub_category', 'event_type', 'startDate', 'endDate', 'location', 'ticket_type', 'cfs', 'event_name', 'is_online', 'has_logo', 'has_image', 'is_past')
2222
get hideClearFilters() {
23-
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.has_logo || this.has_image);
23+
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.has_logo || this.has_image || this.is_past);
2424
}
2525

2626
@computed('category', 'sub_category')
@@ -58,6 +58,14 @@ export default class SideBar extends Component {
5858
});
5959
}
6060

61+
@action
62+
enablePastEvents(val) {
63+
this.set('startDate', null);
64+
this.set('endDate', null);
65+
this.set('dateType', null);
66+
this.set('is_past', this.is_past === val ? null : val);
67+
}
68+
6169
@action
6270
setLocationType(locationType, val) {
6371
this.set('is_online', this.eventLocationType === locationType ? null : val);
@@ -147,6 +155,7 @@ export default class SideBar extends Component {
147155
}
148156
this.set('startDate', newStartDate);
149157
this.set('endDate', newEndDate);
158+
this.set('is_past', null);
150159
}
151160

152161
@action
@@ -184,6 +193,7 @@ export default class SideBar extends Component {
184193
is_online : null,
185194
has_logo : null,
186195
has_image : null,
196+
is_past : null,
187197
eventLocationType : null
188198
});
189199
}

app/controllers/explore.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@ import Controller from '@ember/controller';
44

55
@classic
66
export default class ExploreController extends Controller {
7-
queryParams = ['category', 'sub_category', 'event_type', 'start_date', 'end_date', 'location', 'ticket_type', 'cfs', 'event_name', 'is_online', 'has_logo', 'has_image'];
7+
queryParams = ['category', 'sub_category', 'event_type', 'start_date', 'end_date', 'location', 'ticket_type', 'cfs', 'event_name', 'is_online', 'has_logo', 'has_image', 'is_past'];
88
event_name = null;
99
is_online = null;
10+
is_past = null;
1011
has_logo = null;
1112
has_image = null;
1213
category = null;
@@ -38,6 +39,9 @@ export default class ExploreController extends Controller {
3839
if (filterType === 'has_image') {
3940
this.set('has_image', null);
4041
}
42+
if (filterType === 'is_past') {
43+
this.set('is_past', null);
44+
}
4145
if (filterType === 'start_date') {
4246
this.set('startDate', null);
4347
}

app/routes/explore.js

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import classic from 'ember-classic-decorator';
22
import { action } from '@ember/object';
33
import Route from '@ember/routing/route';
44
import { debounce } from 'lodash-es';
5+
import moment from 'moment';
56

67
@classic
78
export default class ExploreRoute extends Route {
@@ -179,6 +180,21 @@ export default class ExploreRoute extends Route {
179180
}
180181
]
181182
});
183+
} else if (params.is_past) {
184+
filterOptions.push({
185+
and: [
186+
{
187+
name : 'starts-at',
188+
op : 'lt',
189+
val : moment().toISOString()
190+
},
191+
{
192+
name : 'ends-at',
193+
op : 'lt',
194+
val : moment().toISOString()
195+
}
196+
]
197+
});
182198
} else {
183199
filterOptions.push({
184200
or: [
@@ -199,7 +215,7 @@ export default class ExploreRoute extends Route {
199215
return this.infinity.model('event', {
200216
include : 'event-topic,event-sub-topic,event-type',
201217
filter : filterOptions,
202-
sort : 'starts-at',
218+
sort : params.is_past ? '-starts-at' : 'starts-at',
203219
perPage : 6,
204220
startingPage : 1,
205221
perPageParam : 'page[size]',

app/templates/components/explore/side-bar.hbs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,11 @@
9696
</div>
9797
{{/if}}
9898
{{/each}}
99+
<UiCheckbox
100+
@label={{t "Past"}}
101+
@class="ui checkbox"
102+
@checked={{if (eq this.is_past "true") true}}
103+
@onChange={{action "enablePastEvents" "true"}} />
99104
</div>
100105
</div>
101106
</div>

app/templates/explore.hbs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<div class="ui stackable grid">
22
<div class="three wide column">
3-
<Explore::SideBar @model={{this.model}} @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_online={{this.is_online}} @has_logo={{this.has_logo}} @has_image={{this.has_image}} @location={{this.location}} @ticket_type={{this.ticket_type}} @cfs={{this.cfs}} />
3+
<Explore::SideBar @model={{this.model}} @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}} @has_logo={{this.has_logo}} @has_image={{this.has_image}} @location={{this.location}} @ticket_type={{this.ticket_type}} @cfs={{this.cfs}} />
44
</div>
55
<div class="thirteen wide column">
66
<h1 class="ui header">{{t 'Events'}}</h1>

0 commit comments

Comments
 (0)