spree_backend 4.3.0 → 4.4.0.rc1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (262) hide show
  1. checksums.yaml +4 -4
  2. data/.circleci/config.yml +222 -0
  3. data/.codeclimate.yml +36 -0
  4. data/.editorconfig +22 -0
  5. data/.eslintignore +7 -0
  6. data/.eslintrc.cjs +29 -0
  7. data/.gem_release.yml +4 -0
  8. data/.github/CONTRIBUTING.md +1 -0
  9. data/.github/ISSUE_TEMPLATE/bug_report.md +47 -0
  10. data/.github/ISSUE_TEMPLATE/feature_request.md +20 -0
  11. data/.github/ISSUE_TEMPLATE.md +39 -0
  12. data/.github/dependabot.yml +7 -0
  13. data/.github/workflows/spelling_lint.yml +34 -0
  14. data/.gitignore +63 -0
  15. data/.rubocop.yml +197 -0
  16. data/.solargraph.yml +20 -0
  17. data/.stylelintignore +4 -0
  18. data/.stylelintrc +6 -0
  19. data/CODE_OF_CONDUCT.md +22 -0
  20. data/Gemfile +59 -3
  21. data/README.md +123 -0
  22. data/SECURITY.md +1 -0
  23. data/app/assets/config/spree_backend_manifest.js +1 -1
  24. data/app/assets/images/backend-cloud-arrow-up.svg +4 -0
  25. data/app/assets/images/backend-eye-open.svg +1 -1
  26. data/app/assets/images/backend-file-earmark-font.svg +4 -0
  27. data/app/assets/images/backend-file-earmark-image.svg +4 -0
  28. data/app/assets/images/backend-file-earmark-music.svg +4 -0
  29. data/app/assets/images/backend-file-earmark-pdf.svg +4 -0
  30. data/app/assets/images/backend-file-earmark-play.svg +4 -0
  31. data/app/assets/images/backend-file-earmark-spreadsheet.svg +3 -0
  32. data/app/assets/images/backend-file-earmark-zip.svg +4 -0
  33. data/app/assets/images/backend-file-earmark.svg +3 -0
  34. data/app/assets/images/backend-hdd.svg +4 -0
  35. data/app/assets/images/backend-link.svg +4 -0
  36. data/app/assets/images/backend-view.svg +1 -1
  37. data/app/assets/javascripts/spree/backend/adjustments.js +5 -5
  38. data/app/assets/javascripts/spree/backend/admin.js +4 -6
  39. data/app/assets/javascripts/spree/backend/calculator.js +1 -1
  40. data/app/assets/javascripts/spree/backend/checkouts/edit.js +1 -1
  41. data/app/assets/javascripts/spree/backend/cms/links.es6 +1 -1
  42. data/app/assets/javascripts/spree/backend/cms/live_preview.es6 +1 -1
  43. data/app/assets/javascripts/spree/backend/cms/page.es6 +22 -40
  44. data/app/assets/javascripts/spree/backend/cms/section.es6 +1 -1
  45. data/app/assets/javascripts/spree/backend/gateway.js +1 -1
  46. data/app/assets/javascripts/spree/backend/general_settings.js +1 -1
  47. data/app/assets/javascripts/spree/backend/global/_index.js +3 -1
  48. data/app/assets/javascripts/spree/backend/global/alerts.es6 +1 -1
  49. data/app/assets/javascripts/spree/backend/global/animate_css.es6 +19 -0
  50. data/app/assets/javascripts/spree/backend/global/fetch_request_utility.es6 +114 -0
  51. data/app/assets/javascripts/spree/backend/global/flatpickr.es6 +2 -1
  52. data/app/assets/javascripts/spree/backend/global/info_alert.es6 +1 -1
  53. data/app/assets/javascripts/spree/backend/global/radio_panel_toggle.es6 +1 -1
  54. data/app/assets/javascripts/spree/backend/global/ransack.es6 +7 -5
  55. data/app/assets/javascripts/spree/backend/global/responsive_menus.es6 +1 -1
  56. data/app/assets/javascripts/spree/backend/global/select2_autocomplete.es6 +4 -4
  57. data/app/assets/javascripts/spree/backend/global/select2_populate.es6 +2 -2
  58. data/app/assets/javascripts/spree/backend/global/side_scroll_indication.es6 +2 -2
  59. data/app/assets/javascripts/spree/backend/global/sortable.es6 +1 -1
  60. data/app/assets/javascripts/spree/backend/global/tinymce.es6 +3 -2
  61. data/app/assets/javascripts/spree/backend/line_items.js +7 -9
  62. data/app/assets/javascripts/spree/backend/line_items_on_order_edit.js +23 -28
  63. data/app/assets/javascripts/spree/backend/menus/_index.es6 +0 -1
  64. data/app/assets/javascripts/spree/backend/menus/menu_item.es6 +1 -1
  65. data/app/assets/javascripts/spree/backend/multi_currency.js +2 -2
  66. data/app/assets/javascripts/spree/backend/option_type_autocomplete.js +1 -1
  67. data/app/assets/javascripts/spree/backend/orders/edit.js +1 -1
  68. data/app/assets/javascripts/spree/backend/payments/edit.js +32 -22
  69. data/app/assets/javascripts/spree/backend/payments/new.js +1 -1
  70. data/app/assets/javascripts/spree/backend/product_picker.js +16 -25
  71. data/app/assets/javascripts/spree/backend/progress.js +5 -3
  72. data/app/assets/javascripts/spree/backend/promotions.js +3 -1
  73. data/app/assets/javascripts/spree/backend/returns/expedited_exchanges_warning.js +1 -1
  74. data/app/assets/javascripts/spree/backend/returns/return_item_selection.js +1 -1
  75. data/app/assets/javascripts/spree/backend/shipments.js +80 -79
  76. data/app/assets/javascripts/spree/backend/spree-select2.js +1 -1
  77. data/app/assets/javascripts/spree/backend/states.js +1 -1
  78. data/app/assets/javascripts/spree/backend/stock_location.js +1 -1
  79. data/app/assets/javascripts/spree/backend/stock_management.js +1 -1
  80. data/app/assets/javascripts/spree/backend/stock_movement.js +58 -13
  81. data/app/assets/javascripts/spree/backend/stock_transfer.js +62 -32
  82. data/app/assets/javascripts/spree/backend/taxon_autocomplete.js +9 -8
  83. data/app/assets/javascripts/spree/backend/taxons.js +17 -14
  84. data/app/assets/javascripts/spree/backend/user_picker.js +1 -1
  85. data/app/assets/javascripts/spree/backend/users/edit.js +1 -1
  86. data/app/assets/javascripts/spree/backend/variant_autocomplete.js +19 -11
  87. data/app/assets/javascripts/spree/backend/variant_management.js +1 -1
  88. data/app/assets/javascripts/spree/backend/zone.js +1 -1
  89. data/app/assets/javascripts/spree/backend.js +13 -33
  90. data/app/assets/javascripts/spree.js +2 -9
  91. data/app/assets/stylesheets/spree/backend/components/_main.scss +8 -0
  92. data/app/assets/stylesheets/spree/backend/plugins/_nav_x.scss +1 -1
  93. data/app/assets/stylesheets/spree/backend/plugins/_select2_custom.scss +1 -1
  94. data/app/assets/stylesheets/spree/backend/shared/_forms.scss +1 -1
  95. data/app/assets/stylesheets/spree/backend/shared/_sortable_tree.scss +62 -0
  96. data/app/assets/stylesheets/spree/backend/spree_admin.css.scss +3 -0
  97. data/app/assets/stylesheets/spree/backend/views/_digitals.scss +33 -0
  98. data/app/assets/stylesheets/spree/backend/views/{prototypes.scss → _prototypes.scss} +0 -0
  99. data/app/assets/stylesheets/spree/backend/views/_taxonomies.scss +3 -0
  100. data/app/controllers/spree/admin/base_controller.rb +4 -13
  101. data/app/controllers/spree/admin/digitals_controller.rb +33 -0
  102. data/app/controllers/spree/admin/general_settings_controller.rb +0 -5
  103. data/app/controllers/spree/admin/images_controller.rb +1 -1
  104. data/app/controllers/spree/admin/oauth_applications_controller.rb +17 -0
  105. data/app/controllers/spree/admin/orders/customer_details_controller.rb +2 -2
  106. data/app/controllers/spree/admin/orders_controller.rb +10 -2
  107. data/app/controllers/spree/admin/payment_methods_controller.rb +2 -2
  108. data/app/controllers/spree/admin/payments_controller.rb +1 -1
  109. data/app/controllers/spree/admin/products_controller.rb +4 -2
  110. data/app/controllers/spree/admin/promotions_controller.rb +1 -1
  111. data/app/controllers/spree/admin/properties_controller.rb +1 -1
  112. data/app/controllers/spree/admin/resource_controller.rb +9 -4
  113. data/app/controllers/spree/admin/return_index_controller.rb +1 -1
  114. data/app/controllers/spree/admin/stock_transfers_controller.rb +2 -2
  115. data/app/controllers/spree/admin/store_credits_controller.rb +2 -2
  116. data/app/controllers/spree/admin/stores_controller.rb +2 -2
  117. data/app/controllers/spree/admin/taxons_controller.rb +23 -38
  118. data/app/controllers/spree/admin/users_controller.rb +6 -19
  119. data/app/controllers/spree/admin/variants_controller.rb +1 -2
  120. data/app/controllers/spree/admin/webhooks_subscribers_controller.rb +48 -0
  121. data/app/helpers/spree/admin/base_helper.rb +27 -9
  122. data/app/helpers/spree/admin/digital_helper.rb +28 -0
  123. data/app/helpers/spree/admin/menu_helper.rb +0 -21
  124. data/app/helpers/spree/admin/navigation_helper.rb +19 -9
  125. data/app/helpers/spree/admin/sortable_tree_helper.rb +31 -0
  126. data/app/helpers/spree/admin/stores_helper.rb +1 -1
  127. data/app/helpers/spree/admin/webhooks_subscribers_helper.rb +31 -0
  128. data/app/javascript/spree/dashboard/controllers/clipboard_controller.js +12 -0
  129. data/app/javascript/spree/dashboard/controllers/password_toggle_controller.js +14 -0
  130. data/app/javascript/spree/dashboard/controllers/sortable_tree_controller.js +55 -0
  131. data/app/javascript/spree/dashboard/controllers/spree_controller.js +25 -0
  132. data/app/javascript/spree/dashboard/controllers/upload_button_controller.js +13 -0
  133. data/app/javascript/spree/dashboard/controllers/webhooks_subscriber_events_controller.js +19 -0
  134. data/app/javascript/spree/dashboard/index.js +49 -0
  135. data/app/{assets/javascripts/spree/backend/global/bootstrap.es6 → javascript/spree/dashboard/utilities/bootstrap.js} +6 -2
  136. data/app/javascript/spree/dashboard/utilities/request_utility.js +54 -0
  137. data/app/models/spree/backend_configuration.rb +11 -0
  138. data/app/views/spree/admin/adjustments/_form.html.erb +2 -2
  139. data/app/views/spree/admin/adjustments/index.html.erb +1 -0
  140. data/app/views/spree/admin/cms_pages/_form.html.erb +8 -8
  141. data/app/views/spree/admin/cms_pages/edit.html.erb +1 -6
  142. data/app/views/spree/admin/cms_sections/_form.html.erb +2 -2
  143. data/app/views/spree/admin/cms_sections/types/_featured_article.html.erb +6 -6
  144. data/app/views/spree/admin/cms_sections/types/_hero_image.html.erb +6 -6
  145. data/app/views/spree/admin/cms_sections/types/_image_gallery.html.erb +12 -12
  146. data/app/views/spree/admin/cms_sections/types/_rich_text_content.html.erb +1 -1
  147. data/app/views/spree/admin/cms_sections/types/_side_by_side_images.html.erb +12 -12
  148. data/app/views/spree/admin/countries/_form.html.erb +4 -4
  149. data/app/views/spree/admin/customer_returns/new.html.erb +1 -1
  150. data/app/views/spree/admin/digitals/_form.html.erb +35 -0
  151. data/app/views/spree/admin/digitals/index.html.erb +25 -0
  152. data/app/views/spree/admin/general_settings/edit.html.erb +1 -22
  153. data/app/views/spree/admin/menu_items/_form.html.erb +6 -6
  154. data/app/views/spree/admin/menus/_form.html.erb +3 -3
  155. data/app/views/spree/admin/menus/edit.html.erb +18 -18
  156. data/app/views/spree/admin/oauth_applications/_form.html.erb +22 -0
  157. data/app/views/spree/admin/oauth_applications/create.turbo_stream.erb +38 -0
  158. data/app/views/spree/admin/oauth_applications/edit.html.erb +13 -0
  159. data/app/views/spree/admin/oauth_applications/index.html.erb +51 -0
  160. data/app/views/spree/admin/oauth_applications/new.html.erb +15 -0
  161. data/app/views/spree/admin/option_types/_form.html.erb +3 -3
  162. data/app/views/spree/admin/option_types/_option_value_fields.html.erb +2 -2
  163. data/app/views/spree/admin/orders/_channel_form.html.erb +1 -1
  164. data/app/views/spree/admin/orders/_form.html.erb +1 -0
  165. data/app/views/spree/admin/orders/_line_items_edit_form.html.erb +1 -0
  166. data/app/views/spree/admin/orders/_order_actions.html.erb +6 -0
  167. data/app/views/spree/admin/orders/_search.html.erb +151 -0
  168. data/app/views/spree/admin/orders/index.html.erb +2 -151
  169. data/app/views/spree/admin/payment_methods/_form.html.erb +2 -2
  170. data/app/views/spree/admin/payments/_list.html.erb +1 -1
  171. data/app/views/spree/admin/products/_form.html.erb +19 -19
  172. data/app/views/spree/admin/products/index.html.erb +2 -0
  173. data/app/views/spree/admin/products/new.html.erb +6 -6
  174. data/app/views/spree/admin/promotion_actions/create.js.erb +1 -1
  175. data/app/views/spree/admin/promotion_categories/_form.html.erb +2 -2
  176. data/app/views/spree/admin/promotions/_form.html.erb +5 -5
  177. data/app/views/spree/admin/properties/_form.html.erb +3 -3
  178. data/app/views/spree/admin/prototypes/_form.html.erb +4 -4
  179. data/app/views/spree/admin/refunds/new.html.erb +2 -2
  180. data/app/views/spree/admin/reimbursement_types/_form.html.erb +2 -2
  181. data/app/views/spree/admin/return_authorizations/_form.html.erb +3 -3
  182. data/app/views/spree/admin/roles/_form.html.erb +1 -1
  183. data/app/views/spree/admin/shared/_account_nav.html.erb +1 -1
  184. data/app/views/spree/admin/shared/_address_form.html.erb +4 -4
  185. data/app/views/spree/admin/shared/_head.html.erb +4 -8
  186. data/app/views/spree/admin/shared/_main_menu.html.erb +12 -0
  187. data/app/views/spree/admin/shared/_new_resource_links.html.erb +1 -1
  188. data/app/views/spree/admin/shared/_product_tabs.html.erb +8 -0
  189. data/app/views/spree/admin/shared/_version.html.erb +1 -1
  190. data/app/views/spree/admin/shared/cms/_spree_product.html.erb +2 -2
  191. data/app/views/spree/admin/shared/cms/_spree_taxon.html.erb +2 -2
  192. data/app/views/spree/admin/shared/linkables/_spree_cms_page.erb +2 -2
  193. data/app/views/spree/admin/shared/linkables/_spree_product.html.erb +2 -2
  194. data/app/views/spree/admin/shared/linkables/_spree_taxon.html.erb +2 -2
  195. data/app/views/spree/admin/shared/linkables/_url.html.erb +1 -1
  196. data/app/views/spree/admin/shared/named_types/_form.html.erb +1 -1
  197. data/app/views/spree/admin/{menus/nested_menu_items/_item_bar.html.erb → shared/sortable_tree/_menu.html.erb} +10 -7
  198. data/app/views/spree/admin/shared/sortable_tree/_taxonomy.html.erb +34 -0
  199. data/app/views/spree/admin/shared/sub_menu/_apps.html.erb +3 -0
  200. data/app/views/spree/admin/shared/sub_menu/_integrations.html.erb +3 -0
  201. data/app/views/spree/admin/shipping_categories/_form.html.erb +1 -1
  202. data/app/views/spree/admin/shipping_methods/_form.html.erb +8 -8
  203. data/app/views/spree/admin/states/_form.html.erb +2 -2
  204. data/app/views/spree/admin/stock_locations/_form.html.erb +2 -2
  205. data/app/views/spree/admin/stock_movements/_form.html.erb +3 -3
  206. data/app/views/spree/admin/store_credit_categories/_form.html.erb +1 -1
  207. data/app/views/spree/admin/store_credits/_form.html.erb +4 -4
  208. data/app/views/spree/admin/stores/_form.html.erb +280 -227
  209. data/app/views/spree/admin/tax_categories/_form.html.erb +4 -4
  210. data/app/views/spree/admin/tax_rates/_form.html.erb +4 -3
  211. data/app/views/spree/admin/taxonomies/_form.html.erb +2 -2
  212. data/app/views/spree/admin/taxonomies/edit.html.erb +34 -29
  213. data/app/views/spree/admin/taxons/_form.html.erb +101 -57
  214. data/app/views/spree/admin/taxons/edit.html.erb +6 -3
  215. data/app/views/spree/admin/taxons/index.html.erb +1 -1
  216. data/app/views/spree/admin/taxons/new.html.erb +16 -0
  217. data/app/views/spree/admin/users/_form.html.erb +3 -3
  218. data/app/views/spree/admin/users/edit.html.erb +0 -40
  219. data/app/views/spree/admin/variants/_autocomplete.js.erb +5 -5
  220. data/app/views/spree/admin/variants/_autocomplete_line_items_stock.js.erb +2 -2
  221. data/app/views/spree/admin/variants/_autocomplete_stock.js.erb +6 -6
  222. data/app/views/spree/admin/variants/_split.js.erb +1 -1
  223. data/app/views/spree/admin/variants/index.html.erb +4 -1
  224. data/app/views/spree/admin/webhooks_subscribers/_form.html.erb +101 -0
  225. data/app/views/spree/admin/webhooks_subscribers/edit.html.erb +13 -0
  226. data/app/views/spree/admin/webhooks_subscribers/index.html.erb +47 -0
  227. data/app/views/spree/admin/webhooks_subscribers/new.html.erb +13 -0
  228. data/app/views/spree/admin/webhooks_subscribers/show.html.erb +59 -0
  229. data/app/views/spree/admin/zones/_country_members.html.erb +1 -1
  230. data/app/views/spree/admin/zones/_form.html.erb +2 -2
  231. data/app/views/spree/admin/zones/_state_members.html.erb +1 -1
  232. data/app/views/spree/layouts/admin.html.erb +1 -11
  233. data/codespell.txt +8 -0
  234. data/config/locales/en.yml +273 -0
  235. data/config/routes.rb +6 -2
  236. data/lib/generators/spree/backend/install/install_generator.rb +4 -2
  237. data/lib/generators/spree/backend/install/templates/app/javascript/spree-dashboard.js +7 -0
  238. data/lib/spree/backend/engine.rb +2 -1
  239. data/lib/spree/backend/testing_support/capybara_utils.rb +53 -0
  240. data/lib/spree/backend/testing_support/flash.rb +38 -0
  241. data/lib/spree/backend/testing_support/flatpickr_capybara.rb +126 -0
  242. data/lib/spree/backend/version.rb +9 -0
  243. data/lib/spree/backend.rb +2 -1
  244. data/lib/spree_backend.rb +17 -0
  245. data/license.md +13 -0
  246. data/package.json +46 -0
  247. data/rollup.config.js +41 -0
  248. data/spree_backend.gemspec +17 -16
  249. data/vendor/assets/javascripts/purify.js +1 -1
  250. data/vendor/assets/stylesheets/animate.css +2 -4
  251. data/yarn.lock +959 -0
  252. metadata +120 -38
  253. data/app/assets/javascripts/spree/backend/menus/menu.es6 +0 -57
  254. data/app/assets/javascripts/spree/backend/taxon_permalink_preview.js +0 -11
  255. data/app/assets/javascripts/spree/backend/taxon_tree_menu.js +0 -35
  256. data/app/assets/javascripts/spree/backend/taxonomy.js +0 -178
  257. data/app/views/spree/admin/taxonomies/_js_head.html.erb +0 -7
  258. data/vendor/assets/javascripts/jquery.jstree/jquery.jstree.js +0 -4564
  259. data/vendor/assets/javascripts/js.cookie.js +0 -163
  260. data/vendor/assets/javascripts/modernizr.js +0 -3
  261. data/vendor/assets/stylesheets/jquery.jstree/themes/spree/style.scss +0 -230
  262. data/vendor/assets/stylesheets/jquery.jstree/themes/spree/throbber.gif +0 -0
