From 4f4212abd012e1c89b5a5c20ebe5459d7dd80101 Mon Sep 17 00:00:00 2001 From: Anton Khorev Date: Thu, 17 Oct 2024 14:28:06 +0300 Subject: [PATCH] Replace submitted note table color with created/resolved --- app/assets/stylesheets/common.scss | 8 +++++++- app/views/notes/index.html.erb | 22 ++++++++++++++++------ config/locales/en.yml | 6 ++++-- 3 files changed, 27 insertions(+), 9 deletions(-) diff --git a/app/assets/stylesheets/common.scss b/app/assets/stylesheets/common.scss index d551462b220..bb41eda51c5 100644 --- a/app/assets/stylesheets/common.scss +++ b/app/assets/stylesheets/common.scss @@ -64,7 +64,13 @@ time[title] { .table-success { --bs-table-bg: rgb(var(--bs-success-rgb), .25); } - .table-primary, .table-secondary, .table-success { + .table-warning { + --bs-table-bg: rgb(var(--bs-warning-rgb), .25); + } + .table-danger { + --bs-table-bg: rgb(var(--bs-danger-rgb), .25); + } + .table-primary, .table-secondary, .table-success, .table-warning, .table-danger { --bs-table-color: initial; border-color: inherit; } diff --git a/app/views/notes/index.html.erb b/app/views/notes/index.html.erb index d5efe0d79c7..ebfcd54a7da 100644 --- a/app/views/notes/index.html.erb +++ b/app/views/notes/index.html.erb @@ -1,9 +1,11 @@ <% content_for :heading do %>

<%= t ".heading", :user => @user.display_name %>

-

<%= t ".subheading_html", - :user => link_to(@user.display_name, @user), - :submitted => tag.span(t(".subheading_submitted"), :class => "px-2 py-1 bg-primary bg-opacity-25"), - :commented => tag.span(t(".subheading_commented"), :class => "px-2 py-1 bg-body") %>

+

<%= t ".subheading_html", + :user => link_to(@user.display_name, @user), + :submitted => tag.span(t(".subheading_submitted"), :class => "px-2 py-1 bg-danger bg-opacity-25"), + :submitted_and_resolved => tag.span(t(".subheading_submitted_and_resolved"), :class => "px-2 py-1 bg-warning bg-opacity-25"), + :resolved => tag.span(t(".subheading_resolved"), :class => "px-2 py-1 bg-success bg-opacity-25"), + :commented => tag.span(t(".subheading_commented"), :class => "px-2 py-1 bg-body") %>

<% end %> <% if @notes.empty? %> @@ -24,7 +26,15 @@ <% @notes.each do |note| -%> - class="table-primary"<% end %>> + <% opened_by_user = note.comments.any? { |comment| comment.author == @user && comment.event == "opened" } %> + <% closed_by_user = note.comments.any? { |comment| comment.author == @user && comment.event == "closed" } %> + <%= tag.tr :class => if opened_by_user && closed_by_user + "table-warning" + elsif opened_by_user + "table-danger" + elsif closed_by_user + "table-success" + end do %> <% if note.closed? %> <%= image_tag("closed_note_marker.svg", :alt => "closed", :width => 25, :height => 40) %> @@ -37,7 +47,7 @@ <%= note.comments.first.body.to_html %> <%= friendly_date_ago(note.created_at) %> <%= friendly_date_ago(note.updated_at) %> - + <% end %> <% end -%> diff --git a/config/locales/en.yml b/config/locales/en.yml index 20588e5a897..5543f1b158c 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -2957,8 +2957,10 @@ en: index: title: "Notes submitted or commented on by %{user}" heading: "%{user}'s Notes" - subheading_html: "Notes %{submitted} or %{commented} by %{user}" - subheading_submitted: "submitted" + subheading_html: "Notes %{submitted}, %{submitted_and_resolved}, %{resolved} or %{commented} by %{user}" + subheading_submitted: "created" + subheading_submitted_and_resolved: "created and resolved" + subheading_resolved: "resolved" subheading_commented: "commented on" no_notes: No notes id: "Id"