From 73f272f1320b2bc4a654c5cd8a73b789729058ce Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Tue, 15 Apr 2025 19:14:50 +0200 Subject: [PATCH 01/29] Use one controller for all notification readings --- .../notifications/mark_all_reads_controller.rb | 18 ------------------ .../notifications/readings_controller.rb | 14 ++++++++++++++ app/controllers/notifications_controller.rb | 10 ---------- app/helpers/notifications_helper.rb | 2 +- app/views/notifications/_tray.html.erb | 8 ++++---- app/views/notifications/index.html.erb | 9 +++------ .../create.turbo_stream.erb} | 0 config/routes.rb | 18 +++++++----------- .../mark_all_reads_controller_test.rb | 2 +- 9 files changed, 30 insertions(+), 51 deletions(-) delete mode 100644 app/controllers/notifications/mark_all_reads_controller.rb create mode 100644 app/controllers/notifications/readings_controller.rb rename app/views/notifications/{mark_read.turbo_stream.erb => readings/create.turbo_stream.erb} (100%) diff --git a/app/controllers/notifications/mark_all_reads_controller.rb b/app/controllers/notifications/mark_all_reads_controller.rb deleted file mode 100644 index 8b6450515..000000000 --- a/app/controllers/notifications/mark_all_reads_controller.rb +++ /dev/null @@ -1,18 +0,0 @@ -class Notifications::MarkAllReadsController < ApplicationController - def create - Current.user.notifications.unread.read_all - - set_page_and_extract_portion_from Current.user.notifications.read.ordered if request.format.turbo_stream? - - Turbo::StreamsChannel.broadcast_update_to( - [ Current.user, :notifications ], - target: "notifications", - html: "" - ) - - respond_to do |format| - format.turbo_stream - format.html - end - end -end diff --git a/app/controllers/notifications/readings_controller.rb b/app/controllers/notifications/readings_controller.rb new file mode 100644 index 000000000..9da4fb827 --- /dev/null +++ b/app/controllers/notifications/readings_controller.rb @@ -0,0 +1,14 @@ +class Notifications::ReadingsController < ApplicationController + def create + @notification = Current.user.notifications.find(params[:id]) + @notification.update!(read_at: Time.current) + end + + def create_all + Current.user.notifications.unread.read_all + + set_page_and_extract_portion_from Current.user.notifications.read.ordered if request.format.turbo_stream? + + Turbo::StreamsChannel.broadcast_update_to [ Current.user, :notifications ], target: "notifications", html: "" + end +end diff --git a/app/controllers/notifications_controller.rb b/app/controllers/notifications_controller.rb index 403828c2b..83e5db488 100644 --- a/app/controllers/notifications_controller.rb +++ b/app/controllers/notifications_controller.rb @@ -6,14 +6,4 @@ class NotificationsController < ApplicationController @unread = Current.user.notifications.unread.ordered end end - - def mark_read - @notification = Current.user.notifications.find(params[:id]) - @notification.update!(read_at: Time.current) - - respond_to do |format| - format.html { redirect_back fallback_location: notifications_path } - format.turbo_stream - end - end end diff --git a/app/helpers/notifications_helper.rb b/app/helpers/notifications_helper.rb index ca62626cf..656edad54 100644 --- a/app/helpers/notifications_helper.rb +++ b/app/helpers/notifications_helper.rb @@ -32,7 +32,7 @@ module NotificationsHelper end def notification_mark_read_button(notification) - button_to mark_read_notification_path(notification), + button_to read_notification_path(notification), class: "notification__unread_indicator btn borderless", title: "Mark as read", data: { turbo_frame: "_top" } do diff --git a/app/views/notifications/_tray.html.erb b/app/views/notifications/_tray.html.erb index 8e12e58f4..390e47054 100644 --- a/app/views/notifications/_tray.html.erb +++ b/app/views/notifications/_tray.html.erb @@ -6,7 +6,7 @@ dialog_modal_value: false, dialog_target: "dialog", action: "keydown.esc->dialog#close:stop click@document->dialog#closeOnClickOutside" } do %> - <%= turbo_frame_tag("notifications", src: notifications_tray_path) -%> + <%= turbo_frame_tag("notifications", src: tray_notifications_path) -%> <%= link_to notifications_path, class: "tray__overflow border-radius txt-normal", data: { action: "click->dialog#close"} do %>
@@ -17,9 +17,9 @@ <% end %>
- <%= button_to notifications_mark_all_read_path, - class: "notification-tray__read_action btn btn--reversed fill-transparent borderless flex-item-justify-start shadow txt-xx-small", - data: { action: "click->dialog#close", turbo_frame: "notifications" } do %> + <%= button_to read_all_notifications_path, + class: "notification-tray__read_action btn btn--reversed fill-transparent borderless flex-item-justify-start shadow txt-xx-small", + data: { action: "click->dialog#close", turbo_frame: "notifications" } do %> <%= icon_tag "check" %> Mark all read <% end %> diff --git a/app/views/notifications/index.html.erb b/app/views/notifications/index.html.erb index bab485363..806615ce3 100644 --- a/app/views/notifications/index.html.erb +++ b/app/views/notifications/index.html.erb @@ -6,9 +6,8 @@

