From: Anton Khorev Date: Fri, 11 Aug 2023 17:35:36 +0000 (+0300) Subject: Change mark message buttons visibility with hidden attr X-Git-Tag: live~1155^2~3 X-Git-Url: https://git.openstreetmap.org./rails.git/commitdiff_plain/c751967d0ec42b14b3f79016f0cfaa81d08849c3 Change mark message buttons visibility with hidden attr --- diff --git a/app/assets/javascripts/messages.js b/app/assets/javascripts/messages.js index 8c30f9b34..d34ffb466 100644 --- a/app/assets/javascripts/messages.js +++ b/app/assets/javascripts/messages.js @@ -27,6 +27,8 @@ $(document).ready(function () { function updateReadState(target, isRead) { $(target).closest("tr") .toggleClass("inbox-row", isRead) - .toggleClass("inbox-row-unread", !isRead); + .toggleClass("inbox-row-unread", !isRead) + .find(".inbox-mark-unread button").prop("hidden", !isRead).end() + .find(".inbox-mark-read button").prop("hidden", isRead); } }); diff --git a/app/assets/stylesheets/common.scss b/app/assets/stylesheets/common.scss index 8e29424c2..f7192a68e 100644 --- a/app/assets/stylesheets/common.scss +++ b/app/assets/stylesheets/common.scss @@ -1141,14 +1141,6 @@ tr.turn:hover { } } -.inbox-row .inbox-mark-read { - display: none !important; -} - -.inbox-row-unread .inbox-mark-unread { - display: none !important; -} - .search_form { background-color: $lightgrey; diff --git a/app/views/messages/_message_summary.html.erb b/app/views/messages/_message_summary.html.erb index e93b7fa90..dfcb3b02a 100644 --- a/app/views/messages/_message_summary.html.erb +++ b/app/views/messages/_message_summary.html.erb @@ -3,8 +3,8 @@ <%= link_to message_summary.title, message_path(message_summary) %> <%= l message_summary.sent_on, :format => :friendly %> - <%= button_to t(".unread_button"), message_mark_path(message_summary, :mark => "unread"), :remote => true, :class => "btn btn-sm btn-primary", :form_class => "d-inline-block inbox-mark-unread" %> - <%= button_to t(".read_button"), message_mark_path(message_summary, :mark => "read"), :remote => true, :class => "btn btn-sm btn-primary", :form_class => "d-inline-block inbox-mark-read" %> + <%= button_to t(".unread_button"), message_mark_path(message_summary, :mark => "unread"), :remote => true, :class => "btn btn-sm btn-primary", :form_class => "d-inline-block inbox-mark-unread", :hidden => !message_summary.message_read? %> + <%= button_to t(".read_button"), message_mark_path(message_summary, :mark => "read"), :remote => true, :class => "btn btn-sm btn-primary", :form_class => "d-inline-block inbox-mark-read", :hidden => message_summary.message_read? %> <%= button_to t(".destroy_button"), message_path(message_summary, :referer => request.fullpath), :method => :delete, :remote => true, :class => "btn btn-sm btn-danger", :form_class => "d-inline-block inbox-destroy" %>