@@ -3,7 +3,7 @@ module Spree
3
3
  module NavigationHelper
4
4
  # Makes an admin navigation tab (<li> tag) that links to a routing resource under /admin.
5
5
  # The arguments should be a list of symbolized controller names that will cause this tab to
6
- # be highlighted, with the first being the name of the resouce to link (uses URL helpers).
6
+ # be highlighted, with the first being the name of the resource to link (uses URL helpers).
7
7
  #
8
8
  # Option hash may follow. Valid options are
9
9
  # * :label to override link text, otherwise based on the first resource name (translated)
@@ -22,13 +22,18 @@ module Spree
22
22
  options = { label: args.first.to_s }
23
23
 
24
24
  # Return if resource is found and user is not allowed to :admin
25
- return '' if (klass = klass_for(options[:label])) && cannot?(:admin, klass)
25
+ return '' if (klass = klass_for(args.first.to_s)) && cannot?(:admin, klass)
26
26
 
27
27
  options = options.merge(args.pop) if args.last.is_a?(Hash)
28
28
  options[:route] ||= "admin_#{args.first}"
29
29
 
30
30
  destination_url = options[:url] || spree.send("#{options[:route]}_path")
31
- titleized_label = Spree.t(options[:label], default: options[:label], scope: [:admin, :tab]).titleize
31
+
32
+ if options[:do_not_titleize] == true
33
+ titleized_label = options[:label]
34
+ else
35
+ titleized_label = Spree.t(options[:label], default: options[:label], scope: [:admin, :tab]).titleize
36
+ end
32
37
 
