-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Conversation
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> |
There was a problem hiding this comment.
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:
Also, yes -- |
<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 %> |
There was a problem hiding this comment.
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?
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? |
Yes, I think you may have identified an existing bug in the display of alerts. Three conditions, really:
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> |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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?
I believe you can use a `<span>` instead and it'll still have the styling
but won't be "clickable". Thanks!
…On Mon, Dec 5, 2016 at 2:02 PM, 500swapnil ***@***.***> wrote:
***@***.**** commented on this pull request.
------------------------------
In app/views/questions/_answer.html.erb
<#1051>:
> @@ -36,8 +36,8 @@
<% end %>
<hr />
<div style="padding: 0px 20px 10px 20px;">
- <% 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>
If "Accepted" isnt a working button, I needn't put it into "" tags right?
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#1051>, or mute the thread
<https://github.com/notifications/unsubscribe-auth/AABfJ_JeLD4_Yhx5xNDTd9H24rL8k6vUks5rFF_AgaJpZM4LCZsX>
.
|
Left it at '' . I separated them though. Let me know if any other changes are needed. |
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:
Thanks for bearing with us, |
Okay done |
Great work!
|
Thanks. I added my username and email. It will show up on the other changes I make. |
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. |
Thank you. Yeah I will pick another. |
Perfect and much more readable!!! |
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! |
oh weird i guess i submitted this comment out of order -- all good! |
Make sure these boxes are checked before your pull request is ready to be reviewed and merged. Thanks!
rake test:all
schema.rb.example
has been updated if any database migrations were addedPlease 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!