Fix HAML codestyle of answerbox views

This commit is contained in:
Andreas Nedbal 2022-07-30 22:47:18 +02:00 committed by Andreas Nedbal
parent 8314d0740d
commit bb47e30ed1
3 changed files with 25 additions and 25 deletions

View File

@ -1,32 +1,32 @@
%span.d-none.d-sm-inline.text-muted
- if !user_signed_in? && a.smiles.count.positive?
%button.btn.btn-info.btn-sm{ name: 'ab-smile', disabled: true }
%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 } }
%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 } }
%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
%span{ id: "ab-smile-count-#{a.id}" }= a.smiles.count
- unless display_all
%button.btn.btn-link.answerbox__action{ type: :button, name: 'ab-comments', data: { a_id: a.id, state: :hidden } }
%button.btn.btn-link.answerbox__action{ type: :button, name: "ab-comments", data: { a_id: a.id, state: :hidden } }
%i.fa.fa-fw.fa-comments
%span{ id: "ab-comment-count-#{a.id}" }= a.comment_count
.btn-group
%button.btn.btn-link.answerbox__action{ data: { toggle: :dropdown }, aria: { expanded: false } }
%i.fa.fa-fw.fa-share-alt{ title: 'Share' }
%i.fa.fa-fw.fa-share-alt{ title: "Share" }
.dropdown-menu.dropdown-menu-right{ role: :menu }
%a.dropdown-item{ href: twitter_share_url(a), target: '_blank' }
%a.dropdown-item{ href: twitter_share_url(a), target: "_blank" }
%i.fa.fa-fw.fa-twitter
= t(".share.twitter")
%a.dropdown-item{ href: tumblr_share_url(a), target: '_blank' }
%a.dropdown-item{ href: tumblr_share_url(a), target: "_blank" }
%i.fa.fa-fw.fa-tumblr
= t(".share.tumblr")
%a.dropdown-item{ href: '#', name: 'ab-share' }
%a.dropdown-item{ href: "#", name: "ab-share" }
= t(".share.other")
- if user_signed_in?
.btn-group
@ -35,22 +35,22 @@
.dropdown-menu.dropdown-menu-right{ role: :menu }
- if Subscription.is_subscribed(current_user, a)
-# fun joke should subscribe?
%a.dropdown-item{ href: '#', data: { a_id: a.id, action: 'ab-submarine', torpedo: 'no' } }
%a.dropdown-item{ href: "#", data: { a_id: a.id, action: "ab-submarine", torpedo: "no" } }
%i.fa.fa-anchor
= t(".unsubscribe")
- else
%a.dropdown-item{ href: '#', data: { a_id: a.id, action: 'ab-submarine', torpedo: 'yes' } }
%a.dropdown-item{ href: "#", data: { a_id: a.id, action: "ab-submarine", torpedo: "yes" } }
%i.fa.fa-anchor
= t(".subscribe")
- if privileged? a.user
%a.dropdown-item.text-danger{ href: '#', data: { a_id: a.id, action: 'ab-destroy' } }
%a.dropdown-item.text-danger{ href: "#", data: { a_id: a.id, action: "ab-destroy" } }
%i.fa.fa-trash-o
= t(".return")
- unless a.user == current_user
%a.dropdown-item{ href: '#', data: { a_id: a.id, action: 'ab-report' } }
%a.dropdown-item{ href: "#", data: { a_id: a.id, action: "ab-report" } }
%i.fa.fa-exclamation-triangle
= t("voc.report")
- if current_user.has_role? :administrator
%a.dropdown-item{ href: rails_admin_path_for_resource(a), target: '_blank' }
%a.dropdown-item{ href: rails_admin_path_for_resource(a), target: "_blank" }
%i.fa.fa-gears
= t("voc.view_in_rails_admin")

View File