33
38
  css_classes = ['sidebar-menu-item d-block w-100 position-relative']
34
39
 
@@ -88,13 +93,13 @@ module Spree
88
93
  # this method generates the select_tag
89
94
  def per_page_dropdown
90
95
  # there is a config setting for admin_products_per_page, only for the orders page
91
- if @products && per_page_default = Spree::Config.admin_products_per_page
96
+ if @products && per_page_default = Spree::Backend::Config.admin_products_per_page
92
97
  per_page_options = []
93
98
  5.times do |amount|
94
- per_page_options << (amount + 1) * Spree::Config.admin_products_per_page
99
+ per_page_options << (amount + 1) * Spree::Backend::Config.admin_products_per_page
95
100
  end
96
101
  else
97
- per_page_default = Spree::Config.admin_orders_per_page
102
+ per_page_default = Spree::Backend::Config.admin_orders_per_page
98
103
  per_page_options = %w{25 50 75}
99
104
  end
100
105
 
@@ -199,11 +204,13 @@ module Spree
199
204
  end
200
205
  text = "#{icon} #{text}"
201
206
  end
207
+
208
+ css_classes = options[:class] || 'btn-primary'
202
209
  button_tag(
203
210
  text.html_safe,
204
211
  options.merge(
205
212
  type: button_type,
206
- class: "btn btn-primary #{options[:class]}",
213
+ class: "btn #{css_classes}",
207
214
  'data-disable-with' => "#{Spree.t(:saving)}..."
208
215
  )
209
216
  )
