FIX: correct button for anon

FEATURE: suppress button for staff
UX: remove strong green style
This commit is contained in:
Sam Saffron 2015-06-10 18:31:49 +10:00
parent 09292d6ff9
commit b662143cae
3 changed files with 28 additions and 5 deletions

View File

@ -44,12 +44,31 @@ export default {
}); });
PostMenuView.registerButton(function(visibleButtons){ PostMenuView.registerButton(function(visibleButtons){
if (this.get('post.can_accept_answer')) { var position = 0;
visibleButtons.splice(0,0,new Button('acceptAnswer', 'accepted_answer.accept_answer', 'check-square-o', {className: 'unaccepted'}));
var canAccept = this.get('post.can_accept_answer');
var canUnaccept = this.get('post.can_unaccept_answer');
var accepted = this.get('post.accepted_answer');
var isOp = Discourse.User.currentProp("id") !== this.get('post.topic.user_id');
if (canAccept && !isOp) {
// first hidden position
if (this.get('collapsed')) { return; }
position = visibleButtons.length - 2;
} }
if (this.get('post.can_unaccept_answer')) { if (canAccept) {
visibleButtons.splice(0,0,new Button('unacceptAnswer', 'accepted_answer.unaccept_answer', 'check-square', {className: 'accepted'})); visibleButtons.splice(position,0,new Button('acceptAnswer', 'accepted_answer.accept_answer', 'check-square-o', {className: 'unaccepted'}));
} }
if (canUnaccept || accepted) {
var locale = canUnaccept ? 'accepted_answer.unaccept_answer' : 'accepted_answer.accepted_answer';
visibleButtons.splice(position,0,new Button(
'unacceptAnswer',
locale,
'check-square',
{className: 'accepted'})
);
}
}); });
PostMenuView.reopen({ PostMenuView.reopen({
@ -58,6 +77,8 @@ export default {
}.observes('post.accepted_answer'), }.observes('post.accepted_answer'),
clickUnacceptAnswer: function(){ clickUnacceptAnswer: function(){
if (!this.get('post.can_unaccept_answer')) { return; }
this.set('post.can_accept_answer', true); this.set('post.can_accept_answer', true);
this.set('post.can_unaccept_answer', false); this.set('post.can_unaccept_answer', false);
this.set('post.accepted_answer', false); this.set('post.accepted_answer', false);

View File

@ -2,8 +2,9 @@
color: green; color: green;
} }
// you can style accepted answers however your want
.topic-post.accepted-answer .topic-body { .topic-post.accepted-answer .topic-body {
background-color: #E9FFE0; // background-color: #E9FFE0;
} }
.cooked .solved { .cooked .solved {

View File

@ -4,4 +4,5 @@ en:
allow_accepted_answers: "Allow users to accept answers" allow_accepted_answers: "Allow users to accept answers"
accept_answer: "Accept answer" accept_answer: "Accept answer"
unaccept_answer: "Unaccept answer" unaccept_answer: "Unaccept answer"
accepted_answer: "Accepted answer"
accepted_html: "<i class='fa-check-square fa accepted'></i> Solved by <a href data-user-card='{{username_lower}}'>{{username}}</a> in <a href='{{post_path}}'>post #{{post_number}}</a>" accepted_html: "<i class='fa-check-square fa accepted'></i> Solved by <a href data-user-card='{{username_lower}}'>{{username}}</a> in <a href='{{post_path}}'>post #{{post_number}}</a>"