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

Clear searches #202

Merged
merged 3 commits into from
Dec 16, 2016
Merged

Clear searches #202

merged 3 commits into from
Dec 16, 2016

Conversation

jgoley
Copy link
Contributor

@jgoley jgoley commented Dec 13, 2016

I went ahead and created a single template for all the search inputs. I figured it would reduce a fair amount of repetition with clearing inputs and force us into a consistent search UI/UX.

The template receives an object with options including:

  • textFilter: either a reactiveVar or ReactiveTableFilter
  • id the id associated with the element and ReactiveTableFilter if its passed
  • props if a ReactiveTableFilter is not passed, one will be created with the id and props which is an array
  • toggleableIf set to true, the input will be initially hidden and appear when the search icon is clicked. When the user clicks on the search icon within the input, the input returns to its hidden state.
  • placeholder defaults to 'Search'
  • classes classes which will be applied to the input's parent element

Copy link
Contributor

@Broham Broham left a comment

Choose a reason for hiding this comment

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

Two minor things but looks good otherwise.

e.preventDefault()
text = $(e.target).val()
templateInstance.userSearchText.set(text)
# 'input .map-search': _.debounce (e, templateInstance) ->
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we just yank the commented out code below?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yep, my bad


Template.searchInput.onCreated ->
instanceData = @data
searching = true
Copy link
Contributor

Choose a reason for hiding this comment

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

could these lines be changed to: searching = not instanceData.toggelable?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think that would work if we always pass the toggelable property.
Maybe searching = not instanceData.toggelable? would work? But may be confusing.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

searching = not instanceData.toggelable? works in all cases except for when toggleable is set to false. So maybe this:

toggleable = instanceData.toggleable
toggleable ?= false
@searching = new ReactiveVar(not toggleable)

Copy link
Contributor

Choose a reason for hiding this comment

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

hrrm - yeah I didn't think of that case. I'd probably just leave it the way it is then.

@Broham
Copy link
Contributor

Broham commented Dec 15, 2016

looks good 👍

@nathanathan nathanathan merged commit dd468d0 into master Dec 16, 2016
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.

3 participants