@@ -262,6 +269,9 @@ module Spree
262
269
  end
263
270
 
264
271
  def main_part_classes
272
+ ActiveSupport::Deprecation.warn(<<-DEPRECATION, caller)
273
+ Admin::NavigationHelper#main_part_classes is deprecated and will be removed in Spree 5.0.
274
+ DEPRECATION
265
275
  if cookies['sidebar-minimized'] == 'true'
266
276
  'col-12 sidebar-collapsed'
267
277
  else
@@ -271,7 +281,7 @@ module Spree
271
281
 
272
282
  def main_sidebar_classes
273
283
  ActiveSupport::Deprecation.warn(<<-DEPRECATION, caller)
274
- Admin::NavigationsHelper#main_sidebar_classes is deprecated and will be removed in Spree 5.0.
284
+ Admin::NavigationHelper#main_sidebar_classes is deprecated and will be removed in Spree 5.0.
275
285
  DEPRECATION
276
286
  if cookies['sidebar-minimized'] == 'true'
277
287
  'col-3 col-md-2 sidebar'
@@ -282,7 +292,7 @@ module Spree
282
292
 
283
293
  def wrapper_classes
284
294
  ActiveSupport::Deprecation.warn(<<-DEPRECATION, caller)
285
- Admin::NavigationsHelper#wrapper_classes is deprecated and will be removed in Spree 5.0.
295
+ Admin::NavigationHelper#wrapper_classes is deprecated and will be removed in Spree 5.0.
286
296
  DEPRECATION
