mirror of
https://github.com/we-promise/sure.git
synced 2026-09-06 07:11:14 +00:00
* Add parent/child category hierarchy to all category selects; add search to account select
Category selection consistency:
- DS::Select (shared component powering the main transaction form,
transaction edit, bulk-update, and transfer category pickers) now
indents subcategories with a corner-down-right icon, matching the
existing transaction-row category dropdown.
- Feed DS::Select-based category pickers with Category.alphabetically_by_hierarchy
(parent name, then parent-before-children, then own name) so children
render directly under their parent.
- Added Category::Group.select_options, a shared helper producing
parent-then-child ordered options (with an indent marker) for plain
HTML <select> elements. Used by:
- Rule builder category condition/action selects
- Bulk 'categorize transactions' select
- CSV/QIF import category mapping select
- Grouped the splits category combobox and the transaction search
category filter checklist the same way, both with the
corner-down-right indent icon used elsewhere.
Account selection:
- Added searchable: true to the account select in the new/edit
transaction form, matching the category and merchant selects next
to it.
* Fix SyntaxError: 'for' is a Ruby reserved keyword
Category::Group.select_options called for(categories) as a bare method
call, but Ruby parses a bare 'for' as the start of a for..in loop
statement, not a method invocation. Qualify it as self.for(categories)
to call the class method explicitly.
Verified with 'ruby -c' on all touched .rb files and ERB.new(...).src
on all touched .erb files.
* Add test coverage for category hierarchy and account search
Model-level:
- Category::GroupTest (new): for() grouping and the new select_options
helper (order + indent labels).
- CategoryTest: alphabetically_by_hierarchy scope ordering.
- Rule::ConditionFilter::TransactionCategoryTest (new)
- Rule::ActionExecutor::SetTransactionCategoryTest (new)
- Import::CategoryMappingTest (new): grouping + 'Add as new category'
still prepends correctly.
Controller/integration-level (asserting actual rendered HTML order):
- SplitsControllerTest: category combobox data-value ordering.
- Transactions::CategorizesControllerTest: bulk-categorize <select>
option ordering.
- TransactionsControllerTest:
- search filter checkbox ordering (q[categories][])
- new-transaction DS::Select category ordering (via trigger id +
ancestor traversal)
- new-transaction account select renders a search box
All new/modified test files verified with 'ruby -c' (syntax) and
cross-checked fixture names, family scoping, route helpers, and field
names against the actual fixtures/routes/views. Ruby/Bundler network
access to rubygems.org is unavailable in this sandbox, so the suite
itself has not been executed — run 'bin/rails test' before merging.
* Align with design-sure conventions: keep domain logic in component, not template
Per .cursor/rules/view_conventions.mdc ('keep domain logic out of the
views'), the parent/child hierarchy check for DS::Select items belongs
in the component class, not inline in the ERB template. DS::Select
already has this exact pattern for other per-item derived properties
(color_for, icon_for, logo_for) — added child? alongside them and
updated the template to call it instead of computing it inline.
Added test/components/DS/select_test.rb (ViewComponent::TestCase,
no rendering needed) covering child? directly: subcategory objects,
root-category objects, non-hierarchical objects (merchants), and the
include_blank placeholder item.
Also did a broader pass against the design-sure .cursor/rules to confirm
the rest of this branch's changes already comply:
- Uses Current.family (never current_family) throughout
- Uses the icon() helper exclusively, never lucide_icon directly
- No new/hardcoded colors; only existing semantic Tailwind tokens
already used elsewhere in these same files
- No changes to sure-design-system.css / application.css
- Extended existing components/partials rather than creating new ones
where one already existed (view_conventions.mdc component-vs-partial
guidance)
- Test additions stay in Minitest + fixtures, avoid system tests,
and test query-method output directly (testing.mdc)
* Address CodeRabbit review: sort category groups, tighten test assertion, move grouping out of view
* Address review: fix arrow leak in rule summaries, filter panel alignment, simplify splits ordering
* fix(pages): set breadcrumbs for changelog and feedback pages (#2889)
* fix(app): set breadcrumbs for changelog and feedback pages
* feat(test): add test to assert breadcrumbs
* fix(test): remove changes
* feat(app): update breadcrumbs to use semantic nav element
* feat(test): add breadcrumb assertions to changelog and feedback pages
* fix(app): replace breadcrumb nav element with div containing data-breadcrumbs attribute
* fix ci failures
* resolved failures
* Regenerate schema.rb from migrations
* Fix test
* Remove schema dump noise
---------
Signed-off-by: Shibu M <23173570+DataEnginr@users.noreply.github.com>
Signed-off-by: Juan José Mata <juanjo.mata@gmail.com>
Co-authored-by: Claude <claude@anthropic.com>
Co-authored-by: Kenrick Tandrian <60643640+KenTandrian@users.noreply.github.com>
Co-authored-by: Juan José Mata <juanjo.mata@gmail.com>
106 lines
4.2 KiB
ERB
106 lines
4.2 KiB
ERB
<div class="relative"
|
|
data-controller="category-select"
|
|
data-category-select-create-url-value="<%= helpers.categories_path(format: :json) %>"
|
|
data-category-select-default-color-value="<%= Category::COLORS.first %>"
|
|
data-category-select-disabled-value="<%= disabled %>"
|
|
data-category-select-auto-submit-value="<%= auto_submit %>"
|
|
data-category-select-create-label-value="<%= helpers.t("transactions.form.create_category", name: "__CATEGORY_NAME__") %>"
|
|
data-category-select-create-error-message-value="<%= helpers.t("transactions.form.create_category_error") %>"
|
|
data-action="click@window->category-select#handleOutsideClick">
|
|
|
|
<div class="form-field">
|
|
<div class="form-field__body">
|
|
<%= form.label :category_id,
|
|
helpers.t("transactions.form.category"),
|
|
class: "form-field__label" %>
|
|
|
|
<button type="button"
|
|
id="<%= trigger_id %>"
|
|
class="form-field__input min-h-7 flex items-center gap-2 pr-8"
|
|
data-category-select-target="button"
|
|
data-action="click->category-select#toggle"
|
|
aria-haspopup="listbox"
|
|
aria-expanded="false"
|
|
aria-controls="<%= menu_id %>"
|
|
<%= "disabled" if disabled %>>
|
|
|
|
<span data-category-select-target="selectionContainer"
|
|
class="text-secondary">
|
|
<% selected = categories.find { |c| c.id.to_s == selected_id } %>
|
|
|
|
<% if selected %>
|
|
<%= render partial: "categories/badge",
|
|
locals: { category: selected } %>
|
|
<% else %>
|
|
<%= helpers.t("transactions.form.category_prompt") %>
|
|
<% end %>
|
|
</span>
|
|
</button>
|
|
</div>
|
|
</div>
|
|
|
|
<input type="hidden"
|
|
name="<%= field_name %>"
|
|
value="<%= selected_id %>"
|
|
data-category-select-target="hiddenInput"
|
|
<%= "disabled" if disabled %>>
|
|
|
|
<% unless disabled %>
|
|
<div class="absolute z-50 p-1.5 w-full min-w-48 rounded-lg shadow-lg bg-container mt-1.5 hidden"
|
|
data-category-select-target="menu">
|
|
|
|
<%= render DS::SearchInput.new(
|
|
variant: :embedded,
|
|
placeholder: helpers.t("transactions.form.category_search_placeholder"),
|
|
data: {
|
|
category_select_target: "search",
|
|
action: "input->category-select#filter keydown->category-select#handleSearchKeydown"
|
|
}
|
|
) %>
|
|
|
|
<div class="flex flex-col gap-1 max-h-64 overflow-auto mt-1"
|
|
id="<%= menu_id %>"
|
|
role="listbox">
|
|
|
|
<% if blank_label.present? %>
|
|
<button type="button"
|
|
role="option"
|
|
aria-selected="<%= selected_id.blank? %>"
|
|
data-category-select-target="option"
|
|
data-category-id=""
|
|
data-category-name="<%= blank_label %>"
|
|
data-category-display-label="<%= blank_label %>"
|
|
data-action="click->category-select#selectCategory"
|
|
class="flex items-center gap-2 w-full px-3 py-1.5 text-sm rounded-lg hover:bg-container-inset-hover <%= "bg-container-inset" if selected_id.blank? %>">
|
|
<span class="check-icon w-4 <%= "invisible" unless selected_id.blank? %>">
|
|
<%= helpers.icon("check") %>
|
|
</span>
|
|
|
|
<span><%= blank_label %></span>
|
|
</button>
|
|
<% end %>
|
|
|
|
<% categories.each do |category| %>
|
|
<%= render partial: "DS/category_select/option",
|
|
locals: {
|
|
category: category,
|
|
selected: category.id.to_s == selected_id,
|
|
view_helpers: helpers
|
|
} %>
|
|
<% end %>
|
|
|
|
<button type="button"
|
|
class="hidden text-primary text-sm cursor-pointer items-center gap-2 px-3 py-1.5 rounded-lg hover:bg-container-inset-hover"
|
|
data-category-select-target="createForm"
|
|
data-action="click->category-select#createCategory">
|
|
<%= helpers.icon("plus") %>
|
|
<span data-category-select-target="createLabel"></span>
|
|
</button>
|
|
|
|
<p class="hidden px-3 py-1 text-xs text-destructive"
|
|
data-category-select-target="createError"></p>
|
|
</div>
|
|
</div>
|
|
<% end %>
|
|
</div>
|