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

Alert for accepted answer #1051

Merged
merged 7 commits into from
Dec 6, 2016
Merged

Alert for accepted answer #1051

merged 7 commits into from
Dec 6, 2016

Conversation

500swapnil
Copy link
Collaborator

Make sure these boxes are checked before your pull request is ready to be reviewed and merged. Thanks!

  • all tests pass -- rake test:all
  • code is in uniquely-named feature branch, and has been rebased on top of latest master (especially if you've been asked to make additional changes)
  • pull request is descriptively named with #number reference back to original issue
  • if possible, multiple commits squashed if they're smaller changes
  • reviewed/confirmed/tested by another contributor or maintainer
  • schema.rb.example has been updated if any database migrations were added

Please be sure you've reviewed our contribution guidelines at https://publiclab.org/wiki/contributing-to-public-lab-software

We have a loose schedule of reviewing and pulling in changes every Tuesday and Friday, and publishing changes on Fridays. Please alert developers on plots-dev@googlegroups.com when your request is ready or if you need assistance.

Thanks!

@500swapnil
Copy link
Collaborator Author

#847

@500swapnil
Copy link
Collaborator Author

What should I write instead of ? Wont the nid differ for every question?

@@ -32,7 +32,7 @@
<hr />
<div style="padding: 0px 20px 10px 20px;">
<% if current_user && current_user.uid == answer.node.uid || answer.accepted %>
<a <% if current_user && current_user.uid == answer.node.uid %> href="/answers/accept/<%= answer.id %>" <% end %> data-remote="true" id="answer-<%= answer.id %>-accept" class="answer-accept btn btn-sm <% if answer.accepted %>btn-success<% else %>btn-default<% end%>"><% if answer.accepted %>Accepted<% else %>Accept this answer<% end %></a>
<a <% if current_user && current_user.uid == answer.node.uid %> href="/answers/accept/<%= answer.id %>" <% end %> data-remote="true" id="answer-<%= answer.id %>-accept" class="answer-accept btn btn-sm <% if answer.accepted %>btn-success<% else %>btn-default<% end%>"><% if answer.accepted %><p class="alert alert-success">Your answer was accepted! If it would be helpful, consider expanding on this answer by <a href="/post?template=activity,tags=response:<question-nid>">posting a step-by-step activity</a></p><% else %>Accept this answer<% end %></a>
Copy link
Member

Choose a reason for hiding this comment

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

Hi, thanks for the PR!

Here, I think it'll be easier if you break it up into multiple lines; what's happening is we don't really want to delete the existing text, but to add the <div class="alert... onto its own line.

And I think something else is going on too -- this conditional checks if the current user is the same as the question asker -- answer.node.uid -- but we want to know if it's the same as the answerer -- that'd be, I think, answer.author.uid according to this file: https://github.com/publiclab/plots2/blob/master/app/models/answer.rb

And as to where, I think we could display the alert right above the horizontal rule (<hr />) on this line: https://github.com/500swapnil/plots2/blob/21b7823534b62e9564839f15c9e2be6356efeab3/app/views/questions/_answer.html.erb#L32

Take a look at a page with answers, does that placement make sense to you?

https://publiclab.org/questions/dhale2/12-01-2016/spectral-workbench-recording-time

Screenshot:

screenshot 2016-12-03 at 5 50 09 pm

@jywarren
Copy link
Member

jywarren commented Dec 3, 2016

Also, yes -- <question-nid> should become <%= answer.nid %> -- make sense?

<hr />
<div style="padding: 0px 20px 10px 20px;">
<% if current_user && current_user.uid == answer.node.uid || answer.accepted %>
<a <% if current_user && current_user.uid == answer.node.uid %> href="/answers/accept/<%= answer.id %>" <% end %> data-remote="true" id="answer-<%= answer.id %>-accept" class="answer-accept btn btn-sm <% if answer.accepted %>btn-success<% else %>btn-default<% end%>"><% if answer.accepted %><p class="alert alert-success">Your answer was accepted! If it would be helpful, consider expanding on this answer by <a href="/post?template=activity,tags=response:<question-nid>">posting a step-by-step activity</a></p><% else %>Accept this answer<% end %></a>
<% if current_user && current_user.uid == answer.author.uid || answer.accepted %>
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I think this line should have answer.node.uid so that the person who asks the questions can choose to accept it.
What do you think?

@500swapnil
Copy link
Collaborator Author

In the alert on line 32, I have made the condition answer.author.uid so that the answerer shall be notified whether his answer is accepted. But shouldnt the condition check for answer.node.uid on line 39?

@jywarren
Copy link
Member

jywarren commented Dec 5, 2016

Yes, I think you may have identified an existing bug in the display of alerts. Three conditions, really:

  • "Accepted" should be displayed to everyone
  • "Accept this answer" only to the question author.
  • "Your question was accepted... consider making an activity" (etc, your addition) to the answer author

Thanks for catching this! I think multiple lines will make it much easier to identify these three conditions.

<% if current_user && current_user.uid == answer.author.uid || answer.accepted %>
<a <% if current_user && current_user.uid == answer.author.uid %> href="/answers/accept/<%= answer.id %>" <% end %> data-remote="true" id="answer-<%= answer.id %>-accept" class="answer-accept btn btn-sm <% if answer.accepted %>btn-success<% else %>btn-default<% end%>"><% if answer.accepted %>Accepted<% else %>Accept this answer<% end %></a>
<% if current_user && current_user.uid == answer.node.uid || answer.accepted %>
<a <% if current_user && current_user.uid == answer.node.uid %> href="/answers/accept/<%= answer.id %>" <% end %> data-remote="true" id="answer-<%= answer.id %>-accept" class="answer-accept btn btn-sm <% if answer.accepted %>btn-success<% else %>btn-default<% end%>"><% if answer.accepted %>Accepted<% else %><% if current_user && current_user.uid == answer.node.uid %>Accept this answer<% end %><% end %></a>
Copy link
Member

Choose a reason for hiding this comment

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

For readability (and because the first is not actually a working button, even if it uses similar styling), could you break out the Accepted and Accept this answer messages into two separate lines, and two separate <a> tags?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

If "Accepted" isnt a working button, I needn't put it into "" tags right?

@jywarren
Copy link
Member

jywarren commented Dec 5, 2016 via email

@500swapnil
Copy link
Collaborator Author

Left it at '' . I separated them though. Let me know if any other changes are needed.

@ryzokuken
Copy link
Member

Hello! You must've noticed that the unit tests failed unexpectedly on your PR. This was due to some issue in the Travis CI testing configuration which was fixed by @jywarren later tonight. In order to make them work again, please rebase your work on top of the current master and then try pushing to your remote branch. Do this by:

$ git fetch upstream
$ git checkout master
$ git merge upstream/master
$ git checkout <my-branch>
$ git rebase master
$ git push origin <my-branch>

Thanks for bearing with us,
Ujjwal

@500swapnil
Copy link
Collaborator Author

Okay done

@ryzokuken
Copy link
Member

Great work!
Looks like you haven't configured git properly on your device. That's why github's not showing the commits to be added by you. Try:

$ git config --global user.name "<Your name as on Github>"
$ git config --global user.email "<Your email as on Github>"

@500swapnil
Copy link
Collaborator Author

Thanks. I added my username and email. It will show up on the other changes I make.

@ryzokuken
Copy link
Member

ryzokuken commented Dec 6, 2016

Bravo. @jywarren will look into this further. If you're done with this issue, feel free to pick another one up and ask for help if needed on our Gitter channel and/or on Github itself.

@500swapnil
Copy link
Collaborator Author

Thank you. Yeah I will pick another.

@jywarren
Copy link
Member

jywarren commented Dec 6, 2016

Perfect and much more readable!!!

@jywarren jywarren merged commit 89bb691 into publiclab:master Dec 6, 2016
@jywarren
Copy link
Member

jywarren commented Dec 6, 2016

Hi, @publiclab/reviewers - if anyone's able to take a look at this, that'd be super, thanks! I'm still working on a bug with the Features system. Thanks!

@jywarren
Copy link
Member

jywarren commented Dec 6, 2016

oh weird i guess i submitted this comment out of order -- all good!

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.

None yet

3 participants