<%= @page_title %>

- <%= link_to notifications_settings_path, class: "btn flex-item-justify-end" do %> - <%= icon_tag "settings" %> - Notification settings + <%= link_to settings_notifications_path, class: "btn flex-item-justify-end" do %> + <%= icon_tag "settings" %> Notification settings <% end %> <% end %> @@ -18,9 +17,7 @@ <% if @unread.any? %>

New for you

- <%= button_to notifications_mark_all_read_path, class: "btn txt-small" do %> - Mark all as read - <% end %> + <%= button_to "Mark all as read", read_all_notifications_path, class: "btn txt-small" %>
<%= render @unread %> diff --git a/app/views/notifications/mark_read.turbo_stream.erb b/app/views/notifications/readings/create.turbo_stream.erb similarity index 100% rename from app/views/notifications/mark_read.turbo_stream.erb rename to app/views/notifications/readings/create.turbo_stream.erb diff --git a/config/routes.rb b/config/routes.rb index 6eb05dd50..beeae1a5b 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -46,20 +46,16 @@ Rails.application.routes.draw do end - resources :notifications, only: :index - namespace :notifications do - resource :tray, only: :show - resource :mark_all_read, only: :create - resources :mark_read, only: :create - resource :settings, only: :show - end - resources :notifications do - member do - post :mark_read + scope module: :notifications do + get "tray", to: "trays#show", on: :collection + get "settings", to: "settings#show", on: :collection + + post "readings", to: "readings#create_all", on: :collection, as: :read_all + post "reading", to: "readings#create", on: :member, as: :read end end - + resources :filters resources :events, only: :index diff --git a/test/controllers/notifications/mark_all_reads_controller_test.rb b/test/controllers/notifications/mark_all_reads_controller_test.rb index 2fa423b3a..31ca45a68 100644 --- a/test/controllers/notifications/mark_all_reads_controller_test.rb +++ b/test/controllers/notifications/mark_all_reads_controller_test.rb @@ -8,7 +8,7 @@ class Notifications::MarkAllReadsControllerTest < ActionDispatch::IntegrationTes test "show" do assert_changes -> { notifications(:logo_published_kevin).reload.read? }, from: false, to: true do assert_changes -> { notifications(:layout_commented_kevin).reload.read? }, from: false, to: true do - post notifications_mark_all_read_path + post read_all_notifications_path end end From 375afeac7b186b44e783fb077c5a4a84508cfbcd Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Wed, 16 Apr 2025 11:55:35 +0200 Subject: [PATCH 02/29] Fix test --- test/controllers/notifications/trays_controller_test.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/controllers/notifications/trays_controller_test.rb b/test/controllers/notifications/trays_controller_test.rb index d49455ae1..07034fff0 100644 --- a/test/controllers/notifications/trays_controller_test.rb +++ b/test/controllers/notifications/trays_controller_test.rb @@ -6,7 +6,7 @@ class Notifications::TraysControllerTest < ActionDispatch::IntegrationTest end test "show" do - get notifications_tray_path + get tray_notifications_path assert_response :success assert_select "div", text: /Layout is broken/ From 50e4587dd9ad06febe3aa2046cc6b537a389ee1e Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Wed, 16 Apr 2025 11:56:21 +0200 Subject: [PATCH 03/29] Fix trailing spaces --- config/routes.rb | 2 +- test/controllers/users_controller_test.rb | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/config/routes.rb b/config/routes.rb index beeae1a5b..61271338a 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -55,7 +55,7 @@ Rails.application.routes.draw do post "reading", to: "readings#create", on: :member, as: :read end end - + resources :filters resources :events, only: :index diff --git a/test/controllers/users_controller_test.rb b/test/controllers/users_controller_test.rb index 3efbe0489..ff7ec0f2c 100644 --- a/test/controllers/users_controller_test.rb +++ b/test/controllers/users_controller_test.rb @@ -5,8 +5,8 @@ class UsersControllerTest < ActionDispatch::IntegrationTest sign_in_as :kevin get users_path - assert_match /#{users(:david).name}/, @response.body - assert_match /#{users(:kevin).name}/, @response.body + assert_match /#{users(:david).name}/, @response.body + assert_match /#{users(:kevin).name}/, @response.body end test "new" do @@ -20,7 +20,7 @@ class UsersControllerTest < ActionDispatch::IntegrationTest test "create" do assert_difference -> { User.active.count }, +1 do post users_path(params: { join_code: accounts(:"37s").join_code }), - params: { user: { name: "Dash", email_address: "dash@example.com", password: "123" } } + params: { user: { name: "Dash", email_address: "dash@example.com", password: "123" } } assert_redirected_to root_path end @@ -32,7 +32,7 @@ class UsersControllerTest < ActionDispatch::IntegrationTest sign_in_as :kevin get user_path(users(:david)) - assert_match /#{users(:david).name}/, @response.body + assert_match /#{users(:david).name}/, @response.body end test "update oneself" do From 3fc34257c49634a566ddbca80dc2e12c6ff8e814 Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Wed, 16 Apr 2025 11:59:58 +0200 Subject: [PATCH 04/29] No longer used --- .../notifications/mark_all_reads/create.html.erb | 1 - .../mark_all_reads/create.turbo_stream.erb | 14 -------------- 2 files changed, 15 deletions(-) delete mode 100644 app/views/notifications/mark_all_reads/create.html.erb delete mode 100644 app/views/notifications/mark_all_reads/create.turbo_stream.erb diff --git a/app/views/notifications/mark_all_reads/create.html.erb b/app/views/notifications/mark_all_reads/create.html.erb deleted file mode 100644 index 52d6bcd10..000000000 --- a/app/views/notifications/mark_all_reads/create.html.erb +++ /dev/null @@ -1 +0,0 @@ -<%= turbo_frame_tag "notifications" %> diff --git a/app/views/notifications/mark_all_reads/create.turbo_stream.erb b/app/views/notifications/mark_all_reads/create.turbo_stream.erb deleted file mode 100644 index 6d8b0f0a6..000000000 --- a/app/views/notifications/mark_all_reads/create.turbo_stream.erb +++ /dev/null @@ -1,14 +0,0 @@ -<%= turbo_stream.update "notifications_list" do %> -
- Nothing new for you. -
-<% end %> - -<% if @page&.records&.any? %> - <%= turbo_stream.update "notifications_list_read" do %> -

