Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[pull] main from solidusio:main #402

Merged
merged 18 commits into from
Mar 12, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add TaxCategoriesController#new action
The `new` action will render a modal dialog above a list of tax
categories, like the `index` action. For this reason, the common
controller code is extracted to a private method.
  • Loading branch information
spaghetticode committed Mar 7, 2024
commit 15899d4fd12d80c0c814701dc75c5625b71b06dd
26 changes: 20 additions & 6 deletions admin/app/controllers/solidus_admin/tax_categories_controller.rb
Original file line number Diff line number Diff line change
@@ -4,13 +4,18 @@ module SolidusAdmin
class TaxCategoriesController < SolidusAdmin::BaseController
include SolidusAdmin::ControllerHelpers::Search

def index
tax_categories = apply_search_to(
Spree::TaxCategory.order(created_at: :desc, id: :desc),
param: :q,
)
def new
@tax_category = Spree::TaxCategory.new

set_page_and_extract_portion_from(tax_categories)
set_index_page

respond_to do |format|
format.html { render component('tax_categories/new').new(page: @page, tax_category: @tax_category) }
end
end

def index
set_index_page

respond_to do |format|
format.html { render component('tax_categories/index').new(page: @page) }
@@ -36,5 +41,14 @@ def load_tax_category
def tax_category_params
params.require(:tax_category).permit(:name, :description, :is_default, :tax_code)
end

def set_index_page
tax_categories = apply_search_to(
Spree::TaxCategory.order(created_at: :desc, id: :desc),
param: :q,
)

set_page_and_extract_portion_from(tax_categories)
end
end
end