Skip to content

Commit

Permalink
Final cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
jakubkottnauer committed May 21, 2024
1 parent 97801e5 commit 49c04cd
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def create

private
def set_category
@category = Current.family.transaction_categories.find(params[:transaction_category_id])
@category = Current.family.transaction_categories.find(params[:category_id])
end

def set_replacement_category
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,12 @@ class Transactions::Categories::DropdownsController < ApplicationController

def show
@categories = categories_scope.to_a.excluding(@selected_category).prepend(@selected_category).compact
@selected_category_id = params[:selected_category_id]
end

private
def set_from_params
if params[:selected_category_id]
@selected_category = categories_scope.find(params[:selected_category_id])
if params[:category_id]
@selected_category = categories_scope.find(params[:category_id])
end

if params[:transaction_id]
Expand Down
2 changes: 1 addition & 1 deletion app/views/transactions/categories/_menu.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
</button>
<div data-menu-target="content" class="absolute z-10 hidden w-screen mt-2 max-w-min cursor-default">
<div class="w-64 text-sm font-semibold leading-6 text-gray-900 bg-white shadow-lg shrink rounded-xl ring-1 ring-gray-900/5">
<%= turbo_frame_tag "category_dropdown", src: transaction_categories_dropdown_path(selected_category_id: transaction.category_id, transaction_id: transaction.id), loading: :lazy do %>
<%= turbo_frame_tag "category_dropdown", src: transaction_category_dropdown_path(category_id: transaction.category_id, transaction_id: transaction.id), loading: :lazy do %>
<div class="p-6 flex items-center justify-center">
<p class="text-sm text-gray-500 animate-pulse"><%= t(".loading") %></p>
</div>
Expand Down
2 changes: 1 addition & 1 deletion app/views/transactions/categories/dropdowns/_row.html.erb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<%# locals: (category:) %>
<% is_selected = category.id === @selected_category_id %>
<% is_selected = category.id === @selected_category&.id %>
<%= content_tag :div, class: ["filterable-item flex justify-between items-center border-none rounded-lg px-2 py-1 group w-full", { "bg-gray-25": is_selected }], data: { filter_name: category.name } do %>
<%= button_to transaction_path(@transaction, transaction: { category_id: category.id }), method: :patch, class: "flex w-full items-center gap-1.5 cursor-pointer" do %>
Expand Down
6 changes: 3 additions & 3 deletions config/locales/views/transaction/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@ en:
you can also assign a new category below.
replacement_category_prompt: Select category
dropdowns:
row:
delete: Delete category
edit: Edit category
show:
add_new: Add new
clear: Clear
no_categories: No categories found
search_placeholder: Search
row:
delete: Delete category
edit: Edit category
edit:
edit: Edit category
form:
Expand Down
14 changes: 7 additions & 7 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,19 +38,19 @@
end

resources :transactions do
match "search" => "transactions#search", on: :collection, via: %i[ get post ], as: :search

collection do
scope module: :transactions do
resources :categories, as: :transaction_categories do
match "search" => "transactions#search", via: %i[ get post ]

scope module: :transactions, as: :transaction do
resources :categories do
resources :deletions, only: %i[ new create ], module: :categories
collection do
resource :dropdown, only: :show, module: :categories, as: :transaction_categories_dropdown
resource :dropdown, only: :show, module: :categories, as: :category_dropdown
end
end

resources :rules, only: %i[ index ], as: :transaction_rules
resources :merchants, only: %i[ index new create edit update destroy ], as: :transaction_merchants
resources :rules, only: %i[ index ]
resources :merchants, only: %i[ index new create edit update destroy ]
end
end
end
Expand Down

0 comments on commit 49c04cd

Please sign in to comment.