From 3451ae1fb04c2502bead1e4a6025a146adc1a01e Mon Sep 17 00:00:00 2001 From: Karina Kwiatek Date: Sun, 29 Jan 2023 21:01:03 +0100 Subject: [PATCH] Display pinned answers on profiles --- app/views/actions/_answer.html.haml | 9 +++++++++ app/views/user/show.html.haml | 6 +++++- config/locales/controllers.en.yml | 2 ++ config/locales/views.en.yml | 2 ++ 4 files changed, 18 insertions(+), 1 deletion(-) diff --git a/app/views/actions/_answer.html.haml b/app/views/actions/_answer.html.haml index 1fcfdca8..9f778bbe 100644 --- a/app/views/actions/_answer.html.haml +++ b/app/views/actions/_answer.html.haml @@ -16,6 +16,15 @@ %a.dropdown-item{ href: "#", data: { a_id: answer.id, action: "ab-report" } } %i.fa.fa-fw.fa-exclamation-triangle = t("voc.report") + - else + - if answer.pinned? + %a.dropdown-item{ href: "#", data: { a_id: answer.id, action: "ab-unpin" } } + %i.fa.fa-fw.fa-thumbtack + = t(".unpin") + - else + %a.dropdown-item{ href: "#", data: { a_id: answer.id, action: "ab-pin" } } + %i.fa.fa-fw.fa-thumbtack + = t(".pin") - if current_user.admin? %a.dropdown-item{ href: rails_admin_path_for_resource(answer), target: "_blank" } %i.fa.fa-fw.fa-gears diff --git a/app/views/user/show.html.haml b/app/views/user/show.html.haml index ac6452a0..6796f5c0 100644 --- a/app/views/user/show.html.haml +++ b/app/views/user/show.html.haml @@ -1,7 +1,11 @@ - unless @user.banned? + #pinned_answers + - @user.answers.pinned.each do |a| + = render 'answerbox', a: + #answers - @answers.each do |a| - = render 'answerbox', a: a + = render 'answerbox', a: - if @more_data_available .d-flex.justify-content-center.justify-content-sm-start#paginator diff --git a/config/locales/controllers.en.yml b/config/locales/controllers.en.yml index d94570f8..ebd15114 100644 --- a/config/locales/controllers.en.yml +++ b/config/locales/controllers.en.yml @@ -26,6 +26,8 @@ en: destroy: nopriv: "You cannot delete other people's answers." success: "Successfully deleted answer." + pin: + success: "Successfully pinned answer." comment: create: invalid: "Your comment is too long." diff --git a/config/locales/views.en.yml b/config/locales/views.en.yml index c944b72c..4b06bb01 100644 --- a/config/locales/views.en.yml +++ b/config/locales/views.en.yml @@ -73,6 +73,8 @@ en: actions: answer: return: "Return to Inbox" + pin: "Pin to Profile" + unpin: "Unpin from Profile" comment: view_smiles: "View comment smiles" share: