Plots2: Search Bar not working when user is not Logged-in

Created on 25 Oct 2017  Â·  7Comments  Â·  Source: publiclab/plots2

Hi, this is a first-timers-only issue. This means we've worked to make it more legible to folks who either haven't contributed to our codebase before, or even folks who haven't contributed to open source before.

If that's you, we're interested in helping you take the first step and can answer questions and help you out as you do. Note that we're especially interested in contributions from people from groups underrepresented in free and open source software!

If you have contributed before, consider leaving this one for someone new, and looking through our general help wanted issues. Thanks!

The problem

When we visit https://publiclab.org/tags/ , the search bar as marked in image does not work when the user is not Logged-in .

screen shot 2017-10-25 at 2 20 11 pm

Solution

The changes are to be made in :
https://github.com/publiclab/plots2/blob/master/app/views/tag/index.html.erb

In line https://github.com/publiclab/plots2/blob/513048882189abceb3e391e48aec701f9223c654/app/views/tag/index.html.erb#L27

The function :
document.getElementsByTagName("input")[1] ;
Returns array of all input tags in a page . When the user is logged in , the search bar input tag is at index 1 of array .
However when the user is not logged in , the position of search bar tag changes (because of addition of sign-up button) .

We need to find the search bar input tag from its ID instead of its tag name .
So the line :
var pre = document.getElementsByTagName("input")[1].value ;
should be replaced by :
var pre = document.getElementById("myInput").value ;

Steps to fix :

Steps to Fix

  • [ ] claim this issue with a comment here, below, and ask any clarifying questions you need

    • [ ] set up a repository locally following the README instructions, and make sure that all tests pass

  • [ ] try to fix the issue following the steps above, but even before you're done, you can:

    • [ ] commit your changes and start a pull request (see contributing to Public Lab software) but mark it as "in progress" if you have questions or if you haven't finished

    • [ ] alert someone via the developers list (see below) to have your pull request merged. This may take a few extra steps depending on when you do it, but we'll help you out!

Please email the developers list (see https://publiclab.org/wiki/developers) or go to the chatroom if you have questions, and take a look at our first-timers landing page for more information!

JavaScript bug first-timers-only help wanted

Most helpful comment

@sagarpreet-chadha This is awesome! May I suggest using more descriptive names instead? For instance, instead of using #myInput, perhaps we could use #input-tags?

@jywarren wdyt?

All 7 comments

Hi, this looks great!!! 🎉

@sagarpreet-chadha This is awesome! May I suggest using more descriptive names instead? For instance, instead of using #myInput, perhaps we could use #input-tags?

@jywarren wdyt?

I'd like to take on this issue.

That would be great! we're happy to help!

On Fri, Oct 27, 2017 at 3:23 PM, Brandon Shega notifications@github.com
wrote:

I'd like to take on this issue.

—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/publiclab/plots2/issues/1722#issuecomment-340062912,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AABfJ62im5tHZ5Go_99Q-QC1GbvTOSIqks5swi2ZgaJpZM4QFrHb
.

I do have an issue, I followed the instructions on the readme and did everything except for the solr part where it says (optional, not recommended). When I do bundle exec rake tests I get a whole bunch of errors relating to solr. I'm not sure if you can see them here but here is a link to my c9: https://ide.c9.io/brandonshega/plots2

Hmm, well the usual test command is rake test -- maybe adding the s made it try to run solr tests also? I /believe/ you should be able to just run rake test or bundle exec rake test and skip the solr tests. But tell us if that doesn't happen -- we may need to fix something!

Thanks for your help!!!

I must be doing something wrong then, I ran that command as well (I think I was the whole time), but I'm still getting solr test failures:

===================================================================================================================================================
Error: test_note_with_inline_tagged_notes_table_via_insert_extras()_helper(NodeInsertExtrasTest): SocketError: Failed to open TCP connection to solr:8983 (getaddrinfo: Name or service not known)
lib/authlogic_openid/authlogic_openid/acts_as_authentic.rb:74:in `save'
lib/authlogic_openid/authlogic_openid/session.rb:73:in `save'
app/controllers/user_sessions_controller.rb:27:in `create'
test/integration/node_insert_extras_test.rb:5:in `block in <class:NodeInsertExtrasTest>'
===================================================================================================================================================
E
===================================================================================================================================================
Error: test_should_get_wiki_page_and_record_unique_views(NodeInsertExtrasTest): SocketError: Failed to open TCP connection to solr:8983 (getaddrinfo: Name or service not known)
test/integration/node_unique_views_test.rb:10:in `block (2 levels) in <class:NodeInsertExtrasTest>'
test/integration/node_unique_views_test.rb:9:in `block in <class:NodeInsertExtrasTest>'
===================================================================================================================================================
E
===================================================================================================================================================
Error: test_add_series_tag(NodeSeriesTagTest): SocketError: Failed to open TCP connection to solr:8983 (getaddrinfo: Name or service not known)
lib/authlogic_openid/authlogic_openid/acts_as_authentic.rb:74:in `save'
lib/authlogic_openid/authlogic_openid/session.rb:73:in `save'
app/controllers/user_sessions_controller.rb:27:in `create'
test/integration/node_series_tag_test.rb:5:in `block in <class:NodeSeriesTagTest>'
===================================================================================================================================================
E
===================================================================================================================================================
Error: test_edit_note_after_creating_a_new_note(NodeUpdateTest): SocketError: Failed to open TCP connection to solr:8983 (getaddrinfo: Name or service not known)
lib/authlogic_openid/authlogic_openid/acts_as_authentic.rb:74:in `save'
lib/authlogic_openid/authlogic_openid/session.rb:73:in `save'
app/controllers/user_sessions_controller.rb:27:in `create'
test/integration/node_update_test.rb:5:in `block in <class:NodeUpdateTest>'
===================================================================================================================================================
E
===================================================================================================================================================
Error: test_browse_/blog(PublicPagesTest): SocketError: Failed to open TCP connection to solr:8983 (getaddrinfo: Name or service not known)
test/integration/public_pages_test.rb:41:in `block in <class:PublicPagesTest>'
===================================================================================================================================================
..................E
===================================================================================================================================================
Error: test_create_new_wiki_page(WikiCreationTest): SocketError: Failed to open TCP connection to solr:8983 (getaddrinfo: Name or service not known)
lib/authlogic_openid/authlogic_openid/acts_as_authentic.rb:74:in `save'
lib/authlogic_openid/authlogic_openid/session.rb:73:in `save'
app/controllers/user_sessions_controller.rb:27:in `create'
test/integration/wiki_creation_test.rb:5:in `block in <class:WikiCreationTest>'
===================================================================================================================================================
E
===================================================================================================================================================
Error: test_create_new_wiki_page_without_body(WikiCreationTest): SocketError: Failed to open TCP connection to solr:8983 (getaddrinfo: Name or service not known)
lib/authlogic_openid/authlogic_openid/acts_as_authentic.rb:74:in `save'
lib/authlogic_openid/authlogic_openid/session.rb:73:in `save'
app/controllers/user_sessions_controller.rb:27:in `create'
test/integration/wiki_creation_test.rb:23:in `block in <class:WikiCreationTest>'
===================================================================================================================================================
Was this page helpful?
0 / 5 - 0 ratings

Related issues

keshavsethi picture keshavsethi  Â·  3Comments

grvsachdeva picture grvsachdeva  Â·  3Comments

divyabaid16 picture divyabaid16  Â·  3Comments

milaaraujo picture milaaraujo  Â·  3Comments

jywarren picture jywarren  Â·  3Comments