Skip to content

Commit 885a18e

Browse files
kushthedudeabhinavk96
authored andcommitted
feat: Filter Side Bar Enhancements (#3102)
* Filter Side Bar Enhancements * Using modern syntax * Requested Changes making * Using setProperties * Travis Issue * Dangling Comma
1 parent 33739a3 commit 885a18e

File tree

3 files changed

+80
-48
lines changed

3 files changed

+80
-48
lines changed

app/components/explore/side-bar.js

Lines changed: 32 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import Component from '@ember/component';
22
import moment from 'moment';
33
import { computed } from '@ember/object';
4+
import { not } from '@ember/object/computed';
45
import { getDateRanges } from 'open-event-frontend/utils/dictionary/filters';
56

67
export default Component.extend({
@@ -16,6 +17,13 @@ export default Component.extend({
1617
return !(this.category || this.sub_category || this.event_type || this.startDate || this.endDate || this.location || this.ticket_type !== null);
1718
}),
1819

20+
showAllCategories: computed('category', 'sub_category', function() {
21+
return !this.category || !this.sub_category;
22+
23+
}),
24+
showAllTypes: not('event_type'),
25+
26+
1927
dateRanges: computed(function() {
2028
return getDateRanges.bind(this)();
2129
}),
@@ -111,20 +119,36 @@ export default Component.extend({
111119
onDateChange() {
112120
this.send('selectDateFilter', 'custom_dates');
113121
},
122+
clearFilterCategory() {
123+
this.setProperties({
124+
category : null,
125+
sub_category : null
126+
});
114127

115-
clearFilters() {
116-
this.set('startDate', null);
117-
this.set('endDate', null);
118-
this.set('dateType', null);
119-
this.set('category', null);
120-
this.set('sub_category', null);
128+
},
129+
clearFilterTypes() {
121130
this.set('event_type', null);
122-
this.set('location', null);
123-
this.set('ticket_type', null);
131+
132+
},
133+
134+
clearFilters() {
135+
this.setProperties({
136+
startDate : null,
137+
endDate : null,
138+
dateType : null,
139+
category : null,
140+
sub_category : null,
141+
event_type : null,
142+
location : null,
143+
ticket_type : null
144+
});
145+
146+
124147
},
125148

126149
toggleFilters() {
127150
this.set('showFilters', !this.showFilters);
151+
128152
}
129153
}
130154
});

app/components/side-bar.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ export default Component.extend({
4141
if (this.$sidebarOpener) {
4242
this.$sidebarOpener.off('click', this.toggleSidebar.bind(this));
4343
}
44+
4445
if (this.$sidebarClosers && this.$sidebarClosers.length > 0) {
4546
this.$sidebarClosers.off('click', this.hideSidebar.bind(this));
4647
}

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

Lines changed: 47 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,57 @@
1313
</div>
1414
</div>
1515
{{#if showFiltersOnMobile}}
16+
<div class="item">
17+
{{#ui-accordion}}
18+
<span class="title">
19+
<i class="dropdown icon"></i>
20+
{{t 'Date'}}
21+
</span>
22+
<div class="content menu">
23+
{{#each dateRanges as |dateRange|}}
24+
<a href="#" class="link item {{if (eq dateType dateRange.key) 'active'}}" {{action 'selectDateFilter'
25+
dateRange.key}}>
26+
{{dateRange.name}}
27+
{{#if (and (eq dateRange.key 'custom_dates') (eq dateType 'custom_dates'))}}
28+
<div class="explore sub menu">
29+
<div class="ui form">
30+
<div class="grouped fields">
31+
<div class="item field">
32+
<label class="required" for="start_date">{{t 'Starts'}}</label>
33+
{{widgets/forms/date-picker type='text'
34+
value=customStartDate
35+
rangePosition='start'
36+
onChange=(action 'dateValidate')
37+
}}
38+
</div>
39+
<div class="item field">
40+
<label class="required" for="end_date">{{t 'Ends'}}</label>
41+
{{widgets/forms/date-picker type='text'
42+
value=customEndDate
43+
rangePosition='end'
44+
onChange=(action 'onDateChange')
45+
}}
46+
</div>
47+
</div>
48+
</div>
49+
</div>
50+
{{/if}}
51+
</a>
52+
{{/each}}
53+
</div>
54+
{{/ui-accordion}}
55+
</div>
1656
<div class="item">
1757
{{#ui-accordion}}
1858
<span class="title">
1959
<i class="right floated dropdown icon"></i>
2060
{{t 'Categories'}}
2161
</span>
2262
<div class="content menu">
63+
<a href="#" class="link item {{if showAllCategories 'active'}}" {{action 'clearFilterCategory'}}>
64+
<i class="caret right icon"></i>
65+
{{t 'All Categories'}}
66+
</a>
2367
{{#each model.eventTopics as |Category| }}
2468
<a href="#"
2569
class="link item {{if (eq category Category.name) 'active'}}" {{action 'selectCategory' Category.name}}>
@@ -46,6 +90,9 @@
4690
{{t 'Event Type' }}
4791
</span>
4892
<div class="content menu">
93+
<a href="#" class="link item {{if showAllTypes 'active'}}" {{action 'clearFilterTypes'}}>
94+
{{t 'All Types'}}
95+
</a>
4996
{{#each model.eventTypes as |eventType|}}
5097
<a href="#"
5198
class="link item {{if (eq event_type eventType.name) 'active'}}"
@@ -56,46 +103,6 @@
56103
</div>
57104
{{/ui-accordion}}
58105
</div>
59-
<div class="item">
60-
{{#ui-accordion}}
61-
<span class="title">
62-
<i class="dropdown icon"></i>
63-
{{t 'Date'}}
64-
</span>
65-
<div class="content menu">
66-
{{#each dateRanges as |dateRange|}}
67-
<a href="#" class="link item {{if (eq dateType dateRange.key) 'active'}}" {{action 'selectDateFilter'
68-
dateRange.key}}>
69-
{{dateRange.name}}
70-
{{#if (and (eq dateRange.key 'custom_dates') (eq dateType 'custom_dates'))}}
71-
<div class="explore sub menu">
72-
<div class="ui form">
73-
<div class="grouped fields">
74-
<div class="item field">
75-
<label class="required" for="start_date">{{t 'Starts'}}</label>
76-
{{widgets/forms/date-picker type='text'
77-
value=customStartDate
78-
rangePosition='start'
79-
onChange=(action 'dateValidate')
80-
}}
81-
</div>
82-
<div class="item field">
83-
<label class="required" for="end_date">{{t 'Ends'}}</label>
84-
{{widgets/forms/date-picker type='text'
85-
value=customEndDate
86-
rangePosition='end'
87-
onChange=(action 'onDateChange')
88-
}}
89-
</div>
90-
</div>
91-
</div>
92-
</div>
93-
{{/if}}
94-
</a>
95-
{{/each}}
96-
</div>
97-
{{/ui-accordion}}
98-
</div>
99106
<div class="item">
100107
{{#ui-accordion}}
101108
<span class="title">

0 commit comments

Comments
 (0)