-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Add CFS filter to sidebar filters in explore route. #3144
Conversation
I am not quiite sure if we can implement |
@@ -44,6 +44,10 @@ export default Component.extend({ | |||
this.send('selectDateFilter', 'custom_dates'); | |||
}, | |||
|
|||
selectEventCfs(cfs) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just out of doubt, What is this property being used for ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
to set cfs
variable to either open
or closed
. Via this, events are filtered,
@Anupam-dagar can you please open a sub issue related to it ? |
app/routes/explore.js
Outdated
@@ -65,6 +65,18 @@ export default Route.extend({ | |||
}); | |||
} | |||
|
|||
if (params.cfs) { | |||
let cfsVal = false; | |||
if (params.cfs === 'open') { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this entire block can be reduced to a single line:
let cfsVal = (params.cfs === 'open' ? true: false);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@CosmicCoder96 Requested changes completed.
I referenced the issue in the PR as well as commit, I don't know if it will be correct to create a sub issue for it. |
Quoted by @CosmicCoder96 |
I have added If the workflow requirement is to open a subissue for it I'll open it. Waiting for @CosmicCoder96 @niranjan94 answer on it. |
fb668eb
to
cbf80e3
Compare
@Anupam-dagar Please add screenshots showing the changes. Please always add a screenshot to PRs in the frontend. Thanks. |
app/templates/explore.hbs
Outdated
@@ -35,6 +35,12 @@ | |||
<a role="button" {{action 'clearFilter' 'end_date'}}><i class="icon close"></i></a> | |||
</div> | |||
{{/if}} | |||
{{#if filters.cfs}} | |||
<div class="ui mini label"> | |||
{{if (eq filters.cfs 'true') 'Open' 'Closed'}} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no need to explicitly compare with true.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
doing {{if filters.cfs 'Open' 'Closed'}}
results in only Open
being set, even on selecting Closed
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Anupam-dagar then it's probably because filters.cfs
is a string and not a boolean. Ensure it is a boolean.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@niranjan94 I am setting it as boolean only. this.set('cfs', cfs === this.cfs ? null : (cfs === 'open' ? true : false));
Also if filters.cfs
is boolean, then shouldn't the if
block must not get executed when closed
is selected since it will become if false
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Anupam-dagar check the data type in the model definition (if one exists). Also check if it is being assigned as a non-boolean anywhere else. Because the only explanation for the behaviour you talk about is if it is a non-boolean.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@niranjan94 I refactored my code, it was being set as boolean but I interpreted it wrong in the router. A little weird thing is happening. Please take a look at the screenshot.
Before the first click, no filter is set for cfs. I click on Open
, the cfs value passed in action as parameter is true
. Since cfs
variable for request isn't set, this.cfs
is null
. The type here is boolean and Object as expected. I set the variable cfs
to the param value. Now the types are boolean and boolean as expected.
Now I do the second click on the same filter to unset it, before the this.set
line, the cfs param and this.cfs
are both true
but the types are boolean
and string
which should have been boolean
and boolean
as this.cfs
was set to a boolean
which can be seen from the previous console log. Now after the this.set
statement, again the cfs is set to true
which should have been null
but since the type mismatched it is set to true
. Finally the types now are both boolean
.
For the third click, the type for this.cfs
is boolean and hence I can unset the filter. I am not able to understand how the type is getting changed from boolean
to string
.
Also I am still unsure for this code block
{{#if filters.cfs}}
<div class="ui mini label">
{{if filters.cfs 'Open' 'Closed'}}
<a role="button" {{action 'clearFilter' 'cfs'}}><i class="icon close"></i></a>
</div>
{{/if}}
I tried after setting to boolean too. I am concerned about the case when filters.cfs
is false
, in that case will the if
block get executed since the value is false. If it doesn't get executed then we won't be able to display the 'Closed' label.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@shreyanshdwivedi @uds5501 @mrsaicharan1 can you please take a look here.
deb5fc2
to
ee91f3a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Anupam-dagar When you set a query param to true, and it appears in the URL as ?xyz=true
, it has been implicitly typecasted into a string. This also explains the behavior in the screenshot you added.
ee91f3a
to
c821b08
Compare
I have made the changes. I have considered |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have made the changes. I have considered true and false as string data.
@Anupam-dagar this is the wrong fix. It should remain a string only in the query. Any other usage in code should be a boolean. You should do the necessary conversions for it.
@niranjan94 I took a look at the changes I made. I got to know that in the routes for sending a request, I need to send |
@Anupam-dagar see https://guides.emberjs.com/v3.10.0/routing/query-params/#toc_default-values-and-deserialization
|
@niranjan94 I tried by setting a default value, it didn't seem to work as in that case I had to make a decision to what type of events I should show by default. |
app/routes/explore.js
Outdated
@@ -76,6 +76,14 @@ export default Route.extend({ | |||
val : `%${params.location}%` | |||
}); | |||
} | |||
if (params.cfs) { | |||
let cfsVal = params.cfs === 'Open' ? true : false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use lower case open
/close
app/routes/explore.js
Outdated
filterOptions.push({ | ||
name : 'is_sessions_speakers_enabled', | ||
op : 'eq', | ||
val : cfsVal |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can just be params.cfs === 'open'
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Anupam-dagar You missed this one!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@kushthedude this has also been fixed, check in changes section.
@niranjan94 This is ready for another review. I guess it's complete now. |
app/components/explore/side-bar.js
Outdated
hideClearFilters: computed('category', 'sub_category', 'event_type', 'startDate', 'endDate', 'location', 'ticket_type', function() { | ||
return !(this.category || this.sub_category || this.event_type || this.startDate || this.endDate || this.location || this.ticket_type !== null); | ||
hideClearFilters: computed('category', 'sub_category', 'event_type', 'startDate', 'endDate', 'location', 'ticket_type', 'cfs', function() { | ||
return !(this.category || this.sub_category || this.event_type || this.startDate || this.endDate || this.location || this.ticket_type || this.cfs !== null); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if you are passing a string to query param cfs, you can just use || this.cfs
here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the other data type are also string, hence i added it in this way.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this.cfs !== null
is true
if cfs
is not null
, false
if it is null
.
so you can just write this.cfs
, there is no need for the explicit comparison to null
app/routes/explore.js
Outdated
filterOptions.push({ | ||
name : 'is_sessions_speakers_enabled', | ||
op : 'eq', | ||
val : cfsVal |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
val: params.cfs === 'open'
4a8f7e2
to
8470d3e
Compare
app/components/explore/side-bar.js
Outdated
hideClearFilters: computed('category', 'sub_category', 'event_type', 'startDate', 'endDate', 'location', 'ticket_type', function() { | ||
return !(this.category || this.sub_category || this.event_type || this.startDate || this.endDate || this.location || this.ticket_type !== null); | ||
hideClearFilters: computed('category', 'sub_category', 'event_type', 'startDate', 'endDate', 'location', 'ticket_type', 'cfs', function() { | ||
return !(this.category || this.sub_category || this.event_type || this.startDate || this.endDate || this.location || this.ticket_type || this.cfs !== null); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this.cfs !== null
is true
if cfs
is not null
, false
if it is null
.
so you can just write this.cfs
, there is no need for the explicit comparison to null
@CosmicCoder96 @niranjan94 Updated pull request with the requested changes. Please review. |
Reference: #3098
Short description of what this resolves:
This adds a new search filter to sidebar of explore route.
Changes proposed in this pull request:
open
andclosed
options in sidebar.Checklist
development
branch.