287
297
  'sidebar-minimized' if cookies['sidebar-minimized'] == 'true'
288
298
  end
@@ -0,0 +1,31 @@
1
+ module Spree
2
+ module Admin
3
+ module SortableTreeHelper
4
+ def sortable_tree_bar(parent_resource, child_resource)
5
+ partial_name = parent_resource.class.name.demodulize.underscore
6
+ render "spree/admin/shared/sortable_tree/#{partial_name}", parent_resource: parent_resource, child_resource: child_resource
7
+ end
8
+
9
+ def build_sortable_tree(parent_resource, child_resource)
10
+ child_resource_name = child_resource.class.name.demodulize.underscore
11
+ descendants = []
12
+
13
+ unless child_resource.leaf?
14
+ child_resource.children.each do |child_item|
15
+ descendants << build_sortable_tree(parent_resource, child_item) unless child_resource.leaf?
16
+ end
17
+ end
18
+
19
+ row = sortable_tree_bar(parent_resource, child_resource)
20
+ container = content_tag(:div, raw(descendants.join), data: { sortable_tree_parent_id_value: child_resource.id })
21
+
22
+ content_tag(:div, row + container,
23
+ class: 'sortable-tree-item draggable removable-dom-element',
24
+ data: {
25
+ sortable_tree_resource_name_value: child_resource_name.singularize,
26
+ sortable_tree_update_url_value: "/api/v2/platform/#{child_resource_name.pluralize}/#{child_resource.id}/reposition"
27
+ })
28
+ end
29
+ end
30
+ end
31
+ end
@@ -23,7 +23,7 @@ module Spree
23
23
  end
24
24
 
25
25
  link_to icon + store.unique_name, url_for(host: store.formatted_url),
26
- class: "#{classes} text-dark p-3 dropdown-item", id: store.code
26
+ class: "#{classes} text-dark p-3 dropdown-item", id: store.code, data: { turbo: false }
27
27
  end
28
28
  end
29
29
  end
