Fix lints in app/views/question

This commit is contained in:
Andreas Nedbal 2020-05-10 11:00:35 +02:00
parent eed08b811c
commit 7f17a2995e
3 changed files with 22 additions and 18 deletions

View File

@ -1,15 +1,15 @@
$(document).on "keydown", "textarea#q-answer", (evt) -> $(document).on "keydown", "textarea#q-answer-text", (evt) ->
qid = $(this)[0].dataset.id qid = $(this)[0].dataset.id
if evt.keyCode == 13 and evt.ctrlKey if evt.keyCode == 13 and evt.ctrlKey
# trigger warning: # trigger warning:
$("button#q-answer").trigger 'click' $("button#q-answer-btn").trigger 'click'
$(document).on "click", "button#q-answer", -> $(document).on "click", "button#q-answer-btn", ->
btn = $(this) btn = $(this)
btn.button "loading" btn.button "loading"
qid = btn[0].dataset.qId qid = btn[0].dataset.qId
$("textarea#q-answer").attr "readonly", "readonly" $("textarea#q-answer-text").attr "readonly", "readonly"
shareTo = [] shareTo = []
($ "input[type=checkbox][name=share][data-q-id=#{qid}]:checked").each (i, share) -> ($ "input[type=checkbox][name=share][data-q-id=#{qid}]:checked").each (i, share) ->
@ -21,7 +21,7 @@ $(document).on "click", "button#q-answer", ->
dataType: 'json' dataType: 'json'
data: data:
id: qid id: qid
answer: $("textarea#q-answer[data-id=#{qid}]").val() answer: $("textarea#q-answer-text[data-id=#{qid}]").val()
share: JSON.stringify shareTo share: JSON.stringify shareTo
inbox: false inbox: false
success: (data, status, jqxhr) -> success: (data, status, jqxhr) ->
@ -34,4 +34,4 @@ $(document).on "click", "button#q-answer", ->
showNotification translate('frontend.error.message'), false showNotification translate('frontend.error.message'), false
complete: (jqxhr, status) -> complete: (jqxhr, status) ->
btn.button "reset" btn.button "reset"
$("textarea#q-answer").removeAttr "readonly" $("textarea#q-answer-text").removeAttr "readonly"

View File

@ -1,24 +1,28 @@
.card.question--fixed{class: if hidden then 'question--hidden' end, tabindex: if hidden then '-1' end, aria: { hidden: if hidden then :true end }} .card.question--fixed{ class: if hidden then 'question--hidden' end, tabindex: hidden ? '-1' : '', aria: { hidden: hidden } }
.container .container
.card-body .card-body
.media .media
- unless question.author_is_anonymous - unless question.author_is_anonymous
%a.pull-left{href: unless hidden then show_user_profile_path(question.user.screen_name) end} %a.pull-left{ href: unless hidden then show_user_profile_path(question.user.screen_name) end }
%img.answerbox__question-user-avatar.avatar-md{src: question.user.profile_picture.url(:medium)} %img.answerbox__question-user-avatar.avatar-md{ src: question.user.profile_picture.url(:medium) }
.media-body .media-body
- if user_signed_in? - if user_signed_in?
.pull-right .pull-right
.btn-group .btn-group
%button.btn.btn-link.btn-sm.dropdown-toggle{data: { toggle: :dropdown }, aria: { expanded: :false }} %button.btn.btn-link.btn-sm.dropdown-toggle{ data: { toggle: :dropdown }, aria: { expanded: false } }
%span.caret %span.caret
- unless hidden - unless hidden
.dropdown-menu.dropdown-menu-right{role: :menu} .dropdown-menu.dropdown-menu-right{ role: :menu }
- if current_user.mod? or question.user == current_user - if current_user.mod? || question.user == current_user
%a.dropdown-item.text-danger{href: '#', tabindex: -1, data: { action: 'ab-question-destroy', q_id: question.id, redirect: if question.author_is_anonymous? then "/" else show_user_questions_path(question.user.screen_name) end }} %a.dropdown-item.text-danger{ href: '#',
tabindex: -1,
data: { action: 'ab-question-destroy',
q_id: question.id,
redirect: question.author_is_anonymous? ? '/' : show_user_questions_path(question.user.screen_name) } }
%i.fa.fa-trash-o %i.fa.fa-trash-o
= t 'views.actions.delete' = t 'views.actions.delete'
- unless question.user == current_user - unless question.user == current_user
%a.dropdown-item{href: '#', tabindex: -1, data: { action: 'ab-question-report', q_id: question.id }} %a.dropdown-item{ href: '#', tabindex: -1, data: { action: 'ab-question-report', q_id: question.id } }
%i.fa.fa-exclamation-triangle %i.fa.fa-exclamation-triangle
= t 'views.actions.report' = t 'views.actions.report'
%h6.text-muted.media-heading.answerbox__question-user %h6.text-muted.media-heading.answerbox__question-user

View File

@ -9,18 +9,18 @@
= render 'shared/cursored_pagination_dummy', more_data_available: @more_data_available, last_id: @answers_last_id = render 'shared/cursored_pagination_dummy', more_data_available: @more_data_available, last_id: @answers_last_id
- if @more_data_available - if @more_data_available
%button#load-more-btn.btn.btn-default{type: :button, data: { last_id: @answers_last_id }} %button.btn.btn-default#load-more-btn{ type: :button, data: { last_id: @answers_last_id } }
Load more Load more
- if user_signed_in? && !current_user.answered?(@question) && current_user != @question.user && @question.user&.privacy_allow_stranger_answers - if user_signed_in? && !current_user.answered?(@question) && current_user != @question.user && @question.user&.privacy_allow_stranger_answers
.card#q-answer-box .card#q-answer-box
.card-header= t('views.question.title') .card-header= t('views.question.title')
.card-body .card-body
%textarea#q-answer.form-control{placeholder: t('views.placeholder.inbox'), data: { id: @question.id }} %textarea.form-control#q-answer-text{ placeholder: t('views.placeholder.inbox'), data: { id: @question.id } }
%br/ %br/
%button#q-answer.btn.btn-success{data: { q_id: @question.id }} %button.btn.btn-success#q-answer-btn{ data: { q_id: @question.id } }
= t('views.actions.answer') = t('views.actions.answer')
- current_user.services.each do |service| - current_user.services.each do |service|
%label %label
%input{type: 'checkbox', name: 'share', checked: :checked, data: { q_id: @question.id, service: service.provider }} %input{ type: 'checkbox', name: 'share', checked: :checked, data: { q_id: @question.id, service: service.provider } }
= t('views.inbox.entry.sharing.post', service: service.provider.capitalize) = t('views.inbox.entry.sharing.post', service: service.provider.capitalize)