Previously seen

- <%= render partial: "notifications/notification", collection: @page.records %> - <% end %> -<% end %> - -<%= turbo_stream.update "notifications" %> \ No newline at end of file From 980345d1767b88d69bce53e2143508d4530b6adc Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Wed, 16 Apr 2025 12:00:11 +0200 Subject: [PATCH 05/29] Drop the frame, we will do it with streams --- app/views/notifications/trays/show.html.erb | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/app/views/notifications/trays/show.html.erb b/app/views/notifications/trays/show.html.erb index 051055670..8d556c9b8 100644 --- a/app/views/notifications/trays/show.html.erb +++ b/app/views/notifications/trays/show.html.erb @@ -1,3 +1 @@ -<%= turbo_frame_tag "notifications" do %> - <%= render collection: @notifications, partial: "notifications/notification" %> -<% end %> +<%= render partial: "notifications/notification", collection: @notifications %> From 13c44ba6509e3c383435321dc126d4f8bafb245d Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Wed, 16 Apr 2025 12:00:54 +0200 Subject: [PATCH 06/29] Actually need it for the lazy load of course --- app/views/notifications/trays/show.html.erb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/views/notifications/trays/show.html.erb b/app/views/notifications/trays/show.html.erb index 8d556c9b8..1e131caf6 100644 --- a/app/views/notifications/trays/show.html.erb +++ b/app/views/notifications/trays/show.html.erb @@ -1 +1,3 @@ -<%= render partial: "notifications/notification", collection: @notifications %> +<%= turbo_frame_tag "notifications" do %> + <%= render partial: "notifications/notification", collection: @notifications %> +<% end %> From d00a0433e9cbdb389a69c0b2c686c603a4cd8502 Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Wed, 16 Apr 2025 15:34:28 +0200 Subject: [PATCH 07/29] Inline anemic method --- app/controllers/cards/readings_controller.rb | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/app/controllers/cards/readings_controller.rb b/app/controllers/cards/readings_controller.rb index 669d959d8..dbb379b15 100644 --- a/app/controllers/cards/readings_controller.rb +++ b/app/controllers/cards/readings_controller.rb @@ -2,12 +2,7 @@ class Cards::ReadingsController < ApplicationController include CardScoped def create - mark_card_notifications_read + Current.user.notifications.unread.where(card: @card).read_all @notifications = Current.user.notifications.unread.ordered.limit(20) end - - private - def mark_card_notifications_read - Current.user.notifications.unread.where(card: @card).read_all - end end From f9952e0fd6e6be54672144dee06aa69bc81347cc Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Wed, 16 Apr 2025 15:52:02 +0200 Subject: [PATCH 08/29] Style --- app/views/notifications/_tray.html.erb | 27 ++++++++++---------------- 1 file changed, 10 insertions(+), 17 deletions(-) diff --git a/app/views/notifications/_tray.html.erb b/app/views/notifications/_tray.html.erb index 390e47054..9b3c55867 100644 --- a/app/views/notifications/_tray.html.erb +++ b/app/views/notifications/_tray.html.erb @@ -1,14 +1,11 @@ <%= turbo_stream_from Current.user, :notifications %> -<%= tag.dialog id: "notification-tray", class: "tray notification-tray", - data: { controller: "dialog", - turbo_permanent: true, - dialog_modal_value: false, - dialog_target: "dialog", - action: "keydown.esc->dialog#close:stop click@document->dialog#closeOnClickOutside" } do %> - <%= turbo_frame_tag("notifications", src: tray_notifications_path) -%> + + <%= turbo_frame_tag "notifications", src: tray_notifications_path %> - <%= link_to notifications_path, class: "tray__overflow border-radius txt-normal", data: { action: "click->dialog#close"} do %> + <%= link_to notifications_path, class: "tray__overflow border-radius txt-normal", data: { action: "click->dialog#close" } do %>
+ More… @@ -20,19 +17,15 @@ <%= button_to read_all_notifications_path, class: "notification-tray__read_action btn btn--reversed fill-transparent borderless flex-item-justify-start shadow txt-xx-small", data: { action: "click->dialog#close", turbo_frame: "notifications" } do %> - <%= icon_tag "check" %> - Mark all read + <%= icon_tag "check" %> Mark all read <% end %> - <%= link_to notifications_path, + <%= link_to tag.span("Notifications"), notifications_path, class: "btn btn--reversed borderless fill-transparent translucent shadow center txt-uppercase txt-x-small", - data: { action: "click->dialog#close"} do %> - Notifications - <% end %> + data: { action: "click->dialog#close" } %>
- -<% end %> + +
From 5932bf931674344a2ea4295ec47dbad16b49e4c9 Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Wed, 16 Apr 2025 16:21:16 +0200 Subject: [PATCH 09/29] This is rare enough that a redirect is fine --- app/controllers/notifications/readings_controller.rb | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/app/controllers/notifications/readings_controller.rb b/app/controllers/notifications/readings_controller.rb index 9da4fb827..3c1c47c1a 100644 --- a/app/controllers/notifications/readings_controller.rb +++ b/app/controllers/notifications/readings_controller.rb @@ -6,9 +6,6 @@ class Notifications::ReadingsController < ApplicationController def create_all Current.user.notifications.unread.read_all - - set_page_and_extract_portion_from Current.user.notifications.read.ordered if request.format.turbo_stream? - - Turbo::StreamsChannel.broadcast_update_to [ Current.user, :notifications ], target: "notifications", html: "" + redirect_to notifications_path end end From 8ff71b265078ff96795be506ddf9f1c9ea7606d1 Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Wed, 16 Apr 2025 16:21:31 +0200 Subject: [PATCH 10/29] Dont turbo stream when coming from a read_all redirect --- app/controllers/notifications_controller.rb | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/app/controllers/notifications_controller.rb b/app/controllers/notifications_controller.rb index 83e5db488..cbce6a92d 100644 --- a/app/controllers/notifications_controller.rb +++ b/app/controllers/notifications_controller.rb @@ -5,5 +5,10 @@ class NotificationsController < ApplicationController if @page.first? @unread = Current.user.notifications.unread.ordered end + + respond_to do |format| + format.turbo_stream if current_page_param + format.html + end end end From 397fc1d2bd012e8100fe3e1c0f6ceadda752c8b3 Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Wed, 16 Apr 2025 16:21:54 +0200 Subject: [PATCH 11/29] Only broadcast creations --- app/models/notification.rb | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/app/models/notification.rb b/app/models/notification.rb index 3980c3d8d..d4ea87a95 100644 --- a/app/models/notification.rb +++ b/app/models/notification.rb @@ -9,16 +9,18 @@ class Notification < ApplicationRecord scope :ordered, -> { order(read_at: :desc, created_at: :desc) } delegate :creator, to: :event + after_create_commit :broadcast - broadcasts_to ->(notification) { [ notification.user, :notifications ] }, inserts_by: :prepend - - class << self - def read_all - update!(read_at: Time.current) - end + def self.read_all + update!(read_at: Time.current) end def read? read_at.present? end + + private + def broadcast + broadcast_prepend_to user, :notifications, target: "notifications" + end end From 158b694d311957905cd21b01a22d10a537f16cc8 Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Wed, 16 Apr 2025 16:22:36 +0200 Subject: [PATCH 12/29] Simplify the containers Need to use CSS to hide headings in empty containers --- app/views/notifications/index.html.erb | 39 ++++++++++--------- .../readings/create.turbo_stream.erb | 9 +---- 2 files changed, 21 insertions(+), 27 deletions(-) diff --git a/app/views/notifications/index.html.erb b/app/views/notifications/index.html.erb index 806615ce3..a4b441323 100644 --- a/app/views/notifications/index.html.erb +++ b/app/views/notifications/index.html.erb @@ -1,4 +1,5 @@ <% @page_title = "Notifications" %> +<% @hide_footer_frames = true %> <% content_for :header do %>
- <%= render @unread %> + <%= render partial: "notifications/notification", collection: @unread, cached: true %> <% else %>
Nothing new for you. @@ -33,7 +33,7 @@

