solidus_admin 0.0.2 → 0.1.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 +1 -1
- 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.html.erb +32 -0
- data/app/components/solidus_admin/adjustment_reasons/index/component.rb +53 -0
- data/app/components/solidus_admin/adjustment_reasons/index/component.yml +4 -0
- 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.html.erb +30 -0
- data/app/components/solidus_admin/option_types/index/component.rb +57 -0
- data/app/components/solidus_admin/option_types/index/component.yml +4 -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.html.erb +26 -22
- data/app/components/solidus_admin/orders/index/component.rb +80 -16
- data/app/components/solidus_admin/orders/index/component.yml +10 -3
- 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.html.erb +38 -0
- data/app/components/solidus_admin/payment_methods/index/component.rb +93 -0
- data/app/components/solidus_admin/payment_methods/index/component.yml +15 -0
- data/app/components/solidus_admin/products/index/component.html.erb +26 -22
- data/app/components/solidus_admin/products/index/component.rb +36 -36
- data/app/components/solidus_admin/products/index/component.yml +9 -6
- 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.html.erb +26 -0
- data/app/components/solidus_admin/promotion_categories/index/component.rb +57 -0
- data/app/components/solidus_admin/promotion_categories/index/component.yml +4 -0
- data/app/components/solidus_admin/promotions/index/component.html.erb +34 -0
- data/app/components/solidus_admin/promotions/index/component.rb +97 -0
- data/app/components/solidus_admin/promotions/index/component.yml +14 -0
- data/app/components/solidus_admin/properties/index/component.html.erb +34 -0
- data/app/components/solidus_admin/properties/index/component.rb +65 -0
- data/app/components/solidus_admin/properties/index/component.yml +4 -0
- data/app/components/solidus_admin/refund_reasons/index/component.html.erb +31 -0
- data/app/components/solidus_admin/refund_reasons/index/component.rb +53 -0
- data/app/components/solidus_admin/refund_reasons/index/component.yml +4 -0
- data/app/components/solidus_admin/refunds_and_returns/component.html.erb +26 -0
- data/app/components/solidus_admin/refunds_and_returns/component.rb +20 -0
- data/app/components/solidus_admin/refunds_and_returns/component.yml +3 -0
- data/app/components/solidus_admin/reimbursement_types/index/component.html.erb +22 -0
- data/app/components/solidus_admin/reimbursement_types/index/component.rb +45 -0
- data/app/components/solidus_admin/reimbursement_types/index/component.yml +4 -0
- data/app/components/solidus_admin/return_reasons/index/component.html.erb +31 -0
- data/app/components/solidus_admin/return_reasons/index/component.rb +52 -0
- data/app/components/solidus_admin/return_reasons/index/component.yml +4 -0
- data/app/components/solidus_admin/shipping/component.html.erb +30 -0
- data/app/components/solidus_admin/shipping/component.rb +18 -0
- data/app/components/solidus_admin/shipping/component.yml +3 -0
- data/app/components/solidus_admin/shipping_categories/index/component.html.erb +32 -0
- data/app/components/solidus_admin/shipping_categories/index/component.rb +46 -0
- data/app/components/solidus_admin/shipping_categories/index/component.yml +4 -0
- data/app/components/solidus_admin/shipping_methods/index/component.html.erb +32 -0
- data/app/components/solidus_admin/shipping_methods/index/component.rb +61 -0
- data/app/components/solidus_admin/shipping_methods/index/component.yml +4 -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.html.erb +26 -0
- data/app/components/solidus_admin/stock_items/index/component.rb +180 -0
- data/app/components/solidus_admin/stock_items/index/component.yml +10 -0
- data/app/components/solidus_admin/stock_locations/index/component.html.erb +32 -0
- data/app/components/solidus_admin/stock_locations/index/component.rb +81 -0
- data/app/components/solidus_admin/stock_locations/index/component.yml +6 -0
- data/app/components/solidus_admin/store_credit_reasons/index/component.html.erb +31 -0
- data/app/components/solidus_admin/store_credit_reasons/index/component.rb +52 -0
- data/app/components/solidus_admin/store_credit_reasons/index/component.yml +4 -0
- data/app/components/solidus_admin/stores/index/component.html.erb +34 -0
- data/app/components/solidus_admin/stores/index/component.rb +59 -0
- data/app/components/solidus_admin/stores/index/component.yml +4 -0
- data/app/components/solidus_admin/tax_categories/index/component.html.erb +32 -0
- data/app/components/solidus_admin/tax_categories/index/component.rb +58 -0
- data/app/components/solidus_admin/tax_categories/index/component.yml +6 -0
- data/app/components/solidus_admin/tax_rates/index/component.html.erb +32 -0
- data/app/components/solidus_admin/tax_rates/index/component.rb +84 -0
- data/app/components/solidus_admin/tax_rates/index/component.yml +4 -0
- data/app/components/solidus_admin/taxes/component.html.erb +24 -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.html.erb +28 -0
- data/app/components/solidus_admin/taxonomies/index/component.rb +47 -0
- data/app/components/solidus_admin/taxonomies/index/component.yml +4 -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/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 +146 -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.html.erb +34 -0
- data/app/components/solidus_admin/users/index/component.rb +89 -0
- data/app/components/solidus_admin/users/index/component.yml +18 -0
- data/app/components/solidus_admin/zones/index/component.html.erb +35 -0
- data/app/components/solidus_admin/zones/index/component.rb +55 -0
- data/app/components/solidus_admin/zones/index/component.yml +4 -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 +38 -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 +0 -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 +93 -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 +228 -48
- 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/sidebar/account_nav/component.html.erb +0 -67
- data/app/components/solidus_admin/sidebar/account_nav/component.rb +0 -15
- data/app/components/solidus_admin/sidebar/component.rb +0 -21
- data/app/components/solidus_admin/ui/panel/component.js +0 -14
- data/config/solidus_admin/tailwind.config.js.erb +0 -95
- data/docs/customizing_tailwind.md +0 -78
- data/lib/solidus_admin/tailwindcss.rb +0 -58
- data/lib/tasks/tailwindcss.rake +0 -55
- /data/app/components/solidus_admin/{sidebar/account_nav → layout/navigation/account}/component.yml +0 -0
- /data/app/components/solidus_admin/{sidebar → layout/navigation}/component.js +0 -0
- /data/app/components/solidus_admin/{sidebar → layout/navigation}/component.yml +0 -0
- /data/app/components/solidus_admin/{skip_link → layout/skip_link}/component.yml +0 -0
@@ -0,0 +1,37 @@
|
|
1
|
+
import { Controller } from "@hotwired/stimulus"
|
2
|
+
import { useDebounce } from "stimulus-use"
|
3
|
+
|
4
|
+
export default class extends Controller {
|
5
|
+
static values = { productsUrl: String }
|
6
|
+
static debounces = [{ name: "submitLineItems", wait: 500 }]
|
7
|
+
|
8
|
+
connect() {
|
9
|
+
useDebounce(this)
|
10
|
+
this.lineItemsToBeSubmitted = []
|
11
|
+
}
|
12
|
+
|
13
|
+
async search({ detail: { query, controller } }) {
|
14
|
+
controller.resultsValue = await (
|
15
|
+
await fetch(`${this.productsUrlValue}?q[name_or_variants_including_master_sku_cont]=${query}`)
|
16
|
+
).text()
|
17
|
+
}
|
18
|
+
|
19
|
+
updateLineItem(event) {
|
20
|
+
if (!this.lineItemsToBeSubmitted.includes(event.currentTarget)) {
|
21
|
+
this.lineItemsToBeSubmitted.push(event.currentTarget)
|
22
|
+
}
|
23
|
+
|
24
|
+
this.submitLineItems()
|
25
|
+
}
|
26
|
+
|
27
|
+
// This is a workaround to permit using debounce when needing to pass a parameter
|
28
|
+
submitLineItems() {
|
29
|
+
this.lineItemsToBeSubmitted.forEach((lineItem) => lineItem.form.requestSubmit())
|
30
|
+
this.lineItemsToBeSubmitted = []
|
31
|
+
}
|
32
|
+
|
33
|
+
selectResult(event) {
|
34
|
+
const form = event.detail.resultTarget.querySelector("form")
|
35
|
+
form.submit()
|
36
|
+
}
|
37
|
+
}
|
@@ -0,0 +1,26 @@
|
|
1
|
+
<%= render component('ui/forms/search/result').new do %>
|
2
|
+
<%= form_for(@order.line_items.build(variant: @variant), url: solidus_admin.order_line_items_path(@order), method: :post, html: {
|
3
|
+
"data-controller": "readonly-when-submitting",
|
4
|
+
class: "flex items-center",
|
5
|
+
}) do |f| %>
|
6
|
+
<%= hidden_field_tag("#{f.object_name}[variant_id]", @variant.id) %>
|
7
|
+
<div class="flex gap-2 grow">
|
8
|
+
<%= render component("ui/thumbnail").new(
|
9
|
+
src: @image&.url(:small),
|
10
|
+
alt: @variant.name
|
11
|
+
) %>
|
12
|
+
<div class="flex-col">
|
13
|
+
<div class="leading-5 text-black font-semibold text-sm"><%= @variant.name %></div>
|
14
|
+
<div class="leading-5 text-gray-500 font-normal text-sm">
|
15
|
+
SKU:
|
16
|
+
<%= @variant.sku %>
|
17
|
+
<%= @variant.options_text.presence&.prepend("- ") %>
|
18
|
+
</div>
|
19
|
+
</div>
|
20
|
+
</div>
|
21
|
+
<div class="flex gap-2 items-center">
|
22
|
+
<span class="text-gray-500 font-normal text-sm"><%= render component("products/stock").from_variant(@variant) %></span>
|
23
|
+
<span class="text-black font-normal text-sm"><%= @variant.display_price.to_html %></span>
|
24
|
+
</div>
|
25
|
+
<% end %>
|
26
|
+
<% end %>
|
@@ -0,0 +1,11 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class SolidusAdmin::Orders::Cart::Result::Component < SolidusAdmin::BaseComponent
|
4
|
+
with_collection_parameter :variant
|
5
|
+
|
6
|
+
def initialize(order:, variant:)
|
7
|
+
@order = order
|
8
|
+
@variant = variant
|
9
|
+
@image = @variant.images.first || @variant.product.gallery.images.first
|
10
|
+
end
|
11
|
+
end
|
@@ -1,31 +1,35 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
</h1>
|
6
|
-
|
7
|
-
<div class="ml-auto flex gap-2 items-center">
|
8
|
-
<%= render component("feedback").new %>
|
1
|
+
<%= page do %>
|
2
|
+
<%= page_header do %>
|
3
|
+
<%= page_header_title title %>
|
4
|
+
<%= page_header_actions do %>
|
9
5
|
<%= render component("ui/button").new(
|
10
6
|
tag: :a,
|
11
7
|
text: t('.create_order'),
|
12
8
|
href: spree.new_admin_order_path,
|
13
9
|
icon: "add-line",
|
14
10
|
) %>
|
15
|
-
|
16
|
-
|
11
|
+
<% end %>
|
12
|
+
<% end %>
|
17
13
|
|
18
14
|
<%= render component('ui/table').new(
|
19
|
-
id:
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
15
|
+
id: stimulus_id,
|
16
|
+
data: {
|
17
|
+
class: Spree::Order,
|
18
|
+
rows: @page.records,
|
19
|
+
fade: row_fade,
|
20
|
+
url: ->(order) { spree.edit_admin_order_path(order) },
|
21
|
+
batch_actions: batch_actions,
|
22
|
+
columns: columns,
|
23
|
+
prev: prev_page_path,
|
24
|
+
next: next_page_path,
|
25
|
+
},
|
26
|
+
search: {
|
27
|
+
name: :q,
|
28
|
+
value: params[:q],
|
29
|
+
searchbar_key: :number_or_shipments_number_or_bill_address_name_or_email_cont,
|
30
|
+
url: solidus_admin.orders_path(scope: params[:scope]),
|
31
|
+
scopes: scopes,
|
32
|
+
filters: filters,
|
33
|
+
},
|
30
34
|
) %>
|
31
|
-
|
35
|
+
<% end %>
|
@@ -1,34 +1,84 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
class SolidusAdmin::Orders::Index::Component < SolidusAdmin::BaseComponent
|
4
|
+
include SolidusAdmin::Layout::PageHelpers
|
5
|
+
|
4
6
|
def initialize(page:)
|
5
7
|
@page = page
|
6
8
|
end
|
7
9
|
|
8
|
-
class_attribute :
|
10
|
+
class_attribute :row_fade, default: ->(order) { order.paid? && order.shipped? }
|
9
11
|
|
10
12
|
def title
|
11
13
|
Spree::Order.model_name.human.pluralize
|
12
14
|
end
|
13
15
|
|
14
|
-
def
|
15
|
-
|
16
|
+
def prev_page_path
|
17
|
+
solidus_admin.url_for(**request.params, page: @page.number - 1, only_path: true) unless @page.first?
|
16
18
|
end
|
17
19
|
|
18
|
-
def
|
19
|
-
|
20
|
+
def next_page_path
|
21
|
+
solidus_admin.url_for(**request.params, page: @page.next_param, only_path: true) unless @page.last?
|
20
22
|
end
|
21
23
|
|
22
24
|
def batch_actions
|
23
25
|
[]
|
24
26
|
end
|
25
27
|
|
28
|
+
def scopes
|
29
|
+
[
|
30
|
+
{ label: t('.scopes.complete'), name: 'completed', default: true },
|
31
|
+
{ label: t('.scopes.in_progress'), name: 'in_progress' },
|
32
|
+
{ label: t('.scopes.returned'), name: 'returned' },
|
33
|
+
{ label: t('.scopes.canceled'), name: 'canceled' },
|
34
|
+
{ label: t('.scopes.all_orders'), name: 'all' },
|
35
|
+
]
|
36
|
+
end
|
37
|
+
|
26
38
|
def filters
|
27
39
|
[
|
28
40
|
{
|
29
|
-
|
30
|
-
|
31
|
-
|
41
|
+
presentation: t('.filters.status'),
|
42
|
+
combinator: 'or',
|
43
|
+
attribute: "state",
|
44
|
+
predicate: "eq",
|
45
|
+
options: Spree::Order.state_machines[:state].states.map do |state|
|
46
|
+
[
|
47
|
+
state.value.titleize,
|
48
|
+
state.value
|
49
|
+
]
|
50
|
+
end
|
51
|
+
},
|
52
|
+
{
|
53
|
+
presentation: t('.filters.shipment_state'),
|
54
|
+
combinator: 'or',
|
55
|
+
attribute: "shipment_state",
|
56
|
+
predicate: "eq",
|
57
|
+
options: %i[backorder canceled partial pending ready shipped].map do |option|
|
58
|
+
[
|
59
|
+
option.to_s.capitalize,
|
60
|
+
option
|
61
|
+
]
|
62
|
+
end
|
63
|
+
},
|
64
|
+
{
|
65
|
+
presentation: t('.filters.payment_state'),
|
66
|
+
combinator: 'or',
|
67
|
+
attribute: "payment_state",
|
68
|
+
predicate: "eq",
|
69
|
+
options: %i[balance_due checkout completed credit_owed invalid paid pending processing void].map do |option|
|
70
|
+
[
|
71
|
+
option.to_s.titleize,
|
72
|
+
option
|
73
|
+
]
|
74
|
+
end
|
75
|
+
},
|
76
|
+
{
|
77
|
+
presentation: t('.filters.promotions'),
|
78
|
+
combinator: 'or',
|
79
|
+
attribute: "promotions_id",
|
80
|
+
predicate: "in",
|
81
|
+
options: Spree::Promotion.all.pluck(:name, :id),
|
32
82
|
},
|
33
83
|
]
|
34
84
|
end
|
@@ -36,6 +86,7 @@ class SolidusAdmin::Orders::Index::Component < SolidusAdmin::BaseComponent
|
|
36
86
|
def columns
|
37
87
|
[
|
38
88
|
number_column,
|
89
|
+
state_column,
|
39
90
|
date_column,
|
40
91
|
customer_column,
|
41
92
|
total_column,
|
@@ -49,17 +100,30 @@ class SolidusAdmin::Orders::Index::Component < SolidusAdmin::BaseComponent
|
|
49
100
|
{
|
50
101
|
header: :order,
|
51
102
|
data: ->(order) do
|
52
|
-
|
53
|
-
|
54
|
-
if !fade_row_proc.call(order)
|
55
|
-
link_to order.number, order_path, class: 'font-semibold'
|
103
|
+
if !row_fade.call(order)
|
104
|
+
content_tag :div, order.number, class: 'font-semibold'
|
56
105
|
else
|
57
|
-
|
106
|
+
content_tag :div, order.number
|
58
107
|
end
|
59
108
|
end
|
60
109
|
}
|
61
110
|
end
|
62
111
|
|
112
|
+
def state_column
|
113
|
+
{
|
114
|
+
header: :state,
|
115
|
+
data: ->(order) do
|
116
|
+
color = {
|
117
|
+
'complete' => :green,
|
118
|
+
'returned' => :red,
|
119
|
+
'canceled' => :blue,
|
120
|
+
'cart' => :graphite_light,
|
121
|
+
}[order.state] || :yellow
|
122
|
+
component('ui/badge').new(name: order.state.humanize, color: color)
|
123
|
+
end
|
124
|
+
}
|
125
|
+
end
|
126
|
+
|
63
127
|
def date_column
|
64
128
|
{
|
65
129
|
header: :date,
|
@@ -71,7 +135,7 @@ class SolidusAdmin::Orders::Index::Component < SolidusAdmin::BaseComponent
|
|
71
135
|
|
72
136
|
def customer_column
|
73
137
|
{
|
74
|
-
|
138
|
+
col: { class: "w-[400px]" },
|
75
139
|
header: :customer,
|
76
140
|
data: ->(order) do
|
77
141
|
customer_email = order.user&.email
|
@@ -102,7 +166,7 @@ class SolidusAdmin::Orders::Index::Component < SolidusAdmin::BaseComponent
|
|
102
166
|
{
|
103
167
|
header: :payment,
|
104
168
|
data: ->(order) do
|
105
|
-
component('ui/badge').new(name: order.payment_state
|
169
|
+
component('ui/badge').new(name: order.payment_state.humanize, color: order.paid? ? :green : :yellow) if order.payment_state?
|
106
170
|
end
|
107
171
|
}
|
108
172
|
end
|
@@ -111,7 +175,7 @@ class SolidusAdmin::Orders::Index::Component < SolidusAdmin::BaseComponent
|
|
111
175
|
{
|
112
176
|
header: :shipment,
|
113
177
|
data: ->(order) do
|
114
|
-
component('ui/badge').new(name: order.shipment_state
|
178
|
+
component('ui/badge').new(name: order.shipment_state.humanize, color: order.shipped? ? :green : :yellow) if order.shipment_state?
|
115
179
|
end
|
116
180
|
}
|
117
181
|
end
|
@@ -1,5 +1,3 @@
|
|
1
|
-
# Add your component translations here.
|
2
|
-
# Use the translation in the example in your template with `t(".hello")`.
|
3
1
|
en:
|
4
2
|
create_order: 'Create Order'
|
5
3
|
columns:
|
@@ -7,7 +5,16 @@ en:
|
|
7
5
|
one: 1 Item
|
8
6
|
other: '%{count} Items'
|
9
7
|
filters:
|
10
|
-
|
8
|
+
status: Status
|
9
|
+
shipment_state: Shipment State
|
10
|
+
payment_state: Payment State
|
11
|
+
promotions: Promotions
|
11
12
|
date:
|
12
13
|
formats:
|
13
14
|
short: '%d %b %y'
|
15
|
+
scopes:
|
16
|
+
all_orders: All
|
17
|
+
canceled: Canceled
|
18
|
+
complete: Complete
|
19
|
+
returned: Returned
|
20
|
+
in_progress: In Progress
|
@@ -0,0 +1,67 @@
|
|
1
|
+
<div class="<%= stimulus_id %>" data-controller="<%= stimulus_id %>">
|
2
|
+
<%= render component("orders/show").new(order: @order) %>
|
3
|
+
|
4
|
+
<%= render component("ui/modal").new(title: t(".title.#{@type}"), close_path: solidus_admin.order_path(@order)) do |modal| %>
|
5
|
+
<%= form_for @order, url: solidus_admin.send("order_#{@type}_address_path", @order), html: { id: form_id } do |form| %>
|
6
|
+
<div class="w-full flex flex-col mb-4">
|
7
|
+
<div class="flex justify-between items-center mb-4 relative">
|
8
|
+
<h2 class="text-sm font-semibold">
|
9
|
+
<%= t(".subtitle.#{@type}") %>
|
10
|
+
</h2>
|
11
|
+
|
12
|
+
<% if @addresses.present? %>
|
13
|
+
<%= render component('ui/dropdown').new(
|
14
|
+
text: t(".select_address"),
|
15
|
+
"data-#{stimulus_id}-target": "addresses",
|
16
|
+
class: "max-h-[26rem] overflow-y-auto"
|
17
|
+
) do %>
|
18
|
+
<% @addresses.each do |address| %>
|
19
|
+
<%= tag.a(
|
20
|
+
format_address(address),
|
21
|
+
href: solidus_admin.send("order_#{@type}_address_path", @order, address_id: address.id),
|
22
|
+
'data-turbo-frame': address_frame_id,
|
23
|
+
'data-action': "#{component('ui/dropdown').stimulus_id}#close",
|
24
|
+
) %>
|
25
|
+
<% end %>
|
26
|
+
<% end %>
|
27
|
+
<% end %>
|
28
|
+
</div>
|
29
|
+
|
30
|
+
<div class="w-full flex gap-4">
|
31
|
+
<%= turbo_frame_tag address_frame_id do %>
|
32
|
+
<%= render component('ui/forms/address').new(address: @address, name: "order[#{@type}_address_attributes]") %>
|
33
|
+
<% end %>
|
34
|
+
</div>
|
35
|
+
|
36
|
+
<label class="flex gap-2 items-center">
|
37
|
+
<%= form.hidden_field use_attribute, value: '0', id: false %>
|
38
|
+
|
39
|
+
<%= render component("ui/forms/checkbox").new(
|
40
|
+
name: "#{form.object_name}[#{use_attribute}]",
|
41
|
+
checked: @address == (@type == 'ship' ? @order.bill_address : @order.ship_address),
|
42
|
+
value: '1'
|
43
|
+
) %>
|
44
|
+
|
45
|
+
<span class="font-normal text-xs">
|
46
|
+
<%= t(".use_this_address.#{@type}") %>
|
47
|
+
</span>
|
48
|
+
</label>
|
49
|
+
</div>
|
50
|
+
<% end %>
|
51
|
+
|
52
|
+
<% modal.with_actions do %>
|
53
|
+
<%= render component("ui/button").new(
|
54
|
+
tag: :a,
|
55
|
+
scheme: :secondary,
|
56
|
+
text: t(".cancel"),
|
57
|
+
href: solidus_admin.order_path(@order)
|
58
|
+
) %>
|
59
|
+
|
60
|
+
<%= render component("ui/button").new(
|
61
|
+
tag: :button,
|
62
|
+
text: t(".save"),
|
63
|
+
form: form_id
|
64
|
+
) %>
|
65
|
+
<% end %>
|
66
|
+
<% end %>
|
67
|
+
</div>
|
@@ -0,0 +1,53 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class SolidusAdmin::Orders::Show::Address::Component < SolidusAdmin::BaseComponent
|
4
|
+
include SolidusAdmin::Layout::PageHelpers
|
5
|
+
|
6
|
+
VALID_TYPES = ['ship', 'bill'].freeze
|
7
|
+
|
8
|
+
def initialize(order:, address:, user: nil, type: 'ship')
|
9
|
+
@order = order
|
10
|
+
@user = user
|
11
|
+
@address = address
|
12
|
+
@addresses = user&.addresses.to_a.reject(&:new_record?)
|
13
|
+
@type = validate_address_type(type)
|
14
|
+
end
|
15
|
+
|
16
|
+
def form_id
|
17
|
+
@form_id ||= "#{stimulus_id}--form-#{@type}-#{@order.id}"
|
18
|
+
end
|
19
|
+
|
20
|
+
def address_frame_id
|
21
|
+
@table_frame_id ||= "#{stimulus_id}--#{@type}-address-frame-#{@order.id}"
|
22
|
+
end
|
23
|
+
|
24
|
+
def use_attribute
|
25
|
+
case @type
|
26
|
+
when 'ship'
|
27
|
+
'use_shipping'
|
28
|
+
when 'bill'
|
29
|
+
'use_billing'
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
def format_address(address)
|
34
|
+
safe_join([
|
35
|
+
address.name,
|
36
|
+
tag.br,
|
37
|
+
address.address1,
|
38
|
+
tag.br,
|
39
|
+
address.address2,
|
40
|
+
address.city,
|
41
|
+
address.zipcode,
|
42
|
+
address.state&.name,
|
43
|
+
tag.br,
|
44
|
+
address.country.name,
|
45
|
+
tag.br,
|
46
|
+
address.phone,
|
47
|
+
], " ")
|
48
|
+
end
|
49
|
+
|
50
|
+
def validate_address_type(type)
|
51
|
+
VALID_TYPES.include?(type) ? type : raise(ArgumentError, "Invalid address type: #{type}")
|
52
|
+
end
|
53
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
en:
|
2
|
+
save: Save
|
3
|
+
cancel: Cancel
|
4
|
+
back: Back
|
5
|
+
select_address: Select address
|
6
|
+
title:
|
7
|
+
ship: Edit Shipping Address
|
8
|
+
bill: Edit Billing Address
|
9
|
+
subtitle:
|
10
|
+
ship: Shipping Address
|
11
|
+
bill: Billing Address
|
12
|
+
use_this_address:
|
13
|
+
ship: Use this address also for Billing
|
14
|
+
bill: Use this address also for Shipping
|
@@ -0,0 +1,76 @@
|
|
1
|
+
<%= page("data-action": "turbo:before-cache@window->#{stimulus_id}#closeMenus") do %>
|
2
|
+
<%= page_header do %>
|
3
|
+
<%= page_header_back(solidus_admin.orders_path) %>
|
4
|
+
<%= page_header_title(t('.title', number: @order.number)) %>
|
5
|
+
<%= page_header_actions do %>
|
6
|
+
<%= render component("ui/button").new(tag: :button, scheme: :secondary, text: t(".discard"), form: form_id) %>
|
7
|
+
<%= render component("ui/button").new(tag: :button, text: t(".save"), form: form_id) %>
|
8
|
+
<% end %>
|
9
|
+
<% end %>
|
10
|
+
|
11
|
+
<%= page_with_sidebar do %>
|
12
|
+
<%= page_with_sidebar_main do %>
|
13
|
+
<%= render component("orders/cart").new(order: @order) %>
|
14
|
+
<%= render component("orders/show/summary").new(order: @order) %>
|
15
|
+
<% end %>
|
16
|
+
|
17
|
+
<%= page_with_sidebar_aside do %>
|
18
|
+
<%= render component('ui/panel').new do |panel| %>
|
19
|
+
<% panel.with_menu t(".edit_email"), solidus_admin.order_customer_path(@order) %>
|
20
|
+
<% panel.with_menu t(".edit_shipping"), solidus_admin.edit_order_ship_address_path(@order) %>
|
21
|
+
<% panel.with_menu t(".edit_billing"), solidus_admin.edit_order_bill_address_path(@order) %>
|
22
|
+
<% panel.with_menu t(".remove_customer"), solidus_admin.order_customer_path(@order), method: :delete, class: "text-red-500" if @order.user %>
|
23
|
+
|
24
|
+
<% panel.with_section(class: 'flex flex-col gap-6') do %>
|
25
|
+
<div class="flex flex-col gap-2">
|
26
|
+
<span class="font-semibold text-sm"><%= t(".customer") %></span>
|
27
|
+
<% if @order.user %>
|
28
|
+
<div class="font-normal text-sm"><%= customer_name(@order.user) || tag.span(t('.no_name'), class: "text-gray-500") %></div>
|
29
|
+
<div class="font-normal text-sm body-link"><%= link_to @order.user.email, spree.admin_user_path(@order.user) %></div>
|
30
|
+
<div class="font-normal text-sm text-gray-500"><%= t(".orders_count", count: @order.user.orders.complete.count) %></div>
|
31
|
+
<% else %>
|
32
|
+
<%= render component('orders/show/customer_search').new(order: @order) %>
|
33
|
+
<% end %>
|
34
|
+
</div>
|
35
|
+
|
36
|
+
<div class="flex flex-col gap-2">
|
37
|
+
<span class="font-semibold text-sm"><%= t('.order_email') %></span>
|
38
|
+
<div class="font-normal text-sm">
|
39
|
+
<% if @order.email? %>
|
40
|
+
<%= @order.email %>
|
41
|
+
<% else %>
|
42
|
+
<%= link_to(t(".add_email"), solidus_admin.order_customer_path(@order), class: "body-link") %>
|
43
|
+
<% end %>
|
44
|
+
</div>
|
45
|
+
</div>
|
46
|
+
|
47
|
+
<div class="flex flex-col gap-2">
|
48
|
+
<span class="font-semibold text-sm"><%= @order.class.human_attribute_name(:ship_address) %></span>
|
49
|
+
<div class="font-normal text-sm">
|
50
|
+
<% if @order.ship_address %>
|
51
|
+
<%= format_address @order.ship_address %>
|
52
|
+
<% else %>
|
53
|
+
<%= link_to t(".add_shipping"), solidus_admin.edit_order_ship_address_path(@order), class: 'body-link' %>
|
54
|
+
<% end %>
|
55
|
+
</div>
|
56
|
+
</div>
|
57
|
+
|
58
|
+
<div class="flex flex-col gap-2">
|
59
|
+
<span class="font-semibold text-sm"><%= @order.class.human_attribute_name(:bill_address) %></span>
|
60
|
+
<div class="font-normal text-sm">
|
61
|
+
<% if @order.bill_address.blank? %>
|
62
|
+
<%= link_to t(".add_billing"), solidus_admin.edit_order_bill_address_path(@order), class: 'body-link' %>
|
63
|
+
<% elsif @order.bill_address == @order.ship_address %>
|
64
|
+
<span class="text-gray-500"><%= t('.same_as_shipping') %></span>
|
65
|
+
<% else %>
|
66
|
+
<%= format_address @order.bill_address %>
|
67
|
+
<% end %>
|
68
|
+
</div>
|
69
|
+
</div>
|
70
|
+
|
71
|
+
<% end %>
|
72
|
+
<% end %>
|
73
|
+
|
74
|
+
<% end %>
|
75
|
+
<% end %>
|
76
|
+
<% end %>
|
@@ -0,0 +1,40 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class SolidusAdmin::Orders::Show::Component < SolidusAdmin::BaseComponent
|
4
|
+
include SolidusAdmin::Layout::PageHelpers
|
5
|
+
|
6
|
+
def initialize(order:)
|
7
|
+
@order = order
|
8
|
+
end
|
9
|
+
|
10
|
+
def form_id
|
11
|
+
@form_id ||= "#{stimulus_id}--form-#{@order.id}"
|
12
|
+
end
|
13
|
+
|
14
|
+
def format_address(address)
|
15
|
+
return unless address
|
16
|
+
safe_join([
|
17
|
+
address.name,
|
18
|
+
tag.br,
|
19
|
+
address.address1,
|
20
|
+
tag.br,
|
21
|
+
address.address2,
|
22
|
+
address.city,
|
23
|
+
address.zipcode,
|
24
|
+
address.state&.name,
|
25
|
+
tag.br,
|
26
|
+
address.country.name,
|
27
|
+
tag.br,
|
28
|
+
address.phone,
|
29
|
+
], " ")
|
30
|
+
end
|
31
|
+
|
32
|
+
def customer_name(user)
|
33
|
+
(
|
34
|
+
user.default_user_bill_address ||
|
35
|
+
user.default_user_ship_address ||
|
36
|
+
user.user_addresses.where(default: true).first ||
|
37
|
+
user.user_addresses.first
|
38
|
+
)&.address&.name
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
en:
|
2
|
+
save: Save
|
3
|
+
discard: Discard
|
4
|
+
title: "Order %{number}"
|
5
|
+
customer: Customer
|
6
|
+
no_name: No name available
|
7
|
+
order_email: Order contact email
|
8
|
+
back: Back to orders
|
9
|
+
same_as_shipping: Same as shipping address
|
10
|
+
|
11
|
+
edit_email: "Edit order email"
|
12
|
+
add_email: "Add order email"
|
13
|
+
edit_shipping: "Edit shipping address"
|
14
|
+
add_shipping: "Add shipping address"
|
15
|
+
edit_billing: "Edit billing address"
|
16
|
+
add_billing: "Add billing address"
|
17
|
+
remove_customer: "Remove customer"
|
18
|
+
|
19
|
+
orders_count:
|
20
|
+
one: "%{count} order"
|
21
|
+
other: "%{count} orders"
|
@@ -0,0 +1,14 @@
|
|
1
|
+
<div
|
2
|
+
class="w-full relative overflow-visible"
|
3
|
+
data-controller="<%= stimulus_id %>"
|
4
|
+
data-<%= stimulus_id %>-customers-url-value="<%= solidus_admin.customers_for_order_path(@order) %>"
|
5
|
+
data-action="
|
6
|
+
<%= component('ui/forms/search').stimulus_id %>:search-><%= stimulus_id %>#search
|
7
|
+
<%= component('ui/forms/search').stimulus_id %>:submit-><%= stimulus_id %>#submit
|
8
|
+
"
|
9
|
+
>
|
10
|
+
<%= render component("ui/forms/search").new(
|
11
|
+
placeholder: t(".placeholder"),
|
12
|
+
id: :order_customer
|
13
|
+
) %>
|
14
|
+
</div>
|
@@ -0,0 +1,14 @@
|
|
1
|
+
import { Controller } from '@hotwired/stimulus'
|
2
|
+
|
3
|
+
export default class extends Controller {
|
4
|
+
static values = { customersUrl: String }
|
5
|
+
|
6
|
+
async search({ detail: { query, controller } }) {
|
7
|
+
controller.resultsValue =
|
8
|
+
(await (await fetch(`${this.customersUrlValue}?q[name_or_variants_including_master_sku_cont]=${query}`)).text())
|
9
|
+
}
|
10
|
+
|
11
|
+
submit(event) {
|
12
|
+
event.detail.resultTarget.querySelector('form').submit()
|
13
|
+
}
|
14
|
+
}
|