solidus_admin 0.3.2 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.prettierrc +4 -0
- data/app/assets/builds/solidus_admin/tailwind.css +13 -1
- data/app/components/solidus_admin/adjustment_reasons/edit/component.html.erb +2 -3
- data/app/components/solidus_admin/adjustment_reasons/edit/component.rb +1 -9
- data/app/components/solidus_admin/adjustment_reasons/index/component.rb +22 -8
- data/app/components/solidus_admin/adjustment_reasons/new/component.html.erb +2 -4
- data/app/components/solidus_admin/adjustment_reasons/new/component.rb +1 -9
- data/app/components/solidus_admin/base_component.rb +2 -18
- data/app/components/solidus_admin/layout/navigation/component.js +1 -1
- data/app/components/solidus_admin/orders/index/component.rb +2 -2
- data/app/components/solidus_admin/orders/show/address/component.js +2 -2
- data/app/components/solidus_admin/orders/show/component.js +2 -2
- data/app/components/solidus_admin/orders/show/customer_search/component.js +5 -4
- data/app/components/solidus_admin/orders/show/summary/component.html.erb +6 -6
- data/app/components/solidus_admin/products/show/component.html.erb +7 -1
- data/app/components/solidus_admin/products/show/component.rb +6 -0
- data/app/components/solidus_admin/properties/edit/component.html.erb +16 -0
- data/app/components/solidus_admin/properties/edit/component.rb +4 -0
- data/app/components/solidus_admin/properties/edit/component.yml +4 -0
- data/app/components/solidus_admin/properties/index/component.rb +19 -6
- data/app/components/solidus_admin/properties/new/component.html.erb +16 -0
- data/app/components/solidus_admin/properties/new/component.rb +4 -0
- data/app/components/solidus_admin/properties/new/component.yml +4 -0
- data/app/components/solidus_admin/refund_reasons/edit/component.html.erb +2 -3
- data/app/components/solidus_admin/refund_reasons/edit/component.rb +1 -9
- data/app/components/solidus_admin/refund_reasons/index/component.rb +22 -8
- data/app/components/solidus_admin/refund_reasons/new/component.html.erb +2 -4
- data/app/components/solidus_admin/refund_reasons/new/component.rb +1 -9
- data/app/components/solidus_admin/resources/base_component.rb +20 -0
- data/app/components/solidus_admin/resources/edit/component.rb +11 -0
- data/app/components/solidus_admin/resources/new/component.rb +11 -0
- data/app/components/solidus_admin/return_reasons/edit/component.html.erb +2 -3
- data/app/components/solidus_admin/return_reasons/edit/component.rb +1 -9
- data/app/components/solidus_admin/return_reasons/index/component.rb +13 -7
- data/app/components/solidus_admin/return_reasons/new/component.html.erb +2 -4
- data/app/components/solidus_admin/return_reasons/new/component.rb +1 -9
- data/app/components/solidus_admin/roles/edit/component.html.erb +2 -4
- data/app/components/solidus_admin/roles/edit/component.rb +1 -10
- data/app/components/solidus_admin/roles/index/component.rb +16 -8
- data/app/components/solidus_admin/roles/new/component.html.erb +2 -4
- data/app/components/solidus_admin/roles/new/component.rb +1 -10
- data/app/components/solidus_admin/shipping_categories/edit/component.html.erb +2 -3
- data/app/components/solidus_admin/shipping_categories/edit/component.rb +1 -9
- data/app/components/solidus_admin/shipping_categories/index/component.rb +14 -17
- data/app/components/solidus_admin/shipping_categories/new/component.html.erb +2 -4
- data/app/components/solidus_admin/shipping_categories/new/component.rb +1 -9
- data/app/components/solidus_admin/stock_items/edit/component.html.erb +74 -73
- data/app/components/solidus_admin/stock_items/edit/component.js +4 -3
- data/app/components/solidus_admin/stock_items/edit/component.rb +1 -10
- data/app/components/solidus_admin/stock_items/index/component.rb +9 -5
- data/app/components/solidus_admin/store_credit_reasons/edit/component.html.erb +2 -3
- data/app/components/solidus_admin/store_credit_reasons/edit/component.rb +1 -9
- data/app/components/solidus_admin/store_credit_reasons/index/component.rb +14 -7
- data/app/components/solidus_admin/store_credit_reasons/new/component.html.erb +2 -4
- data/app/components/solidus_admin/store_credit_reasons/new/component.rb +1 -9
- data/app/components/solidus_admin/tax_categories/edit/component.html.erb +2 -4
- data/app/components/solidus_admin/tax_categories/edit/component.rb +1 -9
- data/app/components/solidus_admin/tax_categories/index/component.rb +30 -9
- data/app/components/solidus_admin/tax_categories/new/component.html.erb +2 -4
- data/app/components/solidus_admin/tax_categories/new/component.rb +1 -9
- data/app/components/solidus_admin/ui/dropdown/component.js +3 -3
- data/app/components/solidus_admin/ui/forms/address/component.js +5 -6
- data/app/components/solidus_admin/ui/forms/field/component.rb +1 -1
- data/app/components/solidus_admin/ui/forms/input/component.js +3 -4
- data/app/components/solidus_admin/ui/forms/input/component.rb +15 -4
- data/app/components/solidus_admin/ui/modal/component.js +2 -2
- data/app/components/solidus_admin/ui/pages/index/component.html.erb +3 -3
- data/app/components/solidus_admin/ui/pages/index/component.rb +6 -1
- data/app/components/solidus_admin/ui/table/component.html.erb +4 -3
- data/app/components/solidus_admin/ui/table/component.js +13 -17
- data/app/components/solidus_admin/ui/table/ransack_filter/component.js +18 -16
- data/app/components/solidus_admin/ui/toast/component.js +3 -3
- data/app/components/solidus_admin/ui/toggletip/component.js +14 -12
- data/app/components/solidus_admin/users/orders/component.rb +1 -1
- data/app/components/solidus_admin/users/store_credits/edit_amount/component.html.erb +22 -0
- data/app/components/solidus_admin/users/store_credits/edit_amount/component.rb +22 -0
- data/app/components/solidus_admin/users/store_credits/edit_amount/component.yml +5 -0
- data/app/components/solidus_admin/users/store_credits/edit_memo/component.html.erb +15 -0
- data/app/components/solidus_admin/users/store_credits/edit_memo/component.rb +16 -0
- data/app/components/solidus_admin/users/store_credits/edit_memo/component.yml +4 -0
- data/app/components/solidus_admin/users/store_credits/edit_validity/component.html.erb +21 -0
- data/app/components/solidus_admin/users/store_credits/edit_validity/component.rb +22 -0
- data/app/components/solidus_admin/users/store_credits/edit_validity/component.yml +5 -0
- data/app/components/solidus_admin/users/store_credits/index/component.html.erb +27 -11
- data/app/components/solidus_admin/users/store_credits/index/component.rb +18 -10
- data/app/components/solidus_admin/users/store_credits/new/component.html.erb +30 -0
- data/app/components/solidus_admin/users/store_credits/new/component.rb +22 -0
- data/app/components/solidus_admin/users/store_credits/new/component.yml +5 -0
- data/app/components/solidus_admin/users/store_credits/show/component.html.erb +83 -0
- data/app/components/solidus_admin/users/store_credits/show/component.rb +120 -0
- data/app/components/solidus_admin/users/store_credits/show/component.yml +18 -0
- data/app/controllers/solidus_admin/adjustment_reasons_controller.rb +3 -105
- data/app/controllers/solidus_admin/authentication_adapters/backend.rb +1 -1
- data/app/controllers/solidus_admin/base_controller.rb +12 -1
- data/app/controllers/solidus_admin/properties_controller.rb +6 -24
- data/app/controllers/solidus_admin/refund_reasons_controller.rb +5 -105
- data/app/controllers/solidus_admin/resources_controller.rb +152 -0
- data/app/controllers/solidus_admin/return_reasons_controller.rb +4 -104
- data/app/controllers/solidus_admin/roles_controller.rb +3 -105
- data/app/controllers/solidus_admin/shipping_categories_controller.rb +3 -107
- data/app/controllers/solidus_admin/stock_items_controller.rb +12 -29
- data/app/controllers/solidus_admin/store_credit_reasons_controller.rb +5 -105
- data/app/controllers/solidus_admin/store_credits_controller.rb +231 -0
- data/app/controllers/solidus_admin/tax_categories_controller.rb +3 -109
- data/app/controllers/solidus_admin/users_controller.rb +1 -9
- data/app/helpers/solidus_admin/void_elements_helper.rb +13 -0
- data/app/views/layouts/solidus_admin/application.html.erb +3 -0
- data/config/locales/menu_item.en.yml +0 -1
- data/config/locales/properties.en.yml +4 -0
- data/config/locales/store_credits.en.yml +16 -0
- data/config/routes.rb +12 -2
- data/lib/solidus_admin/configuration.rb +0 -5
- data/lib/solidus_admin/engine.rb +6 -0
- data/lib/solidus_admin/install_tailwindcss.rb +1 -1
- data/lib/solidus_admin/testing_support/component_helpers.rb +3 -9
- data/lib/solidus_admin/testing_support/shared_examples/bulk_delete_resources.rb +20 -0
- data/lib/solidus_admin/testing_support/shared_examples/crud_resource_requests.rb +138 -0
- data/lib/solidus_admin/testing_support/shared_examples/promotion_categories_features.rb +72 -0
- data/lib/solidus_admin/version.rb +1 -1
- metadata +35 -6
@@ -0,0 +1,22 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class SolidusAdmin::Users::StoreCredits::EditAmount::Component < SolidusAdmin::Resources::Edit::Component
|
4
|
+
def initialize(user:, store_credit:, reasons:)
|
5
|
+
@user = user
|
6
|
+
super(store_credit)
|
7
|
+
@store_credit_reasons = reasons
|
8
|
+
end
|
9
|
+
|
10
|
+
def form_id
|
11
|
+
dom_id(@store_credit, "#{stimulus_id}_edit_amount_form")
|
12
|
+
end
|
13
|
+
|
14
|
+
def form_url
|
15
|
+
solidus_admin.update_amount_user_store_credit_path(@user, @store_credit, **search_filter_params)
|
16
|
+
end
|
17
|
+
|
18
|
+
def store_credit_reasons_select_options
|
19
|
+
# Placeholder + Store Credit Reasons
|
20
|
+
"<option value>#{t('.choose_reason')}</option>" + options_from_collection_for_select(@store_credit_reasons, :id, :name)
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
<%= turbo_frame_tag :resource_modal, target: "_top" do %>
|
2
|
+
<%= render component("ui/modal").new(title: t(".title")) do |modal| %>
|
3
|
+
<%= form_for @store_credit, url: form_url, method: :put, html: { id: form_id } do |f| %>
|
4
|
+
<div class="flex flex-col gap-6 pb-4">
|
5
|
+
<%= render component("ui/forms/field").text_field(f, :memo) %>
|
6
|
+
</div>
|
7
|
+
<% modal.with_actions do %>
|
8
|
+
<form method="dialog">
|
9
|
+
<%= render component("ui/button").new(scheme: :secondary, text: t('.cancel')) %>
|
10
|
+
</form>
|
11
|
+
<%= render component("ui/button").new(form: form_id, type: :submit, text: t('.submit')) %>
|
12
|
+
<% end %>
|
13
|
+
<% end %>
|
14
|
+
<% end %>
|
15
|
+
<% end %>
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class SolidusAdmin::Users::StoreCredits::EditMemo::Component < SolidusAdmin::Resources::Edit::Component
|
4
|
+
def initialize(user:, store_credit:)
|
5
|
+
@user = user
|
6
|
+
super(store_credit)
|
7
|
+
end
|
8
|
+
|
9
|
+
def form_id
|
10
|
+
dom_id(@store_credit, "#{stimulus_id}_edit_memo_form")
|
11
|
+
end
|
12
|
+
|
13
|
+
def form_url
|
14
|
+
solidus_admin.update_memo_user_store_credit_path(@user, @store_credit, **search_filter_params)
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
<%= turbo_frame_tag :resource_modal, target: "_top" do %>
|
2
|
+
<%= render component("ui/modal").new(title: t(".title")) do |modal| %>
|
3
|
+
<%= form_for @store_credit, url: form_url, method: :put, html: { id: form_id } do |f| %>
|
4
|
+
<div class="flex flex-col gap-6 pb-4">
|
5
|
+
<%= render component("ui/forms/field").select(
|
6
|
+
f,
|
7
|
+
:store_credit_reason_id,
|
8
|
+
store_credit_reasons_select_options.html_safe,
|
9
|
+
include_blank: t('spree.choose_reason'),
|
10
|
+
html: { required: true }
|
11
|
+
) %>
|
12
|
+
</div>
|
13
|
+
<% modal.with_actions do %>
|
14
|
+
<form method="dialog">
|
15
|
+
<%= render component("ui/button").new(scheme: :secondary, text: t('.cancel')) %>
|
16
|
+
</form>
|
17
|
+
<%= render component("ui/button").new(form: form_id, scheme: :danger, type: :submit, text: t('.submit')) %>
|
18
|
+
<% end %>
|
19
|
+
<% end %>
|
20
|
+
<% end %>
|
21
|
+
<% end %>
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class SolidusAdmin::Users::StoreCredits::EditValidity::Component < SolidusAdmin::Resources::Edit::Component
|
4
|
+
def initialize(user:, store_credit:, reasons:)
|
5
|
+
@user = user
|
6
|
+
super(store_credit)
|
7
|
+
@store_credit_reasons = reasons
|
8
|
+
end
|
9
|
+
|
10
|
+
def form_id
|
11
|
+
dom_id(@store_credit, "#{stimulus_id}_edit_validity_form")
|
12
|
+
end
|
13
|
+
|
14
|
+
def form_url
|
15
|
+
solidus_admin.invalidate_user_store_credit_path(@user, @store_credit, **search_filter_params)
|
16
|
+
end
|
17
|
+
|
18
|
+
def store_credit_reasons_select_options
|
19
|
+
# Placeholder + Store Credit Reasons
|
20
|
+
"<option value>#{t('.choose_reason')}</option>" + options_from_collection_for_select(@store_credit_reasons, :id, :name)
|
21
|
+
end
|
22
|
+
end
|
@@ -4,7 +4,15 @@
|
|
4
4
|
<%= page_header_title(t(".title", email: @user.email)) %>
|
5
5
|
|
6
6
|
<%= page_header_actions do %>
|
7
|
-
<%= render component("ui/button").new(
|
7
|
+
<%= render component("ui/button").new(
|
8
|
+
tag: :a,
|
9
|
+
href: new_store_credit_path,
|
10
|
+
data: {
|
11
|
+
turbo_frame: :resource_modal
|
12
|
+
},
|
13
|
+
text: t(".add_store_credit"),
|
14
|
+
icon: "add-line"
|
15
|
+
)%>
|
8
16
|
<% end %>
|
9
17
|
<% end %>
|
10
18
|
|
@@ -23,21 +31,27 @@
|
|
23
31
|
|
24
32
|
<%= render component('ui/panel').new(title: title) do %>
|
25
33
|
<%= render component('ui/table').new(
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
)%>
|
34
|
+
id: stimulus_id,
|
35
|
+
data: {
|
36
|
+
class: model_class,
|
37
|
+
rows: credits,
|
38
|
+
fade: -> (_order) { false },
|
39
|
+
columns: columns
|
40
|
+
}
|
41
|
+
) %>
|
35
42
|
<% end %>
|
36
43
|
<% end %>
|
37
44
|
<% else %>
|
38
45
|
<%= render component('ui/panel').new(title: t(".store_credit")) do %>
|
39
46
|
<%= t(".no_credits_found") %>
|
40
|
-
<%= render component("ui/button").new(
|
47
|
+
<%= render component("ui/button").new(
|
48
|
+
tag: :a,
|
49
|
+
data: {
|
50
|
+
turbo_frame: :resource_modal
|
51
|
+
},
|
52
|
+
href: new_store_credit_path,
|
53
|
+
text: t(".create_one"),
|
54
|
+
)%>
|
41
55
|
<% end %>
|
42
56
|
<% end %>
|
43
57
|
<% end %>
|
@@ -46,4 +60,6 @@
|
|
46
60
|
<%= render component("users/stats").new(user: @user) %>
|
47
61
|
<% end %>
|
48
62
|
<% end %>
|
63
|
+
|
64
|
+
<%= turbo_frame_tag :resource_modal, target: "_top" %>
|
49
65
|
<% end %>
|
@@ -36,7 +36,7 @@ class SolidusAdmin::Users::StoreCredits::Index::Component < SolidusAdmin::BaseCo
|
|
36
36
|
},
|
37
37
|
{
|
38
38
|
text: t('.store_credit'),
|
39
|
-
href: solidus_admin.
|
39
|
+
href: solidus_admin.user_store_credits_path(@user),
|
40
40
|
current: true,
|
41
41
|
},
|
42
42
|
]
|
@@ -46,8 +46,12 @@ class SolidusAdmin::Users::StoreCredits::Index::Component < SolidusAdmin::BaseCo
|
|
46
46
|
@store_credits
|
47
47
|
end
|
48
48
|
|
49
|
-
def
|
50
|
-
|
49
|
+
def show_path(store_credit)
|
50
|
+
solidus_admin.user_store_credit_path(@user, store_credit)
|
51
|
+
end
|
52
|
+
|
53
|
+
def new_store_credit_path
|
54
|
+
solidus_admin.new_user_store_credit_path(user_id: @user.id)
|
51
55
|
end
|
52
56
|
|
53
57
|
def columns
|
@@ -56,21 +60,21 @@ class SolidusAdmin::Users::StoreCredits::Index::Component < SolidusAdmin::BaseCo
|
|
56
60
|
header: :credited,
|
57
61
|
col: { class: "w-[12%]" },
|
58
62
|
data: ->(store_credit) do
|
59
|
-
|
63
|
+
link_to store_credit.display_amount.to_html, show_path(store_credit), class: "body-link text-sm"
|
60
64
|
end
|
61
65
|
},
|
62
66
|
{
|
63
67
|
header: :authorized,
|
64
68
|
col: { class: "w-[13%]" },
|
65
69
|
data: ->(store_credit) do
|
66
|
-
|
70
|
+
link_to store_credit.display_amount_authorized.to_html, show_path(store_credit), class: "body-link text-sm"
|
67
71
|
end
|
68
72
|
},
|
69
73
|
{
|
70
74
|
header: :used,
|
71
75
|
col: { class: "w-[9%]" },
|
72
76
|
data: ->(store_credit) do
|
73
|
-
|
77
|
+
link_to store_credit.display_amount_used.to_html, show_path(store_credit), class: "body-link text-sm"
|
74
78
|
end
|
75
79
|
},
|
76
80
|
{
|
@@ -84,23 +88,27 @@ class SolidusAdmin::Users::StoreCredits::Index::Component < SolidusAdmin::BaseCo
|
|
84
88
|
header: :created_by,
|
85
89
|
col: { class: "w-[22%]" },
|
86
90
|
data: ->(store_credit) do
|
87
|
-
content_tag :div, store_credit.created_by_email, class: "
|
91
|
+
content_tag :div, store_credit.created_by_email, class: "text-sm"
|
88
92
|
end
|
89
93
|
},
|
90
94
|
{
|
91
95
|
header: :issued_on,
|
92
96
|
col: { class: "w-[16%]" },
|
93
97
|
data: ->(store_credit) do
|
94
|
-
I18n.l(store_credit.created_at.to_date)
|
98
|
+
content_tag :span, I18n.l(store_credit.created_at.to_date), class: "text-sm"
|
95
99
|
end
|
96
100
|
},
|
97
101
|
{
|
98
102
|
header: :invalidated,
|
99
103
|
col: { class: "w-[15%]" },
|
100
104
|
data: ->(store_credit) do
|
101
|
-
store_credit.invalidated?
|
105
|
+
if store_credit.invalidated?
|
106
|
+
component('ui/badge').new(name: :yes, color: :red, size: :m)
|
107
|
+
else
|
108
|
+
component('ui/badge').new(name: :no, color: :green, size: :m)
|
109
|
+
end
|
102
110
|
end
|
103
|
-
}
|
111
|
+
}
|
104
112
|
]
|
105
113
|
end
|
106
114
|
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
<%= turbo_frame_tag :resource_modal, target: "_top" do %>
|
2
|
+
<%= render component("ui/modal").new(title: t(".title")) do |modal| %>
|
3
|
+
<%= form_for @store_credit, url: form_url, method: :post, html: { id: form_id } do |f| %>
|
4
|
+
<div class="flex flex-col gap-6 pb-4">
|
5
|
+
<%= render component("ui/forms/field").text_field(f, :amount, class: "required") %>
|
6
|
+
<%= render component("ui/forms/field").select(
|
7
|
+
f,
|
8
|
+
:currency,
|
9
|
+
currency_select_options.html_safe,
|
10
|
+
include_blank: t("spree.currency"),
|
11
|
+
html: { required: true }
|
12
|
+
) %>
|
13
|
+
<%= render component("ui/forms/field").select(
|
14
|
+
f,
|
15
|
+
:category_id,
|
16
|
+
store_credit_categories_select_options.html_safe,
|
17
|
+
include_blank: t("spree.category"),
|
18
|
+
html: { required: true }
|
19
|
+
) %>
|
20
|
+
<%= render component("ui/forms/field").text_field(f, :memo) %>
|
21
|
+
</div>
|
22
|
+
<% modal.with_actions do %>
|
23
|
+
<form method="dialog">
|
24
|
+
<%= render component("ui/button").new(scheme: :secondary, text: t(".cancel")) %>
|
25
|
+
</form>
|
26
|
+
<%= render component("ui/button").new(form: form_id, type: :submit, text: t(".submit")) %>
|
27
|
+
<% end %>
|
28
|
+
<% end %>
|
29
|
+
<% end %>
|
30
|
+
<% end %>
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class SolidusAdmin::Users::StoreCredits::New::Component < SolidusAdmin::Resources::New::Component
|
4
|
+
def initialize(user:, store_credit:, categories:)
|
5
|
+
@user = user
|
6
|
+
super(store_credit)
|
7
|
+
@store_credit_categories = categories
|
8
|
+
end
|
9
|
+
|
10
|
+
def form_url
|
11
|
+
solidus_admin.user_store_credits_path(@user, **search_filter_params)
|
12
|
+
end
|
13
|
+
|
14
|
+
def currency_select_options
|
15
|
+
options_from_collection_for_select(Spree::Config.available_currencies, :iso_code, :iso_code, Spree::Config.currency)
|
16
|
+
end
|
17
|
+
|
18
|
+
def store_credit_categories_select_options
|
19
|
+
# Placeholder + Store Credit Categories
|
20
|
+
"<option value>#{t('.choose_category')}</option>" + options_from_collection_for_select(@store_credit_categories, :id, :name)
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,83 @@
|
|
1
|
+
<%= page do %>
|
2
|
+
<%= page_header do %>
|
3
|
+
<%= page_header_back(solidus_admin.users_path) %>
|
4
|
+
<%= page_header_title(t(".title", email: @user.email, amount: @store_credit.display_amount)) %>
|
5
|
+
<% end %>
|
6
|
+
|
7
|
+
<%= page_header do %>
|
8
|
+
<% tabs.each do |tab| %>
|
9
|
+
<%= render(component("ui/button").new(tag: :a, scheme: :ghost, text: tab[:text], 'aria-current': tab[:current], href: tab[:href])) %>
|
10
|
+
<% end %>
|
11
|
+
<% end %>
|
12
|
+
|
13
|
+
<%= page_with_sidebar do %>
|
14
|
+
<%= page_with_sidebar_main do %>
|
15
|
+
<%= render component('ui/panel').new(title: t(".store_credit")) do |panel| %>
|
16
|
+
<% panel.with_section do %>
|
17
|
+
<%= render component('ui/details_list').new(
|
18
|
+
items: [
|
19
|
+
{ label: t('.credited'), value: @store_credit.display_amount },
|
20
|
+
{ label: t('.created_by'), value: @store_credit.created_by_email },
|
21
|
+
{ label: t('.type'), value: @store_credit.category_name },
|
22
|
+
{ label: t('.memo'), value: @store_credit.memo }
|
23
|
+
]
|
24
|
+
) %>
|
25
|
+
<% end %>
|
26
|
+
|
27
|
+
<% panel.with_section do %>
|
28
|
+
<div class="w-[100%] text-right">
|
29
|
+
<% if @store_credit.invalidateable? %>
|
30
|
+
<%= render component("ui/button").new(
|
31
|
+
tag: :a,
|
32
|
+
scheme: :danger,
|
33
|
+
data: {
|
34
|
+
turbo_frame: :resource_modal
|
35
|
+
},
|
36
|
+
href: edit_validity_url,
|
37
|
+
text: t(".invalidate"),
|
38
|
+
) %>
|
39
|
+
<% end %>
|
40
|
+
|
41
|
+
<%= render component("ui/button").new(
|
42
|
+
tag: :a,
|
43
|
+
data: {
|
44
|
+
turbo_frame: :resource_modal
|
45
|
+
},
|
46
|
+
href: edit_memo_url,
|
47
|
+
text: t(".edit_memo"),
|
48
|
+
) %>
|
49
|
+
|
50
|
+
<% if @store_credit.editable? %>
|
51
|
+
<%= render component("ui/button").new(
|
52
|
+
tag: :a,
|
53
|
+
data: {
|
54
|
+
turbo_frame: :resource_modal
|
55
|
+
},
|
56
|
+
href: edit_amount_url,
|
57
|
+
text: t(".edit_amount"),
|
58
|
+
) %>
|
59
|
+
<% end %>
|
60
|
+
</div>
|
61
|
+
<% end %>
|
62
|
+
<% end %>
|
63
|
+
|
64
|
+
<% if @events.present? %>
|
65
|
+
<h1 class="font-semibold text-base text-center w-[100%]"><%= t(".store_credit_history") %></h1>
|
66
|
+
<%= render component('ui/table').new(
|
67
|
+
id: stimulus_id,
|
68
|
+
data: {
|
69
|
+
class: event_model_class,
|
70
|
+
rows: @events,
|
71
|
+
columns: columns,
|
72
|
+
},
|
73
|
+
)%>
|
74
|
+
<% end %>
|
75
|
+
<% end %>
|
76
|
+
|
77
|
+
<%= page_with_sidebar_aside do %>
|
78
|
+
<%= render component("users/stats").new(user: @user) %>
|
79
|
+
<% end %>
|
80
|
+
<% end %>
|
81
|
+
|
82
|
+
<%= turbo_frame_tag :resource_modal, target: "_top" %>
|
83
|
+
<% end %>
|
@@ -0,0 +1,120 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class SolidusAdmin::Users::StoreCredits::Show::Component < SolidusAdmin::BaseComponent
|
4
|
+
include SolidusAdmin::Layout::PageHelpers
|
5
|
+
include Spree::Admin::StoreCreditEventsHelper
|
6
|
+
|
7
|
+
def initialize(user:, store_credit:, events:)
|
8
|
+
@user = user
|
9
|
+
@store_credit = store_credit
|
10
|
+
@events = events
|
11
|
+
end
|
12
|
+
|
13
|
+
def model_class
|
14
|
+
Spree::StoreCredit
|
15
|
+
end
|
16
|
+
|
17
|
+
def event_model_class
|
18
|
+
Spree::StoreCreditEvent
|
19
|
+
end
|
20
|
+
|
21
|
+
def tabs
|
22
|
+
[
|
23
|
+
{
|
24
|
+
text: t('.account'),
|
25
|
+
href: solidus_admin.user_path(@user),
|
26
|
+
current: false,
|
27
|
+
},
|
28
|
+
{
|
29
|
+
text: t('.addresses'),
|
30
|
+
href: solidus_admin.addresses_user_path(@user),
|
31
|
+
current: false,
|
32
|
+
},
|
33
|
+
{
|
34
|
+
text: t('.order_history'),
|
35
|
+
href: solidus_admin.orders_user_path(@user),
|
36
|
+
current: false,
|
37
|
+
},
|
38
|
+
{
|
39
|
+
text: t('.items'),
|
40
|
+
href: spree.items_admin_user_path(@user),
|
41
|
+
current: false,
|
42
|
+
},
|
43
|
+
{
|
44
|
+
text: t('.store_credit'),
|
45
|
+
href: solidus_admin.user_store_credits_path(@user),
|
46
|
+
current: true,
|
47
|
+
},
|
48
|
+
]
|
49
|
+
end
|
50
|
+
|
51
|
+
def form_id
|
52
|
+
@form_id ||= "#{stimulus_id}--form-#{@store_credit.id}"
|
53
|
+
end
|
54
|
+
|
55
|
+
def edit_validity_url
|
56
|
+
solidus_admin.edit_validity_user_store_credit_path(@user, @store_credit, **search_filter_params)
|
57
|
+
end
|
58
|
+
|
59
|
+
def edit_memo_url
|
60
|
+
solidus_admin.edit_memo_user_store_credit_path(@user, @store_credit, **search_filter_params)
|
61
|
+
end
|
62
|
+
|
63
|
+
def edit_amount_url
|
64
|
+
solidus_admin.edit_amount_user_store_credit_path(@user, @store_credit, **search_filter_params)
|
65
|
+
end
|
66
|
+
|
67
|
+
def columns
|
68
|
+
[
|
69
|
+
{
|
70
|
+
header: :date,
|
71
|
+
col: { class: "w-[15%]" },
|
72
|
+
data: ->(event) do
|
73
|
+
content_tag :span, I18n.l(event.created_at, format: :short), class: "text-sm"
|
74
|
+
end
|
75
|
+
},
|
76
|
+
{
|
77
|
+
header: :action,
|
78
|
+
col: { class: "w-[10%]" },
|
79
|
+
data: ->(event) do
|
80
|
+
content_tag :span, store_credit_event_admin_action_name(event), class: "text-sm"
|
81
|
+
end
|
82
|
+
},
|
83
|
+
{
|
84
|
+
header: :credited,
|
85
|
+
col: { class: "w-[10%]" },
|
86
|
+
data: ->(event) do
|
87
|
+
content_tag :span, event.display_amount, class: "text-sm"
|
88
|
+
end
|
89
|
+
},
|
90
|
+
{
|
91
|
+
header: :created_by,
|
92
|
+
col: { class: "w-[20%]" },
|
93
|
+
data: ->(event) do
|
94
|
+
content_tag :span, store_credit_event_originator_link(event), class: "body-link text-sm"
|
95
|
+
end
|
96
|
+
},
|
97
|
+
{
|
98
|
+
header: :total_amount,
|
99
|
+
col: { class: "w-[10%]" },
|
100
|
+
data: ->(event) do
|
101
|
+
content_tag :span, event.display_user_total_amount, class: "text-sm"
|
102
|
+
end
|
103
|
+
},
|
104
|
+
{
|
105
|
+
header: :total_unused,
|
106
|
+
col: { class: "w-[10%]" },
|
107
|
+
data: ->(event) do
|
108
|
+
content_tag :span, event.display_remaining_amount, class: "text-sm"
|
109
|
+
end
|
110
|
+
},
|
111
|
+
{
|
112
|
+
header: :reason_for_updating,
|
113
|
+
col: { class: "w-[25%]" },
|
114
|
+
data: ->(event) do
|
115
|
+
content_tag :span, event.store_credit_reason&.name, class: "text-sm"
|
116
|
+
end
|
117
|
+
},
|
118
|
+
]
|
119
|
+
end
|
120
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
en:
|
2
|
+
title: "Users / %{email} / Store Credit / %{amount}"
|
3
|
+
account: Account
|
4
|
+
addresses: Addresses
|
5
|
+
order_history: Order History
|
6
|
+
items: Items
|
7
|
+
store_credit: Store Credit
|
8
|
+
last_active: Last Active
|
9
|
+
add_store_credit: Add Store Credit
|
10
|
+
edit_amount: Edit Amount
|
11
|
+
edit_memo: Edit Memo
|
12
|
+
invalidate: Invalidate
|
13
|
+
store_credit_history: Store Credit History
|
14
|
+
credited: Credited
|
15
|
+
created_by: Created By
|
16
|
+
type: Type
|
17
|
+
memo: Memo
|
18
|
+
back: Back
|
@@ -1,115 +1,13 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module SolidusAdmin
|
4
|
-
class AdjustmentReasonsController < SolidusAdmin::
|
5
|
-
include SolidusAdmin::ControllerHelpers::Search
|
6
|
-
|
7
|
-
before_action :set_adjustment_reason, only: %i[edit update]
|
8
|
-
|
9
|
-
def index
|
10
|
-
set_index_page
|
11
|
-
|
12
|
-
respond_to do |format|
|
13
|
-
format.html { render component('adjustment_reasons/index').new(page: @page) }
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
def new
|
18
|
-
@adjustment_reason = Spree::AdjustmentReason.new
|
19
|
-
|
20
|
-
set_index_page
|
21
|
-
|
22
|
-
respond_to do |format|
|
23
|
-
format.html { render component('adjustment_reasons/new').new(page: @page, adjustment_reason: @adjustment_reason) }
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
def create
|
28
|
-
@adjustment_reason = Spree::AdjustmentReason.new(adjustment_reason_params)
|
29
|
-
|
30
|
-
if @adjustment_reason.save
|
31
|
-
respond_to do |format|
|
32
|
-
flash[:notice] = t('.success')
|
33
|
-
|
34
|
-
format.html do
|
35
|
-
redirect_to solidus_admin.adjustment_reasons_path, status: :see_other
|
36
|
-
end
|
37
|
-
|
38
|
-
format.turbo_stream do
|
39
|
-
render turbo_stream: '<turbo-stream action="refresh" />'
|
40
|
-
end
|
41
|
-
end
|
42
|
-
else
|
43
|
-
set_index_page
|
44
|
-
|
45
|
-
respond_to do |format|
|
46
|
-
format.html do
|
47
|
-
page_component = component('adjustment_reasons/new').new(page: @page, adjustment_reason: @adjustment_reason)
|
48
|
-
render page_component, status: :unprocessable_entity
|
49
|
-
end
|
50
|
-
end
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
54
|
-
def edit
|
55
|
-
set_index_page
|
56
|
-
|
57
|
-
respond_to do |format|
|
58
|
-
format.html { render component('adjustment_reasons/edit').new(page: @page, adjustment_reason: @adjustment_reason) }
|
59
|
-
end
|
60
|
-
end
|
61
|
-
|
62
|
-
def update
|
63
|
-
if @adjustment_reason.update(adjustment_reason_params)
|
64
|
-
respond_to do |format|
|
65
|
-
flash[:notice] = t('.success')
|
66
|
-
|
67
|
-
format.html do
|
68
|
-
redirect_to solidus_admin.adjustment_reasons_path, status: :see_other
|
69
|
-
end
|
70
|
-
|
71
|
-
format.turbo_stream do
|
72
|
-
render turbo_stream: '<turbo-stream action="refresh" />'
|
73
|
-
end
|
74
|
-
end
|
75
|
-
else
|
76
|
-
set_index_page
|
77
|
-
|
78
|
-
respond_to do |format|
|
79
|
-
format.html do
|
80
|
-
page_component = component('adjustment_reasons/edit').new(page: @page, adjustment_reason: @adjustment_reason)
|
81
|
-
render page_component, status: :unprocessable_entity
|
82
|
-
end
|
83
|
-
end
|
84
|
-
end
|
85
|
-
end
|
86
|
-
|
87
|
-
def destroy
|
88
|
-
@adjustment_reason = Spree::AdjustmentReason.find_by!(id: params[:id])
|
89
|
-
|
90
|
-
Spree::AdjustmentReason.transaction { @adjustment_reason.destroy }
|
91
|
-
|
92
|
-
flash[:notice] = t('.success')
|
93
|
-
redirect_back_or_to adjustment_reasons_path, status: :see_other
|
94
|
-
end
|
95
|
-
|
4
|
+
class AdjustmentReasonsController < SolidusAdmin::ResourcesController
|
96
5
|
private
|
97
6
|
|
98
|
-
def
|
99
|
-
@adjustment_reason = Spree::AdjustmentReason.find(params[:id])
|
100
|
-
end
|
7
|
+
def resource_class = Spree::AdjustmentReason
|
101
8
|
|
102
|
-
def
|
9
|
+
def permitted_resource_params
|
103
10
|
params.require(:adjustment_reason).permit(:name, :code, :active)
|
104
11
|
end
|
105
|
-
|
106
|
-
def set_index_page
|
107
|
-
adjustment_reasons = apply_search_to(
|
108
|
-
Spree::AdjustmentReason.order(id: :desc),
|
109
|
-
param: :q,
|
110
|
-
)
|
111
|
-
|
112
|
-
set_page_and_extract_portion_from(adjustment_reasons)
|
113
|
-
end
|
114
12
|
end
|
115
13
|
end
|
@@ -13,7 +13,7 @@ module SolidusAdmin::AuthenticationAdapters::Backend
|
|
13
13
|
def authenticate_solidus_backend_user!
|
14
14
|
return if spree_current_user
|
15
15
|
|
16
|
-
|
16
|
+
Spree::Backend::Config.unauthorized_redirect_handler_class.new(self).call
|
17
17
|
end
|
18
18
|
|
19
19
|
def store_location
|