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,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 Adjustment Reason"
|
5
|
+
cancel: "Cancel"
|
6
|
+
submit: "Update Adjustment Reason"
|
7
|
+
hints:
|
8
|
+
active: "When checked, this adjustment reason will be available for selection when adding adjustments to orders."
|
@@ -1,28 +1,43 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
class SolidusAdmin::AdjustmentReasons::Index::Component < SolidusAdmin::
|
4
|
-
|
3
|
+
class SolidusAdmin::AdjustmentReasons::Index::Component < SolidusAdmin::RefundsAndReturns::Component
|
4
|
+
def model_class
|
5
|
+
Spree::AdjustmentReason
|
6
|
+
end
|
7
|
+
|
8
|
+
def search_url
|
9
|
+
solidus_admin.adjustment_reasons_path
|
10
|
+
end
|
5
11
|
|
6
|
-
def
|
7
|
-
|
12
|
+
def search_key
|
13
|
+
:name_or_code_cont
|
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_adjustment_reason_path, data: { turbo_frame: :new_adjustment_reason_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_adjustment_reason_modal
|
29
|
+
edit_adjustment_reason_modal
|
30
|
+
]
|
16
31
|
end
|
17
32
|
|
18
|
-
def
|
19
|
-
|
33
|
+
def row_url(adjustment_reason)
|
34
|
+
spree.edit_admin_adjustment_reason_path(adjustment_reason, _turbo_frame: :edit_adjustment_reason_modal)
|
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.adjustment_reasons_path,
|
27
42
|
method: :delete,
|
28
43
|
icon: 'delete-bin-7-line',
|
@@ -30,14 +45,6 @@ class SolidusAdmin::AdjustmentReasons::Index::Component < SolidusAdmin::BaseComp
|
|
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,
|
@@ -0,0 +1,28 @@
|
|
1
|
+
<%= turbo_frame_tag :new_adjustment_reason_modal do %>
|
2
|
+
<%= render component("ui/modal").new(title: t(".title")) do |modal| %>
|
3
|
+
<%= form_for @adjustment_reason, url: solidus_admin.adjustment_reasons_path, 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, class: "required") %>
|
6
|
+
<%= render component("ui/forms/field").text_field(f, :code, class: "required") %>
|
7
|
+
<label class="flex gap-2 items-center">
|
8
|
+
<%= hidden_field_tag "#{f.object_name}[active]", "0" %>
|
9
|
+
<%= render component("ui/forms/checkbox").new(
|
10
|
+
name: "#{f.object_name}[active]",
|
11
|
+
value: "1",
|
12
|
+
checked: f.object.active
|
13
|
+
) %>
|
14
|
+
<span class="font-semibold text-xs ml-2"><%= Spree::AdjustmentReason.human_attribute_name :active %></span>
|
15
|
+
<%= render component("ui/toggletip").new(text: t(".hints.active")) %>
|
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("adjustment_reasons/index").new(page: @page) %>
|
@@ -0,0 +1,12 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class SolidusAdmin::AdjustmentReasons::New::Component < SolidusAdmin::BaseComponent
|
4
|
+
def initialize(page:, adjustment_reason:)
|
5
|
+
@page = page
|
6
|
+
@adjustment_reason = adjustment_reason
|
7
|
+
end
|
8
|
+
|
9
|
+
def form_id
|
10
|
+
dom_id(@adjustment_reason, "#{stimulus_id}_new_adjustment_reason_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 Adjustment Reason"
|
5
|
+
cancel: "Cancel"
|
6
|
+
submit: "Add Adjustment Reason"
|
7
|
+
hints:
|
8
|
+
active: "When checked, this adjustment reason will be available for selection when adding adjustments to orders."
|
@@ -1,5 +1,8 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require "view_component/version"
|
4
|
+
require "view_component/translatable"
|
5
|
+
|
3
6
|
module SolidusAdmin
|
4
7
|
# BaseComponent is the base class for all components in Solidus Admin.
|
5
8
|
class BaseComponent < ViewComponent::Base
|
@@ -15,7 +18,7 @@ module SolidusAdmin
|
|
15
18
|
|
16
19
|
logger.debug " [#{self.class}] Missing translation: #{keys.join('.')}"
|
17
20
|
|
18
|
-
if options[:locale] != :en
|
21
|
+
if (options[:locale] || I18n.default_locale) != :en
|
19
22
|
t(key, **options, locale: :en)
|
20
23
|
else
|
21
24
|
"translation missing: #{keys.join('.')}"
|
@@ -1,14 +1,28 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
class SolidusAdmin::OptionTypes::Index::Component < SolidusAdmin::
|
4
|
-
|
3
|
+
class SolidusAdmin::OptionTypes::Index::Component < SolidusAdmin::UI::Pages::Index::Component
|
4
|
+
def model_class
|
5
|
+
Spree::OptionType
|
6
|
+
end
|
7
|
+
|
8
|
+
def row_url(option_type)
|
9
|
+
spree.edit_admin_option_type_path(option_type)
|
10
|
+
end
|
5
11
|
|
6
|
-
def
|
7
|
-
|
12
|
+
def sortable_options
|
13
|
+
{
|
14
|
+
url: ->(option_type) { solidus_admin.move_option_type_path(option_type) },
|
15
|
+
param: 'position',
|
16
|
+
}
|
8
17
|
end
|
9
18
|
|
10
|
-
def
|
11
|
-
|
19
|
+
def page_actions
|
20
|
+
render component("ui/button").new(
|
21
|
+
tag: :a,
|
22
|
+
text: t('.add'),
|
23
|
+
href: spree.new_admin_option_type_path,
|
24
|
+
icon: "add-line",
|
25
|
+
)
|
12
26
|
end
|
13
27
|
|
14
28
|
def prev_page_path
|
@@ -22,7 +36,7 @@ class SolidusAdmin::OptionTypes::Index::Component < SolidusAdmin::BaseComponent
|
|
22
36
|
def batch_actions
|
23
37
|
[
|
24
38
|
{
|
25
|
-
|
39
|
+
label: t('.batch_actions.delete'),
|
26
40
|
action: solidus_admin.option_types_path,
|
27
41
|
method: :delete,
|
28
42
|
icon: 'delete-bin-7-line',
|
@@ -1,28 +1,33 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
class SolidusAdmin::Orders::Index::Component < SolidusAdmin::
|
4
|
-
|
5
|
-
|
6
|
-
def initialize(page:)
|
7
|
-
@page = page
|
3
|
+
class SolidusAdmin::Orders::Index::Component < SolidusAdmin::UI::Pages::Index::Component
|
4
|
+
def model_class
|
5
|
+
Spree::Order
|
8
6
|
end
|
9
7
|
|
10
|
-
|
8
|
+
def search_key
|
9
|
+
:number_or_shipments_number_or_bill_address_name_or_email_cont
|
10
|
+
end
|
11
11
|
|
12
|
-
def
|
13
|
-
|
12
|
+
def search_url
|
13
|
+
solidus_admin.orders_path(scope: params[:scope])
|
14
14
|
end
|
15
15
|
|
16
|
-
def
|
17
|
-
|
16
|
+
def row_url(order)
|
17
|
+
spree.edit_admin_order_path(order)
|
18
18
|
end
|
19
19
|
|
20
|
-
def
|
21
|
-
|
20
|
+
def row_fade(order)
|
21
|
+
order.paid? && order.shipped?
|
22
22
|
end
|
23
23
|
|
24
|
-
def
|
25
|
-
|
24
|
+
def page_actions
|
25
|
+
render component("ui/button").new(
|
26
|
+
tag: :a,
|
27
|
+
text: t('.add'),
|
28
|
+
href: spree.new_admin_order_path,
|
29
|
+
icon: "add-line",
|
30
|
+
)
|
26
31
|
end
|
27
32
|
|
28
33
|
def scopes
|
@@ -38,7 +43,7 @@ class SolidusAdmin::Orders::Index::Component < SolidusAdmin::BaseComponent
|
|
38
43
|
def filters
|
39
44
|
[
|
40
45
|
{
|
41
|
-
|
46
|
+
label: t('.filters.status'),
|
42
47
|
combinator: 'or',
|
43
48
|
attribute: "state",
|
44
49
|
predicate: "eq",
|
@@ -50,7 +55,7 @@ class SolidusAdmin::Orders::Index::Component < SolidusAdmin::BaseComponent
|
|
50
55
|
end
|
51
56
|
},
|
52
57
|
{
|
53
|
-
|
58
|
+
label: t('.filters.shipment_state'),
|
54
59
|
combinator: 'or',
|
55
60
|
attribute: "shipment_state",
|
56
61
|
predicate: "eq",
|
@@ -62,7 +67,7 @@ class SolidusAdmin::Orders::Index::Component < SolidusAdmin::BaseComponent
|
|
62
67
|
end
|
63
68
|
},
|
64
69
|
{
|
65
|
-
|
70
|
+
label: t('.filters.payment_state'),
|
66
71
|
combinator: 'or',
|
67
72
|
attribute: "payment_state",
|
68
73
|
predicate: "eq",
|
@@ -74,12 +79,12 @@ class SolidusAdmin::Orders::Index::Component < SolidusAdmin::BaseComponent
|
|
74
79
|
end
|
75
80
|
},
|
76
81
|
{
|
77
|
-
|
82
|
+
label: t('.filters.store'),
|
78
83
|
combinator: 'or',
|
79
|
-
attribute: "
|
80
|
-
predicate: "
|
81
|
-
options: Spree::
|
82
|
-
}
|
84
|
+
attribute: "store_id",
|
85
|
+
predicate: "eq",
|
86
|
+
options: Spree::Store.all.pluck(:name, :id)
|
87
|
+
}
|
83
88
|
]
|
84
89
|
end
|
85
90
|
|
@@ -100,7 +105,7 @@ class SolidusAdmin::Orders::Index::Component < SolidusAdmin::BaseComponent
|
|
100
105
|
{
|
101
106
|
header: :order,
|
102
107
|
data: ->(order) do
|
103
|
-
if !row_fade
|
108
|
+
if !row_fade(order)
|
104
109
|
content_tag :div, order.number, class: 'font-semibold'
|
105
110
|
else
|
106
111
|
content_tag :div, order.number
|
@@ -1,67 +1,69 @@
|
|
1
1
|
<div class="<%= stimulus_id %>" data-controller="<%= stimulus_id %>">
|
2
|
-
<%=
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
</h2>
|
2
|
+
<%= turbo_frame_tag "edit_order_#{params[:type]}_address_modal" do %>
|
3
|
+
<%= render component("ui/modal").new(title: t(".title.#{@type}")) do |modal| %>
|
4
|
+
<%= form_for @order, url: solidus_admin.send("order_#{@type}_address_path", @order), html: { id: form_id } do |form| %>
|
5
|
+
<div class="w-full flex flex-col mb-4">
|
6
|
+
<div class="flex justify-between items-center mb-4 relative">
|
7
|
+
<h2 class="text-sm font-semibold">
|
8
|
+
<%= t(".subtitle.#{@type}") %>
|
9
|
+
</h2>
|
11
10
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
11
|
+
<% if @addresses.present? %>
|
12
|
+
<%= render component('ui/dropdown').new(
|
13
|
+
text: t(".select_address"),
|
14
|
+
"data-#{stimulus_id}-target": "addresses",
|
15
|
+
class: "max-h-[26rem] overflow-y-auto"
|
16
|
+
) do %>
|
17
|
+
<% @addresses.each do |address| %>
|
18
|
+
<%= tag.a(
|
19
|
+
format_address(address),
|
20
|
+
href: solidus_admin.send("order_#{@type}_address_path", @order, address_id: address.id),
|
21
|
+
'data-turbo-frame': address_frame_id,
|
22
|
+
'data-action': "#{component('ui/dropdown').stimulus_id}#close",
|
23
|
+
) %>
|
24
|
+
<% end %>
|
25
25
|
<% end %>
|
26
26
|
<% end %>
|
27
|
-
|
28
|
-
</div>
|
27
|
+
</div>
|
29
28
|
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
29
|
+
<div class="w-full flex gap-4">
|
30
|
+
<%= turbo_frame_tag address_frame_id do %>
|
31
|
+
<%= render component('ui/forms/address').new(address: @address, name: "order[#{@type}_address_attributes]") %>
|
32
|
+
<% end %>
|
33
|
+
</div>
|
35
34
|
|
36
|
-
|
37
|
-
|
35
|
+
<label class="flex gap-2 items-center">
|
36
|
+
<%= form.hidden_field use_attribute, value: '0', id: false %>
|
38
37
|
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
38
|
+
<%= render component("ui/forms/checkbox").new(
|
39
|
+
name: "#{form.object_name}[#{use_attribute}]",
|
40
|
+
checked: @address == (@type == 'ship' ? @order.bill_address : @order.ship_address),
|
41
|
+
value: '1'
|
42
|
+
) %>
|
44
43
|
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
44
|
+
<span class="font-normal text-xs">
|
45
|
+
<%= t(".use_this_address.#{@type}") %>
|
46
|
+
</span>
|
47
|
+
</label>
|
48
|
+
</div>
|
49
|
+
<% end %>
|
51
50
|
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
51
|
+
<% modal.with_actions do %>
|
52
|
+
<form method="dialog">
|
53
|
+
<%= render component("ui/button").new(
|
54
|
+
scheme: :secondary,
|
55
|
+
text: t(".cancel"),
|
56
|
+
) %>
|
57
|
+
</form>
|
59
58
|
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
59
|
+
<%= render component("ui/button").new(
|
60
|
+
tag: :button,
|
61
|
+
text: t(".save"),
|
62
|
+
form: form_id
|
63
|
+
) %>
|
64
|
+
<% end %>
|
65
65
|
<% end %>
|
66
66
|
<% end %>
|
67
|
+
|
68
|
+
<%= render component("orders/show").new(order: @order) %>
|
67
69
|
</div>
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class SolidusAdmin::Orders::Show::Adjustments::Index::Adjustable::Component < SolidusAdmin::BaseComponent
|
4
|
+
attr_reader :adjustment, :adjustable, :model_name
|
5
|
+
|
6
|
+
def initialize(adjustment)
|
7
|
+
@adjustment = adjustment
|
8
|
+
@adjustable = adjustment.adjustable
|
9
|
+
@model_name = adjustable&.model_name&.human
|
10
|
+
end
|
11
|
+
|
12
|
+
def call
|
13
|
+
render component("ui/thumbnail_with_caption").new(caption: caption, detail: detail) do
|
14
|
+
thumbnail
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def thumbnail
|
19
|
+
render(component("ui/thumbnail").for(adjustment.adjustable, class: "basis-10"))
|
20
|
+
end
|
21
|
+
|
22
|
+
def caption
|
23
|
+
end
|
24
|
+
|
25
|
+
def detail
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class SolidusAdmin::Orders::Show::Adjustments::Index::Adjustable::SpreeLineItem::Component < SolidusAdmin::Orders::Show::Adjustments::Index::Adjustable::Component
|
4
|
+
delegate :variant, to: :adjustable
|
5
|
+
|
6
|
+
def caption
|
7
|
+
options_text = variant.options_text.presence
|
8
|
+
options_text || variant.sku
|
9
|
+
end
|
10
|
+
|
11
|
+
def detail
|
12
|
+
link_to(variant.product.name, solidus_admin.product_path(variant.product), class: "body-link")
|
13
|
+
end
|
14
|
+
end
|
data/app/components/solidus_admin/orders/show/adjustments/index/adjustable/spree_order/component.rb
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class SolidusAdmin::Orders::Show::Adjustments::Index::Adjustable::SpreeOrder::Component < SolidusAdmin::Orders::Show::Adjustments::Index::Adjustable::Component
|
4
|
+
def caption
|
5
|
+
"#{Spree::Order.model_name.human} ##{adjustable.number}"
|
6
|
+
end
|
7
|
+
|
8
|
+
def detail
|
9
|
+
adjustable.display_total
|
10
|
+
end
|
11
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class SolidusAdmin::Orders::Show::Adjustments::Index::Adjustable::SpreeShipment::Component < SolidusAdmin::Orders::Show::Adjustments::Index::Adjustable::Component
|
4
|
+
def caption
|
5
|
+
"#{t('spree.shipment')} ##{adjustable.number}"
|
6
|
+
end
|
7
|
+
|
8
|
+
def detail
|
9
|
+
link_to(
|
10
|
+
adjustable.shipping_method.name,
|
11
|
+
spree.edit_admin_shipping_method_path(adjustable.shipping_method),
|
12
|
+
class: "body-link"
|
13
|
+
)
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,147 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class SolidusAdmin::Orders::Show::Adjustments::Index::Component < SolidusAdmin::UI::Pages::Index::Component
|
4
|
+
def model_class
|
5
|
+
Spree::Adjustment
|
6
|
+
end
|
7
|
+
|
8
|
+
def back_url
|
9
|
+
solidus_admin.order_path(@order)
|
10
|
+
end
|
11
|
+
|
12
|
+
def title
|
13
|
+
t(".title", number: @order.number)
|
14
|
+
end
|
15
|
+
|
16
|
+
NBSP = " ".html_safe
|
17
|
+
|
18
|
+
def initialize(order:, adjustments:)
|
19
|
+
@order = order
|
20
|
+
@adjustments = adjustments
|
21
|
+
@page = GearedPagination::Recordset.new(adjustments, per_page: adjustments.size).page(1)
|
22
|
+
end
|
23
|
+
|
24
|
+
def batch_actions
|
25
|
+
[
|
26
|
+
{
|
27
|
+
label: t(".actions.lock"),
|
28
|
+
action: solidus_admin.lock_order_adjustments_path(@order),
|
29
|
+
method: :put,
|
30
|
+
icon: "lock-line"
|
31
|
+
},
|
32
|
+
{
|
33
|
+
label: t(".actions.unlock"),
|
34
|
+
action: solidus_admin.unlock_order_adjustments_path(@order),
|
35
|
+
method: :put,
|
36
|
+
icon: "lock-unlock-line"
|
37
|
+
},
|
38
|
+
{
|
39
|
+
label: t(".actions.delete"),
|
40
|
+
action: spree.admin_order_adjustment_path(@order, '[]'),
|
41
|
+
method: :delete,
|
42
|
+
icon: "delete-bin-7-line"
|
43
|
+
},
|
44
|
+
]
|
45
|
+
end
|
46
|
+
|
47
|
+
def search_key
|
48
|
+
:label_cont
|
49
|
+
end
|
50
|
+
|
51
|
+
def search_url
|
52
|
+
solidus_admin.order_adjustments_path(@order)
|
53
|
+
end
|
54
|
+
|
55
|
+
def columns
|
56
|
+
[
|
57
|
+
{
|
58
|
+
header: :state,
|
59
|
+
wrap: true,
|
60
|
+
col: { class: 'w-[calc(5rem+2rem+2.5rem+1px)]' },
|
61
|
+
data: ->(adjustment) {
|
62
|
+
if adjustment.finalized?
|
63
|
+
icon = 'lock-fill'
|
64
|
+
title = t(".state.locked")
|
65
|
+
else
|
66
|
+
icon = 'lock-unlock-line'
|
67
|
+
title = t(".state.unlocked")
|
68
|
+
end
|
69
|
+
icon_tag(icon, class: "w-5 h-5 align-middle") + tag.span(title)
|
70
|
+
}
|
71
|
+
},
|
72
|
+
{
|
73
|
+
header: :adjustable,
|
74
|
+
col: { class: 'w-56' },
|
75
|
+
data: ->(adjustment) {
|
76
|
+
render_thumbnail_with_caption(adjustment, :adjustable)
|
77
|
+
}
|
78
|
+
},
|
79
|
+
{
|
80
|
+
header: :source,
|
81
|
+
col: { class: "w-56" },
|
82
|
+
data: ->(adjustment) {
|
83
|
+
render_thumbnail_with_caption(adjustment, :source)
|
84
|
+
}
|
85
|
+
},
|
86
|
+
{
|
87
|
+
header: :amount,
|
88
|
+
col: { class: 'w-24' },
|
89
|
+
data: ->(adjustment) { tag.span adjustment.display_amount.to_html, class: "grow text-right whitespace-nowrap" }
|
90
|
+
},
|
91
|
+
{
|
92
|
+
header: tag.span(t(".actions.title"), class: 'sr-only'),
|
93
|
+
col: { class: 'w-24' },
|
94
|
+
wrap: false,
|
95
|
+
data: ->(adjustment) do
|
96
|
+
actions = []
|
97
|
+
|
98
|
+
unless adjustment.source
|
99
|
+
actions << link_to(
|
100
|
+
t(".actions.edit"),
|
101
|
+
spree.edit_admin_order_adjustment_path(@order, adjustment),
|
102
|
+
class: 'body-link',
|
103
|
+
)
|
104
|
+
end
|
105
|
+
|
106
|
+
if adjustment.finalized?
|
107
|
+
actions << link_to(
|
108
|
+
t(".actions.unlock"),
|
109
|
+
solidus_admin.unlock_order_adjustments_path(@order, id: adjustment),
|
110
|
+
"data-turbo-method": :put,
|
111
|
+
"data-turbo-confirm": t('.confirm'),
|
112
|
+
class: 'body-link',
|
113
|
+
)
|
114
|
+
else
|
115
|
+
actions << link_to(
|
116
|
+
t(".actions.lock"),
|
117
|
+
solidus_admin.lock_order_adjustments_path(@order, id: adjustment),
|
118
|
+
"data-turbo-method": :put,
|
119
|
+
"data-turbo-confirm": t('.confirm'),
|
120
|
+
class: 'body-link',
|
121
|
+
)
|
122
|
+
actions << link_to(
|
123
|
+
t(".actions.delete"),
|
124
|
+
spree.admin_order_adjustment_path(@order, adjustment),
|
125
|
+
"data-turbo-method": :delete,
|
126
|
+
"data-turbo-confirm": t('.confirm'),
|
127
|
+
class: 'body-link !text-red-500',
|
128
|
+
)
|
129
|
+
end
|
130
|
+
|
131
|
+
render component('ui/dropdown').new(
|
132
|
+
direction: :right,
|
133
|
+
class: 'relative w-fit m-auto',
|
134
|
+
).with_content(safe_join(actions))
|
135
|
+
end
|
136
|
+
},
|
137
|
+
]
|
138
|
+
end
|
139
|
+
|
140
|
+
private
|
141
|
+
|
142
|
+
def render_thumbnail_with_caption(adjustment, role)
|
143
|
+
component_name = adjustment.send(role).class.base_class.name.delete("::").underscore if adjustment.send(role)
|
144
|
+
component_key = ["orders/show/adjustments/index/#{role}", component_name].compact.join("/")
|
145
|
+
render component(component_key).new(adjustment)
|
146
|
+
end
|
147
|
+
end
|