-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
[Admin] Create new Tax Categories #5674
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
Merged
spaghetticode
merged 9 commits into
solidusio:main
from
nebulab:spaghetticode/admin-new-tax-category
Mar 11, 2024
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
01cf140
Fix tax category filtering
spaghetticode 8f8a4be
Fix tax category params
spaghetticode 1878496
Rework modal component
spaghetticode dca0c68
Add turbo frames to page component
spaghetticode ef06144
Show link to new tax category page
spaghetticode 565e58a
Update turbo-rails gem to v2.0
spaghetticode 15899d4
Add TaxCategoriesController#new action
spaghetticode bcbd4eb
Add New Tax Category component
spaghetticode 5584f93
Complete tax category creation process
spaghetticode File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
admin/app/components/solidus_admin/tax_categories/new/component.html.erb
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| <%= turbo_frame_tag :new_tax_category_modal do %> | ||
| <%= render component("ui/modal").new(title: t(".title")) do |modal| %> | ||
| <%= form_for @tax_category, url: solidus_admin.tax_categories_path(page: params[:page], q: params[:q]), html: { id: form_id } do |f| %> | ||
| <div class="flex flex-col gap-6 pb-4"> | ||
| <%= render component("ui/forms/field").text_field(f, :name) %> | ||
| <%= render component("ui/forms/field").text_field(f, :tax_code) %> | ||
| <%= render component("ui/forms/field").text_field(f, :description) %> | ||
| <label class="flex gap-2 items-center"> | ||
| <%= render component("ui/forms/checkbox").new( | ||
| name: "#{f.object_name}[is_default]", | ||
| value: "1", | ||
| checked: f.object.is_default | ||
| ) %> | ||
| <span class="font-semibold text-xs ml-2"><%= Spree::TaxCategory.human_attribute_name :is_default %></span> | ||
| <%= render component("ui/toggletip").new(text: t(".hints.is_default")) %> | ||
| </label> | ||
| </div> | ||
| <% modal.with_actions do %> | ||
| <form method="dialog"> | ||
| <%= render component("ui/button").new(scheme: :secondary, text: t('.cancel')) %> | ||
| </form> | ||
| <%= render component("ui/button").new(form: form_id, type: :submit, text: t('.submit')) %> | ||
| <% end %> | ||
| <% end %> | ||
| <% end %> | ||
| <% end %> | ||
|
|
||
| <%= render component("tax_categories/index").new(page: @page) %> |
12 changes: 12 additions & 0 deletions
12
admin/app/components/solidus_admin/tax_categories/new/component.rb
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| # frozen_string_literal: true | ||
|
|
||
| class SolidusAdmin::TaxCategories::New::Component < SolidusAdmin::TaxCategories::Index::Component | ||
| def initialize(page:, tax_category:) | ||
| @page = page | ||
| @tax_category = tax_category | ||
| end | ||
|
|
||
| def form_id | ||
| dom_id(@tax_category, "#{stimulus_id}_new_tax_category_form") | ||
| end | ||
| end |
8 changes: 8 additions & 0 deletions
8
admin/app/components/solidus_admin/tax_categories/new/component.yml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| # Add your component translations here. | ||
| # Use the translation in the example in your template with `t(".hello")`. | ||
| en: | ||
| title: "New Tax Category" | ||
| cancel: "Cancel" | ||
| submit: "Add Tax Category" | ||
| hints: | ||
| is_default: "When checked, this tax category will be selected by default when creating new products or variants." |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| import { Controller } from "@hotwired/stimulus"; | ||
|
|
||
| export default class extends Controller { | ||
| connect() { | ||
| this.element.showModal(); | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -98,4 +98,8 @@ def render_sidebar | |
|
|
||
| page_with_sidebar_aside { sidebar } if sidebar | ||
| end | ||
|
|
||
| def turbo_frames | ||
| [] | ||
| end | ||
| end | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
;semicolons can be omitted.