Skip to content
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

add functionality to hide all search indicator arrows via config #577

Conversation

josh-hunter-software
Copy link

config/initializer/ransack.rb

Ransack.configure do |c|
c.remove_search_order_indicators = true
end

This is basically like passing 'hide_indicator: true' to all of your search indicators..without passing it to all of your search indicators.

Josh Hunter and others added 4 commits August 21, 2015 12:21
Changed the description of the 'false' case spec to be more accurate.
fixed formatting of code portion of description
@@ -198,7 +198,7 @@ def default_sort_order(attr_name)
end

def order_indicator
if @hide_indicator || no_sort_direction_specified?
if @hide_indicator || no_sort_direction_specified? || Ransack.options[:remove_search_order_indicators]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps better to do this in SortLink#initialize when @hide_indicator is set up?

@jonatack
Copy link
Contributor

Thanks! Looks pretty good. I made a few comments in the code.

@josh-hunter-software
Copy link
Author

You bet! I'm glad you like it!


```ruby
Ransack.configure do |c|
c.remove_search_order_indicators = true
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps should be updated to c.hide_sort_order_indicators = true?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the better formatting!

controller: 'people'
)
}
it { should match /Full Name/ }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. Does this test ever fail? Perhaps it should not match ▼ and also not match the other arrow to be safe, WDYT?
  2. Could you please use RSpec expect instead of should syntax? We've been migrating all the specs in that direction.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that if it is matching /Full Name/ it is automatically not matching either arrow. I literally just copied/pasted that spec from the 'hide_indicator => true' spec because I figured the behavior is the same, but the implementation is different.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just tried that test with the inverse condition hide_sort_order_indicators = false and it passes instead of failing, because it will always match to the attribute name which is present either way.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To make the test work properly, I'd suggest:

it { should_not match /▼|▲/ }

It should pass when hide_sort_order_indicators = true and fail when hide_sort_order_indicators = false.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK for leaving the tests with RSpec should syntax since the rest of that file is that way. It may be better to move these 2 tests up to line 356 at the end of the sort_link tests where the other hide indicator specs are, and describe them like the other tests too, i.e. 'sort_link with...' instead of 'search_form_for with...' since they relate to the sort_link method.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If all this is confusing, don't worry about it and let me know, and I'll just commit it and clean it up.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch, the spec for hide_indicator has the same problem.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right, good catch, that test wasn't working 👍

Josh Hunter added 2 commits August 27, 2015 14:12
…e regex in the hide_indicator spec and hide_sort_order_indicator spec; corrected option name in hide_sort_orders setter in configuration.rb
…t_link specs and corrected their description
@josh-hunter-software
Copy link
Author

I think I got everything. Thanks for your patience! This is my first contribution to a gem and I really appreciate the feedback and insights!

@jonatack
Copy link
Contributor

All good!

Here is what remains: To keep the git history clean and clear, we need to merge the commits into one, but only the ones relevant to the new feature, and update the change log. The change that fixes the other spec, and the change to the order_indicator method in form_helper.rb, which have nothing to do with the new feature, should be in separate commits. For the moment we want one clean commit without the two other changes in it, and with an updated change log.

We have two options. You can do it, but it might be a little complicated if you haven't squashed/cherry-picked/rebased commits before (I can help you if needed). Or I can do it. The result will be the same. Let me know!

@jonatack
Copy link
Contributor

P.S. It's great that working together, the bug in the other spec was found and fixed. Two pairs of eyes are better than one.

@josh-hunter-software
Copy link
Author

If you don't mind, I'd rather leave that stuff up to you. Thanks again!

@jonatack
Copy link
Contributor

I don't mind. Thanks for the contributions!

@jonatack
Copy link
Contributor

P.S. It looks like you have different user names/emails between your github account and your local .gitconfig file. The git history has commits from both Josh Hunter <josh-hunter@am.com> and from kalami <kalami@users.noreply.github.com>. Might be best to set them up the same.

@jonatack jonatack closed this in 95d4591 Aug 27, 2015
@jonatack
Copy link
Contributor

Once your .gitconfig is aligned, would you like to make a quick PR to fix that other test you spotted?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants