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
@@ -9,7 +9,8 @@ class SolidusAdmin::StoreCreditReasons::Index::Component < SolidusAdmin::Refunds
|
|
9
9
|
render component("ui/button").new(
|
10
10
|
tag: :a,
|
11
11
|
text: t('.add'),
|
12
|
-
href: solidus_admin.new_store_credit_reason_path,
|
12
|
+
href: solidus_admin.new_store_credit_reason_path(**search_filter_params),
|
13
|
+
data: { turbo_frame: :resource_modal },
|
13
14
|
icon: "add-line",
|
14
15
|
class: "align-self-end w-full",
|
15
16
|
)
|
@@ -17,13 +18,12 @@ class SolidusAdmin::StoreCreditReasons::Index::Component < SolidusAdmin::Refunds
|
|
17
18
|
|
18
19
|
def turbo_frames
|
19
20
|
%w[
|
20
|
-
|
21
|
-
edit_store_credit_reason_modal
|
21
|
+
resource_modal
|
22
22
|
]
|
23
23
|
end
|
24
24
|
|
25
|
-
def
|
26
|
-
spree.edit_admin_store_credit_reason_path(store_credit_reason,
|
25
|
+
def edit_path(store_credit_reason)
|
26
|
+
spree.edit_admin_store_credit_reason_path(store_credit_reason, **search_filter_params)
|
27
27
|
end
|
28
28
|
|
29
29
|
def search_url
|
@@ -38,7 +38,7 @@ class SolidusAdmin::StoreCreditReasons::Index::Component < SolidusAdmin::Refunds
|
|
38
38
|
[
|
39
39
|
{
|
40
40
|
label: t('.batch_actions.delete'),
|
41
|
-
action: solidus_admin.store_credit_reasons_path,
|
41
|
+
action: solidus_admin.store_credit_reasons_path(**search_filter_params),
|
42
42
|
method: :delete,
|
43
43
|
icon: 'delete-bin-7-line',
|
44
44
|
},
|
@@ -47,7 +47,14 @@ class SolidusAdmin::StoreCreditReasons::Index::Component < SolidusAdmin::Refunds
|
|
47
47
|
|
48
48
|
def columns
|
49
49
|
[
|
50
|
-
|
50
|
+
{
|
51
|
+
header: :name,
|
52
|
+
data: ->(store_credit_reason) do
|
53
|
+
link_to store_credit_reason.name, edit_path(store_credit_reason),
|
54
|
+
data: { turbo_frame: :resource_modal },
|
55
|
+
class: 'body-link'
|
56
|
+
end
|
57
|
+
},
|
51
58
|
{
|
52
59
|
header: :active,
|
53
60
|
data: ->(store_credit_reason) do
|
@@ -1,6 +1,6 @@
|
|
1
|
-
<%= turbo_frame_tag :
|
1
|
+
<%= turbo_frame_tag :resource_modal, target: "_top" do %>
|
2
2
|
<%= render component("ui/modal").new(title: t(".title")) do |modal| %>
|
3
|
-
<%= form_for @store_credit_reason, url:
|
3
|
+
<%= form_for @store_credit_reason, url: form_url, html: { id: form_id } do |f| %>
|
4
4
|
<div class="flex flex-col gap-6 pb-4">
|
5
5
|
<%= render component("ui/forms/field").text_field(f, :name, class: "required") %>
|
6
6
|
<label class="flex gap-2 items-center">
|
@@ -23,5 +23,3 @@
|
|
23
23
|
<% end %>
|
24
24
|
<% end %>
|
25
25
|
<% end %>
|
26
|
-
|
27
|
-
<%= render component("store_credit_reasons/index").new(page: @page) %>
|
@@ -1,12 +1,4 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
class SolidusAdmin::StoreCreditReasons::New::Component < SolidusAdmin::
|
4
|
-
def initialize(page:, store_credit_reason:)
|
5
|
-
@page = page
|
6
|
-
@store_credit_reason = store_credit_reason
|
7
|
-
end
|
8
|
-
|
9
|
-
def form_id
|
10
|
-
dom_id(@store_credit_reason, "#{stimulus_id}_new_store_credit_reason_form")
|
11
|
-
end
|
3
|
+
class SolidusAdmin::StoreCreditReasons::New::Component < SolidusAdmin::Resources::New::Component
|
12
4
|
end
|
@@ -1,6 +1,6 @@
|
|
1
|
-
<%= turbo_frame_tag :
|
1
|
+
<%= turbo_frame_tag :resource_modal, target: "_top" do %>
|
2
2
|
<%= render component("ui/modal").new(title: t(".title")) do |modal| %>
|
3
|
-
<%= form_for @tax_category, url:
|
3
|
+
<%= form_for @tax_category, url: form_url, html: { id: form_id } do |f| %>
|
4
4
|
<div class="flex flex-col gap-6 pb-4">
|
5
5
|
<%= render component("ui/forms/field").text_field(f, :name) %>
|
6
6
|
<%= render component("ui/forms/field").text_field(f, :tax_code) %>
|
@@ -24,5 +24,3 @@
|
|
24
24
|
<% end %>
|
25
25
|
<% end %>
|
26
26
|
<% end %>
|
27
|
-
|
28
|
-
<%= render component("tax_categories/index").new(page: @page) %>
|
@@ -1,12 +1,4 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
class SolidusAdmin::TaxCategories::Edit::Component < SolidusAdmin::
|
4
|
-
def initialize(page:, tax_category:)
|
5
|
-
@page = page
|
6
|
-
@tax_category = tax_category
|
7
|
-
end
|
8
|
-
|
9
|
-
def form_id
|
10
|
-
dom_id(@tax_category, "#{stimulus_id}_edit_tax_category_form")
|
11
|
-
end
|
3
|
+
class SolidusAdmin::TaxCategories::Edit::Component < SolidusAdmin::Resources::Edit::Component
|
12
4
|
end
|
@@ -1,8 +1,8 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
class SolidusAdmin::TaxCategories::Index::Component < SolidusAdmin::Taxes::Component
|
4
|
-
def
|
5
|
-
spree.edit_admin_tax_category_path(tax_category,
|
4
|
+
def edit_path(tax_category)
|
5
|
+
spree.edit_admin_tax_category_path(tax_category, **search_filter_params)
|
6
6
|
end
|
7
7
|
|
8
8
|
def model_class
|
@@ -17,7 +17,8 @@ class SolidusAdmin::TaxCategories::Index::Component < SolidusAdmin::Taxes::Compo
|
|
17
17
|
render component("ui/button").new(
|
18
18
|
tag: :a,
|
19
19
|
text: t('.add'),
|
20
|
-
href: solidus_admin.new_tax_category_path,
|
20
|
+
href: solidus_admin.new_tax_category_path(**search_filter_params),
|
21
|
+
data: { turbo_frame: :resource_modal },
|
21
22
|
icon: "add-line",
|
22
23
|
class: "align-self-end w-full",
|
23
24
|
)
|
@@ -25,8 +26,7 @@ class SolidusAdmin::TaxCategories::Index::Component < SolidusAdmin::Taxes::Compo
|
|
25
26
|
|
26
27
|
def turbo_frames
|
27
28
|
%w[
|
28
|
-
|
29
|
-
edit_tax_category_modal
|
29
|
+
resource_modal
|
30
30
|
]
|
31
31
|
end
|
32
32
|
|
@@ -38,7 +38,7 @@ class SolidusAdmin::TaxCategories::Index::Component < SolidusAdmin::Taxes::Compo
|
|
38
38
|
[
|
39
39
|
{
|
40
40
|
label: t('.batch_actions.delete'),
|
41
|
-
action: solidus_admin.tax_categories_path,
|
41
|
+
action: solidus_admin.tax_categories_path(**search_filter_params),
|
42
42
|
method: :delete,
|
43
43
|
icon: 'delete-bin-7-line',
|
44
44
|
},
|
@@ -47,9 +47,30 @@ class SolidusAdmin::TaxCategories::Index::Component < SolidusAdmin::Taxes::Compo
|
|
47
47
|
|
48
48
|
def columns
|
49
49
|
[
|
50
|
-
|
51
|
-
|
52
|
-
|
50
|
+
{
|
51
|
+
header: :name,
|
52
|
+
data: ->(tax_category) do
|
53
|
+
link_to tax_category.name, edit_path(tax_category),
|
54
|
+
data: { turbo_frame: :resource_modal },
|
55
|
+
class: 'body-link'
|
56
|
+
end
|
57
|
+
},
|
58
|
+
{
|
59
|
+
header: :tax_code,
|
60
|
+
data: ->(tax_category) do
|
61
|
+
link_to_if tax_category.tax_code, tax_category.tax_code, edit_path(tax_category),
|
62
|
+
data: { turbo_frame: :resource_modal },
|
63
|
+
class: 'body-link'
|
64
|
+
end
|
65
|
+
},
|
66
|
+
{
|
67
|
+
header: :description,
|
68
|
+
data: ->(tax_category) do
|
69
|
+
link_to_if tax_category.description, tax_category.description, edit_path(tax_category),
|
70
|
+
data: { turbo_frame: :resource_modal },
|
71
|
+
class: 'body-link'
|
72
|
+
end
|
73
|
+
},
|
53
74
|
{
|
54
75
|
header: :is_default,
|
55
76
|
data: ->(tax_category) {
|
@@ -1,6 +1,6 @@
|
|
1
|
-
<%= turbo_frame_tag :
|
1
|
+
<%= turbo_frame_tag :resource_modal, target: "_top" do %>
|
2
2
|
<%= render component("ui/modal").new(title: t(".title")) do |modal| %>
|
3
|
-
<%= form_for @tax_category, url:
|
3
|
+
<%= form_for @tax_category, url: form_url, html: { id: form_id } do |f| %>
|
4
4
|
<div class="flex flex-col gap-6 pb-4">
|
5
5
|
<%= render component("ui/forms/field").text_field(f, :name) %>
|
6
6
|
<%= render component("ui/forms/field").text_field(f, :tax_code) %>
|
@@ -24,5 +24,3 @@
|
|
24
24
|
<% end %>
|
25
25
|
<% end %>
|
26
26
|
<% end %>
|
27
|
-
|
28
|
-
<%= render component("tax_categories/index").new(page: @page) %>
|
@@ -1,12 +1,4 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
class SolidusAdmin::TaxCategories::New::Component < SolidusAdmin::
|
4
|
-
def initialize(page:, tax_category:)
|
5
|
-
@page = page
|
6
|
-
@tax_category = tax_category
|
7
|
-
end
|
8
|
-
|
9
|
-
def form_id
|
10
|
-
dom_id(@tax_category, "#{stimulus_id}_new_tax_category_form")
|
11
|
-
end
|
3
|
+
class SolidusAdmin::TaxCategories::New::Component < SolidusAdmin::Resources::New::Component
|
12
4
|
end
|
@@ -1,5 +1,5 @@
|
|
1
|
-
import { Controller } from
|
2
|
-
import { useClickOutside } from
|
1
|
+
import { Controller } from "@hotwired/stimulus"
|
2
|
+
import { useClickOutside } from "stimulus-use"
|
3
3
|
|
4
4
|
export default class extends Controller {
|
5
5
|
connect() {
|
@@ -11,6 +11,6 @@ export default class extends Controller {
|
|
11
11
|
}
|
12
12
|
|
13
13
|
close() {
|
14
|
-
this.element.removeAttribute(
|
14
|
+
this.element.removeAttribute("open")
|
15
15
|
}
|
16
16
|
}
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import { Controller } from
|
1
|
+
import { Controller } from "@hotwired/stimulus"
|
2
2
|
|
3
3
|
export default class extends Controller {
|
4
4
|
static targets = ["country", "state", "stateName", "stateWrapper", "stateNameWrapper"]
|
@@ -7,8 +7,8 @@ export default class extends Controller {
|
|
7
7
|
const countryId = this.countryTarget.value
|
8
8
|
|
9
9
|
fetch(`/admin/countries/${countryId}/states`)
|
10
|
-
.then(response => response.json())
|
11
|
-
.then(data => {
|
10
|
+
.then((response) => response.json())
|
11
|
+
.then((data) => {
|
12
12
|
this.updateStateOptions(data)
|
13
13
|
})
|
14
14
|
}
|
@@ -30,13 +30,12 @@ export default class extends Controller {
|
|
30
30
|
const stateSelect = this.stateTarget
|
31
31
|
const stateName = this.stateNameTarget
|
32
32
|
|
33
|
-
|
34
33
|
if (showSelect) {
|
35
34
|
// Show state select dropdown.
|
36
35
|
stateSelect.disabled = false
|
37
36
|
stateName.value = ""
|
38
|
-
stateWrapper.classList.remove(
|
39
|
-
stateNameWrapper.classList.add(
|
37
|
+
stateWrapper.classList.remove("hidden")
|
38
|
+
stateNameWrapper.classList.add("hidden")
|
40
39
|
} else {
|
41
40
|
// Show state name text input if no states to choose from.
|
42
41
|
stateSelect.disabled = true
|
@@ -46,7 +46,7 @@ class SolidusAdmin::UI::Forms::Field::Component < SolidusAdmin::BaseComponent
|
|
46
46
|
tag: :select,
|
47
47
|
choices:,
|
48
48
|
size:,
|
49
|
-
value: object.public_send(method),
|
49
|
+
value: (object.public_send(method) if object.respond_to?(method)),
|
50
50
|
error: (errors.to_sentence.capitalize if errors),
|
51
51
|
**attributes,
|
52
52
|
}
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import { Controller } from
|
1
|
+
import { Controller } from "@hotwired/stimulus"
|
2
2
|
|
3
3
|
export default class extends Controller {
|
4
4
|
static values = {
|
@@ -6,11 +6,10 @@ export default class extends Controller {
|
|
6
6
|
}
|
7
7
|
|
8
8
|
connect() {
|
9
|
-
if (this.customValidityValue)
|
10
|
-
this.element.setCustomValidity(this.customValidityValue)
|
9
|
+
if (this.customValidityValue) this.element.setCustomValidity(this.customValidityValue)
|
11
10
|
}
|
12
11
|
|
13
12
|
clearCustomValidity() {
|
14
|
-
this.element.setCustomValidity(
|
13
|
+
this.element.setCustomValidity("")
|
15
14
|
}
|
16
15
|
}
|
@@ -93,13 +93,24 @@ class SolidusAdmin::UI::Forms::Input::Component < SolidusAdmin::BaseComponent
|
|
93
93
|
with_content options_for_select(@attributes.delete(:choices), @attributes.delete(:value))
|
94
94
|
end
|
95
95
|
|
96
|
-
|
97
|
-
|
98
|
-
|
96
|
+
build_tag
|
97
|
+
end
|
98
|
+
|
99
|
+
private
|
100
|
+
|
101
|
+
def build_tag
|
102
|
+
args = [@tag]
|
103
|
+
args << content unless void_element?(@tag)
|
104
|
+
|
105
|
+
tag.public_send(*args, **tag_options)
|
106
|
+
end
|
107
|
+
|
108
|
+
def tag_options
|
109
|
+
@tag_options ||= {
|
99
110
|
"data-controller": stimulus_id,
|
100
111
|
"data-#{stimulus_id}-custom-validity-value": @error.presence,
|
101
112
|
"data-action": "#{stimulus_id}#clearCustomValidity",
|
102
113
|
**@attributes
|
103
|
-
|
114
|
+
}
|
104
115
|
end
|
105
116
|
end
|
@@ -1,12 +1,12 @@
|
|
1
1
|
<%= page do %>
|
2
|
-
<% if
|
2
|
+
<% if tabs %>
|
3
3
|
<%= page_header do %>
|
4
4
|
<%= render_title %>
|
5
5
|
<% end %>
|
6
6
|
|
7
7
|
<%= page_header do %>
|
8
8
|
<% rendered_tabs = capture do %>
|
9
|
-
<%
|
9
|
+
<% renderable_tabs.each do %>
|
10
10
|
<%= render(component("ui/button").new(tag: :a, scheme: :ghost, text: _1.text, 'aria-current': _1.current, href: _1.href)) %>
|
11
11
|
<% end %>
|
12
12
|
<% end %>
|
@@ -39,6 +39,6 @@
|
|
39
39
|
<% end %>
|
40
40
|
|
41
41
|
<% turbo_frames.each do |frame| %>
|
42
|
-
<%= turbo_frame_tag frame %>
|
42
|
+
<%= turbo_frame_tag frame, target: "_top" %>
|
43
43
|
<% end %>
|
44
44
|
<% end %>
|
@@ -22,13 +22,18 @@ class SolidusAdmin::UI::Pages::Index::Component < SolidusAdmin::BaseComponent
|
|
22
22
|
|
23
23
|
def initialize(page:)
|
24
24
|
@page = page
|
25
|
-
@tabs = tabs&.map { |tab| Tab.new(**tab) }
|
26
25
|
end
|
27
26
|
|
28
27
|
def row_fade(_record)
|
29
28
|
false
|
30
29
|
end
|
31
30
|
|
31
|
+
def renderable_tabs
|
32
|
+
return unless tabs
|
33
|
+
|
34
|
+
tabs.map { |tab| Tab.new(**tab) }
|
35
|
+
end
|
36
|
+
|
32
37
|
def title
|
33
38
|
model_class.model_name.human.pluralize
|
34
39
|
end
|
@@ -137,11 +137,12 @@
|
|
137
137
|
<%= "data-sortable-animation-value=#{@sortable.animation}" if @sortable&.animation %>
|
138
138
|
>
|
139
139
|
<% @data.rows.each do |row| %>
|
140
|
+
<% row_url = @data.url&.call(row) %>
|
140
141
|
<tr
|
141
|
-
class="border-b border-gray-100 last:border-0 hover:bg-gray-50 cursor-pointer <%= 'bg-gray-15 text-gray-700' if @data.fade&.call(row) %>"
|
142
|
-
<% if
|
142
|
+
class="border-b border-gray-100 last:border-0 <%= 'hover:bg-gray-50 cursor-pointer' if row_url %> <%= 'bg-gray-15 text-gray-700' if @data.fade&.call(row) %>"
|
143
|
+
<% if row_url %>
|
143
144
|
data-action="click-><%= stimulus_id %>#rowClicked"
|
144
|
-
data-<%= stimulus_id %>-url-param="<%=
|
145
|
+
data-<%= stimulus_id %>-url-param="<%= row_url %>"
|
145
146
|
<%= "data-sortable-url=#{@sortable.url.call(row)}" if @sortable&.url %>
|
146
147
|
<% end %>
|
147
148
|
>
|
@@ -36,9 +36,9 @@ export default class extends Controller {
|
|
36
36
|
const shouldSetSortable = this.sortableValue && this.modeValue !== "batch" && this.modeValue !== "search"
|
37
37
|
|
38
38
|
if (shouldSetSortable) {
|
39
|
-
this.tableBodyTarget.setAttribute(
|
39
|
+
this.tableBodyTarget.setAttribute("data-controller", "sortable")
|
40
40
|
} else {
|
41
|
-
this.tableBodyTarget.removeAttribute(
|
41
|
+
this.tableBodyTarget.removeAttribute("data-controller")
|
42
42
|
}
|
43
43
|
}
|
44
44
|
|
@@ -54,13 +54,13 @@ export default class extends Controller {
|
|
54
54
|
}
|
55
55
|
|
56
56
|
clearSearch() {
|
57
|
-
this.searchFieldTarget.value =
|
57
|
+
this.searchFieldTarget.value = ""
|
58
58
|
this.search()
|
59
59
|
}
|
60
60
|
|
61
61
|
resetSearchAndFilters() {
|
62
62
|
if (this.hasFilterToolbarTarget) {
|
63
|
-
this.filterToolbarTarget.querySelectorAll(
|
63
|
+
this.filterToolbarTarget.querySelectorAll("fieldset").forEach((fieldset) => (fieldset.disabled = true))
|
64
64
|
}
|
65
65
|
|
66
66
|
this.searchFieldTarget.disabled = true
|
@@ -70,7 +70,7 @@ export default class extends Controller {
|
|
70
70
|
selectRow(event) {
|
71
71
|
if (this.checkboxTargets.some((checkbox) => checkbox.checked)) {
|
72
72
|
this.modeValue = "batch"
|
73
|
-
} else if (this.hasSearchFieldTarget &&
|
73
|
+
} else if (this.hasSearchFieldTarget && this.searchFieldTarget.value !== "") {
|
74
74
|
this.modeValue = "search"
|
75
75
|
} else if (this.hasScopesToolbarTarget) {
|
76
76
|
this.modeValue = "scopes"
|
@@ -84,7 +84,7 @@ export default class extends Controller {
|
|
84
84
|
selectAllRows(event) {
|
85
85
|
if (event.target.checked) {
|
86
86
|
this.modeValue = "batch"
|
87
|
-
} else if (this.hasSearchFieldTarget &&
|
87
|
+
} else if (this.hasSearchFieldTarget && this.searchFieldTarget.value !== "") {
|
88
88
|
this.modeValue = "search"
|
89
89
|
} else if (this.hasScopesToolbarTarget) {
|
90
90
|
this.modeValue = "scopes"
|
@@ -103,13 +103,13 @@ export default class extends Controller {
|
|
103
103
|
|
104
104
|
if (this.modeValue === "batch") {
|
105
105
|
this.toggleCheckbox(event.currentTarget)
|
106
|
-
} else {
|
106
|
+
} else if (event.params.url) {
|
107
107
|
const url = new URL(event.params.url, "http://dummy.com")
|
108
108
|
const params = new URLSearchParams(url.search)
|
109
|
-
const frameId = params.get(
|
109
|
+
const frameId = params.get("_turbo_frame")
|
110
110
|
const frame = frameId ? { frame: frameId } : {}
|
111
111
|
// remove the custom _turbo_frame param from url search:
|
112
|
-
params.delete(
|
112
|
+
params.delete("_turbo_frame")
|
113
113
|
url.search = params.toString()
|
114
114
|
|
115
115
|
window.Turbo.visit(url.pathname + url.search, frame)
|
@@ -117,7 +117,7 @@ export default class extends Controller {
|
|
117
117
|
}
|
118
118
|
|
119
119
|
toggleCheckbox(row) {
|
120
|
-
const checkbox = this.checkboxTargets.find(selection => row.contains(selection))
|
120
|
+
const checkbox = this.checkboxTargets.find((selection) => row.contains(selection))
|
121
121
|
|
122
122
|
if (checkbox) {
|
123
123
|
checkbox.checked = !checkbox.checked
|
@@ -131,14 +131,10 @@ export default class extends Controller {
|
|
131
131
|
|
132
132
|
confirmAction(event) {
|
133
133
|
const message = event.params.message
|
134
|
+
.replace("${count}", this.selectedRows().length)
|
134
135
|
.replace(
|
135
|
-
"${count}",
|
136
|
-
this.selectedRows().length
|
137
|
-
).replace(
|
138
136
|
"${resource}",
|
139
|
-
this.selectedRows().length > 1 ?
|
140
|
-
event.params.resourcePlural :
|
141
|
-
event.params.resourceSingular
|
137
|
+
this.selectedRows().length > 1 ? event.params.resourcePlural : event.params.resourceSingular
|
142
138
|
)
|
143
139
|
|
144
140
|
if (!confirm(message)) {
|
@@ -167,7 +163,7 @@ export default class extends Controller {
|
|
167
163
|
|
168
164
|
// Update the rows background color
|
169
165
|
this.checkboxTargets.filter((checkbox) =>
|
170
|
-
checkbox.closest("tr").classList.toggle(this.selectedRowClass, checkbox.checked)
|
166
|
+
checkbox.closest("tr").classList.toggle(this.selectedRowClass, checkbox.checked)
|
171
167
|
)
|
172
168
|
|
173
169
|
// Update the selected rows count
|
@@ -1,11 +1,11 @@
|
|
1
|
-
import { Controller } from
|
2
|
-
import { useClickOutside, useDebounce } from
|
1
|
+
import { Controller } from "@hotwired/stimulus"
|
2
|
+
import { useClickOutside, useDebounce } from "stimulus-use"
|
3
3
|
|
4
|
-
const BG_GRAY =
|
4
|
+
const BG_GRAY = "bg-gray-100"
|
5
5
|
|
6
6
|
export default class extends Controller {
|
7
|
-
static targets = [
|
8
|
-
static debounces = [
|
7
|
+
static targets = ["details", "summary", "option", "checkbox", "menu"]
|
8
|
+
static debounces = ["init"]
|
9
9
|
|
10
10
|
connect() {
|
11
11
|
useDebounce(this, { wait: 50 })
|
@@ -37,7 +37,7 @@ export default class extends Controller {
|
|
37
37
|
filterOptions(event) {
|
38
38
|
const query = event.currentTarget.value.toLowerCase()
|
39
39
|
this.optionTargets.forEach((option) => {
|
40
|
-
option.style.display = option.textContent.toLowerCase().includes(query) ?
|
40
|
+
option.style.display = option.textContent.toLowerCase().includes(query) ? "block" : "none"
|
41
41
|
})
|
42
42
|
}
|
43
43
|
|
@@ -50,24 +50,26 @@ export default class extends Controller {
|
|
50
50
|
this.checkboxTargets.forEach((checkbox) => {
|
51
51
|
const hiddenElements = checkbox.parentElement.querySelectorAll("input[type='hidden']")
|
52
52
|
checkbox.checked
|
53
|
-
? hiddenElements.forEach(e => e.removeAttribute("disabled"))
|
54
|
-
: hiddenElements.forEach(e => e.setAttribute("disabled", true))
|
53
|
+
? hiddenElements.forEach((e) => e.removeAttribute("disabled"))
|
54
|
+
: hiddenElements.forEach((e) => e.setAttribute("disabled", true))
|
55
55
|
})
|
56
56
|
}
|
57
57
|
|
58
58
|
sortCheckboxes() {
|
59
59
|
const checkboxes = this.checkboxTargets
|
60
60
|
|
61
|
-
checkboxes
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
61
|
+
checkboxes
|
62
|
+
.sort((a, b) => {
|
63
|
+
if (a.checked && !b.checked) return -1
|
64
|
+
if (!a.checked && b.checked) return 1
|
65
|
+
return 0
|
66
|
+
})
|
67
|
+
.forEach((checkbox) => {
|
68
|
+
this.menuTarget.appendChild(checkbox.closest("div"))
|
69
|
+
})
|
68
70
|
}
|
69
71
|
|
70
72
|
isAnyCheckboxChecked() {
|
71
|
-
return this.checkboxTargets.some(checkbox => checkbox.checked)
|
73
|
+
return this.checkboxTargets.some((checkbox) => checkbox.checked)
|
72
74
|
}
|
73
75
|
}
|
@@ -1,8 +1,8 @@
|
|
1
|
-
import { Controller } from
|
1
|
+
import { Controller } from "@hotwired/stimulus"
|
2
2
|
|
3
3
|
export default class extends Controller {
|
4
|
-
static targets = [
|
5
|
-
static classes = [
|
4
|
+
static targets = ["closeButton"]
|
5
|
+
static classes = ["animation"]
|
6
6
|
static values = { transition: Number }
|
7
7
|
|
8
8
|
connect() {
|
@@ -1,30 +1,30 @@
|
|
1
|
-
import { Controller } from
|
2
|
-
import { useClickOutside } from
|
1
|
+
import { Controller } from "@hotwired/stimulus"
|
2
|
+
import { useClickOutside } from "stimulus-use"
|
3
3
|
|
4
4
|
export default class extends Controller {
|
5
|
-
static targets = [
|
5
|
+
static targets = ["bubble"]
|
6
6
|
|
7
|
-
connect
|
7
|
+
connect() {
|
8
8
|
useClickOutside(this)
|
9
9
|
this.open = false
|
10
10
|
}
|
11
11
|
|
12
|
-
clickOutside
|
12
|
+
clickOutside() {
|
13
13
|
this.close()
|
14
14
|
}
|
15
15
|
|
16
|
-
toggle
|
16
|
+
toggle(e) {
|
17
17
|
e.preventDefault()
|
18
18
|
this.open = !this.open
|
19
19
|
this.render()
|
20
20
|
}
|
21
21
|
|
22
|
-
open
|
22
|
+
open() {
|
23
23
|
this.open = true
|
24
24
|
this.render()
|
25
25
|
}
|
26
26
|
|
27
|
-
close
|
27
|
+
close() {
|
28
28
|
this.open = false
|
29
29
|
this.render()
|
30
30
|
}
|
@@ -35,10 +35,12 @@ export default class extends Controller {
|
|
35
35
|
|
36
36
|
if (needsPositioning) {
|
37
37
|
const bubbleRect = this.bubbleTarget.getBoundingClientRect()
|
38
|
-
if (bubbleRect.right
|
39
|
-
|
40
|
-
if (bubbleRect.
|
41
|
-
|
38
|
+
if (bubbleRect.right > window.innerWidth)
|
39
|
+
this.bubbleTarget.style.left = `${window.innerWidth - bubbleRect.width}px`
|
40
|
+
if (bubbleRect.bottom > window.innerHeight)
|
41
|
+
this.bubbleTarget.style.top = `${window.innerHeight - bubbleRect.height}px`
|
42
|
+
if (bubbleRect.left < 0) this.bubbleTarget.style.left = "0px"
|
43
|
+
if (bubbleRect.top < 0) this.bubbleTarget.style.top = "0px"
|
42
44
|
}
|
43
45
|
}
|
44
46
|
}
|
@@ -0,0 +1,22 @@
|
|
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, :amount, class: "required") %>
|
6
|
+
<%= render component("ui/forms/field").select(
|
7
|
+
f,
|
8
|
+
:store_credit_reason_id,
|
9
|
+
store_credit_reasons_select_options.html_safe,
|
10
|
+
include_blank: t('spree.choose_reason'),
|
11
|
+
html: { required: true }
|
12
|
+
) %>
|
13
|
+
</div>
|
14
|
+
<% modal.with_actions do %>
|
15
|
+
<form method="dialog">
|
16
|
+
<%= render component("ui/button").new(scheme: :secondary, text: t('.cancel')) %>
|
17
|
+
</form>
|
18
|
+
<%= render component("ui/button").new(form: form_id, type: :submit, text: t('.submit')) %>
|
19
|
+
<% end %>
|
20
|
+
<% end %>
|
21
|
+
<% end %>
|
22
|
+
<% end %>
|