solidus_admin 0.1.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +61 -7
- data/Rakefile +1 -0
- data/app/assets/builds/solidus_admin/tailwind.css +197 -162
- data/app/assets/stylesheets/solidus_admin/dark.css +1 -0
- data/app/assets/stylesheets/solidus_admin/dimmed.css +1 -0
- data/app/components/solidus_admin/adjustment_reasons/edit/component.html.erb +27 -0
- data/app/components/solidus_admin/adjustment_reasons/edit/component.rb +12 -0
- data/app/components/solidus_admin/adjustment_reasons/edit/component.yml +8 -0
- data/app/components/solidus_admin/adjustment_reasons/index/component.rb +26 -19
- data/app/components/solidus_admin/adjustment_reasons/new/component.html.erb +28 -0
- data/app/components/solidus_admin/adjustment_reasons/new/component.rb +12 -0
- data/app/components/solidus_admin/adjustment_reasons/new/component.yml +8 -0
- data/app/components/solidus_admin/base_component.rb +4 -1
- data/app/components/solidus_admin/option_types/index/component.rb +21 -7
- data/app/components/solidus_admin/orders/index/component.rb +28 -23
- data/app/components/solidus_admin/orders/index/component.yml +1 -1
- data/app/components/solidus_admin/orders/show/address/component.html.erb +56 -54
- data/app/components/solidus_admin/orders/show/adjustments/index/adjustable/component.rb +27 -0
- data/app/components/solidus_admin/orders/show/adjustments/index/adjustable/spree_line_item/component.rb +14 -0
- data/app/components/solidus_admin/orders/show/adjustments/index/adjustable/spree_order/component.rb +11 -0
- data/app/components/solidus_admin/orders/show/adjustments/index/adjustable/spree_shipment/component.rb +15 -0
- data/app/components/solidus_admin/orders/show/adjustments/index/component.rb +147 -0
- data/app/components/solidus_admin/orders/show/adjustments/index/component.yml +21 -0
- data/app/components/solidus_admin/orders/show/adjustments/index/source/component.rb +26 -0
- data/app/components/solidus_admin/orders/show/adjustments/index/source/spree_tax_rate/component.rb +17 -0
- data/app/components/solidus_admin/orders/show/adjustments/index/source/spree_unit_cancel/component.rb +7 -0
- data/app/components/solidus_admin/orders/show/component.html.erb +7 -3
- data/app/components/solidus_admin/orders/show/component.rb +8 -0
- data/app/components/solidus_admin/orders/show/email/component.html.erb +18 -13
- data/app/components/solidus_admin/orders/show/email/component.rb +0 -4
- data/app/components/solidus_admin/orders/show/summary/component.html.erb +1 -1
- data/app/components/solidus_admin/payment_methods/index/component.rb +29 -19
- data/app/components/solidus_admin/payment_methods/index/component.yml +0 -5
- data/app/components/solidus_admin/products/index/component.rb +25 -15
- data/app/components/solidus_admin/products/index/component.yml +0 -2
- data/app/components/solidus_admin/products/show/component.html.erb +14 -3
- data/app/components/solidus_admin/products/status/component.rb +4 -1
- data/app/components/solidus_admin/products/status/component.yml +1 -0
- data/app/components/solidus_admin/properties/index/component.rb +18 -19
- data/app/components/solidus_admin/refund_reasons/edit/component.html.erb +27 -0
- data/app/components/solidus_admin/refund_reasons/edit/component.rb +12 -0
- data/app/components/solidus_admin/refund_reasons/edit/component.yml +8 -0
- data/app/components/solidus_admin/refund_reasons/index/component.rb +26 -19
- data/app/components/solidus_admin/refund_reasons/new/component.html.erb +27 -0
- data/app/components/solidus_admin/refund_reasons/new/component.rb +12 -0
- data/app/components/solidus_admin/refund_reasons/new/component.yml +6 -0
- data/app/components/solidus_admin/refunds_and_returns/component.rb +33 -13
- data/app/components/solidus_admin/reimbursement_types/index/component.rb +7 -25
- data/app/components/solidus_admin/return_reasons/edit/component.html.erb +26 -0
- data/app/components/solidus_admin/return_reasons/edit/component.rb +12 -0
- data/app/components/solidus_admin/return_reasons/edit/component.yml +8 -0
- data/app/components/solidus_admin/return_reasons/index/component.rb +27 -19
- data/app/components/solidus_admin/return_reasons/new/component.html.erb +27 -0
- data/app/components/solidus_admin/return_reasons/new/component.rb +12 -0
- data/app/components/solidus_admin/return_reasons/new/component.yml +8 -0
- data/app/components/solidus_admin/roles/edit/component.html.erb +33 -0
- data/app/components/solidus_admin/roles/edit/component.rb +20 -0
- data/app/components/solidus_admin/roles/edit/component.yml +19 -0
- data/app/components/solidus_admin/roles/index/component.rb +70 -0
- data/app/components/solidus_admin/roles/index/component.yml +6 -0
- data/app/components/solidus_admin/roles/new/component.html.erb +33 -0
- data/app/components/solidus_admin/roles/new/component.rb +20 -0
- data/app/components/solidus_admin/roles/new/component.yml +19 -0
- data/app/components/solidus_admin/shipping/component.rb +23 -11
- data/app/components/solidus_admin/shipping_categories/edit/component.html.erb +16 -0
- data/app/components/solidus_admin/shipping_categories/edit/component.rb +12 -0
- data/app/components/solidus_admin/shipping_categories/edit/component.yml +6 -0
- data/app/components/solidus_admin/shipping_categories/index/component.rb +37 -20
- data/app/components/solidus_admin/shipping_categories/new/component.html.erb +17 -0
- data/app/components/solidus_admin/shipping_categories/new/component.rb +12 -0
- data/app/components/solidus_admin/shipping_categories/new/component.yml +6 -0
- data/app/components/solidus_admin/shipping_methods/index/component.rb +19 -19
- data/app/components/solidus_admin/stock_items/edit/component.html.erb +66 -72
- data/app/components/solidus_admin/stock_items/edit/component.rb +0 -5
- data/app/components/solidus_admin/stock_items/index/component.rb +13 -20
- data/app/components/solidus_admin/stock_locations/index/component.rb +19 -11
- data/app/components/solidus_admin/stock_locations/index/component.yml +0 -3
- data/app/components/solidus_admin/store_credit_reasons/edit/component.html.erb +26 -0
- data/app/components/solidus_admin/store_credit_reasons/edit/component.rb +12 -0
- data/app/components/solidus_admin/store_credit_reasons/edit/component.yml +8 -0
- data/app/components/solidus_admin/store_credit_reasons/index/component.rb +26 -19
- data/app/components/solidus_admin/store_credit_reasons/new/component.html.erb +27 -0
- data/app/components/solidus_admin/store_credit_reasons/new/component.rb +12 -0
- data/app/components/solidus_admin/store_credit_reasons/new/component.yml +8 -0
- data/app/components/solidus_admin/stores/index/component.rb +18 -19
- data/app/components/solidus_admin/tax_categories/edit/component.html.erb +28 -0
- data/app/components/solidus_admin/tax_categories/edit/component.rb +12 -0
- data/app/components/solidus_admin/tax_categories/edit/component.yml +8 -0
- data/app/components/solidus_admin/tax_categories/index/component.rb +28 -21
- data/app/components/solidus_admin/tax_categories/new/component.html.erb +28 -0
- data/app/components/solidus_admin/tax_categories/new/component.rb +12 -0
- data/app/components/solidus_admin/tax_categories/new/component.yml +8 -0
- data/app/components/solidus_admin/tax_rates/index/component.rb +21 -17
- data/app/components/solidus_admin/taxes/component.rb +8 -8
- data/app/components/solidus_admin/taxonomies/index/component.rb +18 -12
- data/app/components/solidus_admin/ui/button/component.rb +1 -1
- data/app/components/solidus_admin/ui/checkbox_row/component.html.erb +29 -0
- data/app/components/solidus_admin/ui/checkbox_row/component.rb +11 -0
- data/app/components/solidus_admin/ui/forms/address/component.html.erb +27 -9
- data/app/components/solidus_admin/ui/forms/address/component.js +38 -13
- data/app/components/solidus_admin/ui/forms/search/component.html.erb +2 -3
- data/app/components/solidus_admin/ui/forms/search/component.js +3 -3
- data/app/components/solidus_admin/ui/modal/component.html.erb +7 -7
- data/app/components/solidus_admin/ui/modal/component.js +7 -0
- data/app/components/solidus_admin/ui/modal/component.rb +1 -1
- data/app/components/solidus_admin/ui/pages/index/component.html.erb +44 -0
- data/app/components/solidus_admin/ui/pages/index/component.rb +105 -0
- data/app/components/solidus_admin/ui/panel/component.html.erb +5 -16
- data/app/components/solidus_admin/ui/panel/component.rb +11 -7
- data/app/components/solidus_admin/ui/table/component.html.erb +2 -1
- data/app/components/solidus_admin/ui/table/component.js +31 -2
- data/app/components/solidus_admin/ui/table/component.rb +24 -8
- data/app/components/solidus_admin/ui/table/component.yml +1 -0
- data/app/components/solidus_admin/ui/thumbnail/component.rb +1 -1
- data/app/components/solidus_admin/ui/thumbnail_with_caption/component.html.erb +17 -0
- data/app/components/solidus_admin/ui/thumbnail_with_caption/component.rb +15 -0
- data/app/components/solidus_admin/users/addresses/component.html.erb +46 -0
- data/app/components/solidus_admin/users/addresses/component.rb +61 -0
- data/app/components/solidus_admin/users/addresses/component.yml +14 -0
- data/app/components/solidus_admin/users/edit/api_access/component.html.erb +49 -0
- data/app/components/solidus_admin/users/edit/api_access/component.js +9 -0
- data/app/components/solidus_admin/users/edit/api_access/component.rb +7 -0
- data/app/components/solidus_admin/users/edit/api_access/component.yml +10 -0
- data/app/components/solidus_admin/users/edit/component.html.erb +52 -0
- data/app/components/solidus_admin/users/edit/component.rb +51 -0
- data/app/components/solidus_admin/users/edit/component.yml +12 -0
- data/app/components/solidus_admin/users/index/component.rb +25 -16
- data/app/components/solidus_admin/users/index/component.yml +0 -3
- data/app/components/solidus_admin/users/items/component.html.erb +41 -0
- data/app/components/solidus_admin/users/items/component.rb +170 -0
- data/app/components/solidus_admin/users/items/component.yml +16 -0
- data/app/components/solidus_admin/users/orders/component.html.erb +42 -0
- data/app/components/solidus_admin/users/orders/component.rb +131 -0
- data/app/components/solidus_admin/users/orders/component.yml +12 -0
- data/app/components/solidus_admin/users/stats/component.html.erb +11 -0
- data/app/components/solidus_admin/users/stats/component.rb +9 -0
- data/app/components/solidus_admin/users/stats/component.yml +2 -0
- data/app/components/solidus_admin/users_and_roles/component.rb +24 -0
- data/app/components/solidus_admin/users_and_roles/component.yml +2 -0
- data/app/components/solidus_admin/zones/index/component.rb +19 -11
- data/app/controllers/solidus_admin/addresses_controller.rb +6 -1
- data/app/controllers/solidus_admin/adjustment_reasons_controller.rb +85 -10
- data/app/controllers/solidus_admin/adjustments_controller.rb +57 -0
- data/app/controllers/solidus_admin/customers_controller.rb +5 -1
- data/app/controllers/solidus_admin/orders_controller.rb +5 -1
- data/app/controllers/solidus_admin/products_controller.rb +11 -0
- data/app/controllers/solidus_admin/properties_controller.rb +1 -1
- data/app/controllers/solidus_admin/refund_reasons_controller.rb +85 -10
- data/app/controllers/solidus_admin/reimbursement_types_controller.rb +0 -5
- data/app/controllers/solidus_admin/return_reasons_controller.rb +85 -10
- data/app/controllers/solidus_admin/roles_controller.rb +118 -0
- data/app/controllers/solidus_admin/shipping_categories_controller.rb +87 -10
- data/app/controllers/solidus_admin/shipping_methods_controller.rb +0 -5
- data/app/controllers/solidus_admin/stock_items_controller.rb +6 -6
- data/app/controllers/solidus_admin/stock_locations_controller.rb +0 -5
- data/app/controllers/solidus_admin/store_credit_reasons_controller.rb +85 -10
- data/app/controllers/solidus_admin/stores_controller.rb +0 -5
- data/app/controllers/solidus_admin/tax_categories_controller.rb +89 -10
- data/app/controllers/solidus_admin/tax_rates_controller.rb +0 -5
- data/app/controllers/solidus_admin/users_controller.rb +85 -6
- data/app/controllers/solidus_admin/zones_controller.rb +0 -5
- data/app/helpers/solidus_admin/last_login_helper.rb +16 -0
- data/app/helpers/solidus_admin/permission_sets_helper.rb +32 -0
- data/app/views/layouts/solidus_admin/application.html.erb +2 -1
- data/app/views/layouts/solidus_admin/preview.html.erb +2 -0
- data/config/initializers/view_component.rb +1 -1
- data/config/locales/adjustment_reasons.en.yml +5 -1
- data/config/locales/adjustments.en.yml +10 -0
- data/config/locales/refund_reasons.en.yml +10 -0
- data/config/locales/return_reasons.en.yml +5 -1
- data/config/locales/roles.en.yml +10 -0
- data/config/locales/shipping_categories.en.yml +4 -0
- data/config/locales/store_credit_reasons.en.yml +5 -1
- data/config/locales/tax_categories.en.yml +4 -0
- data/config/locales/users.en.yml +10 -0
- data/config/routes.rb +24 -7
- data/docs/components.md +109 -0
- data/docs/{customizing_view_components.md → customizing_components.md} +2 -7
- data/docs/index_pages.md +146 -0
- data/docs/{customizing_menu_items.md → menu_items.md} +1 -1
- data/docs/stimulusjs.md +85 -0
- data/docs/{customizing_tailwindcss.md → tailwindcss.md} +27 -8
- data/lib/solidus_admin/component_registry.rb +40 -0
- data/lib/solidus_admin/configuration.rb +5 -27
- data/lib/solidus_admin/install_tailwindcss.rb +3 -1
- data/lib/solidus_admin/testing_support/admin_assets.rb +10 -0
- data/lib/solidus_admin/testing_support/component_helpers.rb +27 -0
- data/lib/solidus_admin/testing_support/dummy_app/rake_tasks.rb +60 -0
- data/lib/solidus_admin/testing_support/feature_helpers.rb +34 -0
- data/lib/solidus_admin/version.rb +1 -1
- data/solidus_admin.gemspec +7 -3
- metadata +111 -59
- data/app/components/solidus_admin/adjustment_reasons/index/component.html.erb +0 -32
- data/app/components/solidus_admin/adjustment_reasons/index/component.yml +0 -4
- data/app/components/solidus_admin/option_types/index/component.html.erb +0 -30
- data/app/components/solidus_admin/orders/index/component.html.erb +0 -35
- data/app/components/solidus_admin/payment_methods/index/component.html.erb +0 -38
- data/app/components/solidus_admin/products/index/component.html.erb +0 -34
- data/app/components/solidus_admin/promotion_categories/index/component.html.erb +0 -26
- data/app/components/solidus_admin/promotion_categories/index/component.rb +0 -57
- data/app/components/solidus_admin/promotion_categories/index/component.yml +0 -4
- data/app/components/solidus_admin/promotions/index/component.html.erb +0 -34
- data/app/components/solidus_admin/promotions/index/component.rb +0 -97
- data/app/components/solidus_admin/promotions/index/component.yml +0 -14
- data/app/components/solidus_admin/properties/index/component.html.erb +0 -34
- data/app/components/solidus_admin/properties/index/component.yml +0 -4
- data/app/components/solidus_admin/refund_reasons/index/component.html.erb +0 -31
- data/app/components/solidus_admin/refund_reasons/index/component.yml +0 -4
- data/app/components/solidus_admin/refunds_and_returns/component.html.erb +0 -26
- data/app/components/solidus_admin/reimbursement_types/index/component.html.erb +0 -22
- data/app/components/solidus_admin/reimbursement_types/index/component.yml +0 -4
- data/app/components/solidus_admin/return_reasons/index/component.html.erb +0 -31
- data/app/components/solidus_admin/return_reasons/index/component.yml +0 -4
- data/app/components/solidus_admin/shipping/component.html.erb +0 -30
- data/app/components/solidus_admin/shipping_categories/index/component.html.erb +0 -32
- data/app/components/solidus_admin/shipping_categories/index/component.yml +0 -4
- data/app/components/solidus_admin/shipping_methods/index/component.html.erb +0 -32
- data/app/components/solidus_admin/shipping_methods/index/component.yml +0 -4
- data/app/components/solidus_admin/stock_items/index/component.html.erb +0 -26
- data/app/components/solidus_admin/stock_locations/index/component.html.erb +0 -32
- data/app/components/solidus_admin/store_credit_reasons/index/component.html.erb +0 -31
- data/app/components/solidus_admin/store_credit_reasons/index/component.yml +0 -4
- data/app/components/solidus_admin/stores/index/component.html.erb +0 -34
- data/app/components/solidus_admin/stores/index/component.yml +0 -4
- data/app/components/solidus_admin/tax_categories/index/component.html.erb +0 -32
- data/app/components/solidus_admin/tax_categories/index/component.yml +0 -6
- data/app/components/solidus_admin/tax_rates/index/component.html.erb +0 -32
- data/app/components/solidus_admin/tax_rates/index/component.yml +0 -4
- data/app/components/solidus_admin/taxes/component.html.erb +0 -24
- data/app/components/solidus_admin/taxonomies/index/component.html.erb +0 -28
- data/app/components/solidus_admin/taxonomies/index/component.yml +0 -4
- data/app/components/solidus_admin/users/index/component.html.erb +0 -34
- data/app/components/solidus_admin/zones/index/component.html.erb +0 -35
- data/app/components/solidus_admin/zones/index/component.yml +0 -4
- data/app/controllers/solidus_admin/promotion_categories_controller.rb +0 -38
- data/app/controllers/solidus_admin/promotions_controller.rb +0 -46
- data/config/locales/promotion_categories.en.yml +0 -6
- data/config/locales/promotions.en.yml +0 -6
- data/config/locales/refund_reasons_.en.yml +0 -6
- /data/app/components/solidus_admin/{option_types → ui/pages}/index/component.yml +0 -0
@@ -0,0 +1,12 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class SolidusAdmin::TaxCategories::Edit::Component < SolidusAdmin::TaxCategories::Index::Component
|
4
|
+
def initialize(page:, tax_category:)
|
5
|
+
@page = page
|
6
|
+
@tax_category = tax_category
|
7
|
+
end
|
8
|
+
|
9
|
+
def form_id
|
10
|
+
dom_id(@tax_category, "#{stimulus_id}_edit_tax_category_form")
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,8 @@
|
|
1
|
+
# Add your component translations here.
|
2
|
+
# Use the translation in the example in your template with `t(".hello")`.
|
3
|
+
en:
|
4
|
+
title: "Edit Tax Category"
|
5
|
+
cancel: "Cancel"
|
6
|
+
submit: "Update Tax Category"
|
7
|
+
hints:
|
8
|
+
is_default: "When checked, this tax category will be selected by default when creating new products or variants."
|
@@ -1,28 +1,43 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
class SolidusAdmin::TaxCategories::Index::Component < SolidusAdmin::
|
4
|
-
|
3
|
+
class SolidusAdmin::TaxCategories::Index::Component < SolidusAdmin::Taxes::Component
|
4
|
+
def row_url(tax_category)
|
5
|
+
spree.edit_admin_tax_category_path(tax_category, _turbo_frame: :edit_tax_category_modal)
|
6
|
+
end
|
7
|
+
|
8
|
+
def model_class
|
9
|
+
Spree::TaxCategory
|
10
|
+
end
|
5
11
|
|
6
|
-
def
|
7
|
-
|
12
|
+
def search_url
|
13
|
+
solidus_admin.tax_categories_path
|
8
14
|
end
|
9
15
|
|
10
|
-
def
|
11
|
-
|
16
|
+
def page_actions
|
17
|
+
render component("ui/button").new(
|
18
|
+
tag: :a,
|
19
|
+
text: t('.add'),
|
20
|
+
href: solidus_admin.new_tax_category_path, data: { turbo_frame: :new_tax_category_modal },
|
21
|
+
icon: "add-line",
|
22
|
+
class: "align-self-end w-full",
|
23
|
+
)
|
12
24
|
end
|
13
25
|
|
14
|
-
def
|
15
|
-
|
26
|
+
def turbo_frames
|
27
|
+
%w[
|
28
|
+
new_tax_category_modal
|
29
|
+
edit_tax_category_modal
|
30
|
+
]
|
16
31
|
end
|
17
32
|
|
18
|
-
def
|
19
|
-
|
33
|
+
def search_key
|
34
|
+
:name_or_description_cont
|
20
35
|
end
|
21
36
|
|
22
37
|
def batch_actions
|
23
38
|
[
|
24
39
|
{
|
25
|
-
|
40
|
+
label: t('.batch_actions.delete'),
|
26
41
|
action: solidus_admin.tax_categories_path,
|
27
42
|
method: :delete,
|
28
43
|
icon: 'delete-bin-7-line',
|
@@ -30,14 +45,6 @@ class SolidusAdmin::TaxCategories::Index::Component < SolidusAdmin::BaseComponen
|
|
30
45
|
]
|
31
46
|
end
|
32
47
|
|
33
|
-
def scopes
|
34
|
-
[]
|
35
|
-
end
|
36
|
-
|
37
|
-
def filters
|
38
|
-
[]
|
39
|
-
end
|
40
|
-
|
41
48
|
def columns
|
42
49
|
[
|
43
50
|
:name,
|
@@ -47,9 +54,9 @@ class SolidusAdmin::TaxCategories::Index::Component < SolidusAdmin::BaseComponen
|
|
47
54
|
header: :is_default,
|
48
55
|
data: ->(tax_category) {
|
49
56
|
if tax_category.is_default?
|
50
|
-
component('ui/badge').
|
57
|
+
component('ui/badge').yes
|
51
58
|
else
|
52
|
-
component('ui/badge').
|
59
|
+
component('ui/badge').no
|
53
60
|
end
|
54
61
|
},
|
55
62
|
},
|
@@ -0,0 +1,28 @@
|
|
1
|
+
<%= turbo_frame_tag :new_tax_category_modal do %>
|
2
|
+
<%= render component("ui/modal").new(title: t(".title")) do |modal| %>
|
3
|
+
<%= form_for @tax_category, url: solidus_admin.tax_categories_path(page: params[:page], q: params[:q]), html: { id: form_id } do |f| %>
|
4
|
+
<div class="flex flex-col gap-6 pb-4">
|
5
|
+
<%= render component("ui/forms/field").text_field(f, :name) %>
|
6
|
+
<%= render component("ui/forms/field").text_field(f, :tax_code) %>
|
7
|
+
<%= render component("ui/forms/field").text_field(f, :description) %>
|
8
|
+
<label class="flex gap-2 items-center">
|
9
|
+
<%= render component("ui/forms/checkbox").new(
|
10
|
+
name: "#{f.object_name}[is_default]",
|
11
|
+
value: "1",
|
12
|
+
checked: f.object.is_default
|
13
|
+
) %>
|
14
|
+
<span class="font-semibold text-xs ml-2"><%= Spree::TaxCategory.human_attribute_name :is_default %></span>
|
15
|
+
<%= render component("ui/toggletip").new(text: t(".hints.is_default")) %>
|
16
|
+
</label>
|
17
|
+
</div>
|
18
|
+
<% modal.with_actions do %>
|
19
|
+
<form method="dialog">
|
20
|
+
<%= render component("ui/button").new(scheme: :secondary, text: t('.cancel')) %>
|
21
|
+
</form>
|
22
|
+
<%= render component("ui/button").new(form: form_id, type: :submit, text: t('.submit')) %>
|
23
|
+
<% end %>
|
24
|
+
<% end %>
|
25
|
+
<% end %>
|
26
|
+
<% end %>
|
27
|
+
|
28
|
+
<%= render component("tax_categories/index").new(page: @page) %>
|
@@ -0,0 +1,12 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class SolidusAdmin::TaxCategories::New::Component < SolidusAdmin::TaxCategories::Index::Component
|
4
|
+
def initialize(page:, tax_category:)
|
5
|
+
@page = page
|
6
|
+
@tax_category = tax_category
|
7
|
+
end
|
8
|
+
|
9
|
+
def form_id
|
10
|
+
dom_id(@tax_category, "#{stimulus_id}_new_tax_category_form")
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,8 @@
|
|
1
|
+
# Add your component translations here.
|
2
|
+
# Use the translation in the example in your template with `t(".hello")`.
|
3
|
+
en:
|
4
|
+
title: "New Tax Category"
|
5
|
+
cancel: "Cancel"
|
6
|
+
submit: "Add Tax Category"
|
7
|
+
hints:
|
8
|
+
is_default: "When checked, this tax category will be selected by default when creating new products or variants."
|
@@ -1,28 +1,36 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
class SolidusAdmin::TaxRates::Index::Component < SolidusAdmin::
|
4
|
-
|
3
|
+
class SolidusAdmin::TaxRates::Index::Component < SolidusAdmin::Taxes::Component
|
4
|
+
def row_url(tax_rate)
|
5
|
+
spree.edit_admin_tax_rate_path(tax_rate)
|
6
|
+
end
|
5
7
|
|
6
|
-
def
|
7
|
-
|
8
|
+
def model_class
|
9
|
+
Spree::TaxRate
|
8
10
|
end
|
9
11
|
|
10
|
-
def
|
11
|
-
|
12
|
+
def search_url
|
13
|
+
solidus_admin.tax_rates_path
|
12
14
|
end
|
13
15
|
|
14
|
-
def
|
15
|
-
|
16
|
+
def actions
|
17
|
+
render component("ui/button").new(
|
18
|
+
tag: :a,
|
19
|
+
text: t('.add'),
|
20
|
+
href: spree.new_admin_tax_rate_path,
|
21
|
+
icon: "add-line",
|
22
|
+
class: "align-self-end w-full",
|
23
|
+
)
|
16
24
|
end
|
17
25
|
|
18
|
-
def
|
19
|
-
|
26
|
+
def search_key
|
27
|
+
:name_or_description_cont
|
20
28
|
end
|
21
29
|
|
22
30
|
def batch_actions
|
23
31
|
[
|
24
32
|
{
|
25
|
-
|
33
|
+
label: t('.batch_actions.delete'),
|
26
34
|
action: solidus_admin.tax_rates_path,
|
27
35
|
method: :delete,
|
28
36
|
icon: 'delete-bin-7-line',
|
@@ -30,20 +38,16 @@ class SolidusAdmin::TaxRates::Index::Component < SolidusAdmin::BaseComponent
|
|
30
38
|
]
|
31
39
|
end
|
32
40
|
|
33
|
-
def scopes
|
34
|
-
[]
|
35
|
-
end
|
36
|
-
|
37
41
|
def filters
|
38
42
|
[
|
39
43
|
{
|
40
|
-
|
44
|
+
label: Spree::Zone.model_name.human,
|
41
45
|
attribute: :zone_id,
|
42
46
|
predicate: :eq,
|
43
47
|
options: Spree::Zone.pluck(:name, :id),
|
44
48
|
},
|
45
49
|
{
|
46
|
-
|
50
|
+
label: Spree::TaxCategory.model_name.human,
|
47
51
|
attribute: :tax_categories_id,
|
48
52
|
predicate: :in,
|
49
53
|
options: Spree::TaxCategory.pluck(:name, :id),
|
@@ -1,11 +1,11 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
class SolidusAdmin::Taxes::Component < SolidusAdmin::
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
3
|
+
class SolidusAdmin::Taxes::Component < SolidusAdmin::UI::Pages::Index::Component
|
4
|
+
def title
|
5
|
+
safe_join([
|
6
|
+
tag.div(t(".title")),
|
7
|
+
tag.div(t(".subtitle"), class: "font-normal text-sm text-gray-500"),
|
8
|
+
])
|
9
9
|
end
|
10
10
|
|
11
11
|
def tabs
|
@@ -13,12 +13,12 @@ class SolidusAdmin::Taxes::Component < SolidusAdmin::BaseComponent
|
|
13
13
|
{
|
14
14
|
text: Spree::TaxCategory.model_name.human.pluralize,
|
15
15
|
href: solidus_admin.tax_categories_path,
|
16
|
-
|
16
|
+
current: model_class == Spree::TaxCategory,
|
17
17
|
},
|
18
18
|
{
|
19
19
|
text: Spree::TaxRate.model_name.human.pluralize,
|
20
20
|
href: solidus_admin.tax_rates_path,
|
21
|
-
|
21
|
+
current: model_class == Spree::TaxRate,
|
22
22
|
},
|
23
23
|
]
|
24
24
|
end
|
@@ -1,28 +1,34 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
class SolidusAdmin::Taxonomies::Index::Component < SolidusAdmin::
|
4
|
-
|
5
|
-
|
6
|
-
def initialize(page:)
|
7
|
-
@page = page
|
3
|
+
class SolidusAdmin::Taxonomies::Index::Component < SolidusAdmin::UI::Pages::Index::Component
|
4
|
+
def model_class
|
5
|
+
Spree::Taxonomy
|
8
6
|
end
|
9
7
|
|
10
|
-
def
|
11
|
-
|
8
|
+
def row_url(taxonomy)
|
9
|
+
spree.edit_admin_taxonomy_path(taxonomy)
|
12
10
|
end
|
13
11
|
|
14
|
-
def
|
15
|
-
|
12
|
+
def sortable_options
|
13
|
+
{
|
14
|
+
url: ->(taxonomy) { solidus_admin.move_taxonomy_path(taxonomy) },
|
15
|
+
param: 'position',
|
16
|
+
}
|
16
17
|
end
|
17
18
|
|
18
|
-
def
|
19
|
-
|
19
|
+
def page_actions
|
20
|
+
render component("ui/button").new(
|
21
|
+
tag: :a,
|
22
|
+
text: t('.add'),
|
23
|
+
href: spree.new_admin_taxonomy_path,
|
24
|
+
icon: "add-line",
|
25
|
+
)
|
20
26
|
end
|
21
27
|
|
22
28
|
def batch_actions
|
23
29
|
[
|
24
30
|
{
|
25
|
-
|
31
|
+
label: t('.batch_actions.delete'),
|
26
32
|
action: solidus_admin.taxonomies_path,
|
27
33
|
method: :delete,
|
28
34
|
icon: 'delete-bin-7-line',
|
@@ -78,7 +78,7 @@ class SolidusAdmin::UI::Button::Component < SolidusAdmin::BaseComponent
|
|
78
78
|
|
79
79
|
@attributes[:class] = [
|
80
80
|
'justify-start items-center justify-center gap-1 inline-flex rounded',
|
81
|
-
'focus:ring focus:ring-gray-300 focus:ring-0.5 focus:
|
81
|
+
'focus:ring focus:ring-gray-300 focus:ring-0.5 focus:ring-offset-0 [&:focus-visible]:outline-none',
|
82
82
|
SIZES.fetch(size.to_sym),
|
83
83
|
(TEXT_PADDINGS.fetch(size.to_sym) if @text),
|
84
84
|
SCHEMES.fetch(scheme.to_sym),
|
@@ -0,0 +1,29 @@
|
|
1
|
+
<% if @layout == :default && @options.present? %>
|
2
|
+
<span class="p-2 flex hover:bg-gray-50 rounded-md">
|
3
|
+
<span class="w-1/2"><%= @row_title %></span>
|
4
|
+
<span class="w-1/2 text-right">
|
5
|
+
<% @options.each do |option| %>
|
6
|
+
<label class="px-2 cursor-pointer">
|
7
|
+
<%= @form.check_box(@method.to_s, { checked: @form.object.try(@method.to_sym)&.include?(option[:id]), multiple: true }, option[:id], nil)%>
|
8
|
+
<span class="capitalize"><%= option[:label] %></span>
|
9
|
+
</label>
|
10
|
+
<% end %>
|
11
|
+
</span>
|
12
|
+
</span>
|
13
|
+
<% end %>
|
14
|
+
|
15
|
+
<% if @layout == :subsection && @options.present? %>
|
16
|
+
<div class="hover:bg-gray-50 rounded-md">
|
17
|
+
<div class="font-semibold px-2 py-2 mt-2 mb-1"><%= @row_title %></div>
|
18
|
+
<div class="px-4">
|
19
|
+
<% @options.each do |option| %>
|
20
|
+
<div class="py-1">
|
21
|
+
<label class="cursor-pointer">
|
22
|
+
<%= @form.check_box(@method.to_s, { checked: @form.object.try(@method.to_sym)&.include?(option[:id]), multiple: true }, option[:id], nil)%>
|
23
|
+
<span class="capitalize"><%= option[:label] %></span>
|
24
|
+
</label>
|
25
|
+
</div>
|
26
|
+
<% end %>
|
27
|
+
</div>
|
28
|
+
</div>
|
29
|
+
<% end %>
|
@@ -0,0 +1,11 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class SolidusAdmin::UI::CheckboxRow::Component < SolidusAdmin::BaseComponent
|
4
|
+
def initialize(options:, row_title:, form:, method:, layout: :default)
|
5
|
+
@options = options
|
6
|
+
@row_title = row_title
|
7
|
+
@form = form
|
8
|
+
@method = method
|
9
|
+
@layout = layout
|
10
|
+
end
|
11
|
+
end
|
@@ -21,15 +21,33 @@
|
|
21
21
|
"data-action": "change->#{stimulus_id}#loadStates"
|
22
22
|
) %>
|
23
23
|
|
24
|
-
<%=
|
25
|
-
|
26
|
-
:
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
24
|
+
<%= content_tag(:div,
|
25
|
+
data: { "#{stimulus_id}-target": "stateNameWrapper" },
|
26
|
+
class: (@address.country&.states&.empty? ? "flex flex-col gap-2 w-full" : "hidden flex flex-col gap-2 w-full")
|
27
|
+
) do %>
|
28
|
+
<%= render component("ui/forms/field").text_field(
|
29
|
+
@name,
|
30
|
+
:state_name,
|
31
|
+
object: @address,
|
32
|
+
value: @address.try(:state_name),
|
33
|
+
"data-#{stimulus_id}-target": "stateName"
|
34
|
+
) %>
|
35
|
+
<% end %>
|
36
|
+
<input autocomplete="off" type="hidden" name=<%= "#{@name}[state_id]" %>>
|
37
|
+
|
38
|
+
<%= content_tag(:div,
|
39
|
+
data: { "#{stimulus_id}-target": "stateWrapper" },
|
40
|
+
class: (@address.country&.states&.empty? ? "hidden flex flex-col gap-2 w-full" : "flex flex-col gap-2 w-full")
|
41
|
+
) do %>
|
42
|
+
<%= render component("ui/forms/field").select(
|
43
|
+
@name,
|
44
|
+
:state_id,
|
45
|
+
state_options,
|
46
|
+
object: @address,
|
47
|
+
value: @address.try(:state_id),
|
48
|
+
"data-#{stimulus_id}-target": "state"
|
49
|
+
) %>
|
50
|
+
<% end %>
|
33
51
|
|
34
52
|
<%= render component("ui/forms/field").text_field(@name, :phone, object: @address) %>
|
35
53
|
</div>
|
@@ -1,7 +1,7 @@
|
|
1
1
|
import { Controller } from '@hotwired/stimulus'
|
2
2
|
|
3
3
|
export default class extends Controller {
|
4
|
-
static targets = ["country", "state"]
|
4
|
+
static targets = ["country", "state", "stateName", "stateWrapper", "stateNameWrapper"]
|
5
5
|
|
6
6
|
loadStates() {
|
7
7
|
const countryId = this.countryTarget.value
|
@@ -13,22 +13,47 @@ export default class extends Controller {
|
|
13
13
|
})
|
14
14
|
}
|
15
15
|
|
16
|
-
updateStateOptions(
|
16
|
+
updateStateOptions(states) {
|
17
|
+
if (states.length === 0) {
|
18
|
+
// Show state name text input if no states to choose from.
|
19
|
+
this.toggleStateFields(false)
|
20
|
+
} else {
|
21
|
+
// Show state select dropdown.
|
22
|
+
this.toggleStateFields(true)
|
23
|
+
this.populateStateSelect(states)
|
24
|
+
}
|
25
|
+
}
|
26
|
+
|
27
|
+
toggleStateFields(showSelect) {
|
28
|
+
const stateWrapper = this.stateWrapperTarget
|
29
|
+
const stateNameWrapper = this.stateNameWrapperTarget
|
17
30
|
const stateSelect = this.stateTarget
|
31
|
+
const stateName = this.stateNameTarget
|
18
32
|
|
19
|
-
stateSelect.innerHTML = ""
|
20
33
|
|
21
|
-
if (
|
22
|
-
|
23
|
-
} else {
|
34
|
+
if (showSelect) {
|
35
|
+
// Show state select dropdown.
|
24
36
|
stateSelect.disabled = false
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
37
|
+
stateName.value = ""
|
38
|
+
stateWrapper.classList.remove('hidden')
|
39
|
+
stateNameWrapper.classList.add('hidden')
|
40
|
+
} else {
|
41
|
+
// Show state name text input if no states to choose from.
|
42
|
+
stateSelect.disabled = true
|
43
|
+
stateWrapper.classList.add("hidden")
|
44
|
+
stateNameWrapper.classList.remove("hidden")
|
32
45
|
}
|
33
46
|
}
|
47
|
+
|
48
|
+
populateStateSelect(states) {
|
49
|
+
const stateSelect = this.stateTarget
|
50
|
+
stateSelect.innerHTML = ""
|
51
|
+
|
52
|
+
states.forEach((state) => {
|
53
|
+
const option = document.createElement("option")
|
54
|
+
option.value = state.id
|
55
|
+
option.innerText = state.name
|
56
|
+
stateSelect.appendChild(option)
|
57
|
+
})
|
58
|
+
}
|
34
59
|
}
|
@@ -23,8 +23,7 @@
|
|
23
23
|
) %>
|
24
24
|
</div>
|
25
25
|
|
26
|
-
<
|
27
|
-
<summary class="hidden"></summary>
|
26
|
+
<div class="px-6 relative overflow-visible">
|
28
27
|
<div
|
29
28
|
class="
|
30
29
|
absolute
|
@@ -47,6 +46,6 @@
|
|
47
46
|
data-<%= stimulus_id %>-target="results"
|
48
47
|
>
|
49
48
|
</div>
|
50
|
-
</
|
49
|
+
</div>
|
51
50
|
</div>
|
52
51
|
</div>
|
@@ -95,7 +95,7 @@ export default class extends Controller {
|
|
95
95
|
}
|
96
96
|
|
97
97
|
if (this.openResults && resultsHtml && this.query) {
|
98
|
-
if (
|
98
|
+
if (this.resultsTarget.parentNode.classList.contains("hidden")) this.selectedIndex = 0
|
99
99
|
|
100
100
|
for (const result of this.resultTargets) {
|
101
101
|
if (result === this.selectedResult) {
|
@@ -108,9 +108,9 @@ export default class extends Controller {
|
|
108
108
|
result.removeAttribute("aria-selected")
|
109
109
|
}
|
110
110
|
}
|
111
|
-
this.resultsTarget.parentNode.
|
111
|
+
this.resultsTarget.parentNode.classList.remove("hidden")
|
112
112
|
} else {
|
113
|
-
this.resultsTarget.parentNode.
|
113
|
+
this.resultsTarget.parentNode.classList.add("hidden")
|
114
114
|
}
|
115
115
|
}
|
116
116
|
}
|
@@ -14,13 +14,13 @@
|
|
14
14
|
<h3 class="text-xl font-semibold text-gray-900">
|
15
15
|
<%= @title %>
|
16
16
|
</h3>
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
17
|
+
<form method="dialog">
|
18
|
+
<%= render component('ui/button').new(
|
19
|
+
icon: 'close-line',
|
20
|
+
scheme: :ghost,
|
21
|
+
title: t('.close'),
|
22
|
+
) %>
|
23
|
+
</form>
|
24
24
|
</header>
|
25
25
|
|
26
26
|
<div class="p-4 overflow-auto">
|
@@ -3,7 +3,7 @@
|
|
3
3
|
class SolidusAdmin::UI::Modal::Component < SolidusAdmin::BaseComponent
|
4
4
|
renders_one :actions
|
5
5
|
|
6
|
-
def initialize(title:, close_path: nil, open:
|
6
|
+
def initialize(title:, close_path: nil, open: false, **attributes)
|
7
7
|
@title = title
|
8
8
|
@close_path = close_path
|
9
9
|
@attributes = attributes
|
@@ -0,0 +1,44 @@
|
|
1
|
+
<%= page do %>
|
2
|
+
<% if @tabs %>
|
3
|
+
<%= page_header do %>
|
4
|
+
<%= render_title %>
|
5
|
+
<% end %>
|
6
|
+
|
7
|
+
<%= page_header do %>
|
8
|
+
<% rendered_tabs = capture do %>
|
9
|
+
<% @tabs.each do %>
|
10
|
+
<%= render(component("ui/button").new(tag: :a, scheme: :ghost, text: _1.text, 'aria-current': _1.current, href: _1.href)) %>
|
11
|
+
<% end %>
|
12
|
+
<% end %>
|
13
|
+
<%= page_header_title rendered_tabs %>
|
14
|
+
<%= page_header_actions do %>
|
15
|
+
<%= page_actions %>
|
16
|
+
<% end %>
|
17
|
+
<% end %>
|
18
|
+
|
19
|
+
<% else %>
|
20
|
+
<%= page_header do %>
|
21
|
+
<%= render_title %>
|
22
|
+
|
23
|
+
<%= page_header_actions do %>
|
24
|
+
<%= page_actions %>
|
25
|
+
<% end %>
|
26
|
+
<% end %>
|
27
|
+
<% end %>
|
28
|
+
|
29
|
+
<%= page_with_sidebar do %>
|
30
|
+
<%= page_with_sidebar_main do %>
|
31
|
+
<%= render_table %>
|
32
|
+
<% end %>
|
33
|
+
|
34
|
+
<% if sidebar %>
|
35
|
+
<%= page_with_sidebar_aside do %>
|
36
|
+
<%= sidebar %>
|
37
|
+
<% end %>
|
38
|
+
<% end %>
|
39
|
+
<% end %>
|
40
|
+
|
41
|
+
<% turbo_frames.each do |frame| %>
|
42
|
+
<%= turbo_frame_tag frame %>
|
43
|
+
<% end %>
|
44
|
+
<% end %>
|