Remove "frown" state when an answer/comment is smiled

This commit is contained in:
Andreas Nedbal 2022-08-30 19:47:18 +02:00
parent 633a88ec4f
commit ba0ee581c4
4 changed files with 6 additions and 30 deletions

View File

@ -47,11 +47,9 @@ export function commentSmileHandler(event: Event): void {
switch(action) { switch(action) {
case 'smile': case 'smile':
button.dataset.action = 'unsmile'; button.dataset.action = 'unsmile';
button.innerHTML = `<i class="fa fa-fw fa-frown-o"></i> <span id="ab-comment-smile-count-${id}">${count}</span>`;
break; break;
case 'unsmile': case 'unsmile':
button.dataset.action = 'smile'; button.dataset.action = 'smile';
button.innerHTML = `<i class="fa fa-fw fa-smile-o"></i> <span id="ab-comment-smile-count-${id}">${count}</span>`;
break; break;
} }
} }

View File

@ -47,11 +47,9 @@ export function answerboxSmileHandler(event: Event): void {
switch(action) { switch(action) {
case 'smile': case 'smile':
button.dataset.action = 'unsmile'; button.dataset.action = 'unsmile';
button.innerHTML = `<i class="fa fa-fw fa-frown-o"></i> <span id="ab-smile-count-${id}">${count}</span>`;
break; break;
case 'unsmile': case 'unsmile':
button.dataset.action = 'smile'; button.dataset.action = 'smile';
button.innerHTML = `<i class="fa fa-fw fa-smile-o"></i> <span id="ab-smile-count-${id}">${count}</span>`;
break; break;
} }
} }

View File

@ -1,15 +1,5 @@
%span.d-none.d-sm-inline.text-muted %span.d-none.d-sm-inline.text-muted
- if !user_signed_in? && a.smiles.count.positive? %button.btn.btn-link.answerbox__action{ type: :button, name: "ab-smile", data: { a_id: a.id, action: current_user&.smiled?(a) ? :unsmile : :smile }, disabled: !user_signed_in? }
%button.btn.btn-info.btn-sm{ name: "ab-smile", disabled: true }
%i.fa.fa-smile-o
%span{ id: "ab-smile-count-#{a.id}" }= a.smiles.count
- if user_signed_in?
- if current_user.smiled? a
%button.btn.btn-link.answerbox__action{ type: :button, name: "ab-smile", data: { a_id: a.id, action: :unsmile } }
%i.fa.fa-fw.fa-frown-o
%span{ id: "ab-smile-count-#{a.id}" }= a.smiles.count
- else
%button.btn.btn-link.answerbox__action{ type: :button, name: "ab-smile", data: { a_id: a.id, action: :smile } }
%i.fa.fa-fw.fa-smile-o %i.fa.fa-fw.fa-smile-o
%span{ id: "ab-smile-count-#{a.id}" }= a.smiles.count %span{ id: "ab-smile-count-#{a.id}" }= a.smiles.count
- unless display_all - unless display_all

View File

@ -18,17 +18,7 @@
= markdown comment.content = markdown comment.content
.pull-right .pull-right
%span.d-none.d-sm-inline.text-muted %span.d-none.d-sm-inline.text-muted
- if !user_signed_in? && comment.smile_count.positive? %button.btn.btn-link.answerbox__action{ type: :button, name: "ab-smile-comment", data: { c_id: comment.id, action: current_user&.smiled?(comment) ? :unsmile : :smile }, disabled: !user_signed_in? }
%button.btn.btn-link.answerbox__action{ name: "ab-smile-comment", disabled: true }
%i.fa.fa-fw.fa-smile-o
%span{ id: "ab-comment-smile-count-#{comment.id}" }= comment.smile_count
- if user_signed_in?
- if current_user.smiled? comment
%button.btn.btn-link.answerbox__action{ type: :button, name: "ab-smile-comment", data: { c_id: comment.id, action: :unsmile } }
%i.fa.fa-fw.fa-frown-o
%span{ id: "ab-comment-smile-count-#{comment.id}" }= comment.smile_count
- else
%button.btn.btn-link.answerbox__action{ type: :button, name: "ab-smile-comment", data: { c_id: comment.id, action: :smile } }
%i.fa.fa-fw.fa-smile-o %i.fa.fa-fw.fa-smile-o
%span{ id: "ab-comment-smile-count-#{comment.id}" }= comment.smile_count %span{ id: "ab-comment-smile-count-#{comment.id}" }= comment.smile_count
.btn-group .btn-group