Add an optional description field for public collections

This commit is contained in:
Jason Zimdars
2025-06-18 19:02:02 -05:00
parent 5e7349d274
commit fcfd149bd6
6 changed files with 43 additions and 5 deletions
+12
View File
@@ -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;
}
}
}
+7
View File
@@ -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; }
+1 -1
View File
@@ -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
+2
View File
@@ -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
@@ -19,12 +19,21 @@
<div class="flex align-center gap-half margin-block">
<%= text_field_tag :publication_url, published_collection_url(collection), disabled: true, class: "full-width input fill-white" %>
<div class="flex align-center justify-center gap-half">
<%= button_to_copy_to_clipboard(published_collection_url(collection)) do %>
<%= button_to_copy_to_clipboard(published_collection_url(collection)) do %>
<%= icon_tag "copy-paste" %>
<span class="for-screen-reader">Copy public link</span>
<% end %>
</div>
</div>
<strong class="margin-block-end-half flex justify-center txt-small">Add an optional description to the public page</strong>
<div class="border-radius input fill-white">
<%= 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 %>
</div>
</div>
<% else %>
<div class="border-radius pad fill-shade">
+11 -3
View File
@@ -1,9 +1,17 @@
<% @page_title = @collection.name %>
<% content_for :header do %>
<h1 class="txt-large overflow-ellipsis margin-none pad">
<span><%= @page_title %></span>
</h1>
<div class="flex-column margin-block unpad gap-none">
<h1 class="txt-large overflow-ellipsis margin-none">
<span><%= @page_title %></span>
</h1>
<% if @collection.public_description.present? %>
<div class="card__collection-public-description txt-align-center">
<%= @collection.public_description %>
</div>
<% end %>
</div>
<% end %>
<div class="card-columns">