solidus_admin 0.5.0 → 0.5.2
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/app/assets/builds/solidus_admin/tailwind.css +4 -0
- data/app/components/solidus_admin/ui/alert/component.html.erb +1 -1
- data/app/components/solidus_admin/ui/pages/index/component.rb +6 -2
- data/app/controllers/solidus_admin/adjustments_controller.rb +5 -2
- data/app/controllers/solidus_admin/controller_helpers/authorization.rb +12 -0
- data/app/controllers/solidus_admin/controller_helpers/locale.rb +2 -1
- data/app/controllers/solidus_admin/controller_helpers/theme.rb +2 -1
- data/app/controllers/solidus_admin/customers_controller.rb +1 -0
- data/app/controllers/solidus_admin/orders_controller.rb +1 -1
- data/app/controllers/solidus_admin/product_taxons_controller.rb +1 -0
- data/app/controllers/solidus_admin/products_controller.rb +6 -1
- data/app/controllers/solidus_admin/reimbursement_types_controller.rb +1 -1
- data/app/controllers/solidus_admin/resources_controller.rb +5 -1
- data/app/controllers/solidus_admin/shipping_methods_controller.rb +2 -1
- data/app/controllers/solidus_admin/stock_items_controller.rb +7 -1
- data/app/controllers/solidus_admin/store_credits_controller.rb +6 -3
- data/app/controllers/solidus_admin/stores_controller.rb +3 -2
- data/app/controllers/solidus_admin/taxonomies_controller.rb +2 -1
- data/app/controllers/solidus_admin/users_controller.rb +11 -11
- data/lib/solidus_admin/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 1cc353f410a59b215ed2ec204142a898415cc32f0ccc5d808019fe9c196bdfae
|
|
4
|
+
data.tar.gz: 50796a9a1bd1be8a888f61ac20fd753ed88661de07f9427bb5d6b1c72fcf1d2b
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: a25f0ba55ab0ea44fecbb6e6f48a65b480f63ea7cbcca9d66c1c6a29cf1f62642c4c66b5e9da4b1326cf1c4c54e98ca4f8c6eb43ec434ccb459fc7dd1b8ac5a1
|
|
7
|
+
data.tar.gz: 591bd3ef9b1f3b80be29af4f3f05bdbf17b1d7be444a9e52894945708754a896fe72f44b8ea76adf9245040ff4f2d169da22b5d875f1f533eddc81a2086a6f09
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
</div>
|
|
19
19
|
<div class="flex flex-col px-2 pt-1 gap-3">
|
|
20
20
|
<p class="font-semibold text-base text-black leading-none"><%= @title %></p>
|
|
21
|
-
<p class="font-normal text-sm text-black leading-none"><%= @message
|
|
21
|
+
<p class="font-normal text-sm text-black leading-none whitespace-pre-line"><%= @message %></p>
|
|
22
22
|
</div>
|
|
23
23
|
</div>
|
|
24
24
|
<div>
|
|
@@ -80,11 +80,15 @@ class SolidusAdmin::UI::Pages::Index::Component < SolidusAdmin::BaseComponent
|
|
|
80
80
|
end
|
|
81
81
|
|
|
82
82
|
def prev_page_path
|
|
83
|
-
|
|
83
|
+
page_path(@page.current_page - 1) if @page && !@page.first_page?
|
|
84
84
|
end
|
|
85
85
|
|
|
86
86
|
def next_page_path
|
|
87
|
-
|
|
87
|
+
page_path(@page.next_page) if @page&.next_page
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
def page_path(page)
|
|
91
|
+
"#{request.path}?#{request.query_parameters.merge("page" => page).to_query}"
|
|
88
92
|
end
|
|
89
93
|
|
|
90
94
|
def search_options
|
|
@@ -18,6 +18,7 @@ class SolidusAdmin::AdjustmentsController < SolidusAdmin::BaseController
|
|
|
18
18
|
|
|
19
19
|
def lock
|
|
20
20
|
@adjustments = @order.all_adjustments.not_finalized.where(id: params[:id])
|
|
21
|
+
authorize_each! @adjustments
|
|
21
22
|
@adjustments.each(&:finalize!)
|
|
22
23
|
flash[:notice] = t(".success")
|
|
23
24
|
|
|
@@ -26,6 +27,7 @@ class SolidusAdmin::AdjustmentsController < SolidusAdmin::BaseController
|
|
|
26
27
|
|
|
27
28
|
def unlock
|
|
28
29
|
@adjustments = @order.all_adjustments.finalized.where(id: params[:id])
|
|
30
|
+
authorize_each! @adjustments
|
|
29
31
|
@adjustments.each(&:unfinalize!)
|
|
30
32
|
flash[:notice] = t(".success")
|
|
31
33
|
|
|
@@ -34,6 +36,7 @@ class SolidusAdmin::AdjustmentsController < SolidusAdmin::BaseController
|
|
|
34
36
|
|
|
35
37
|
def destroy
|
|
36
38
|
@adjustments = @order.all_adjustments.where(id: params[:id])
|
|
39
|
+
authorize_each! @adjustments
|
|
37
40
|
@adjustments.destroy_all
|
|
38
41
|
flash[:notice] = t(".success")
|
|
39
42
|
|
|
@@ -43,8 +46,7 @@ class SolidusAdmin::AdjustmentsController < SolidusAdmin::BaseController
|
|
|
43
46
|
private
|
|
44
47
|
|
|
45
48
|
def load_adjustments
|
|
46
|
-
@adjustments = @order
|
|
47
|
-
.all_adjustments
|
|
49
|
+
@adjustments = accessible(@order.all_adjustments)
|
|
48
50
|
.order("adjustable_type ASC, created_at ASC")
|
|
49
51
|
.ransack(params[:q])
|
|
50
52
|
.result
|
|
@@ -52,5 +54,6 @@ class SolidusAdmin::AdjustmentsController < SolidusAdmin::BaseController
|
|
|
52
54
|
|
|
53
55
|
def load_order
|
|
54
56
|
@order = Spree::Order.find_by!(number: params[:order_id])
|
|
57
|
+
authorize! :show, @order
|
|
55
58
|
end
|
|
56
59
|
end
|
|
@@ -24,6 +24,18 @@ module SolidusAdmin::ControllerHelpers::Authorization
|
|
|
24
24
|
authorize! action_name.to_sym, subject
|
|
25
25
|
end
|
|
26
26
|
|
|
27
|
+
# Rules defined with a block can't be turned into a query, so the scope is
|
|
28
|
+
# left as it is for them, like in the legacy backend.
|
|
29
|
+
def accessible(scope)
|
|
30
|
+
return scope if current_ability.has_block?(:index, scope.all.klass)
|
|
31
|
+
|
|
32
|
+
scope.accessible_by(current_ability, :index)
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def authorize_each!(records)
|
|
36
|
+
records.each { authorize! action_name.to_sym, _1 }
|
|
37
|
+
end
|
|
38
|
+
|
|
27
39
|
def authorization_subject
|
|
28
40
|
"Spree::#{controller_name.classify}".constantize
|
|
29
41
|
rescue NameError
|
|
@@ -18,7 +18,8 @@ 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
|
-
|
|
21
|
+
query = request.query_parameters.except("switch_to_locale").merge("account_menu_open" => true)
|
|
22
|
+
redirect_to "#{request.path}?#{query.to_query}"
|
|
22
23
|
end
|
|
23
24
|
end
|
|
24
25
|
|
|
@@ -20,7 +20,8 @@ module SolidusAdmin::ControllerHelpers::Theme
|
|
|
20
20
|
session[session_key] = requested_theme
|
|
21
21
|
|
|
22
22
|
flash[:notice] = t("spree.theme_changed")
|
|
23
|
-
|
|
23
|
+
query = request.query_parameters.except("switch_to_theme", "system_theme").merge("account_menu_open" => true)
|
|
24
|
+
redirect_to "#{request.path}?#{query.to_query}"
|
|
24
25
|
end
|
|
25
26
|
end
|
|
26
27
|
|
|
@@ -13,7 +13,7 @@ module SolidusAdmin
|
|
|
13
13
|
|
|
14
14
|
def index
|
|
15
15
|
products = apply_search_to(
|
|
16
|
-
Spree::Product.includes(
|
|
16
|
+
accessible(Spree::Product).includes(
|
|
17
17
|
:variant_images,
|
|
18
18
|
master: :prices,
|
|
19
19
|
variants: :prices,
|
|
@@ -36,6 +36,7 @@ module SolidusAdmin
|
|
|
36
36
|
|
|
37
37
|
def show
|
|
38
38
|
@product = Spree::Product.with_discarded.friendly.find(params[:id])
|
|
39
|
+
authorize! :show, @product
|
|
39
40
|
|
|
40
41
|
respond_to do |format|
|
|
41
42
|
format.html { render component("products/show").new(product: @product) }
|
|
@@ -44,6 +45,7 @@ module SolidusAdmin
|
|
|
44
45
|
|
|
45
46
|
def update
|
|
46
47
|
@product = Spree::Product.friendly.find(params[:id])
|
|
48
|
+
authorize! :update, @product
|
|
47
49
|
|
|
48
50
|
if @product.update(product_params)
|
|
49
51
|
flash[:success] = t(".success")
|
|
@@ -59,6 +61,7 @@ module SolidusAdmin
|
|
|
59
61
|
|
|
60
62
|
def destroy
|
|
61
63
|
@products = Spree::Product.where(id: params[:id])
|
|
64
|
+
authorize_each! @products
|
|
62
65
|
|
|
63
66
|
Spree::Product.transaction do
|
|
64
67
|
@products.discard_all
|
|
@@ -70,6 +73,7 @@ module SolidusAdmin
|
|
|
70
73
|
|
|
71
74
|
def discontinue
|
|
72
75
|
@products = Spree::Product.where(id: params[:id])
|
|
76
|
+
authorize_each! @products
|
|
73
77
|
|
|
74
78
|
Spree::Product.transaction do
|
|
75
79
|
@products
|
|
@@ -82,6 +86,7 @@ module SolidusAdmin
|
|
|
82
86
|
|
|
83
87
|
def activate
|
|
84
88
|
@products = Spree::Product.where(id: params[:id])
|
|
89
|
+
authorize_each! @products
|
|
85
90
|
|
|
86
91
|
Spree::Product.transaction do
|
|
87
92
|
@products
|
|
@@ -32,11 +32,13 @@ module SolidusAdmin
|
|
|
32
32
|
|
|
33
33
|
def new
|
|
34
34
|
@resource ||= resource_class.new
|
|
35
|
+
authorize! :new, @resource
|
|
35
36
|
render new_component.new(@resource)
|
|
36
37
|
end
|
|
37
38
|
|
|
38
39
|
def create
|
|
39
40
|
@resource ||= resource_class.new(permitted_resource_params)
|
|
41
|
+
authorize! :create, @resource
|
|
40
42
|
|
|
41
43
|
if @resource.save
|
|
42
44
|
flash[:notice] = t(".success")
|
|
@@ -73,6 +75,7 @@ module SolidusAdmin
|
|
|
73
75
|
|
|
74
76
|
def destroy
|
|
75
77
|
@resource = resource_class.where(id: params[:id])
|
|
78
|
+
authorize_each! @resource
|
|
76
79
|
|
|
77
80
|
resource_class.transaction { @resource.destroy_all }
|
|
78
81
|
|
|
@@ -92,7 +95,7 @@ module SolidusAdmin
|
|
|
92
95
|
|
|
93
96
|
def set_paginated_resources
|
|
94
97
|
@resources ||= apply_search_to(
|
|
95
|
-
resources_collection,
|
|
98
|
+
accessible(resources_collection),
|
|
96
99
|
param: :q
|
|
97
100
|
).tap do |resources|
|
|
98
101
|
instance_variable_set("@#{plural_resource_name}", resources)
|
|
@@ -114,6 +117,7 @@ module SolidusAdmin
|
|
|
114
117
|
|
|
115
118
|
def set_resource
|
|
116
119
|
@resource ||= resource_class.find(params[:id]).tap do |resource|
|
|
120
|
+
authorize! action_name.to_sym, resource
|
|
117
121
|
instance_variable_set("@#{resource_name}", resource)
|
|
118
122
|
end
|
|
119
123
|
end
|
|
@@ -6,7 +6,7 @@ module SolidusAdmin
|
|
|
6
6
|
|
|
7
7
|
def index
|
|
8
8
|
shipping_methods = apply_search_to(
|
|
9
|
-
Spree::ShippingMethod.order(id: :desc),
|
|
9
|
+
accessible(Spree::ShippingMethod).order(id: :desc),
|
|
10
10
|
param: :q
|
|
11
11
|
)
|
|
12
12
|
|
|
@@ -19,6 +19,7 @@ module SolidusAdmin
|
|
|
19
19
|
|
|
20
20
|
def destroy
|
|
21
21
|
@shipping_methods = Spree::ShippingMethod.where(id: params[:id])
|
|
22
|
+
authorize_each! @shipping_methods
|
|
22
23
|
|
|
23
24
|
Spree::ShippingMethod.transaction { @shipping_methods.destroy_all }
|
|
24
25
|
|
|
@@ -10,6 +10,8 @@ module SolidusAdmin
|
|
|
10
10
|
search_scope(:low_stock) { _1.where("count_on_hand > 0 AND count_on_hand < ?", SolidusAdmin::Config.low_stock_value) }
|
|
11
11
|
search_scope(:in_stock) { _1.where("count_on_hand > 0") }
|
|
12
12
|
|
|
13
|
+
before_action :authorize_stock_item, only: %i[edit update]
|
|
14
|
+
|
|
13
15
|
def index
|
|
14
16
|
respond_to do |format|
|
|
15
17
|
format.html { render component("stock_items/index").new(page: @page) }
|
|
@@ -34,12 +36,16 @@ module SolidusAdmin
|
|
|
34
36
|
def resource_class = Spree::StockItem
|
|
35
37
|
|
|
36
38
|
def resources_collection
|
|
37
|
-
Spree::StockItem.reorder(nil).includes(
|
|
39
|
+
Spree::StockItem.accessible_by(current_ability, action_name.to_sym).reorder(nil).includes(
|
|
38
40
|
:stock_location,
|
|
39
41
|
variant: [:product, :images, {option_values: :option_type}]
|
|
40
42
|
)
|
|
41
43
|
end
|
|
42
44
|
|
|
45
|
+
def authorize_stock_item
|
|
46
|
+
authorize! action_name.to_sym, @stock_item
|
|
47
|
+
end
|
|
48
|
+
|
|
43
49
|
def resources_sorting_options
|
|
44
50
|
{
|
|
45
51
|
variant_id: :desc,
|
|
@@ -9,7 +9,7 @@ module SolidusAdmin
|
|
|
9
9
|
before_action :set_store_credit_categories, only: [:new]
|
|
10
10
|
|
|
11
11
|
def index
|
|
12
|
-
@store_credits =
|
|
12
|
+
@store_credits = accessible(@user.store_credits).order(id: :desc)
|
|
13
13
|
|
|
14
14
|
respond_to do |format|
|
|
15
15
|
format.html { render component("users/store_credits/index").new(user: @user, store_credits: @store_credits) }
|
|
@@ -23,7 +23,8 @@ module SolidusAdmin
|
|
|
23
23
|
end
|
|
24
24
|
|
|
25
25
|
def new
|
|
26
|
-
@store_credit ||= Spree::StoreCredit.new
|
|
26
|
+
@store_credit ||= Spree::StoreCredit.new(user: @user)
|
|
27
|
+
authorize! :new, @store_credit
|
|
27
28
|
|
|
28
29
|
respond_to do |format|
|
|
29
30
|
format.html {
|
|
@@ -43,6 +44,7 @@ module SolidusAdmin
|
|
|
43
44
|
action_originator: spree_current_user
|
|
44
45
|
})
|
|
45
46
|
)
|
|
47
|
+
authorize! :create, @store_credit
|
|
46
48
|
|
|
47
49
|
return unless ensure_amount { render_new_with_errors }
|
|
48
50
|
return unless ensure_store_credit_category { render_new_with_errors }
|
|
@@ -132,7 +134,8 @@ module SolidusAdmin
|
|
|
132
134
|
def resource_class = Spree::StoreCredit
|
|
133
135
|
|
|
134
136
|
def set_store_credit
|
|
135
|
-
@store_credit ||=
|
|
137
|
+
@store_credit ||= @user.store_credits.find(params[:id])
|
|
138
|
+
authorize! action_name.to_sym, @store_credit
|
|
136
139
|
end
|
|
137
140
|
|
|
138
141
|
def set_user
|
|
@@ -6,7 +6,7 @@ module SolidusAdmin
|
|
|
6
6
|
|
|
7
7
|
def index
|
|
8
8
|
stores = apply_search_to(
|
|
9
|
-
Spree::Store.order(id: :desc),
|
|
9
|
+
accessible(Spree::Store).order(id: :desc),
|
|
10
10
|
param: :q
|
|
11
11
|
)
|
|
12
12
|
|
|
@@ -19,6 +19,7 @@ module SolidusAdmin
|
|
|
19
19
|
|
|
20
20
|
def destroy
|
|
21
21
|
@resource = resource_class.where(id: params[:id])
|
|
22
|
+
authorize_each! @resource
|
|
22
23
|
|
|
23
24
|
failed = @resource.destroy_all.reject(&:destroyed?)
|
|
24
25
|
if failed.none?
|
|
@@ -28,7 +29,7 @@ module SolidusAdmin
|
|
|
28
29
|
t ".error.description",
|
|
29
30
|
name: record.name,
|
|
30
31
|
reason: record.errors.full_messages.join(", ")
|
|
31
|
-
}.join("
|
|
32
|
+
}.join("\n")
|
|
32
33
|
|
|
33
34
|
flash[:alert] = {
|
|
34
35
|
danger: {title: t(".error.title"), message: failure_summary}
|
|
@@ -7,7 +7,7 @@ module SolidusAdmin
|
|
|
7
7
|
|
|
8
8
|
def index
|
|
9
9
|
taxonomies = apply_search_to(
|
|
10
|
-
Spree::Taxonomy
|
|
10
|
+
accessible(Spree::Taxonomy),
|
|
11
11
|
param: :q
|
|
12
12
|
)
|
|
13
13
|
|
|
@@ -20,6 +20,7 @@ module SolidusAdmin
|
|
|
20
20
|
|
|
21
21
|
def destroy
|
|
22
22
|
@taxonomies = Spree::Taxonomy.where(id: params[:id])
|
|
23
|
+
authorize_each! @taxonomies
|
|
23
24
|
|
|
24
25
|
Spree::Taxonomy.transaction { @taxonomies.destroy_all }
|
|
25
26
|
|
|
@@ -15,7 +15,7 @@ module SolidusAdmin
|
|
|
15
15
|
|
|
16
16
|
def index
|
|
17
17
|
users = apply_search_to(
|
|
18
|
-
Spree.user_class.order(created_at: :desc, id: :desc),
|
|
18
|
+
accessible(Spree.user_class).order(created_at: :desc, id: :desc),
|
|
19
19
|
param: :q
|
|
20
20
|
)
|
|
21
21
|
|
|
@@ -36,7 +36,7 @@ module SolidusAdmin
|
|
|
36
36
|
def update_addresses
|
|
37
37
|
set_address_from_params
|
|
38
38
|
|
|
39
|
-
if @address.valid? && @user.update(
|
|
39
|
+
if @address.valid? && @user.update(address_params)
|
|
40
40
|
flash[:notice] = t(".#{@type}.success")
|
|
41
41
|
|
|
42
42
|
respond_to do |format|
|
|
@@ -74,6 +74,7 @@ module SolidusAdmin
|
|
|
74
74
|
|
|
75
75
|
def destroy
|
|
76
76
|
@users = Spree.user_class.where(id: params[:id])
|
|
77
|
+
authorize_each! @users
|
|
77
78
|
|
|
78
79
|
Spree.user_class.transaction { @users.destroy_all }
|
|
79
80
|
|
|
@@ -85,12 +86,11 @@ module SolidusAdmin
|
|
|
85
86
|
|
|
86
87
|
def set_user
|
|
87
88
|
@user = Spree.user_class.find(params[:id])
|
|
89
|
+
authorize! action_name.to_sym, @user
|
|
88
90
|
end
|
|
89
91
|
|
|
90
|
-
def
|
|
92
|
+
def address_params
|
|
91
93
|
params.require(:user).permit(
|
|
92
|
-
:user_id,
|
|
93
|
-
permitted_user_attributes,
|
|
94
94
|
bill_address_attributes: permitted_address_attributes,
|
|
95
95
|
ship_address_attributes: permitted_address_attributes
|
|
96
96
|
)
|
|
@@ -100,24 +100,24 @@ module SolidusAdmin
|
|
|
100
100
|
# Since the update is being performed via the @user, and not directly on
|
|
101
101
|
# the @address, we sadly don't seem to get these errors automatically.
|
|
102
102
|
def set_address_from_params
|
|
103
|
-
if
|
|
104
|
-
@address = Spree::Address.new(
|
|
103
|
+
if address_params.key?(:bill_address_attributes)
|
|
104
|
+
@address = Spree::Address.new(address_params[:bill_address_attributes])
|
|
105
105
|
@type = "bill"
|
|
106
|
-
elsif
|
|
107
|
-
@address = Spree::Address.new(
|
|
106
|
+
elsif address_params.key?(:ship_address_attributes)
|
|
107
|
+
@address = Spree::Address.new(address_params[:ship_address_attributes])
|
|
108
108
|
@type = "ship"
|
|
109
109
|
end
|
|
110
110
|
end
|
|
111
111
|
|
|
112
112
|
def set_orders
|
|
113
113
|
params[:q] ||= {}
|
|
114
|
-
@search = Spree::Order.reverse_chronological.ransack(params[:q]
|
|
114
|
+
@search = Spree::Order.where(user_id: @user.id).reverse_chronological.ransack(params[:q])
|
|
115
115
|
@orders = @search.result.page(params[:page]).per(Spree::Config.admin_products_per_page)
|
|
116
116
|
end
|
|
117
117
|
|
|
118
118
|
def set_items
|
|
119
119
|
params[:q] ||= {}
|
|
120
|
-
@search = Spree::Order.reverse_chronological.includes(line_items: {variant: [:product, {option_values: :option_type}]}).ransack(params[:q]
|
|
120
|
+
@search = Spree::Order.where(user_id: @user.id).reverse_chronological.includes(line_items: {variant: [:product, {option_values: :option_type}]}).ransack(params[:q])
|
|
121
121
|
@orders = @search.result.page(params[:page]).per(Spree::Config.admin_products_per_page)
|
|
122
122
|
@items = @orders&.map(&:line_items)&.flatten
|
|
123
123
|
end
|