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

Change the text on top of profile search pages #2520

Closed
steviepubliclab opened this issue Mar 21, 2018 · 11 comments
Closed

Change the text on top of profile search pages #2520

steviepubliclab opened this issue Mar 21, 2018 · 11 comments
Labels
add-code-links enhancement explains that the issue is to improve upon one of our existing features help wanted requires help by anyone willing to contribute Ruby

Comments

@steviepubliclab
Copy link
Contributor

steviepubliclab commented Mar 21, 2018

I'm interested in adding to that text that appears on top of the profile pages that shows up when you click: "Questions Asked," "Activities Posted," and "Activities Attempted"

(example profile page: https://publiclab.org/profile/stevie)

It currently says:
screen shot 2018-03-21 at 9 47 59 am

I'm interested in adding: "Here are all the questions you've asked. This is a wildcard tag search. Please enter a tag without wildcards to display lead wiki pages. Wildcard tag searches use the * asterisk in their URLs"

@ebarry
Copy link
Member

ebarry commented Mar 21, 2018

love this!

I notice that this part "Please enter a tag without wildcards to display lead wiki pages" is pretty deep in the weeds -- is there another way we could explain this and help people find their way to what they are looking for?

@jywarren jywarren added enhancement explains that the issue is to improve upon one of our existing features help wanted requires help by anyone willing to contribute Ruby add-code-links labels Mar 23, 2018
@jywarren jywarren added this to the Tagging and topics milestone Mar 23, 2018
@jywarren
Copy link
Member

Agreed on both! We actually show something similar on https://publiclab.org/contributors/pm

<div class="row" id="highlight" style=" text-align: center;">
<h3 class="col-md-4 col-xs-12 col-sm-4"><%= @users.length || 0 %> contributors</h3>
<h3 class="col-md-4 col-xs-12 col-sm-4"><%= @note_count %> research notes</h3>
<h3 class="col-md-4 col-xs-12 col-sm-4"><%= @wikis.length %> wiki pages</h3>
</div>

Or we could adapt the code from the profile page, which is a little complex but not bad:

<div class="row" id="highlight" style=" text-align: center;">
<h3 class="col-md-4 col-xs-12 col-sm-4"><a href = "/tag/question:*/author/<%= params[:id] %>"><%= Node.questions.where(status: 1, uid: @user.id).length %> questions asked </a><br><br> <%= Answer.where(uid: @profile_user.id).count %> answers posted</h3>
<h3 class="col-md-4 col-xs-12 col-sm-4"><a href = "/tag/activity:*/author/<%= params[:id] %>"><%= @count_activities_posted %> activities posted </a><br><br> <a href = "/tag/replication:*/author/<%= params[:id] %>"><%= @count_activities_attempted %> activities attempted</a></h3>
<% if !@map_lat.nil? && !@map_lon.nil? %>
<%= render :partial => "map/userLeaflet" , locals: {haslocation: true} %>
<% elsif !current_user.nil? && current_user.id == @user.id %>
<%= render :partial => "map/userLeaflet" , locals: {haslocation: false} %>
<% end %>
</div>

@rtrunkhill
Copy link
Contributor

rtrunkhill commented Jun 8, 2018

Hey i'm looking into this.

Would it be better to put the "Here are all the questions you've asked" next to the asked/answered toggle button?

image

Ive been trying to figure out how to change the message to "These are the answers provided by<%= link_to(@user.name,"/profile/#{@user.name}") %>" but im having trouble attaching it to the toggle buttons activity.

@grvsachdeva
Copy link
Member

grvsachdeva commented Jun 8, 2018

Hi @rtrunkhill, Can't say much about the placement of text, @publiclab/community-reps will update you shortly on that. About the code: You can use JavaScript for updating the text on button click. Like each time button is clicked, send it to JS function. Hope it help!

@grvsachdeva
Copy link
Member

oops, sorry

@rtrunkhill
Copy link
Contributor

rtrunkhill commented Jun 13, 2018

so I added this code and it works great for the tag/question:* route :

<% elsif @wildcard %>
    <% if @node_type == "questions"%>
      <p>Here are all the questions asked by <%= link_to(@user.name,"/profile/#{@user.name}") %>.</p>
    <% end %>
    <p><i>This is a wildcard tag search. Please enter a tag without wildcards to display lead wiki pages.</i></p>
    <p>Wildcard tag searches use the * asterisk in their URLs</p>
  <% else %>
    <p>This topic has no lead wiki page.</p>
    <p><a class="btn btn-primary" href="/wiki/<%= params[:id] %>?n=14552"><span class="fa fa-plus fa-white"></span> Add one now</a></p>
  <% end %>

image

But i haven't been able to find the node_types for act ivies nor replications because something like this:

<% if @node_type == "questions"%>
      <p>Here are all the questions asked by <%= link_to(@user.name,"/profile/#{@user.name}") %>.</p>
    <% elsif @node_type == "activity"%>
      <p>Here are all of <%= link_to(@user.name,"/profile/#{@user.name}") %> activities.</p>
    <% end %>

doesn't bring up the message on the /tag/activity:* route

@jywarren
Copy link
Member

Unfortunately we don't have a convenient method for separating out activities or replications -- perhaps we need a convenience method like node.is_type('activity')?

But for now, you can check by looking if node.has_power_tag('activity') or node.has_power_tag('replication')

@rtrunkhill
Copy link
Contributor

i just figured it out, I wrote the code like this <% elsif @node_type == "note" && params[:id].match("activity:") %> and <% elsif @node_type == "note" && params[:id].match("replication:") %>

it works great. going to submit the pr

@jywarren
Copy link
Member

oh cool!

@rtrunkhill
Copy link
Contributor

rtrunkhill commented Jun 14, 2018

rake test gives me this error

TagControllerTest#test_wildcard_tag_should_have_a_active_asked_and_an_inactive_answered_tab_for_question:
ActionView::Template::Error: undefined method `name' for nil:NilClass
    app/views/tag/show.html.erb:25:in `_app_views_tag_show_html_erb__3511267637889032259_72613600'
    app/controllers/tag_controller.rb:134:in `block (2 levels) in show'
    app/controllers/tag_controller.rb:133:in `show'
    test/functional/tag_controller_test.rb:211:in `block in <class:TagControllerTest>'

which is referencing this line <p>Here are all the questions asked by <%= link_to(@user.name,"/profile/#{@user.name}") %>.</p>

that's the exact same line used later on the page here
image

im not sure why it's kicking it back.

@rtrunkhill
Copy link
Contributor

disregard. i just made the messages more generic and it passed all tests, re submitting the pr now

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
add-code-links enhancement explains that the issue is to improve upon one of our existing features help wanted requires help by anyone willing to contribute Ruby
Projects
None yet
Development

No branches or pull requests

5 participants