Merge branch 'main' into activity-dom

* main:
  Just set the clear filter so `restore_collections_filter_from_cookie` can do the right thing
  Refresh local time target when morphed
  Handle case where no params are sent because nothing is checked
  Ensure checkboxes in menus have full size click targets
  Do or die
  Handle collections that do not auto close
  Ensure dates are re-formatted on turbo frame load
This commit is contained in:
Andy Smith
2025-05-13 16:28:17 -05:00
8 changed files with 33 additions and 23 deletions
@@ -4,12 +4,19 @@ module DayTimelinesScoped
included do
include FilterScoped
before_action :normalize_collection_params
before_action :restore_collections_filter_from_cookie
before_action :set_day_timeline
after_action :save_collections_filter_to_cookie
end
private
def normalize_collection_params
if params[:collection_ids].blank? && !params[:clear_filter]
params[:clear_filter] = true
end
end
def restore_collections_filter_from_cookie
if params[:clear_filter]
delete_collections_filter_cookie
+1 -1
View File
@@ -1,5 +1,5 @@
module TimeHelper
def local_datetime_tag(datetime, style: :time, **attributes)
tag.time **attributes, datetime: datetime.iso8601, data: { local_time_target: style }
tag.time **attributes, datetime: datetime.iso8601, data: { local_time_target: style, action: "turbo:morph-element->local-time#refreshTarget" }
end
end
@@ -37,6 +37,12 @@ export default class extends Controller {
})
}
refreshTarget(event) {
const target = event.target;
const targetName = target.dataset.localTimeTarget
this.#formatTime(this[`${targetName}Formatter`], target)
}
timeTargetConnected(target) {
this.#formatTime(this.timeFormatter, target)
}
+1 -1
View File
@@ -34,7 +34,7 @@ module Card::Closeable
end
def closing_soon?
considering? && Time.current >= auto_close_at - AUTO_CLOSE_REMINDER_BEFORE
considering? && auto_closing? && Time.current >= auto_close_at - AUTO_CLOSE_REMINDER_BEFORE
end
def closed?
@@ -5,7 +5,7 @@
<% end %>
<% if Current.user.collections.one? %>
<%= link_to cards_path(filter.as_params.except(:collection_ids)), class: "popup__group flex align-center", style: "--hover-size: 0" do %>
<%= link_to cards_path(filter.as_params.except(:collection_ids)), class: "popup__group flex align-center" do %>
<%= tag.div class: "btn popup__item min-width flex-item-grow" do %>
<span class="overflow-ellipsis"><%= Current.user.collections.first.name %></span>
<span class="txt-ink translucent flex-item-no-shrink flex-item-justify-end"><span class="txt-x-small txt-uppercase">GO TO</span> </span>
@@ -13,14 +13,14 @@
<% end %>
<% elsif Current.user.collections.many? %>
<%= link_to cards_path(filter.as_params.except(:collection_ids)), class: "popup__group flex align-center", style: "--hover-size: 0" do %>
<div class="btn txt-xx-small flex-item-no-shrink">
<label class="btn txt-xx-small flex-item-no-shrink" style="--hover-size: 0.15rem">
<input type="checkbox" <%= "checked" if filter.collection_ids.empty? %>>
<span class="for-screen-reader">
See everything in all collections
</span>
<%= icon_tag "check", size: 18, class: "checked" %>
</div>
</label>
<%= tag.div class: "btn popup__item min-width flex-item-grow" do %>
<span class="overflow-ellipsis">All collections</span>
<span class="txt-ink translucent flex-item-no-shrink flex-item-justify-end"><span class="txt-x-small txt-uppercase">GO TO</span> </span>
@@ -29,7 +29,7 @@
<% Current.user.collections.order(:name).each do |collection| %>
<li class="popup__group flex align-center" data-value="<%= collection.name.downcase %>">
<div class="btn txt-xx-small flex-item-no-shrink">
<label class="btn txt-xx-small flex-item-no-shrink">
<%= form.check_box "collection_ids[]", {
checked: filter.collections.include?(collection),
data: { action: "change->form#submit" },
@@ -40,7 +40,7 @@
Toggle filter for <%= collection.name %>
</span>
<%= icon_tag "check", size: 18, class: "checked" %>
</div>
</label>
<%= link_to cards_path(collection_ids: [ collection ]), class: "btn popup__item min-width flex-item-grow" do %>
<span class="overflow-ellipsis"><%= collection.name %></span>
@@ -1,4 +1,4 @@
<strong class="txt-large">Auto-Close Cards</strong>
<strong class="txt-large">Do or Die</strong>
<label for="closure" class="margin-block-end">Cards automatically close when there is no activity for…</label>
<%= form_with model: collection, data: { controller: "form" } do |form| %>
@@ -6,21 +6,18 @@
<% end %>
<% end %>
<% elsif Current.user.collections.many? %>
<div class="popup__group flex align-center" style="--hover-size: 0">
<div class="btn txt-xx-small flex-item-no-shrink">
<%= link_to events_path(clear_filter: true), style: "--hover-size: 0" do %>
<div class="popup__group flex align-center">
<%= link_to events_path(clear_filter: true), class: "btn txt-xx-small flex-item-no-shrink" do %>
<%= check_box_tag "filter_collections", nil, filter.collections.blank?, class: "form-checkbox" %>
<span class="for-screen-reader">
See everything in all collections
</span>
<%= icon_tag "check", size: 18, class: "checked" %>
<% end %>
<span class="for-screen-reader">
See everything in all collections
</span>
<%= icon_tag "check", size: 18, class: "checked" %>
</div>
<%= link_to cards_path(filter.as_params.except(:collection_ids)), class: "btn popup__item min-width flex-item-grow" do %>
<span class="overflow-ellipsis">All collections</span>
<span class="txt-ink translucent flex-item-no-shrink flex-item-justify-end"><span class="txt-x-small txt-uppercase">GO TO</span> </span>
<% end %>
<%= link_to cards_path(filter.as_params.except(:collection_ids)), class: "btn popup__item min-width flex-item-grow" do %>
<span class="overflow-ellipsis">All collections</span>
<span class="txt-ink translucent flex-item-no-shrink flex-item-justify-end"><span class="txt-x-small txt-uppercase">GO TO</span> </span>
<% end %>
</div>
<% end %>
@@ -1,5 +1,5 @@
<li class="popup__group flex align-center" data-value="<%= collection.name.downcase %>">
<div class="btn txt-xx-small">
<label class="btn txt-xx-small">
<%= form.check_box "collection_ids[]", {
checked: filter.collections.include?(collection),
data: { action: "change->form#submit" },
@@ -10,7 +10,7 @@
Toggle filter for <%= collection.name %>
</span>
<%= icon_tag "check", size: 18, class: "checked flex-item-justify-end" %>
</div>
</label>
<%= link_to cards_path(collection_ids: [ collection ]), class: "btn popup__item min-width flex-item-grow" do %>
<span class="overflow-ellipsis"><%= collection.name %></span>