solidus_admin 0.0.1 → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (285) hide show
  1. checksums.yaml +4 -4
  2. data/.eslintrc.json +7 -0
  3. data/README.md +1 -1
  4. data/Rakefile +26 -0
  5. data/app/assets/builds/.keep +0 -0
  6. data/app/assets/builds/solidus_admin/tailwind.css +2799 -0
  7. data/app/assets/config/solidus_admin_manifest.js +1 -0
  8. data/app/assets/stylesheets/solidus_admin/application.tailwind.css +4 -0
  9. data/app/assets/stylesheets/solidus_admin/dark.css +12 -0
  10. data/app/assets/stylesheets/solidus_admin/dimmed.css +11 -0
  11. data/app/components/solidus_admin/adjustment_reasons/index/component.html.erb +32 -0
  12. data/app/components/solidus_admin/adjustment_reasons/index/component.rb +53 -0
  13. data/app/components/solidus_admin/adjustment_reasons/index/component.yml +4 -0
  14. data/app/components/solidus_admin/layout/feedback/component.html.erb +15 -0
  15. data/app/components/solidus_admin/layout/feedback/component.rb +4 -0
  16. data/app/components/solidus_admin/layout/feedback/component.yml +3 -0
  17. data/app/components/solidus_admin/layout/navigation/account/component.html.erb +74 -0
  18. data/app/components/solidus_admin/layout/navigation/account/component.js +16 -0
  19. data/app/components/solidus_admin/layout/navigation/account/component.rb +36 -0
  20. data/app/components/solidus_admin/{sidebar → layout/navigation}/component.html.erb +9 -9
  21. data/app/components/solidus_admin/layout/navigation/component.rb +26 -0
  22. data/app/components/solidus_admin/{sidebar → layout/navigation}/item/component.html.erb +5 -5
  23. data/app/components/solidus_admin/{sidebar → layout/navigation}/item/component.rb +2 -2
  24. data/app/components/solidus_admin/layout/page_helpers.rb +55 -0
  25. data/app/components/solidus_admin/{skip_link → layout/skip_link}/component.rb +2 -4
  26. data/app/components/solidus_admin/option_types/index/component.html.erb +30 -0
  27. data/app/components/solidus_admin/option_types/index/component.rb +57 -0
  28. data/app/components/solidus_admin/option_types/index/component.yml +4 -0
  29. data/app/components/solidus_admin/orders/cart/component.html.erb +77 -0
  30. data/app/components/solidus_admin/orders/cart/component.js +37 -0
  31. data/app/components/solidus_admin/orders/cart/component.rb +7 -0
  32. data/app/components/solidus_admin/orders/cart/component.yml +3 -0
  33. data/app/components/solidus_admin/orders/cart/result/component.html.erb +26 -0
  34. data/app/components/solidus_admin/orders/cart/result/component.rb +11 -0
  35. data/app/components/solidus_admin/orders/index/component.html.erb +26 -22
  36. data/app/components/solidus_admin/orders/index/component.rb +80 -16
  37. data/app/components/solidus_admin/orders/index/component.yml +10 -3
  38. data/app/components/solidus_admin/orders/show/address/component.html.erb +67 -0
  39. data/app/components/solidus_admin/orders/show/address/component.js +9 -0
  40. data/app/components/solidus_admin/orders/show/address/component.rb +53 -0
  41. data/app/components/solidus_admin/orders/show/address/component.yml +14 -0
  42. data/app/components/solidus_admin/orders/show/component.html.erb +76 -0
  43. data/app/components/solidus_admin/orders/show/component.js +7 -0
  44. data/app/components/solidus_admin/orders/show/component.rb +40 -0
  45. data/app/components/solidus_admin/orders/show/component.yml +21 -0
  46. data/app/components/solidus_admin/orders/show/customer_search/component.html.erb +14 -0
  47. data/app/components/solidus_admin/orders/show/customer_search/component.js +14 -0
  48. data/app/components/solidus_admin/orders/show/customer_search/component.rb +7 -0
  49. data/app/components/solidus_admin/orders/show/customer_search/component.yml +2 -0
  50. data/app/components/solidus_admin/orders/show/customer_search/result/component.html.erb +17 -0
  51. data/app/components/solidus_admin/orders/show/customer_search/result/component.rb +11 -0
  52. data/app/components/solidus_admin/orders/show/email/component.html.erb +18 -0
  53. data/app/components/solidus_admin/orders/show/email/component.rb +15 -0
  54. data/app/components/solidus_admin/orders/show/email/component.yml +8 -0
  55. data/app/components/solidus_admin/orders/show/summary/component.html.erb +14 -0
  56. data/app/components/solidus_admin/orders/show/summary/component.rb +7 -0
  57. data/app/components/solidus_admin/orders/show/summary/component.yml +8 -0
  58. data/app/components/solidus_admin/payment_methods/index/component.html.erb +38 -0
  59. data/app/components/solidus_admin/payment_methods/index/component.rb +93 -0
  60. data/app/components/solidus_admin/payment_methods/index/component.yml +15 -0
  61. data/app/components/solidus_admin/products/index/component.html.erb +26 -22
  62. data/app/components/solidus_admin/products/index/component.rb +36 -36
  63. data/app/components/solidus_admin/products/index/component.yml +9 -6
  64. data/app/components/solidus_admin/products/show/component.html.erb +32 -38
  65. data/app/components/solidus_admin/products/show/component.rb +2 -0
  66. data/app/components/solidus_admin/products/show/component.yml +5 -5
  67. data/app/components/solidus_admin/products/status/component.rb +20 -18
  68. data/app/components/solidus_admin/products/status/component.yml +1 -0
  69. data/app/components/solidus_admin/products/stock/component.rb +38 -0
  70. data/app/components/solidus_admin/products/stock/component.yml +5 -0
  71. data/app/components/solidus_admin/promotion_categories/index/component.html.erb +26 -0
  72. data/app/components/solidus_admin/promotion_categories/index/component.rb +57 -0
  73. data/app/components/solidus_admin/promotion_categories/index/component.yml +4 -0
  74. data/app/components/solidus_admin/promotions/index/component.html.erb +34 -0
  75. data/app/components/solidus_admin/promotions/index/component.rb +97 -0
  76. data/app/components/solidus_admin/promotions/index/component.yml +14 -0
  77. data/app/components/solidus_admin/properties/index/component.html.erb +34 -0
  78. data/app/components/solidus_admin/properties/index/component.rb +65 -0
  79. data/app/components/solidus_admin/properties/index/component.yml +4 -0
  80. data/app/components/solidus_admin/refund_reasons/index/component.html.erb +31 -0
  81. data/app/components/solidus_admin/refund_reasons/index/component.rb +53 -0
  82. data/app/components/solidus_admin/refund_reasons/index/component.yml +4 -0
  83. data/app/components/solidus_admin/refunds_and_returns/component.html.erb +26 -0
  84. data/app/components/solidus_admin/refunds_and_returns/component.rb +20 -0
  85. data/app/components/solidus_admin/refunds_and_returns/component.yml +3 -0
  86. data/app/components/solidus_admin/reimbursement_types/index/component.html.erb +22 -0
  87. data/app/components/solidus_admin/reimbursement_types/index/component.rb +45 -0
  88. data/app/components/solidus_admin/reimbursement_types/index/component.yml +4 -0
  89. data/app/components/solidus_admin/return_reasons/index/component.html.erb +31 -0
  90. data/app/components/solidus_admin/return_reasons/index/component.rb +52 -0
  91. data/app/components/solidus_admin/return_reasons/index/component.yml +4 -0
  92. data/app/components/solidus_admin/shipping/component.html.erb +30 -0
  93. data/app/components/solidus_admin/shipping/component.rb +18 -0
  94. data/app/components/solidus_admin/shipping/component.yml +3 -0
  95. data/app/components/solidus_admin/shipping_categories/index/component.html.erb +32 -0
  96. data/app/components/solidus_admin/shipping_categories/index/component.rb +46 -0
  97. data/app/components/solidus_admin/shipping_categories/index/component.yml +4 -0
  98. data/app/components/solidus_admin/shipping_methods/index/component.html.erb +32 -0
  99. data/app/components/solidus_admin/shipping_methods/index/component.rb +61 -0
  100. data/app/components/solidus_admin/shipping_methods/index/component.yml +4 -0
  101. data/app/components/solidus_admin/stock_items/edit/component.html.erb +89 -0
  102. data/app/components/solidus_admin/stock_items/edit/component.js +17 -0
  103. data/app/components/solidus_admin/stock_items/edit/component.rb +23 -0
  104. data/app/components/solidus_admin/stock_items/edit/component.yml +10 -0
  105. data/app/components/solidus_admin/stock_items/index/component.html.erb +26 -0
  106. data/app/components/solidus_admin/stock_items/index/component.rb +180 -0
  107. data/app/components/solidus_admin/stock_items/index/component.yml +10 -0
  108. data/app/components/solidus_admin/stock_locations/index/component.html.erb +32 -0
  109. data/app/components/solidus_admin/stock_locations/index/component.rb +81 -0
  110. data/app/components/solidus_admin/stock_locations/index/component.yml +6 -0
  111. data/app/components/solidus_admin/store_credit_reasons/index/component.html.erb +31 -0
  112. data/app/components/solidus_admin/store_credit_reasons/index/component.rb +52 -0
  113. data/app/components/solidus_admin/store_credit_reasons/index/component.yml +4 -0
  114. data/app/components/solidus_admin/stores/index/component.html.erb +34 -0
  115. data/app/components/solidus_admin/stores/index/component.rb +59 -0
  116. data/app/components/solidus_admin/stores/index/component.yml +4 -0
  117. data/app/components/solidus_admin/tax_categories/index/component.html.erb +32 -0
  118. data/app/components/solidus_admin/tax_categories/index/component.rb +58 -0
  119. data/app/components/solidus_admin/tax_categories/index/component.yml +6 -0
  120. data/app/components/solidus_admin/tax_rates/index/component.html.erb +32 -0
  121. data/app/components/solidus_admin/tax_rates/index/component.rb +84 -0
  122. data/app/components/solidus_admin/tax_rates/index/component.yml +4 -0
  123. data/app/components/solidus_admin/taxes/component.html.erb +24 -0
  124. data/app/components/solidus_admin/taxes/component.rb +25 -0
  125. data/app/components/solidus_admin/taxes/component.yml +3 -0
  126. data/app/components/solidus_admin/taxonomies/index/component.html.erb +28 -0
  127. data/app/components/solidus_admin/taxonomies/index/component.rb +47 -0
  128. data/app/components/solidus_admin/taxonomies/index/component.yml +4 -0
  129. data/app/components/solidus_admin/ui/badge/component.rb +18 -8
  130. data/app/components/solidus_admin/ui/badge/component.yml +3 -0
  131. data/app/components/solidus_admin/ui/button/component.rb +32 -32
  132. data/app/components/solidus_admin/ui/details_list/component.html.erb +10 -0
  133. data/app/components/solidus_admin/ui/details_list/component.rb +7 -0
  134. data/app/components/solidus_admin/ui/dropdown/component.html.erb +50 -0
  135. data/app/components/solidus_admin/ui/dropdown/component.js +16 -0
  136. data/app/components/solidus_admin/ui/dropdown/component.rb +28 -0
  137. data/app/components/solidus_admin/ui/dropdown/component.yml +2 -0
  138. data/app/components/solidus_admin/ui/forms/address/component.html.erb +36 -0
  139. data/app/components/solidus_admin/ui/forms/address/component.js +34 -0
  140. data/app/components/solidus_admin/ui/forms/address/component.rb +14 -0
  141. data/app/components/solidus_admin/ui/forms/field/component.html.erb +5 -4
  142. data/app/components/solidus_admin/ui/forms/field/component.rb +53 -15
  143. data/app/components/solidus_admin/ui/forms/input/component.rb +11 -5
  144. data/app/components/solidus_admin/ui/forms/search/component.html.erb +52 -0
  145. data/app/components/solidus_admin/ui/forms/search/component.js +116 -0
  146. data/app/components/solidus_admin/ui/forms/search/component.rb +8 -0
  147. data/app/components/solidus_admin/ui/forms/search/component.yml +4 -0
  148. data/app/components/solidus_admin/ui/forms/search/result/component.rb +12 -0
  149. data/app/components/solidus_admin/ui/forms/search_field/component.html.erb +20 -0
  150. data/app/{javascript/solidus_admin/controllers/hello_controller.js → components/solidus_admin/ui/forms/search_field/component.js} +4 -2
  151. data/app/components/solidus_admin/ui/forms/search_field/component.rb +10 -0
  152. data/app/components/solidus_admin/ui/forms/search_field/component.yml +2 -0
  153. data/app/components/solidus_admin/ui/forms/switch/component.rb +27 -31
  154. data/app/components/solidus_admin/ui/forms/switch_field/component.html.erb +20 -0
  155. data/app/components/solidus_admin/ui/forms/switch_field/component.rb +11 -0
  156. data/app/components/solidus_admin/ui/icon/component.rb +4 -0
  157. data/app/components/solidus_admin/ui/modal/component.html.erb +37 -0
  158. data/app/components/solidus_admin/ui/modal/component.rb +12 -0
  159. data/app/components/solidus_admin/ui/modal/component.yml +2 -0
  160. data/app/components/solidus_admin/ui/panel/component.html.erb +26 -12
  161. data/app/components/solidus_admin/ui/panel/component.rb +17 -0
  162. data/app/components/solidus_admin/ui/panel/component.yml +1 -3
  163. data/app/components/solidus_admin/ui/resource_item/component.html.erb +10 -0
  164. data/app/components/solidus_admin/ui/resource_item/component.rb +9 -0
  165. data/app/components/solidus_admin/ui/tab/component.rb +9 -8
  166. data/app/components/solidus_admin/ui/table/component.html.erb +146 -135
  167. data/app/components/solidus_admin/ui/table/component.js +56 -17
  168. data/app/components/solidus_admin/ui/table/component.rb +94 -70
  169. data/app/components/solidus_admin/ui/table/component.yml +0 -1
  170. data/app/components/solidus_admin/ui/table/ransack_filter/component.html.erb +72 -0
  171. data/app/components/solidus_admin/ui/table/ransack_filter/component.js +73 -0
  172. data/app/components/solidus_admin/ui/table/ransack_filter/component.rb +68 -0
  173. data/app/components/solidus_admin/ui/table/ransack_filter/component.yml +3 -0
  174. data/app/components/solidus_admin/ui/table/toolbar/component.rb +21 -0
  175. data/app/components/solidus_admin/ui/thumbnail/component.rb +46 -0
  176. data/app/components/solidus_admin/ui/toast/component.html.erb +9 -5
  177. data/app/components/solidus_admin/ui/toast/component.js +9 -6
  178. data/app/components/solidus_admin/ui/toast/component.rb +2 -2
  179. data/app/components/solidus_admin/ui/toggletip/component.html.erb +14 -10
  180. data/app/components/solidus_admin/ui/toggletip/component.js +22 -4
  181. data/app/components/solidus_admin/ui/toggletip/component.rb +8 -85
  182. data/app/components/solidus_admin/users/index/component.html.erb +34 -0
  183. data/app/components/solidus_admin/users/index/component.rb +89 -0
  184. data/app/components/solidus_admin/users/index/component.yml +18 -0
  185. data/app/components/solidus_admin/zones/index/component.html.erb +35 -0
  186. data/app/components/solidus_admin/zones/index/component.rb +55 -0
  187. data/app/components/solidus_admin/zones/index/component.yml +4 -0
  188. data/app/controllers/solidus_admin/addresses_controller.rb +92 -0
  189. data/app/controllers/solidus_admin/adjustment_reasons_controller.rb +40 -0
  190. data/app/controllers/solidus_admin/base_controller.rb +1 -0
  191. data/app/controllers/solidus_admin/controller_helpers/authorization.rb +5 -1
  192. data/app/controllers/solidus_admin/controller_helpers/locale.rb +2 -2
  193. data/app/controllers/solidus_admin/controller_helpers/search.rb +48 -0
  194. data/app/controllers/solidus_admin/controller_helpers/theme.rb +30 -0
  195. data/app/controllers/solidus_admin/countries_controller.rb +12 -0
  196. data/app/controllers/solidus_admin/customers_controller.rb +29 -0
  197. data/app/controllers/solidus_admin/line_items_controller.rb +45 -0
  198. data/app/controllers/solidus_admin/option_types_controller.rb +46 -0
  199. data/app/controllers/solidus_admin/orders_controller.rb +104 -7
  200. data/app/controllers/solidus_admin/payment_methods_controller.rb +52 -0
  201. data/app/controllers/solidus_admin/products_controller.rb +26 -17
  202. data/app/controllers/solidus_admin/promotion_categories_controller.rb +38 -0
  203. data/app/controllers/solidus_admin/promotions_controller.rb +46 -0
  204. data/app/controllers/solidus_admin/properties_controller.rb +33 -0
  205. data/app/controllers/solidus_admin/refund_reasons_controller.rb +40 -0
  206. data/app/controllers/solidus_admin/reimbursement_types_controller.rb +31 -0
  207. data/app/controllers/solidus_admin/return_reasons_controller.rb +40 -0
  208. data/app/controllers/solidus_admin/shipping_categories_controller.rb +40 -0
  209. data/app/controllers/solidus_admin/shipping_methods_controller.rb +40 -0
  210. data/app/controllers/solidus_admin/stock_items_controller.rb +67 -0
  211. data/app/controllers/solidus_admin/stock_locations_controller.rb +40 -0
  212. data/app/controllers/solidus_admin/store_credit_reasons_controller.rb +40 -0
  213. data/app/controllers/solidus_admin/stores_controller.rb +40 -0
  214. data/app/controllers/solidus_admin/tax_categories_controller.rb +40 -0
  215. data/app/controllers/solidus_admin/tax_rates_controller.rb +40 -0
  216. data/app/controllers/solidus_admin/taxonomies_controller.rb +46 -0
  217. data/app/controllers/solidus_admin/users_controller.rb +50 -0
  218. data/app/controllers/solidus_admin/zones_controller.rb +40 -0
  219. data/app/javascript/solidus_admin/controllers/components.js +3 -1
  220. data/app/javascript/solidus_admin/controllers/confirm_controller.js +21 -0
  221. data/app/javascript/solidus_admin/controllers/details_click_outside_controller.js +12 -0
  222. data/app/javascript/solidus_admin/controllers/readonly_when_submitting_controller.js +17 -0
  223. data/app/javascript/solidus_admin/controllers/sortable_controller.js +33 -0
  224. data/app/views/layouts/solidus_admin/application.html.erb +16 -10
  225. data/app/views/layouts/solidus_admin/preview.html.erb +0 -1
  226. data/app/views/solidus_admin/base/unauthorized.html.erb +4 -0
  227. data/config/importmap.rb +2 -0
  228. data/config/initializers/view_component.rb +20 -0
  229. data/config/locales/adjustment_reasons.en.yml +6 -0
  230. data/config/locales/customers.en.yml +7 -0
  231. data/config/locales/errors.en.yml +7 -0
  232. data/config/locales/line_items.en.yml +9 -0
  233. data/config/locales/{main_nav.en.yml → menu_item.en.yml} +8 -2
  234. data/config/locales/option_types.en.yml +6 -0
  235. data/config/locales/orders.en.yml +9 -0
  236. data/config/locales/payment_methods.en.yml +6 -0
  237. data/config/locales/promotion_categories.en.yml +6 -0
  238. data/config/locales/promotions.en.yml +6 -0
  239. data/config/locales/properties.en.yml +6 -0
  240. data/config/locales/refund_reasons_.en.yml +6 -0
  241. data/config/locales/reimbursement_types.en.yml +4 -0
  242. data/config/locales/return_reasons.en.yml +6 -0
  243. data/config/locales/shipping_categories.en.yml +6 -0
  244. data/config/locales/shipping_methods.en.yml +6 -0
  245. data/config/locales/stock_items.en.yml +4 -0
  246. data/config/locales/stock_locations.en.yml +6 -0
  247. data/config/locales/store_credit_reasons.en.yml +6 -0
  248. data/config/locales/stores.en.yml +6 -0
  249. data/config/locales/tax_categories.en.yml +6 -0
  250. data/config/locales/tax_rates.en.yml +6 -0
  251. data/config/locales/taxonomies.en.yml +6 -0
  252. data/config/locales/users.en.yml +6 -0
  253. data/config/locales/zones.en.yml +6 -0
  254. data/config/routes.rb +50 -3
  255. data/config/tailwind.config.js +119 -0
  256. data/docs/{customizing_main_navigation.md → customizing_menu_items.md} +2 -2
  257. data/docs/customizing_tailwindcss.md +57 -0
  258. data/docs/customizing_view_components.md +17 -38
  259. data/lib/generators/solidus_admin/install/install_generator.rb +13 -4
  260. data/lib/generators/solidus_admin/install/templates/config/initializers/{solidus_admin.rb → solidus_admin.rb.tt} +10 -14
  261. data/lib/solidus_admin/admin_resources.rb +23 -0
  262. data/lib/solidus_admin/configuration.rb +93 -67
  263. data/lib/solidus_admin/install_tailwindcss.rb +102 -0
  264. data/lib/solidus_admin/{main_nav_item.rb → menu_item.rb} +2 -2
  265. data/lib/solidus_admin/version.rb +1 -1
  266. data/lib/solidus_admin.rb +1 -2
  267. data/lib/tasks/tailwind.rake +10 -0
  268. data/solidus_admin.gemspec +3 -4
  269. metadata +230 -50
  270. data/app/assets/stylesheets/solidus_admin/application.tailwind.css.erb +0 -35
  271. data/app/components/solidus_admin/feedback/component.html.erb +0 -11
  272. data/app/components/solidus_admin/feedback/component.rb +0 -4
  273. data/app/components/solidus_admin/feedback/component.yml +0 -5
  274. data/app/components/solidus_admin/sidebar/account_nav/component.html.erb +0 -67
  275. data/app/components/solidus_admin/sidebar/account_nav/component.rb +0 -15
  276. data/app/components/solidus_admin/sidebar/component.rb +0 -21
  277. data/app/components/solidus_admin/ui/panel/component.js +0 -14
  278. data/config/solidus_admin/tailwind.config.js.erb +0 -95
  279. data/docs/customizing_tailwind.md +0 -78
  280. data/lib/solidus_admin/tailwindcss.rb +0 -58
  281. data/lib/tasks/tailwindcss.rake +0 -55
  282. /data/app/components/solidus_admin/{sidebar/account_nav → layout/navigation/account}/component.yml +0 -0
  283. /data/app/components/solidus_admin/{sidebar → layout/navigation}/component.js +0 -0
  284. /data/app/components/solidus_admin/{sidebar → layout/navigation}/component.yml +0 -0
  285. /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,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ class SolidusAdmin::Orders::Cart::Component < SolidusAdmin::BaseComponent
