Skip to content
Merged
4 changes: 4 additions & 0 deletions .claude/settings.local.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@
"Bash(bundle exec rails routes:*)",
"Bash(bundle exec rubocop:*)",
"Bash(git -C /Users/maebeale/programming/awbw diff --name-only main...HEAD)",

"Bash(ruby:*)",
"Bash(bundle install:*)"

"Bash(git merge:*)"
]
}
Expand Down
20 changes: 20 additions & 0 deletions app/helpers/taggings_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,24 @@ def tagged_index_path(type, sector_names_all:, category_names_all:)

polymorphic_path(klass, params)
end

# Collects all tags (sectors and categories) for a resource
# Returns an array of tag names sorted appropriately
def collect_all_tags(resource)
all_tags = []

if resource.respond_to?(:sectors) && resource.sectors.any?
all_tags += resource.sectors
.sort_by { |s| s.name.to_s.downcase }
.map(&:name)
end

if resource.respond_to?(:categories) && resource.categories.any?
all_tags += resource.categories
.sort_by { |c| [ c.position.to_i, c.name.to_s.downcase ] }
.map(&:name)
end

all_tags
end
end
4 changes: 2 additions & 2 deletions app/views/bookmarks/_personal_row.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@
You bookmarked on
<%= bookmark.created_at.strftime("%B %d, %Y") %>
</div>
<% tag_list = bookmark.bookmarkable_type == "Workshop" ? collect_all_tags(bookmarkable) : [] %>
<div class="text-sm text-gray-600">
Bookmarked by community
<%= bookmark.bookmarkable.bookmarks_count %> times
Bookmarked by community <%= bookmark.bookmarkable.bookmarks_count %> times<% if tag_list.any? %>, <span class="group relative inline-block"><span class="cursor-help">Tags: <%= tag_list.count %></span><div class="hidden group-hover:block absolute left-0 top-full mt-1 bg-white border border-gray-300 rounded-lg shadow-lg p-3 z-10 min-w-[300px] max-w-[500px]"><div class="text-sm text-gray-800"><%= tag_list.join(", ") %></div></div></span><% end %>
</div>
</div>

Expand Down
6 changes: 1 addition & 5 deletions app/views/bookmarks/update.turbo_stream.erb
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
<%= turbo_stream.replace dom_id(@bookmarkable, :bookmark_icon), partial: "editable_bookmark_icon", locals: {resource: @bookmarkable} %>
<%= turbo_stream.replace dom_id(@bookmarkable, :bookmark_button), partial: "editable_bookmark_button", locals: {resource: @bookmarkable} %>

<%= turbo_stream.update dom_id(@bookmarkable, :bookmark_count) do %>
Bookmarked:
<%= @bookmarkable.bookmarks_count %>
<%= "time".pluralize(@bookmarkable.bookmarks_count) %>
<% end %>
<%= turbo_stream.update dom_id(@bookmarkable, :bookmark_count) do %>Bookmarked: <%= @bookmarkable.bookmarks_count %> <%= "time".pluralize(@bookmarkable.bookmarks_count) %><% end %>

<%= turbo_stream.update dom_id(@bookmarkable, :bookmark_count_person) do %>
(Bookmarked by
Expand Down
24 changes: 6 additions & 18 deletions app/views/workshops/_index_row.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,11 @@
| <%= workshop.date %>
</div>

<!-- Bookmarked count -->
<%= tag.div id: dom_id(workshop, :bookmark_count),
class: "text-sm text-gray-600 leading-tight" do %>
Bookmarked: <%= workshop.bookmarks_count %> <%= "time".pluralize(workshop.bookmarks_count.to_i) %>
<% end %>
<!-- Bookmarked count + Tags count -->
<% tag_list = hide_tags ? [] : collect_all_tags(workshop) %>
<div class="text-sm text-gray-600 leading-tight">
<span id="<%= dom_id(workshop, :bookmark_count) %>">Bookmarked: <%= workshop.bookmarks_count %> <%= "time".pluralize(workshop.bookmarks_count.to_i) %></span><% if tag_list.any? %>, <span class="group relative inline-block"><span class="cursor-help">Tags: <%= tag_list.count %></span><div class="hidden group-hover:block absolute left-0 top-full mt-1 bg-white border border-gray-300 rounded-lg shadow-lg p-3 z-10 min-w-[300px] max-w-[500px]"><div class="text-sm text-gray-800"><%= tag_list.join(", ") %></div></div></span><% end %>
</div>

<!-- Led count -->
<%#= tag.div id: dom_id(workshop, :led_count),
Expand Down Expand Up @@ -110,19 +110,7 @@
</span>
</p>

<% unless hide_tags %>
<% if workshop.categories.any? %>
<% ordered_tags = workshop.categories
.sort_by { |c| [c.position.to_i, c.name.to_s.downcase] }
.map(&:name)
.to_sentence %>
<p class="tags mt-3 italic">
Tags:
<span title="<%= ordered_tags %>">
<%= ordered_tags.truncate(150) %></span>
</p>
<% end %>
<% end %>


</div>
</div>
Expand Down