solidus_admin 0.0.2 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.eslintrc.json +7 -0
- data/README.md +2 -2
- data/Rakefile +26 -0
- data/app/assets/builds/.keep +0 -0
- data/app/assets/builds/solidus_admin/tailwind.css +2799 -0
- data/app/assets/config/solidus_admin_manifest.js +1 -0
- data/app/assets/stylesheets/solidus_admin/application.tailwind.css +4 -0
- data/app/assets/stylesheets/solidus_admin/dark.css +12 -0
- data/app/assets/stylesheets/solidus_admin/dimmed.css +11 -0
- data/app/components/solidus_admin/adjustment_reasons/index/component.rb +43 -0
- data/app/components/solidus_admin/base_component.rb +29 -1
- data/app/components/solidus_admin/layout/feedback/component.html.erb +15 -0
- data/app/components/solidus_admin/layout/feedback/component.rb +4 -0
- data/app/components/solidus_admin/layout/feedback/component.yml +3 -0
- data/app/components/solidus_admin/layout/navigation/account/component.html.erb +74 -0
- data/app/components/solidus_admin/layout/navigation/account/component.js +16 -0
- data/app/components/solidus_admin/layout/navigation/account/component.rb +36 -0
- data/app/components/solidus_admin/{sidebar → layout/navigation}/component.html.erb +9 -9
- data/app/components/solidus_admin/layout/navigation/component.rb +26 -0
- data/app/components/solidus_admin/{sidebar → layout/navigation}/item/component.html.erb +5 -5
- data/app/components/solidus_admin/{sidebar → layout/navigation}/item/component.rb +2 -2
- data/app/components/solidus_admin/layout/page_helpers.rb +55 -0
- data/app/components/solidus_admin/{skip_link → layout/skip_link}/component.rb +2 -4
- data/app/components/solidus_admin/option_types/index/component.rb +71 -0
- data/app/components/solidus_admin/orders/cart/component.html.erb +77 -0
- data/app/components/solidus_admin/orders/cart/component.js +37 -0
- data/app/components/solidus_admin/orders/cart/component.rb +7 -0
- data/app/components/solidus_admin/orders/cart/component.yml +3 -0
- data/app/components/solidus_admin/orders/cart/result/component.html.erb +26 -0
- data/app/components/solidus_admin/orders/cart/result/component.rb +11 -0
- data/app/components/solidus_admin/orders/index/component.rb +92 -23
- data/app/components/solidus_admin/orders/index/component.yml +10 -4
- data/app/components/solidus_admin/orders/show/address/component.html.erb +67 -0
- data/app/components/solidus_admin/orders/show/address/component.js +9 -0
- data/app/components/solidus_admin/orders/show/address/component.rb +53 -0
- data/app/components/solidus_admin/orders/show/address/component.yml +14 -0
- data/app/components/solidus_admin/orders/show/component.html.erb +76 -0
- data/app/components/solidus_admin/orders/show/component.js +7 -0
- data/app/components/solidus_admin/orders/show/component.rb +40 -0
- data/app/components/solidus_admin/orders/show/component.yml +21 -0
- data/app/components/solidus_admin/orders/show/customer_search/component.html.erb +14 -0
- data/app/components/solidus_admin/orders/show/customer_search/component.js +14 -0
- data/app/components/solidus_admin/orders/show/customer_search/component.rb +7 -0
- data/app/components/solidus_admin/orders/show/customer_search/component.yml +2 -0
- data/app/components/solidus_admin/orders/show/customer_search/result/component.html.erb +17 -0
- data/app/components/solidus_admin/orders/show/customer_search/result/component.rb +11 -0
- data/app/components/solidus_admin/orders/show/email/component.html.erb +18 -0
- data/app/components/solidus_admin/orders/show/email/component.rb +15 -0
- data/app/components/solidus_admin/orders/show/email/component.yml +8 -0
- data/app/components/solidus_admin/orders/show/summary/component.html.erb +14 -0
- data/app/components/solidus_admin/orders/show/summary/component.rb +7 -0
- data/app/components/solidus_admin/orders/show/summary/component.yml +8 -0
- data/app/components/solidus_admin/payment_methods/index/component.rb +103 -0
- data/app/components/solidus_admin/payment_methods/index/component.yml +10 -0
- data/app/components/solidus_admin/products/index/component.rb +48 -41
- data/app/components/solidus_admin/products/index/component.yml +8 -7
- data/app/components/solidus_admin/products/show/component.html.erb +32 -38
- data/app/components/solidus_admin/products/show/component.rb +2 -0
- data/app/components/solidus_admin/products/show/component.yml +5 -5
- data/app/components/solidus_admin/products/status/component.rb +20 -18
- data/app/components/solidus_admin/products/status/component.yml +1 -0
- data/app/components/solidus_admin/products/stock/component.rb +38 -0
- data/app/components/solidus_admin/products/stock/component.yml +5 -0
- data/app/components/solidus_admin/promotion_categories/index/component.rb +56 -0
- data/app/components/solidus_admin/promotions/index/component.rb +104 -0
- data/app/components/solidus_admin/promotions/index/component.yml +10 -0
- data/app/components/solidus_admin/properties/index/component.rb +64 -0
- data/app/components/solidus_admin/refund_reasons/index/component.rb +53 -0
- data/app/components/solidus_admin/refunds_and_returns/component.rb +40 -0
- data/app/components/solidus_admin/refunds_and_returns/component.yml +3 -0
- data/app/components/solidus_admin/reimbursement_types/index/component.rb +27 -0
- data/app/components/solidus_admin/return_reasons/index/component.rb +42 -0
- data/app/components/solidus_admin/shipping/component.rb +30 -0
- data/app/components/solidus_admin/shipping/component.yml +3 -0
- data/app/components/solidus_admin/shipping_categories/index/component.rb +46 -0
- data/app/components/solidus_admin/shipping_methods/index/component.rb +61 -0
- data/app/components/solidus_admin/stock_items/edit/component.html.erb +89 -0
- data/app/components/solidus_admin/stock_items/edit/component.js +17 -0
- data/app/components/solidus_admin/stock_items/edit/component.rb +23 -0
- data/app/components/solidus_admin/stock_items/edit/component.yml +10 -0
- data/app/components/solidus_admin/stock_items/index/component.rb +174 -0
- data/app/components/solidus_admin/stock_items/index/component.yml +10 -0
- data/app/components/solidus_admin/stock_locations/index/component.rb +89 -0
- data/app/components/solidus_admin/stock_locations/index/component.yml +3 -0
- data/app/components/solidus_admin/store_credit_reasons/index/component.rb +52 -0
- data/app/components/solidus_admin/stores/index/component.rb +58 -0
- data/app/components/solidus_admin/tax_categories/index/component.rb +58 -0
- data/app/components/solidus_admin/tax_rates/index/component.rb +88 -0
- data/app/components/solidus_admin/taxes/component.rb +25 -0
- data/app/components/solidus_admin/taxes/component.yml +3 -0
- data/app/components/solidus_admin/taxonomies/index/component.rb +53 -0
- data/app/components/solidus_admin/ui/badge/component.rb +18 -8
- data/app/components/solidus_admin/ui/badge/component.yml +3 -0
- data/app/components/solidus_admin/ui/button/component.rb +32 -32
- data/app/components/solidus_admin/ui/details_list/component.html.erb +10 -0
- data/app/components/solidus_admin/ui/details_list/component.rb +7 -0
- data/app/components/solidus_admin/ui/dropdown/component.html.erb +50 -0
- data/app/components/solidus_admin/ui/dropdown/component.js +16 -0
- data/app/components/solidus_admin/ui/dropdown/component.rb +28 -0
- data/app/components/solidus_admin/ui/dropdown/component.yml +2 -0
- data/app/components/solidus_admin/ui/forms/address/component.html.erb +36 -0
- data/app/components/solidus_admin/ui/forms/address/component.js +34 -0
- data/app/components/solidus_admin/ui/forms/address/component.rb +14 -0
- data/app/components/solidus_admin/ui/forms/field/component.html.erb +5 -4
- data/app/components/solidus_admin/ui/forms/field/component.rb +53 -15
- data/app/components/solidus_admin/ui/forms/input/component.rb +11 -5
- data/app/components/solidus_admin/ui/forms/search/component.html.erb +52 -0
- data/app/components/solidus_admin/ui/forms/search/component.js +116 -0
- data/app/components/solidus_admin/ui/forms/search/component.rb +8 -0
- data/app/components/solidus_admin/ui/forms/search/component.yml +4 -0
- data/app/components/solidus_admin/ui/forms/search/result/component.rb +12 -0
- data/app/components/solidus_admin/ui/forms/search_field/component.html.erb +20 -0
- data/app/{javascript/solidus_admin/controllers/hello_controller.js → components/solidus_admin/ui/forms/search_field/component.js} +4 -2
- data/app/components/solidus_admin/ui/forms/search_field/component.rb +10 -0
- data/app/components/solidus_admin/ui/forms/search_field/component.yml +2 -0
- data/app/components/solidus_admin/ui/forms/switch/component.rb +27 -31
- data/app/components/solidus_admin/ui/forms/switch_field/component.html.erb +20 -0
- data/app/components/solidus_admin/ui/forms/switch_field/component.rb +11 -0
- data/app/components/solidus_admin/ui/icon/component.rb +4 -0
- data/app/components/solidus_admin/ui/modal/component.html.erb +37 -0
- data/app/components/solidus_admin/ui/modal/component.rb +12 -0
- data/app/components/solidus_admin/ui/modal/component.yml +2 -0
- data/app/components/solidus_admin/ui/pages/index/component.html.erb +30 -0
- data/app/components/solidus_admin/ui/pages/index/component.rb +119 -0
- data/app/components/solidus_admin/ui/pages/index/component.yml +4 -0
- data/app/components/solidus_admin/ui/panel/component.html.erb +26 -12
- data/app/components/solidus_admin/ui/panel/component.rb +17 -0
- data/app/components/solidus_admin/ui/panel/component.yml +1 -3
- data/app/components/solidus_admin/ui/resource_item/component.html.erb +10 -0
- data/app/components/solidus_admin/ui/resource_item/component.rb +9 -0
- data/app/components/solidus_admin/ui/tab/component.rb +9 -8
- data/app/components/solidus_admin/ui/table/component.html.erb +147 -135
- data/app/components/solidus_admin/ui/table/component.js +56 -17
- data/app/components/solidus_admin/ui/table/component.rb +94 -70
- data/app/components/solidus_admin/ui/table/component.yml +0 -1
- data/app/components/solidus_admin/ui/table/ransack_filter/component.html.erb +72 -0
- data/app/components/solidus_admin/ui/table/ransack_filter/component.js +73 -0
- data/app/components/solidus_admin/ui/table/ransack_filter/component.rb +68 -0
- data/app/components/solidus_admin/ui/table/ransack_filter/component.yml +3 -0
- data/app/components/solidus_admin/ui/table/toolbar/component.rb +21 -0
- data/app/components/solidus_admin/ui/thumbnail/component.rb +46 -0
- data/app/components/solidus_admin/ui/toast/component.html.erb +9 -5
- data/app/components/solidus_admin/ui/toast/component.js +9 -6
- data/app/components/solidus_admin/ui/toast/component.rb +2 -2
- data/app/components/solidus_admin/ui/toggletip/component.html.erb +14 -10
- data/app/components/solidus_admin/ui/toggletip/component.js +22 -4
- data/app/components/solidus_admin/ui/toggletip/component.rb +8 -85
- data/app/components/solidus_admin/users/index/component.rb +96 -0
- data/app/components/solidus_admin/users/index/component.yml +15 -0
- data/app/components/solidus_admin/zones/index/component.rb +63 -0
- data/app/controllers/solidus_admin/addresses_controller.rb +92 -0
- data/app/controllers/solidus_admin/adjustment_reasons_controller.rb +40 -0
- data/app/controllers/solidus_admin/base_controller.rb +1 -0
- data/app/controllers/solidus_admin/controller_helpers/authorization.rb +5 -1
- data/app/controllers/solidus_admin/controller_helpers/locale.rb +2 -2
- data/app/controllers/solidus_admin/controller_helpers/search.rb +48 -0
- data/app/controllers/solidus_admin/controller_helpers/theme.rb +30 -0
- data/app/controllers/solidus_admin/countries_controller.rb +12 -0
- data/app/controllers/solidus_admin/customers_controller.rb +29 -0
- data/app/controllers/solidus_admin/line_items_controller.rb +45 -0
- data/app/controllers/solidus_admin/option_types_controller.rb +46 -0
- data/app/controllers/solidus_admin/orders_controller.rb +104 -7
- data/app/controllers/solidus_admin/payment_methods_controller.rb +52 -0
- data/app/controllers/solidus_admin/products_controller.rb +26 -17
- data/app/controllers/solidus_admin/promotion_categories_controller.rb +29 -0
- data/app/controllers/solidus_admin/promotions_controller.rb +46 -0
- data/app/controllers/solidus_admin/properties_controller.rb +33 -0
- data/app/controllers/solidus_admin/refund_reasons_controller.rb +40 -0
- data/app/controllers/solidus_admin/reimbursement_types_controller.rb +31 -0
- data/app/controllers/solidus_admin/return_reasons_controller.rb +40 -0
- data/app/controllers/solidus_admin/shipping_categories_controller.rb +40 -0
- data/app/controllers/solidus_admin/shipping_methods_controller.rb +40 -0
- data/app/controllers/solidus_admin/stock_items_controller.rb +67 -0
- data/app/controllers/solidus_admin/stock_locations_controller.rb +40 -0
- data/app/controllers/solidus_admin/store_credit_reasons_controller.rb +40 -0
- data/app/controllers/solidus_admin/stores_controller.rb +40 -0
- data/app/controllers/solidus_admin/tax_categories_controller.rb +40 -0
- data/app/controllers/solidus_admin/tax_rates_controller.rb +40 -0
- data/app/controllers/solidus_admin/taxonomies_controller.rb +46 -0
- data/app/controllers/solidus_admin/users_controller.rb +50 -0
- data/app/controllers/solidus_admin/zones_controller.rb +40 -0
- data/app/javascript/solidus_admin/controllers/components.js +3 -1
- data/app/javascript/solidus_admin/controllers/confirm_controller.js +21 -0
- data/app/javascript/solidus_admin/controllers/details_click_outside_controller.js +12 -0
- data/app/javascript/solidus_admin/controllers/readonly_when_submitting_controller.js +17 -0
- data/app/javascript/solidus_admin/controllers/sortable_controller.js +33 -0
- data/app/views/layouts/solidus_admin/application.html.erb +16 -10
- data/app/views/layouts/solidus_admin/preview.html.erb +2 -1
- data/app/views/solidus_admin/base/unauthorized.html.erb +4 -0
- data/config/importmap.rb +2 -0
- data/config/initializers/view_component.rb +20 -0
- data/config/locales/adjustment_reasons.en.yml +6 -0
- data/config/locales/customers.en.yml +7 -0
- data/config/locales/errors.en.yml +7 -0
- data/config/locales/line_items.en.yml +9 -0
- data/config/locales/{main_nav.en.yml → menu_item.en.yml} +8 -2
- data/config/locales/option_types.en.yml +6 -0
- data/config/locales/orders.en.yml +9 -0
- data/config/locales/payment_methods.en.yml +6 -0
- data/config/locales/promotion_categories.en.yml +6 -0
- data/config/locales/promotions.en.yml +6 -0
- data/config/locales/properties.en.yml +6 -0
- data/config/locales/refund_reasons_.en.yml +6 -0
- data/config/locales/reimbursement_types.en.yml +4 -0
- data/config/locales/return_reasons.en.yml +6 -0
- data/config/locales/shipping_categories.en.yml +6 -0
- data/config/locales/shipping_methods.en.yml +6 -0
- data/config/locales/stock_items.en.yml +4 -0
- data/config/locales/stock_locations.en.yml +6 -0
- data/config/locales/store_credit_reasons.en.yml +6 -0
- data/config/locales/stores.en.yml +6 -0
- data/config/locales/tax_categories.en.yml +6 -0
- data/config/locales/tax_rates.en.yml +6 -0
- data/config/locales/taxonomies.en.yml +6 -0
- data/config/locales/users.en.yml +6 -0
- data/config/locales/zones.en.yml +6 -0
- data/config/routes.rb +50 -3
- data/config/tailwind.config.js +119 -0
- data/docs/{customizing_main_navigation.md → customizing_menu_items.md} +2 -2
- data/docs/customizing_tailwindcss.md +57 -0
- data/docs/customizing_view_components.md +17 -38
- data/lib/generators/solidus_admin/install/install_generator.rb +13 -4
- data/lib/generators/solidus_admin/install/templates/config/initializers/{solidus_admin.rb → solidus_admin.rb.tt} +10 -14
- data/lib/solidus_admin/admin_resources.rb +23 -0
- data/lib/solidus_admin/configuration.rb +95 -67
- data/lib/solidus_admin/install_tailwindcss.rb +102 -0
- data/lib/solidus_admin/{main_nav_item.rb → menu_item.rb} +2 -2
- data/lib/solidus_admin/version.rb +1 -1
- data/lib/solidus_admin.rb +1 -2
- data/lib/tasks/tailwind.rake +10 -0
- data/solidus_admin.gemspec +3 -4
- metadata +193 -50
- data/app/assets/stylesheets/solidus_admin/application.tailwind.css.erb +0 -35
- data/app/components/solidus_admin/feedback/component.html.erb +0 -11
- data/app/components/solidus_admin/feedback/component.rb +0 -4
- data/app/components/solidus_admin/feedback/component.yml +0 -5
- data/app/components/solidus_admin/orders/index/component.html.erb +0 -31
- data/app/components/solidus_admin/products/index/component.html.erb +0 -30
- data/app/components/solidus_admin/sidebar/account_nav/component.html.erb +0 -67
- data/app/components/solidus_admin/sidebar/account_nav/component.rb +0 -15
- data/app/components/solidus_admin/sidebar/component.rb +0 -21
- data/app/components/solidus_admin/ui/panel/component.js +0 -14
- data/config/solidus_admin/tailwind.config.js.erb +0 -95
- data/docs/customizing_tailwind.md +0 -78
- data/lib/solidus_admin/tailwindcss.rb +0 -58
- data/lib/tasks/tailwindcss.rake +0 -55
- /data/app/components/solidus_admin/{sidebar/account_nav → layout/navigation/account}/component.yml +0 -0
- /data/app/components/solidus_admin/{sidebar → layout/navigation}/component.js +0 -0
- /data/app/components/solidus_admin/{sidebar → layout/navigation}/component.yml +0 -0
- /data/app/components/solidus_admin/{skip_link → layout/skip_link}/component.yml +0 -0
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
en:
|
|
2
|
+
batch_actions:
|
|
3
|
+
discontinue: 'Discontinue'
|
|
4
|
+
activate: 'Activate'
|
|
5
|
+
filters:
|
|
6
|
+
with_deleted: Include deleted
|
|
7
|
+
scopes:
|
|
8
|
+
customers: Customers
|
|
9
|
+
admin: Admins
|
|
10
|
+
with_orders: With Orders
|
|
11
|
+
without_orders: Without Orders
|
|
12
|
+
all: All
|
|
13
|
+
status:
|
|
14
|
+
active: Active
|
|
15
|
+
inactive: Inactive
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
class SolidusAdmin::Zones::Index::Component < SolidusAdmin::UI::Pages::Index::Component
|
|
4
|
+
def model_class
|
|
5
|
+
Spree::Zone
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
def search_key
|
|
9
|
+
:name_or_description_cont
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def search_url
|
|
13
|
+
solidus_admin.zones_path
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def row_url(zone)
|
|
17
|
+
spree.edit_admin_zone_path(zone)
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def page_actions
|
|
21
|
+
render component("ui/button").new(
|
|
22
|
+
tag: :a,
|
|
23
|
+
text: t('.add'),
|
|
24
|
+
href: spree.new_admin_zone_path,
|
|
25
|
+
icon: "add-line",
|
|
26
|
+
class: "align-self-end w-full",
|
|
27
|
+
)
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def batch_actions
|
|
31
|
+
[
|
|
32
|
+
{
|
|
33
|
+
display_name: t('.batch_actions.delete'),
|
|
34
|
+
action: solidus_admin.zones_path,
|
|
35
|
+
method: :delete,
|
|
36
|
+
icon: 'delete-bin-7-line',
|
|
37
|
+
},
|
|
38
|
+
]
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
def scopes
|
|
42
|
+
[]
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
def filters
|
|
46
|
+
[]
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
def columns
|
|
50
|
+
[
|
|
51
|
+
:name,
|
|
52
|
+
:description,
|
|
53
|
+
{
|
|
54
|
+
header: :kind,
|
|
55
|
+
data: -> { component('ui/badge').new(name: _1.kind, color: _1.kind == 'country' ? :green : :blue) },
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
header: :zone_members,
|
|
59
|
+
data: -> { _1.zone_members.map(&:zoneable).map(&:name).to_sentence },
|
|
60
|
+
},
|
|
61
|
+
]
|
|
62
|
+
end
|
|
63
|
+
end
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module SolidusAdmin
|
|
4
|
+
class AddressesController < BaseController
|
|
5
|
+
include Spree::Core::ControllerHelpers::StrongParameters
|
|
6
|
+
|
|
7
|
+
before_action :load_order, :load_address
|
|
8
|
+
before_action :validate_address_type
|
|
9
|
+
|
|
10
|
+
def show
|
|
11
|
+
respond_to do |format|
|
|
12
|
+
format.html do
|
|
13
|
+
render component('orders/show/address').new(
|
|
14
|
+
order: @order,
|
|
15
|
+
user: @order.user,
|
|
16
|
+
address: @address,
|
|
17
|
+
type: address_type,
|
|
18
|
+
)
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def edit
|
|
24
|
+
redirect_to action: :show
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def update
|
|
28
|
+
if @order.contents.update_cart(order_params)
|
|
29
|
+
redirect_to order_path(@order), status: :see_other, notice: t('.success')
|
|
30
|
+
else
|
|
31
|
+
flash.now[:error] = @order.errors[:base].join(", ") if @order.errors[:base].any?
|
|
32
|
+
|
|
33
|
+
respond_to do |format|
|
|
34
|
+
format.html do
|
|
35
|
+
render component('orders/show/address').new(
|
|
36
|
+
order: @order,
|
|
37
|
+
user: @order.user,
|
|
38
|
+
address: @order.send("#{address_type}_address"),
|
|
39
|
+
type: address_type,
|
|
40
|
+
), status: :unprocessable_entity
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
private
|
|
47
|
+
|
|
48
|
+
def load_address
|
|
49
|
+
if params[:address_id].present? && @order.user
|
|
50
|
+
@address =
|
|
51
|
+
@order.user.addresses.find_by(id: params[:address_id]) ||
|
|
52
|
+
@order.user.addresses.build(country: default_country)
|
|
53
|
+
else
|
|
54
|
+
@address =
|
|
55
|
+
@order.public_send("#{address_type}_address") ||
|
|
56
|
+
@order.public_send("build_#{address_type}_address", country: default_country)
|
|
57
|
+
end
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
def address_type
|
|
61
|
+
params[:type].presence_in(%w[bill ship])
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
def validate_address_type
|
|
65
|
+
unless address_type
|
|
66
|
+
flash[:error] = t('.errors.address_type_invalid')
|
|
67
|
+
redirect_to spree.admin_order_url(@order)
|
|
68
|
+
end
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
def default_country
|
|
72
|
+
@default_country ||= begin
|
|
73
|
+
country = Spree::Country.default
|
|
74
|
+
country if Spree::Country.available.exists?(id: country.id)
|
|
75
|
+
end
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
def load_order
|
|
79
|
+
@order = Spree::Order.find_by!(number: params[:order_id])
|
|
80
|
+
authorize! action_name, @order
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
def order_params
|
|
84
|
+
params.require(:order).permit(
|
|
85
|
+
:use_billing,
|
|
86
|
+
:use_shipping,
|
|
87
|
+
bill_address_attributes: permitted_address_attributes,
|
|
88
|
+
ship_address_attributes: permitted_address_attributes
|
|
89
|
+
)
|
|
90
|
+
end
|
|
91
|
+
end
|
|
92
|
+
end
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module SolidusAdmin
|
|
4
|
+
class AdjustmentReasonsController < SolidusAdmin::BaseController
|
|
5
|
+
include SolidusAdmin::ControllerHelpers::Search
|
|
6
|
+
|
|
7
|
+
def index
|
|
8
|
+
adjustment_reasons = apply_search_to(
|
|
9
|
+
Spree::AdjustmentReason.order(id: :desc),
|
|
10
|
+
param: :q,
|
|
11
|
+
)
|
|
12
|
+
|
|
13
|
+
set_page_and_extract_portion_from(adjustment_reasons)
|
|
14
|
+
|
|
15
|
+
respond_to do |format|
|
|
16
|
+
format.html { render component('adjustment_reasons/index').new(page: @page) }
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def destroy
|
|
21
|
+
@adjustment_reason = Spree::AdjustmentReason.find_by!(id: params[:id])
|
|
22
|
+
|
|
23
|
+
Spree::AdjustmentReason.transaction { @adjustment_reason.destroy }
|
|
24
|
+
|
|
25
|
+
flash[:notice] = t('.success')
|
|
26
|
+
redirect_back_or_to adjustment_reasons_path, status: :see_other
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
private
|
|
30
|
+
|
|
31
|
+
def load_adjustment_reason
|
|
32
|
+
@adjustment_reason = Spree::AdjustmentReason.find_by!(id: params[:id])
|
|
33
|
+
authorize! action_name, @adjustment_reason
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
def adjustment_reason_params
|
|
37
|
+
params.require(:adjustment_reason).permit(:adjustment_reason_id, permitted_adjustment_reason_attributes)
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
end
|
|
@@ -11,6 +11,7 @@ module SolidusAdmin
|
|
|
11
11
|
include SolidusAdmin::ControllerHelpers::Authentication
|
|
12
12
|
include SolidusAdmin::ControllerHelpers::Authorization
|
|
13
13
|
include SolidusAdmin::ControllerHelpers::Locale
|
|
14
|
+
include SolidusAdmin::ControllerHelpers::Theme
|
|
14
15
|
include SolidusAdmin::ComponentsHelper
|
|
15
16
|
include SolidusAdmin::AuthenticationAdapters::Backend if defined?(Spree::Backend)
|
|
16
17
|
|
|
@@ -5,6 +5,10 @@ module SolidusAdmin::ControllerHelpers::Authorization
|
|
|
5
5
|
|
|
6
6
|
included do
|
|
7
7
|
before_action :authorize_solidus_admin_user!
|
|
8
|
+
|
|
9
|
+
rescue_from CanCan::AccessDenied do
|
|
10
|
+
render 'unauthorized', status: :forbidden
|
|
11
|
+
end
|
|
8
12
|
end
|
|
9
13
|
|
|
10
14
|
private
|
|
@@ -17,7 +21,7 @@ module SolidusAdmin::ControllerHelpers::Authorization
|
|
|
17
21
|
subject = authorization_subject
|
|
18
22
|
|
|
19
23
|
authorize! :admin, subject
|
|
20
|
-
authorize! action_name, subject
|
|
24
|
+
authorize! action_name.to_sym, subject
|
|
21
25
|
end
|
|
22
26
|
|
|
23
27
|
def authorization_subject
|
|
@@ -18,7 +18,7 @@ module SolidusAdmin::ControllerHelpers::Locale
|
|
|
18
18
|
session[set_user_language_locale_key] = requested_locale
|
|
19
19
|
|
|
20
20
|
flash[:notice] = t('spree.locale_changed')
|
|
21
|
-
redirect_to
|
|
21
|
+
redirect_to params.except(:switch_to_locale).permit!.to_h.merge(account_menu_open: true)
|
|
22
22
|
end
|
|
23
23
|
end
|
|
24
24
|
|
|
@@ -27,6 +27,6 @@ module SolidusAdmin::ControllerHelpers::Locale
|
|
|
27
27
|
end
|
|
28
28
|
|
|
29
29
|
def set_locale
|
|
30
|
-
I18n.locale = user_locale
|
|
30
|
+
I18n.locale = I18n.locale_available?(user_locale) ? user_locale : I18n.default_locale
|
|
31
31
|
end
|
|
32
32
|
end
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module SolidusAdmin::ControllerHelpers::Search
|
|
4
|
+
extend ActiveSupport::Concern
|
|
5
|
+
|
|
6
|
+
module ClassMethods
|
|
7
|
+
def search_scope(name, default: false, &block)
|
|
8
|
+
search_scopes << SearchScope.new(
|
|
9
|
+
name: name.to_s,
|
|
10
|
+
block: block,
|
|
11
|
+
default: default,
|
|
12
|
+
)
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def search_scopes
|
|
16
|
+
@search_scopes ||= []
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
private
|
|
21
|
+
|
|
22
|
+
def apply_search_to(relation, param:)
|
|
23
|
+
relation = apply_scopes_to(relation, param: param)
|
|
24
|
+
apply_ransack_search_to(relation, param: param)
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def apply_ransack_search_to(relation, param:)
|
|
28
|
+
relation
|
|
29
|
+
.ransack(params[param]&.except(:scope))
|
|
30
|
+
.result(distinct: true)
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def apply_scopes_to(relation, param:)
|
|
34
|
+
current_scope_name = params.dig(param, :scope)
|
|
35
|
+
|
|
36
|
+
search_block = (
|
|
37
|
+
self.class.search_scopes.find { _1.name == current_scope_name } ||
|
|
38
|
+
self.class.search_scopes.find { _1.default }
|
|
39
|
+
)&.block
|
|
40
|
+
|
|
41
|
+
# Run the search if a block is present, fall back to the relation even if the
|
|
42
|
+
# block is present but returns nil.
|
|
43
|
+
(search_block && instance_exec(relation, &search_block)) || relation
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
SearchScope = Struct.new(:name, :block, :default, keyword_init: true)
|
|
47
|
+
private_constant :SearchScope
|
|
48
|
+
end
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module SolidusAdmin::ControllerHelpers::Theme
|
|
4
|
+
extend ActiveSupport::Concern
|
|
5
|
+
|
|
6
|
+
included do
|
|
7
|
+
before_action :update_user_theme
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
private
|
|
11
|
+
|
|
12
|
+
def update_user_theme
|
|
13
|
+
requested_theme = params[:switch_to_theme].presence or return
|
|
14
|
+
|
|
15
|
+
# Avoid interpolating user content into the session key
|
|
16
|
+
system_theme = params[:system_theme].presence == "dark" ? "dark" : "light"
|
|
17
|
+
session_key = :"admin_#{system_theme}_theme"
|
|
18
|
+
|
|
19
|
+
if theme_is_available?(requested_theme) && requested_theme.to_sym != session[session_key]
|
|
20
|
+
session[session_key] = requested_theme
|
|
21
|
+
|
|
22
|
+
flash[:notice] = t('spree.theme_changed')
|
|
23
|
+
redirect_to params.except(:switch_to_theme, :system_theme).permit!.to_h.merge(account_menu_open: true)
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def theme_is_available?(theme)
|
|
28
|
+
theme && SolidusAdmin::Config.themes.key?(theme.to_sym)
|
|
29
|
+
end
|
|
30
|
+
end
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module SolidusAdmin
|
|
4
|
+
class CountriesController < SolidusAdmin::BaseController
|
|
5
|
+
skip_before_action :authorize_solidus_admin_user!
|
|
6
|
+
|
|
7
|
+
def states
|
|
8
|
+
@states = Spree::State.where(country_id: params[:country_id])
|
|
9
|
+
render json: @states.select(:id, :name)
|
|
10
|
+
end
|
|
11
|
+
end
|
|
12
|
+
end
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
class SolidusAdmin::CustomersController < SolidusAdmin::BaseController
|
|
4
|
+
before_action :load_order, only: [:show, :destroy]
|
|
5
|
+
|
|
6
|
+
def show
|
|
7
|
+
render component('orders/show/email').new(order: @order)
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def destroy
|
|
11
|
+
if @order.update(user: nil)
|
|
12
|
+
flash[:success] = t('.success')
|
|
13
|
+
else
|
|
14
|
+
flash[:error] = t('.error')
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
redirect_to order_path(@order), status: :see_other
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
private
|
|
21
|
+
|
|
22
|
+
def load_order
|
|
23
|
+
@order = Spree::Order.find_by!(number: params[:order_id])
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def authorization_subject
|
|
27
|
+
@order || Spree::Order
|
|
28
|
+
end
|
|
29
|
+
end
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module SolidusAdmin
|
|
4
|
+
class LineItemsController < SolidusAdmin::BaseController
|
|
5
|
+
def destroy
|
|
6
|
+
load_order
|
|
7
|
+
load_line_item
|
|
8
|
+
|
|
9
|
+
@line_item.destroy!
|
|
10
|
+
|
|
11
|
+
redirect_to order_path(@order), status: :see_other, notice: t('.success')
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def create
|
|
15
|
+
load_order
|
|
16
|
+
variant_id = params.require(:line_item).require(:variant_id)
|
|
17
|
+
@variant = Spree::Variant.find(variant_id)
|
|
18
|
+
@line_item = @order.contents.add(@variant)
|
|
19
|
+
|
|
20
|
+
redirect_to order_path(@order), status: :see_other, notice: t('.success')
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def update
|
|
24
|
+
load_order
|
|
25
|
+
load_line_item
|
|
26
|
+
|
|
27
|
+
desired_quantity = params[:line_item][:quantity].to_i
|
|
28
|
+
|
|
29
|
+
@line_item = @order.contents.add(@line_item.variant, desired_quantity - @line_item.quantity)
|
|
30
|
+
|
|
31
|
+
redirect_to order_path(@order), status: :see_other, notice: t('.success')
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
private
|
|
35
|
+
|
|
36
|
+
def load_order
|
|
37
|
+
@order = Spree::Order.find_by!(number: params[:order_id])
|
|
38
|
+
authorize! action_name, @order
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
def load_line_item
|
|
42
|
+
@line_item = @order.line_items.find(params[:id])
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
end
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module SolidusAdmin
|
|
4
|
+
class OptionTypesController < SolidusAdmin::BaseController
|
|
5
|
+
include SolidusAdmin::ControllerHelpers::Search
|
|
6
|
+
|
|
7
|
+
before_action :load_option_type, only: [:move]
|
|
8
|
+
|
|
9
|
+
def index
|
|
10
|
+
option_types = apply_search_to(
|
|
11
|
+
Spree::OptionType.all,
|
|
12
|
+
param: :q,
|
|
13
|
+
)
|
|
14
|
+
|
|
15
|
+
set_page_and_extract_portion_from(option_types)
|
|
16
|
+
|
|
17
|
+
respond_to do |format|
|
|
18
|
+
format.html { render component('option_types/index').new(page: @page) }
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def move
|
|
23
|
+
@option_type.insert_at(params[:position].to_i)
|
|
24
|
+
|
|
25
|
+
respond_to do |format|
|
|
26
|
+
format.js { head :no_content }
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def destroy
|
|
31
|
+
@option_types = Spree::OptionType.where(id: params[:id])
|
|
32
|
+
|
|
33
|
+
Spree::OptionType.transaction { @option_types.destroy_all }
|
|
34
|
+
|
|
35
|
+
flash[:notice] = t('.success')
|
|
36
|
+
redirect_back_or_to option_types_path, status: :see_other
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
private
|
|
40
|
+
|
|
41
|
+
def load_option_type
|
|
42
|
+
@option_type = Spree::OptionType.find(params[:id])
|
|
43
|
+
authorize! action_name, @option_type
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
end
|
|
@@ -2,20 +2,117 @@
|
|
|
2
2
|
|
|
3
3
|
module SolidusAdmin
|
|
4
4
|
class OrdersController < SolidusAdmin::BaseController
|
|
5
|
+
include Spree::Core::ControllerHelpers::StrongParameters
|
|
6
|
+
include SolidusAdmin::ControllerHelpers::Search
|
|
7
|
+
|
|
8
|
+
search_scope(:completed, default: true) { _1.complete }
|
|
9
|
+
search_scope(:canceled) { _1.canceled }
|
|
10
|
+
search_scope(:returned) { _1.with_state(:returned) }
|
|
11
|
+
search_scope(:in_progress) { _1.with_state([:cart] + _1.checkout_step_names) }
|
|
12
|
+
search_scope(:all) { _1 }
|
|
13
|
+
|
|
5
14
|
def index
|
|
6
|
-
orders =
|
|
15
|
+
orders = apply_search_to(
|
|
16
|
+
Spree::Order.order(created_at: :desc, id: :desc),
|
|
17
|
+
param: :q,
|
|
18
|
+
)
|
|
19
|
+
|
|
20
|
+
set_page_and_extract_portion_from(orders)
|
|
21
|
+
|
|
22
|
+
respond_to do |format|
|
|
23
|
+
format.html { render component('orders/index').new(page: @page) }
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def new
|
|
28
|
+
order = Spree::Order.create!(
|
|
29
|
+
created_by: current_solidus_admin_user,
|
|
30
|
+
frontend_viewable: false,
|
|
31
|
+
store_id: current_store.try(:id)
|
|
32
|
+
)
|
|
33
|
+
|
|
34
|
+
redirect_to order_url(order), status: :see_other
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
def show
|
|
38
|
+
load_order
|
|
39
|
+
|
|
40
|
+
respond_to do |format|
|
|
41
|
+
format.html { render component('orders/show').new(order: @order) }
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
def update
|
|
46
|
+
load_order
|
|
47
|
+
|
|
48
|
+
@order.assign_attributes(order_params)
|
|
49
|
+
@order.email ||= @order.user.email if @order.user && @order.user.changed?
|
|
50
|
+
|
|
51
|
+
if @order.save
|
|
52
|
+
flash[:notice] = t('.success')
|
|
53
|
+
else
|
|
54
|
+
flash[:error] = t('.error')
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
redirect_to spree.edit_admin_order_path(@order)
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
def edit
|
|
61
|
+
redirect_to action: :show
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
def variants_for
|
|
65
|
+
load_order
|
|
66
|
+
|
|
67
|
+
# We need to eager load active storage attachments when using it
|
|
68
|
+
if Spree::Image.include?(Spree::Image::ActiveStorageAttachment)
|
|
69
|
+
image_includes = {
|
|
70
|
+
attachment_attachment: { blob: { variant_records: { image_attachment: :blob } } }
|
|
71
|
+
}
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
@variants = Spree::Variant
|
|
75
|
+
.where.not(id: @order.line_items.select(:variant_id))
|
|
76
|
+
.order(created_at: :desc, id: :desc)
|
|
77
|
+
.where(product_id: Spree::Product.ransack(params[:q]).result.select(:id))
|
|
78
|
+
.limit(10)
|
|
79
|
+
.eager_load(
|
|
80
|
+
:prices,
|
|
81
|
+
images: image_includes || {},
|
|
82
|
+
option_values: :option_type,
|
|
83
|
+
stock_items: :stock_location,
|
|
84
|
+
)
|
|
85
|
+
|
|
86
|
+
respond_to do |format|
|
|
87
|
+
format.html { render component('orders/cart/result').with_collection(@variants, order: @order), layout: false }
|
|
88
|
+
end
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
def customers_for
|
|
92
|
+
load_order
|
|
93
|
+
|
|
94
|
+
@users = Spree.user_class
|
|
95
|
+
.where.not(id: @order.user_id)
|
|
7
96
|
.order(created_at: :desc, id: :desc)
|
|
8
97
|
.ransack(params[:q])
|
|
9
98
|
.result(distinct: true)
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
orders,
|
|
13
|
-
per_page: SolidusAdmin::Config[:orders_per_page]
|
|
14
|
-
)
|
|
99
|
+
.includes(:default_user_bill_address, :default_user_ship_address)
|
|
100
|
+
.limit(10)
|
|
15
101
|
|
|
16
102
|
respond_to do |format|
|
|
17
|
-
format.html { render component('orders/
|
|
103
|
+
format.html { render component('orders/show/customer_search/result').with_collection(@users, order: @order), layout: false }
|
|
18
104
|
end
|
|
19
105
|
end
|
|
106
|
+
|
|
107
|
+
private
|
|
108
|
+
|
|
109
|
+
def load_order
|
|
110
|
+
@order = Spree::Order.find_by!(number: params[:id])
|
|
111
|
+
authorize! action_name, @order
|
|
112
|
+
end
|
|
113
|
+
|
|
114
|
+
def order_params
|
|
115
|
+
params.require(:order).permit(:user_id, permitted_order_attributes)
|
|
116
|
+
end
|
|
20
117
|
end
|
|
21
118
|
end
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module SolidusAdmin
|
|
4
|
+
class PaymentMethodsController < SolidusAdmin::BaseController
|
|
5
|
+
include SolidusAdmin::ControllerHelpers::Search
|
|
6
|
+
|
|
7
|
+
before_action :load_payment_method, only: [:move]
|
|
8
|
+
|
|
9
|
+
search_scope(:all)
|
|
10
|
+
search_scope(:active, default: true, &:active)
|
|
11
|
+
search_scope(:inactive) { _1.where.not(active: true) }
|
|
12
|
+
search_scope(:storefront, &:available_to_users)
|
|
13
|
+
search_scope(:admin, &:available_to_admin)
|
|
14
|
+
|
|
15
|
+
def index
|
|
16
|
+
payment_methods = apply_search_to(
|
|
17
|
+
Spree::PaymentMethod.ordered_by_position,
|
|
18
|
+
param: :q,
|
|
19
|
+
)
|
|
20
|
+
|
|
21
|
+
set_page_and_extract_portion_from(payment_methods)
|
|
22
|
+
|
|
23
|
+
respond_to do |format|
|
|
24
|
+
format.html { render component('payment_methods/index').new(page: @page) }
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def move
|
|
29
|
+
@payment_method.insert_at(params[:position].to_i)
|
|
30
|
+
|
|
31
|
+
respond_to do |format|
|
|
32
|
+
format.js { head :no_content }
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
def destroy
|
|
37
|
+
@payment_methods = Spree::PaymentMethod.where(id: params[:id])
|
|
38
|
+
|
|
39
|
+
Spree::PaymentMethod.transaction { @payment_methods.destroy_all }
|
|
40
|
+
|
|
41
|
+
flash[:notice] = t('.success')
|
|
42
|
+
redirect_back_or_to payment_methods_path, status: :see_other
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
private
|
|
46
|
+
|
|
47
|
+
def load_payment_method
|
|
48
|
+
@payment_method = Spree::PaymentMethod.find_by!(id: params[:id])
|
|
49
|
+
authorize! action_name, @payment_method
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
end
|