mirror of
https://github.com/we-promise/sure.git
synced 2026-05-29 23:39:03 +00:00
fix(goals): keep archived cards out of the filter loop entirely
The earlier 'filter archived too' attempts kept toggling the archived section based on chip state, which produced more confusion than value (filter shows partial counts, archived hides on some chips, etc.). Step back: archived stays in its own collapsed-by-default section, always visible, never reacts to the chip / search filter. Render the cards with filterable: false so they don't add a filter target in the first place — no JS handling needed, and the active grid + chips behave exactly like they did before this whole thread.
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
<div class="group relative bg-container rounded-xl shadow-border-xs hover:shadow-sm transition-shadow p-6 <%= "opacity-75" if goal.paused? || goal.archived? %>"
|
||||
data-goals-filter-target="card"
|
||||
<% if filterable %>data-goals-filter-target="card"<% end %>
|
||||
data-goal-name="<%= goal.name %>"
|
||||
data-goal-status="<%= goal.display_status %>">
|
||||
<div class="flex items-start gap-3">
|
||||
|
||||
@@ -2,11 +2,12 @@ class Goals::CardComponent < ApplicationComponent
|
||||
RING_SIZE = 64
|
||||
RING_STROKE = 6
|
||||
|
||||
def initialize(goal:)
|
||||
def initialize(goal:, filterable: true)
|
||||
@goal = goal
|
||||
@filterable = filterable
|
||||
end
|
||||
|
||||
attr_reader :goal
|
||||
attr_reader :goal, :filterable
|
||||
|
||||
def progress_percent
|
||||
goal.progress_percent
|
||||
|
||||
@@ -20,9 +20,10 @@ class GoalsController < ApplicationController
|
||||
.sort_by { |g| [ g.paused? ? 3 : ACTIVE_STATUS_RANK.fetch(g.status, 4), g.name.downcase ] }
|
||||
@completed_goals = all_goals.select { |g| g.state == "completed" }.sort_by { |g| g.name.downcase }
|
||||
@archived_goals = all_goals.select { |g| g.state == "archived" }
|
||||
# Completed goals join the chip-filterable grid below the active ones so
|
||||
# the `completed` chip can isolate them. Archived stays in the separate
|
||||
# collapsed-by-default section below.
|
||||
# Completed goals join the chip-filterable grid below the active ones
|
||||
# so the `completed` chip can isolate them. Archived stays in a
|
||||
# separate collapsed-by-default section, opted out of the filter
|
||||
# entirely (rendered with filterable: false).
|
||||
@grid_goals = @active_goals + @completed_goals
|
||||
|
||||
@linkable_account_count = Current.family.accounts.where(accountable_type: "Depository").visible.count
|
||||
|
||||
@@ -182,7 +182,7 @@
|
||||
</summary>
|
||||
<div class="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-3.5">
|
||||
<% @archived_goals.each do |goal| %>
|
||||
<%= render Goals::CardComponent.new(goal: goal) %>
|
||||
<%= render Goals::CardComponent.new(goal: goal, filterable: false) %>
|
||||
<% end %>
|
||||
</div>
|
||||
</details>
|
||||
|
||||
Reference in New Issue
Block a user