@@ -0,0 +1,31 @@
1
+ module Spree
2
+ module Admin
3
+ module WebhooksSubscribersHelper
4
+ def event_checkbox_for(resource_name, form)
5
+ content_tag :div, class: 'col-xs-12 col-sm-6 col-md-4 col-lg-4 form-group' do
6
+ content_tag :div, class: 'custom-control custom-switch' do
7
+ (form.check_box resource_name, event_checkbox_opts(resource_name), true, nil) + ' ' +
8
+ form.label(resource_name, Spree.t("admin.webhooks_subscribers.#{resource_name.to_s.pluralize}"), class: 'custom-control-label')
9
+ end
10
+ end
11
+ end
12
+
13
+ def subscribe_to_all_events?
14
+ @webhooks_subscriber.new_record? || @webhooks_subscriber.subscriptions == ['*']
15
+ end
16
+
17
+ private
18
+
19
+ def event_checkbox_opts(resource_name)
20
+ {
21
+ class: 'events-checkbox custom-control-input',
22
+ checked: subscribed_to_resource?(resource_name)
23
+ }
24
+ end
25
+
26
+ def subscribed_to_resource?(resource_name)
27
+ @webhooks_subscriber.subscriptions&.any? { |event| event.include? "#{resource_name}." }
28
+ end
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,12 @@
1
+ import { Controller } from "@hotwired/stimulus"
2
+
3
+ export default class extends Controller {
4
+ static targets = [ "source" ]
5
+
6
+ copy(event) {
7
+ console.log(event)
8
+ event.preventDefault()
9
+ this.sourceTarget.select()
10
+ document.execCommand("copy")
11
+ }
12
+ }
@@ -0,0 +1,14 @@
1
+ import { Controller } from "@hotwired/stimulus"
2
+
3
+ export default class extends Controller {
4
+ static targets = ["unhide"]
5
+
6
+ password(e) {
7
+ if (this.unhideTarget.type === "password") {
8
+ this.unhideTarget.type = "text"
9
+ } else {
10
+ this.unhideTarget.type = "password"
11
+ }
12
+ }
13
+ }
14
+
@@ -0,0 +1,55 @@
1
+ import { Controller } from "@hotwired/stimulus"
2
+ import { Sortable } from "sortablejs"
3
+ import { patch } from "../utilities/request_utility"
4
+
5
+ export default class extends Controller {
6
+ static values = { handle: String }
7
+
8
+ connect() {
9
+ const itemSortable = {
10
+ ...this.options
11
+ }
12
+
13
+ let containers = null
14
+ containers = this.element.querySelectorAll("[data-sortable-tree-parent-id-value]")
15
+
16
+ for (let i = 0; i < containers.length; i++) {
17
+ new Sortable(containers[i], itemSortable)
18
+ }
19
+ }
20
+
21
+ async end({ item, newIndex, to }) {
22
+ if (!item.dataset.sortableTreeUpdateUrlValue) return
23
+
24
+ const data = {
25
+ [item.dataset.sortableTreeResourceNameValue]: {
26
+ new_parent_id: to.dataset.sortableTreeParentIdValue,
27
+ new_position_idx: newIndex
28
+ }
29
+ }
30
+
31
+ const response = await patch(item.dataset.sortableTreeUpdateUrlValue, { body: data })
32
+
33
+ if (!response.ok) {
34
+ show_flash("error", "This move could not be saved.")
35
+ }
36
+ }
37
+
38
+ get options() {
39
+ return {
40
+ group: {
41
+ name: "sortable-tree",
42
+ pull: true,
43
+ put: true
44
+ },
45
+ handle: this.handleValue || undefined,
46
+ swapThreshold: 0.5,
47
+ emptyInsertThreshold: 8,
48
+ dragClass: "item-dragged",
49
+ draggable: ".draggable",
50
+ animation: 350,
51
+ forceFallback: false,
52
+ onEnd: this.end
53
+ }
54
+ }
55
+ }
@@ -0,0 +1,25 @@
1
+ import { Controller } from "@hotwired/stimulus"
2
+
3
+ export default class extends Controller {
4
+ connect() {
5
+
6
+ // This is a hack to allow legacy JavaScript to run in a Turbo enabled environment.
7
+ // Once all JavaScript is reduced to Stimulus controllers, this can be removed.
8
+ const event = new Event("spree:load")
9
+ document.dispatchEvent(event)
10
+
11
+ // The Issue
12
+ // If you initiate common JavaScript with an event listener of "turbo:load"
13
+ // This will work, but if someone submits an update to a field that is required,
14
+ // a 442 Unprocessable entity is returned, and a render event is used render the errors in place.
15
+
16
+ // Because this in not a successful "turbo:load" event, all common JavaScript will fail.
17
+ // You could set up a separate listener for "turbo:render", but this can cause duplicate loading.
18
+ // Using a Stimulus connect() is the correct way to go, but should be phased out as JavaScript is replaced
19
+ // With Hotwire Frames and dedicated Stimulus controllers for the JavaScript you have remaining.
20
+
21
+ // References:
22
+ // https://github.com/hotwired/turbo-rails/issues/12#issuecomment-915893233
23
+ // https://github.com/hotwired/turbo/issues/85#issuecomment-756259687
24
+ }
25
+ }
@@ -0,0 +1,13 @@
1
+ import { Controller } from "@hotwired/stimulus"
2
+
3
+ export default class extends Controller {
4
+ static targets = [ "uploadButton"]
5
+
6
+ initialize() {
7
+ this.uploadButtonTarget.disabled = true
8
+ }
9
+
10
+ buttonState() {
11
+ this.uploadButtonTarget.disabled = false
12
+ }
13
+ }
@@ -0,0 +1,19 @@
1
+ import { Controller } from "@hotwired/stimulus"
2
+
3
+ export default class extends Controller {
4
+ static targets = [ "eventsCheckboxesContainer", "subscribeToAll" ]
5
+
6
+ hideCheckboxes() {
7
+ this.eventsCheckboxesContainerTarget.hidden = true
8
+ }
9
+
10
+ showCheckboxes() {
11
+ this.eventsCheckboxesContainerTarget.hidden = false
12
+ }
13
+
14
+ initialize() {
15
+ if (this.subscribeToAllTarget.checked) {
16
+ this.hideCheckboxes()
17
+ }
18
+ }
19
+ }
@@ -0,0 +1,49 @@
1
+ //
2
+ // Initialize Dashboard
3
+ class Dashboard {
4
+ constructor() {
5
+ console.log("Spree Dashboard Initialized")
6
+ }
7
+ }
8
+
9
+ //
10
+ // Import JavaScript packages that are required globally.
11
+ import { Application } from "@hotwired/stimulus"
12
+ import flatpickr from "flatpickr"
13
+ import * as Turbo from "@hotwired/turbo"
14
+
15
+ // To disable Turbo, un-comment the line below.
16
+ // Turbo.session.drive = false
17
+
18
+ //
19
+ // Import Utility JavaScript required globally.
20
+ import "./utilities/bootstrap"
21
+
22
+ //
23
+ // Stimulus - Setup
24
+ const application = Application.start()
25
+ application.debug = false
26
+ window.Stimulus = application
27
+
28
+ // Stimulus - Spree Controllers
29
+ import UploadButtonController from "./controllers/upload_button_controller"
30
+ application.register("upload-button", UploadButtonController)
31
+
32
+ import SpreeController from "./controllers/spree_controller"
33
+ application.register("spree", SpreeController)
34
+
35
+ import SortableTreeController from "./controllers/sortable_tree_controller"
36
+ application.register("sortable-tree", SortableTreeController)
37
+
38
+ import WebhooksSubscriberEventsController from "./controllers/webhooks_subscriber_events_controller"
39
+ application.register("webhooks_subscriber_events", WebhooksSubscriberEventsController)
40
+
41
+ import PasswordToggleController from "./controllers/password_toggle_controller"
42
+ application.register("password-toggle", PasswordToggleController)
43
+
44
+ import ClipboardController from "./controllers/clipboard_controller"
45
+ application.register("clipboard", ClipboardController)
46
+
47
+ //
48
+ // Export
49
+ export { Dashboard, application, flatpickr, Turbo }
@@ -1,6 +1,10 @@
1
- // Use this file for Boostrap customization applied across the Spree Backend
1
+ import jquery from 'jquery'
2
+ import 'bootstrap'
3
+ import 'popper.js'
2
4
 
