Skip to content

Commit 599c4ae

Browse files
Anupam-dagarniranjan94
authored andcommitted
feat: Add filter to filter events by ticket type.
Reference: #3098
1 parent 3504b16 commit 599c4ae

File tree

5 files changed

+51
-4
lines changed

5 files changed

+51
-4
lines changed

app/components/explore/side-bar.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ export default Component.extend({
1212
customEndDate : null,
1313
showFilters : false,
1414

15-
hideClearFilters: computed('category', 'sub_category', 'event_type', 'startDate', 'endDate', 'location', function() {
16-
return !(this.category || this.sub_category || this.event_type || this.startDate || this.endDate || this.location !== null);
15+
hideClearFilters: computed('category', 'sub_category', 'event_type', 'startDate', 'endDate', 'location', 'ticket_type', function() {
16+
return !(this.category || this.sub_category || this.event_type || this.startDate || this.endDate || this.location || this.ticket_type !== null);
1717
}),
1818

1919
dateRanges: computed(function() {
@@ -41,6 +41,10 @@ export default Component.extend({
4141
this.set('event_type', eventType === this.event_type ? null : eventType);
4242
},
4343

44+
selectTicketType(ticketType) {
45+
this.set('ticket_type', ticketType === this.ticket_type ? null : ticketType);
46+
},
47+
4448
dateValidate(date) {
4549
if (moment(date).isAfter(this.customEndDate)) {
4650
this.set('customEndDate', date);
@@ -116,6 +120,7 @@ export default Component.extend({
116120
this.set('sub_category', null);
117121
this.set('event_type', null);
118122
this.set('location', null);
123+
this.set('ticket_type', null);
119124
},
120125

121126
toggleFilters() {

app/controllers/explore.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
import Controller from '@ember/controller';
22

33
export default Controller.extend({
4-
queryParams : ['category', 'sub_category', 'event_type', 'start_date', 'end_date', 'location'],
4+
queryParams : ['category', 'sub_category', 'event_type', 'start_date', 'end_date', 'location', 'ticket_type'],
55
category : null,
66
sub_category : null,
77
event_type : null,
88
start_date : null,
99
end_date : null,
1010
location : null,
11+
ticket_type : null,
1112

1213
actions: {
1314
shareEvent(event) {
@@ -33,6 +34,9 @@ export default Controller.extend({
3334
if (filterType === 'location') {
3435
this.set('location', null);
3536
}
37+
if (filterType === 'ticket_type') {
38+
this.set('ticket_type', null);
39+
}
3640
}
3741
}
3842
});

app/routes/explore.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,18 @@ export default Route.extend({
5757
});
5858
}
5959

60+
if (params.ticket_type) {
61+
filterOptions.push({
62+
name : 'tickets',
63+
op : 'any',
64+
val : {
65+
name : 'type',
66+
op : 'eq',
67+
val : params.ticket_type
68+
}
69+
});
70+
}
71+
6072
if (params.location) {
6173
filterOptions.push({
6274
name : 'location_name',

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

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,26 @@
9696
</div>
9797
{{/ui-accordion}}
9898
</div>
99+
<div class="item">
100+
{{#ui-accordion}}
101+
<span class="title">
102+
<i class="dropdown icon"></i>
103+
{{t 'Ticket Type' }}
104+
</span>
105+
<div class="content menu">
106+
<a href="#"
107+
class="link item {{if (eq ticket_type 'free') 'active'}}"
108+
{{action 'selectTicketType' 'free'}}>
109+
{{t 'Free'}}
110+
</a>
111+
<a href="#"
112+
class="link item {{if (eq ticket_type 'paid') 'active'}}"
113+
{{action 'selectTicketType' 'paid'}}>
114+
{{t 'Paid'}}
115+
</a>
116+
</div>
117+
{{/ui-accordion}}
118+
</div>
99119
{{/if}}
100120
<div class="item">
101121
<button class="ui red button {{if hideClearFilters 'disabled'}}" {{action 'clearFilters'}}>{{t 'Clear Filters'}}</button>

app/templates/explore.hbs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<div class="ui stackable grid">
22
<div class="four wide column">
3-
{{explore/side-bar model=model category=category sub_category=sub_category event_type=event_type startDate=start_date endDate=end_date location=location}}
3+
{{explore/side-bar model=model category=category sub_category=sub_category event_type=event_type startDate=start_date endDate=end_date location=location ticket_type=ticket_type}}
44
</div>
55
<div class="twelve wide column">
66
<h1 class="ui header">{{t 'Events'}}</h1>
@@ -35,6 +35,12 @@
3535
<a role="button" {{action 'clearFilter' 'end_date'}}><i class="icon close"></i></a>
3636
</div>
3737
{{/if}}
38+
{{#if filters.ticket_type}}
39+
<div class="ui mini label">
40+
{{ticket_type}}
41+
<a role="button" {{action 'clearFilter' 'ticket_type'}}><i class="icon close"></i></a>
42+
</div>
43+
{{/if}}
3844
</div>
3945
{{#each filteredEvents as |event|}}
4046
{{event-card event=event isWide=true filterByTags=true category=category subCategory=sub_category eventType=event_type shareEvent=(action 'shareEvent')}}

0 commit comments

Comments
 (0)