solidus_admin 0.0.2 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- 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
@@ -2,12 +2,37 @@
|
|
2
2
|
|
3
3
|
module SolidusAdmin
|
4
4
|
class ProductsController < SolidusAdmin::BaseController
|
5
|
+
include SolidusAdmin::ControllerHelpers::Search
|
6
|
+
|
7
|
+
search_scope(:all, default: true)
|
8
|
+
search_scope(:deleted) { _1.with_discarded.discarded }
|
9
|
+
search_scope(:discontinued) { _1.where(discontinue_on: ...Time.current) }
|
10
|
+
search_scope(:available) { _1.available }
|
11
|
+
search_scope(:in_stock) { _1.where(id: Spree::Variant.in_stock.distinct.select(:product_id)) }
|
12
|
+
search_scope(:out_of_stock) { _1.where.not(id: Spree::Variant.in_stock.distinct.select(:product_id)) }
|
13
|
+
|
14
|
+
def index
|
15
|
+
products = apply_search_to(
|
16
|
+
Spree::Product.includes(:master, :variants),
|
17
|
+
param: :q,
|
18
|
+
)
|
19
|
+
|
20
|
+
set_page_and_extract_portion_from(
|
21
|
+
products,
|
22
|
+
ordered_by: { updated_at: :desc, id: :desc },
|
23
|
+
)
|
24
|
+
|
25
|
+
respond_to do |format|
|
26
|
+
format.html { render component('products/index').new(page: @page) }
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
5
30
|
def edit
|
6
31
|
redirect_to action: :show
|
7
32
|
end
|
8
33
|
|
9
34
|
def show
|
10
|
-
@product = Spree::Product.friendly.find(params[:id])
|
35
|
+
@product = Spree::Product.with_discarded.friendly.find(params[:id])
|
11
36
|
|
12
37
|
respond_to do |format|
|
13
38
|
format.html { render component('products/show').new(product: @product) }
|
@@ -33,22 +58,6 @@ module SolidusAdmin
|
|
33
58
|
end
|
34
59
|
end
|
35
60
|
|
36
|
-
def index
|
37
|
-
products = Spree::Product
|
38
|
-
.order(created_at: :desc, id: :desc)
|
39
|
-
.ransack(params[:q])
|
40
|
-
.result(distinct: true)
|
41
|
-
|
42
|
-
set_page_and_extract_portion_from(
|
43
|
-
products,
|
44
|
-
per_page: SolidusAdmin::Config[:products_per_page]
|
45
|
-
)
|
46
|
-
|
47
|
-
respond_to do |format|
|
48
|
-
format.html { render component('products/index').new(page: @page) }
|
49
|
-
end
|
50
|
-
end
|
51
|
-
|
52
61
|
def destroy
|
53
62
|
@products = Spree::Product.where(id: params[:id])
|
54
63
|
|
@@ -0,0 +1,29 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module SolidusAdmin
|
4
|
+
class PromotionCategoriesController < SolidusAdmin::BaseController
|
5
|
+
include SolidusAdmin::ControllerHelpers::Search
|
6
|
+
|
7
|
+
def index
|
8
|
+
promotion_categories = apply_search_to(
|
9
|
+
Spree::PromotionCategory.all,
|
10
|
+
param: :q,
|
11
|
+
)
|
12
|
+
|
13
|
+
set_page_and_extract_portion_from(promotion_categories)
|
14
|
+
|
15
|
+
respond_to do |format|
|
16
|
+
format.html { render component('promotion_categories/index').new(page: @page) }
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def destroy
|
21
|
+
@promotion_categories = Spree::PromotionCategory.where(id: params[:id])
|
22
|
+
|
23
|
+
Spree::PromotionCategory.transaction { @promotion_categories.destroy_all }
|
24
|
+
|
25
|
+
flash[:notice] = t('.success')
|
26
|
+
redirect_back_or_to promotion_categories_path, status: :see_other
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module SolidusAdmin
|
4
|
+
class PromotionsController < SolidusAdmin::BaseController
|
5
|
+
include SolidusAdmin::ControllerHelpers::Search
|
6
|
+
|
7
|
+
search_scope(:active, default: true, &:active)
|
8
|
+
search_scope(:draft) { _1.where.not(id: _1.has_actions.select(:id)) }
|
9
|
+
search_scope(:future) { _1.has_actions.where(starts_at: Time.current..) }
|
10
|
+
search_scope(:expired) { _1.has_actions.where(expires_at: ..Time.current) }
|
11
|
+
search_scope(:all)
|
12
|
+
|
13
|
+
def index
|
14
|
+
promotions = apply_search_to(
|
15
|
+
Spree::Promotion.order(id: :desc),
|
16
|
+
param: :q,
|
17
|
+
)
|
18
|
+
|
19
|
+
set_page_and_extract_portion_from(promotions)
|
20
|
+
|
21
|
+
respond_to do |format|
|
22
|
+
format.html { render component('promotions/index').new(page: @page) }
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def destroy
|
27
|
+
@promotions = Spree::Promotion.where(id: params[:id])
|
28
|
+
|
29
|
+
Spree::Promotion.transaction { @promotions.destroy_all }
|
30
|
+
|
31
|
+
flash[:notice] = t('.success')
|
32
|
+
redirect_back_or_to promotions_path, status: :see_other
|
33
|
+
end
|
34
|
+
|
35
|
+
private
|
36
|
+
|
37
|
+
def load_promotion
|
38
|
+
@promotion = Spree::Promotion.find_by!(number: params[:id])
|
39
|
+
authorize! action_name, @promotion
|
40
|
+
end
|
41
|
+
|
42
|
+
def promotion_params
|
43
|
+
params.require(:promotion).permit(:user_id, permitted_promotion_attributes)
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module SolidusAdmin
|
4
|
+
class PropertiesController < SolidusAdmin::BaseController
|
5
|
+
include SolidusAdmin::ControllerHelpers::Search
|
6
|
+
|
7
|
+
def index
|
8
|
+
properties = apply_search_to(
|
9
|
+
Spree::Property.order(created_at: :desc, id: :desc),
|
10
|
+
param: :q,
|
11
|
+
)
|
12
|
+
|
13
|
+
set_page_and_extract_portion_from(
|
14
|
+
properties,
|
15
|
+
)
|
16
|
+
|
17
|
+
respond_to do |format|
|
18
|
+
format.html { render component('properties/index').new(page: @page) }
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def destroy
|
23
|
+
@properties = Spree::Property.where(id: params[:id])
|
24
|
+
|
25
|
+
Spree::Property.transaction do
|
26
|
+
@properties.destroy_all
|
27
|
+
end
|
28
|
+
|
29
|
+
flash[:notice] = t('.success')
|
30
|
+
redirect_to properties_path, status: :see_other
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module SolidusAdmin
|
4
|
+
class RefundReasonsController < SolidusAdmin::BaseController
|
5
|
+
include SolidusAdmin::ControllerHelpers::Search
|
6
|
+
|
7
|
+
def index
|
8
|
+
refund_reasons = apply_search_to(
|
9
|
+
Spree::RefundReason.unscoped.order(id: :desc),
|
10
|
+
param: :q,
|
11
|
+
)
|
12
|
+
|
13
|
+
set_page_and_extract_portion_from(refund_reasons)
|
14
|
+
|
15
|
+
respond_to do |format|
|
16
|
+
format.html { render component('refund_reasons/index').new(page: @page) }
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def destroy
|
21
|
+
@refund_reason = Spree::RefundReason.find_by!(id: params[:id])
|
22
|
+
|
23
|
+
Spree::RefundReason.transaction { @refund_reason.destroy }
|
24
|
+
|
25
|
+
flash[:notice] = t('.success')
|
26
|
+
redirect_back_or_to refund_reasons_path, status: :see_other
|
27
|
+
end
|
28
|
+
|
29
|
+
private
|
30
|
+
|
31
|
+
def load_refund_reason
|
32
|
+
@refund_reason = Spree::RefundReason.find_by!(id: params[:id])
|
33
|
+
authorize! action_name, @refund_reason
|
34
|
+
end
|
35
|
+
|
36
|
+
def refund_reason_params
|
37
|
+
params.require(:refund_reason).permit(:refund_reason_id, permitted_refund_reason_attributes)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module SolidusAdmin
|
4
|
+
class ReimbursementTypesController < SolidusAdmin::BaseController
|
5
|
+
include SolidusAdmin::ControllerHelpers::Search
|
6
|
+
|
7
|
+
def index
|
8
|
+
reimbursement_types = apply_search_to(
|
9
|
+
Spree::ReimbursementType.unscoped.order(id: :desc),
|
10
|
+
param: :q,
|
11
|
+
)
|
12
|
+
|
13
|
+
set_page_and_extract_portion_from(reimbursement_types)
|
14
|
+
|
15
|
+
respond_to do |format|
|
16
|
+
format.html { render component('reimbursement_types/index').new(page: @page) }
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
private
|
21
|
+
|
22
|
+
def load_reimbursement_type
|
23
|
+
@reimbursement_type = Spree::ReimbursementType.find_by!(id: params[:id])
|
24
|
+
authorize! action_name, @reimbursement_type
|
25
|
+
end
|
26
|
+
|
27
|
+
def reimbursement_type_params
|
28
|
+
params.require(:reimbursement_type).permit(:reimbursement_type_id, permitted_reimbursement_type_attributes)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module SolidusAdmin
|
4
|
+
class ReturnReasonsController < SolidusAdmin::BaseController
|
5
|
+
include SolidusAdmin::ControllerHelpers::Search
|
6
|
+
|
7
|
+
def index
|
8
|
+
return_reasons = apply_search_to(
|
9
|
+
Spree::ReturnReason.unscoped.order(id: :desc),
|
10
|
+
param: :q,
|
11
|
+
)
|
12
|
+
|
13
|
+
set_page_and_extract_portion_from(return_reasons)
|
14
|
+
|
15
|
+
respond_to do |format|
|
16
|
+
format.html { render component('return_reasons/index').new(page: @page) }
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def destroy
|
21
|
+
@return_reason = Spree::ReturnReason.find_by!(id: params[:id])
|
22
|
+
|
23
|
+
Spree::ReturnReason.transaction { @return_reason.destroy }
|
24
|
+
|
25
|
+
flash[:notice] = t('.success')
|
26
|
+
redirect_back_or_to return_reasons_path, status: :see_other
|
27
|
+
end
|
28
|
+
|
29
|
+
private
|
30
|
+
|
31
|
+
def load_return_reason
|
32
|
+
@return_reason = Spree::ReturnReason.find_by!(id: params[:id])
|
33
|
+
authorize! action_name, @return_reason
|
34
|
+
end
|
35
|
+
|
36
|
+
def return_reason_params
|
37
|
+
params.require(:return_reason).permit(:return_reason_id, permitted_return_reason_attributes)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module SolidusAdmin
|
4
|
+
class ShippingCategoriesController < SolidusAdmin::BaseController
|
5
|
+
include SolidusAdmin::ControllerHelpers::Search
|
6
|
+
|
7
|
+
def index
|
8
|
+
shipping_categories = apply_search_to(
|
9
|
+
Spree::ShippingCategory.order(id: :desc),
|
10
|
+
param: :q,
|
11
|
+
)
|
12
|
+
|
13
|
+
set_page_and_extract_portion_from(shipping_categories)
|
14
|
+
|
15
|
+
respond_to do |format|
|
16
|
+
format.html { render component('shipping_categories/index').new(page: @page) }
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def destroy
|
21
|
+
@shipping_category = Spree::ShippingCategory.find_by!(id: params[:id])
|
22
|
+
|
23
|
+
Spree::ShippingCategory.transaction { @shipping_category.destroy }
|
24
|
+
|
25
|
+
flash[:notice] = t('.success')
|
26
|
+
redirect_back_or_to shipping_categories_path, status: :see_other
|
27
|
+
end
|
28
|
+
|
29
|
+
private
|
30
|
+
|
31
|
+
def load_shipping_category
|
32
|
+
@shipping_category = Spree::ShippingCategory.find_by!(id: params[:id])
|
33
|
+
authorize! action_name, @shipping_category
|
34
|
+
end
|
35
|
+
|
36
|
+
def shipping_category_params
|
37
|
+
params.require(:shipping_category).permit(:shipping_category_id, permitted_shipping_category_attributes)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module SolidusAdmin
|
4
|
+
class ShippingMethodsController < SolidusAdmin::BaseController
|
5
|
+
include SolidusAdmin::ControllerHelpers::Search
|
6
|
+
|
7
|
+
def index
|
8
|
+
shipping_methods = apply_search_to(
|
9
|
+
Spree::ShippingMethod.order(id: :desc),
|
10
|
+
param: :q,
|
11
|
+
)
|
12
|
+
|
13
|
+
set_page_and_extract_portion_from(shipping_methods)
|
14
|
+
|
15
|
+
respond_to do |format|
|
16
|
+
format.html { render component('shipping_methods/index').new(page: @page) }
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def destroy
|
21
|
+
@shipping_methods = Spree::ShippingMethod.where(id: params[:id])
|
22
|
+
|
23
|
+
Spree::ShippingMethod.transaction { @shipping_methods.destroy_all }
|
24
|
+
|
25
|
+
flash[:notice] = t('.success')
|
26
|
+
redirect_back_or_to shipping_methods_path, status: :see_other
|
27
|
+
end
|
28
|
+
|
29
|
+
private
|
30
|
+
|
31
|
+
def load_shipping_method
|
32
|
+
@shipping_method = Spree::ShippingMethod.find_by!(number: params[:id])
|
33
|
+
authorize! action_name, @shipping_method
|
34
|
+
end
|
35
|
+
|
36
|
+
def shipping_method_params
|
37
|
+
params.require(:shipping_method).permit(:shipping_method_id, permitted_shipping_method_attributes)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,67 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module SolidusAdmin
|
4
|
+
class StockItemsController < SolidusAdmin::BaseController
|
5
|
+
include SolidusAdmin::ControllerHelpers::Search
|
6
|
+
before_action :load_stock_items, only: [:index, :edit, :update]
|
7
|
+
before_action :load_stock_item, only: [:edit, :update]
|
8
|
+
|
9
|
+
search_scope(:all, default: true) { _1 }
|
10
|
+
search_scope(:back_orderable) { _1.where(backorderable: true) }
|
11
|
+
search_scope(:out_of_stock) { _1.where('count_on_hand <= 0') }
|
12
|
+
search_scope(:low_stock) { _1.where('count_on_hand > 0 AND count_on_hand < ?', SolidusAdmin::Config[:low_stock_value]) }
|
13
|
+
search_scope(:in_stock) { _1.where('count_on_hand > 0') }
|
14
|
+
|
15
|
+
def index
|
16
|
+
respond_to do |format|
|
17
|
+
format.html { render component('stock_items/index').new(page: @page) }
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def edit
|
22
|
+
respond_to do |format|
|
23
|
+
format.html { render component('stock_items/edit').new(stock_item: @stock_item, page: @page) }
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def update
|
28
|
+
quantity_adjustment = params[:quantity_adjustment].to_i
|
29
|
+
@stock_item.assign_attributes(stock_item_params.except(:page, :q))
|
30
|
+
@stock_item.stock_movements.build(quantity: quantity_adjustment, originator: current_solidus_admin_user)
|
31
|
+
|
32
|
+
if @stock_item.save
|
33
|
+
redirect_to solidus_admin.stock_items_path(
|
34
|
+
page: stock_item_params[:page].to_i.presence,
|
35
|
+
q: stock_item_params[:q].presence&.then { |q| JSON.parse(q) }
|
36
|
+
), status: :see_other
|
37
|
+
else
|
38
|
+
respond_to do |format|
|
39
|
+
format.html { render component('stock_items/edit').new(stock_item: @stock_item, page: @page), status: :unprocessable_entity }
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
private
|
45
|
+
|
46
|
+
def load_stock_items
|
47
|
+
@stock_items = apply_search_to(
|
48
|
+
Spree::StockItem.reorder(nil),
|
49
|
+
param: :q,
|
50
|
+
)
|
51
|
+
|
52
|
+
set_page_and_extract_portion_from(@stock_items, ordered_by: {
|
53
|
+
variant_id: :desc,
|
54
|
+
stock_location_id: :desc,
|
55
|
+
id: :desc,
|
56
|
+
})
|
57
|
+
end
|
58
|
+
|
59
|
+
def load_stock_item
|
60
|
+
@stock_item = Spree::StockItem.find(params[:id])
|
61
|
+
end
|
62
|
+
|
63
|
+
def stock_item_params
|
64
|
+
params.require(:stock_item).permit(:backorderable, :page, :q)
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module SolidusAdmin
|
4
|
+
class StockLocationsController < SolidusAdmin::BaseController
|
5
|
+
include SolidusAdmin::ControllerHelpers::Search
|
6
|
+
|
7
|
+
def index
|
8
|
+
stock_locations = apply_search_to(
|
9
|
+
Spree::StockLocation.order(id: :desc),
|
10
|
+
param: :q,
|
11
|
+
)
|
12
|
+
|
13
|
+
set_page_and_extract_portion_from(stock_locations)
|
14
|
+
|
15
|
+
respond_to do |format|
|
16
|
+
format.html { render component('stock_locations/index').new(page: @page) }
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def destroy
|
21
|
+
@stock_locations = Spree::StockLocation.where(id: params[:id])
|
22
|
+
|
23
|
+
Spree::StockLocation.transaction { @stock_locations.destroy_all }
|
24
|
+
|
25
|
+
flash[:notice] = t('.success')
|
26
|
+
redirect_back_or_to stock_locations_path, status: :see_other
|
27
|
+
end
|
28
|
+
|
29
|
+
private
|
30
|
+
|
31
|
+
def load_stock_location
|
32
|
+
@stock_location = Spree::StockLocation.find_by!(number: params[:id])
|
33
|
+
authorize! action_name, @stock_location
|
34
|
+
end
|
35
|
+
|
36
|
+
def stock_location_params
|
37
|
+
params.require(:stock_location).permit(:stock_location_id, permitted_stock_location_attributes)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module SolidusAdmin
|
4
|
+
class StoreCreditReasonsController < SolidusAdmin::BaseController
|
5
|
+
include SolidusAdmin::ControllerHelpers::Search
|
6
|
+
|
7
|
+
def index
|
8
|
+
store_credit_reasons = apply_search_to(
|
9
|
+
Spree::StoreCreditReason.unscoped.order(id: :desc),
|
10
|
+
param: :q,
|
11
|
+
)
|
12
|
+
|
13
|
+
set_page_and_extract_portion_from(store_credit_reasons)
|
14
|
+
|
15
|
+
respond_to do |format|
|
16
|
+
format.html { render component('store_credit_reasons/index').new(page: @page) }
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def destroy
|
21
|
+
@store_credit_reason = Spree::StoreCreditReason.find_by!(id: params[:id])
|
22
|
+
|
23
|
+
Spree::StoreCreditReason.transaction { @store_credit_reason.destroy }
|
24
|
+
|
25
|
+
flash[:notice] = t('.success')
|
26
|
+
redirect_back_or_to store_credit_reasons_path, status: :see_other
|
27
|
+
end
|
28
|
+
|
29
|
+
private
|
30
|
+
|
31
|
+
def load_store_credit_reason
|
32
|
+
@store_credit_reason = Spree::StoreCreditReason.find_by!(id: params[:id])
|
33
|
+
authorize! action_name, @store_credit_reason
|
34
|
+
end
|
35
|
+
|
36
|
+
def store_credit_reason_params
|
37
|
+
params.require(:store_credit_reason).permit(:store_credit_reason_id, permitted_store_credit_reason_attributes)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module SolidusAdmin
|
4
|
+
class StoresController < SolidusAdmin::BaseController
|
5
|
+
include SolidusAdmin::ControllerHelpers::Search
|
6
|
+
|
7
|
+
def index
|
8
|
+
stores = apply_search_to(
|
9
|
+
Spree::Store.order(id: :desc),
|
10
|
+
param: :q
|
11
|
+
)
|
12
|
+
|
13
|
+
set_page_and_extract_portion_from(stores)
|
14
|
+
|
15
|
+
respond_to do |format|
|
16
|
+
format.html { render component('stores/index').new(page: @page) }
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def destroy
|
21
|
+
@stores = Spree::Store.where(id: params[:id])
|
22
|
+
|
23
|
+
Spree::Store.transaction { @stores.destroy_all }
|
24
|
+
|
25
|
+
flash[:notice] = t('.success')
|
26
|
+
redirect_back_or_to stores_path, status: :see_other
|
27
|
+
end
|
28
|
+
|
29
|
+
private
|
30
|
+
|
31
|
+
def load_store
|
32
|
+
@store = Spree::Store.find_by!(number: params[:id])
|
33
|
+
authorize! action_name, @store
|
34
|
+
end
|
35
|
+
|
36
|
+
def store_params
|
37
|
+
params.require(:store).permit(:store_id, permitted_store_attributes)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module SolidusAdmin
|
4
|
+
class TaxCategoriesController < SolidusAdmin::BaseController
|
5
|
+
include SolidusAdmin::ControllerHelpers::Search
|
6
|
+
|
7
|
+
def index
|
8
|
+
tax_categories = apply_search_to(
|
9
|
+
Spree::TaxCategory.order(created_at: :desc, id: :desc),
|
10
|
+
param: :q,
|
11
|
+
)
|
12
|
+
|
13
|
+
set_page_and_extract_portion_from(tax_categories)
|
14
|
+
|
15
|
+
respond_to do |format|
|
16
|
+
format.html { render component('tax_categories/index').new(page: @page) }
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def destroy
|
21
|
+
@tax_categories = Spree::TaxCategory.where(id: params[:id])
|
22
|
+
|
23
|
+
Spree::TaxCategory.transaction { @tax_categories.destroy_all }
|
24
|
+
|
25
|
+
flash[:notice] = t('.success')
|
26
|
+
redirect_back_or_to tax_categories_path, status: :see_other
|
27
|
+
end
|
28
|
+
|
29
|
+
private
|
30
|
+
|
31
|
+
def load_tax_category
|
32
|
+
@tax_category = Spree::TaxCategory.find_by!(number: params[:id])
|
33
|
+
authorize! action_name, @tax_category
|
34
|
+
end
|
35
|
+
|
36
|
+
def tax_category_params
|
37
|
+
params.require(:tax_category).permit(:tax_category_id, permitted_tax_category_attributes)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module SolidusAdmin
|
4
|
+
class TaxRatesController < SolidusAdmin::BaseController
|
5
|
+
include SolidusAdmin::ControllerHelpers::Search
|
6
|
+
|
7
|
+
def index
|
8
|
+
tax_rates = apply_search_to(
|
9
|
+
Spree::TaxRate.order(created_at: :desc, id: :desc),
|
10
|
+
param: :q,
|
11
|
+
)
|
12
|
+
|
13
|
+
set_page_and_extract_portion_from(tax_rates)
|
14
|
+
|
15
|
+
respond_to do |format|
|
16
|
+
format.html { render component('tax_rates/index').new(page: @page) }
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def destroy
|
21
|
+
@tax_rates = Spree::TaxRate.where(id: params[:id])
|
22
|
+
|
23
|
+
Spree::TaxRate.transaction { @tax_rates.destroy_all }
|
24
|
+
|
25
|
+
flash[:notice] = t('.success')
|
26
|
+
redirect_back_or_to tax_rates_path, status: :see_other
|
27
|
+
end
|
28
|
+
|
29
|
+
private
|
30
|
+
|
31
|
+
def load_tax_rate
|
32
|
+
@tax_rate = Spree::TaxRate.find_by!(number: params[:id])
|
33
|
+
authorize! action_name, @tax_rate
|
34
|
+
end
|
35
|
+
|
36
|
+
def tax_rate_params
|
37
|
+
params.require(:tax_rate).permit(:tax_rate_id, permitted_tax_rate_attributes)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module SolidusAdmin
|
4
|
+
class TaxonomiesController < SolidusAdmin::BaseController
|
5
|
+
include SolidusAdmin::ControllerHelpers::Search
|
6
|
+
|
7
|
+
before_action :load_taxonomy, only: [:move]
|
8
|
+
|
9
|
+
def index
|
10
|
+
taxonomies = apply_search_to(
|
11
|
+
Spree::Taxonomy.all,
|
12
|
+
param: :q,
|
13
|
+
)
|
14
|
+
|
15
|
+
set_page_and_extract_portion_from(taxonomies)
|
16
|
+
|
17
|
+
respond_to do |format|
|
18
|
+
format.html { render component('taxonomies/index').new(page: @page) }
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def move
|
23
|
+
@taxonomy.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
|
+
@taxonomies = Spree::Taxonomy.where(id: params[:id])
|
32
|
+
|
33
|
+
Spree::Taxonomy.transaction { @taxonomies.destroy_all }
|
34
|
+
|
35
|
+
flash[:notice] = t('.success')
|
36
|
+
redirect_back_or_to taxonomies_path, status: :see_other
|
37
|
+
end
|
38
|
+
|
39
|
+
private
|
40
|
+
|
41
|
+
def load_taxonomy
|
42
|
+
@taxonomy = Spree::Taxonomy.find(params[:id])
|
43
|
+
authorize! action_name, @taxonomy
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|