3
- document.addEventListener('DOMContentLoaded', function() {
5
+ const $ = jquery
6
+
7
+ document.addEventListener("spree:load", function() {
4
8
  $('.with-tip').each(function() {
5
9
  $(this).tooltip({
6
10
  container: $(this)
@@ -0,0 +1,54 @@
1
+ import { RequestInterceptor } from "@rails/request.js"
2
+ import { FetchRequest } from "@rails/request.js"
3
+ import { navigator } from "@hotwired/turbo"
4
+
5
+ //
6
+ // Inject Authorization & Content-Type into @rails/request.js requests.
7
+ RequestInterceptor.register(async (request) => {
8
+ request.addHeader("Authorization", `Bearer ${OAUTH_TOKEN}`)
9
+ })
10
+
11
+ //
12
+ // Setup Turbo Progress bar on @rails/request.js requests.
13
+ export function showProgressBar() {
14
+ navigator.delegate.adapter.progressBar.setValue(0)
15
+ navigator.delegate.adapter.progressBar.show()
16
+ }
17
+
18
+ export function hideProgressBar() {
19
+ navigator.delegate.adapter.progressBar.setValue(1)
20
+ navigator.delegate.adapter.progressBar.hide()
21
+ }
22
+
23
+ export function withProgress(request) {
24
+ new Promise(resolve => {
25
+ showProgressBar()
26
+ resolve(request.then(hideProgressBar))
27
+ })
28
+ return request
29
+ }
30
+
31
+ export function get (url, options) {
32
+ const request = new FetchRequest("get", url, options)
33
+ return withProgress(request.perform())
34
+ }
35
+
36
+ export function post (url, options) {
37
+ const request = new FetchRequest("post", url, options)
38
+ return withProgress(request.perform())
39
+ }
40
+
41
+ export function put (url, options) {
42
+ const request = new FetchRequest("put", url, options)
43
+ return withProgress(request.perform())
44
+ }
45
+
46
+ export function patch (url, options) {
47
+ const request = new FetchRequest("patch", url, options)
48
+ return withProgress(request.perform())
49
+ }
50
+
51
+ export function destroy (url, options) {
52
+ const request = new FetchRequest("delete", url, options)
53
+ return withProgress(request.perform())
54
+ }
@@ -1,8 +1,19 @@
1
1
  module Spree
2
2
  class BackendConfiguration < Preferences::Configuration
3
+ preference :admin_path, :string, default: '/admin'
4
+ preference :admin_products_per_page, :integer, default: Kaminari.config.default_per_page
5
+ preference :admin_orders_per_page, :integer, default: Kaminari.config.default_per_page
6
+ preference :admin_properties_per_page, :integer, default: Kaminari.config.default_per_page
7
+ preference :admin_promotions_per_page, :integer, default: Kaminari.config.default_per_page
8
+ preference :admin_customer_returns_per_page, :integer, default: Kaminari.config.default_per_page
9
+ preference :admin_users_per_page, :integer, default: Kaminari.config.default_per_page
10
+ preference :admin_show_version, :boolean, default: true
3
11
  preference :locale, :string, default: Rails.application.config.i18n.default_locale
4
12
  preference :variants_per_page, :integer, default: Kaminari.config.default_per_page
5
13
  preference :menus_per_page, :integer, default: Kaminari.config.default_per_page
14
+ preference :product_wysiwyg_editor_enabled, :boolean, default: true
15
+ preference :taxon_wysiwyg_editor_enabled, :boolean, default: true
16
+ preference :show_only_complete_orders_by_default, :boolean, default: true
6
17
 
7
18
  ORDER_TABS ||= [:orders, :payments, :creditcard_payments,
8
19
  :shipments, :credit_cards, :return_authorizations,
@@ -1,10 +1,10 @@
1
1
  <div data-hook="admin_adjustment_form_fields">
2
- <%= f.field_container :amount, class: ['form-group'] do %>
2
+ <%= f.field_container :amount do %>
3
3
  <%= f.label :amount, raw(Spree.t(:amount) + required_span_tag) %>
4
4
  <%= text_field :adjustment, :amount, class: 'form-control' %>
5
5
  <%= f.error_message_on :amount %>
6
6
  <% end %>
7
- <%= f.field_container :label, class: ['form-group'] do %>
7
+ <%= f.field_container :label do %>
8
8
  <%= f.label :label, raw(Spree.t(:description) + required_span_tag) %>
9
9
  <%= text_field :adjustment, :label, class: 'form-control' %>
10
10
  <%= f.error_message_on :label %>
@@ -31,6 +31,7 @@
31
31
 
32
32
  <script>
33
33
  var order_number = '<%= @order.number %>';
34
+ var order_id = '<%= @order.id %>';
34
35
  </script>
35
36
 
36
37
  <%= render partial: 'spree/admin/shared/order_summary' %>
@@ -6,7 +6,7 @@
6
6
  <div class="card-header col-12">
7
7
  <div class="row no-gutters pb-0">
8
8
  <div class="col d-flex justify-content-start align-items-center">
9
- <%= f.field_container :visible, class: ['form-group pb-0 mb-0'] do %>
9
+ <%= f.field_container :visible, class: ['pb-0 mb-0'] do %>
10
10
  <div class="custom-control custom-switch custom-switch-md">
11
11
  <%= f.check_box :visible, class: 'custom-control-input', data: {cms_page_id: @cms_page.id} %>
12
12
  <label class="custom-control-label" for="cms_page_visible"></label>
@@ -36,13 +36,13 @@
36
36
  <div class="card-body pb-2">
37
37
  <div class="row pb-0">
38
38
 
39
- <%= f.field_container :title, class: ['form-group col-12 col-md-6'] do %>
39
+ <%= f.field_container :title, class: ['col-12 col-md-6'] do %>
40
40
  <%= f.label :title, raw(Spree.t('admin.cms.title') + required_span_tag) %>
41
41
  <%= f.text_field :title, class: 'form-control', required: true %>
42
42
  <%= f.error_message_on :title %>
43
43
  <% end %>
44
44
 
45
- <%= f.field_container :type, class: ['form-group col-12 col-md-6'] do %>
45
+ <%= f.field_container :type, class: ['col-12 col-md-6'] do %>
46
46
  <%= f.label :type, Spree.t('admin.cms.page_type') %>
47
47
  <%= f.select(:type, spree_humanize_dropdown_values('Spree::CmsPage', {const: 'TYPES'}), {include_blank: false}, class: 'select2') %>
48
48
  <%= f.error_message_on :type %>
@@ -61,19 +61,19 @@
61
61
  <div class="<% unless %w[new create].include? controller.action_name %>collapse<% end %>" id="cmsPageSettings">
62
62
  <div class="row pb-0">
63
63
  <div class="col-12"><hr></div>
64
- <%= f.field_container :locale, class: ['form-group col-12 col-md-4'] do %>
64
+ <%= f.field_container :locale, class: ['col-12 col-md-4'] do %>
65
65
  <%= f.label :language %>
66
66
  <%= f.select :locale, options_from_collection_for_select(supported_locales_options, :last, :first, @cms_page.locale || I18n.locale), {}, { class: 'select2' } %>
67
67
  <%= f.error_message_on :default_locale %>
68
68
  <% end %>
69
69
 
70
- <%= f.field_container :meta_title, class: ['form-group col-12 col-md-4'] do %>
70
+ <%= f.field_container :meta_title, class: ['col-12 col-md-4'] do %>
71
71
  <%= f.label :meta_title, Spree.t('admin.cms.meta_title') %>
72
72
  <%= f.text_field :meta_title, class: 'form-control' %>
73
73
  <%= f.error_message_on :meta_title %>
74
74
  <% end %>
75
75
 
76
- <%= f.field_container :slug, class: ['form-group col-12 col-md-4'] do %>
76
+ <%= f.field_container :slug, class: ['col-12 col-md-4'] do %>
77
77
  <div id="noHomePage">
78
78
  <%= f.label :slug, Spree.t('slug') %>
79
79
  <%= f.text_field :slug, class: 'form-control', disabled: @cms_page.homepage? %>
@@ -81,7 +81,7 @@
81
81
  </div>
82
82
  <% end %>
83
83
 
84
- <%= f.field_container :meta_description, class: ['form-group col-12'] do %>
84
+ <%= f.field_container :meta_description, class: ['col-12'] do %>
85
85
  <%= f.label :meta_description, Spree.t('admin.cms.meta_description') %>
86
86
  <%= f.text_area :meta_description, { rows: 3, class: 'form-control' } %>
87
87
  <%= f.error_message_on :meta_description %>
@@ -123,7 +123,7 @@
123
123
  <% if @cms_page.type == 'Spree::Cms::Pages::StandardPage' %>
124
124
  <div class="row">
125
125
  <div class="col-12">
126
- <%= f.field_container :content, class: ['form-group'] do %>
126
+ <%= f.field_container :content do %>
127
127
  <%= f.text_area :content, { rows: 22, class: 'spree-rte'} %>
128
128
  <%= f.error_message_on :content %>
129
129
  <% end %>
@@ -3,12 +3,7 @@
3
3
  <% end %>
4
4
 
5
5
  <% content_for :page_actions do %>
6
- <%= button_link_to(Spree.t('admin.cms.preview_page'),
7
- cms_page_preview_url(@cms_page),
8
- class: 'btn-outline-secondary',
9
- icon: 'view.svg',
10
- id: 'admin_preview_product',
11
- target: :blank) %>
6
+ <%= external_page_preview_link(@cms_page, { name: Spree.t('admin.cms.page') }) %>
12
7
  <% end %>
13
8
 
14
9
  <%= render partial: 'spree/admin/shared/error_messages', locals: { target: @cms_page } %>
@@ -1,14 +1,14 @@
1
1
  <div data-hook="admin_cms_section_form_fields">
2
2
  <div class="row">
3
3
  <div class="col-12 col-md-6">
4
- <%= f.field_container :name, class: ['form-group'] do %>
4
+ <%= f.field_container :name do %>
5
5
  <%= f.label :name, raw(Spree.t(:name) + required_span_tag) %>
6
6
  <%= f.text_field :name, class: 'form-control', required: true, autocomplete: false %>
7
7
  <%= f.error_message_on :name %>
8
8
  <% end %>
9
9
  </div>
10
10
  <div class="col-12 col-md-6">
11
- <%= f.field_container :type, class: ['form-group'] do %>
11
+ <%= f.field_container :type do %>
12
12
  <%= f.label :type, Spree.t('admin.cms.section_type') %>
13
13
  <%= f.select(:type, spree_humanize_dropdown_values('Spree::CmsSection', {const: 'TYPES'}), {include_blank: false}) %>
14
14
  <%= f.error_message_on :type %>
@@ -1,24 +1,24 @@
1
1
  <div class="row">
2
2
  <div class="col-12 col-md-4">
3
- <%= f.field_container :title, class: ['form-group'] do %>
3
+ <%= f.field_container :title do %>
4
4
  <%= f.label :title, Spree.t('admin.cms.title') %>
5
5
  <%= f.text_field :title, class: 'form-control' %>
6
6
  <%= f.error_message_on :title %>
7
7
  <% end %>
8
8
 
9
- <%= f.field_container :subtitle, class: ['form-group'] do %>
9
+ <%= f.field_container :subtitle do %>
10
10
  <%= f.label :subtitle, Spree.t('admin.cms.subtitle') %>
11
11
  <%= f.text_field :subtitle, class: 'form-control' %>
12
12
  <%= f.error_message_on :subtitle %>
13
13
  <% end %>
14
14
 
15
- <%= f.field_container :button_text, class: ['form-group'] do %>
15
+ <%= f.field_container :button_text do %>
16
16
  <%= f.label :button_text, Spree.t('admin.cms.button_text') %>
17
17
  <%= f.text_field :button_text, class: 'form-control' %>
18
18
  <%= f.error_message_on :button_text %>
19
19
  <% end %>
20
20
 
21
- <%= f.field_container :gutters, class: ['form-group'] do %>
21
+ <%= f.field_container :gutters do %>
22
22
  <%= f.label :gutters, Spree.t('admin.cms.gutters') %>
23
23
  <%= f.select(:gutters, @cms_section.gutters_sizes, {include_blank: false}, class: 'select2') %>
24
24
  <%= f.error_message_on :gutters %>
@@ -26,7 +26,7 @@
26
26
 
27
27
  </div>
28
28
  <div class="col-12 col-md-8">
29
- <%= f.field_container :rte_content, class: ['form-group'] do %>
29
+ <%= f.field_container :rte_content do %>
30
30
  <%= f.label :rte_content, Spree.t('admin.cms.content') %>
31
31
  <%= f.text_area :rte_content, { rows: "20", class: 'form-control spree-rte' } %>
32
32
  <%= f.error_message_on :rte_content %>
@@ -34,7 +34,7 @@
34
34
  </div>
35
35
  <div class="col-12"><hr></div>
36
36
  <div class="col-12 col-md-6">
37
- <%= f.field_container :linked_resource_type, class: ['form-group'] do %>
37
+ <%= f.field_container :linked_resource_type do %>
38
38
  <%= f.label :linked_resource_type, Spree.t('admin.navigation.link_to') %>
39
39
  <%= f.select(:linked_resource_type,
40
40
  spree_humanize_dropdown_values('Spree::Cms::Sections::FeaturedArticle',