@ -11,20 +11,20 @@
%span.caret
.dropdown-menu.dropdown-menu-right{ role: :menu }
- if current_user.mod? || a.question.user == current_user
%a.dropdown-item.text-danger{ href: '#', tabindex: -1, data: { action: 'ab-question-destroy', q_id: a.question.id } }
%a.dropdown-item.text-danger{ href: "#", tabindex: -1, data: { action: "ab-question-destroy", q_id: a.question.id } }
%i.fa.fa-trash-o
= t("voc.delete")
- unless a.question.user == current_user
%a.dropdown-item{ href: '#', tabindex: -1, data: { action: 'ab-question-report', q_id: a.question.id } }
%a.dropdown-item{ href: "#", tabindex: -1, data: { action: "ab-question-report", q_id: a.question.id } }
%i.fa.fa-exclamation-triangle
= t("voc.report")
- if current_user.has_role? :administrator
%a.dropdown-item{ href: rails_admin_path_for_resource(a.question), target: '_blank' }
%a.dropdown-item{ href: rails_admin_path_for_resource(a.question), target: "_blank" }
%i.fa.fa-gears
= t("voc.view_in_rails_admin")
%h6.text-muted.media-heading.answerbox__question-user
- if a.question.author_is_anonymous
%i.fa.fa-user-secret{ title: t('.anon_hint') }
%i.fa.fa-user-secret{ title: t(".anon_hint") }
= raw t(".asked", user: user_screen_name(a.question.user, context_user: a.user, author_identifier: a.question.author_is_anonymous ? a.question.author_identifier: nil), time: time_tooltip(a.question))
- if !a.question.author_is_anonymous && !a.question.direct
·

View File

@ -1,7 +1,7 @@
- display_all ||= nil
.card.answerbox{ data: { id: a.id, q_id: a.question.id } }
- if @question.nil?
= render 'answerbox/header', a: a
= render "answerbox/header", a: a
.card-body
- if display_all.nil?
.answerbox__answer-text
@ -23,18 +23,18 @@
%img.answerbox__answer-user-avatar.avatar-sm{ src: a.user.profile_picture.url(:medium) }
.media-body
%h6.media-heading.answerbox__answer-user
= raw t(".answered", hide: hidespan(t(".hide"), 'd-none d-sm-inline'), user: user_screen_name(a.user))
= raw t(".answered", hide: hidespan(t(".hide"), "d-none d-sm-inline"), user: user_screen_name(a.user))
.answerbox__answer-date
= link_to(raw(t("time.distance_ago", time: time_tooltip(a))), answer_path(a.user.screen_name, a.id))
.col-md-6.d-flex.d-md-block.answerbox__actions
= render 'answerbox/actions', a: a, display_all: display_all
= render "answerbox/actions", a: a, display_all: display_all
- else
.row
.col-md-6.text-left.text-muted
%i.fa.fa-clock-o
= link_to(raw(t("time.distance_ago", time: time_tooltip(a))), answer_path(a.user.screen_name, a.id), class: 'answerbox__permalink')
= link_to(raw(t("time.distance_ago", time: time_tooltip(a))), answer_path(a.user.screen_name, a.id), class: "answerbox__permalink")
.col-md-6.d-md-flex.answerbox__actions
= render 'answerbox/actions', a: a, display_all: display_all
.card-footer{ id: "ab-comments-section-#{a.id}", class: display_all.nil? ? 'd-none' : nil }
%div{ id: "ab-smiles-#{a.id}" }= render 'answerbox/smiles', a: a
%div{ id: "ab-comments-#{a.id}" }= render 'answerbox/comments', a: a
= render "answerbox/actions", a: a, display_all: display_all
.card-footer{ id: "ab-comments-section-#{a.id}", class: display_all.nil? ? "d-none" : nil }
%div{ id: "ab-smiles-#{a.id}" }= render "answerbox/smiles", a: a
%div{ id: "ab-comments-#{a.id}" }= render "answerbox/comments", a: a