From 3a335798feb7901307faa6cef223c49ba29c64a3 Mon Sep 17 00:00:00 2001 From: Andreas Nedbal Date: Sun, 10 May 2020 13:21:41 +0200 Subject: [PATCH] Fix lints in app/views/inbox --- app/assets/javascripts/inbox.coffee | 2 +- .../inbox/{_entry.html.haml => _entry.haml} | 24 ++++++++--------- app/views/inbox/_sidebar.haml | 27 +++++++++++++++++++ app/views/inbox/_sidebar.html.haml | 25 ----------------- app/views/inbox/{show.html.haml => show.haml} | 2 +- app/views/layouts/inbox.haml | 2 +- 6 files changed, 42 insertions(+), 40 deletions(-) rename app/views/inbox/{_entry.html.haml => _entry.haml} (51%) create mode 100644 app/views/inbox/_sidebar.haml delete mode 100644 app/views/inbox/_sidebar.html.haml rename app/views/inbox/{show.html.haml => show.haml} (75%) diff --git a/app/assets/javascripts/inbox.coffee b/app/assets/javascripts/inbox.coffee index f35361d8..bdff685c 100644 --- a/app/assets/javascripts/inbox.coffee +++ b/app/assets/javascripts/inbox.coffee @@ -22,7 +22,7 @@ btn.button "reset" ($ document).on "click", "button#ib-author", -> - $('#author_form').submit -> + $('#author-form').submit -> query = $('#author').val() window.location.href = '/inbox/' + query false diff --git a/app/views/inbox/_entry.html.haml b/app/views/inbox/_entry.haml similarity index 51% rename from app/views/inbox/_entry.html.haml rename to app/views/inbox/_entry.haml index 307a43c6..9e7066b4 100644 --- a/app/views/inbox/_entry.html.haml +++ b/app/views/inbox/_entry.haml @@ -1,36 +1,36 @@ -.card.inbox-entry{class: i.new? ? 'inbox-entry--new' : '', data: { id: i.id }} +.card.inbox-entry{ class: i.new? ? 'inbox-entry--new' : '', data: { id: i.id } } .card-header .media - unless i.question.author_is_anonymous - %a.pull-left{href: show_user_profile_path(i.question.user.screen_name)} - %img.answerbox__question-user-avatar.avatar-md{src: i.question.user.profile_picture.url(:medium)} + %a.pull-left{ href: show_user_profile_path(i.question.user.screen_name) } + %img.answerbox__question-user-avatar.avatar-md{ src: i.question.user.profile_picture.url(:medium) } .media-body %h6.text-muted.media-heading.answerbox__question-user = raw t('views.inbox.entry.asked', user: user_screen_name(i.question.user, anonymous: i.question.author_is_anonymous), time: time_tooltip(i.question)) - unless i.question.author_is_anonymous - - if i.question.answer_count > 0 + - if i.question.answer_count.positive? ยท - %a{href: show_user_question_path(i.question.user.screen_name, i.question.id)} + %a{ href: show_user_question_path(i.question.user.screen_name, i.question.id) } = pluralize(i.question.answer_count, t('views.inbox.entry.response')) %p.answerbox__question-text= i.question.content .card-body - %textarea.form-control{name: 'ib-answer', placeholder: t('views.placeholder.inbox'), data: { id: i.id }} + %textarea.form-control{ name: 'ib-answer', placeholder: t('views.placeholder.inbox'), data: { id: i.id } } %br/ - %button.btn.btn-success{name: 'ib-answer', data: { ib_id: i.id }} + %button.btn.btn-success{ name: 'ib-answer', data: { ib_id: i.id } } = t 'views.actions.answer' - %button.btn.btn-danger{name: 'ib-destroy', data: { ib_id: i.id }} + %button.btn.btn-danger{ name: 'ib-destroy', data: { ib_id: i.id } } = t 'views.actions.delete' - %button.btn.btn-default{name: 'ib-options', data: { ib_id: i.id, state: :hidden }} + %button.btn.btn-default{ name: 'ib-options', data: { ib_id: i.id, state: :hidden } } %i.fa.fa-cog %span.sr-only= t 'views.actions.options' - .card-footer{id: "ib-options-#{i.id}", style: 'display: none'} + .card-footer{ id: "ib-options-#{i.id}", style: 'display: none' } %h4= t 'views.inbox.entry.sharing.title' - - if current_user.services.count > 0 + - if current_user.services.count.positive? .row - current_user.services.each do |service| .col-md-3.col-sm-4.col-xs-6 %label - %input{type: 'checkbox', name: 'ib-share', checked: :checked, data: { ib_id: i.id, service: service.provider }} + %input{ type: 'checkbox', name: 'ib-share', checked: :checked, data: { ib_id: i.id, service: service.provider } } = raw t('views.inbox.entry.sharing.post', service: service.provider.capitalize) - else %p= raw t('views.inbox.entry.sharing.none', settings: link_to(t('views.inbox.entry.sharing.settings'), services_path)) diff --git a/app/views/inbox/_sidebar.haml b/app/views/inbox/_sidebar.haml new file mode 100644 index 00000000..230ac511 --- /dev/null +++ b/app/views/inbox/_sidebar.haml @@ -0,0 +1,27 @@ +.card + .card-header= t 'views.inbox.sidebar.questions.title' + .card-body + %button.btn.btn-block.btn-info{ type: :button, id: 'ib-generate-question' }= t 'views.inbox.sidebar.questions.button' +.card + .card-header= t 'views.inbox.sidebar.share.title' + .card-body + %a.btn.btn-block.btn-primary{ target: '_blank', + href: "https://twitter.com/intent/tweet?text=Ask%20me%20anything%21&url=#{show_user_profile_url(current_user.screen_name)}" } + %i.fa.fa-fw.fa-twitter + = raw t('views.inbox.sidebar.share.button', service: 'Twitter') + %a.btn.btn-block.btn-primary{ target: '_blank', + href: "https://www.tumblr.com/share/link?url=#{show_user_profile_url(current_user.screen_name)}&name=Ask%20me%20anything%21" } + %i.fa.fa-fw.fa-tumblr + = raw t('views.inbox.sidebar.share.button', service: 'Tumblr') +.card + .card-header Show author + .card-body + %form#author-form + = bootstrap_form_tag url: inbox_path, method: :get do |f| + = f.text_field :author, value: params[:author], placeholder: 'username', prepend: '@', hide_label: true + = f.button 'Show', name: nil, class: 'btn btn-light btn-block btn-sm', id: 'ib-author' +.card + .card-header= t 'views.inbox.sidebar.actions.title' + .card-body + %button.btn.btn-block.btn-danger{ type: :button, id: delete_id, disabled: (disabled ? 'disabled' : nil), data: { ib_count: inbox_count } } + = t 'views.inbox.sidebar.actions.button' diff --git a/app/views/inbox/_sidebar.html.haml b/app/views/inbox/_sidebar.html.haml deleted file mode 100644 index 4cda09a0..00000000 --- a/app/views/inbox/_sidebar.html.haml +++ /dev/null @@ -1,25 +0,0 @@ -.card.inbox--panel - .card-header= t 'views.inbox.sidebar.questions.title' - .card-body - %button.btn.btn-block.btn-info{type: :button, id: 'ib-generate-question'}= t 'views.inbox.sidebar.questions.button' -.card.inbox--panel - .card-header= t 'views.inbox.sidebar.share.title' - .card-body - %a.btn.btn-block.btn-primary{target: '_blank', href: "https://twitter.com/intent/tweet?text=Ask%20me%20anything%21&url=#{show_user_profile_url(current_user.screen_name)}"} - %i.fa.fa-fw.fa-twitter - = raw t('views.inbox.sidebar.share.button', service: "Twitter") - %a.btn.btn-block.btn-primary{target: '_blank', href: "https://www.tumblr.com/share/link?url=#{show_user_profile_url(current_user.screen_name)}&name=Ask%20me%20anything%21"} - %i.fa.fa-fw.fa-tumblr - = raw t('views.inbox.sidebar.share.button', service: "Tumblr") -.card.inbox--panel - .card-header Show author - .card-body - %form#author_form - = bootstrap_form_tag url: inbox_path, method: :get do |f| - = f.text_field :author, value: params[:author], placeholder: "username", prepend: "@" , hide_label: true - = f.button "Show", name: nil, class: "btn btn-light btn-block btn-sm", id: "ib-author" -.card.warning--panel - .card-header= t 'views.inbox.sidebar.actions.title' - .card-body - %button.btn.btn-block.btn-danger{type: :button, id: @delete_id , disabled: (@disabled ? 'disabled' : nil), data: { ib_count: @inbox_count }}= t 'views.inbox.sidebar.actions.button' - diff --git a/app/views/inbox/show.html.haml b/app/views/inbox/show.haml similarity index 75% rename from app/views/inbox/show.html.haml rename to app/views/inbox/show.haml index 89e14824..86b9e4c6 100644 --- a/app/views/inbox/show.html.haml +++ b/app/views/inbox/show.haml @@ -8,5 +8,5 @@ = render 'shared/cursored_pagination_dummy', more_data_available: @more_data_available, last_id: @inbox_last_id - if @more_data_available - %button#load-more-btn.btn.btn-default{type: :button, data: { last_id: @inbox_last_id }} + %button.btn.btn-default#load-more-btn{ type: :button, data: { last_id: @inbox_last_id } } = t 'views.actions.load' diff --git a/app/views/layouts/inbox.haml b/app/views/layouts/inbox.haml index 2333af9d..8dcff72c 100644 --- a/app/views/layouts/inbox.haml +++ b/app/views/layouts/inbox.haml @@ -1,7 +1,7 @@ .container.container--main .row .col-md-3.col-xs-12.col-sm-4.order-2.order-sm-1 - = render 'inbox/sidebar' + = render 'inbox/sidebar', delete_id: @delete_id, disabled: @disabled, inbox_count: @inbox_count .col-md-9.col-xs-12.col-sm-8.order-1.order-sm-2 = render 'layouts/messages' = yield