Previously seen

- <%= render @page.records %> + <%= render partial: "notifications/notification", collection: @page.records, cached: true %>
diff --git a/app/views/notifications/trays/show.html.erb b/app/views/notifications/trays/show.html.erb index 1e131caf6..f61c52d51 100644 --- a/app/views/notifications/trays/show.html.erb +++ b/app/views/notifications/trays/show.html.erb @@ -1,3 +1,3 @@ <%= turbo_frame_tag "notifications" do %> - <%= render partial: "notifications/notification", collection: @notifications %> + <%= render partial: "notifications/notification", collection: @notifications, cached: true %> <% end %> From d8ec2c33642f97bf22a9878da1cb35caac7344ba Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Wed, 16 Apr 2025 16:58:03 +0200 Subject: [PATCH 20/29] More natural to fetch that which will be shown first --- app/controllers/notifications_controller.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/controllers/notifications_controller.rb b/app/controllers/notifications_controller.rb index 8471b20c0..44dc0f604 100644 --- a/app/controllers/notifications_controller.rb +++ b/app/controllers/notifications_controller.rb @@ -1,11 +1,11 @@ class NotificationsController < ApplicationController def index - set_page_and_extract_portion_from Current.user.notifications.read.ordered - - if @page.first? + unless current_page_param @unread = Current.user.notifications.unread.ordered end + set_page_and_extract_portion_from Current.user.notifications.read.ordered + respond_to do |format| format.turbo_stream if current_page_param # Allows read-all action to side step pagination format.html From 2ced8e643d71bb24658a8c1b616af3e14092392a Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Wed, 16 Apr 2025 17:01:32 +0200 Subject: [PATCH 21/29] Clarify a bit --- app/models/notification.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/models/notification.rb b/app/models/notification.rb index e6a32ef3c..9fbb94a5b 100644 --- a/app/models/notification.rb +++ b/app/models/notification.rb @@ -9,7 +9,7 @@ class Notification < ApplicationRecord scope :ordered, -> { order(read_at: :desc, created_at: :desc) } delegate :creator, to: :event - after_create_commit :broadcast + after_create_commit :broadcast_unread def self.read_all update!(read_at: Time.current) @@ -24,7 +24,7 @@ class Notification < ApplicationRecord end private - def broadcast + def broadcast_unread broadcast_prepend_later_to user, :notifications, target: "notifications" end end From cfa2f2d1f930ea93a76f175307caab5ce8dd6a35 Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Wed, 16 Apr 2025 17:02:48 +0200 Subject: [PATCH 22/29] Trailing spaces --- app/views/notifications/_tray.html.erb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/views/notifications/_tray.html.erb b/app/views/notifications/_tray.html.erb index 9b3c55867..9095f1946 100644 --- a/app/views/notifications/_tray.html.erb +++ b/app/views/notifications/_tray.html.erb @@ -15,13 +15,13 @@
<%= button_to read_all_notifications_path, - class: "notification-tray__read_action btn btn--reversed fill-transparent borderless flex-item-justify-start shadow txt-xx-small", + class: "notification-tray__read_action btn btn--reversed fill-transparent borderless flex-item-justify-start shadow txt-xx-small", data: { action: "click->dialog#close", turbo_frame: "notifications" } do %> <%= icon_tag "check" %> Mark all read <% end %> <%= link_to tag.span("Notifications"), notifications_path, - class: "btn btn--reversed borderless fill-transparent translucent shadow center txt-uppercase txt-x-small", + class: "btn btn--reversed borderless fill-transparent translucent shadow center txt-uppercase txt-x-small", data: { action: "click->dialog#close" } %> From 00cbe8101c15ae839e0d04804fb2c4c091e4326c Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Wed, 16 Apr 2025 17:07:43 +0200 Subject: [PATCH 23/29] Slim it down --- app/views/notifications/index.turbo_stream.erb | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/app/views/notifications/index.turbo_stream.erb b/app/views/notifications/index.turbo_stream.erb index 00d744dcd..4d74e0941 100644 --- a/app/views/notifications/index.turbo_stream.erb +++ b/app/views/notifications/index.turbo_stream.erb @@ -1,7 +1,2 @@ -<%= turbo_stream.append :notifications_list_read do %> - <%= render @page.records %> -<% end %> - -<%= turbo_stream.replace :next_page do %> - <%= notifications_next_page_link(@page) %> -<% end %> +<%= turbo_stream.append :notifications_list_read, partial: "notifications/notification", collection: @page.records %> +<%= turbo_stream.replace :next_page, notifications_next_page_link(@page) %> From 5dc6e0394fe7f27478f26f7e5456c4b72a411e76 Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Wed, 16 Apr 2025 17:12:20 +0200 Subject: [PATCH 24/29] Style --- app/controllers/notifications_controller.rb | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/app/controllers/notifications_controller.rb b/app/controllers/notifications_controller.rb index 44dc0f604..d188e3a1e 100644 --- a/app/controllers/notifications_controller.rb +++ b/app/controllers/notifications_controller.rb @@ -1,9 +1,6 @@ class NotificationsController < ApplicationController def index - unless current_page_param - @unread = Current.user.notifications.unread.ordered - end - + @unread = Current.user.notifications.unread.ordered unless current_page_param set_page_and_extract_portion_from Current.user.notifications.read.ordered respond_to do |format| From 7c5a58bf4da160df02f61db5b9c4db920d7f4cc1 Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Wed, 16 Apr 2025 17:12:31 +0200 Subject: [PATCH 25/29] Note that this need to be able to dynamically appear --- app/views/notifications/index.html.erb | 1 + 1 file changed, 1 insertion(+) diff --git a/app/views/notifications/index.html.erb b/app/views/notifications/index.html.erb index fff162709..bf83657ee 100644 --- a/app/views/notifications/index.html.erb +++ b/app/views/notifications/index.html.erb @@ -22,6 +22,7 @@ <%= render partial: "notifications/notification", collection: @unread, cached: true %> <% else %> + <%# FIXME: Need to reveal this section if there are unread notification records in it %>
Nothing new for you.
From 5c4c06d74c4cec987f978553d7e11e262237338e Mon Sep 17 00:00:00 2001 From: Jason Zimdars Date: Wed, 16 Apr 2025 09:41:48 -0500 Subject: [PATCH 26/29] No longer used --- app/views/cards/_date.html.erb | 9 --------- 1 file changed, 9 deletions(-) delete mode 100644 app/views/cards/_date.html.erb diff --git a/app/views/cards/_date.html.erb b/app/views/cards/_date.html.erb deleted file mode 100644 index cc19afe32..000000000 --- a/app/views/cards/_date.html.erb +++ /dev/null @@ -1,9 +0,0 @@ -<% if card.due_on.present? %> - <%= form_with model: card, url: collection_card_path(card.collection, card), data: { controller: "form" } do |form| %> - - <% end %> -<% end %> From beae3d9a6b862df61e7c476605e19fc2de3f44d8 Mon Sep 17 00:00:00 2001 From: Jason Zimdars Date: Wed, 16 Apr 2025 09:55:41 -0500 Subject: [PATCH 27/29] Clearer assignment icon --- app/assets/images/person-add.svg | 1 + app/assets/stylesheets/icons.css | 1 + app/views/cards/display/common/_assignees.html.erb | 2 +- 3 files changed, 3 insertions(+), 1 deletion(-) create mode 100644 app/assets/images/person-add.svg diff --git a/app/assets/images/person-add.svg b/app/assets/images/person-add.svg new file mode 100644 index 000000000..9c8e13b8c --- /dev/null +++ b/app/assets/images/person-add.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/app/assets/stylesheets/icons.css b/app/assets/stylesheets/icons.css index 987210def..bc6f9e77f 100644 --- a/app/assets/stylesheets/icons.css +++ b/app/assets/stylesheets/icons.css @@ -50,6 +50,7 @@ .icon--password { --svg: url("password.svg "); } .icon--pencil { --svg: url("pencil.svg "); } .icon--person { --svg: url("person.svg "); } + .icon--person-add { --svg: url("person-add.svg "); } .icon--picture-add { --svg: url("picture-add.svg "); } .icon--picture-double { --svg: url("picture-double.svg "); } .icon--picture-remove { --svg: url("picture-remove.svg "); } diff --git a/app/views/cards/display/common/_assignees.html.erb b/app/views/cards/display/common/_assignees.html.erb index 58b4b67c5..7cfa48447 100644 --- a/app/views/cards/display/common/_assignees.html.erb +++ b/app/views/cards/display/common/_assignees.html.erb @@ -5,7 +5,7 @@
> From 00dd312cd694b3e138af2a6503e1112293cc2b60 Mon Sep 17 00:00:00 2001 From: Jason Zimdars Date: Wed, 16 Apr 2025 10:05:02 -0500 Subject: [PATCH 28/29] Change alignment --- app/assets/stylesheets/card-perma.css | 10 ++-------- app/views/cards/_closure_toggle.html.erb | 2 +- 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/app/assets/stylesheets/card-perma.css b/app/assets/stylesheets/card-perma.css index 3b64b2200..af825bb32 100644 --- a/app/assets/stylesheets/card-perma.css +++ b/app/assets/stylesheets/card-perma.css @@ -6,7 +6,7 @@ --actions-inline-inset: 4rem; --color-container: color-mix(in srgb, var(--card-color) 33%, var(--color-bg)); --padding-inline: calc(var(--block-space-double) + var(--block-space)); - --padding-block: var(--block-space-double) calc(var(--block-space-double) + var(--block-space-half)); + --padding-block: calc(var(--block-space-double) + var(--block-space-half)); align-items: start; column-gap: var(--inline-space); @@ -60,12 +60,7 @@ /* -------------------------------------------------------------------------- */ .card-perma__notch { - --card-notch-padding: 0.5ch; - --border-radius: 1em; - align-items: center; - background-color: var(--color-bg); - border-radius: 99rem; color: color-mix(in srgb, var(--card-color) 40%, var(--color-ink)); display: inline-flex; inline-size: auto; @@ -99,8 +94,7 @@ .card-perma__notch--bottom { grid-area: notch-bottom; - padding: calc(var(--block-space) * 0.75) calc(var(--block-space) * 0.66); - translate: 0 -50%; + translate: 0 -25%; &:has([open]) { z-index: 1; diff --git a/app/views/cards/_closure_toggle.html.erb b/app/views/cards/_closure_toggle.html.erb index 76edfa091..7958b0887 100644 --- a/app/views/cards/_closure_toggle.html.erb +++ b/app/views/cards/_closure_toggle.html.erb @@ -1,4 +1,4 @@ -
"> +
"> <% if card.closed? %> Completed by <%= card.closed_by.name %> on <%= local_datetime_tag(card.closed_at, style: :shortdate) %>. <%= button_to card_closure_path(card), method: :delete, class: "btn btn--plain borderless fill-transparent" do %> From b5090c4b214b454b47a8257eaa41877dbed535d7 Mon Sep 17 00:00:00 2001 From: Jason Zimdars Date: Wed, 16 Apr 2025 10:06:48 -0500 Subject: [PATCH 29/29] Copy edit --- app/views/cards/display/common/_meta.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/cards/display/common/_meta.html.erb b/app/views/cards/display/common/_meta.html.erb index d2ba79b98..94c5f477a 100644 --- a/app/views/cards/display/common/_meta.html.erb +++ b/app/views/cards/display/common/_meta.html.erb @@ -20,7 +20,7 @@ Reported by <%= familiar_name_for(card.creator) %> - Assigned to <%= card.assignees.any? ? card.assignees.map { |assignee| "#{familiar_name_for(assignee)}" }.to_sentence.html_safe : "no one" %> + <%= card.assignees.any? ? card.assignees.map { |assignee| "Assigned to #{familiar_name_for(assignee)}" }.to_sentence.html_safe : "Not assigned" %>