4
+ def initialize(order:)
5
+ @order = order
6
+ end
7
+ end
@@ -0,0 +1,3 @@
1
+ en:
2
+ title: "Cart"
3
+ search_placeholder: "Find a variant by name or SKU"
@@ -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
- <div class="<%= stimulus_id %> px-4">
2
- <header class="py-6 flex items-center">
3
- <h1 class="body-title">
4
- <%= title %>
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
- </div>
16
- </header>
11
+ <% end %>
12
+ <% end %>
17
13
 
18
14
  <%= render component('ui/table').new(
19
- id: 'orders-list',
20
- model_class: Spree::Order,
21
- rows: @page.records,
22
- fade_row_proc: fade_row_proc,
23
- search_key: SolidusAdmin::Config[:order_search_key],
24
- search_url: solidus_admin.orders_path,
25
- batch_actions: batch_actions,
26
- filters: filters,
27
- columns: columns,
28
- prev_page_link: prev_page_link,
29
- next_page_link: next_page_link,
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
- </div>
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 :fade_row_proc, default: ->(order) { order.paid? && order.shipped? }
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 prev_page_link
15
- @page.first? ? nil : solidus_admin.url_for(host: request.host, port: request.port, **request.params, page: @page.number - 1)
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 next_page_link
19
- @page.last? ? nil : solidus_admin.url_for(host: request.host, port: request.port, **request.params, page: @page.next_param)
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
- name: 'q[completed_at_not_null]',
30
- value: 1,
31
- label: t('.filters.only_show_complete_orders'),
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
- order_path = spree.edit_admin_order_path(order)
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
- link_to order.number, order_path
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
- class_name: "w-[400px]",
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&.humanize, color: order.paid? ? :green : :yellow)
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&.humanize, color: order.shipped? ? :green : :yellow)
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
- only_show_complete_orders: Only show complete orders
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,9 @@
1
+ import { Controller } from '@hotwired/stimulus'
2
+
3
+ export default class extends Controller {
4
+ static targets = ["addresses"]
5
+
6
+ close() {
7
+ this.addressesTarget.removeAttribute('open')
8
+ }
9
+ }
@@ -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,7 @@
1
+ import { Controller } from '@hotwired/stimulus'
2
+
3
+ export default class extends Controller {
4
+ closeMenus() {
5
+ this.element.querySelectorAll('details').forEach(details => details.removeAttribute('open'))
6
+ }
7
+ }
@@ -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
+ }
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ class SolidusAdmin::Orders::Show::CustomerSearch::Component < SolidusAdmin::BaseComponent
4
+ def initialize(order:)
5
+ @order = order
6
+ end
7
+ end