From fcfd149bd6fa1f88d6ffc2239de9414902ce8d8c Mon Sep 17 00:00:00 2001 From: Jason Zimdars Date: Wed, 18 Jun 2025 19:02:02 -0500 Subject: [PATCH] Add an optional description field for public collections --- app/assets/stylesheets/cards.css | 12 ++++++++++++ app/assets/stylesheets/utilities.css | 7 +++++++ app/controllers/collections_controller.rb | 2 +- app/models/collection.rb | 2 ++ app/views/collections/edit/_publication.html.erb | 11 ++++++++++- app/views/public/collections/show.html.erb | 14 +++++++++++--- 6 files changed, 43 insertions(+), 5 deletions(-) diff --git a/app/assets/stylesheets/cards.css b/app/assets/stylesheets/cards.css index 30aa3015a..b06987c19 100644 --- a/app/assets/stylesheets/cards.css +++ b/app/assets/stylesheets/cards.css @@ -425,4 +425,16 @@ } } } + + .card__collection-public-description { + max-inline-size: 66ch; + + p:first-child { + margin-block-start: 0; + } + + p:last-child { + margin-block-end: 0; + } + } } diff --git a/app/assets/stylesheets/utilities.css b/app/assets/stylesheets/utilities.css index 050a152aa..7da38de27 100644 --- a/app/assets/stylesheets/utilities.css +++ b/app/assets/stylesheets/utilities.css @@ -65,6 +65,13 @@ row-gap: var(--row-gap, var(--block-space-half)); } + .gap-none { + --column-gap: 0; + --row-gap: 0; + + gap: 0; + } + /* Sizing */ .full-width { inline-size: 100%; } .min-width { min-inline-size: 0; } diff --git a/app/controllers/collections_controller.rb b/app/controllers/collections_controller.rb index 170715e2c..e7100eaa4 100644 --- a/app/controllers/collections_controller.rb +++ b/app/controllers/collections_controller.rb @@ -33,7 +33,7 @@ class CollectionsController < ApplicationController end def collection_params - params.expect(collection: [ :name, :all_access, :auto_close_period, :auto_reconsider_period ]) + params.expect(collection: [ :name, :all_access, :auto_close_period, :auto_reconsider_period, :public_description ]) end def grantees diff --git a/app/models/collection.rb b/app/models/collection.rb index f341eeb40..1cce236e8 100644 --- a/app/models/collection.rb +++ b/app/models/collection.rb @@ -3,6 +3,8 @@ class Collection < ApplicationRecord belongs_to :creator, class_name: "User", default: -> { Current.user } + has_rich_text :public_description + has_many :cards, dependent: :destroy has_many :tags, -> { distinct }, through: :cards has_many :events diff --git a/app/views/collections/edit/_publication.html.erb b/app/views/collections/edit/_publication.html.erb index 82a6f3f10..72f315b8d 100644 --- a/app/views/collections/edit/_publication.html.erb +++ b/app/views/collections/edit/_publication.html.erb @@ -19,12 +19,21 @@
<%= text_field_tag :publication_url, published_collection_url(collection), disabled: true, class: "full-width input fill-white" %>
- <%= button_to_copy_to_clipboard(published_collection_url(collection)) do %> + <%= button_to_copy_to_clipboard(published_collection_url(collection)) do %> <%= icon_tag "copy-paste" %> Copy public link <% end %>
+ Add an optional description to the public page +
+ <%= form_with model: collection, class: "txt-align-start", data: { controller: "form" } do |form| %> + <%= form.rich_textarea :public_description, class: "rich-text-content txt-small", + placeholder: "Add a public note about this collection…", + data: { action: "keydown.ctrl+enter->form#submit:prevent keydown.meta+enter->form#submit:prevent keydown.esc->form#cancel:stop" } %> + <%= form.button "Save changes", type: :submit, class: "btn txt-small" %> + <% end %> +
<% else %>
diff --git a/app/views/public/collections/show.html.erb b/app/views/public/collections/show.html.erb index d55baf708..3ab851fff 100644 --- a/app/views/public/collections/show.html.erb +++ b/app/views/public/collections/show.html.erb @@ -1,9 +1,17 @@ <% @page_title = @collection.name %> <% content_for :header do %> -

- <%= @page_title %> -

+
+

+ <%= @page_title %> +

+ + <% if @collection.public_description.present? %> +
+ <%= @collection.public_description %> +
+ <% end %> +
<% end %>